Skip to content

Commit

Permalink
Merge pull request #217 from kookmin-sw/feature/be/#130-like-answer-r…
Browse files Browse the repository at this point in the history
…edis

Feature/be/#130 추천시 request body 요청 수정 + 추천 여부 null 반환 수정
  • Loading branch information
BlueBerrySoda authored May 17, 2024
2 parents 6df5e9b + b6a5640 commit be41d9e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ public ResponseEntity<ApiResult<Integer>> eraseAnswer( @Parameter(description
@ApiResponse(responseCode = "200", description = "완료시 200을 반환합니다.")
public ResponseEntity<ApiResult<Integer>> upLikeCount(@RequestHeader("X-User-ID") String userId,
@Parameter(description = "추천할 댓글의 id가 필요합니다.", required = true)
@RequestParam Long id) {
likeService.likeAnswer(userId, id);
answerService.increaseLikeCountById(id);
@RequestBody LikeRequest id) {
likeService.likeAnswer(userId, id.answerId());
answerService.increaseLikeCountById(id.answerId());

return ResponseEntity
.ok(new ApiResult<>("Successfully like answer", 200));
Expand All @@ -80,9 +80,9 @@ public ResponseEntity<ApiResult<Integer>> upLikeCount(@RequestHeader("X-User-ID"
@ApiResponse(responseCode = "200", description = "완료시 200을 반환합니다.")
public ResponseEntity<ApiResult<Integer>> downLikeCount(@RequestHeader("X-User-ID") String userId,
@Parameter(description = "추천 해제할 댓글의 id가 필요합니다.", required = true)
@RequestParam Long id) {
likeService.unlikeAnswer(userId, id);
answerService.decreaseLikeCountById(id);
@RequestBody LikeRequest id) {
likeService.unlikeAnswer(userId, id.answerId());
answerService.decreaseLikeCountById(id.answerId());

return ResponseEntity
.ok(new ApiResult<>("Successfully unlike answer", 200));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.example.capstone.domain.qna.dto;

public record LikeRequest(
Long answerId
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public AnswerSliceResponse getAnswerListByPaging(Long cursorId, Pageable page, L
.select(
Projections.constructor(AnswerListResponse.class, answer.id, answer.question.id,
answer.author, answer.context,
answer.likeCount, like.isClick.isTrue(), answer.createdDate, answer.updatedDate, answer.uuid)
answer.likeCount, like.isClick.coalesce(false).as("likeCheck"), answer.createdDate, answer.updatedDate, answer.uuid)
)
.from(answer)
.innerJoin(answer.question, question)
Expand Down

0 comments on commit be41d9e

Please sign in to comment.