From dc71e2f63edbfaa26b8df3108dc836d041da58cb Mon Sep 17 00:00:00 2001 From: Jiwon Date: Sat, 29 Jul 2023 17:20:20 +0900 Subject: [PATCH] =?UTF-8?q?[refactor]=20=EC=B7=A8=EC=86=8C=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shop/hooking/hooking/controller/CopyController.java | 9 +++++---- .../shop/hooking/hooking/repository/ScrapRepository.java | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/shop/hooking/hooking/controller/CopyController.java b/src/main/java/shop/hooking/hooking/controller/CopyController.java index 85b6311..bc86a2f 100644 --- a/src/main/java/shop/hooking/hooking/controller/CopyController.java +++ b/src/main/java/shop/hooking/hooking/controller/CopyController.java @@ -161,17 +161,18 @@ public ResponseEntity> searchFilterCard(HttpServletRequest httpReq // 카피라이팅 스크랩 취소 (soft delete) - @PostMapping ("/scrap/cancel") - public ResponseEntity cancelScrap(HttpServletRequest httpRequest, @RequestBody CopyReq copyReq){ + @PostMapping ("/scrap/cancle") + public ResponseEntity> 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)); } } diff --git a/src/main/java/shop/hooking/hooking/repository/ScrapRepository.java b/src/main/java/shop/hooking/hooking/repository/ScrapRepository.java index a8fdcb1..d9b2a17 100644 --- a/src/main/java/shop/hooking/hooking/repository/ScrapRepository.java +++ b/src/main/java/shop/hooking/hooking/repository/ScrapRepository.java @@ -14,7 +14,7 @@ public interface ScrapRepository extends JpaRepository { @Override List findAll(); - List findScrapByUser(User user); + List findScrapByUser(User user); //여기서 최신순으로 가져오게 List findByCardId(Long id); // 카드 식별번호로 스크랩 객체 찾기