Skip to content

Commit f5943dd

Browse files
Merge pull request #333 from Podo-Store/develop
feat: 대본 좋아요 여부 전달
2 parents 01b0d6e + 393b3e2 commit f5943dd

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

src/main/java/PodoeMarket/podoemarket/product/controller/ProductController.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,4 +130,14 @@ public ResponseEntity<StreamingResponseBody> scriptView(@RequestParam("script")
130130
return ResponseEntity.badRequest().body((StreamingResponseBody) resDTO);
131131
}
132132
}
133+
134+
@GetMapping("/likeStatus/{id}")
135+
public ResponseEntity<?> likeStatus(@AuthenticationPrincipal UserEntity userInfo, @PathVariable UUID id) {
136+
try{
137+
return ResponseEntity.ok().body(productService.getLikeStatus(userInfo, id));
138+
} catch(Exception e) {
139+
ResponseDTO resDTO = ResponseDTO.builder().error(e.getMessage()).build();
140+
return ResponseEntity.badRequest().body(resDTO);
141+
}
142+
}
133143
}

src/main/java/PodoeMarket/podoemarket/product/service/ProductService.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,18 @@ public ResponseEntity<StreamingResponseBody> generateFullScriptDirect(String pre
208208
.body(streamingResponseBody);
209209
}
210210

211+
public boolean getLikeStatus(final UserEntity userInfo, final UUID productId) {
212+
try {
213+
if (userInfo == null)
214+
return false;
215+
216+
return productLikeRepo.existsByUserAndProductId(userInfo, productId);
217+
} catch (Exception e) {
218+
log.error("좋아요 상태 확인 중 오류 발생: userId={}, productId={}, error={}",
219+
userInfo != null ? userInfo.getId() : "null", productId, e.getMessage());
220+
return false; // 오류 발생 시 좋아요하지 않은 것으로 처리
221+
}
222+
}
211223

212224
// ============== private (protected) method ===============
213225
private Sort createSort(SortType sortType) {
@@ -351,17 +363,4 @@ else if(isBuyScript && isExpiryDate && isBuyPerformance) { // 공연권만 보
351363
}
352364

353365
}
354-
355-
private boolean getLikeStatus(final UserEntity userInfo, final UUID productId) {
356-
try {
357-
if (userInfo == null)
358-
return false;
359-
360-
return productLikeRepo.existsByUserAndProductId(userInfo, productId);
361-
} catch (Exception e) {
362-
log.error("좋아요 상태 확인 중 오류 발생: userId={}, productId={}, error={}",
363-
userInfo != null ? userInfo.getId() : "null", productId, e.getMessage());
364-
return false; // 오류 발생 시 좋아요하지 않은 것으로 처리
365-
}
366-
}
367366
}

0 commit comments

Comments
 (0)