From e497b18669a0d32e3b4687e283158076f056dde5 Mon Sep 17 00:00:00 2001 From: yeonjae02 <0yeonjae2@naver.com> Date: Sat, 3 Aug 2024 02:29:33 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C?= =?UTF-8?q?=20=EC=BD=94=EB=93=9C=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - memberService.getMemberByEmail(memberEmail) 호출에서 이미 null 처리를 진행하므로 해당 함수 호출 이후 멤버에 대한 null 체크 삭제 - 주석 처리한 함수 삭제 - 디버깅용 출력문 일괄 삭제 --- .../community_board/api/PostController.java | 48 ------------------- .../community_board/service/PostService.java | 14 ------ .../api/SearchHistoryControllerV2.java | 5 -- .../service/SearchHistoryServiceV2.java | 2 - 4 files changed, 69 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 1ac857c..d1331a4 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 @@ -153,9 +153,6 @@ public ResponseEntity createPost(Authentication authentication, String memberEmail = authentication.getName(); Member member = memberService.getMemberByEmail(memberEmail); - if (member == null) { - return ResponseEntity.status(HttpStatus.NOT_FOUND).body("사용자를 찾을 수 없습니다."); - } Set> violations = validator.validate(postRequestDto); if (!violations.isEmpty()) { @@ -237,9 +234,6 @@ public ResponseEntity deletePost(@PathVariable Long postId, Authentication au String memberEmail = authentication.getName(); Member member = memberService.getMemberByEmail(memberEmail); - if (member == null) { - return ResponseEntity.status(HttpStatus.NOT_FOUND).body("사용자를 찾을 수 없습니다."); - } postService.deletePost(member, postId); return ResponseEntity.status(HttpStatus.NO_CONTENT).body("게시글을 성공적으로 삭제하였습니다."); @@ -253,45 +247,6 @@ public ResponseEntity deletePost(@PathVariable Long postId, Authentication au } } -// @PatchMapping(value = "/{postId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) -// public ResponseEntity updatePost(@PathVariable Long postId, -// Authentication authentication, -// @RequestPart("postDto") String postUpdateDtoJson, -// @RequestPart(value = "postImages", required = false) List postImages) throws JsonProcessingException { -// try{ -// PostUpdateDto postUpdateDto = objectMapper.readValue(postUpdateDtoJson, PostUpdateDto.class); -// -// if (authentication == null || !authentication.isAuthenticated()) { -// return ResponseEntity.status(HttpStatus.UNAUTHORIZED) -// .body("해당 서비스를 이용하기 위해서는 로그인이 필요합니다."); -// } -// -// String memberEmail = authentication.getName(); -// Member member = memberService.getMemberByEmail(memberEmail); -// if (member == null) { -// return ResponseEntity.status(HttpStatus.NOT_FOUND).body("사용자를 찾을 수 없습니다."); -// } -// -// postUpdateDto.validate(); // 제목, 본문, 해시태그 검증 -// -// if (postImages != null && !postImages.isEmpty() && postImages.size() > 3) { // 이미지 변경이 있는 경우 -// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("이미지는 최대 3장까지 업로드 가능합니다."); -// } -// -// postService.updatePost(postId, postUpdateDto, member, postImages); -// -// return ResponseEntity.status(HttpStatus.OK).body("게시글을 성공적으로 수정했습니다."); -// } catch (EntityNotFoundException e) { -// return ResponseEntity.status(HttpStatus.NOT_FOUND).body("해당 게시글이 존재하지 않습니다."); -// } catch (AccessDeniedException e) { -// return ResponseEntity.status(HttpStatus.FORBIDDEN).body(e.getMessage()); -// } catch (RuntimeException e) { -// return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(e.getMessage()); -// } catch (Exception e) { -// return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("게시글 수정 중 오류가 발생하였습니다." + e.getMessage()); -// } -// } - @PatchMapping(value = "/{postId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) public ResponseEntity updatePost(@PathVariable Long postId, Authentication authentication, @@ -307,9 +262,6 @@ public ResponseEntity updatePost(@PathVariable Long postId, String memberEmail = authentication.getName(); Member member = memberService.getMemberByEmail(memberEmail); - if (member == null) { - return ResponseEntity.status(HttpStatus.NOT_FOUND).body("사용자를 찾을 수 없습니다."); - } int nowImageCnt = postService.getPostById(postId, member).getImages().size(); int validImageCnt = 0; diff --git a/src/main/java/com/solucitation/midpoint_backend/domain/community_board/service/PostService.java b/src/main/java/com/solucitation/midpoint_backend/domain/community_board/service/PostService.java index 75b4559..7a9833a 100644 --- a/src/main/java/com/solucitation/midpoint_backend/domain/community_board/service/PostService.java +++ b/src/main/java/com/solucitation/midpoint_backend/domain/community_board/service/PostService.java @@ -301,11 +301,6 @@ public void updatePost(Long postId, PostUpdateDto postUpdateDto, Member member, } } - // Debug: 정렬된 이미지 리스트 출력 - for (Image image : existImages) { - System.out.println(image.getOrder() + " : " + image.getImageUrl()); - } - post = Post.builder() .id(post.getId()) .member(post.getMember()) @@ -329,9 +324,6 @@ protected List addForUpdateImages(Post post, Member member, List