diff --git a/Api/src/main/java/tify/server/api/answer/service/RetrieveDailyAnswerUseCase.java b/Api/src/main/java/tify/server/api/answer/service/RetrieveDailyAnswerUseCase.java index 605aec3e..b655e70a 100644 --- a/Api/src/main/java/tify/server/api/answer/service/RetrieveDailyAnswerUseCase.java +++ b/Api/src/main/java/tify/server/api/answer/service/RetrieveDailyAnswerUseCase.java @@ -19,11 +19,7 @@ import tify.server.domain.domains.question.domain.DailyQuestion; import tify.server.domain.domains.question.dto.condition.AnswerCondition; import tify.server.domain.domains.user.adaptor.NeighborAdaptor; -import tify.server.domain.domains.user.adaptor.UserAdaptor; -import tify.server.domain.domains.user.adaptor.UserBlockAdaptor; import tify.server.domain.domains.user.domain.Neighbor; -import tify.server.domain.domains.user.domain.UserBlock; -import tify.server.domain.domains.user.dto.condition.NeighborCondition; import tify.server.domain.domains.user.dto.model.RetrieveNeighborDTO; @Slf4j @@ -31,9 +27,7 @@ @RequiredArgsConstructor public class RetrieveDailyAnswerUseCase { - private final UserAdaptor userAdaptor; private final AnswerAdaptor answerAdaptor; - private final UserBlockAdaptor userBlockAdaptor; private final NeighborAdaptor neighborAdaptor; private final DailyQuestionAdaptor dailyQuestionAdaptor; private final KnockAdaptor knockAdaptor; @@ -56,17 +50,7 @@ public List execute(Long questionId) { @Transactional(readOnly = true) public List executeNeighborAnswerList(Long questionId, Long userId) { - List blockedIdList = - userBlockAdaptor.queryAllByFromUserId(userId).stream() - .map(UserBlock::getToUserId) - .toList(); - List friendIdList = - neighborAdaptor.queryAllByFromUserId(userId).stream() - .map(Neighbor::getToUserId) - .toList(); - NeighborCondition neighborCondition = - new NeighborCondition(userId, blockedIdList, friendIdList); - List neighbors = neighborAdaptor.searchNeighbors(neighborCondition); + List neighbors = neighborAdaptor.searchNeighbors(userId); return neighbors.stream() .map( dto -> { diff --git a/Api/src/main/java/tify/server/api/config/GlobalExceptionHandler.java b/Api/src/main/java/tify/server/api/config/GlobalExceptionHandler.java index 487bad02..991a54be 100644 --- a/Api/src/main/java/tify/server/api/config/GlobalExceptionHandler.java +++ b/Api/src/main/java/tify/server/api/config/GlobalExceptionHandler.java @@ -47,7 +47,6 @@ protected ResponseEntity internalServerExceptionHandle( // e.getMessage(), // e.getCause()); log.error(String.valueOf(e)); - e.printStackTrace(); GlobalException internalServerError = GlobalException.INTERNAL_SERVER_ERROR; ErrorResponse errorResponse = new ErrorResponse(internalServerError.getErrorDetail()); diff --git a/Api/src/main/java/tify/server/api/config/security/CorsConfig.java b/Api/src/main/java/tify/server/api/config/security/CorsConfig.java index 8b899cce..0ce93835 100644 --- a/Api/src/main/java/tify/server/api/config/security/CorsConfig.java +++ b/Api/src/main/java/tify/server/api/config/security/CorsConfig.java @@ -19,6 +19,7 @@ public void addCorsMappings(CorsRegistry registry) { allowedOriginPatterns.add("http://54.180.57.46"); allowedOriginPatterns.add("http://192.168.0.18:5173"); allowedOriginPatterns.add("https://tifyfreinds.com"); + allowedOriginPatterns.add("https://tify-client.vercel.app"); /* Todo: 도메인 나오면 추가예정 */ diff --git a/Api/src/main/java/tify/server/api/product/controller/ProductController.java b/Api/src/main/java/tify/server/api/product/controller/ProductController.java index a68e3771..ebd174c1 100644 --- a/Api/src/main/java/tify/server/api/product/controller/ProductController.java +++ b/Api/src/main/java/tify/server/api/product/controller/ProductController.java @@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.RestController; import tify.server.api.common.slice.SliceResponse; import tify.server.api.product.model.dto.ProductFilterCondition; +import tify.server.api.product.model.vo.ProductRetrieveVo; import tify.server.api.product.service.CrawlingUseCase; import tify.server.api.product.service.ProductSearchUseCase; import tify.server.api.product.service.RetrieveProductListUseCase; @@ -62,7 +63,7 @@ public SliceResponse productSearch( @Operation(summary = "SmallCategory(FE기준 중분류) 별 상품을 조회합니다.") @GetMapping("/products/small-category") - public List getCategoricalProduct( + public List getCategoricalProduct( @ParameterObject ProductFilterCondition productFilterCondition) { return retrieveProductListUseCase.executeToSmallCategory(productFilterCondition); } diff --git a/Api/src/main/java/tify/server/api/product/model/vo/ProductRetrieveVo.java b/Api/src/main/java/tify/server/api/product/model/vo/ProductRetrieveVo.java new file mode 100644 index 00000000..7a95e3cd --- /dev/null +++ b/Api/src/main/java/tify/server/api/product/model/vo/ProductRetrieveVo.java @@ -0,0 +1,68 @@ +package tify.server.api.product.model.vo; + + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Builder; +import lombok.Getter; +import tify.server.domain.domains.product.dto.ProductRetrieveDTO; +import tify.server.domain.domains.user.domain.DetailCategory; +import tify.server.domain.domains.user.domain.LargeCategory; +import tify.server.domain.domains.user.domain.SmallCategory; + +@Getter +@Builder +public class ProductRetrieveVo { + + @Schema(description = "상품의 pk 값입니다.") + private final Long productId; + + @Schema(description = "상품의 이름입니다.") + private final String name; + + @Schema(description = "상품의 브랜드입니다.") + private final String brand; + + @Schema(description = "상품의 속성입니다.", example = "포근한") + private final String characteristic; + + @Schema(description = "상품의 가격입니다.") + private final Long price; + + @Schema(description = "상품의 옵션입니다.", example = "브라운, 옐로우") + private final String productOption; + + @Schema(description = "상품의 이미지 url입니다.") + private final String imageUrl; + + @Schema(description = "상품의 구매 링크입니다.") + private final String siteUrl; + + @Schema(description = "상품의 대분류입니다.", implementation = LargeCategory.class) + private final LargeCategory largeCategory; + + @Schema(description = "상품의 중분류입니다.", implementation = SmallCategory.class) + private final SmallCategory smallCategory; + + @Schema(description = "상품의 소분류입니다.", implementation = DetailCategory.class) + private final DetailCategory detailCategory; + + @Schema(description = "상품 질문의 카테고리 이름입니다.", example = "BMLIP") + private final String categoryName; + + public static ProductRetrieveVo from(ProductRetrieveDTO dto) { + return ProductRetrieveVo.builder() + .productId(dto.getProduct().getId()) + .name(dto.getProduct().getName()) + .brand(dto.getProduct().getBrand()) + .characteristic(dto.getProduct().getCharacteristic()) + .price(dto.getProduct().getPrice()) + .productOption(dto.getProduct().getProductOption()) + .imageUrl(dto.getProduct().getImageUrl()) + .siteUrl(dto.getProduct().getCrawlUrl()) + .largeCategory(dto.getFavorQuestionCategory().getLargeCategory()) + .smallCategory(dto.getFavorQuestionCategory().getSmallCategory()) + .detailCategory(dto.getFavorQuestionCategory().getDetailCategory()) + .categoryName(dto.getFavorQuestionCategory().getName()) + .build(); + } +} diff --git a/Api/src/main/java/tify/server/api/product/service/RetrieveProductListUseCase.java b/Api/src/main/java/tify/server/api/product/service/RetrieveProductListUseCase.java index fc20a23c..36c81a33 100644 --- a/Api/src/main/java/tify/server/api/product/service/RetrieveProductListUseCase.java +++ b/Api/src/main/java/tify/server/api/product/service/RetrieveProductListUseCase.java @@ -7,9 +7,11 @@ import lombok.RequiredArgsConstructor; import org.springframework.transaction.annotation.Transactional; import tify.server.api.product.model.dto.ProductFilterCondition; +import tify.server.api.product.model.vo.ProductRetrieveVo; import tify.server.core.annotation.UseCase; import tify.server.domain.domains.product.adaptor.ProductAdaptor; -import tify.server.domain.domains.product.domain.Product; +import tify.server.domain.domains.product.domain.PriceFilter; +import tify.server.domain.domains.product.domain.PriceOrder; import tify.server.domain.domains.product.dto.ProductCategoryCondition; import tify.server.domain.domains.product.dto.ProductRetrieveDTO; import tify.server.domain.domains.question.adaptor.FavorQuestionAdaptor; @@ -23,7 +25,7 @@ public class RetrieveProductListUseCase { private final FavorQuestionAdaptor favorQuestionAdaptor; @Transactional(readOnly = true) - public List executeToSmallCategory( + public List executeToSmallCategory( ProductFilterCondition productFilterCondition) { List categoryIdList = new ArrayList<>(); productFilterCondition @@ -35,14 +37,17 @@ public List executeToSmallCategory( .map(FavorQuestionCategory::getId) .toList()); }); - List results = + List results = productAdaptor.findAllBySmallCategoryId( new ProductCategoryCondition( categoryIdList, productFilterCondition.getPriceOrder(), productFilterCondition.getPriceFilter(), null)); - Collections.shuffle(results); - return results.stream().map(ProductRetrieveDTO::from).toList(); + if (productFilterCondition.getPriceOrder().equals(PriceOrder.DEFAULT) + && productFilterCondition.getPriceFilter().equals(PriceFilter.DEFAULT)) { + Collections.shuffle(results); // TODO : 추천 전략을 적용하는 부분일듯 + } + return results.stream().map(ProductRetrieveVo::from).toList(); } } diff --git a/Api/src/main/java/tify/server/api/user/controller/UserController.java b/Api/src/main/java/tify/server/api/user/controller/UserController.java index e8a451b4..0b088b30 100644 --- a/Api/src/main/java/tify/server/api/user/controller/UserController.java +++ b/Api/src/main/java/tify/server/api/user/controller/UserController.java @@ -11,9 +11,19 @@ import org.springdoc.api.annotations.ParameterObject; import org.springframework.data.domain.Pageable; import org.springframework.data.web.PageableDefault; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; import tify.server.api.common.slice.SliceResponse; import tify.server.api.user.model.dto.request.PatchNeighborsOrdersRequest; +import tify.server.api.user.model.dto.request.PatchUserFavorRequest; import tify.server.api.user.model.dto.request.PatchUserProfileRequest; import tify.server.api.user.model.dto.request.PostUserOpinionRequest; import tify.server.api.user.model.dto.request.UserOnBoardingRequest; @@ -21,20 +31,42 @@ import tify.server.api.user.model.dto.response.UserReportResponse; import tify.server.api.user.model.dto.vo.MutualFriendsVo; import tify.server.api.user.model.dto.vo.MyDailyQuestionAnswerVo; +import tify.server.api.user.model.dto.vo.RetrieveUserFavorBoxVo; import tify.server.api.user.model.dto.vo.UserDailyQuestionAnswerVo; +import tify.server.api.user.model.dto.vo.UserFavorBoxVo; import tify.server.api.user.model.dto.vo.UserOpinionVo; import tify.server.api.user.model.dto.vo.UserReportInfoVo; import tify.server.api.user.model.dto.vo.UserSearchInfoVo; -import tify.server.api.user.service.*; +import tify.server.api.user.service.AcceptanceNeighborApplicationUseCase; import tify.server.api.user.service.CreateNeighborUseCase; +import tify.server.api.user.service.CreateUserOpinionUseCase; +import tify.server.api.user.service.CreateUserReportUseCase; +import tify.server.api.user.service.NeighborInfoUseCase; +import tify.server.api.user.service.RejectNeighborApplicationUseCase; +import tify.server.api.user.service.RemoveNeighborUseCase; +import tify.server.api.user.service.RetrieveBirthdayNeighborUseCase; +import tify.server.api.user.service.RetrieveMutualFriendsUseCase; +import tify.server.api.user.service.RetrieveMyDailyAnswerUseCase; +import tify.server.api.user.service.RetrieveNeighborApplicationUseCase; +import tify.server.api.user.service.RetrieveNeighborFavorBoxUseCase; +import tify.server.api.user.service.RetrieveNeighborListUseCase; +import tify.server.api.user.service.RetrieveUserListUseCase; +import tify.server.api.user.service.RetrieveUserOpinionUseCase; +import tify.server.api.user.service.RetrieveUserReportUseCase; +import tify.server.api.user.service.UpdateNeighborUseCase; +import tify.server.api.user.service.UpdateUserFavorUseCase; +import tify.server.api.user.service.UpdateUserProfileUseCase; +import tify.server.api.user.service.UserBlockUseCase; +import tify.server.api.user.service.UserFavorFilterUseCase; +import tify.server.api.user.service.UserFavorUseCase; +import tify.server.api.user.service.UserInfoUseCase; +import tify.server.api.user.service.UserOnBoardingUseCase; import tify.server.domain.domains.question.domain.DailyQuestionCategory; -import tify.server.domain.domains.user.domain.LargeCategory; import tify.server.domain.domains.user.domain.SmallCategory; import tify.server.domain.domains.user.dto.condition.UserCondition; import tify.server.domain.domains.user.dto.model.GetNeighborApplicationDTO; import tify.server.domain.domains.user.dto.model.RetrieveNeighborDTO; import tify.server.domain.domains.user.vo.UserAnswerVo; -import tify.server.domain.domains.user.vo.UserFavorVo; import tify.server.domain.domains.user.vo.UserInfoVo; import tify.server.domain.domains.user.vo.UserProfileVo; @@ -49,6 +81,7 @@ public class UserController { private final UserFavorUseCase userFavorUseCase; private final UpdateUserProfileUseCase updateUserProfileUseCase; private final UserFavorFilterUseCase userFavorFilterUseCase; + private final UpdateUserFavorUseCase updateUserFavorUseCase; private final UserOnBoardingUseCase userOnBoardingUseCase; private final NeighborInfoUseCase neighborInfoUseCase; private final RetrieveNeighborListUseCase retrieveNeighborListUseCase; @@ -67,6 +100,7 @@ public class UserController { private final RetrieveMyDailyAnswerUseCase retrieveMyDailyAnswerUseCase; private final CreateUserOpinionUseCase createUserOpinionUseCase; private final RetrieveUserOpinionUseCase retrieveUserOpinionUseCase; + private final RetrieveNeighborFavorBoxUseCase retrieveNeighborFavorBoxUseCase; @Operation(summary = "유저 정보 조회") @GetMapping("/{userId}") @@ -87,7 +121,7 @@ public void updateNeighborViewedAt(@PathVariable Long neighborId) { } @Operation(summary = "유저 취향 답변 중분류 별 조회") - @GetMapping("/{userId}/tags") + @GetMapping("/{userId}/favors") public List getUserTags( @PathVariable Long userId, @RequestParam @Parameter(description = "필터로 쓰일 중분류입니다.") @@ -108,11 +142,18 @@ public UserInfoVo getUserProfileInfoByToken() { return userInfoUseCase.executeByToken(); } - @Operation(summary = "대분류 별 유저 취향 조회 필터") - @GetMapping("/{userId}/category") - public List getUserTagsByLargeCategory( - @PathVariable Long userId, @RequestParam LargeCategory largeCategory) { - return userFavorFilterUseCase.execute(userId, largeCategory); + @Operation(summary = "유저 취향 상자 조회") + @GetMapping("/{userId}/tags") + public List getUserFavorsByUserId(@PathVariable Long userId) { + return userFavorFilterUseCase.execute(userId); + } + + @Operation(summary = "유저 취향 상자 수정") + @PatchMapping("/{userId}/tags") + public void patchUserFavorsByUserId( + @PathVariable Long userId, + @RequestBody @Valid PatchUserFavorRequest patchUserFavorRequest) { + updateUserFavorUseCase.execute(userId, patchUserFavorRequest); } @Operation(summary = "온보딩") @@ -283,4 +324,10 @@ public UserOpinionVo getMyOpinion( public List getMyAllOpinion() { return retrieveUserOpinionUseCase.executeAll(); } + + @Operation(summary = "친구들의 취향 상자 정보와 프로필 리스트를 조회합니다.") + @GetMapping("/neighbors/favors") + public List getNeighborsFavorBox() { + return retrieveNeighborFavorBoxUseCase.execute(); + } } diff --git a/Api/src/main/java/tify/server/api/user/model/dto/UserFavorDto.java b/Api/src/main/java/tify/server/api/user/model/dto/UserFavorDto.java new file mode 100644 index 00000000..c3ee1200 --- /dev/null +++ b/Api/src/main/java/tify/server/api/user/model/dto/UserFavorDto.java @@ -0,0 +1,15 @@ +package tify.server.api.user.model.dto; + + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Getter; +import lombok.NoArgsConstructor; +import tify.server.domain.domains.user.domain.DetailCategory; + +@Getter +@NoArgsConstructor +public class UserFavorDto { + + @Schema(description = "취향의 종류입니다.", example = "LIP") + private DetailCategory detailCategory; +} diff --git a/Api/src/main/java/tify/server/api/user/model/dto/request/PatchUserFavorRequest.java b/Api/src/main/java/tify/server/api/user/model/dto/request/PatchUserFavorRequest.java new file mode 100644 index 00000000..119985b0 --- /dev/null +++ b/Api/src/main/java/tify/server/api/user/model/dto/request/PatchUserFavorRequest.java @@ -0,0 +1,15 @@ +package tify.server.api.user.model.dto.request; + + +import java.util.List; +import javax.validation.constraints.NotNull; +import lombok.Getter; +import lombok.NoArgsConstructor; +import tify.server.api.user.model.dto.UserFavorDto; + +@Getter +@NoArgsConstructor +public class PatchUserFavorRequest { + + @NotNull private List userFavorDtoList; +} diff --git a/Api/src/main/java/tify/server/api/user/model/dto/request/UserOnBoardingRequest.java b/Api/src/main/java/tify/server/api/user/model/dto/request/UserOnBoardingRequest.java index 6ccde5c9..8591f46a 100644 --- a/Api/src/main/java/tify/server/api/user/model/dto/request/UserOnBoardingRequest.java +++ b/Api/src/main/java/tify/server/api/user/model/dto/request/UserOnBoardingRequest.java @@ -2,10 +2,13 @@ import io.swagger.v3.oas.annotations.media.Schema; +import java.util.List; import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; import lombok.Getter; import lombok.NoArgsConstructor; +import tify.server.api.user.model.dto.UserFavorDto; @Getter @NoArgsConstructor @@ -28,4 +31,8 @@ public class UserOnBoardingRequest { @NotBlank(message = "상태값을 입력해주세요.") private String onBoardingState; + + @Schema(description = "유저 취향 상자에 들어갈 소분류들입니다.") + @NotNull + private List userFavorDtoList; } diff --git a/Api/src/main/java/tify/server/api/user/model/dto/vo/RetrieveUserFavorBoxVo.java b/Api/src/main/java/tify/server/api/user/model/dto/vo/RetrieveUserFavorBoxVo.java new file mode 100644 index 00000000..4bfb806e --- /dev/null +++ b/Api/src/main/java/tify/server/api/user/model/dto/vo/RetrieveUserFavorBoxVo.java @@ -0,0 +1,56 @@ +package tify.server.api.user.model.dto.vo; + + +import io.swagger.v3.oas.annotations.media.Schema; +import java.sql.Timestamp; +import java.util.List; +import lombok.Builder; +import lombok.Getter; +import tify.server.domain.domains.user.domain.DetailCategory; +import tify.server.domain.domains.user.domain.UserFavor; +import tify.server.domain.domains.user.dto.model.RetrieveNeighborFavorBoxDTO; + +@Getter +@Builder +public class RetrieveUserFavorBoxVo { + + @Schema(description = "친구의 pk값입니다.", example = "1") + private final Long id; + + @Schema(description = "친구의 프로필 이미지입니다.") + private final String thumbnail; + + @Schema(description = "친구의 id입니다.", example = "@aaa") + private final String userId; + + @Schema(description = "친구의 이름입니다.", example = "홍길동") + private final String userName; + + @Schema(description = "친구의 취향 상자 정보입니다.", example = "PLACE, TOP, FAS_PRODUCT") + private final List userFavorList; + + @Schema(description = "친구의 온보딩 상태 정보입니다.") + private final String userOnBoardingStatus; + + @Schema(description = "친구가 정보를 업데이트한 시점입니다.") + private final Timestamp updateAt; + + @Schema(description = "친구의 정보 업데이트를 조회한 시점입니다.") + private final Timestamp viewedAt; + + public static RetrieveUserFavorBoxVo from(RetrieveNeighborFavorBoxDTO dto) { + return RetrieveUserFavorBoxVo.builder() + .id(dto.getUser().getId()) + .thumbnail(dto.getUser().getProfile().getThumbNail()) + .userId(dto.getUser().getUserId()) + .userName(dto.getUser().getProfile().getUserName()) + .userFavorList( + dto.getUser().getUserFavors().stream() + .map(UserFavor::getDetailCategory) + .toList()) + .userOnBoardingStatus(dto.getUser().getOnBoardingStatus().getName()) + .updateAt(dto.getUser().getUpdatedAt()) + .viewedAt(dto.getViewedAt()) + .build(); + } +} diff --git a/Api/src/main/java/tify/server/api/user/model/dto/vo/UserFavorBoxVo.java b/Api/src/main/java/tify/server/api/user/model/dto/vo/UserFavorBoxVo.java new file mode 100644 index 00000000..6610c1a0 --- /dev/null +++ b/Api/src/main/java/tify/server/api/user/model/dto/vo/UserFavorBoxVo.java @@ -0,0 +1,36 @@ +package tify.server.api.user.model.dto.vo; + + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Builder; +import lombok.Getter; +import tify.server.domain.domains.user.domain.DetailCategory; +import tify.server.domain.domains.user.domain.LargeCategory; +import tify.server.domain.domains.user.domain.SmallCategory; +import tify.server.domain.domains.user.vo.UserFavorVo; + +@Getter +@Builder +public class UserFavorBoxVo { + + @Schema(description = "유저 취향 박스 내 취향의 pk값입니다.", example = "1") + private final Long userFavorId; + + @Schema(description = "유저 취향 박스 내 취향의 대분류입니다.", example = "BEAUTY") + private final LargeCategory largeCategory; + + @Schema(description = "유저 취향 박스 내 취향의 중분류입니다.", example = "MAKEUP") + private final SmallCategory smallCategory; + + @Schema(description = "유저 취향 박스 내 취향의 소분류입니다.", example = "LIP") + private final DetailCategory detailCategory; + + public static UserFavorBoxVo from(UserFavorVo userFavorVo) { + return UserFavorBoxVo.builder() + .userFavorId(userFavorVo.getUserFavor().getId()) + .largeCategory(userFavorVo.getLargeCategory()) + .smallCategory(userFavorVo.getUserFavor().getDetailCategory().getSmallCategory()) + .detailCategory(userFavorVo.getUserFavor().getDetailCategory()) + .build(); + } +} diff --git a/Api/src/main/java/tify/server/api/user/service/AcceptanceNeighborApplicationUseCase.java b/Api/src/main/java/tify/server/api/user/service/AcceptanceNeighborApplicationUseCase.java index fc1c6a0b..8922f5d5 100644 --- a/Api/src/main/java/tify/server/api/user/service/AcceptanceNeighborApplicationUseCase.java +++ b/Api/src/main/java/tify/server/api/user/service/AcceptanceNeighborApplicationUseCase.java @@ -39,7 +39,8 @@ public void execute(Long neighborApplicationId) { throw AlreadyExistNeighborRelationshipException.EXCEPTION; } - List neighbors = neighborAdaptor.queryAllByFromUserId(currentUserId); + List fromNeighbors = neighborAdaptor.queryAllByFromUserId(currentUserId); + List toNeighbors = neighborAdaptor.queryAllByFromUserId(toUserId); neighborAdaptor.save( Neighbor.builder() @@ -47,7 +48,16 @@ public void execute(Long neighborApplicationId) { .toUserId(toUserId) .isView(true) .isNew(true) - .order((long) neighbors.size() + 1L) + .order((long) fromNeighbors.size() + 1L) + .build()); + + neighborAdaptor.save( + Neighbor.builder() + .fromUserId(toUserId) + .toUserId(currentUserId) + .isView(true) + .isNew(true) + .order((long) toNeighbors.size() + 1L) .build()); } } diff --git a/Api/src/main/java/tify/server/api/user/service/CreateNeighborUseCase.java b/Api/src/main/java/tify/server/api/user/service/CreateNeighborUseCase.java index 5ff0bedc..0f1c3bcf 100644 --- a/Api/src/main/java/tify/server/api/user/service/CreateNeighborUseCase.java +++ b/Api/src/main/java/tify/server/api/user/service/CreateNeighborUseCase.java @@ -1,14 +1,12 @@ package tify.server.api.user.service; -import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.transaction.annotation.Transactional; import tify.server.api.config.security.SecurityUtils; import tify.server.core.annotation.UseCase; import tify.server.domain.domains.user.adaptor.NeighborAdaptor; import tify.server.domain.domains.user.adaptor.UserAdaptor; -import tify.server.domain.domains.user.domain.Neighbor; import tify.server.domain.domains.user.domain.NeighborApplication; import tify.server.domain.domains.user.domain.User; import tify.server.domain.domains.user.exception.AlreadyExistNeighborRelationshipException; @@ -33,16 +31,6 @@ public void execute(Long toUserId) { if (neighborAdaptor.existsNeighbor(currentUserId, toUser.getId())) { throw AlreadyExistNeighborRelationshipException.EXCEPTION; } - List neighbors = neighborAdaptor.queryAllByFromUserId(currentUserId); - - neighborAdaptor.save( - Neighbor.builder() - .fromUserId(currentUserId) - .toUserId(toUser.getId()) - .isView(true) - .isNew(true) - .order((long) neighbors.size() + 1L) - .build()); // 반대편에서 이미 친구가 되어있다면 신청을 보내지 않음 if (!neighborAdaptor diff --git a/Api/src/main/java/tify/server/api/user/service/RemoveNeighborUseCase.java b/Api/src/main/java/tify/server/api/user/service/RemoveNeighborUseCase.java index 0f62098d..12e4de1b 100644 --- a/Api/src/main/java/tify/server/api/user/service/RemoveNeighborUseCase.java +++ b/Api/src/main/java/tify/server/api/user/service/RemoveNeighborUseCase.java @@ -6,8 +6,6 @@ import tify.server.api.config.security.SecurityUtils; import tify.server.core.annotation.UseCase; import tify.server.domain.domains.user.adaptor.NeighborAdaptor; -import tify.server.domain.domains.user.domain.Neighbor; -import tify.server.domain.domains.user.exception.NeighborNotFoundException; import tify.server.domain.domains.user.validator.UserValidator; @UseCase @@ -21,17 +19,11 @@ public class RemoveNeighborUseCase { public void execute(Long toUserId) { Long userId = SecurityUtils.getCurrentUserId(); userValidator.isNeighbor(userId, toUserId); - - Neighbor fromNeighbor = - neighborAdaptor - .queryByFromUserIdAndToUserId(userId, toUserId) - .orElseThrow(() -> NeighborNotFoundException.EXCEPTION); - Neighbor toNeighbor = - neighborAdaptor - .queryByFromUserIdAndToUserId(toUserId, userId) - .orElseThrow(() -> NeighborNotFoundException.EXCEPTION); - - neighborAdaptor.delete(fromNeighbor); - neighborAdaptor.delete(toNeighbor); + neighborAdaptor + .queryByFromUserIdAndToUserId(userId, toUserId) + .ifPresent(neighborAdaptor::delete); + neighborAdaptor + .queryByFromUserIdAndToUserId(toUserId, userId) + .ifPresent(neighborAdaptor::delete); } } diff --git a/Api/src/main/java/tify/server/api/user/service/RetrieveBirthdayNeighborUseCase.java b/Api/src/main/java/tify/server/api/user/service/RetrieveBirthdayNeighborUseCase.java index 3f5133cb..3385acf2 100644 --- a/Api/src/main/java/tify/server/api/user/service/RetrieveBirthdayNeighborUseCase.java +++ b/Api/src/main/java/tify/server/api/user/service/RetrieveBirthdayNeighborUseCase.java @@ -8,9 +8,6 @@ import tify.server.core.annotation.UseCase; import tify.server.domain.domains.user.adaptor.NeighborAdaptor; import tify.server.domain.domains.user.adaptor.UserBlockAdaptor; -import tify.server.domain.domains.user.domain.Neighbor; -import tify.server.domain.domains.user.domain.UserBlock; -import tify.server.domain.domains.user.dto.condition.NeighborCondition; import tify.server.domain.domains.user.dto.model.RetrieveNeighborDTO; @UseCase @@ -24,16 +21,6 @@ public class RetrieveBirthdayNeighborUseCase { @Transactional(readOnly = true) public List execute() { Long currentUserId = userUtils.getUserId(); - List blockedUserList = - userBlockAdaptor.queryAllByFromUserId(currentUserId).stream() - .map(UserBlock::getToUserId) - .toList(); - List friendIdList = - neighborAdaptor.queryAllByToUserId(currentUserId).stream() - .map(Neighbor::getFromUserId) - .toList(); - NeighborCondition neighborCondition = - new NeighborCondition(currentUserId, blockedUserList, friendIdList); - return neighborAdaptor.searchBirthdayNeighbors(neighborCondition); + return neighborAdaptor.searchBirthdayNeighbors(currentUserId); } } diff --git a/Api/src/main/java/tify/server/api/user/service/RetrieveNeighborFavorBoxUseCase.java b/Api/src/main/java/tify/server/api/user/service/RetrieveNeighborFavorBoxUseCase.java new file mode 100644 index 00000000..77996daa --- /dev/null +++ b/Api/src/main/java/tify/server/api/user/service/RetrieveNeighborFavorBoxUseCase.java @@ -0,0 +1,30 @@ +package tify.server.api.user.service; + + +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.springframework.transaction.annotation.Transactional; +import tify.server.api.config.security.SecurityUtils; +import tify.server.api.user.model.dto.vo.RetrieveUserFavorBoxVo; +import tify.server.core.annotation.UseCase; +import tify.server.domain.domains.user.adaptor.NeighborAdaptor; +import tify.server.domain.domains.user.adaptor.UserAdaptor; +import tify.server.domain.domains.user.adaptor.UserBlockAdaptor; + +@UseCase +@RequiredArgsConstructor +public class RetrieveNeighborFavorBoxUseCase { + + private final UserAdaptor userAdaptor; + private final UserBlockAdaptor userBlockAdaptor; + private final NeighborAdaptor neighborAdaptor; + + @Transactional(readOnly = true) + public List execute() { + Long currentUserId = SecurityUtils.getCurrentUserId(); + + return userAdaptor.queryUserFavorBox(currentUserId).stream() + .map(RetrieveUserFavorBoxVo::from) + .toList(); + } +} diff --git a/Api/src/main/java/tify/server/api/user/service/RetrieveNeighborListUseCase.java b/Api/src/main/java/tify/server/api/user/service/RetrieveNeighborListUseCase.java index 21c52e87..6d77f6c6 100644 --- a/Api/src/main/java/tify/server/api/user/service/RetrieveNeighborListUseCase.java +++ b/Api/src/main/java/tify/server/api/user/service/RetrieveNeighborListUseCase.java @@ -10,9 +10,6 @@ import tify.server.domain.domains.user.adaptor.NeighborAdaptor; import tify.server.domain.domains.user.adaptor.UserAdaptor; import tify.server.domain.domains.user.adaptor.UserBlockAdaptor; -import tify.server.domain.domains.user.domain.Neighbor; -import tify.server.domain.domains.user.domain.UserBlock; -import tify.server.domain.domains.user.dto.condition.NeighborCondition; import tify.server.domain.domains.user.dto.model.RetrieveNeighborDTO; @Slf4j @@ -28,33 +25,13 @@ public class RetrieveNeighborListUseCase { @Transactional(readOnly = true) public List execute() { Long currentUserId = userUtils.getUserId(); - List blockedUserList = - userBlockAdaptor.queryAllByFromUserId(currentUserId).stream() - .map(UserBlock::getToUserId) - .toList(); - List friendIdList = - neighborAdaptor.queryAllByToUserId(currentUserId).stream() - .map(Neighbor::getFromUserId) - .toList(); - NeighborCondition neighborCondition = - new NeighborCondition(currentUserId, blockedUserList, friendIdList); - return neighborAdaptor.searchNeighbors(neighborCondition); + return neighborAdaptor.searchNeighbors(currentUserId); } @Transactional(readOnly = true) public List executeToIsNew() { Long currentUserId = userUtils.getUserId(); - List blockedUserList = - userBlockAdaptor.queryAllByFromUserId(currentUserId).stream() - .map(UserBlock::getToUserId) - .toList(); - List friendIdList = - neighborAdaptor.queryAllByToUserId(currentUserId).stream() - .map(Neighbor::getFromUserId) - .toList(); - NeighborCondition neighborCondition = - new NeighborCondition(currentUserId, blockedUserList, friendIdList); - return neighborAdaptor.searchNeighbors(neighborCondition).stream() + return neighborAdaptor.searchNeighbors(currentUserId).stream() .filter(RetrieveNeighborDTO::isNew) .toList(); } diff --git a/Api/src/main/java/tify/server/api/user/service/UpdateUserFavorUseCase.java b/Api/src/main/java/tify/server/api/user/service/UpdateUserFavorUseCase.java new file mode 100644 index 00000000..4c253f96 --- /dev/null +++ b/Api/src/main/java/tify/server/api/user/service/UpdateUserFavorUseCase.java @@ -0,0 +1,41 @@ +package tify.server.api.user.service; + + +import java.util.List; +import lombok.RequiredArgsConstructor; +import org.springframework.transaction.annotation.Transactional; +import tify.server.api.user.model.dto.request.PatchUserFavorRequest; +import tify.server.core.annotation.UseCase; +import tify.server.core.exception.BaseException; +import tify.server.domain.domains.user.adaptor.UserAdaptor; +import tify.server.domain.domains.user.adaptor.UserFavorAdaptor; +import tify.server.domain.domains.user.domain.User; +import tify.server.domain.domains.user.domain.UserFavor; +import tify.server.domain.domains.user.exception.UserException; + +@UseCase +@RequiredArgsConstructor +public class UpdateUserFavorUseCase { + + private final UserAdaptor userAdaptor; + private final UserFavorAdaptor userFavorAdaptor; + + @Transactional + public void execute(Long userId, PatchUserFavorRequest body) { + if (body.getUserFavorDtoList().size() != 3) { + throw new BaseException(UserException.USER_FAVOR_UPDATE_ERROR); + } + User user = userAdaptor.query(userId); + + List updateFavors = + body.getUserFavorDtoList().stream() + .map( + dto -> + UserFavor.builder() + .user(user) + .detailCategory(dto.getDetailCategory()) + .build()) + .toList(); + user.updateUserFavors(updateFavors); + } +} diff --git a/Api/src/main/java/tify/server/api/user/service/UserBlockUseCase.java b/Api/src/main/java/tify/server/api/user/service/UserBlockUseCase.java index 3f2a1ae1..ce2f95a6 100644 --- a/Api/src/main/java/tify/server/api/user/service/UserBlockUseCase.java +++ b/Api/src/main/java/tify/server/api/user/service/UserBlockUseCase.java @@ -33,7 +33,7 @@ public void execute(Long toUserId) { .optionalQueryByFromUserIdAndToUserId(toUserId, userId) .ifPresent(neighborAdaptor::deleteNeighborApplication); - // 타겟이 되는 유저와 원래 친구였다면 둘의 친구를 끊음 + // 타겟이 되는 유저와 원래 친구였다면 둘의 친구를 끊음 & 두 사람의 친구 목록 업데이트 neighborAdaptor .queryByFromUserIdAndToUserId(userId, toUserId) .ifPresent(neighborAdaptor::delete); diff --git a/Api/src/main/java/tify/server/api/user/service/UserFavorFilterUseCase.java b/Api/src/main/java/tify/server/api/user/service/UserFavorFilterUseCase.java index 69622949..b7eaa72d 100644 --- a/Api/src/main/java/tify/server/api/user/service/UserFavorFilterUseCase.java +++ b/Api/src/main/java/tify/server/api/user/service/UserFavorFilterUseCase.java @@ -4,13 +4,11 @@ import java.util.List; import lombok.RequiredArgsConstructor; import org.springframework.transaction.annotation.Transactional; -import tify.server.api.utils.UserUtils; +import tify.server.api.user.model.dto.vo.UserFavorBoxVo; import tify.server.core.annotation.UseCase; import tify.server.domain.domains.user.adaptor.UserAdaptor; import tify.server.domain.domains.user.adaptor.UserFavorAdaptor; -import tify.server.domain.domains.user.domain.LargeCategory; import tify.server.domain.domains.user.domain.User; -import tify.server.domain.domains.user.domain.UserTag; import tify.server.domain.domains.user.vo.UserFavorVo; @UseCase @@ -18,16 +16,15 @@ @Transactional(readOnly = true) public class UserFavorFilterUseCase { - private final UserUtils userUtils; private final UserAdaptor userAdaptor; private final UserFavorAdaptor userFavorAdaptor; - public List execute(Long userId, LargeCategory largeCategory) { - // 유저를 끌고온다 + @Transactional(readOnly = true) + public List execute(Long userId) { User user = userAdaptor.query(userId); - // 유저의 Tag를 가져온다 - List userTagList = user.getUserTags(); - // largeCategory에 대한 UserFavorVo를 리턴한다 - return userFavorAdaptor.queryByLargeCategory(largeCategory); + return userFavorAdaptor.queryAllByUser(user).stream() + .map(UserFavorVo::from) + .map(UserFavorBoxVo::from) + .toList(); } } diff --git a/Api/src/main/java/tify/server/api/user/service/UserFavorUseCase.java b/Api/src/main/java/tify/server/api/user/service/UserFavorUseCase.java index bde49866..6df4b68d 100644 --- a/Api/src/main/java/tify/server/api/user/service/UserFavorUseCase.java +++ b/Api/src/main/java/tify/server/api/user/service/UserFavorUseCase.java @@ -9,6 +9,7 @@ import tify.server.domain.domains.question.adaptor.FavorAnswerAdaptor; import tify.server.domain.domains.question.domain.FavorAnswer; import tify.server.domain.domains.user.domain.SmallCategory; +import tify.server.domain.domains.user.vo.FavorAnswerContentVo; import tify.server.domain.domains.user.vo.UserAnswerVo; @UseCase @@ -19,18 +20,25 @@ public class UserFavorUseCase { private final FavorAnswerAdaptor favorAnswerAdaptor; public List execute(Long userId, List smallCategoryList) { - List userAnswerVoList = new ArrayList<>(); return smallCategoryList.stream() .map( smallCategory -> { List favorAnswers = favorAnswerAdaptor.searchByUserIdAndSmallCategory( userId, smallCategory); - List favorAnswerContentList = new ArrayList<>(); + List favorAnswerContentList = new ArrayList<>(); favorAnswers.forEach( favorAnswer -> favorAnswerContentList.add( - favorAnswer.getAnswerContent())); + FavorAnswerContentVo.of( + favorAnswer + .getFavorQuestion() + .getFavorQuestionCategory() + .getDetailCategory(), + favorAnswer + .getFavorQuestion() + .getNumber(), + favorAnswer.getAnswerContent()))); return UserAnswerVo.of(smallCategory, favorAnswerContentList); }) .toList(); diff --git a/Api/src/main/java/tify/server/api/user/service/UserOnBoardingUseCase.java b/Api/src/main/java/tify/server/api/user/service/UserOnBoardingUseCase.java index 3c2e9a88..11dd5215 100644 --- a/Api/src/main/java/tify/server/api/user/service/UserOnBoardingUseCase.java +++ b/Api/src/main/java/tify/server/api/user/service/UserOnBoardingUseCase.java @@ -9,8 +9,10 @@ import tify.server.core.annotation.UseCase; import tify.server.core.exception.BaseException; import tify.server.domain.domains.user.adaptor.UserAdaptor; +import tify.server.domain.domains.user.adaptor.UserFavorAdaptor; import tify.server.domain.domains.user.domain.Gender; import tify.server.domain.domains.user.domain.User; +import tify.server.domain.domains.user.domain.UserFavor; import tify.server.domain.domains.user.exception.UserException; import tify.server.domain.domains.user.vo.UserOnBoardingStatusInfoVo; @@ -20,6 +22,7 @@ public class UserOnBoardingUseCase { private final UserAdaptor userAdaptor; + private final UserFavorAdaptor userFavorAdaptor; @Transactional public void execute(UserOnBoardingRequest body, Long userId) { @@ -28,12 +31,31 @@ public void execute(UserOnBoardingRequest body, Long userId) { throw new BaseException(UserException.ALREADY_EXIST_USER_ERROR); } User user = userAdaptor.query(userId); + + if (body.getUserFavorDtoList().size() != 3) { + throw new BaseException(UserException.USER_FAVOR_UPDATE_ERROR); + } + + body.getUserFavorDtoList() + .forEach( + userFavorDto -> { + UserFavor userFavor = + UserFavor.builder() + .user(user) + .detailCategory(userFavorDto.getDetailCategory()) + .build(); + userFavorAdaptor.save(userFavor); + }); + + List userFavorList = userFavorAdaptor.queryAllByUser(user); + user.onBoarding( body.getUsername(), body.getId(), body.getBirth(), Gender.toGender(body.getGender()), - userAdaptor.queryOnBoardingStatusByName(body.getOnBoardingState())); + userAdaptor.queryOnBoardingStatusByName(body.getOnBoardingState()), + userFavorList); } public boolean checkUserId(String userId) { diff --git a/Api/src/main/java/tify/server/api/utils/UserUtils.java b/Api/src/main/java/tify/server/api/utils/UserUtils.java index ae7db5d1..44e773b2 100644 --- a/Api/src/main/java/tify/server/api/utils/UserUtils.java +++ b/Api/src/main/java/tify/server/api/utils/UserUtils.java @@ -5,7 +5,7 @@ import org.springframework.stereotype.Component; import tify.server.api.config.security.SecurityUtils; import tify.server.domain.domains.user.adaptor.UserAdaptor; -import tify.server.domain.domains.user.adaptor.UserTagAdaptor; +import tify.server.domain.domains.user.adaptor.UserBlockAdaptor; import tify.server.domain.domains.user.domain.User; @Component @@ -13,7 +13,7 @@ public class UserUtils { private final UserAdaptor userAdaptor; - private final UserTagAdaptor userTagAdaptor; + private final UserBlockAdaptor userBlockAdaptor; public Long getUserId() { return SecurityUtils.getCurrentUserId(); diff --git a/Domain/src/main/java/tify/server/domain/domains/product/adaptor/ProductAdaptor.java b/Domain/src/main/java/tify/server/domain/domains/product/adaptor/ProductAdaptor.java index 655bee56..0c851dab 100644 --- a/Domain/src/main/java/tify/server/domain/domains/product/adaptor/ProductAdaptor.java +++ b/Domain/src/main/java/tify/server/domain/domains/product/adaptor/ProductAdaptor.java @@ -48,7 +48,7 @@ public Slice searchBySmallCategoryId( return productRepository.searchBySmallCategory(productCategoryCondition); } - public List findAllBySmallCategoryId( + public List findAllBySmallCategoryId( ProductCategoryCondition productCategoryCondition) { return productRepository.findAllBySmallCategory(productCategoryCondition); } diff --git a/Domain/src/main/java/tify/server/domain/domains/product/dto/ProductRetrieveDTO.java b/Domain/src/main/java/tify/server/domain/domains/product/dto/ProductRetrieveDTO.java index 4edc33ea..0255fb97 100644 --- a/Domain/src/main/java/tify/server/domain/domains/product/dto/ProductRetrieveDTO.java +++ b/Domain/src/main/java/tify/server/domain/domains/product/dto/ProductRetrieveDTO.java @@ -5,31 +5,14 @@ import lombok.Builder; import lombok.Getter; import tify.server.domain.domains.product.domain.Product; +import tify.server.domain.domains.question.domain.FavorQuestionCategory; @Getter @AllArgsConstructor @Builder public class ProductRetrieveDTO { - private Long productId; - private String name; - private String brand; - private String characteristic; - private Long price; - private String productOption; - private String imageUrl; - private String siteUrl; + private Product product; - public static ProductRetrieveDTO from(Product product) { - return ProductRetrieveDTO.builder() - .productId(product.getId()) - .name(product.getName()) - .brand(product.getBrand()) - .characteristic(product.getCharacteristic()) - .price(product.getPrice()) - .productOption(product.getProductOption()) - .imageUrl(product.getImageUrl()) - .siteUrl(product.getCrawlUrl()) - .build(); - } + private FavorQuestionCategory favorQuestionCategory; } diff --git a/Domain/src/main/java/tify/server/domain/domains/product/repository/ProductCustomRepository.java b/Domain/src/main/java/tify/server/domain/domains/product/repository/ProductCustomRepository.java index 55b5b38b..0ba484d0 100644 --- a/Domain/src/main/java/tify/server/domain/domains/product/repository/ProductCustomRepository.java +++ b/Domain/src/main/java/tify/server/domain/domains/product/repository/ProductCustomRepository.java @@ -22,5 +22,6 @@ public interface ProductCustomRepository { Slice searchBySmallCategory( ProductCategoryCondition productCategoryCondition); - List findAllBySmallCategory(ProductCategoryCondition productCategoryCondition); + List findAllBySmallCategory( + ProductCategoryCondition productCategoryCondition); } diff --git a/Domain/src/main/java/tify/server/domain/domains/product/repository/ProductCustomRepositoryImpl.java b/Domain/src/main/java/tify/server/domain/domains/product/repository/ProductCustomRepositoryImpl.java index 82bd1f58..2589e94e 100644 --- a/Domain/src/main/java/tify/server/domain/domains/product/repository/ProductCustomRepositoryImpl.java +++ b/Domain/src/main/java/tify/server/domain/domains/product/repository/ProductCustomRepositoryImpl.java @@ -75,7 +75,8 @@ public Slice searchByKeyword(ProductCondition productConditi product.characteristic, product.price, product.productOption, - product.imageUrl)) + product.imageUrl, + product.crawlUrl)) .from(product) .where(product.name.contains(productCondition.getKeyword())) .orderBy(product.id.asc()) @@ -100,7 +101,8 @@ public Slice searchBySmallCategory( product.characteristic, product.price, product.productOption, - product.imageUrl)) + product.imageUrl, + product.crawlUrl)) .from(product) .where( product.favorQuestionCategoryId.in( @@ -114,13 +116,20 @@ public Slice searchBySmallCategory( } @Override - public List findAllBySmallCategory(ProductCategoryCondition productCategoryCondition) { + public List findAllBySmallCategory( + ProductCategoryCondition productCategoryCondition) { return queryFactory - .selectFrom(product) + .select( + Projections.constructor( + ProductRetrieveDTO.class, product, favorQuestionCategory)) + .from(product) + .join(favorQuestionCategory) + .on(product.favorQuestionCategoryId.eq(favorQuestionCategory.id)) .where( product.favorQuestionCategoryId.in( productCategoryCondition.getCategoryIdList()), priceBetween(productCategoryCondition.getPriceFilter())) + .orderBy(orderByPrice(productCategoryCondition.getPriceOrder())) .fetch(); } diff --git a/Domain/src/main/java/tify/server/domain/domains/user/adaptor/NeighborAdaptor.java b/Domain/src/main/java/tify/server/domain/domains/user/adaptor/NeighborAdaptor.java index 886e28be..4748965e 100644 --- a/Domain/src/main/java/tify/server/domain/domains/user/adaptor/NeighborAdaptor.java +++ b/Domain/src/main/java/tify/server/domain/domains/user/adaptor/NeighborAdaptor.java @@ -10,7 +10,6 @@ import tify.server.domain.domains.user.domain.Neighbor; import tify.server.domain.domains.user.domain.NeighborApplication; import tify.server.domain.domains.user.domain.User; -import tify.server.domain.domains.user.dto.condition.NeighborCondition; import tify.server.domain.domains.user.dto.model.GetNeighborApplicationDTO; import tify.server.domain.domains.user.dto.model.RetrieveNeighborDTO; import tify.server.domain.domains.user.exception.NeighborApplicationNotFoundException; @@ -53,13 +52,12 @@ public Optional queryByFromUserIdAndToUserId(Long userId, Long neighbo return neighborRepository.findByFromUserIdAndToUserId(userId, neighborId); } - public List searchNeighbors(NeighborCondition neighborCondition) { - return neighborRepository.searchNeighbors(neighborCondition); + public List searchNeighbors(Long userId) { + return neighborRepository.searchNeighbors(userId); } - public Slice searchNeighbors( - NeighborCondition neighborCondition, Pageable pageable) { - return neighborRepository.searchNeighborsToPage(neighborCondition, pageable); + public Slice searchNeighbors(Long userId, Pageable pageable) { + return neighborRepository.searchNeighborsToPage(userId, pageable); } public boolean existsNeighbor(Long userId, Long neighborId) { @@ -74,8 +72,8 @@ public void delete(Neighbor neighbor) { neighborRepository.delete(neighbor); } - public List searchBirthdayNeighbors(NeighborCondition neighborCondition) { - return neighborRepository.searchBirthdayNeighbors(neighborCondition); + public List searchBirthdayNeighbors(Long userId) { + return neighborRepository.searchBirthdayNeighbors(userId); } public void saveNeighborApplication(NeighborApplication neighborApplication) { @@ -121,4 +119,8 @@ public Optional optionalQueryByFromUserIdAndToUserId( public void deleteNeighborApplication(NeighborApplication neighborApplication) { neighborApplicationRepository.delete(neighborApplication); } + + public List queryAllByFromUserIdOrderByOrder(Long fromUserId) { + return neighborRepository.findAllByFromUserIdOrderByOrder(fromUserId); + } } diff --git a/Domain/src/main/java/tify/server/domain/domains/user/adaptor/UserAdaptor.java b/Domain/src/main/java/tify/server/domain/domains/user/adaptor/UserAdaptor.java index 04fde841..b6854b6c 100644 --- a/Domain/src/main/java/tify/server/domain/domains/user/adaptor/UserAdaptor.java +++ b/Domain/src/main/java/tify/server/domain/domains/user/adaptor/UserAdaptor.java @@ -13,6 +13,7 @@ import tify.server.domain.domains.user.domain.User; import tify.server.domain.domains.user.domain.UserOnBoardingStatus; import tify.server.domain.domains.user.dto.condition.UserCondition; +import tify.server.domain.domains.user.dto.model.RetrieveNeighborFavorBoxDTO; import tify.server.domain.domains.user.exception.UserNotFoundException; import tify.server.domain.domains.user.repository.UserOnBoardingStatusRepository; import tify.server.domain.domains.user.repository.UserRepository; @@ -55,4 +56,8 @@ public List searchByKeyword(String keyword) { public Slice searchUsers(Pageable pageable, UserCondition condition, Long currentUserId) { return userRepository.searchUsers(pageable, condition, currentUserId); } + + public List queryUserFavorBox(Long userId) { + return userRepository.findNeighbors(userId); + } } diff --git a/Domain/src/main/java/tify/server/domain/domains/user/adaptor/UserFavorAdaptor.java b/Domain/src/main/java/tify/server/domain/domains/user/adaptor/UserFavorAdaptor.java index dfe1df02..608a1824 100644 --- a/Domain/src/main/java/tify/server/domain/domains/user/adaptor/UserFavorAdaptor.java +++ b/Domain/src/main/java/tify/server/domain/domains/user/adaptor/UserFavorAdaptor.java @@ -4,11 +4,10 @@ import java.util.List; import lombok.RequiredArgsConstructor; import tify.server.core.annotation.Adaptor; -import tify.server.domain.domains.user.domain.LargeCategory; +import tify.server.domain.domains.user.domain.User; import tify.server.domain.domains.user.domain.UserFavor; import tify.server.domain.domains.user.exception.UserFavorNotFoundException; import tify.server.domain.domains.user.repository.UserFavorRepository; -import tify.server.domain.domains.user.vo.UserFavorVo; @Adaptor @RequiredArgsConstructor @@ -22,7 +21,11 @@ public UserFavor query(Long userFavorId) { .orElseThrow(() -> UserFavorNotFoundException.EXCEPTION); } - public List queryByLargeCategory(LargeCategory largeCategory) { - return userFavorRepository.findByLargeCategory(largeCategory); + public void save(UserFavor userFavor) { + userFavorRepository.save(userFavor); + } + + public List queryAllByUser(User user) { + return userFavorRepository.findAllByUser(user); } } diff --git a/Domain/src/main/java/tify/server/domain/domains/user/adaptor/UserTagAdaptor.java b/Domain/src/main/java/tify/server/domain/domains/user/adaptor/UserTagAdaptor.java deleted file mode 100644 index 94b38961..00000000 --- a/Domain/src/main/java/tify/server/domain/domains/user/adaptor/UserTagAdaptor.java +++ /dev/null @@ -1,21 +0,0 @@ -package tify.server.domain.domains.user.adaptor; - - -import lombok.RequiredArgsConstructor; -import tify.server.core.annotation.Adaptor; -import tify.server.domain.domains.user.domain.UserTag; -import tify.server.domain.domains.user.exception.UserTagNotFoundException; -import tify.server.domain.domains.user.repository.UserTagRepository; - -@Adaptor -@RequiredArgsConstructor -public class UserTagAdaptor { - - private final UserTagRepository userTagRepository; - - public UserTag query(Long userTagId) { - return userTagRepository - .findById(userTagId) - .orElseThrow(() -> UserTagNotFoundException.EXCEPTION); - } -} diff --git a/Domain/src/main/java/tify/server/domain/domains/user/domain/User.java b/Domain/src/main/java/tify/server/domain/domains/user/domain/User.java index c13542f9..74ce0aa2 100644 --- a/Domain/src/main/java/tify/server/domain/domains/user/domain/User.java +++ b/Domain/src/main/java/tify/server/domain/domains/user/domain/User.java @@ -44,7 +44,7 @@ public class User extends AbstractTimeStamp { fetch = FetchType.LAZY, cascade = CascadeType.ALL, orphanRemoval = true) - private List userTags = new ArrayList<>(); + private List userFavors = new ArrayList<>(); @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "onBoardingStatusId") @@ -87,17 +87,23 @@ public void onBoarding( String userId, String birth, Gender gender, - UserOnBoardingStatus onBoardingStatus) { + UserOnBoardingStatus onBoardingStatus, + List userFavorList) { // this.profile.onBoardingProfile(username, birth, gender); this.profile = Profile.builder().userName(username).birth(birth).gender(gender).build(); this.userId = userId; this.onBoardingStatus = onBoardingStatus; + this.userFavors = userFavorList; } public void updateFavor() { setUpdatedAt(); } + public void updateUserFavors(List userFavors) { + this.userFavors = userFavors; + } + public void updateAppleRefreshToken(String appleRefreshToken) { this.appleRefreshToken = appleRefreshToken; } diff --git a/Domain/src/main/java/tify/server/domain/domains/user/domain/UserFavor.java b/Domain/src/main/java/tify/server/domain/domains/user/domain/UserFavor.java index 86d84b6b..2bf7653a 100644 --- a/Domain/src/main/java/tify/server/domain/domains/user/domain/UserFavor.java +++ b/Domain/src/main/java/tify/server/domain/domains/user/domain/UserFavor.java @@ -2,7 +2,6 @@ import javax.persistence.*; -import javax.validation.constraints.NotNull; import lombok.AccessLevel; import lombok.Builder; import lombok.Getter; @@ -19,22 +18,20 @@ public class UserFavor extends AbstractTimeStamp { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @NotNull private Long userTagId; + @ManyToOne + @JoinColumn(name = "tbl_user_id") + private User user; @Enumerated(EnumType.STRING) - private SmallCategory smallCategory; - - // public UserTagVo toUserFavorVo() { - // return UserTagVo.from(new UserTag(0L, this.largeCategoryId)); - // } + private DetailCategory detailCategory; @Builder - public UserFavor( - Long userTagId, - Long largeCategoryId, - SmallCategory smallCategory, - String thumbNailImageUrl) { - this.userTagId = userTagId; - this.smallCategory = smallCategory; + public UserFavor(User user, DetailCategory detailCategory) { + this.user = user; + this.detailCategory = detailCategory; + } + + public void updateFavor(DetailCategory detailCategory) { + this.detailCategory = detailCategory; } } diff --git a/Domain/src/main/java/tify/server/domain/domains/user/domain/UserTag.java b/Domain/src/main/java/tify/server/domain/domains/user/domain/UserTag.java deleted file mode 100644 index e677121e..00000000 --- a/Domain/src/main/java/tify/server/domain/domains/user/domain/UserTag.java +++ /dev/null @@ -1,46 +0,0 @@ -package tify.server.domain.domains.user.domain; - - -import java.util.ArrayList; -import java.util.List; -import javax.persistence.*; -import lombok.AccessLevel; -import lombok.Builder; -import lombok.Getter; -import lombok.NoArgsConstructor; -import tify.server.domain.domains.AbstractTimeStamp; - -@Getter -@Entity -@Table(name = "tbl_user_tag") -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class UserTag extends AbstractTimeStamp { - - @Id - @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - - @ManyToOne - @JoinColumn(name = "tbl_user_id") - private User user; - - @Enumerated(EnumType.STRING) - private LargeCategory largeCategory; - - @OneToMany( - mappedBy = "userTagId", - fetch = FetchType.LAZY, - cascade = CascadeType.ALL, - orphanRemoval = true) - private List favors = new ArrayList<>(); - - @Builder - public UserTag(User user, LargeCategory largeCategory) { - this.user = user; - this.largeCategory = largeCategory; - } - - public void updateUserFavors(List favors) { - this.favors.addAll(favors); - } -} diff --git a/Domain/src/main/java/tify/server/domain/domains/user/dto/model/RetrieveNeighborDTO.java b/Domain/src/main/java/tify/server/domain/domains/user/dto/model/RetrieveNeighborDTO.java index 60a2e50f..5ff38772 100644 --- a/Domain/src/main/java/tify/server/domain/domains/user/dto/model/RetrieveNeighborDTO.java +++ b/Domain/src/main/java/tify/server/domain/domains/user/dto/model/RetrieveNeighborDTO.java @@ -11,6 +11,8 @@ public class RetrieveNeighborDTO { private Long neighborId; + private Long neighborUserId; + private Long userId; private String neighborThumbnail; diff --git a/Domain/src/main/java/tify/server/domain/domains/user/dto/model/RetrieveNeighborFavorBoxDTO.java b/Domain/src/main/java/tify/server/domain/domains/user/dto/model/RetrieveNeighborFavorBoxDTO.java new file mode 100644 index 00000000..8f77dfa5 --- /dev/null +++ b/Domain/src/main/java/tify/server/domain/domains/user/dto/model/RetrieveNeighborFavorBoxDTO.java @@ -0,0 +1,16 @@ +package tify.server.domain.domains.user.dto.model; + + +import java.sql.Timestamp; +import lombok.AllArgsConstructor; +import lombok.Getter; +import tify.server.domain.domains.user.domain.User; + +@Getter +@AllArgsConstructor +public class RetrieveNeighborFavorBoxDTO { + + private final User user; + + private final Timestamp viewedAt; +} diff --git a/Domain/src/main/java/tify/server/domain/domains/user/repository/NeighborCustomRepository.java b/Domain/src/main/java/tify/server/domain/domains/user/repository/NeighborCustomRepository.java index 9d5ebf39..05aa3f6f 100644 --- a/Domain/src/main/java/tify/server/domain/domains/user/repository/NeighborCustomRepository.java +++ b/Domain/src/main/java/tify/server/domain/domains/user/repository/NeighborCustomRepository.java @@ -4,15 +4,13 @@ import java.util.List; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; -import tify.server.domain.domains.user.dto.condition.NeighborCondition; import tify.server.domain.domains.user.dto.model.RetrieveNeighborDTO; public interface NeighborCustomRepository { - List searchNeighbors(NeighborCondition neighborCondition); + List searchNeighbors(Long userId); - List searchBirthdayNeighbors(NeighborCondition neighborCondition); + List searchBirthdayNeighbors(Long userId); - Slice searchNeighborsToPage( - NeighborCondition neighborCondition, Pageable pageable); + Slice searchNeighborsToPage(Long userId, Pageable pageable); } diff --git a/Domain/src/main/java/tify/server/domain/domains/user/repository/NeighborCustomRepositoryImpl.java b/Domain/src/main/java/tify/server/domain/domains/user/repository/NeighborCustomRepositoryImpl.java index a51fc3a6..1edd1e63 100644 --- a/Domain/src/main/java/tify/server/domain/domains/user/repository/NeighborCustomRepositoryImpl.java +++ b/Domain/src/main/java/tify/server/domain/domains/user/repository/NeighborCustomRepositoryImpl.java @@ -2,6 +2,8 @@ import static tify.server.domain.domains.user.domain.QNeighbor.neighbor; import static tify.server.domain.domains.user.domain.QUser.user; +import static tify.server.domain.domains.user.domain.QUserFavor.*; +import static tify.server.domain.domains.user.domain.QUserOnBoardingStatus.*; import com.querydsl.core.types.Projections; import com.querydsl.jpa.impl.JPAQueryFactory; @@ -12,7 +14,6 @@ import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; import tify.server.domain.common.util.SliceUtil; -import tify.server.domain.domains.user.dto.condition.NeighborCondition; import tify.server.domain.domains.user.dto.model.RetrieveNeighborDTO; @RequiredArgsConstructor @@ -20,11 +21,12 @@ public class NeighborCustomRepositoryImpl implements NeighborCustomRepository { private final JPAQueryFactory queryFactory; @Override - public List searchNeighbors(NeighborCondition neighborCondition) { + public List searchNeighbors(Long userId) { return queryFactory .select( Projections.constructor( RetrieveNeighborDTO.class, + neighbor.id, neighbor.toUserId, neighbor.fromUserId, user.profile.thumbNail, @@ -39,16 +41,13 @@ public List searchNeighbors(NeighborCondition neighborCondi .from(neighbor) .join(user) .on(user.id.eq(neighbor.toUserId)) - .where( - neighbor.fromUserId.eq(neighborCondition.getCurrentUserId()), - neighbor.toUserId.notIn(neighborCondition.getBlockedUserIdList()), - neighbor.toUserId.in(neighborCondition.getFriendIdList())) + .where(neighbor.fromUserId.eq(userId)) .orderBy(neighbor.order.asc()) .fetch(); } @Override - public List searchBirthdayNeighbors(NeighborCondition neighborCondition) { + public List searchBirthdayNeighbors(Long userId) { LocalDateTime today = LocalDateTime.now(ZoneId.of("Asia/Seoul")); String monthAndYear = String.format("%02d%02d", today.getMonth().getValue(), today.getDayOfMonth()); @@ -56,6 +55,7 @@ public List searchBirthdayNeighbors(NeighborCondition neigh .select( Projections.constructor( RetrieveNeighborDTO.class, + neighbor.id, neighbor.toUserId, neighbor.fromUserId, user.profile.thumbNail, @@ -70,23 +70,19 @@ public List searchBirthdayNeighbors(NeighborCondition neigh .from(neighbor) .join(user) .on(user.id.eq(neighbor.toUserId)) - .where( - neighbor.fromUserId.eq(neighborCondition.getCurrentUserId()), - neighbor.toUserId.notIn(neighborCondition.getBlockedUserIdList()), - user.profile.birth.contains(monthAndYear), - neighbor.toUserId.in(neighborCondition.getFriendIdList())) + .where(neighbor.fromUserId.eq(userId), user.profile.birth.contains(monthAndYear)) .orderBy(neighbor.order.asc()) .fetch(); } @Override - public Slice searchNeighborsToPage( - NeighborCondition neighborCondition, Pageable pageable) { + public Slice searchNeighborsToPage(Long userId, Pageable pageable) { List retrieveNeighborDTOS = queryFactory .select( Projections.constructor( RetrieveNeighborDTO.class, + neighbor.id, neighbor.toUserId, neighbor.fromUserId, user.profile.thumbNail, @@ -101,10 +97,7 @@ public Slice searchNeighborsToPage( .from(neighbor) .join(user) .on(user.id.eq(neighbor.toUserId)) - .where( - neighbor.fromUserId.eq(neighborCondition.getCurrentUserId()), - neighbor.toUserId.notIn(neighborCondition.getBlockedUserIdList()), - neighbor.toUserId.in(neighborCondition.getFriendIdList())) + .where(neighbor.fromUserId.eq(userId)) .orderBy(neighbor.order.asc()) .offset(pageable.getOffset()) .limit(pageable.getPageSize()) diff --git a/Domain/src/main/java/tify/server/domain/domains/user/repository/NeighborRepository.java b/Domain/src/main/java/tify/server/domain/domains/user/repository/NeighborRepository.java index 974b17e5..503da1ca 100644 --- a/Domain/src/main/java/tify/server/domain/domains/user/repository/NeighborRepository.java +++ b/Domain/src/main/java/tify/server/domain/domains/user/repository/NeighborRepository.java @@ -19,4 +19,6 @@ public interface NeighborRepository boolean existsByFromUserIdAndToUserId(Long userId, Long neighborId); List findAllByFromUserIdAndIsView(Long fromUserId, boolean isView); + + List findAllByFromUserIdOrderByOrder(Long fromUserId); } diff --git a/Domain/src/main/java/tify/server/domain/domains/user/repository/UserCustomRepository.java b/Domain/src/main/java/tify/server/domain/domains/user/repository/UserCustomRepository.java index 146c7e27..9504212f 100644 --- a/Domain/src/main/java/tify/server/domain/domains/user/repository/UserCustomRepository.java +++ b/Domain/src/main/java/tify/server/domain/domains/user/repository/UserCustomRepository.java @@ -1,12 +1,16 @@ package tify.server.domain.domains.user.repository; +import java.util.List; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Slice; import tify.server.domain.domains.user.domain.User; import tify.server.domain.domains.user.dto.condition.UserCondition; +import tify.server.domain.domains.user.dto.model.RetrieveNeighborFavorBoxDTO; public interface UserCustomRepository { Slice searchUsers(Pageable pageable, UserCondition userCondition, Long currentUserId); + + List findNeighbors(Long userId); } diff --git a/Domain/src/main/java/tify/server/domain/domains/user/repository/UserCustomRepositoryImpl.java b/Domain/src/main/java/tify/server/domain/domains/user/repository/UserCustomRepositoryImpl.java index dcc592b3..e6f43988 100644 --- a/Domain/src/main/java/tify/server/domain/domains/user/repository/UserCustomRepositoryImpl.java +++ b/Domain/src/main/java/tify/server/domain/domains/user/repository/UserCustomRepositoryImpl.java @@ -1,8 +1,11 @@ package tify.server.domain.domains.user.repository; +import static tify.server.domain.domains.user.domain.QNeighbor.*; import static tify.server.domain.domains.user.domain.QUser.user; import static tify.server.domain.domains.user.domain.QUserBlock.userBlock; +import static tify.server.domain.domains.user.domain.QUserOnBoardingStatus.*; +import com.querydsl.core.types.Projections; import com.querydsl.core.types.dsl.BooleanExpression; import com.querydsl.jpa.impl.JPAQueryFactory; import java.util.List; @@ -12,6 +15,7 @@ import tify.server.domain.common.util.SliceUtil; import tify.server.domain.domains.user.domain.User; import tify.server.domain.domains.user.dto.condition.UserCondition; +import tify.server.domain.domains.user.dto.model.RetrieveNeighborFavorBoxDTO; @RequiredArgsConstructor public class UserCustomRepositoryImpl implements UserCustomRepository { @@ -37,6 +41,20 @@ public Slice searchUsers( return SliceUtil.valueOf(contents, pageable); } + @Override + public List findNeighbors(Long userId) { + return jpaQueryFactory + .select( + Projections.constructor( + RetrieveNeighborFavorBoxDTO.class, user, neighbor.viewedAt)) + .from(user) + .join(neighbor) + .on(user.id.eq(neighbor.toUserId)) + .where(neighbor.fromUserId.eq(userId)) + .orderBy(neighbor.order.asc()) + .fetch(); + } + private BooleanExpression userIdEquals(String userId) { return (userId != null) ? user.userId.eq(userId) : null; } diff --git a/Domain/src/main/java/tify/server/domain/domains/user/repository/UserFavorCustomRepository.java b/Domain/src/main/java/tify/server/domain/domains/user/repository/UserFavorCustomRepository.java index 4cb4f30c..df877e68 100644 --- a/Domain/src/main/java/tify/server/domain/domains/user/repository/UserFavorCustomRepository.java +++ b/Domain/src/main/java/tify/server/domain/domains/user/repository/UserFavorCustomRepository.java @@ -1,10 +1,3 @@ package tify.server.domain.domains.user.repository; - -import java.util.List; -import tify.server.domain.domains.user.domain.LargeCategory; -import tify.server.domain.domains.user.vo.UserFavorVo; - -public interface UserFavorCustomRepository { - List findByLargeCategory(LargeCategory largeCategory); -} +public interface UserFavorCustomRepository {} diff --git a/Domain/src/main/java/tify/server/domain/domains/user/repository/UserFavorCustomRepositoryImpl.java b/Domain/src/main/java/tify/server/domain/domains/user/repository/UserFavorCustomRepositoryImpl.java deleted file mode 100644 index 570bab57..00000000 --- a/Domain/src/main/java/tify/server/domain/domains/user/repository/UserFavorCustomRepositoryImpl.java +++ /dev/null @@ -1,31 +0,0 @@ -package tify.server.domain.domains.user.repository; - -import static tify.server.domain.domains.user.domain.QUserFavor.userFavor; -import static tify.server.domain.domains.user.domain.QUserTag.userTag; - -import com.querydsl.jpa.impl.JPAQueryFactory; -import java.util.List; -import lombok.RequiredArgsConstructor; -import tify.server.domain.domains.user.domain.LargeCategory; -import tify.server.domain.domains.user.domain.UserFavor; -import tify.server.domain.domains.user.vo.UserFavorVo; - -@RequiredArgsConstructor -public class UserFavorCustomRepositoryImpl implements UserFavorCustomRepository { - private final JPAQueryFactory queryFactory; - - @Override - public List findByLargeCategory(LargeCategory largeCategory) { - List favors = - queryFactory - .select(userFavor) - .from(userFavor) - .join(userTag) - .on(userFavor.userTagId.eq(userTag.id)) - .where(userTag.largeCategory.eq(largeCategory)) - .orderBy(userFavor.createdAt.asc()) - .fetch(); - - return favors.stream().map(UserFavorVo::from).toList(); - } -} diff --git a/Domain/src/main/java/tify/server/domain/domains/user/repository/UserFavorRepository.java b/Domain/src/main/java/tify/server/domain/domains/user/repository/UserFavorRepository.java index c7055a77..0267e6fc 100644 --- a/Domain/src/main/java/tify/server/domain/domains/user/repository/UserFavorRepository.java +++ b/Domain/src/main/java/tify/server/domain/domains/user/repository/UserFavorRepository.java @@ -1,8 +1,13 @@ package tify.server.domain.domains.user.repository; +import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; +import tify.server.domain.domains.user.domain.User; import tify.server.domain.domains.user.domain.UserFavor; public interface UserFavorRepository - extends JpaRepository, UserFavorCustomRepository {} + extends JpaRepository, UserFavorCustomRepository { + + List findAllByUser(User user); +} diff --git a/Domain/src/main/java/tify/server/domain/domains/user/repository/UserTagRepository.java b/Domain/src/main/java/tify/server/domain/domains/user/repository/UserTagRepository.java deleted file mode 100644 index 85d314b5..00000000 --- a/Domain/src/main/java/tify/server/domain/domains/user/repository/UserTagRepository.java +++ /dev/null @@ -1,7 +0,0 @@ -package tify.server.domain.domains.user.repository; - - -import org.springframework.data.jpa.repository.JpaRepository; -import tify.server.domain.domains.user.domain.UserTag; - -public interface UserTagRepository extends JpaRepository {} diff --git a/Domain/src/main/java/tify/server/domain/domains/user/vo/FavorAnswerContentVo.java b/Domain/src/main/java/tify/server/domain/domains/user/vo/FavorAnswerContentVo.java new file mode 100644 index 00000000..d4b84bba --- /dev/null +++ b/Domain/src/main/java/tify/server/domain/domains/user/vo/FavorAnswerContentVo.java @@ -0,0 +1,26 @@ +package tify.server.domain.domains.user.vo; + + +import lombok.Builder; +import lombok.Getter; +import tify.server.domain.domains.user.domain.DetailCategory; + +@Getter +@Builder +public class FavorAnswerContentVo { + + private DetailCategory detailCategory; + + private Long number; + + private String answerContent; + + public static FavorAnswerContentVo of( + DetailCategory detailCategory, Long number, String answerContent) { + return FavorAnswerContentVo.builder() + .detailCategory(detailCategory) + .number(number) + .answerContent(answerContent) + .build(); + } +} diff --git a/Domain/src/main/java/tify/server/domain/domains/user/vo/UserAnswerVo.java b/Domain/src/main/java/tify/server/domain/domains/user/vo/UserAnswerVo.java index 956cf47c..4e952ce5 100644 --- a/Domain/src/main/java/tify/server/domain/domains/user/vo/UserAnswerVo.java +++ b/Domain/src/main/java/tify/server/domain/domains/user/vo/UserAnswerVo.java @@ -12,9 +12,10 @@ public class UserAnswerVo { private final SmallCategory smallCategory; - private final List answerContentList; + private final List answerContentList; - public static UserAnswerVo of(SmallCategory smallCategory, List answerContentList) { + public static UserAnswerVo of( + SmallCategory smallCategory, List answerContentList) { return UserAnswerVo.builder() .smallCategory(smallCategory) .answerContentList(answerContentList) diff --git a/Domain/src/main/java/tify/server/domain/domains/user/vo/UserFavorVo.java b/Domain/src/main/java/tify/server/domain/domains/user/vo/UserFavorVo.java index 88f64222..ed3bdd2a 100644 --- a/Domain/src/main/java/tify/server/domain/domains/user/vo/UserFavorVo.java +++ b/Domain/src/main/java/tify/server/domain/domains/user/vo/UserFavorVo.java @@ -3,20 +3,21 @@ import lombok.Builder; import lombok.Getter; +import tify.server.domain.domains.user.domain.LargeCategory; import tify.server.domain.domains.user.domain.UserFavor; @Getter @Builder public class UserFavorVo { - private final Long userFavorId; + private final UserFavor userFavor; - private final String smallCategory; + private final LargeCategory largeCategory; public static UserFavorVo from(UserFavor userFavor) { return UserFavorVo.builder() - .userFavorId(userFavor.getId()) - .smallCategory(userFavor.getSmallCategory().getValue()) + .userFavor(userFavor) + .largeCategory(userFavor.getDetailCategory().getSmallCategory().getLargeCategory()) .build(); } } diff --git a/Domain/src/main/java/tify/server/domain/domains/user/vo/UserProfileVo.java b/Domain/src/main/java/tify/server/domain/domains/user/vo/UserProfileVo.java index 55f34d1e..3ca28fd4 100644 --- a/Domain/src/main/java/tify/server/domain/domains/user/vo/UserProfileVo.java +++ b/Domain/src/main/java/tify/server/domain/domains/user/vo/UserProfileVo.java @@ -1,13 +1,16 @@ package tify.server.domain.domains.user.vo; +import java.util.List; import java.util.Optional; import lombok.Builder; import lombok.Data; +import tify.server.domain.domains.user.domain.DetailCategory; import tify.server.domain.domains.user.domain.Gender; import tify.server.domain.domains.user.domain.NeighborApplication; import tify.server.domain.domains.user.domain.Profile; import tify.server.domain.domains.user.domain.User; +import tify.server.domain.domains.user.domain.UserFavor; import tify.server.domain.domains.user.domain.UserOnBoardingStatus; @Data @@ -33,10 +36,13 @@ public class UserProfileVo { private boolean isFriend; private boolean isBlocked; + private NeighborApplication receivedApplication; private NeighborApplication sentApplication; + private List userFavorList; + public static UserProfileVo from(User user) { return UserProfileVo.builder() .userName( @@ -60,6 +66,8 @@ public static UserProfileVo from(User user) { Optional.ofNullable(user.getOnBoardingStatus()) .map(UserOnBoardingStatus::getName) .orElse(null)) + .userFavorList( + user.getUserFavors().stream().map(UserFavor::getDetailCategory).toList()) .build(); }