Skip to content

Commit

Permalink
refactor: 폐기물 관심 추가 또는 삭제 반환값 변경
Browse files Browse the repository at this point in the history
- like -> true
- unlike -> false
  • Loading branch information
garamv20 committed May 1, 2024
1 parent 38df979 commit ee71283
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import freshtrash.freshtrashbackend.dto.constants.LikeStatus;
import freshtrash.freshtrashbackend.dto.request.ReviewRequest;
import freshtrash.freshtrashbackend.dto.request.WasteRequest;
import freshtrash.freshtrashbackend.dto.response.ApiResponse;
import freshtrash.freshtrashbackend.dto.response.ReviewResponse;
import freshtrash.freshtrashbackend.dto.response.WasteResponse;
import freshtrash.freshtrashbackend.dto.security.MemberPrincipal;
Expand Down Expand Up @@ -138,19 +139,19 @@ private ResponseEntity<ReviewResponse> addWasteReview(
* 폐기물 관심 추가 또는 삭제
*/
@PostMapping("/{wasteId}/likes")
public ResponseEntity<Void> addOrDeleteWasteLike(
public ResponseEntity<ApiResponse<Boolean>> addOrDeleteWasteLike(
@RequestParam LikeStatus likeStatus,
@PathVariable Long wasteId,
@AuthenticationPrincipal MemberPrincipal memberPrincipal) {
checkIfNotWriter(memberPrincipal, wasteId);

Boolean isLike = likeStatus == LikeStatus.LIKE;
if (likeStatus == LikeStatus.LIKE) {
wasteService.addWasteLike(memberPrincipal.id(), wasteId);
} else if (likeStatus == LikeStatus.UNLIKE) {
wasteService.deleteWasteLike(memberPrincipal.id(), wasteId);
}

return ResponseEntity.status(HttpStatus.NO_CONTENT).body(null);
return ResponseEntity.status(HttpStatus.OK).body(ApiResponse.of(isLike));
}

/**
Expand Down

0 comments on commit ee71283

Please sign in to comment.