Skip to content

Commit

Permalink
chore: 불필요한 코드 삭제
Browse files Browse the repository at this point in the history
- memberService.getMemberByEmail(memberEmail) 호출에서 이미 null 처리를 진행하므로 해당 함수 호출 이후 멤버에 대한 null 체크 삭제
- 주석 처리한 함수 삭제
- 디버깅용 출력문 일괄 삭제
  • Loading branch information
yeonjae02 committed Aug 2, 2024
1 parent 8d44fdc commit e497b18
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<ConstraintViolation<PostRequestDto>> violations = validator.validate(postRequestDto);
if (!violations.isEmpty()) {
Expand Down Expand Up @@ -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("게시글을 성공적으로 삭제하였습니다.");
Expand All @@ -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<MultipartFile> 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,
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -329,9 +324,6 @@ protected List<Image> addForUpdateImages(Post post, Member member, List<Multipar

int idx = 0;

// Debug: 초기 idx 값 출력
System.out.println("Initial idx = " + idx);

if (!postImages.isEmpty()) {
try {
for (MultipartFile postImage : postImages) {
Expand All @@ -347,9 +339,6 @@ protected List<Image> addForUpdateImages(Post post, Member member, List<Multipar
order = post.getImages().size() + idx + 1; // 기존 이미지 개수 + 현재 추가된 이미지 순서
}

// Debug: 현재 이미지의 order 값 출력
System.out.println("Order for new image = " + order);

Image image = Image.builder()
.imageUrl(postImageUrl).member(member).post(post)
.order(order)
Expand All @@ -375,8 +364,6 @@ protected void updateImageOrders(List<Image> images) {

int order = 1;
for (Image image : images) {
System.out.println("image.getImageUrl() = " + image.getImageUrl());
System.out.println("order = " + order);
image.setOrder(order++);
}

Expand All @@ -397,7 +384,6 @@ protected List<Integer> deleteImagesWithUrl(List<String> images, Long postId) {
List<Integer> deleteImageIdx = new ArrayList<>();
for (String imageUrl : images) {
Integer idx = imageRepository.findOrderByImageUrlAndPostId(imageUrl, postId);
System.out.println("remove idx = " + idx);
if (idx != null) {
s3Service.delete(imageUrl);
imageRepository.deleteImageByImageUrlAndPostId(imageUrl, postId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ public ResponseEntity<Object> saveHistory(Authentication authentication,
String neighborhood = request.getNeighborhood();
List<PlaceDtoV2> searchHistoryRequestDtos = request.getHistoryDto();

System.out.println("ssearchHistoryRequestDtos.size()= " +searchHistoryRequestDtos.size());
for (PlaceDtoV2 searchHistoryRequestDto : searchHistoryRequestDtos) {
System.out.println("searchHistoryRequestDto = " + searchHistoryRequestDto.getPlaceId());
}

// neighborhood 검증
if (neighborhood == null || neighborhood.trim().isEmpty()) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public void save(String neighborhood, String memberEmail, List<PlaceDtoV2> place
.neighborhood(neighborhood)
.build();

System.out.println("placeDtos.size() = " + placeDtos.size());
for (PlaceDtoV2 dto : placeDtos) {
String imageUrl = dto.getImageUrl();
if (imageUrl == null || imageUrl.trim().isEmpty()) { // 이미지 url이 없거나 공백
Expand All @@ -51,7 +50,6 @@ public void save(String neighborhood, String memberEmail, List<PlaceDtoV2> place
.searchHistory(searchHistory) // searchHistory 필드 설정
.build();
searchHistory.getPlaceList().add(placeInfo);
System.out.println("placeInfo = " + placeInfo);
}
searchHistoryRepository.save(searchHistory);
}
Expand Down

0 comments on commit e497b18

Please sign in to comment.