Skip to content

Commit

Permalink
[refactor] 취소로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiwon committed Jul 29, 2023
1 parent 75e3746 commit dc71e2f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,17 +161,18 @@ public ResponseEntity<List<CopyRes>> searchFilterCard(HttpServletRequest httpReq


// 카피라이팅 스크랩 취소 (soft delete)
@PostMapping ("/scrap/cancel")
public ResponseEntity<String> cancelScrap(HttpServletRequest httpRequest, @RequestBody CopyReq copyReq){
@PostMapping ("/scrap/cancle")
public ResponseEntity<HttpRes<String>> cancelScrap(HttpServletRequest httpRequest, @RequestBody CopyReq copyReq){
User user = jwtTokenProvider.getUserInfoByToken(httpRequest);
Long cardId = copyReq.getCardId();
Card card = cardRepository.findCardById(cardId);
boolean is_canceled = copyService.cancelScrap(user, card);
if(is_canceled){
return ResponseEntity.status(HttpStatus.OK).body("삭제되었습니다.");
return ResponseEntity.ok(new HttpRes<>("해당 스크랩을 삭제했습니다."));
}
else{
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("스크랩 정보가 유효하지 않습니다.");
String errorMessage = "스크랩 정보가 유효하지 않습니다.";
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(new HttpRes<>(HttpStatus.BAD_REQUEST.value(), errorMessage));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public interface ScrapRepository extends JpaRepository<Scrap, Long> {
@Override
List<Scrap> findAll();

List<Scrap> findScrapByUser(User user);
List<Scrap> findScrapByUser(User user); //여기서 최신순으로 가져오게

List<Scrap> findByCardId(Long id); // 카드 식별번호로 스크랩 객체 찾기

Expand Down

0 comments on commit dc71e2f

Please sign in to comment.