Skip to content

Commit

Permalink
chore:불필요한 코드 삭제 및 http 반환 타입 형식화
Browse files Browse the repository at this point in the history
  • Loading branch information
yeonjae02 committed Aug 3, 2024
1 parent 15c42dd commit fc8b3aa
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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", "게시글 삭제 중 오류가 발생하였습니다."));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,6 @@ public ResponseEntity<Object> 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<SearchHistoryResponseDtoV2> searchHistoryResponseDtos = searchHistoryService.getHistory(member);
return ResponseEntity.ok(searchHistoryResponseDtos);
Expand All @@ -120,4 +116,30 @@ public ResponseEntity<Object> 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", "검색 기록 삭제 중 오류가 발생하였습니다."));
// }
// }
}

0 comments on commit fc8b3aa

Please sign in to comment.