From fc8b3aa2b9727d98f02c371e87016115cbe01060 Mon Sep 17 00:00:00 2001 From: yeonjae02 <0yeonjae2@naver.com> Date: Sat, 3 Aug 2024 21:08:28 +0900 Subject: [PATCH] =?UTF-8?q?chore:=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C=20=EB=B0=8F=20http=20?= =?UTF-8?q?=EB=B0=98=ED=99=98=20=ED=83=80=EC=9E=85=20=ED=98=95=EC=8B=9D?= =?UTF-8?q?=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../community_board/api/PostController.java | 3 +- .../api/SearchHistoryControllerV2.java | 30 ++++++++++++++++--- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/solucitation/midpoint_backend/domain/community_board/api/PostController.java b/src/main/java/com/solucitation/midpoint_backend/domain/community_board/api/PostController.java index c5b4cb3..a4af9dd 100644 --- a/src/main/java/com/solucitation/midpoint_backend/domain/community_board/api/PostController.java +++ b/src/main/java/com/solucitation/midpoint_backend/domain/community_board/api/PostController.java @@ -245,7 +245,8 @@ public ResponseEntity deletePost(@PathVariable Long postId, Authentication au return ResponseEntity.status(HttpStatus.NOT_FOUND) .body(Map.of("error", "POST_NOT_FOUND", "message", "해당 게시글이 존재하지 않습니다.")); } catch (AccessDeniedException e) { - return ResponseEntity.status(HttpStatus.FORBIDDEN).body(e.getMessage()); + return ResponseEntity.status(HttpStatus.FORBIDDEN) + .body(Map.of("error", "FORBIDDEN", "message", e.getMessage())); } catch (Exception e) { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) .body(Map.of("error", e.getMessage(), "message", "게시글 삭제 중 오류가 발생하였습니다.")); diff --git a/src/main/java/com/solucitation/midpoint_backend/domain/history2/api/SearchHistoryControllerV2.java b/src/main/java/com/solucitation/midpoint_backend/domain/history2/api/SearchHistoryControllerV2.java index 1ca022b..e645f7e 100644 --- a/src/main/java/com/solucitation/midpoint_backend/domain/history2/api/SearchHistoryControllerV2.java +++ b/src/main/java/com/solucitation/midpoint_backend/domain/history2/api/SearchHistoryControllerV2.java @@ -107,10 +107,6 @@ public ResponseEntity getHistory(Authentication authentication) { String memberEmail = authentication.getName(); Member member = memberService.getMemberByEmail(memberEmail); - if (member == null) { - return ResponseEntity.status(HttpStatus.NOT_FOUND) - .body(Map.of("error", "USER_NOT_FOUND", "message", "사용자를 찾을 수 없습니다.")); - } List searchHistoryResponseDtos = searchHistoryService.getHistory(member); return ResponseEntity.ok(searchHistoryResponseDtos); @@ -120,4 +116,30 @@ public ResponseEntity getHistory(Authentication authentication) { } } +// /** +// * 검색 기록을 일괄 삭제합니다. (내부용) +// * @param authentication 인증 정보 +// * @return +// * 삭제 성공 시 204 NO_CONTENT를 반환합니다. +// * 로그인하지 않은 계정일 경우 401 UNAUTHORIZED 를 반환합니다. +// * 기타 오류 발생 시 500 INTERNAL_SERVER_ERROR 를 반환합니다. +// */ +// @DeleteMapping("/all") +// public ResponseEntity removeAll(Authentication authentication) { +// try { +// if (authentication == null || !authentication.isAuthenticated()) { +// return ResponseEntity.status(HttpStatus.UNAUTHORIZED) +// .body(Map.of("error", "UNAUTHORIZED", "message", "해당 서비스를 이용하기 위해서는 로그인이 필요합니다.")); +// } +// +// String memberEmail = authentication.getName(); +// Member member = memberService.getMemberByEmail(memberEmail); +// +// searchHistoryService.removeAll(member); +// return ResponseEntity.status(HttpStatus.NO_CONTENT).body(Map.of("message", "감색 기록을 일괄 삭제하였습니다.")); +// } catch (Exception e) { +// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR) +// .body(Map.of("error", e.getMessage(), "message", "검색 기록 삭제 중 오류가 발생하였습니다.")); +// } +// } } \ No newline at end of file