diff --git a/sluv-api/src/.DS_Store b/sluv-api/src/.DS_Store deleted file mode 100644 index 773c8251..00000000 Binary files a/sluv-api/src/.DS_Store and /dev/null differ diff --git a/sluv-api/src/main/.DS_Store b/sluv-api/src/main/.DS_Store deleted file mode 100644 index d1102ff4..00000000 Binary files a/sluv-api/src/main/.DS_Store and /dev/null differ diff --git a/sluv-api/src/main/java/com/sluv/api/admin/controller/AdminController.java b/sluv-api/src/main/java/com/sluv/api/admin/controller/AdminController.java index 580af4d0..879353a1 100644 --- a/sluv-api/src/main/java/com/sluv/api/admin/controller/AdminController.java +++ b/sluv-api/src/main/java/com/sluv/api/admin/controller/AdminController.java @@ -24,13 +24,13 @@ public ResponseEntity> getUserTokenB @RequestBody AdminUserTokenRequest request) { AdminUserTokenResponse response = adminService.getUserTokenByAdmin(request); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @PostMapping("") public ResponseEntity> saveAdmin(@RequestBody AdminRequest request) { AdminResponse response = adminService.getAdminData(request); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } } diff --git a/sluv-api/src/main/java/com/sluv/api/alarm/controller/AlarmController.java b/sluv-api/src/main/java/com/sluv/api/alarm/controller/AlarmController.java index fe129e27..68dc02ec 100644 --- a/sluv-api/src/main/java/com/sluv/api/alarm/controller/AlarmController.java +++ b/sluv-api/src/main/java/com/sluv/api/alarm/controller/AlarmController.java @@ -23,7 +23,7 @@ public class AlarmController { public ResponseEntity>> getAlarms( @CurrentUserId Long userId, Pageable pageable) { PaginationResponse response = alarmService.getAlarmsByUserId(userId, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @PatchMapping("/read") @@ -50,7 +50,7 @@ public ResponseEntity deleteAllAlarm(@CurrentUserId Long userId @GetMapping("/check") public ResponseEntity> checkAlarmAllRead(@CurrentUserId Long userId) { AlarmCheckResponse response = alarmService.checkAlarmAllRead(userId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } } diff --git a/sluv-api/src/main/java/com/sluv/api/alarm/service/AlarmService.java b/sluv-api/src/main/java/com/sluv/api/alarm/service/AlarmService.java index f4abfc58..8c1b96f2 100644 --- a/sluv-api/src/main/java/com/sluv/api/alarm/service/AlarmService.java +++ b/sluv-api/src/main/java/com/sluv/api/alarm/service/AlarmService.java @@ -34,7 +34,7 @@ public PaginationResponse getAlarmsByUserId(Long userId, Pageable List content = alarmPage.stream() .map(alarm -> AlarmResponse.of(alarm, getAlarmImages(alarm))) .toList(); - return PaginationResponse.create(alarmPage, content); + return PaginationResponse.of(alarmPage, content); } private AlarmImages getAlarmImages(Alarm alarm) { diff --git a/sluv-api/src/main/java/com/sluv/api/auth/controller/AuthController.java b/sluv-api/src/main/java/com/sluv/api/auth/controller/AuthController.java index 5026652c..6515efae 100644 --- a/sluv-api/src/main/java/com/sluv/api/auth/controller/AuthController.java +++ b/sluv-api/src/main/java/com/sluv/api/auth/controller/AuthController.java @@ -48,7 +48,7 @@ public ResponseEntity> socialLogin(@RequestBod visitCounter.countVisit(loginUser.getId()); AuthResponse response = authService.getAuthResDto(loginUser); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Deprecated @@ -59,7 +59,7 @@ public ResponseEntity> autoLogin(@Current User user = authService.findLogInUser(userId); // authService.checkFcm(user); AutoLoginResponse response = AutoLoginResponse.of(user); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*자동 로그인", description = "토큰 만료 시 error code : 4002") @@ -73,7 +73,7 @@ public ResponseEntity> autoLoginWithFcm(@ User user = authService.findLogInUser(userId); // authService.checkFcm(user); AutoLoginResponse response = AutoLoginResponse.of(user); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*FCM 토큰 갱신", description = "FCM 토큰을 갱신") diff --git a/sluv-api/src/main/java/com/sluv/api/brand/controller/BrandController.java b/sluv-api/src/main/java/com/sluv/api/brand/controller/BrandController.java index a69963e2..1d6717db 100644 --- a/sluv-api/src/main/java/com/sluv/api/brand/controller/BrandController.java +++ b/sluv-api/src/main/java/com/sluv/api/brand/controller/BrandController.java @@ -26,14 +26,14 @@ public class BrandController { public ResponseEntity>> getBrandSearch( @RequestParam String brandName, Pageable pageable) { PaginationResponse response = brandService.findAllBrand(brandName, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "인기 브랜드 검색", description = "인기 브랜드 검색(상위 10개)") @GetMapping("/top") public ResponseEntity>> getTopBrand() { List response = brandService.findTopBrand(); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } } diff --git a/sluv-api/src/main/java/com/sluv/api/brand/controller/NewBrandController.java b/sluv-api/src/main/java/com/sluv/api/brand/controller/NewBrandController.java index 8feff047..90191d7d 100644 --- a/sluv-api/src/main/java/com/sluv/api/brand/controller/NewBrandController.java +++ b/sluv-api/src/main/java/com/sluv/api/brand/controller/NewBrandController.java @@ -24,7 +24,7 @@ public class NewBrandController { public ResponseEntity> postNewBrand( @RequestBody NewBrandPostRequest request) { NewBrandPostResponse response = newBrandService.postNewBrand(request); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } } diff --git a/sluv-api/src/main/java/com/sluv/api/brand/controller/RecentSelectBrandController.java b/sluv-api/src/main/java/com/sluv/api/brand/controller/RecentSelectBrandController.java index eca07996..4d197d52 100644 --- a/sluv-api/src/main/java/com/sluv/api/brand/controller/RecentSelectBrandController.java +++ b/sluv-api/src/main/java/com/sluv/api/brand/controller/RecentSelectBrandController.java @@ -2,7 +2,6 @@ import com.sluv.api.brand.dto.request.RecentSelectBrandRequest; import com.sluv.api.brand.dto.response.RecentSelectBrandResponse; -import com.sluv.api.brand.service.BrandService; import com.sluv.api.brand.service.RecentSelectBrandService; import com.sluv.api.common.response.SuccessDataResponse; import com.sluv.api.common.response.SuccessResponse; @@ -18,15 +17,14 @@ @RequiredArgsConstructor @RequestMapping("/app/brand/recent") public class RecentSelectBrandController { - private final BrandService brandService; private final RecentSelectBrandService recentSelectBrandService; @Operation(summary = "*최근 선택한 브랜드 검색", description = "최근 선택한 브랜드을 검색") @GetMapping("") public ResponseEntity>> getRecentSelectBrand( @CurrentUserId Long userId) { - List response = brandService.findRecentSelectBrand(userId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + List response = recentSelectBrandService.findRecentSelectBrand(userId); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*최근 선택한 브랜드 등록", description = "User 토큰 필요") diff --git a/sluv-api/src/main/java/com/sluv/api/brand/dto/request/NewBrandPostRequest.java b/sluv-api/src/main/java/com/sluv/api/brand/dto/request/NewBrandPostRequest.java index f3113a7b..aeb1d613 100644 --- a/sluv-api/src/main/java/com/sluv/api/brand/dto/request/NewBrandPostRequest.java +++ b/sluv-api/src/main/java/com/sluv/api/brand/dto/request/NewBrandPostRequest.java @@ -1,11 +1,13 @@ package com.sluv.api.brand.dto.request; import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @Getter @NoArgsConstructor +@AllArgsConstructor public class NewBrandPostRequest { @Schema(description = "새로 등록할 브랜드의 이름") private String newBrandName; diff --git a/sluv-api/src/main/java/com/sluv/api/brand/dto/request/RecentSelectBrandRequest.java b/sluv-api/src/main/java/com/sluv/api/brand/dto/request/RecentSelectBrandRequest.java index 362f6770..318f101d 100644 --- a/sluv-api/src/main/java/com/sluv/api/brand/dto/request/RecentSelectBrandRequest.java +++ b/sluv-api/src/main/java/com/sluv/api/brand/dto/request/RecentSelectBrandRequest.java @@ -2,11 +2,13 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.AccessLevel; +import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @Getter @NoArgsConstructor(access = AccessLevel.PROTECTED) +@AllArgsConstructor public class RecentSelectBrandRequest { @Schema(description = "브랜드 Id") private Long brandId; diff --git a/sluv-api/src/main/java/com/sluv/api/brand/dto/response/BrandSearchResponse.java b/sluv-api/src/main/java/com/sluv/api/brand/dto/response/BrandSearchResponse.java index 362d329e..ef235025 100644 --- a/sluv-api/src/main/java/com/sluv/api/brand/dto/response/BrandSearchResponse.java +++ b/sluv-api/src/main/java/com/sluv/api/brand/dto/response/BrandSearchResponse.java @@ -23,7 +23,7 @@ public class BrandSearchResponse implements Serializable { @Schema(description = "브랜드 이미지 URL") private String brandImgUrl; - public static BrandSearchResponse of(Brand brand) { + public static BrandSearchResponse from(Brand brand) { return BrandSearchResponse.builder() .id(brand.getId()) .brandKr(brand.getBrandKr()) diff --git a/sluv-api/src/main/java/com/sluv/api/brand/dto/response/NewBrandPostResponse.java b/sluv-api/src/main/java/com/sluv/api/brand/dto/response/NewBrandPostResponse.java index f2ec164d..6673dd5e 100644 --- a/sluv-api/src/main/java/com/sluv/api/brand/dto/response/NewBrandPostResponse.java +++ b/sluv-api/src/main/java/com/sluv/api/brand/dto/response/NewBrandPostResponse.java @@ -19,7 +19,7 @@ public class NewBrandPostResponse implements Serializable { @Schema(description = "생성된 newBrand의 이름") private String newBrandName; - public static NewBrandPostResponse of(NewBrand newBrand) { + public static NewBrandPostResponse from(NewBrand newBrand) { return NewBrandPostResponse.builder() .newBrandId(newBrand.getId()) .newBrandName(newBrand.getBrandName()) diff --git a/sluv-api/src/main/java/com/sluv/api/brand/dto/response/RecentSelectBrandResponse.java b/sluv-api/src/main/java/com/sluv/api/brand/dto/response/RecentSelectBrandResponse.java index 6f6abb9b..ddcc1599 100644 --- a/sluv-api/src/main/java/com/sluv/api/brand/dto/response/RecentSelectBrandResponse.java +++ b/sluv-api/src/main/java/com/sluv/api/brand/dto/response/RecentSelectBrandResponse.java @@ -22,7 +22,7 @@ public class RecentSelectBrandResponse { @Schema(description = "브랜드(Y)와 뉴브랜드(N)를 구분하는 플래그") private String flag; - public static RecentSelectBrandResponse of(RecentSelectBrand recentSelectBrand) { + public static RecentSelectBrandResponse from(RecentSelectBrand recentSelectBrand) { Long id; String brandName; String brandImgUrl; diff --git a/sluv-api/src/main/java/com/sluv/api/brand/service/BrandService.java b/sluv-api/src/main/java/com/sluv/api/brand/service/BrandService.java index 30e330fa..a091ba9b 100644 --- a/sluv-api/src/main/java/com/sluv/api/brand/service/BrandService.java +++ b/sluv-api/src/main/java/com/sluv/api/brand/service/BrandService.java @@ -29,28 +29,18 @@ public class BrandService { public PaginationResponse findAllBrand(String brandName, Pageable pageable) { Page brandPage = brandDomainService.findByAllBrandKrOrBrandEnStartingWith(brandName, pageable); - List dtoList = brandPage.stream() - .map(BrandSearchResponse::of) + List brandSearchResponses = brandPage.stream() + .map(BrandSearchResponse::from) .toList(); - return PaginationResponse.create(brandPage, dtoList); + return PaginationResponse.of(brandPage, brandSearchResponses); } @Transactional(readOnly = true) public List findTopBrand() { return brandDomainService.findTopBrand() .stream() - .map(BrandSearchResponse::of) - .toList(); - } - - @Transactional(readOnly = true) - public List findRecentSelectBrand(Long userId) { - User user = userDomainService.findById(userId); - List recentSelectBrandList = recentSelectBrandDomainService.getRecentSelectBrandTop20(user); - - return recentSelectBrandList.stream() - .map(RecentSelectBrandResponse::of) + .map(BrandSearchResponse::from) .toList(); } diff --git a/sluv-api/src/main/java/com/sluv/api/brand/service/NewBrandService.java b/sluv-api/src/main/java/com/sluv/api/brand/service/NewBrandService.java index e3774b3a..73a1f213 100644 --- a/sluv-api/src/main/java/com/sluv/api/brand/service/NewBrandService.java +++ b/sluv-api/src/main/java/com/sluv/api/brand/service/NewBrandService.java @@ -25,7 +25,7 @@ public NewBrandPostResponse postNewBrand(NewBrandPostRequest request) { webHookService.sendCreateNewBrandMessage(newBrand); } - return NewBrandPostResponse.of(newBrand); + return NewBrandPostResponse.from(newBrand); } diff --git a/sluv-api/src/main/java/com/sluv/api/brand/service/RecentSelectBrandService.java b/sluv-api/src/main/java/com/sluv/api/brand/service/RecentSelectBrandService.java index b57dc2e9..7510d8e7 100644 --- a/sluv-api/src/main/java/com/sluv/api/brand/service/RecentSelectBrandService.java +++ b/sluv-api/src/main/java/com/sluv/api/brand/service/RecentSelectBrandService.java @@ -1,6 +1,7 @@ package com.sluv.api.brand.service; import com.sluv.api.brand.dto.request.RecentSelectBrandRequest; +import com.sluv.api.brand.dto.response.RecentSelectBrandResponse; import com.sluv.domain.brand.entity.Brand; import com.sluv.domain.brand.entity.NewBrand; import com.sluv.domain.brand.entity.RecentSelectBrand; @@ -14,6 +15,8 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.List; + @Service @Slf4j @RequiredArgsConstructor @@ -47,4 +50,14 @@ public void deleteRecentSelectBrand(Long userId, Long brandId, String flag) { } } + @Transactional(readOnly = true) + public List findRecentSelectBrand(Long userId) { + User user = userDomainService.findById(userId); + List recentSelectBrands = recentSelectBrandDomainService.getRecentSelectBrandTop20(user); + + return recentSelectBrands.stream() + .map(RecentSelectBrandResponse::from) + .toList(); + } + } diff --git a/sluv-api/src/main/java/com/sluv/api/celeb/controller/CelebActivityController.java b/sluv-api/src/main/java/com/sluv/api/celeb/controller/CelebActivityController.java index 3d7cab96..07be140f 100644 --- a/sluv-api/src/main/java/com/sluv/api/celeb/controller/CelebActivityController.java +++ b/sluv-api/src/main/java/com/sluv/api/celeb/controller/CelebActivityController.java @@ -25,7 +25,7 @@ public class CelebActivityController { public ResponseEntity>> getCelebActivity( @PathVariable("celebId") Long celebId) { List response = celebActivityService.getCelebActivity(celebId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } } diff --git a/sluv-api/src/main/java/com/sluv/api/celeb/controller/CelebController.java b/sluv-api/src/main/java/com/sluv/api/celeb/controller/CelebController.java index 197dab52..e7b7eb6c 100644 --- a/sluv-api/src/main/java/com/sluv/api/celeb/controller/CelebController.java +++ b/sluv-api/src/main/java/com/sluv/api/celeb/controller/CelebController.java @@ -28,7 +28,7 @@ public class CelebController { public ResponseEntity>> searchCelebByName( @RequestParam String celebName, Pageable pageable) { PaginationResponse response = celebService.searchCeleb(celebName, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "관심셀럽 등록 시 Celeb 검색", description = "멤버 이름을 검색하면 그룹이 검색됨. Pagination X") @@ -36,20 +36,20 @@ public ResponseEntity>> searchInterestedCelebByName( @RequestParam String celebName) { List response = celebService.searchInterestedCelebByName(celebName); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "인기 셀럽 조회", description = "조회가 많이된 Celeb 상위 10개 조회") @GetMapping("/top") public ResponseEntity>> searchTop10Celeb() { List response = celebService.getTop10Celeb(); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "관심 셀럽 조회 시, 카테고리별 셀럽 조회", description = "카테고리별 최대 30개를 한번에 전달, 카테고리는 순서 X, 셀럽는 가나다 순서.") @GetMapping("/category") public ResponseEntity>> searchCelebByCategory() { List response = celebService.getCelebByCategory(); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } } diff --git a/sluv-api/src/main/java/com/sluv/api/celeb/controller/NewCelebController.java b/sluv-api/src/main/java/com/sluv/api/celeb/controller/NewCelebController.java index 6cbd2d42..ee22c380 100644 --- a/sluv-api/src/main/java/com/sluv/api/celeb/controller/NewCelebController.java +++ b/sluv-api/src/main/java/com/sluv/api/celeb/controller/NewCelebController.java @@ -24,7 +24,7 @@ public class NewCelebController { public ResponseEntity> postNewCeleb( @RequestBody NewCelebPostRequest request) { NewCelebPostResponse response = newCelebService.postNewCeleb(request); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } } diff --git a/sluv-api/src/main/java/com/sluv/api/celeb/controller/RecentSelectCelebController.java b/sluv-api/src/main/java/com/sluv/api/celeb/controller/RecentSelectCelebController.java index db5ef12a..b6fb9fc6 100644 --- a/sluv-api/src/main/java/com/sluv/api/celeb/controller/RecentSelectCelebController.java +++ b/sluv-api/src/main/java/com/sluv/api/celeb/controller/RecentSelectCelebController.java @@ -27,7 +27,7 @@ public class RecentSelectCelebController { public ResponseEntity>> getRecentSelectCeleb( @CurrentUserId Long userId) { List response = celebService.getUserRecentSelectCeleb(userId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*최근 선택한 셀럽 등록", description = "User 토큰 필요.") diff --git a/sluv-api/src/main/java/com/sluv/api/celeb/service/CelebService.java b/sluv-api/src/main/java/com/sluv/api/celeb/service/CelebService.java index 7a981b51..e0437146 100644 --- a/sluv-api/src/main/java/com/sluv/api/celeb/service/CelebService.java +++ b/sluv-api/src/main/java/com/sluv/api/celeb/service/CelebService.java @@ -40,7 +40,7 @@ public PaginationResponse searchCeleb(String celebName, Pag .map(CelebSearchResponse::of) .toList(); - return PaginationResponse.create(celebPage, content); + return PaginationResponse.of(celebPage, content); } diff --git a/sluv-api/src/main/java/com/sluv/api/closet/controller/ClosetController.java b/sluv-api/src/main/java/com/sluv/api/closet/controller/ClosetController.java index 58d99546..f4941dfd 100644 --- a/sluv-api/src/main/java/com/sluv/api/closet/controller/ClosetController.java +++ b/sluv-api/src/main/java/com/sluv/api/closet/controller/ClosetController.java @@ -23,7 +23,7 @@ public class ClosetController { @GetMapping("/list") public ResponseEntity> getClosetList(@CurrentUserId Long userId) { ClosetListCountResponse response = closetService.getClosetList(userId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "옷장 이름 중복 검사", description = "옷장 등록 및 수정 시 호출") @@ -31,7 +31,7 @@ public ResponseEntity> getClosetLis public ResponseEntity> checkClosetNameDuplicated( @RequestParam("name") String name, @Nullable @RequestParam("id") Long closetId) { ClosetNameCheckResponse response = closetService.checkClosetNameDuplicated(name, closetId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*옷장 생성", description = "User 토큰 필요") diff --git a/sluv-api/src/main/java/com/sluv/api/comment/controller/CommentController.java b/sluv-api/src/main/java/com/sluv/api/comment/controller/CommentController.java index 5a9dea15..bd36a9e0 100644 --- a/sluv-api/src/main/java/com/sluv/api/comment/controller/CommentController.java +++ b/sluv-api/src/main/java/com/sluv/api/comment/controller/CommentController.java @@ -27,7 +27,7 @@ public ResponseEntity>> @PathVariable("questionId") Long questionId, Pageable pageable) { PaginationResponse response = commentService.getComment(userId, questionId, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*Question 게시글의 댓글의 대댓글 조회", description = "User 토큰 필요. Pagination 적용.") @@ -37,7 +37,7 @@ public ResponseEntity response = commentService.getSubComment(userId, commentId, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*댓글 상세 조회", description = "User 토큰 필요. Pagination 적용.") @@ -46,7 +46,7 @@ public ResponseEntity> getCommentDetail( @CurrentUserId Long userId, @PathVariable("commentId") Long commentId) { CommentResponse response = commentService.getCommentDetail(userId, commentId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*댓글 작성", description = "User 토큰 필요") diff --git a/sluv-api/src/main/java/com/sluv/api/comment/service/CommentService.java b/sluv-api/src/main/java/com/sluv/api/comment/service/CommentService.java index 0bf4cfdb..ae71c70d 100644 --- a/sluv-api/src/main/java/com/sluv/api/comment/service/CommentService.java +++ b/sluv-api/src/main/java/com/sluv/api/comment/service/CommentService.java @@ -60,7 +60,7 @@ public PaginationResponse getComment(Long userId, Long question // Content 제작 List content = commentHelper.getCommentResDtos(user, commentPage.getContent()); - return PaginationResponse.create(commentPage, content); + return PaginationResponse.of(commentPage, content); } /** diff --git a/sluv-api/src/main/java/com/sluv/api/common/image/AWSS3Controller.java b/sluv-api/src/main/java/com/sluv/api/common/image/AWSS3Controller.java index e918b597..98f986a2 100644 --- a/sluv-api/src/main/java/com/sluv/api/common/image/AWSS3Controller.java +++ b/sluv-api/src/main/java/com/sluv/api/common/image/AWSS3Controller.java @@ -23,7 +23,7 @@ public class AWSS3Controller { public ResponseEntity> getUserProfileUrl( @RequestParam ImgExtension imgExtension) { PreSingedUrlResDto response = awss3Service.forUserProfile(imgExtension); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "아이템 이미지 업로드", description = "아이템 이미지 업로드\n imgExtension: 이미지 확장자") @@ -31,7 +31,7 @@ public ResponseEntity> getUserProfileUrl public ResponseEntity> getItemImgUrl( @RequestParam ImgExtension imgExtension) { PreSingedUrlResDto response = awss3Service.forItem(imgExtension); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "커뮤니티 게시글 이미지 업로드", description = "커뮤니티 게시글 이미지 업로드\n imgExtension: 이미지 확장자") @@ -39,7 +39,7 @@ public ResponseEntity> getItemImgUrl( public ResponseEntity> getQuestionImgUrl( @RequestParam ImgExtension imgExtension) { PreSingedUrlResDto response = awss3Service.forCommunityPost(imgExtension); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "커뮤니티 댓글 이미지 업로드", description = "커뮤니티 댓글 이미지 업로드\n imgExtension: 이미지 확장자") @@ -47,7 +47,7 @@ public ResponseEntity> getQuestionImgUrl public ResponseEntity> getCommentImgUrl( @RequestParam ImgExtension imgExtension) { PreSingedUrlResDto response = awss3Service.forCommunityComment(imgExtension); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "옷장 이미지 업로드", description = "옷장 이미지 업로드\n imgExtension: 이미지 확장자") @@ -55,6 +55,6 @@ public ResponseEntity> getCommentImgUrl( public ResponseEntity> getClosetImgUrl( @RequestParam ImgExtension imgExtension) { PreSingedUrlResDto response = awss3Service.forCloset(imgExtension); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } } diff --git a/sluv-api/src/main/java/com/sluv/api/common/response/PaginationResponse.java b/sluv-api/src/main/java/com/sluv/api/common/response/PaginationResponse.java index e12d958d..79462f80 100644 --- a/sluv-api/src/main/java/com/sluv/api/common/response/PaginationResponse.java +++ b/sluv-api/src/main/java/com/sluv/api/common/response/PaginationResponse.java @@ -20,7 +20,7 @@ public class PaginationResponse { @Schema(description = "데이터들") private List content; - public static PaginationResponse create(Page page, List content) { + public static PaginationResponse of(Page page, List content) { return PaginationResponse.builder() .page(page.getNumber()) .hasNext(page.hasNext()) diff --git a/sluv-api/src/main/java/com/sluv/api/common/response/SuccessDataResponse.java b/sluv-api/src/main/java/com/sluv/api/common/response/SuccessDataResponse.java index eb6c4f2b..8a9f0d0e 100644 --- a/sluv-api/src/main/java/com/sluv/api/common/response/SuccessDataResponse.java +++ b/sluv-api/src/main/java/com/sluv/api/common/response/SuccessDataResponse.java @@ -17,7 +17,7 @@ public SuccessDataResponse(T result) { this.result = result; } - public static SuccessDataResponse create(T result) { + public static SuccessDataResponse from(T result) { return SuccessDataResponse.builder() .result(result) .build(); diff --git a/sluv-api/src/main/java/com/sluv/api/item/controller/HashtagController.java b/sluv-api/src/main/java/com/sluv/api/item/controller/HashtagController.java index 4768ee63..580086e6 100644 --- a/sluv-api/src/main/java/com/sluv/api/item/controller/HashtagController.java +++ b/sluv-api/src/main/java/com/sluv/api/item/controller/HashtagController.java @@ -25,7 +25,7 @@ public class HashtagController { public ResponseEntity>> getHashtag( @Nullable @RequestParam String name, Pageable pageable) { PaginationResponse response = hashtagService.getHashtag(name, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "새로운 해쉬태그 등록", @@ -34,6 +34,6 @@ public ResponseEntity public ResponseEntity> postHashtag( @RequestBody HashtagRequestDto requestDto) { HashtagPostResponseDto response = hashtagService.postHashtag(requestDto); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } } diff --git a/sluv-api/src/main/java/com/sluv/api/item/controller/ItemCategoryController.java b/sluv-api/src/main/java/com/sluv/api/item/controller/ItemCategoryController.java index 4f843b36..92314697 100644 --- a/sluv-api/src/main/java/com/sluv/api/item/controller/ItemCategoryController.java +++ b/sluv-api/src/main/java/com/sluv/api/item/controller/ItemCategoryController.java @@ -24,7 +24,7 @@ public class ItemCategoryController { public ResponseEntity>> getItemCategory() { List response = itemCategoryService.getItemCategory(); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } } diff --git a/sluv-api/src/main/java/com/sluv/api/item/controller/ItemController.java b/sluv-api/src/main/java/com/sluv/api/item/controller/ItemController.java index 0efaaae5..aa9f8864 100644 --- a/sluv-api/src/main/java/com/sluv/api/item/controller/ItemController.java +++ b/sluv-api/src/main/java/com/sluv/api/item/controller/ItemController.java @@ -34,7 +34,7 @@ public class ItemController { public ResponseEntity> getItemDetail(@CurrentUserId Long userId, @PathVariable("itemId") Long itemId) { ItemDetailResDto response = itemService.getItemDetail(userId, itemId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } /** @@ -45,7 +45,7 @@ public ResponseEntity> getItemDetail(@Curr public ResponseEntity>> getSameCelebItem( @CurrentUserId Long userId, @RequestParam("itemId") Long itemId) { List response = itemService.getSameCelebItems(userId, itemId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } /** @@ -56,7 +56,7 @@ public ResponseEntity>> getSameCelebItem public ResponseEntity>> getSameBrandItem( @CurrentUserId Long userId, @RequestParam("itemId") Long itemId) { List response = itemService.getSameBrandItem(userId, itemId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } /** @@ -68,7 +68,7 @@ public ResponseEntity>> getTogetherScrap @CurrentUserId Long userId, @RequestParam("itemId") Long itemId) { List response = itemService.getTogetherScrapItem(userId, itemId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*최근 본 아이템 조회", description = "User 토큰 필요. Pagination 적용. 최근 본 순서로 정렬.") @@ -76,7 +76,7 @@ public ResponseEntity>> getTogetherScrap public ResponseEntity>> getRecentItem( @CurrentUserId Long userId, Pageable pageable) { PaginationResponse response = itemService.getRecentItem(userId, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*찜한 아이템 조회", description = "User 토큰 필요. Pagination 적용. 스크랩한 최신순으로 정렬.") @@ -84,7 +84,7 @@ public ResponseEntity>> ge public ResponseEntity>> getScrapItem( @CurrentUserId Long userId, Pageable pageable) { PaginationResponse response = itemService.getScrapItem(userId, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*아이템 등록 및 수정", description = "User 토큰 필요") @@ -92,7 +92,7 @@ public ResponseEntity>> ge public ResponseEntity> postItem(@CurrentUserId Long userId, @RequestBody ItemPostReqDto reqDto) { ItemPostResDto response = itemService.postItem(userId, reqDto); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "아이템 게시글 좋아요", description = "User 토큰 필요") @@ -120,7 +120,7 @@ public ResponseEntity deleteItem(@PathVariable("itemId") Long i public ResponseEntity>> getRecommendItem( @CurrentUserId Long userId, Pageable pageable) { PaginationResponse response = itemService.getRecommendItem(userId, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*핫한 셀럽들이 선택한 여름나기 아이템 조회", @@ -131,7 +131,7 @@ public ResponseEntity>> ge Pageable pageable, SearchFilterReqDto dto) { PaginationResponse response = itemService.getSummerItem(userId, pageable, dto); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*지금 당장 구매가능한 아이템 조회", @@ -142,7 +142,7 @@ public ResponseEntity>> ge Pageable pageable, SearchFilterReqDto dto) { PaginationResponse response = itemService.getNowBuyItem(userId, pageable, dto); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*실시간 뉴 아이템 조회", description = "WhenDiscovery 기준 아이템 조회. User 토큰 필요. Pagination 적용.") @@ -151,7 +151,7 @@ public ResponseEntity>> ge @CurrentUserId Long userId, Pageable pageable) { PaginationResponse response = itemService.getNewItem(userId, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*주목해야할 럭셔리 무드 아이템 조회", description = "User 토큰 필요. Pagination 적용.") @@ -161,7 +161,7 @@ public ResponseEntity>> ge Pageable pageable, SearchFilterReqDto dto) { PaginationResponse response = itemService.getLuxuryItem(userId, pageable, dto); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*가성비 좋은 선물 아이템 조회", description = "User 토큰 필요. Pagination 적용.") @@ -171,7 +171,7 @@ public ResponseEntity>> ge Pageable pageable, SearchFilterReqDto filterReqDto) { PaginationResponse response = itemService.getEfficientItem(userId, pageable, filterReqDto); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Deprecated @@ -188,7 +188,7 @@ public ResponseEntity>> getHotItem(@Curr throw new StandardNotFoundException(); } - return ResponseEntity.ok().body(SuccessDataResponse.create(result)); + return ResponseEntity.ok().body(SuccessDataResponse.from(result)); } /** @@ -200,7 +200,7 @@ public ResponseEntity>> getHotItem(@Curr public ResponseEntity>> getHotCelebItem( @CurrentUserId Long userId, Pageable pageable, SearchFilterReqDto dto) { PaginationResponse response = itemService.getHotCelebItem(userId, pageable, dto); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } /** @@ -212,7 +212,7 @@ public ResponseEntity>> ge public ResponseEntity>> getCurationItem( @CurrentUserId Long userId) { List response = itemService.getCurationItem(userId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } /** @@ -223,7 +223,7 @@ public ResponseEntity>> getCurationItem( public ResponseEntity>> getHowAboutItem( @CurrentUserId Long userId) { List response = itemService.getHowAboutItem(userId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*트랜드 셀럽의 아이템", description = "홈 화면 직접 선정한 셀럽의 아이템 조회") @@ -231,7 +231,7 @@ public ResponseEntity>> getHowAboutItem( public ResponseEntity>> getTrendItems( @CurrentUserId Long userId, Pageable pageable) { List response = itemService.getTrendItems(userId, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } } diff --git a/sluv-api/src/main/java/com/sluv/api/item/controller/ItemEditController.java b/sluv-api/src/main/java/com/sluv/api/item/controller/ItemEditController.java index 7a16c9c4..ec2e28a0 100644 --- a/sluv-api/src/main/java/com/sluv/api/item/controller/ItemEditController.java +++ b/sluv-api/src/main/java/com/sluv/api/item/controller/ItemEditController.java @@ -31,6 +31,6 @@ public ResponseEntity postItemEdit(@CurrentUserId Long userId, public ResponseEntity> getItemEdit(@CurrentUserId Long userId, @PathVariable(name = "editReqId") Long editReqId) { ItemEditReqResponseDto response = itemEditReqService.getItemEdit(userId, editReqId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } } diff --git a/sluv-api/src/main/java/com/sluv/api/item/controller/PlaceRankController.java b/sluv-api/src/main/java/com/sluv/api/item/controller/PlaceRankController.java index c81539bb..3ee12c80 100644 --- a/sluv-api/src/main/java/com/sluv/api/item/controller/PlaceRankController.java +++ b/sluv-api/src/main/java/com/sluv/api/item/controller/PlaceRankController.java @@ -27,7 +27,7 @@ public class PlaceRankController { @GetMapping("/top") public ResponseEntity>> getTopPlace() { List response = itemService.getTopPlace(); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*유저가 최근 입력한 장소 검색", description = "User 토큰 필요") @@ -35,7 +35,7 @@ public ResponseEntity>> getTopPlace() { public ResponseEntity>> getRecentPlaceTop20( @CurrentUserId Long userId) { List response = placeRankService.getRecentPlaceTop20(userId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*최근 입력한 장소 등록", description = "User 토큰 필요.") diff --git a/sluv-api/src/main/java/com/sluv/api/item/controller/TempItemController.java b/sluv-api/src/main/java/com/sluv/api/item/controller/TempItemController.java index 7afb1834..218d77c2 100644 --- a/sluv-api/src/main/java/com/sluv/api/item/controller/TempItemController.java +++ b/sluv-api/src/main/java/com/sluv/api/item/controller/TempItemController.java @@ -26,7 +26,7 @@ public class TempItemController { public ResponseEntity>> getTempItemList( @CurrentUserId Long userId, Pageable pageable) { PaginationCountResponse response = tempItemService.getTempItemList(userId, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*임시저장 아이템 갯수 조회", description = "User 토큰 필요") @@ -34,7 +34,7 @@ public ResponseEntity> getTempItemCount( @CurrentUserId Long userId) { TempItemCountResDto response = tempItemService.countTempItemCount(userId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*Item 임시저장", description = "User 토큰 필요") @@ -42,7 +42,7 @@ public ResponseEntity> getTempItemCount public ResponseEntity> postTempItem(@CurrentUserId Long userId, @RequestBody TempItemPostReqDto reqDto) { TempItemPostResDto response = TempItemPostResDto.of(tempItemService.postTempItem(userId, reqDto)); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "임시저장 아이템 선택삭제", description = "User 토큰 필요") diff --git a/sluv-api/src/main/java/com/sluv/api/item/dto/ItemDetailFixData.java b/sluv-api/src/main/java/com/sluv/api/item/dto/ItemDetailFixData.java index 8f7a8b0c..32305572 100644 --- a/sluv-api/src/main/java/com/sluv/api/item/dto/ItemDetailFixData.java +++ b/sluv-api/src/main/java/com/sluv/api/item/dto/ItemDetailFixData.java @@ -48,7 +48,7 @@ public static ItemDetailFixData of(Item item, CelebSearchResponse celeb, NewCele ) { NewCelebPostResponse newCelebPostResponse = newCeleb == null ? null : NewCelebPostResponse.of(newCeleb); - NewBrandPostResponse newBrandPostResponse = newBrand == null ? null : NewBrandPostResponse.of(newBrand); + NewBrandPostResponse newBrandPostResponse = newBrand == null ? null : NewBrandPostResponse.from(newBrand); return ItemDetailFixData.builder() .imgList(imgList) diff --git a/sluv-api/src/main/java/com/sluv/api/item/dto/TempItemResDto.java b/sluv-api/src/main/java/com/sluv/api/item/dto/TempItemResDto.java index 3d0fe2ba..48333d08 100644 --- a/sluv-api/src/main/java/com/sluv/api/item/dto/TempItemResDto.java +++ b/sluv-api/src/main/java/com/sluv/api/item/dto/TempItemResDto.java @@ -80,7 +80,7 @@ public static TempItemResDto of(TempItem tempItem, List imgList, Lis : null; NewBrandPostResponse newBrand = tempItem.getNewBrand() != null - ? NewBrandPostResponse.of(tempItem.getNewBrand()) + ? NewBrandPostResponse.from(tempItem.getNewBrand()) : null; return TempItemResDto.builder() diff --git a/sluv-api/src/main/java/com/sluv/api/item/service/HashtagService.java b/sluv-api/src/main/java/com/sluv/api/item/service/HashtagService.java index f122810a..770cf608 100644 --- a/sluv-api/src/main/java/com/sluv/api/item/service/HashtagService.java +++ b/sluv-api/src/main/java/com/sluv/api/item/service/HashtagService.java @@ -29,7 +29,7 @@ public PaginationResponse getHashtag(String name, Pageable p Page hashtagPage = hashtagDomainService.findAllByContent(name, pageable); List dtoList = hashtagPage .stream().map(hashtagHelper::convertHashtagCountDtoToHashtagResponseDto).toList(); - return PaginationResponse.create(hashtagPage, dtoList); + return PaginationResponse.of(hashtagPage, dtoList); } @Transactional diff --git a/sluv-api/src/main/java/com/sluv/api/item/service/ItemService.java b/sluv-api/src/main/java/com/sluv/api/item/service/ItemService.java index 89d3539c..46f844bf 100644 --- a/sluv-api/src/main/java/com/sluv/api/item/service/ItemService.java +++ b/sluv-api/src/main/java/com/sluv/api/item/service/ItemService.java @@ -258,7 +258,7 @@ private ItemDetailFixData getItemDetailFixData(Item item) { // 3. Brand BrandSearchResponse brand = item.getBrand() != null ? - BrandSearchResponse.of(item.getBrand()) + BrandSearchResponse.from(item.getBrand()) : null; // 4. 작성자 info @@ -312,7 +312,7 @@ public PaginationResponse getRecentItem(Long userId, Pageable pag Page recentItemPage = itemDomainService.getRecentItem(user, pageable); List itemSimpleDtos = itemDomainService.getItemSimpleDto(user, recentItemPage.getContent()); - return PaginationResponse.create(recentItemPage, itemSimpleDtos); + return PaginationResponse.of(recentItemPage, itemSimpleDtos); } @@ -322,7 +322,7 @@ public PaginationResponse getScrapItem(Long userId, Pageable page // User, Closet, Item 조인하여 ItemPage 조회 Page itemPage = itemDomainService.getAllScrapItem(user, pageable); List itemSimpleDtos = itemDomainService.getItemSimpleDto(user, itemPage.getContent()); - return PaginationResponse.create(itemPage, itemSimpleDtos); + return PaginationResponse.of(itemPage, itemSimpleDtos); } @Transactional(readOnly = true) @@ -340,7 +340,7 @@ public PaginationResponse getRecommendItem(Long userId, Pageable List content = itemDomainService.getItemSimpleDto(user, recommendItemPage.getContent()); - return PaginationResponse.create(recommendItemPage, content); + return PaginationResponse.of(recommendItemPage, content); } /** @@ -354,7 +354,7 @@ public PaginationResponse getSummerItem(Long userId, Pageable pag // Content 조립 List content = itemDomainService.getItemSimpleDto(user, itemPage.getContent()); - return PaginationResponse.create(itemPage, content); + return PaginationResponse.of(itemPage, content); } /** @@ -371,7 +371,7 @@ public PaginationResponse getNowBuyItem(Long userId, Pageable pag } Page itemPage = itemDomainService.getNowBuyItem(blockUserIds, pageable, dto); List content = itemDomainService.getItemSimpleDto(user, itemPage.getContent()); - return PaginationResponse.create(itemPage, content); + return PaginationResponse.of(itemPage, content); } @Transactional(readOnly = true) @@ -390,7 +390,7 @@ public PaginationResponse getNewItem(Long userId, Pageable pageab // Content 조립 List content = itemDomainService.getItemSimpleDto(user, itemPage.getContent()); - return PaginationResponse.create(itemPage, content); + return PaginationResponse.of(itemPage, content); } @Transactional(readOnly = true) @@ -405,7 +405,7 @@ public PaginationResponse getLuxuryItem(Long userId, Pageable pag Page itemPage = itemDomainService.getLuxuryItem(blockUserIds, pageable, dto); List content = itemDomainService.getItemSimpleDto(user, itemPage.getContent()); - return PaginationResponse.create(itemPage, content); + return PaginationResponse.of(itemPage, content); } @Transactional(readOnly = true) @@ -421,7 +421,7 @@ public PaginationResponse getEfficientItem(Long userId, Pageable Page itemPage = itemDomainService.getEfficientItem(blockUserIds, pageable, filterReqDto); List content = itemDomainService.getItemSimpleDto(user, itemPage.getContent()); - return PaginationResponse.create(itemPage, content); + return PaginationResponse.of(itemPage, content); } @Transactional(readOnly = true) @@ -450,7 +450,7 @@ public PaginationResponse getHotCelebItem(Long userId, Pageable p List content = itemDomainService.getItemSimpleDto(user, itemPage.getContent()); - return PaginationResponse.create(itemPage, content); + return PaginationResponse.of(itemPage, content); } @Transactional(readOnly = true) diff --git a/sluv-api/src/main/java/com/sluv/api/notice/controller/NoticeController.java b/sluv-api/src/main/java/com/sluv/api/notice/controller/NoticeController.java index 1d278b21..31fa103c 100644 --- a/sluv-api/src/main/java/com/sluv/api/notice/controller/NoticeController.java +++ b/sluv-api/src/main/java/com/sluv/api/notice/controller/NoticeController.java @@ -32,7 +32,7 @@ public ResponseEntity response = noticeService.getAllNotice(pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation( @@ -47,6 +47,6 @@ public ResponseEntity> getNoticeDetail @PathVariable("noticeId") Long noticeId) { NoticeDetailResponse response = noticeService.getNoticeDetail(noticeId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } } diff --git a/sluv-api/src/main/java/com/sluv/api/notice/service/NoticeService.java b/sluv-api/src/main/java/com/sluv/api/notice/service/NoticeService.java index 110d360d..691f6a3f 100644 --- a/sluv-api/src/main/java/com/sluv/api/notice/service/NoticeService.java +++ b/sluv-api/src/main/java/com/sluv/api/notice/service/NoticeService.java @@ -32,7 +32,7 @@ public PaginationResponse getAllNotice(Pageable pageable) .map(NoticeSimpleResponse::of) .toList(); - return PaginationResponse.create(noticePage, content); + return PaginationResponse.of(noticePage, content); } /** diff --git a/sluv-api/src/main/java/com/sluv/api/question/controller/QuestionController.java b/sluv-api/src/main/java/com/sluv/api/question/controller/QuestionController.java index d6af46aa..651a4da1 100644 --- a/sluv-api/src/main/java/com/sluv/api/question/controller/QuestionController.java +++ b/sluv-api/src/main/java/com/sluv/api/question/controller/QuestionController.java @@ -29,7 +29,7 @@ public class QuestionController { public ResponseEntity> postFind(@CurrentUserId Long userId, @RequestBody QuestionFindPostReqDto dto) { QuestionPostResDto response = questionService.postQuestionFind(userId, dto); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*이중에뭐살까 게시글 등록", @@ -39,7 +39,7 @@ public ResponseEntity> postBuy(@CurrentU @RequestBody QuestionBuyPostReqDto dto) { QuestionPostResDto response = questionService.postQuestionBuy(userId, dto); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*이거어때 게시글 등록", @@ -50,7 +50,7 @@ public ResponseEntity> postHowabout(@Cur QuestionPostResDto response = questionService.postQuestionHowabout(userId, dto); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*추천해 줘 게시글 등록", @@ -59,7 +59,7 @@ public ResponseEntity> postHowabout(@Cur public ResponseEntity> postRecommend(@CurrentUserId Long userId, @RequestBody QuestionRecommendPostReqDto dto) { QuestionPostResDto response = questionService.postQuestionRecommend(userId, dto); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "Question 게시글 삭제", @@ -94,7 +94,7 @@ public ResponseEntity> postQuestion @CurrentUserId Long userId, @PathVariable("questionId") Long questionId) { QuestionGetDetailResDto response = questionService.getQuestionDetail(userId, questionId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*QuestionBuy 게시글 투표", description = "User 토큰 필요. 좋아요 시스템과 동일.") @@ -121,7 +121,7 @@ public ResponseEntity>> getWaitQu default -> throw new QuestionTypeNotFoundException(); }; - return ResponseEntity.ok().body(SuccessDataResponse.create(result)); + return ResponseEntity.ok().body(SuccessDataResponse.from(result)); } @Operation(summary = "Question 커뮤니티 게시글 종합 검색", description = "Pagination 적용. 최신순으로 조회") @@ -129,7 +129,7 @@ public ResponseEntity>> getWaitQu public ResponseEntity>> getQuestionTotalList( @CurrentUserId Long userId, Pageable pageable) { PaginationResponse response = questionService.getTotalQuestionList(userId, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "QuestionFind 커뮤니티 게시글 검색", @@ -141,7 +141,7 @@ public ResponseEntity response = questionService.getQuestionFindList(userId, celebId, isNewCeleb, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation( @@ -162,7 +162,7 @@ public ResponseEntity response = questionService.getQuestionBuyList(userId, voteStatus, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "QuestionHowabout 커뮤니티 게시글 검색", description = "Pagination 적용. Ordering 최신순") @@ -171,7 +171,7 @@ public ResponseEntity response = questionService.getQuestionHowaboutList( userId, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "QuestionRecommend 커뮤니티 게시글 검색", @@ -181,7 +181,7 @@ public ResponseEntity response = questionService.getQuestionRecommendList( userId, hashtag, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "일간 핫 커뮤니티 게시글 검색", @@ -189,7 +189,7 @@ public ResponseEntity>> getDailyHotQuestionList(@CurrentUserId Long userId) { List response = questionService.getDailyHotQuestionList(userId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "주간 핫 커뮤니티 게시글 검색", @@ -199,6 +199,6 @@ public ResponseEntity response = questionService.getWeeklyHotQuestionList( userId, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } } diff --git a/sluv-api/src/main/java/com/sluv/api/question/service/QuestionService.java b/sluv-api/src/main/java/com/sluv/api/question/service/QuestionService.java index 5445393b..5e848630 100644 --- a/sluv-api/src/main/java/com/sluv/api/question/service/QuestionService.java +++ b/sluv-api/src/main/java/com/sluv/api/question/service/QuestionService.java @@ -630,7 +630,7 @@ public PaginationResponse getTotalQuestionList(Long userId return getQuestionSimpleResDto(question, qType); }).toList(); - return PaginationResponse.create(questionPage, content); + return PaginationResponse.of(questionPage, content); } @Transactional(readOnly = true) @@ -686,7 +686,7 @@ public PaginationResponse getQuestionBuyList(Long userI questionVote); }).toList(); - return PaginationResponse.create(questionPage, content); + return PaginationResponse.of(questionPage, content); } private Long getTotalVoteCount(List imgList, List itemImgList) { @@ -722,7 +722,7 @@ public PaginationResponse getQuestionFindList(Long userId, getQuestionSimpleResDto(question, "Find") ).toList(); - return PaginationResponse.create(questionPage, content); + return PaginationResponse.of(questionPage, content); } @Transactional(readOnly = true) @@ -739,7 +739,7 @@ public PaginationResponse getQuestionHowaboutList(Long use getQuestionSimpleResDto(question, "How") ).toList(); - return PaginationResponse.create(questionPage, content); + return PaginationResponse.of(questionPage, content); } @Transactional(readOnly = true) @@ -756,7 +756,7 @@ public PaginationResponse getQuestionRecommendList(Long us getQuestionSimpleResDto(question, "Recommend") ).toList(); - return PaginationResponse.create(questionPage, content); + return PaginationResponse.of(questionPage, content); } private String getQuestionCelebName(QuestionFind questionFind) { @@ -869,7 +869,7 @@ public PaginationResponse getWeeklyHotQuestionList(Long us return QuestionSimpleResDto.of(question, writer, likeNum, commentNum, imgList, itemImgList, categoryList); }).toList(); - return PaginationResponse.create(page, content); + return PaginationResponse.of(page, content); } } diff --git a/sluv-api/src/main/java/com/sluv/api/search/controller/SearchController.java b/sluv-api/src/main/java/com/sluv/api/search/controller/SearchController.java index d0d1ceb9..744aa9de 100644 --- a/sluv-api/src/main/java/com/sluv/api/search/controller/SearchController.java +++ b/sluv-api/src/main/java/com/sluv/api/search/controller/SearchController.java @@ -49,7 +49,7 @@ public ResponseEntity>> se PaginationResponse response = searchEngineService.getSearchItem(userId, keyword, dto, pageable).get(); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation( @@ -73,7 +73,7 @@ public ResponseEntity response = searchEngineService.getSearchQuestion( userId, keyword, qType, pageable).get(); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation( @@ -92,7 +92,7 @@ public ResponseEntity> Pageable pageable) throws ExecutionException, InterruptedException { PaginationResponse response = searchEngineService.getSearchUser( userId, keyword, pageable).get(); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation( @@ -109,7 +109,7 @@ public ResponseEntity> searchTotal(@Curre @RequestParam("keyword") String keyword) throws ExecutionException, InterruptedException { SearchTotalResDto response = searchEngineTotalService.getSearchTotal(userId, keyword); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation( @@ -123,7 +123,7 @@ public ResponseEntity> searchTotal(@Curre public ResponseEntity> searchItemCount( @RequestParam("keyword") String keyword, SearchFilterReqDto dto) { SearchItemCountResDto response = searchEngineService.getSearchItemCount(keyword, dto); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation( @@ -137,7 +137,7 @@ public ResponseEntity> searchItemCoun public ResponseEntity>> getRecentSearch( @CurrentUserId Long userId) { List response = searchService.getRecentSearch(userId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation( @@ -151,7 +151,7 @@ public ResponseEntity>> getRece @GetMapping("/searchRank") public ResponseEntity>> getRecentSearch() { List response = searchService.getSearchRank(); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation( @@ -166,7 +166,7 @@ public ResponseEntity response = searchService.getSearchKeyword(keyword, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation( @@ -202,6 +202,6 @@ public ResponseEntity> getAllDateB @CurrentUserId Long userId, @RequestParam("keyword") String keyword) { SearchKeywordTotalResDto response = searchService.getAllDateByKeyword(userId, keyword); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } } diff --git a/sluv-api/src/main/java/com/sluv/api/search/service/SearchEngineService.java b/sluv-api/src/main/java/com/sluv/api/search/service/SearchEngineService.java index 5f1ab921..39362476 100644 --- a/sluv-api/src/main/java/com/sluv/api/search/service/SearchEngineService.java +++ b/sluv-api/src/main/java/com/sluv/api/search/service/SearchEngineService.java @@ -58,7 +58,7 @@ public CompletableFuture> getSearchItem(Long u // 서치 데이터 등록 searchService.postSearchData(keyword); - return CompletableFuture.completedFuture(PaginationResponse.create(searchItemPage, content)); + return CompletableFuture.completedFuture(PaginationResponse.of(searchItemPage, content)); } @Transactional @@ -101,7 +101,7 @@ public CompletableFuture> getSearchQues // 서치 데이터 등록 searchService.postSearchData(keyword); - return CompletableFuture.completedFuture(PaginationResponse.create(searchQuestionPage, content)); + return CompletableFuture.completedFuture(PaginationResponse.of(searchQuestionPage, content)); } @@ -122,7 +122,7 @@ public CompletableFuture> getSearchUser(Lo // 서치 데이터 등록 searchService.postSearchData(keyword); - return CompletableFuture.completedFuture(PaginationResponse.create(searchUserPage, content)); + return CompletableFuture.completedFuture(PaginationResponse.of(searchUserPage, content)); } @Transactional diff --git a/sluv-api/src/main/java/com/sluv/api/search/service/SearchService.java b/sluv-api/src/main/java/com/sluv/api/search/service/SearchService.java index ea8ae22d..0366edef 100644 --- a/sluv-api/src/main/java/com/sluv/api/search/service/SearchService.java +++ b/sluv-api/src/main/java/com/sluv/api/search/service/SearchService.java @@ -69,7 +69,7 @@ public PaginationResponse getSearchKeyword(String keyword, .map(searchData -> SearchKeywordResDto.of(searchData.getSearchWord())) .toList(); - return PaginationResponse.create(searchDataPage, content); + return PaginationResponse.of(searchDataPage, content); } @Async @@ -115,7 +115,7 @@ public SearchKeywordTotalResDto getAllDateByKeyword(Long userId, String keyword) .toList(); List brandByContainKeyword = brandDomainService.getBrandContainKeyword(keyword).stream() - .map(BrandSearchResponse::of) + .map(BrandSearchResponse::from) .toList(); List itemByContainKeyword = itemDomainService.getItemContainKeyword(keyword).stream() diff --git a/sluv-api/src/main/java/com/sluv/api/user/controller/FollowController.java b/sluv-api/src/main/java/com/sluv/api/user/controller/FollowController.java index baa5f24e..0ee13192 100644 --- a/sluv-api/src/main/java/com/sluv/api/user/controller/FollowController.java +++ b/sluv-api/src/main/java/com/sluv/api/user/controller/FollowController.java @@ -24,7 +24,7 @@ public class FollowController { public ResponseEntity>> getUserFollower( @CurrentUserId Long userId, @PathVariable("userId") Long targetId, Pageable pageable) { PaginationResponse response = followService.getUserFollower(userId, targetId, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*특정 유저가 등록한 팔로잉 조회", description = "User 토큰 필요. Pagination 적용") @@ -33,7 +33,7 @@ public ResponseEntity> @CurrentUserId Long userId, @PathVariable("userId") Long targetId, Pageable pageable) { PaginationResponse response = followService.getUserFollowing(userId, targetId, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*현재 유저를 등록한 팔로워들 조회", description = "User 토큰 필요. Pagination 적용") @@ -41,7 +41,7 @@ public ResponseEntity> public ResponseEntity>> getNowUserFollower( @CurrentUserId Long userId, Pageable pageable) { PaginationResponse response = followService.getUserFollower(userId, userId, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*현재 유저가 등록한 팔로잉 조회", description = "User 토큰 필요. Pagination 적용") @@ -49,7 +49,7 @@ public ResponseEntity> public ResponseEntity>> getNowUserFollowing( @CurrentUserId Long userId, Pageable pageable) { PaginationResponse response = followService.getUserFollowing(userId, userId, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*유저 팔로우/팔로잉", description = "User 토큰 필요") diff --git a/sluv-api/src/main/java/com/sluv/api/user/controller/UserBlockController.java b/sluv-api/src/main/java/com/sluv/api/user/controller/UserBlockController.java index 0b541c38..ac1dd744 100644 --- a/sluv-api/src/main/java/com/sluv/api/user/controller/UserBlockController.java +++ b/sluv-api/src/main/java/com/sluv/api/user/controller/UserBlockController.java @@ -29,7 +29,7 @@ public ResponseEntity postUserBlock(@CurrentUserId Long userId, public ResponseEntity>> getUserBlock(@CurrentUserId Long userId, Pageable pageable) { PaginationResponse response = userBlockService.getUserBlock(userId, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } } diff --git a/sluv-api/src/main/java/com/sluv/api/user/controller/UserCelebController.java b/sluv-api/src/main/java/com/sluv/api/user/controller/UserCelebController.java index cdbca7f5..4c4da16f 100644 --- a/sluv-api/src/main/java/com/sluv/api/user/controller/UserCelebController.java +++ b/sluv-api/src/main/java/com/sluv/api/user/controller/UserCelebController.java @@ -28,7 +28,7 @@ public ResponseEntity> @CurrentUserId Long userId) { List response = userCelebService.getInterestedCelebByCategory( userId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*현재 유저의 관심 샐럽을 등록순을 기준으로 조회", @@ -38,7 +38,7 @@ public ResponseEntity>> @CurrentUserId Long userId) { List response = userCelebService.getInterestedCelebByPostTime( userId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "특정 유저의 관심 샐럽을 등록순을 기준으로 조회", @@ -47,7 +47,7 @@ public ResponseEntity>> public ResponseEntity>> getTargetUserInterestedCelebByPostTime( @PathVariable("userId") Long userId) { List response = userCelebService.getInterestedCelebByPostTime(userId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*특정 유저의 관심 샐럽을 카테고리를 기준으로 조회", @@ -56,7 +56,7 @@ public ResponseEntity>> public ResponseEntity>> getTargetUserInterestedCelebByCategory( @PathVariable("userId") Long userId) { List response = userCelebService.getInterestedCelebByCategory(userId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*유저의 관심 셀럽 업데이트", description = "User 토큰 필요") diff --git a/sluv-api/src/main/java/com/sluv/api/user/controller/UserController.java b/sluv-api/src/main/java/com/sluv/api/user/controller/UserController.java index c361cc4f..f5defc36 100644 --- a/sluv-api/src/main/java/com/sluv/api/user/controller/UserController.java +++ b/sluv-api/src/main/java/com/sluv/api/user/controller/UserController.java @@ -50,14 +50,14 @@ public ResponseEntity postUserProfile(@CurrentUserId Long userI public ResponseEntity> getTargetUserMypage(@CurrentUserId Long userId, @PathVariable("userId") Long targetId) { UserMypageResDto response = userService.getUserMypage(userId, targetId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "현재 유저의 마이페이지 조회", description = "User 토큰 필요") @GetMapping("/mypage") public ResponseEntity> getUserMypage(@CurrentUserId Long userId) { UserMypageResDto response = userService.getUserMypage(userId, null); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "특정 유저의 아이템 목록 조회", description = "User 토큰 필요. Pagination 적용.") @@ -65,7 +65,7 @@ public ResponseEntity> getUserMypage(@Curr public ResponseEntity>> getUserItem( @CurrentUserId Long userId, @PathVariable("userId") Long targetId, Pageable pageable) { PaginationResponse response = userService.getUserItem(userId, targetId, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*특정 유저의 옷장 목록 조회", description = "User 토큰 필요. Pagination 적용.") @@ -73,14 +73,14 @@ public ResponseEntity>> ge public ResponseEntity>> getUserCloset( @CurrentUserId Long userId, @PathVariable("userId") Long targetId, Pageable pageable) { PaginationResponse response = userService.getUserCloset(userId, targetId, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*유저의 이메일, 소셜 종류 조회", description = "User 토큰 필요.") @GetMapping("/social") public ResponseEntity> getUserSocialData(@CurrentUserId Long userId) { UserSocialDto response = userService.getUserSocialData(userId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*유저의 프로필 이미지 수정", description = "User 토큰 필요. Pagination 적용.") @@ -105,7 +105,7 @@ public ResponseEntity deleteUserProfileImg(@CurrentUserId Long public ResponseEntity>> getUserUploadItem( @CurrentUserId Long userId, Pageable pageable) { PaginationCountResponse response = userService.getUserUploadItem(userId, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*유저가 작성한 Question 게시글 조회", description = "User 토큰 필요. Pagination 적용.") @@ -115,7 +115,7 @@ public ResponseEntity response = userService.getUserUploadQuestion(userId, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*유저가 작성한 Comment 게시글 조회", description = "User 토큰 필요. Pagination 적용.") @@ -124,7 +124,7 @@ public ResponseEntity response = userService.getUserUploadComment(userId, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } /** @@ -136,21 +136,21 @@ public ResponseEntity>> getHotSluver @Nullable @RequestParam("celebId") Long celebId, @Nullable @RequestParam("isNewCeleb") Boolean isNewCeleb) { List response = userService.getHotSluver(userId, celebId, isNewCeleb); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*약관 동의", description = "광고성 정보 수신 및 마케팅 활용 동의") @PostMapping("/terms") public ResponseEntity> postTerms(@CurrentUserId Long userId) { UserTermsResDto response = userService.postTerms(userId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*약관 동의 상태 조회", description = "광고성 정보 수신 및 마케팅 활용 동의 상태 조회") @GetMapping("/terms") public ResponseEntity> getUserTermsStatus(@CurrentUserId Long userId) { UserTermsResDto response = userService.findUserTermsStatus(userId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*회원 탈퇴", description = "회원 탈퇴 기능") @@ -165,7 +165,7 @@ public ResponseEntity withdrawUser(@CurrentUserId Long userId, @PatchMapping("/alarm-status") public ResponseEntity> changeUserAlarmStatus(@CurrentUserId Long userId) { UserAlarmStatusResponse response = userService.changeAlarmStatus(userId); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } } diff --git a/sluv-api/src/main/java/com/sluv/api/user/controller/UserLikeController.java b/sluv-api/src/main/java/com/sluv/api/user/controller/UserLikeController.java index 5bf90ae4..4c541316 100644 --- a/sluv-api/src/main/java/com/sluv/api/user/controller/UserLikeController.java +++ b/sluv-api/src/main/java/com/sluv/api/user/controller/UserLikeController.java @@ -28,7 +28,7 @@ public ResponseEntity @CurrentUserId Long userId, Pageable pageable) { PaginationCountResponse response = userLikeService.getUserLikeItem(userId, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "유저가 좋아요한 Question 게시글 조회", description = "User 토큰 필요. Pagination 적용.") @@ -37,7 +37,7 @@ public ResponseEntity response = userLikeService.getUserLikeQuestion(userId, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "유저가 좋아요한 Comment 조회", description = "User 토큰 필요. Pagination 적용.") @@ -46,6 +46,6 @@ public ResponseEntity response = userLikeService.getUserLikeComment(userId, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } } diff --git a/sluv-api/src/main/java/com/sluv/api/user/controller/UserRecentController.java b/sluv-api/src/main/java/com/sluv/api/user/controller/UserRecentController.java index d9c12f68..8a4f5c7d 100644 --- a/sluv-api/src/main/java/com/sluv/api/user/controller/UserRecentController.java +++ b/sluv-api/src/main/java/com/sluv/api/user/controller/UserRecentController.java @@ -25,7 +25,7 @@ public class UserRecentController { public ResponseEntity>> getUserRecentItem( @CurrentUserId Long userId, Pageable pageable) { PaginationCountResponse response = userRecentService.getUserRecentItem(userId, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } @Operation(summary = "*유저의 최근 본 Question 조회", description = "User 토큰 필요. Pagination 적용.") @@ -34,6 +34,6 @@ public ResponseEntity response = userRecentService.getUserRecentQuestion( userId, pageable); - return ResponseEntity.ok().body(SuccessDataResponse.create(response)); + return ResponseEntity.ok().body(SuccessDataResponse.from(response)); } } diff --git a/sluv-api/src/main/java/com/sluv/api/user/service/FollowService.java b/sluv-api/src/main/java/com/sluv/api/user/service/FollowService.java index 9fc5ae55..5bf211cf 100644 --- a/sluv-api/src/main/java/com/sluv/api/user/service/FollowService.java +++ b/sluv-api/src/main/java/com/sluv/api/user/service/FollowService.java @@ -52,7 +52,7 @@ public PaginationResponse getUserFollower(Long userId, Long t List content = followDomainService.getUserSearchInfoDto(user, followerPage.getContent(), "follower"); - return PaginationResponse.create(followerPage, content); + return PaginationResponse.of(followerPage, content); } @Transactional(readOnly = true) @@ -66,7 +66,7 @@ public PaginationResponse getUserFollowing(Long userId, Long List content = followDomainService.getUserSearchInfoDto(user, followerPage.getContent(), "followee"); - return PaginationResponse.create(followerPage, content); + return PaginationResponse.of(followerPage, content); } } diff --git a/sluv-api/src/main/java/com/sluv/api/user/service/UserBlockService.java b/sluv-api/src/main/java/com/sluv/api/user/service/UserBlockService.java index 692c7042..ef1aab7a 100644 --- a/sluv-api/src/main/java/com/sluv/api/user/service/UserBlockService.java +++ b/sluv-api/src/main/java/com/sluv/api/user/service/UserBlockService.java @@ -45,6 +45,6 @@ public PaginationResponse getUserBlock(Long userId, Pageable pagea .map(userBlock -> UserBlockDto.of(userBlock.getBlockedUser(), true)) .toList(); - return PaginationResponse.create(blockUserPage, content); + return PaginationResponse.of(blockUserPage, content); } } diff --git a/sluv-api/src/main/java/com/sluv/api/user/service/UserService.java b/sluv-api/src/main/java/com/sluv/api/user/service/UserService.java index cf3ddf85..503d5dff 100644 --- a/sluv-api/src/main/java/com/sluv/api/user/service/UserService.java +++ b/sluv-api/src/main/java/com/sluv/api/user/service/UserService.java @@ -131,7 +131,7 @@ public PaginationResponse getUserItem(Long userId, Long targetId, .map(item -> itemHelper.convertItemToSimpleResDto(item, user)) .toList(); - return PaginationResponse.create(itemPage, content); + return PaginationResponse.of(itemPage, content); } @Transactional(readOnly = true) @@ -150,7 +150,7 @@ public PaginationResponse getUserCloset(Long userId, Long target .map(closet -> ClosetResponse.of(closet, itemScrapDomainService.countByClosetId(closet.getId()))) .toList(); - return PaginationResponse.create(closetPage, content); + return PaginationResponse.of(closetPage, content); } @Transactional diff --git a/sluv-api/src/test/java/com/sluv/api/domain/brand/controller/BrandControllerTest.java b/sluv-api/src/test/java/com/sluv/api/domain/brand/controller/BrandControllerTest.java new file mode 100644 index 00000000..edad75fc --- /dev/null +++ b/sluv-api/src/test/java/com/sluv/api/domain/brand/controller/BrandControllerTest.java @@ -0,0 +1,101 @@ +package com.sluv.api.domain.brand.controller; + +import com.sluv.api.brand.controller.BrandController; +import com.sluv.api.brand.dto.response.BrandSearchResponse; +import com.sluv.api.brand.service.BrandService; +import com.sluv.api.common.response.PaginationResponse; +import com.sluv.domain.brand.entity.Brand; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.web.servlet.MockMvc; + +import java.util.ArrayList; +import java.util.List; + +import static org.hamcrest.Matchers.hasSize; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@WebMvcTest(controllers = BrandController.class) +@ActiveProfiles("test") +public class BrandControllerTest { + + @Autowired + private MockMvc mockMvc; + + @MockBean + private BrandService brandService; + + + @Test + @DisplayName("브랜드 검색") + @WithMockUser("1") + void getBrandSearchTest() throws Exception { + // given + String searchKeyword = "나"; + String brandKrName = "나이키"; + String brandEnName = "NIKE"; + String brandImageUrl = "http://image.url"; + PageRequest pageable = PageRequest.of(0, 1); + Brand brand = Brand.of(brandKrName, brandEnName, brandImageUrl); + List content = List.of(brand); + Page brandPage = new PageImpl<>(content, pageable, content.size()); + + + BrandSearchResponse responseDto = BrandSearchResponse.from(brand); + List responseDtos = List.of(responseDto); + PaginationResponse response = PaginationResponse.of(brandPage, responseDtos); + + when(brandService.findAllBrand(searchKeyword, pageable)).thenReturn(response); + + + // when & then + mockMvc.perform(get("/app/brand/search") + .param("brandName", searchKeyword) + .param("size", "1") + .param("page", "0") + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.isSuccess").value(true)) + .andExpect(jsonPath("$.result.content[0].brandKr").value(brandKrName)) + .andExpect(jsonPath("$.result.content[0].brandEn").value(brandEnName)) + .andExpect(jsonPath("$.result.content[0].brandImgUrl").value(brandImageUrl)); + } + + @Test + @DisplayName("Top 10 브랜드 검색") + @WithMockUser("1") + void getTopBrandTest() throws Exception { + // given + List content = new ArrayList<>(); + for (int i=1; i<=10; i++) { + Brand brand = Brand.of("나이키" + i, "NIKE" + i, "http://image.url"); + content.add(BrandSearchResponse.from(brand)); + } + + when(brandService.findTopBrand()).thenReturn(content); + + // when & then + mockMvc.perform(get("/app/brand/top") + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.isSuccess").value(true)) + .andExpect(jsonPath("$.result", hasSize(10))); + } + +} diff --git a/sluv-api/src/test/java/com/sluv/api/domain/brand/controller/NewBrandControllerTest.java b/sluv-api/src/test/java/com/sluv/api/domain/brand/controller/NewBrandControllerTest.java new file mode 100644 index 00000000..43ff8a64 --- /dev/null +++ b/sluv-api/src/test/java/com/sluv/api/domain/brand/controller/NewBrandControllerTest.java @@ -0,0 +1,64 @@ +package com.sluv.api.domain.brand.controller; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.sluv.api.brand.controller.NewBrandController; +import com.sluv.api.brand.dto.request.NewBrandPostRequest; +import com.sluv.api.brand.dto.request.RecentSelectBrandRequest; +import com.sluv.api.brand.dto.response.NewBrandPostResponse; +import com.sluv.api.brand.service.NewBrandService; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.web.servlet.MockMvc; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.when; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@WebMvcTest(controllers = NewBrandController.class) +@ActiveProfiles("test") +public class NewBrandControllerTest{ + + @Autowired + private MockMvc mockMvc; + + @MockBean + private NewBrandService newBrandService; + + @Autowired + private ObjectMapper objectMapper; + + @Test + @DisplayName("뉴브랜드 등록") + @WithMockUser("1") + void postNewBrandTest() throws Exception { + // given + NewBrandPostRequest requestDto = new NewBrandPostRequest("뉴브랜드"); + NewBrandPostResponse response = NewBrandPostResponse.builder() + .newBrandId(1L) + .newBrandName("뉴브랜드") + .build(); + + when(newBrandService.postNewBrand(any(NewBrandPostRequest.class))).thenReturn(response); + + // when & then + mockMvc.perform(post("/app/newBrand") + .content(objectMapper.writeValueAsString(requestDto)) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.isSuccess").value(true)) + .andExpect(jsonPath("$.result.newBrandName").value("뉴브랜드")); + } + +} diff --git a/sluv-api/src/test/java/com/sluv/api/domain/brand/controller/RecentSelectBrandControllerTest.java b/sluv-api/src/test/java/com/sluv/api/domain/brand/controller/RecentSelectBrandControllerTest.java new file mode 100644 index 00000000..e53ebf15 --- /dev/null +++ b/sluv-api/src/test/java/com/sluv/api/domain/brand/controller/RecentSelectBrandControllerTest.java @@ -0,0 +1,120 @@ +package com.sluv.api.domain.brand.controller; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.sluv.api.brand.controller.RecentSelectBrandController; +import com.sluv.api.brand.dto.request.RecentSelectBrandRequest; +import com.sluv.api.brand.dto.response.RecentSelectBrandResponse; +import com.sluv.api.brand.service.RecentSelectBrandService; +import com.sluv.domain.brand.entity.Brand; +import com.sluv.domain.brand.entity.RecentSelectBrand; +import com.sluv.domain.user.entity.User; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.security.test.context.support.WithMockUser; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.web.servlet.MockMvc; + +import java.util.List; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.*; +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@WebMvcTest(controllers = RecentSelectBrandController.class) +@ActiveProfiles("test") +public class RecentSelectBrandControllerTest { + + @Autowired + private MockMvc mockMvc; + + @MockBean + private RecentSelectBrandService recentSelectBrandService; + + @Autowired + private ObjectMapper objectMapper; + + + @Test + @DisplayName("최근 선택한 브랜드 조회") + @WithMockUser("1") + void getRecentSelectBrandTest() throws Exception { + // given + Brand brand = Brand.of("나이키", "NIKE", "http://image.url"); + RecentSelectBrand recentSelectBrand = RecentSelectBrand.builder() + .user(Mockito.mock(User.class)) + .brand(brand) + .build(); + + RecentSelectBrandResponse responseDto = RecentSelectBrandResponse.from(recentSelectBrand); + List responseDtos = List.of(responseDto); + + when(recentSelectBrandService.findRecentSelectBrand(1L)).thenReturn(responseDtos); + + + // when & then + mockMvc.perform(get("/app/brand/recent") + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.isSuccess").value(true)) + .andExpect(jsonPath("$.result[0].brandName").value("나이키")) + .andExpect(jsonPath("$.result[0].brandImgUrl").value("http://image.url")); + } + + @Test + @DisplayName("최근 선택한 브랜드 등록") + @WithMockUser("1") + void postRecentSelectBrandTest() throws Exception { + // given + RecentSelectBrandRequest requestDto = new RecentSelectBrandRequest(1L, null); + + doNothing().when(recentSelectBrandService).postRecentSelectBrand(eq(1L), any(RecentSelectBrandRequest.class)); + + // when & then + mockMvc.perform(post("/app/brand/recent") + .content(objectMapper.writeValueAsString(requestDto)) + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.isSuccess").value(true)); + } + + @Test + @DisplayName("최근 선택한 브랜드 모두 삭제") + @WithMockUser("1") + void deleteAllRecentSelectBrandTest() throws Exception { + // given + doNothing().when(recentSelectBrandService).deleteAllRecentSelectBrand(eq(1L)); + + // when & then + mockMvc.perform(delete("/app/brand/recent") + .with(csrf()) + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.isSuccess").value(true)); + } + + @Test + @DisplayName("최근 선택한 브랜드 선택 삭제") + @WithMockUser("1") + void deleteRecentSelectBrandTest() throws Exception { + // given + doNothing().when(recentSelectBrandService).deleteRecentSelectBrand(1L, 1L, "Y"); + + // when & then + mockMvc.perform(delete("/app/brand/recent/{brandId}", 1L) + .with(csrf()) + .queryParam("flag", "Y") + .contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()) + .andExpect(jsonPath("$.isSuccess").value(true)); + } + +} diff --git a/sluv-api/src/test/java/com/sluv/api/domain/brand/repository/BrandRepositoryTest.java b/sluv-api/src/test/java/com/sluv/api/domain/brand/repository/BrandRepositoryTest.java deleted file mode 100644 index 3fbb9570..00000000 --- a/sluv-api/src/test/java/com/sluv/api/domain/brand/repository/BrandRepositoryTest.java +++ /dev/null @@ -1,98 +0,0 @@ -//package com.sluv.server.domain.brand.repository; -// -//import static org.assertj.core.api.Assertions.assertThat; -// -//import com.sluv.server.domain.auth.enums.SnsType; -//import com.sluv.server.domain.brand.entity.Brand; -//import com.sluv.server.domain.brand.entity.RecentSelectBrand; -//import com.sluv.server.domain.user.entity.User; -//import com.sluv.server.domain.user.enums.UserStatus; -//import com.sluv.server.domain.user.repository.UserRepository; -//import java.util.ArrayList; -//import java.util.List; -//import org.junit.jupiter.api.AfterEach; -//import org.junit.jupiter.api.DisplayName; -//import org.junit.jupiter.api.Test; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.boot.test.context.SpringBootTest; -//import org.springframework.data.domain.Page; -//import org.springframework.data.domain.PageRequest; -// -//@SpringBootTest -//class BrandRepositoryTest { -// @Autowired -// private UserRepository userRepository; -// @Autowired -// private BrandRepository brandRepository; -// @Autowired -// private RecentSelectBrandRepository recentSelectBrandRepository; -// -// @AfterEach -// void tearDown() { -// recentSelectBrandRepository.deleteAll(); -// brandRepository.deleteAll(); -// userRepository.deleteAll(); -// } -// -// @DisplayName("한글 혹은 영어 이름으로 브랜드를 검색할 수 있다.") -// @Test -// void findByAllBrandKrOrBrandEnStartingWith() { -// // given -// Brand brand1 = Brand.builder().brandKr("테스트1").brandEn("test1").build(); -// Brand brand2 = Brand.builder().brandKr("테스트2").brandEn("test2").build(); -// -// brandRepository.save(brand1); -// brandRepository.save(brand2); -// -// PageRequest pageable = PageRequest.of(0, 2); -// -// // when -// Page brandPage = brandRepository.findByAllBrandKrOrBrandEnStartingWith("테스트", pageable); -// -// // then -// assertThat(brandPage.getContent().size()).isEqualTo(2); -// assertThat(brandPage.getContent().get(0).getBrandKr()).isEqualTo("테스트1"); -// -// } -// -// @DisplayName("최근 많이 검색된 브랜드 상위 10개를 검색한다.") -// @Test -// void findTop10Brand() { -// // given -// List brands = new ArrayList<>(); -// List recentSelectBrands = new ArrayList<>(); -// for (int i = 1; i <= 11; i++) { -// brands.add(Brand.builder().brandKr("테스트" + i).brandEn("test" + i).build()); -// } -// brandRepository.saveAll(brands); -// -// User user = User.builder() -// .email("testMan@sluv.com") -// .snsType(SnsType.KAKAO) -// .userStatus(UserStatus.ACTIVE) -// .build(); -// -// User saveUser = userRepository.save(user); -// -// for (int j = 0; j < brands.size(); j++) { -// for (int i = 1; i <= j + 1; i++) { -// recentSelectBrands.add(RecentSelectBrand.builder() -// .brand(brands.get(j)) -// .user(saveUser) -// .build() -// ); -// } -// } -// -// recentSelectBrandRepository.saveAll(recentSelectBrands); -// -// // when -// List top10By = brandRepository.findTop10By(); -// -// // then -// assertThat(top10By.get(0).getBrandKr()).isEqualTo("테스트11"); -// assertThat(top10By.get(1).getBrandKr()).isEqualTo("테스트10"); -// assertThat(top10By.size()).isEqualTo(10); -// -// } -//} \ No newline at end of file diff --git a/sluv-api/src/test/java/com/sluv/api/domain/brand/service/BrandServiceTest.java b/sluv-api/src/test/java/com/sluv/api/domain/brand/service/BrandServiceTest.java index f6e8a76a..4fad8b80 100644 --- a/sluv-api/src/test/java/com/sluv/api/domain/brand/service/BrandServiceTest.java +++ b/sluv-api/src/test/java/com/sluv/api/domain/brand/service/BrandServiceTest.java @@ -1,134 +1,92 @@ -//package com.sluv.server.domain.brand.service; -// -//import static com.sluv.server.fixture.UserFixture.카카오_유저_생성; -//import static org.assertj.core.api.Assertions.assertThat; -// -//import com.sluv.server.domain.brand.dto.BrandSearchResDto; -//import com.sluv.server.domain.brand.dto.RecentSelectBrandResDto; -//import com.sluv.server.domain.brand.entity.Brand; -//import com.sluv.server.domain.brand.entity.RecentSelectBrand; -//import com.sluv.server.domain.brand.repository.BrandRepository; -//import com.sluv.server.domain.brand.repository.NewBrandRepository; -//import com.sluv.server.domain.brand.repository.RecentSelectBrandRepository; -//import com.sluv.server.domain.user.entity.User; -//import com.sluv.server.domain.user.repository.UserRepository; -//import com.sluv.server.global.common.response.PaginationResDto; -//import java.util.ArrayList; -//import java.util.List; -//import org.junit.jupiter.api.AfterEach; -//import org.junit.jupiter.api.DisplayName; -//import org.junit.jupiter.api.Test; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.boot.test.context.SpringBootTest; -//import org.springframework.data.domain.PageRequest; -// -//@SpringBootTest -//public class BrandServiceTest { -// -// @Autowired -// private BrandService brandService; -// -// @Autowired -// private BrandRepository brandRepository; -// -// @Autowired -// private NewBrandRepository newBrandRepository; -// -// @Autowired -// private RecentSelectBrandRepository recentSelectBrandRepository; -// -// @Autowired -// private UserRepository userRepository; -// -// @AfterEach -// void clear() { -// recentSelectBrandRepository.deleteAll(); -// brandRepository.deleteAll(); -// newBrandRepository.deleteAll(); -// userRepository.deleteAll(); -// } -// -// @DisplayName("이름으로 브랜드를 검색한다.") -// @Test -// void findAllBrandByNameTest() { -// //given -// Brand brand1 = Brand.builder().brandKr("브랜드1").brandEn("brand1").build(); -// Brand brand2 = Brand.builder().brandKr("브랜드2").brandEn("brand2").build(); -// Brand brand3 = Brand.builder().brandKr("브랜드3").brandEn("brand3").build(); -// -// brandRepository.saveAll(List.of(brand1, brand2, brand3)); -// -// //when -// PaginationResDto brand = brandService.findAllBrand("브랜드", PageRequest.of(0, 2)); -// -// //then -// assertThat(brand.getContent().get(0)).extracting("brandKr").isEqualTo("브랜드1"); -// assertThat(brand.getContent().get(1)).extracting("brandKr").isEqualTo("브랜드2"); -// assertThat(brand).extracting("hasNext").isEqualTo(true); -// } -// -// @DisplayName("상위 10의 브랜드를 조회한다.") -// @Test -// void findTopBrandTest() { -// //given -// User user = userRepository.save(카카오_유저_생성()); -// -// List brands = new ArrayList<>(); -// for (int i = 1; i <= 11; i++) { -// Brand brand = Brand.builder().brandKr("브랜드" + i).brandEn("brand" + i).build(); -// brands.add(brand); -// } -// brandRepository.saveAll(brands); -// -// List recentSelectBrands = new ArrayList<>(); -// RecentSelectBrand recentSelectBrand1 = RecentSelectBrand.toEntity(brands.get(0), null, user); -// RecentSelectBrand recentSelectBrand2 = RecentSelectBrand.toEntity(brands.get(0), null, user); -// RecentSelectBrand recentSelectBrand3 = RecentSelectBrand.toEntity(brands.get(0), null, user); -// RecentSelectBrand recentSelectBrand4 = RecentSelectBrand.toEntity(brands.get(1), null, user); -// RecentSelectBrand recentSelectBrand5 = RecentSelectBrand.toEntity(brands.get(1), null, user); -// -// recentSelectBrands.addAll(List.of(recentSelectBrand1, recentSelectBrand2, recentSelectBrand3, -// recentSelectBrand4, recentSelectBrand5)); -// -// for (int i = 2; i <= 10; i++) { -// RecentSelectBrand recentSelectBrand = RecentSelectBrand.toEntity(brands.get(i), null, user); -// recentSelectBrands.add(recentSelectBrand); -// } -// recentSelectBrandRepository.saveAll(recentSelectBrands); -// -// //when -// List topBrand = brandService.findTopBrand(); -// -// //then -// assertThat(topBrand.get(0)).extracting("brandKr").isEqualTo("브랜드1"); -// assertThat(topBrand.get(1)).extracting("brandKr").isEqualTo("브랜드2"); -// assertThat(topBrand).hasSize(10); -// } -// -// @DisplayName("최근 선택한 브랜드를 조회할 수 있다.") -// @Test -// void findRecentSelectBrandTest() { -// //given -// User user = userRepository.save(카카오_유저_생성()); -// Brand brand1 = Brand.builder().brandKr("브랜드1").brandEn("brand1").build(); -// Brand brand2 = Brand.builder().brandKr("브랜드2").brandEn("brand2").build(); -// Brand brand3 = Brand.builder().brandKr("브랜드3").brandEn("brand3").build(); -// List brands = brandRepository.saveAll(List.of(brand1, brand2, brand3)); -// -// RecentSelectBrand recentSelectBrand1 = RecentSelectBrand.toEntity(brands.get(0), null, user); -// RecentSelectBrand recentSelectBrand2 = RecentSelectBrand.toEntity(brands.get(1), null, user); -// RecentSelectBrand recentSelectBrand3 = RecentSelectBrand.toEntity(brands.get(2), null, user); -// RecentSelectBrand recentSelectBrand4 = RecentSelectBrand.toEntity(brands.get(0), null, user); -// List recentSelectBrands = List.of(recentSelectBrand1, recentSelectBrand2, -// recentSelectBrand3, recentSelectBrand4); -// -// recentSelectBrandRepository.saveAll(recentSelectBrands); -// -// //when -// List recentSelectBrand = brandService.findRecentSelectBrand(user); -// -// //then -// assertThat(recentSelectBrand.get(0)).extracting("brandName").isEqualTo("브랜드1"); -// assertThat(recentSelectBrand.get(1)).extracting("brandName").isEqualTo("브랜드3"); -// } -//} +package com.sluv.api.domain.brand.service; + +import com.sluv.api.brand.dto.response.BrandSearchResponse; +import com.sluv.api.brand.service.BrandService; +import com.sluv.api.common.response.PaginationResponse; +import com.sluv.domain.brand.entity.Brand; +import com.sluv.domain.brand.service.BrandDomainService; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; +import org.springframework.data.domain.PageRequest; +import org.springframework.test.context.ActiveProfiles; + +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Mockito.when; + +@ExtendWith(MockitoExtension.class) +@ActiveProfiles("test") +public class BrandServiceTest { + + @InjectMocks + private BrandService brandService; + + + @Mock + private BrandDomainService brandDomainService; + + + @Test + @DisplayName("한글 이름으로 브랜드 검색") + void findAllBrandWithKrNameTest() { + // given + String keyword = "나"; + PageRequest pageable = PageRequest.of(0, 1); + Brand brand = Brand.of("나이키", "NIKE", "http://image.url"); + List content = List.of(brand); + Page brandPage = new PageImpl<>(content, pageable, content.size()); + when(brandDomainService.findByAllBrandKrOrBrandEnStartingWith(keyword, pageable)).thenReturn(brandPage); + + // when + PaginationResponse response = brandService.findAllBrand(keyword, pageable); + + // then + assertThat(response.getContent().size()).isEqualTo(1); + assertThat(response.getContent().get(0).getBrandKr()).isEqualTo("나이키"); + } + + @Test + @DisplayName("영어 이름으로 브랜드 검색") + void findAllBrandWithEnNameTest() { + // given + String keyword = "N"; + PageRequest pageable = PageRequest.of(0, 1); + Brand brand = Brand.of("나이키", "NIKE", "http://image.url"); + List content = List.of(brand); + Page brandPage = new PageImpl<>(content, pageable, content.size()); + when(brandDomainService.findByAllBrandKrOrBrandEnStartingWith(keyword, pageable)).thenReturn(brandPage); + + // when + PaginationResponse response = brandService.findAllBrand(keyword, pageable); + + // then + assertThat(response.getContent().size()).isEqualTo(1); + assertThat(response.getContent().get(0).getBrandEn()).isEqualTo("NIKE"); + } + + @Test + @DisplayName("Top 10 브랜드 검색") + void findTopBrandTest() { + // given + List content = new ArrayList<>(); + for (int i=1; i<=10; i++) { + content.add(Brand.of("나이키"+i, "NIKE"+i, "http://image.url")); + } + when(brandDomainService.findTopBrand()).thenReturn(content); + + // when + List topBrands = brandService.findTopBrand(); + + // then + assertThat(topBrands.size()).isEqualTo(10); + } + +} diff --git a/sluv-api/src/test/java/com/sluv/api/domain/brand/service/NewBrandServiceTest.java b/sluv-api/src/test/java/com/sluv/api/domain/brand/service/NewBrandServiceTest.java index 1324cea8..930b9c0d 100644 --- a/sluv-api/src/test/java/com/sluv/api/domain/brand/service/NewBrandServiceTest.java +++ b/sluv-api/src/test/java/com/sluv/api/domain/brand/service/NewBrandServiceTest.java @@ -1,39 +1,81 @@ -//package com.sluv.server.domain.brand.service; -// -//import com.sluv.server.domain.brand.dto.NewBrandPostReqDto; -//import com.sluv.server.domain.brand.repository.NewBrandRepository; -//import org.assertj.core.api.Assertions; -//import org.junit.jupiter.api.AfterEach; -//import org.junit.jupiter.api.DisplayName; -//import org.junit.jupiter.api.Test; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.boot.test.context.SpringBootTest; -// -//@SpringBootTest -//public class NewBrandServiceTest { -// -// @Autowired -// private NewBrandService newBrandService; -// -// @Autowired -// private NewBrandRepository newBrandRepository; -// -// @AfterEach -// void clear() { -// newBrandRepository.deleteAll(); -// } -// -// @DisplayName("뉴브랜드를 저장한다.") -// @Test -// void postNewBrandTest() { -// //given -// NewBrandPostReqDto newBrandPostReqDto = new NewBrandPostReqDto("뉴브랜드1"); -// -// //when -// newBrandService.postNewBrand(newBrandPostReqDto); -// -// //then -// Assertions.assertThat(newBrandRepository.findAll()).hasSize(1); -// } -// -//} +package com.sluv.api.domain.brand.service; + +import com.sluv.api.brand.dto.request.NewBrandPostRequest; +import com.sluv.api.brand.dto.response.NewBrandPostResponse; +import com.sluv.api.brand.service.NewBrandService; +import com.sluv.domain.brand.entity.NewBrand; +import com.sluv.domain.brand.service.NewBrandDomainService; +import com.sluv.infra.discord.WebHookService; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.springframework.boot.test.context.SpringBootTest; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.*; + +@SpringBootTest +public class NewBrandServiceTest { + + @InjectMocks + private NewBrandService newBrandService; + + + @Mock + private NewBrandDomainService newBrandDomainService; + + @Mock + private WebHookService webHookService; + + + @DisplayName("뉴브랜드 등록 - 신규 등록") + @Test + void postNewBrandTest() { + //given + NewBrandPostRequest newBrandPostReqDto = new NewBrandPostRequest("뉴브랜드"); + NewBrand newBrand = NewBrand.builder() + .id(1L) + .brandName("뉴브랜드") + .build(); + + when(newBrandDomainService.findByBrandName("뉴브랜드")).thenReturn(null); + when(newBrandDomainService.saveNewBrand(any(NewBrand.class))).thenReturn(newBrand); + doNothing().when(webHookService).sendCreateNewBrandMessage(any(NewBrand.class)); + + + //when + NewBrandPostResponse response = newBrandService.postNewBrand(newBrandPostReqDto); + + //then + assertThat(response.getNewBrandId()).isEqualTo(1L); + assertThat(response.getNewBrandName()).isEqualTo("뉴브랜드"); + verify(webHookService).sendCreateNewBrandMessage(any(NewBrand.class)); + } + + @DisplayName("뉴브랜드 등록 - 이미 등록된 뉴브랜드") + @Test + void postNewBrandTest_Duplicate() { + //given + NewBrandPostRequest newBrandPostReqDto = new NewBrandPostRequest("뉴브랜드"); + NewBrand newBrand = NewBrand.builder() + .id(1L) + .brandName("뉴브랜드") + .build(); + + when(newBrandDomainService.findByBrandName("뉴브랜드")).thenReturn(newBrand); + + + //when + NewBrandPostResponse response = newBrandService.postNewBrand(newBrandPostReqDto); + + //then + assertThat(response.getNewBrandId()).isEqualTo(1L); + assertThat(response.getNewBrandName()).isEqualTo("뉴브랜드"); + verify(newBrandDomainService, never()).saveNewBrand(any(NewBrand.class)); + verify(webHookService, never()).sendCreateNewBrandMessage(any(NewBrand.class)); + } + +} diff --git a/sluv-api/src/test/java/com/sluv/api/domain/brand/service/RecentSelectBrandServiceTest.java b/sluv-api/src/test/java/com/sluv/api/domain/brand/service/RecentSelectBrandServiceTest.java index 124298eb..87f0d88c 100644 --- a/sluv-api/src/test/java/com/sluv/api/domain/brand/service/RecentSelectBrandServiceTest.java +++ b/sluv-api/src/test/java/com/sluv/api/domain/brand/service/RecentSelectBrandServiceTest.java @@ -1,111 +1,145 @@ -//package com.sluv.server.domain.brand.service; -// -//import static com.sluv.server.fixture.UserFixture.카카오_유저_생성; -//import static org.assertj.core.api.Assertions.assertThat; -// -//import com.sluv.server.domain.brand.dto.RecentSelectBrandReqDto; -//import com.sluv.server.domain.brand.entity.Brand; -//import com.sluv.server.domain.brand.entity.RecentSelectBrand; -//import com.sluv.server.domain.brand.repository.BrandRepository; -//import com.sluv.server.domain.brand.repository.NewBrandRepository; -//import com.sluv.server.domain.brand.repository.RecentSelectBrandRepository; -//import com.sluv.server.domain.user.entity.User; -//import com.sluv.server.domain.user.repository.UserRepository; -//import java.util.List; -//import org.junit.jupiter.api.AfterEach; -//import org.junit.jupiter.api.DisplayName; -//import org.junit.jupiter.api.Test; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.boot.test.context.SpringBootTest; -// -//@SpringBootTest -//public class RecentSelectBrandServiceTest { -// -// @Autowired -// private BrandRepository brandRepository; -// -// @Autowired -// private NewBrandRepository newBrandRepository; -// -// @Autowired -// private RecentSelectBrandService recentSelectBrandService; -// -// @Autowired -// private RecentSelectBrandRepository recentSelectBrandRepository; -// -// @Autowired -// private UserRepository userRepository; -// -// @AfterEach -// void clear() { -// recentSelectBrandRepository.deleteAll(); -// newBrandRepository.deleteAll(); -// brandRepository.deleteAll(); -// userRepository.deleteAll(); -// } -// -// @DisplayName("최근 검색한 브랜드를 저장한다.") -// @Test -// void postRecentSelectBrandTest() { -// //given -// User user = 카카오_유저_생성(); -// userRepository.save(user); -// Brand brand = Brand.builder() -// .brandKr("브랜드1") -// .brandEn("brand1") -// .brandImgUrl(null) -// .build(); -// brandRepository.save(brand); -// -// //when -// recentSelectBrandService.postRecentSelectBrand(user, new RecentSelectBrandReqDto(brand.getId(), null)); -// //then -// assertThat(recentSelectBrandRepository.findAll()).hasSize(1); -// } -// -// @DisplayName("최근 검색한 브랜드를 모두 삭제한다.") -// @Test -// void deleteAllRecentSelectBrandTest() { -// //given -// User user = 카카오_유저_생성(); -// user.changeNickname("deleteAllRecentSelectBrandTest"); -// userRepository.save(user); -// -// Brand saveBrand = brandRepository.save( -// Brand.builder().brandKr("브랜드1").brandEn("brand1").brandImgUrl(null).build() -// ); -// -// recentSelectBrandRepository.save(RecentSelectBrand.toEntity(saveBrand, null, user)); -// -// //when -// recentSelectBrandService.deleteAllRecentSelectBrand(user); -// -// //then -// assertThat(recentSelectBrandRepository.findAll()).hasSize(0); -// } -// -// @DisplayName("최근 검색한 특정 브랜드를 삭제한다.") -// @Test -// void deleteRecentSelectBrandTest() { -// //given -// User user = 카카오_유저_생성(); -// userRepository.save(user); -// -// Brand brand1 = Brand.builder().brandKr("브랜드1").brandEn("brand1").brandImgUrl(null).build(); -// Brand brand2 = Brand.builder().brandKr("브랜드2").brandEn("brand2").brandImgUrl(null).build(); -// -// List brands = brandRepository.saveAll(List.of(brand1, brand2)); -// -// RecentSelectBrand recentSelectBrand1 = RecentSelectBrand.toEntity(brands.get(0), null, user); -// RecentSelectBrand recentSelectBrand2 = RecentSelectBrand.toEntity(brands.get(0), null, user); -// RecentSelectBrand recentSelectBrand3 = RecentSelectBrand.toEntity(brands.get(1), null, user); -// -// recentSelectBrandRepository.saveAll(List.of(recentSelectBrand1, recentSelectBrand2, recentSelectBrand3)); -// -// //when -// recentSelectBrandService.deleteRecentSelectBrand(user, brands.get(0).getId(), "Y"); -// -// //then -// assertThat(recentSelectBrandRepository.findAll()).hasSize(1); -// } -//} +package com.sluv.api.domain.brand.service; + +import com.sluv.api.brand.dto.request.RecentSelectBrandRequest; +import com.sluv.api.brand.dto.response.RecentSelectBrandResponse; +import com.sluv.api.brand.service.RecentSelectBrandService; +import com.sluv.domain.brand.entity.Brand; +import com.sluv.domain.brand.entity.RecentSelectBrand; +import com.sluv.domain.brand.service.BrandDomainService; +import com.sluv.domain.brand.service.NewBrandDomainService; +import com.sluv.domain.brand.service.RecentSelectBrandDomainService; +import com.sluv.domain.user.entity.User; +import com.sluv.domain.user.service.UserDomainService; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.test.context.ActiveProfiles; + +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.*; + +@ExtendWith(MockitoExtension.class) +@ActiveProfiles("test") +public class RecentSelectBrandServiceTest { + + @InjectMocks + private RecentSelectBrandService recentSelectBrandService; + + + @Mock + private RecentSelectBrandDomainService recentSelectBrandDomainService; + + @Mock + private UserDomainService userDomainService; + + @Mock + private BrandDomainService brandDomainService; + + @Mock + private NewBrandDomainService newBrandDomainService; + + + @Test + @DisplayName("최근 검색한 브랜드를 조회") + void findRecentSelectBrandTest() { + // given + User user = User.builder() + .id(1L) + .build(); + + Brand brand = Brand.of("나이키", "NIKE", "http://image.url"); + RecentSelectBrand recentSelectBrand = RecentSelectBrand.builder() + .brand(brand) + .user(user) + .build(); + + List recentSelectBrands = List.of(recentSelectBrand); + + when(userDomainService.findById(1L)).thenReturn(user); + when(recentSelectBrandDomainService.getRecentSelectBrandTop20(user)).thenReturn(recentSelectBrands); + + // when + List response = recentSelectBrandService.findRecentSelectBrand(1L); + + // then + assertThat(response.size()).isEqualTo(1); + assertThat(response.get(0).getBrandName()).isEqualTo("나이키"); + assertThat(response.get(0).getBrandImgUrl()).isEqualTo("http://image.url"); + } + + @Test + @DisplayName("최근 검색한 브랜드 등록") + void postRecentSelectBrandTest() { + // given + User user = User.builder() + .id(1L) + .build(); + + Brand brand = Brand.of("나이키", "NIKE", "http://image.url"); + + RecentSelectBrand recentSelectBrand = RecentSelectBrand.builder() + .id(1L) + .brand(brand) + .user(user) + .build(); + + RecentSelectBrandRequest requestDto = new RecentSelectBrandRequest(1L, null); + + when(userDomainService.findById(1L)).thenReturn(user); + when(brandDomainService.findByIdOrNull(1L)).thenReturn(brand); + when(newBrandDomainService.findByIdOrNull(null)).thenReturn(null); + when(recentSelectBrandDomainService.saveRecentSelectBrand(any(RecentSelectBrand.class))).thenReturn(recentSelectBrand); + + // when + recentSelectBrandService.postRecentSelectBrand(1L, requestDto); + + // then + verify(recentSelectBrandDomainService).saveRecentSelectBrand(any(RecentSelectBrand.class)); + } + + @Test + @DisplayName("최근 선택한 브랜드 모두 삭제") + void deleteAllRecentSelectBrandTest() { + // given + doNothing().when(recentSelectBrandDomainService).deleteAllByUserId(1L); + + // when + recentSelectBrandService.deleteAllRecentSelectBrand(1L); + + // then + verify(recentSelectBrandDomainService).deleteAllByUserId(eq(1L)); + } + + @Test + @DisplayName("최근 선택한 브랜드 삭제") + void deleteRecentSelectBrandTest() { + // given + doNothing().when(recentSelectBrandDomainService).deleteByUserIdAndBrandId(1L, 1L); + + // when + recentSelectBrandService.deleteRecentSelectBrand(1L, 1L ,"Y"); + + // then + verify(recentSelectBrandDomainService).deleteByUserIdAndBrandId(1L, 1L); + } + + @Test + @DisplayName("최근 선택한 브랜드 중 뉴브랜드 삭제") + void deleteRecentSelectBrandWithNewBrandTest() { + // given + doNothing().when(recentSelectBrandDomainService).deleteByUserIdAndNewBrandId(1L, 1L); + + // when + recentSelectBrandService.deleteRecentSelectBrand(1L, 1L ,"N"); + + // then + verify(recentSelectBrandDomainService).deleteByUserIdAndNewBrandId(1L, 1L); + } + +} diff --git a/sluv-api/src/test/java/com/sluv/api/domain/item/service/ItemServiceTest.java b/sluv-api/src/test/java/com/sluv/api/domain/item/service/ItemServiceTest.java index 5cda1a8d..73f6dac7 100644 --- a/sluv-api/src/test/java/com/sluv/api/domain/item/service/ItemServiceTest.java +++ b/sluv-api/src/test/java/com/sluv/api/domain/item/service/ItemServiceTest.java @@ -131,7 +131,7 @@ void getItemDetail_cacheHit() { when(fixData.getNewCeleb()).thenReturn(null); Brand brand = mock(Brand.class); - BrandSearchResponse brandRes = BrandSearchResponse.of(brand); + BrandSearchResponse brandRes = BrandSearchResponse.from(brand); when(fixData.getBrand()).thenReturn(brandRes); when(fixData.getNewBrand()).thenReturn(null); diff --git a/sluv-domain/src/main/java/com/sluv/domain/brand/repository/impl/BrandRepositoryImpl.java b/sluv-domain/src/main/java/com/sluv/domain/brand/repository/impl/BrandRepositoryImpl.java index 04dd10ca..e4a1f389 100644 --- a/sluv-domain/src/main/java/com/sluv/domain/brand/repository/impl/BrandRepositoryImpl.java +++ b/sluv-domain/src/main/java/com/sluv/domain/brand/repository/impl/BrandRepositoryImpl.java @@ -41,7 +41,6 @@ public Page findByAllBrandKrOrBrandEnStartingWith(String brandName, Pagea @Override public List findTop10By() { - return jpaQueryFactory.select(recentSelectBrand.brand) .from(recentSelectBrand) .groupBy(recentSelectBrand.brand) diff --git a/sluv-domain/src/main/java/com/sluv/domain/brand/repository/impl/RecentSelectBrandRepositoryImpl.java b/sluv-domain/src/main/java/com/sluv/domain/brand/repository/impl/RecentSelectBrandRepositoryImpl.java index f366c453..120251b7 100644 --- a/sluv-domain/src/main/java/com/sluv/domain/brand/repository/impl/RecentSelectBrandRepositoryImpl.java +++ b/sluv-domain/src/main/java/com/sluv/domain/brand/repository/impl/RecentSelectBrandRepositoryImpl.java @@ -28,8 +28,6 @@ public List getRecentSelectBrandTop20(User user) { .limit(20) .orderBy(recentSelectBrand.createdAt.max().desc()) .fetch(); - -// return null; } @Override diff --git a/sluv-domain/src/main/java/com/sluv/domain/brand/service/BrandDomainService.java b/sluv-domain/src/main/java/com/sluv/domain/brand/service/BrandDomainService.java index fb827207..ee8376e4 100644 --- a/sluv-domain/src/main/java/com/sluv/domain/brand/service/BrandDomainService.java +++ b/sluv-domain/src/main/java/com/sluv/domain/brand/service/BrandDomainService.java @@ -14,8 +14,8 @@ @Service @RequiredArgsConstructor public class BrandDomainService { - private final BrandRepository brandRepository; + private final BrandRepository brandRepository; public Page findByAllBrandKrOrBrandEnStartingWith(String brandName, Pageable pageable) { return brandRepository.findByAllBrandKrOrBrandEnStartingWith(brandName, pageable); diff --git a/sluv-domain/src/test/java/com/sluv/domain/brand/repository/BrandRepositoryTest.java b/sluv-domain/src/test/java/com/sluv/domain/brand/repository/BrandRepositoryTest.java new file mode 100644 index 00000000..6e0f12f2 --- /dev/null +++ b/sluv-domain/src/test/java/com/sluv/domain/brand/repository/BrandRepositoryTest.java @@ -0,0 +1,144 @@ +package com.sluv.domain.brand.repository; + +import com.sluv.domain.auth.enums.SnsType; +import com.sluv.domain.brand.entity.Brand; +import com.sluv.domain.brand.entity.RecentSelectBrand; +import com.sluv.domain.config.TestConfig; +import com.sluv.domain.user.entity.User; +import com.sluv.domain.user.enums.UserAge; +import com.sluv.domain.user.enums.UserGender; +import com.sluv.domain.user.enums.UserStatus; +import com.sluv.domain.user.repository.UserRepository; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; + +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +@DataJpaTest +@ContextConfiguration(classes = TestConfig.class) +@ActiveProfiles("test") +public class BrandRepositoryTest { + + @Autowired + private BrandRepository brandRepository; + + @Autowired + private RecentSelectBrandRepository recentSelectBrandRepository; + + @Autowired + private UserRepository userRepository; + + @AfterEach + void clean() { + recentSelectBrandRepository.deleteAll(); + userRepository.deleteAll(); + brandRepository.deleteAll(); + } + + @Test + @DisplayName("한글 키워드로 브랜드 조회") + void findByAllWithKrNameTest() { + // given + String searchKeyword = "나"; + PageRequest pageRequest = PageRequest.of(0, 1); + + Brand brand = Brand.builder() + .brandKr("나이키") + .brandEn("NIKE") + .brandImgUrl("http://image.ulr") + .build(); + brandRepository.save(brand); + + // when + Page brandPage = brandRepository.findByAllBrandKrOrBrandEnStartingWith(searchKeyword, pageRequest); + + // then + assertThat(brandPage.getContent().size()).isEqualTo(1); + assertThat(brandPage.getContent().get(0).getBrandKr()).isEqualTo("나이키"); + } + + @Test + @DisplayName("영어 키워드로 브랜드 조회") + void findByAllWithEnNameTest() { + // given + String searchKeyword = "N"; + PageRequest pageRequest = PageRequest.of(0, 1); + + Brand brand = Brand.builder() + .brandKr("나이키") + .brandEn("NIKE") + .brandImgUrl("http://image.ulr") + .build(); + brandRepository.save(brand); + + // when + Page brandPage = brandRepository.findByAllBrandKrOrBrandEnStartingWith(searchKeyword, pageRequest); + + // then + assertThat(brandPage.getContent().size()).isEqualTo(1); + assertThat(brandPage.getContent().get(0).getBrandEn()).isEqualTo("NIKE"); + } + + @Test + @DisplayName("Top 10 브랜드 조회") + void findTop10ByTest() { + // given + User user1 = User.builder() + .email("user1@example.com") + .snsType(SnsType.ETC) + .nickname("u1") + .userStatus(UserStatus.ACTIVE) + .ageRange(UserAge.TWENTIES) + .gender(UserGender.FEMALE) + .build(); + userRepository.save(user1); + + List brands = new ArrayList<>(); + for (int i=1; i<=11; i++) { + Brand brand = Brand.builder() + .brandKr("나이키"+i) + .brandEn("NIKE"+i) + .brandImgUrl("http://image.ulr") + .build(); + brands.add(brand); + } + brandRepository.saveAll(brands); + + + List recentSelectBrands = new ArrayList<>(); + for (int i=1; i<=10; i++) { + RecentSelectBrand recentSelectBrand = RecentSelectBrand.builder() + .brand(brands.get(i-1)) + .user(user1) + .build(); + recentSelectBrands.add(recentSelectBrand); + } + + // 2번 브랜드를 1등으로 설정 + RecentSelectBrand recentSelectBrand = RecentSelectBrand.builder() + .brand(brands.get(1)) + .user(user1) + .build(); + recentSelectBrands.add(recentSelectBrand); + recentSelectBrandRepository.saveAll(recentSelectBrands); + + // when + List top10Brand = brandRepository.findTop10By(); + + // then + assertThat(top10Brand.size()).isEqualTo(10); + assertThat(top10Brand.get(0).getBrandKr()).isEqualTo("나이키2"); + } + +} diff --git a/sluv-domain/src/test/java/com/sluv/domain/brand/repository/RecentSelectBrandRepositoryTest.java b/sluv-domain/src/test/java/com/sluv/domain/brand/repository/RecentSelectBrandRepositoryTest.java new file mode 100644 index 00000000..b6a335c4 --- /dev/null +++ b/sluv-domain/src/test/java/com/sluv/domain/brand/repository/RecentSelectBrandRepositoryTest.java @@ -0,0 +1,101 @@ +package com.sluv.domain.brand.repository; + +import com.sluv.domain.auth.enums.SnsType; +import com.sluv.domain.brand.entity.Brand; +import com.sluv.domain.brand.entity.RecentSelectBrand; +import com.sluv.domain.config.TestConfig; +import com.sluv.domain.user.entity.User; +import com.sluv.domain.user.enums.UserAge; +import com.sluv.domain.user.enums.UserGender; +import com.sluv.domain.user.enums.UserStatus; +import com.sluv.domain.user.repository.UserRepository; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageRequest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; + +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +@DataJpaTest +@ContextConfiguration(classes = TestConfig.class) +@ActiveProfiles("test") +public class RecentSelectBrandRepositoryTest { + + @Autowired + private RecentSelectBrandRepository recentSelectBrandRepository; + + @Autowired + private UserRepository userRepository; + + @Autowired + private BrandRepository brandRepository; + + @AfterEach + void clean() { + recentSelectBrandRepository.deleteAll(); + userRepository.deleteAll(); + brandRepository.deleteAll(); + } + + @Test + @DisplayName("최근 선택한 브랜드 20개 조회") + void getRecentSelectBrandTop20() { + // given + User user = User.builder() + .email("user1@example.com") + .snsType(SnsType.ETC) + .nickname("u1") + .userStatus(UserStatus.ACTIVE) + .ageRange(UserAge.TWENTIES) + .gender(UserGender.FEMALE) + .build(); + userRepository.save(user); + + List brands = new ArrayList<>(); + for (int i=1; i<=21; i++) { + Brand brand = Brand.builder() + .brandKr("나이키"+i) + .brandEn("NIKE"+i) + .brandImgUrl("http://image.url") + .build(); + brands.add(brand); + } + brandRepository.saveAll(brands); + + + List recentSelectBrands = new ArrayList<>(); + for (int i=1; i<=20; i++) { + RecentSelectBrand recentSelectBrand = RecentSelectBrand.builder() + .brand(brands.get(i-1)) + .user(user) + .build(); + recentSelectBrands.add(recentSelectBrand); + } + + recentSelectBrandRepository.saveAll(recentSelectBrands); + + // 21번 브랜드를 가장 최근에 선택 + RecentSelectBrand mostRecentSelectBrand = RecentSelectBrand.builder() + .brand(brands.get(20)) + .user(user) + .build(); + recentSelectBrandRepository.save(mostRecentSelectBrand); + + + // when + List recentSelectBrandTop20 = recentSelectBrandRepository.getRecentSelectBrandTop20(user); + + // then + assertThat(recentSelectBrandTop20.size()).isEqualTo(20); + assertThat(recentSelectBrandTop20.get(0).getBrand().getBrandKr()).isEqualTo("나이키21"); + } + +} diff --git a/sluv-domain/src/test/java/com/sluv/domain/item/config/TestConfig.java b/sluv-domain/src/test/java/com/sluv/domain/config/TestConfig.java similarity index 93% rename from sluv-domain/src/test/java/com/sluv/domain/item/config/TestConfig.java rename to sluv-domain/src/test/java/com/sluv/domain/config/TestConfig.java index 1e4db155..ca3c8a0e 100644 --- a/sluv-domain/src/test/java/com/sluv/domain/item/config/TestConfig.java +++ b/sluv-domain/src/test/java/com/sluv/domain/config/TestConfig.java @@ -1,4 +1,4 @@ -package com.sluv.domain.item.config; +package com.sluv.domain.config; import com.sluv.domain.config.QueryDslConfig; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/sluv-domain/src/test/java/com/sluv/domain/item/repository/ItemRepositoryTest.java b/sluv-domain/src/test/java/com/sluv/domain/item/repository/ItemRepositoryTest.java index abcf5968..f8ea6c39 100644 --- a/sluv-domain/src/test/java/com/sluv/domain/item/repository/ItemRepositoryTest.java +++ b/sluv-domain/src/test/java/com/sluv/domain/item/repository/ItemRepositoryTest.java @@ -1,7 +1,7 @@ package com.sluv.domain.item.repository; import com.sluv.domain.closet.repository.ClosetRepository; -import com.sluv.domain.item.config.TestConfig; +import com.sluv.domain.config.TestConfig; import com.sluv.domain.item.dto.ItemCountDto; import com.sluv.domain.item.dto.ItemStatusDto; import com.sluv.domain.item.entity.Item;