From 65979445feea2876459922aa72ad5b4141460cb8 Mon Sep 17 00:00:00 2001 From: kangseungmin Date: Wed, 14 Aug 2024 21:02:12 +0900 Subject: [PATCH 1/7] =?UTF-8?q?[fix]=20DiscountDto=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/discountinfo/dto/DiscountRequest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/dto/DiscountRequest.java b/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/dto/DiscountRequest.java index 490565bf..66a145ed 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/dto/DiscountRequest.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/dto/DiscountRequest.java @@ -10,7 +10,7 @@ public class DiscountRequest { @Builder @NoArgsConstructor @AllArgsConstructor - public static class RegisterDto { + public static class RegisterDiscountDto { private String title; @@ -29,7 +29,7 @@ public static class RegisterDto { @Builder @NoArgsConstructor @AllArgsConstructor - public static class UpdateDto { + public static class UpdateDiscountDto { private Long id; From 7037acd5bee293c4ef999dfa68502b8c1513801e Mon Sep 17 00:00:00 2001 From: kangseungmin Date: Wed, 14 Aug 2024 21:02:18 +0900 Subject: [PATCH 2/7] =?UTF-8?q?[fix]=20SupportDto=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../budgetbuddies/domain/supportinfo/dto/SupportRequest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/dto/SupportRequest.java b/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/dto/SupportRequest.java index a9ba1405..e63b7bc1 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/dto/SupportRequest.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/dto/SupportRequest.java @@ -14,7 +14,7 @@ public class SupportRequest { @Builder @NoArgsConstructor @AllArgsConstructor - public static class RegisterDto { + public static class RegisterSupportDto { private String title; @@ -32,7 +32,7 @@ public static class RegisterDto { @Builder @NoArgsConstructor @AllArgsConstructor - public static class UpdateDto { + public static class UpdateSupportDto { private Long id; From 691f52030a72da82de54400de0dc293214c9c6f2 Mon Sep 17 00:00:00 2001 From: kangseungmin Date: Wed, 14 Aug 2024 21:02:24 +0900 Subject: [PATCH 3/7] =?UTF-8?q?[fix]=20UserDto=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/bbteam/budgetbuddies/domain/user/dto/UserDto.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/user/dto/UserDto.java b/src/main/java/com/bbteam/budgetbuddies/domain/user/dto/UserDto.java index 7dd580d3..b1913d9e 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/user/dto/UserDto.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/user/dto/UserDto.java @@ -15,7 +15,7 @@ public class UserDto { @Getter @Builder - public static class RegisterDto { + public static class RegisterUserDto { @Length(min = 11, message = "전화번호 11자리를 입력해주세요.") private String phoneNumber; private String name; @@ -29,7 +29,7 @@ public static class RegisterDto { @Getter @Builder - public static class ResponseDto { + public static class ResponseUserDto { private Long id; private String phoneNumber; private String name; From 0edeee6bf27d2de55e4f222ebb0696c642401cbc Mon Sep 17 00:00:00 2001 From: kangseungmin Date: Wed, 14 Aug 2024 21:07:52 +0900 Subject: [PATCH 4/7] =?UTF-8?q?[fix]=20CommentDto=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../comment/controller/CommentController.java | 58 ++++++------- .../controller/CommentControllerApi.java | 26 +++--- .../comment/converter/CommentConverter.java | 12 +-- .../domain/comment/dto/CommentRequestDto.java | 6 +- .../comment/dto/CommentResponseDto.java | 5 +- .../comment/service/CommentService.java | 9 +- .../comment/service/CommentServiceTestV2.java | 86 +++++++++---------- 7 files changed, 95 insertions(+), 107 deletions(-) diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/comment/controller/CommentController.java b/src/main/java/com/bbteam/budgetbuddies/domain/comment/controller/CommentController.java index 8254f21e..d071fec8 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/comment/controller/CommentController.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/comment/controller/CommentController.java @@ -6,12 +6,10 @@ import com.bbteam.budgetbuddies.domain.comment.service.CommentService; import com.bbteam.budgetbuddies.domain.comment.validation.ExistComment; import com.bbteam.budgetbuddies.domain.user.validation.ExistUser; -import jakarta.validation.Valid; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; import org.springframework.data.web.PageableDefault; -import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -20,53 +18,53 @@ public class CommentController implements CommentControllerApi { @Qualifier("discountCommentService") - private final CommentService discountCommentService; + private final CommentService discountCommentService; @Qualifier("supportCommentService") - private final CommentService supportCommentService; + private final CommentService supportCommentService; - public CommentController(CommentService discountCommentService, - CommentService supportCommentService) { + public CommentController(CommentService discountCommentService, + CommentService supportCommentService) { this.discountCommentService = discountCommentService; this.supportCommentService = supportCommentService; } @PostMapping("/discounts/comments") - public ApiResponse saveDiscountInfoComment( + public ApiResponse saveDiscountInfoComment( @RequestParam("userId") @ExistUser Long userId, - @RequestBody CommentRequestDto.DiscountInfoCommentDto discountInfoCommentDto){ - CommentResponseDto.DiscountInfoCommentDto dto = discountCommentService.saveComment(userId, discountInfoCommentDto); + @RequestBody CommentRequestDto.DiscountInfoCommentRequestDto discountInfoCommentRequestDto){ + CommentResponseDto.DiscountInfoCommentResponseDto dto = discountCommentService.saveComment(userId, discountInfoCommentRequestDto); return ApiResponse.onSuccess(dto); } @GetMapping("/discounts/{discountInfoId}/comments") - public ApiResponse> findAllByDiscountInfo( + public ApiResponse> findAllByDiscountInfo( @PathVariable("discountInfoId") Long discountInfoId, @PageableDefault(size = 20, page = 0) Pageable pageable){ - Page result = discountCommentService.findByInfoWithPaging(discountInfoId, pageable); + Page result = discountCommentService.findByInfoWithPaging(discountInfoId, pageable); return ApiResponse.onSuccess(result); } @PostMapping("/supports/comments") - public ApiResponse saveSupportInfoComment( + public ApiResponse saveSupportInfoComment( @RequestParam("userId") @ExistUser Long userId, - @RequestBody CommentRequestDto.SupportInfoCommentDto supportInfoCommentDto){ - CommentResponseDto.SupportInfoCommentDto dto = supportCommentService.saveComment(userId, supportInfoCommentDto); + @RequestBody CommentRequestDto.SupportInfoCommentRequestDto supportInfoCommentRequestDto){ + CommentResponseDto.SupportInfoCommentResponseDto dto = supportCommentService.saveComment(userId, supportInfoCommentRequestDto); return ApiResponse.onSuccess(dto); } @GetMapping("/supports/{supportInfoId}/comments") - public ApiResponse> findAllBySupportInfo( + public ApiResponse> findAllBySupportInfo( @PathVariable("supportInfoId") Long supportInfoId, @PageableDefault(size = 20, page = 0)Pageable pageable){ - Page result = supportCommentService.findByInfoWithPaging(supportInfoId, pageable); + Page result = supportCommentService.findByInfoWithPaging(supportInfoId, pageable); return ApiResponse.onSuccess(result); } @@ -77,28 +75,28 @@ public ApiResponse deleteComment(@PathVariable("commentId") @ExistCommen } @GetMapping("/supports/comments/getOne/{commentId}") - public ApiResponse findSupportOne(@PathVariable("commentId")Long commentId) { - CommentResponseDto.SupportInfoCommentDto result = supportCommentService.findCommentOne(commentId); + public ApiResponse findSupportOne(@PathVariable("commentId")Long commentId) { + CommentResponseDto.SupportInfoCommentResponseDto result = supportCommentService.findCommentOne(commentId); return ApiResponse.onSuccess(result); } @PutMapping("/supports/comments/modify") - public ApiResponse modifySupportOne( - @RequestBody CommentRequestDto.CommentModifyDto dto) { - CommentResponseDto.SupportInfoCommentDto result = supportCommentService.modifyComment(dto); + public ApiResponse modifySupportOne( + @RequestBody CommentRequestDto.CommentModifyRequestDto dto) { + CommentResponseDto.SupportInfoCommentResponseDto result = supportCommentService.modifyComment(dto); return ApiResponse.onSuccess(result); } @GetMapping("/discounts/comments/getOne/{commentId}") - public ApiResponse findDiscountOne(@PathVariable("commentId")Long commentId) { - CommentResponseDto.DiscountInfoCommentDto result = discountCommentService.findCommentOne(commentId); + public ApiResponse findDiscountOne(@PathVariable("commentId")Long commentId) { + CommentResponseDto.DiscountInfoCommentResponseDto result = discountCommentService.findCommentOne(commentId); return ApiResponse.onSuccess(result); } @PutMapping("/discounts/comments/modify") - public ApiResponse modifyDiscountOne( - @RequestBody CommentRequestDto.CommentModifyDto dto) { - CommentResponseDto.DiscountInfoCommentDto result = discountCommentService.modifyComment(dto); + public ApiResponse modifyDiscountOne( + @RequestBody CommentRequestDto.CommentModifyRequestDto dto) { + CommentResponseDto.DiscountInfoCommentResponseDto result = discountCommentService.modifyComment(dto); return ApiResponse.onSuccess(result); } diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/comment/controller/CommentControllerApi.java b/src/main/java/com/bbteam/budgetbuddies/domain/comment/controller/CommentControllerApi.java index 9054b374..87c0b0a7 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/comment/controller/CommentControllerApi.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/comment/controller/CommentControllerApi.java @@ -10,10 +10,8 @@ import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.responses.ApiResponses; -import jakarta.validation.Valid; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; -import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; @@ -30,9 +28,9 @@ public interface CommentControllerApi { @Parameter(name = "discountInfoId", description = "댓글을 다는 할인 정보 게시글 id입니다. requestBody"), @Parameter(name = "content", description = "댓글 내용입니다. requestBody"), }) - ApiResponse saveDiscountInfoComment( + ApiResponse saveDiscountInfoComment( @ExistUser Long userId, - CommentRequestDto.DiscountInfoCommentDto discountInfoCommentDto); + CommentRequestDto.DiscountInfoCommentRequestDto discountInfoCommentRequestDto); @Operation(summary = "[User] 특정 할인 정보 게시글의 댓글 조회하기", description = "특정 할인 정보 게시글의 댓글을 가져오는 API입니다.") @@ -44,7 +42,7 @@ ApiResponse saveDiscountInfoComment( @Parameter(name = "page", description = "페이징을 위한 페이지 번호입니다. 0부터 시작합니다. parameter"), @Parameter(name = "size", description = "페이징을 위한 페이지 사이즈입니다. default는 20입니다. parameter") }) - ApiResponse> findAllByDiscountInfo( + ApiResponse> findAllByDiscountInfo( Long discountInfoId, Pageable pageable); @@ -57,9 +55,9 @@ ApiResponse> findAllByDiscountIn @Parameter(name = "supportInfoId", description = "댓글을 다는 지원 정보 게시글 id입니다. requestBody"), @Parameter(name = "content", description = "댓글 내용입니다. requestBody"), }) - ApiResponse saveSupportInfoComment( + ApiResponse saveSupportInfoComment( @ExistUser Long userId, - CommentRequestDto.SupportInfoCommentDto supportInfoCommentDto); + CommentRequestDto.SupportInfoCommentRequestDto supportInfoCommentRequestDto); @Operation(summary = "[User] 특정 지원 정보 게시글의 댓글 조회하기", description = "특정 지원 정보 게시글의 댓글을 가져오는 API입니다.") @ApiResponses({ @@ -72,7 +70,7 @@ ApiResponse saveSupportInfoComment( }) - ApiResponse> findAllBySupportInfo( + ApiResponse> findAllBySupportInfo( Long supportInfoId, Pageable pageable); @@ -92,7 +90,7 @@ ApiResponse> findAllBySupportInfo @Parameters({ @Parameter(name = "commentId", description = "조회할 댓글 id 입니다. pathVariable") }) - ApiResponse findSupportOne(@RequestParam("commentId")Long commentId); + ApiResponse findSupportOne(@RequestParam("commentId")Long commentId); @Operation(summary = "[User] SupportInfo의 댓글 변경 API", description = "특정 댓글을 변경하는 API입니다.") @ApiResponses({ @@ -103,8 +101,8 @@ ApiResponse> findAllBySupportInfo @Parameter(name = "content", description = "변경할 댓글 내용입니다.. requestbody") }) - ApiResponse modifySupportOne( - @RequestBody CommentRequestDto.CommentModifyDto dto); + ApiResponse modifySupportOne( + @RequestBody CommentRequestDto.CommentModifyRequestDto dto); @Operation(summary = "[User] DiscountInfo의 특정 댓글 요청 API", description = "특정 댓글을 요청하는 API입니다.") @@ -114,7 +112,7 @@ ApiResponse modifySupportOne( @Parameters({ @Parameter(name = "commentId", description = "조회할 댓글 id 입니다. pathVariable") }) - ApiResponse findDiscountOne(@RequestParam("commentId")Long commentId); + ApiResponse findDiscountOne(@RequestParam("commentId")Long commentId); @Operation(summary = "[User] DiscountInfo의 댓글 변경 API", description = "특정 댓글을 변경하는 API입니다.") @ApiResponses({ @@ -125,7 +123,7 @@ ApiResponse modifySupportOne( @Parameter(name = "content", description = "변경할 댓글 내용입니다.. requestbody") }) - ApiResponse modifyDiscountOne( - @RequestBody CommentRequestDto.CommentModifyDto dto); + ApiResponse modifyDiscountOne( + @RequestBody CommentRequestDto.CommentModifyRequestDto dto); } diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/comment/converter/CommentConverter.java b/src/main/java/com/bbteam/budgetbuddies/domain/comment/converter/CommentConverter.java index 8e424e50..9e5b79d6 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/comment/converter/CommentConverter.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/comment/converter/CommentConverter.java @@ -9,7 +9,7 @@ public class CommentConverter { - public static Comment toDiscountComment(CommentRequestDto.DiscountInfoCommentDto dto, User user, DiscountInfo discountInfo, + public static Comment toDiscountComment(CommentRequestDto.DiscountInfoCommentRequestDto dto, User user, DiscountInfo discountInfo, Integer anonymousNumber) { return Comment.builder() .user(user) @@ -19,7 +19,7 @@ public static Comment toDiscountComment(CommentRequestDto.DiscountInfoCommentDto .build(); } - public static Comment toSupportComment(CommentRequestDto.SupportInfoCommentDto dto, User user, SupportInfo supportInfo, + public static Comment toSupportComment(CommentRequestDto.SupportInfoCommentRequestDto dto, User user, SupportInfo supportInfo, Integer anonymousNumber) { return Comment.builder() .user(user) @@ -29,8 +29,8 @@ public static Comment toSupportComment(CommentRequestDto.SupportInfoCommentDto d .build(); } - public static CommentResponseDto.DiscountInfoCommentDto toDiscountInfoCommentDto(Comment comment){ - return CommentResponseDto.DiscountInfoCommentDto.builder() + public static CommentResponseDto.DiscountInfoCommentResponseDto toDiscountInfoCommentDto(Comment comment){ + return CommentResponseDto.DiscountInfoCommentResponseDto.builder() .commentId(comment.getId()) .discountInfoId(comment.getDiscountInfo().getId()) .userId(comment.getUser().getId()) @@ -41,8 +41,8 @@ public static CommentResponseDto.DiscountInfoCommentDto toDiscountInfoCommentDto } - public static CommentResponseDto.SupportInfoCommentDto toSupportInfoCommentDto(Comment comment){ - return CommentResponseDto.SupportInfoCommentDto.builder() + public static CommentResponseDto.SupportInfoCommentResponseDto toSupportInfoCommentDto(Comment comment){ + return CommentResponseDto.SupportInfoCommentResponseDto.builder() .commentId(comment.getId()) .supportInfoId(comment.getSupportInfo().getId()) .userId(comment.getUser().getId()) diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/comment/dto/CommentRequestDto.java b/src/main/java/com/bbteam/budgetbuddies/domain/comment/dto/CommentRequestDto.java index 9b516614..ae354563 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/comment/dto/CommentRequestDto.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/comment/dto/CommentRequestDto.java @@ -7,21 +7,21 @@ public class CommentRequestDto { @Getter @Builder - public static class DiscountInfoCommentDto { + public static class DiscountInfoCommentRequestDto { private String content; private Long discountInfoId; } @Getter @Builder - public static class SupportInfoCommentDto { + public static class SupportInfoCommentRequestDto { private String content; private Long supportInfoId; } @Getter @Builder - public static class CommentModifyDto { + public static class CommentModifyRequestDto { private String content; private Long commentId; } diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/comment/dto/CommentResponseDto.java b/src/main/java/com/bbteam/budgetbuddies/domain/comment/dto/CommentResponseDto.java index 48931147..2fdeceff 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/comment/dto/CommentResponseDto.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/comment/dto/CommentResponseDto.java @@ -5,14 +5,13 @@ import lombok.Builder; import lombok.Getter; -import java.time.LocalDate; import java.time.LocalDateTime; public class CommentResponseDto { @Getter @Builder - public static class DiscountInfoCommentDto{ + public static class DiscountInfoCommentResponseDto { private Long commentId; private Long userId; private Long discountInfoId; @@ -24,7 +23,7 @@ public static class DiscountInfoCommentDto{ @Getter @Builder - public static class SupportInfoCommentDto{ + public static class SupportInfoCommentResponseDto { private Long commentId; private Long userId; private Long supportInfoId; diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/comment/service/CommentService.java b/src/main/java/com/bbteam/budgetbuddies/domain/comment/service/CommentService.java index 29661e29..98426d60 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/comment/service/CommentService.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/comment/service/CommentService.java @@ -1,19 +1,12 @@ package com.bbteam.budgetbuddies.domain.comment.service; -import com.bbteam.budgetbuddies.domain.comment.converter.CommentConverter; import com.bbteam.budgetbuddies.domain.comment.dto.CommentRequestDto; -import com.bbteam.budgetbuddies.domain.comment.dto.CommentResponseDto; import com.bbteam.budgetbuddies.domain.comment.entity.Comment; -import com.bbteam.budgetbuddies.domain.discountinfo.entity.DiscountInfo; -import com.bbteam.budgetbuddies.domain.user.entity.User; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; -import org.springframework.transaction.annotation.Transactional; import java.util.List; -import java.util.NoSuchElementException; import java.util.Optional; -import java.util.stream.Collectors; public interface CommentService { @@ -33,7 +26,7 @@ public interface CommentService { - T modifyComment(CommentRequestDto.CommentModifyDto dto); + T modifyComment(CommentRequestDto.CommentModifyRequestDto dto); Optional findById(Long commentId); } diff --git a/src/test/java/com/bbteam/budgetbuddies/domain/comment/service/CommentServiceTestV2.java b/src/test/java/com/bbteam/budgetbuddies/domain/comment/service/CommentServiceTestV2.java index ff919466..da975e72 100644 --- a/src/test/java/com/bbteam/budgetbuddies/domain/comment/service/CommentServiceTestV2.java +++ b/src/test/java/com/bbteam/budgetbuddies/domain/comment/service/CommentServiceTestV2.java @@ -73,7 +73,7 @@ public void saveDiscountInfoCommentTest(){ .build(); discountInfoRepository.save(sale1); - CommentRequestDto.DiscountInfoCommentDto dto1 = CommentRequestDto.DiscountInfoCommentDto.builder() + CommentRequestDto.DiscountInfoCommentRequestDto dto1 = CommentRequestDto.DiscountInfoCommentRequestDto.builder() .discountInfoId(sale1.getId()) .content("굿") .build(); @@ -81,7 +81,7 @@ public void saveDiscountInfoCommentTest(){ discountCommentService.saveComment(user1.getId(), dto1); em.flush(); - List returnDto = discountCommentService.findByInfo(sale1.getId()); + List returnDto = discountCommentService.findByInfo(sale1.getId()); Assertions.assertThat(returnDto.size()).isEqualTo(1); Assertions.assertThat(returnDto.get(0).getDiscountInfoId()).isEqualTo(sale1.getId()); @@ -118,16 +118,16 @@ public void saveDiscountInfoCommentTest2(){ discountInfoRepository.save(sale2); - CommentRequestDto.DiscountInfoCommentDto dto1 = CommentRequestDto.DiscountInfoCommentDto.builder() + CommentRequestDto.DiscountInfoCommentRequestDto dto1 = CommentRequestDto.DiscountInfoCommentRequestDto.builder() .discountInfoId(sale1.getId()) .content("굿") .build(); - CommentRequestDto.DiscountInfoCommentDto dto2 = CommentRequestDto.DiscountInfoCommentDto.builder() + CommentRequestDto.DiscountInfoCommentRequestDto dto2 = CommentRequestDto.DiscountInfoCommentRequestDto.builder() .discountInfoId(sale1.getId()) .content("좋아요") .build(); - CommentRequestDto.DiscountInfoCommentDto dto3 = CommentRequestDto.DiscountInfoCommentDto.builder() + CommentRequestDto.DiscountInfoCommentRequestDto dto3 = CommentRequestDto.DiscountInfoCommentRequestDto.builder() .discountInfoId(sale2.getId()) .content("유용해요!") .build(); @@ -138,8 +138,8 @@ public void saveDiscountInfoCommentTest2(){ em.flush(); - List returnDto = discountCommentService.findByInfo(sale1.getId()); - List returnDto2 = discountCommentService.findByInfo(sale2.getId()); + List returnDto = discountCommentService.findByInfo(sale1.getId()); + List returnDto2 = discountCommentService.findByInfo(sale2.getId()); Assertions.assertThat(returnDto.size()).isEqualTo(2); Assertions.assertThat(returnDto.get(0).getDiscountInfoId()).isEqualTo(sale1.getId()); Assertions.assertThat(returnDto.get(0).getUserId()).isEqualTo(user1.getId()); @@ -187,20 +187,20 @@ void DiscountAnonymousCommentTest(){ discountInfoRepository.save(sale2); - CommentRequestDto.DiscountInfoCommentDto dto1 = CommentRequestDto.DiscountInfoCommentDto.builder() + CommentRequestDto.DiscountInfoCommentRequestDto dto1 = CommentRequestDto.DiscountInfoCommentRequestDto.builder() .discountInfoId(sale1.getId()) .content("굿") .build(); - CommentRequestDto.DiscountInfoCommentDto dto2 = CommentRequestDto.DiscountInfoCommentDto.builder() + CommentRequestDto.DiscountInfoCommentRequestDto dto2 = CommentRequestDto.DiscountInfoCommentRequestDto.builder() .discountInfoId(sale1.getId()) .content("좋아요") .build(); - CommentRequestDto.DiscountInfoCommentDto dto3 = CommentRequestDto.DiscountInfoCommentDto.builder() + CommentRequestDto.DiscountInfoCommentRequestDto dto3 = CommentRequestDto.DiscountInfoCommentRequestDto.builder() .discountInfoId(sale2.getId()) .content("유용해요!") .build(); - CommentRequestDto.DiscountInfoCommentDto dto4 = CommentRequestDto.DiscountInfoCommentDto.builder() + CommentRequestDto.DiscountInfoCommentRequestDto dto4 = CommentRequestDto.DiscountInfoCommentRequestDto.builder() .discountInfoId(sale1.getId()) .content("구웃!") .build(); @@ -214,7 +214,7 @@ void DiscountAnonymousCommentTest(){ em.flush(); - List result = discountCommentService.findByInfo(sale1.getId()); + List result = discountCommentService.findByInfo(sale1.getId()); Integer test1 = result.get(0).getAnonymousNumber(); Integer test2 = result.get(1).getAnonymousNumber(); Integer test3 = result.get(2).getAnonymousNumber(); @@ -252,16 +252,16 @@ public void saveSupportInfoCommentTest2(){ supportInfoRepository.save(info2); - CommentRequestDto.SupportInfoCommentDto dto1 = CommentRequestDto.SupportInfoCommentDto.builder() + CommentRequestDto.SupportInfoCommentRequestDto dto1 = CommentRequestDto.SupportInfoCommentRequestDto.builder() .supportInfoId(info1.getId()) .content("굿") .build(); - CommentRequestDto.SupportInfoCommentDto dto2 = CommentRequestDto.SupportInfoCommentDto.builder() + CommentRequestDto.SupportInfoCommentRequestDto dto2 = CommentRequestDto.SupportInfoCommentRequestDto.builder() .supportInfoId(info1.getId()) .content("좋아요") .build(); - CommentRequestDto.SupportInfoCommentDto dto3 = CommentRequestDto.SupportInfoCommentDto.builder() + CommentRequestDto.SupportInfoCommentRequestDto dto3 = CommentRequestDto.SupportInfoCommentRequestDto.builder() .supportInfoId(info2.getId()) .content("유용해요!") .build(); @@ -272,8 +272,8 @@ public void saveSupportInfoCommentTest2(){ em.flush(); - List returnDto = supportCommentService.findByInfo(info1.getId()); - List returnDto2 = supportCommentService.findByInfo(info2.getId()); + List returnDto = supportCommentService.findByInfo(info1.getId()); + List returnDto2 = supportCommentService.findByInfo(info2.getId()); Assertions.assertThat(returnDto.size()).isEqualTo(2); Assertions.assertThat(returnDto.get(0).getSupportInfoId()).isEqualTo(info1.getId()); Assertions.assertThat(returnDto.get(0).getUserId()).isEqualTo(user1.getId()); @@ -327,28 +327,28 @@ void supportAnonymousCommentTest(){ supportInfoRepository.save(info2); - CommentRequestDto.SupportInfoCommentDto dto1 = CommentRequestDto.SupportInfoCommentDto.builder() + CommentRequestDto.SupportInfoCommentRequestDto dto1 = CommentRequestDto.SupportInfoCommentRequestDto.builder() .supportInfoId(info1.getId()) .content("굿") .build(); - CommentRequestDto.SupportInfoCommentDto dto2 = CommentRequestDto.SupportInfoCommentDto.builder() + CommentRequestDto.SupportInfoCommentRequestDto dto2 = CommentRequestDto.SupportInfoCommentRequestDto.builder() .supportInfoId(info1.getId()) .content("좋아요") .build(); - CommentRequestDto.SupportInfoCommentDto dto3 = CommentRequestDto.SupportInfoCommentDto.builder() + CommentRequestDto.SupportInfoCommentRequestDto dto3 = CommentRequestDto.SupportInfoCommentRequestDto.builder() .supportInfoId(info2.getId()) .content("유용해요!") .build(); - CommentRequestDto.SupportInfoCommentDto dto6 = CommentRequestDto.SupportInfoCommentDto.builder() + CommentRequestDto.SupportInfoCommentRequestDto dto6 = CommentRequestDto.SupportInfoCommentRequestDto.builder() .supportInfoId(info1.getId()) .content("굿") .build(); - CommentRequestDto.SupportInfoCommentDto dto4 = CommentRequestDto.SupportInfoCommentDto.builder() + CommentRequestDto.SupportInfoCommentRequestDto dto4 = CommentRequestDto.SupportInfoCommentRequestDto.builder() .supportInfoId(info1.getId()) .content("굿") .build(); - CommentRequestDto.SupportInfoCommentDto dto5 = CommentRequestDto.SupportInfoCommentDto.builder() + CommentRequestDto.SupportInfoCommentRequestDto dto5 = CommentRequestDto.SupportInfoCommentRequestDto.builder() .supportInfoId(info1.getId()) .content("굿") .build(); @@ -362,8 +362,8 @@ void supportAnonymousCommentTest(){ em.flush(); - List returnDto = supportCommentService.findByInfo(info1.getId()); - List returnDto2 = supportCommentService.findByInfo(info2.getId()); + List returnDto = supportCommentService.findByInfo(info1.getId()); + List returnDto2 = supportCommentService.findByInfo(info2.getId()); Integer test1 = returnDto.get(0).getAnonymousNumber(); Integer test2 = returnDto.get(1).getAnonymousNumber(); @@ -410,20 +410,20 @@ void DiscountInfoCommentPagingTest() { discountInfoRepository.save(sale2); - CommentRequestDto.DiscountInfoCommentDto dto1 = CommentRequestDto.DiscountInfoCommentDto.builder() + CommentRequestDto.DiscountInfoCommentRequestDto dto1 = CommentRequestDto.DiscountInfoCommentRequestDto.builder() .discountInfoId(sale1.getId()) .content("굿") .build(); - CommentRequestDto.DiscountInfoCommentDto dto2 = CommentRequestDto.DiscountInfoCommentDto.builder() + CommentRequestDto.DiscountInfoCommentRequestDto dto2 = CommentRequestDto.DiscountInfoCommentRequestDto.builder() .discountInfoId(sale1.getId()) .content("좋아요") .build(); - CommentRequestDto.DiscountInfoCommentDto dto3 = CommentRequestDto.DiscountInfoCommentDto.builder() + CommentRequestDto.DiscountInfoCommentRequestDto dto3 = CommentRequestDto.DiscountInfoCommentRequestDto.builder() .discountInfoId(sale2.getId()) .content("유용해요!") .build(); - CommentRequestDto.DiscountInfoCommentDto dto4 = CommentRequestDto.DiscountInfoCommentDto.builder() + CommentRequestDto.DiscountInfoCommentRequestDto dto4 = CommentRequestDto.DiscountInfoCommentRequestDto.builder() .discountInfoId(sale1.getId()) .content("구웃!") .build(); @@ -440,24 +440,24 @@ void DiscountInfoCommentPagingTest() { PageRequest pageRequest1 = PageRequest.of(0, 2); - Page result1 = discountCommentService.findByInfoWithPaging(sale1.getId(), pageRequest1); + Page result1 = discountCommentService.findByInfoWithPaging(sale1.getId(), pageRequest1); Assertions.assertThat(result1.getTotalElements()).isEqualTo(5); Assertions.assertThat(result1.getTotalPages()).isEqualTo(3); Assertions.assertThat(result1.hasNext()).isTrue(); Assertions.assertThat(result1.hasPrevious()).isFalse(); - List list1 = result1.getContent(); + List list1 = result1.getContent(); Assertions.assertThat(list1.get(0).getUserId()).isEqualTo(user1.getId()); Assertions.assertThat(list1.get(0).getContent()).isEqualTo("굿"); Assertions.assertThat(list1.get(0).getAnonymousNumber()).isEqualTo(1); PageRequest pageRequest2 = PageRequest.of(1, 3); - Page result2 = discountCommentService.findByInfoWithPaging(sale1.getId(), pageRequest2); + Page result2 = discountCommentService.findByInfoWithPaging(sale1.getId(), pageRequest2); Assertions.assertThat(result2.getTotalElements()).isEqualTo(5); Assertions.assertThat(result2.getTotalPages()).isEqualTo(2); Assertions.assertThat(result2.hasNext()).isFalse(); Assertions.assertThat(result2.hasPrevious()).isTrue(); - List list2 = result2.getContent(); + List list2 = result2.getContent(); Assertions.assertThat(list2.get(0).getUserId()).isEqualTo(user3.getId()); Assertions.assertThat(list2.get(0).getContent()).isEqualTo("구웃!"); Assertions.assertThat(list2.get(0).getAnonymousNumber()).isEqualTo(3); @@ -503,28 +503,28 @@ void SupportInfoPagingTest() { supportInfoRepository.save(info2); - CommentRequestDto.SupportInfoCommentDto dto1 = CommentRequestDto.SupportInfoCommentDto.builder() + CommentRequestDto.SupportInfoCommentRequestDto dto1 = CommentRequestDto.SupportInfoCommentRequestDto.builder() .supportInfoId(info1.getId()) .content("굿") .build(); - CommentRequestDto.SupportInfoCommentDto dto2 = CommentRequestDto.SupportInfoCommentDto.builder() + CommentRequestDto.SupportInfoCommentRequestDto dto2 = CommentRequestDto.SupportInfoCommentRequestDto.builder() .supportInfoId(info1.getId()) .content("좋아요") .build(); - CommentRequestDto.SupportInfoCommentDto dto3 = CommentRequestDto.SupportInfoCommentDto.builder() + CommentRequestDto.SupportInfoCommentRequestDto dto3 = CommentRequestDto.SupportInfoCommentRequestDto.builder() .supportInfoId(info2.getId()) .content("유용해요!") .build(); - CommentRequestDto.SupportInfoCommentDto dto6 = CommentRequestDto.SupportInfoCommentDto.builder() + CommentRequestDto.SupportInfoCommentRequestDto dto6 = CommentRequestDto.SupportInfoCommentRequestDto.builder() .supportInfoId(info1.getId()) .content("굿") .build(); - CommentRequestDto.SupportInfoCommentDto dto4 = CommentRequestDto.SupportInfoCommentDto.builder() + CommentRequestDto.SupportInfoCommentRequestDto dto4 = CommentRequestDto.SupportInfoCommentRequestDto.builder() .supportInfoId(info1.getId()) .content("굿") .build(); - CommentRequestDto.SupportInfoCommentDto dto5 = CommentRequestDto.SupportInfoCommentDto.builder() + CommentRequestDto.SupportInfoCommentRequestDto dto5 = CommentRequestDto.SupportInfoCommentRequestDto.builder() .supportInfoId(info1.getId()) .content("굿") .build(); @@ -540,25 +540,25 @@ void SupportInfoPagingTest() { em.flush(); PageRequest pageRequest1 = PageRequest.of(0, 2); - Page result1 = supportCommentService.findByInfoWithPaging(info1.getId(), pageRequest1); + Page result1 = supportCommentService.findByInfoWithPaging(info1.getId(), pageRequest1); Assertions.assertThat(result1.getTotalElements()).isEqualTo(7); Assertions.assertThat(result1.getTotalPages()).isEqualTo(4); Assertions.assertThat(result1.hasNext()).isTrue(); Assertions.assertThat(result1.hasPrevious()).isFalse(); - List list1 = result1.getContent(); + List list1 = result1.getContent(); Assertions.assertThat(list1.get(0).getUserId()).isEqualTo(user1.getId()); Assertions.assertThat(list1.get(0).getContent()).isEqualTo("굿"); Assertions.assertThat(list1.get(0).getAnonymousNumber()).isEqualTo(1); PageRequest pageRequest2 = PageRequest.of(1, 5); - Page result2 = supportCommentService.findByInfoWithPaging(info1.getId(), pageRequest2); + Page result2 = supportCommentService.findByInfoWithPaging(info1.getId(), pageRequest2); Assertions.assertThat(result2.getTotalElements()).isEqualTo(7); Assertions.assertThat(result2.getTotalPages()).isEqualTo(2); Assertions.assertThat(result2.hasNext()).isFalse(); Assertions.assertThat(result2.hasPrevious()).isTrue(); - List list2 = result2.getContent(); + List list2 = result2.getContent(); Assertions.assertThat(list2.get(0).getUserId()).isEqualTo(user2.getId()); Assertions.assertThat(list2.get(0).getContent()).isEqualTo("굿"); Assertions.assertThat(list2.get(0).getAnonymousNumber()).isEqualTo(2); From db43288f54ef1a7302326a5162e40b97d52ed94c Mon Sep 17 00:00:00 2001 From: kangseungmin Date: Wed, 14 Aug 2024 21:08:09 +0900 Subject: [PATCH 5/7] =?UTF-8?q?[fix]=20DiscountDto=20=EB=8B=A4=EC=8B=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/DiscountCommentService.java | 18 +++++++++--------- .../controller/DiscountInfoApi.java | 4 ++-- .../controller/DiscountInfoController.java | 4 ++-- .../converter/DiscountInfoConverter.java | 2 +- .../discountinfo/entity/DiscountInfo.java | 3 +-- .../service/DiscountInfoService.java | 4 ++-- .../service/DiscountInfoServiceImpl.java | 4 ++-- .../service/DiscountInfoServiceTest.java | 2 +- 8 files changed, 20 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/comment/service/DiscountCommentService.java b/src/main/java/com/bbteam/budgetbuddies/domain/comment/service/DiscountCommentService.java index b5a146a4..c270de67 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/comment/service/DiscountCommentService.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/comment/service/DiscountCommentService.java @@ -21,8 +21,8 @@ @Service("discountCommentService") @Transactional(readOnly = true) -public class DiscountCommentService extends AbstractCommentService { +public class DiscountCommentService extends AbstractCommentService { private final UserRepository userRepository; private final DiscountInfoRepository discountInfoRepository; @@ -34,7 +34,7 @@ public DiscountCommentService(CommentRepository commentRepository, UserRepositor @Override @Transactional - public CommentResponseDto.DiscountInfoCommentDto saveComment(Long userId, CommentRequestDto.DiscountInfoCommentDto dto) { + public CommentResponseDto.DiscountInfoCommentResponseDto saveComment(Long userId, CommentRequestDto.DiscountInfoCommentRequestDto dto) { User user = userRepository.findById(userId).orElseThrow(() -> new NoSuchElementException("유저 존재 x")); DiscountInfo info = discountInfoRepository.findById(dto.getDiscountInfoId()).orElseThrow(() -> new NoSuchElementException("정보 존재 x")); // dto에서 infoId를 추출하여 찾는 메서드 int anonymousNumber = getAnonymousNumber(user, info); @@ -58,18 +58,18 @@ private int getAnonymousNumber(User user, DiscountInfo info) { } @Override - public List findByInfo(Long infoId) { + public List findByInfo(Long infoId) { List commentList = commentRepository.findByDiscountInfo(infoId); - List collect = commentList.stream() + List collect = commentList.stream() .map(CommentConverter::toDiscountInfoCommentDto) .collect(Collectors.toList()); return collect; } @Override - public Page findByInfoWithPaging(Long infoId, Pageable pageable) { + public Page findByInfoWithPaging(Long infoId, Pageable pageable) { Page commentPage = commentRepository.findByDiscountInfoWithPaging(infoId, pageable); - Page result = commentPage.map(CommentConverter::toDiscountInfoCommentDto); + Page result = commentPage.map(CommentConverter::toDiscountInfoCommentDto); return result; } @@ -81,7 +81,7 @@ public void deleteComment(Long commentId) { } @Override - public CommentResponseDto.DiscountInfoCommentDto findCommentOne(Long commentId) { + public CommentResponseDto.DiscountInfoCommentResponseDto findCommentOne(Long commentId) { Comment comment = commentRepository.findById(commentId).orElseThrow(() -> new NoSuchElementException("No such comment")); if(comment.getDiscountInfo() == null){ throw new RuntimeException("DiscountInfo comment에 대한 요청이 아닙니다."); @@ -91,7 +91,7 @@ public CommentResponseDto.DiscountInfoCommentDto findCommentOne(Long commentId) @Override @Transactional - public CommentResponseDto.DiscountInfoCommentDto modifyComment(CommentRequestDto.CommentModifyDto dto) { + public CommentResponseDto.DiscountInfoCommentResponseDto modifyComment(CommentRequestDto.CommentModifyRequestDto dto) { Comment comment = commentRepository.findById(dto.getCommentId()).orElseThrow(() -> new NoSuchElementException("xxx")); if (comment.getDiscountInfo() == null) { throw new RuntimeException("DiscountInfo comment에 대한 요청이 아닙니다."); diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/controller/DiscountInfoApi.java b/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/controller/DiscountInfoApi.java index 0aee8c53..3ceb2112 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/controller/DiscountInfoApi.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/controller/DiscountInfoApi.java @@ -45,7 +45,7 @@ ApiResponse> getDiscountsByYearAndMonth( // @Parameter(name = "discountRequestDto", description = "등록할 할인 정보의 전체 내용입니다."), }) ApiResponse registerDiscountInfo( - @RequestBody DiscountRequest.RegisterDto discountRequestDto + @RequestBody DiscountRequest.RegisterDiscountDto discountRequestDto ); @Operation(summary = "[User] 특정 할인정보에 좋아요 클릭 API", description = "특정 할인정보에 좋아요 버튼을 클릭하는 API이며, 일단은 사용자 ID를 입력하여 사용합니다. (추후 토큰으로 검증)") @@ -77,7 +77,7 @@ ApiResponse likeDiscountInfo( }) ApiResponse updateDiscountInfo( @RequestParam Long userId, - @RequestBody DiscountRequest.UpdateDto discountRequestDto + @RequestBody DiscountRequest.UpdateDiscountDto discountRequestDto ); @Operation(summary = "[ADMIN] 특정 할인정보 삭제하기 API", description = "특정 할인정보를 삭제하는 API이며, 일단은 사용자 ID를 입력하여 사용합니다. (추후 토큰으로 검증)") diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/controller/DiscountInfoController.java b/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/controller/DiscountInfoController.java index 918107cc..c17af639 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/controller/DiscountInfoController.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/controller/DiscountInfoController.java @@ -32,7 +32,7 @@ public ApiResponse> getDiscountsByYearAndMonth( @Override @PostMapping("") public ApiResponse registerDiscountInfo( - @RequestBody DiscountRequest.RegisterDto discountRequestDto + @RequestBody DiscountRequest.RegisterDiscountDto discountRequestDto ) { DiscountResponseDto discountResponseDto = discountInfoService.registerDiscountInfo(discountRequestDto); @@ -54,7 +54,7 @@ public ApiResponse likeDiscountInfo( @PutMapping("") public ApiResponse updateDiscountInfo( @RequestParam @ExistUser Long userId, - @RequestBody DiscountRequest.UpdateDto discountRequestDto + @RequestBody DiscountRequest.UpdateDiscountDto discountRequestDto ) { DiscountResponseDto discountResponseDto = discountInfoService.updateDiscountInfo(userId, discountRequestDto); diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/converter/DiscountInfoConverter.java b/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/converter/DiscountInfoConverter.java index 7a9e39eb..9cb07da0 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/converter/DiscountInfoConverter.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/converter/DiscountInfoConverter.java @@ -32,7 +32,7 @@ public DiscountResponseDto toDto(DiscountInfo entity) { * @param requestDto * @return entity */ - public DiscountInfo toEntity(DiscountRequest.RegisterDto requestDto) { + public DiscountInfo toEntity(DiscountRequest.RegisterDiscountDto requestDto) { return DiscountInfo.builder() .title(requestDto.getTitle()) diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/entity/DiscountInfo.java b/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/entity/DiscountInfo.java index 3c1d0a5e..6c6779dc 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/entity/DiscountInfo.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/entity/DiscountInfo.java @@ -6,7 +6,6 @@ import jakarta.persistence.Entity; import lombok.*; import lombok.experimental.SuperBuilder; -import org.hibernate.annotations.ColumnDefault; import java.time.LocalDate; @@ -51,7 +50,7 @@ public Integer addAndGetAnonymousNumber() { return anonymousNumber; } - public void update(DiscountRequest.UpdateDto discountRequestDto) { + public void update(DiscountRequest.UpdateDiscountDto discountRequestDto) { this.title = discountRequestDto.getTitle(); this.startDate = discountRequestDto.getStartDate(); this.endDate = discountRequestDto.getEndDate(); diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/service/DiscountInfoService.java b/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/service/DiscountInfoService.java index cd8d54de..ba77217d 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/service/DiscountInfoService.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/service/DiscountInfoService.java @@ -12,11 +12,11 @@ Page getDiscountsByYearAndMonth( Integer size ); - DiscountResponseDto registerDiscountInfo(DiscountRequest.RegisterDto discountRequestDto); + DiscountResponseDto registerDiscountInfo(DiscountRequest.RegisterDiscountDto discountRequestDto); DiscountResponseDto toggleLike(Long userId, Long discountInfoId); - DiscountResponseDto updateDiscountInfo(Long userId, DiscountRequest.UpdateDto discountRequestDto); + DiscountResponseDto updateDiscountInfo(Long userId, DiscountRequest.UpdateDiscountDto discountRequestDto); String deleteDiscountInfo(Long userId, Long discountInfoId); diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/service/DiscountInfoServiceImpl.java b/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/service/DiscountInfoServiceImpl.java index b7348821..8e472080 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/service/DiscountInfoServiceImpl.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/discountinfo/service/DiscountInfoServiceImpl.java @@ -53,7 +53,7 @@ public Page getDiscountsByYearAndMonth(Integer year, Intege @Transactional @Override - public DiscountResponseDto registerDiscountInfo(DiscountRequest.RegisterDto discountRequestDto) { + public DiscountResponseDto registerDiscountInfo(DiscountRequest.RegisterDiscountDto discountRequestDto) { /** * 1. RequestDto -> Entity로 변환 * 2. Entity 저장 @@ -117,7 +117,7 @@ public DiscountResponseDto toggleLike(Long userId, Long discountInfoId) { @Transactional @Override - public DiscountResponseDto updateDiscountInfo(Long userId, DiscountRequest.UpdateDto discountRequestDto) { + public DiscountResponseDto updateDiscountInfo(Long userId, DiscountRequest.UpdateDiscountDto discountRequestDto) { /** * 1. 사용자 조회 -> 없으면 에러 * 2. 할인정보 조회 -> 없으면 에러 diff --git a/src/test/java/com/bbteam/budgetbuddies/domain/discountinfo/service/DiscountInfoServiceTest.java b/src/test/java/com/bbteam/budgetbuddies/domain/discountinfo/service/DiscountInfoServiceTest.java index 0fee5041..eea83d2b 100644 --- a/src/test/java/com/bbteam/budgetbuddies/domain/discountinfo/service/DiscountInfoServiceTest.java +++ b/src/test/java/com/bbteam/budgetbuddies/domain/discountinfo/service/DiscountInfoServiceTest.java @@ -103,7 +103,7 @@ void getDiscountsByYearAndMonthTest() { @DisplayName("할인 정보 등록이 정상적으로 되는지 검증") void registerDiscountInfoTest() { // given - DiscountRequest.RegisterDto requestDto = DiscountRequest.RegisterDto.builder() + DiscountRequest.RegisterDiscountDto requestDto = DiscountRequest.RegisterDiscountDto.builder() .title("할인 정보 제목") .startDate(LocalDate.of(2024, 7, 1)) .endDate(LocalDate.of(2024, 7, 21)) From 5201b731fb95f629636f88dc8f9da6a0f781a1ee Mon Sep 17 00:00:00 2001 From: kangseungmin Date: Wed, 14 Aug 2024 21:08:24 +0900 Subject: [PATCH 6/7] =?UTF-8?q?[fix]=20SupportDto=20=EB=8B=A4=EC=8B=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../comment/service/SupportCommentService.java | 18 +++++++++--------- .../supportinfo/controller/SupportInfoApi.java | 4 ++-- .../controller/SupportInfoController.java | 4 ++-- .../converter/SupportInfoConverter.java | 2 +- .../domain/supportinfo/entity/SupportInfo.java | 4 +--- .../service/SupportInfoService.java | 4 ++-- .../service/SupportInfoServiceImpl.java | 4 ++-- .../service/SupportInfoServiceTest.java | 2 +- 8 files changed, 20 insertions(+), 22 deletions(-) diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/comment/service/SupportCommentService.java b/src/main/java/com/bbteam/budgetbuddies/domain/comment/service/SupportCommentService.java index 9e46d66b..74c2ce1f 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/comment/service/SupportCommentService.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/comment/service/SupportCommentService.java @@ -21,8 +21,8 @@ @Service("supportCommentService") @Transactional(readOnly = true) -public class SupportCommentService extends AbstractCommentService { +public class SupportCommentService extends AbstractCommentService { private final UserRepository userRepository; private final SupportInfoRepository supportInfoRepository; @@ -35,7 +35,7 @@ public SupportCommentService(CommentRepository commentRepository, UserRepository @Override @Transactional - public CommentResponseDto.SupportInfoCommentDto saveComment(Long userId, CommentRequestDto.SupportInfoCommentDto dto) { + public CommentResponseDto.SupportInfoCommentResponseDto saveComment(Long userId, CommentRequestDto.SupportInfoCommentRequestDto dto) { User user = userRepository.findById(userId).orElseThrow(() -> new NoSuchElementException("유저 존재 x")); SupportInfo info = supportInfoRepository.findById(dto.getSupportInfoId()).orElseThrow(() -> new NoSuchElementException("정보 존재 x")); // dto에서 infoId를 추출하여 찾는 메서드 int anonymousNumber = getAnonymousNumber(user, info); @@ -57,18 +57,18 @@ private int getAnonymousNumber(User user, SupportInfo info) { } @Override - public List findByInfo(Long infoId) { + public List findByInfo(Long infoId) { List commentList = commentRepository.findBySupportInfo(infoId); - List collect = commentList.stream() + List collect = commentList.stream() .map(CommentConverter::toSupportInfoCommentDto) .collect(Collectors.toList()); return collect; } @Override - public Page findByInfoWithPaging(Long infoId, Pageable pageable) { + public Page findByInfoWithPaging(Long infoId, Pageable pageable) { Page commentPage = commentRepository.findBySupportInfoWithPaging(infoId, pageable); - Page result = commentPage.map(CommentConverter::toSupportInfoCommentDto); + Page result = commentPage.map(CommentConverter::toSupportInfoCommentDto); return result; } @@ -80,7 +80,7 @@ public void deleteComment(Long commentId) { } @Override - public CommentResponseDto.SupportInfoCommentDto findCommentOne(Long commentId) { + public CommentResponseDto.SupportInfoCommentResponseDto findCommentOne(Long commentId) { Comment comment = commentRepository.findById(commentId).orElseThrow(() -> new NoSuchElementException("No such comment")); if(comment.getSupportInfo() == null){ throw new RuntimeException("supportInfo comment에 대한 요청이 아닙니다."); @@ -90,7 +90,7 @@ public CommentResponseDto.SupportInfoCommentDto findCommentOne(Long commentId) { @Override @Transactional - public CommentResponseDto.SupportInfoCommentDto modifyComment(CommentRequestDto.CommentModifyDto dto) { + public CommentResponseDto.SupportInfoCommentResponseDto modifyComment(CommentRequestDto.CommentModifyRequestDto dto) { Comment comment = commentRepository.findById(dto.getCommentId()).orElseThrow(() -> new NoSuchElementException("xxx")); if (comment.getSupportInfo() == null) { throw new RuntimeException("supportInfo comment에 대한 요청이 아닙니다."); diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/controller/SupportInfoApi.java b/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/controller/SupportInfoApi.java index 900b6ff4..8fbc3a83 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/controller/SupportInfoApi.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/controller/SupportInfoApi.java @@ -42,7 +42,7 @@ ApiResponse> getSupportsByYearAndMonth( // @io.swagger.v3.oas.annotations.responses.ApiResponse(responseCode = "AUTH006", description = "access 토큰 모양이 이상함", content = @Content(schema = @Schema(implementation = ApiResponse.class))) }) ApiResponse registerSupportInfo( - @RequestBody SupportRequest.RegisterDto requestDto + @RequestBody SupportRequest.RegisterSupportDto requestDto ); @Operation(summary = "[User] 특정 지원정보에 좋아요 클릭 API", description = "특정 지원정보에 좋아요 버튼을 클릭하는 API이며, 일단은 사용자 ID를 입력하여 사용합니다. (추후 토큰으로 검증)") @@ -73,7 +73,7 @@ ApiResponse likeSupportInfo( }) ApiResponse updateSupportInfo( @RequestParam Long userId, - @RequestBody SupportRequest.UpdateDto supportRequestDto + @RequestBody SupportRequest.UpdateSupportDto supportRequestDto ); @Operation(summary = "[ADMIN] 특정 지원정보 삭제하기 API", description = "특정 지원정보를 삭제하는 API이며, 일단은 사용자 ID를 입력하여 사용합니다. (추후 토큰으로 검증)") diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/controller/SupportInfoController.java b/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/controller/SupportInfoController.java index eb0c89b5..44eb81d4 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/controller/SupportInfoController.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/controller/SupportInfoController.java @@ -32,7 +32,7 @@ public ApiResponse> getSupportsByYearAndMonth( @Override @PostMapping("") public ApiResponse registerSupportInfo( - @RequestBody SupportRequest.RegisterDto requestDto + @RequestBody SupportRequest.RegisterSupportDto requestDto ) { SupportResponseDto supportResponseDto = supportInfoService.registerSupportInfo(requestDto); @@ -54,7 +54,7 @@ public ApiResponse likeSupportInfo( @PutMapping("") public ApiResponse updateSupportInfo( @RequestParam @ExistUser Long userId, - @RequestBody SupportRequest.UpdateDto supportRequestDto + @RequestBody SupportRequest.UpdateSupportDto supportRequestDto ) { SupportResponseDto supportResponseDto = supportInfoService.updateSupportInfo(userId, supportRequestDto); diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/converter/SupportInfoConverter.java b/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/converter/SupportInfoConverter.java index 5c70330b..804f8b51 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/converter/SupportInfoConverter.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/converter/SupportInfoConverter.java @@ -30,7 +30,7 @@ public SupportResponseDto toDto(SupportInfo entity) { * @param requestDto * @return entity */ - public SupportInfo toEntity(SupportRequest.RegisterDto requestDto) { + public SupportInfo toEntity(SupportRequest.RegisterSupportDto requestDto) { return SupportInfo.builder() .title(requestDto.getTitle()) diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/entity/SupportInfo.java b/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/entity/SupportInfo.java index 93d43d0d..95b14372 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/entity/SupportInfo.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/entity/SupportInfo.java @@ -1,13 +1,11 @@ package com.bbteam.budgetbuddies.domain.supportinfo.entity; import com.bbteam.budgetbuddies.common.BaseEntity; -import com.bbteam.budgetbuddies.domain.discountinfo.dto.DiscountRequest; import com.bbteam.budgetbuddies.domain.supportinfo.dto.SupportRequest; import jakarta.persistence.Column; import jakarta.persistence.Entity; import lombok.*; import lombok.experimental.SuperBuilder; -import org.hibernate.annotations.ColumnDefault; import java.time.LocalDate; @@ -50,7 +48,7 @@ public Integer addAndGetAnonymousNumber() { return anonymousNumber; } - public void update(SupportRequest.UpdateDto supportRequestDto) { + public void update(SupportRequest.UpdateSupportDto supportRequestDto) { this.title = supportRequestDto.getTitle(); this.startDate = supportRequestDto.getStartDate(); this.endDate = supportRequestDto.getEndDate(); diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/service/SupportInfoService.java b/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/service/SupportInfoService.java index b56e149f..9f87b268 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/service/SupportInfoService.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/service/SupportInfoService.java @@ -12,11 +12,11 @@ Page getSupportsByYearAndMonth( Integer size ); - SupportResponseDto registerSupportInfo(SupportRequest.RegisterDto supportRequest); + SupportResponseDto registerSupportInfo(SupportRequest.RegisterSupportDto supportRequest); SupportResponseDto toggleLike(Long userId, Long supportInfoId); - SupportResponseDto updateSupportInfo(Long userId, SupportRequest.UpdateDto supportRequestDto); + SupportResponseDto updateSupportInfo(Long userId, SupportRequest.UpdateSupportDto supportRequestDto); String deleteSupportInfo(Long userId, Long supportInfoId); diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/service/SupportInfoServiceImpl.java b/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/service/SupportInfoServiceImpl.java index 86a781b0..b3f37f31 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/service/SupportInfoServiceImpl.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/supportinfo/service/SupportInfoServiceImpl.java @@ -53,7 +53,7 @@ public Page getSupportsByYearAndMonth(Integer year, Integer @Transactional @Override - public SupportResponseDto registerSupportInfo(SupportRequest.RegisterDto supportRequest) { + public SupportResponseDto registerSupportInfo(SupportRequest.RegisterSupportDto supportRequest) { /** * 1. RequestDto -> Entity로 변환 * 2. Entity 저장 @@ -117,7 +117,7 @@ public SupportResponseDto toggleLike(Long userId, Long supportInfoId) { @Transactional @Override - public SupportResponseDto updateSupportInfo(Long userId, SupportRequest.UpdateDto supportRequestDto) { + public SupportResponseDto updateSupportInfo(Long userId, SupportRequest.UpdateSupportDto supportRequestDto) { /** * 1. 사용자 조회 -> 없으면 에러 * 2. 지원정보 조회 -> 없으면 에러 diff --git a/src/test/java/com/bbteam/budgetbuddies/domain/supportinfo/service/SupportInfoServiceTest.java b/src/test/java/com/bbteam/budgetbuddies/domain/supportinfo/service/SupportInfoServiceTest.java index 0c360ecf..258c674b 100644 --- a/src/test/java/com/bbteam/budgetbuddies/domain/supportinfo/service/SupportInfoServiceTest.java +++ b/src/test/java/com/bbteam/budgetbuddies/domain/supportinfo/service/SupportInfoServiceTest.java @@ -103,7 +103,7 @@ void getSupportsByYearAndMonthTest() { @DisplayName("지원 정보 등록이 정상적으로 되는지 검증") void registerSupportInfoTest() { // given - SupportRequest.RegisterDto requestDto = SupportRequest.RegisterDto.builder() + SupportRequest.RegisterSupportDto requestDto = SupportRequest.RegisterSupportDto.builder() .title("지원 정보 제목") .startDate(LocalDate.of(2024, 7, 1)) .endDate(LocalDate.of(2024, 7, 21)) From 29566614e75855c71fdbf085f91e44baa73847dc Mon Sep 17 00:00:00 2001 From: kangseungmin Date: Wed, 14 Aug 2024 21:08:32 +0900 Subject: [PATCH 7/7] =?UTF-8?q?[fix]=20UserDto=20=EB=8B=A4=EC=8B=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/user/controller/UserController.java | 8 ++++---- .../domain/user/converter/UserConverter.java | 6 +++--- .../com/bbteam/budgetbuddies/domain/user/dto/UserDto.java | 3 --- .../budgetbuddies/domain/user/service/UserService.java | 6 +++--- .../domain/user/service/UserServiceImpl.java | 6 +++--- 5 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/user/controller/UserController.java b/src/main/java/com/bbteam/budgetbuddies/domain/user/controller/UserController.java index 0cd4b5d4..791cdd7e 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/user/controller/UserController.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/user/controller/UserController.java @@ -27,18 +27,18 @@ public ResponseEntity> createConsumptionGoals( } @PostMapping("/register") - public ApiResponse registerUser(@RequestBody UserDto.RegisterDto dto) { + public ApiResponse registerUser(@RequestBody UserDto.RegisterUserDto dto) { return ApiResponse.onSuccess(userService.saveUser(dto)); } @GetMapping("/{userId}/find") - public ApiResponse findOne(@PathVariable("userId") @ExistUser Long userId) { + public ApiResponse findOne(@PathVariable("userId") @ExistUser Long userId) { return ApiResponse.onSuccess(userService.findUser(userId)); } @PutMapping("/{userId}/change") - public ApiResponse changeOne(@PathVariable("userId") @ExistUser Long userId, - @RequestParam("email") String email, @RequestParam("name") String name) { + public ApiResponse changeOne(@PathVariable("userId") @ExistUser Long userId, + @RequestParam("email") String email, @RequestParam("name") String name) { return ApiResponse.onSuccess(userService.changeUser(userId, email, name)); } } diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/user/converter/UserConverter.java b/src/main/java/com/bbteam/budgetbuddies/domain/user/converter/UserConverter.java index 522cd458..7de36315 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/user/converter/UserConverter.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/user/converter/UserConverter.java @@ -5,8 +5,8 @@ public class UserConverter { - public static UserDto.ResponseDto toDto(User user) { - return UserDto.ResponseDto.builder() + public static UserDto.ResponseUserDto toDto(User user) { + return UserDto.ResponseUserDto.builder() .id(user.getId()) .name(user.getName()) .phoneNumber(user.getPhoneNumber()) @@ -19,7 +19,7 @@ public static UserDto.ResponseDto toDto(User user) { .build(); } - public static User toUser(UserDto.RegisterDto dto) { + public static User toUser(UserDto.RegisterUserDto dto) { return User.builder() .phoneNumber(dto.getPhoneNumber()) .email(dto.getEmail()) diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/user/dto/UserDto.java b/src/main/java/com/bbteam/budgetbuddies/domain/user/dto/UserDto.java index b1913d9e..7fe98955 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/user/dto/UserDto.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/user/dto/UserDto.java @@ -1,9 +1,6 @@ package com.bbteam.budgetbuddies.domain.user.dto; import com.bbteam.budgetbuddies.enums.Gender; -import jakarta.persistence.Column; -import jakarta.persistence.EnumType; -import jakarta.persistence.Enumerated; import jakarta.validation.constraints.Min; import lombok.Builder; import lombok.Getter; diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/user/service/UserService.java b/src/main/java/com/bbteam/budgetbuddies/domain/user/service/UserService.java index b53ca17e..7cd64307 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/user/service/UserService.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/user/service/UserService.java @@ -7,9 +7,9 @@ public interface UserService { List createConsumptionGoalWithDefaultGoals(Long userId); - UserDto.ResponseDto saveUser(UserDto.RegisterDto dto); + UserDto.ResponseUserDto saveUser(UserDto.RegisterUserDto dto); - UserDto.ResponseDto findUser(Long userId); + UserDto.ResponseUserDto findUser(Long userId); - UserDto.ResponseDto changeUser(Long userId, String email, String name); + UserDto.ResponseUserDto changeUser(Long userId, String email, String name); } diff --git a/src/main/java/com/bbteam/budgetbuddies/domain/user/service/UserServiceImpl.java b/src/main/java/com/bbteam/budgetbuddies/domain/user/service/UserServiceImpl.java index e8794018..8908a7a7 100644 --- a/src/main/java/com/bbteam/budgetbuddies/domain/user/service/UserServiceImpl.java +++ b/src/main/java/com/bbteam/budgetbuddies/domain/user/service/UserServiceImpl.java @@ -55,21 +55,21 @@ public List createConsumptionGoalWithDefaultGoals(L @Override @Transactional - public UserDto.ResponseDto saveUser(UserDto.RegisterDto dto) { + public UserDto.ResponseUserDto saveUser(UserDto.RegisterUserDto dto) { User user = UserConverter.toUser(dto); userRepository.save(user); return UserConverter.toDto(user); } @Override - public UserDto.ResponseDto findUser(Long userId) { + public UserDto.ResponseUserDto findUser(Long userId) { User user = userRepository.findById(userId).orElseThrow(() -> new NoSuchElementException("해당 유저는 존재하지 않습니다.")); return UserConverter.toDto(user); } @Override @Transactional - public UserDto.ResponseDto changeUser(Long userId, String email, String name) { + public UserDto.ResponseUserDto changeUser(Long userId, String email, String name) { User user = userRepository.findById(userId).orElseThrow(() -> new NoSuchElementException("No such user")); user.changeUserDate(email, name); return UserConverter.toDto(user);