Skip to content

Commit

Permalink
[FEATURE] 유저 취향 답변 조회 response dto 변경 (#133)
Browse files Browse the repository at this point in the history
* feat : 유저 취향 답변 조회 response dto 변경 #132

* feat : 유저 취향 상자, 유저 프로필 정보 조회 API 응답 VO 변경 #132

* spotless apply

* merge dev

* spotless apply
  • Loading branch information
bongsh0112 authored Dec 16, 2023
1 parent 4e391b3 commit 8636ae2
Show file tree
Hide file tree
Showing 50 changed files with 569 additions and 315 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,15 @@
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
@UseCase
@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;
Expand All @@ -56,17 +50,7 @@ public List<RetrieveAnswerVo> execute(Long questionId) {

@Transactional(readOnly = true)
public List<NeighborAnswerInfoDTO> executeNeighborAnswerList(Long questionId, Long userId) {
List<Long> blockedIdList =
userBlockAdaptor.queryAllByFromUserId(userId).stream()
.map(UserBlock::getToUserId)
.toList();
List<Long> friendIdList =
neighborAdaptor.queryAllByFromUserId(userId).stream()
.map(Neighbor::getToUserId)
.toList();
NeighborCondition neighborCondition =
new NeighborCondition(userId, blockedIdList, friendIdList);
List<RetrieveNeighborDTO> neighbors = neighborAdaptor.searchNeighbors(neighborCondition);
List<RetrieveNeighborDTO> neighbors = neighborAdaptor.searchNeighbors(userId);
return neighbors.stream()
.map(
dto -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ protected ResponseEntity<ErrorResponse> internalServerExceptionHandle(
// e.getMessage(),
// e.getCause());
log.error(String.valueOf(e));
e.printStackTrace();
GlobalException internalServerError = GlobalException.INTERNAL_SERVER_ERROR;
ErrorResponse errorResponse = new ErrorResponse(internalServerError.getErrorDetail());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: 도메인 나오면 추가예정
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -62,7 +63,7 @@ public SliceResponse<ProductRetrieveDTO> productSearch(

@Operation(summary = "SmallCategory(FE기준 중분류) 별 상품을 조회합니다.")
@GetMapping("/products/small-category")
public List<ProductRetrieveDTO> getCategoricalProduct(
public List<ProductRetrieveVo> getCategoricalProduct(
@ParameterObject ProductFilterCondition productFilterCondition) {
return retrieveProductListUseCase.executeToSmallCategory(productFilterCondition);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -23,7 +25,7 @@ public class RetrieveProductListUseCase {
private final FavorQuestionAdaptor favorQuestionAdaptor;

@Transactional(readOnly = true)
public List<ProductRetrieveDTO> executeToSmallCategory(
public List<ProductRetrieveVo> executeToSmallCategory(
ProductFilterCondition productFilterCondition) {
List<Long> categoryIdList = new ArrayList<>();
productFilterCondition
Expand All @@ -35,14 +37,17 @@ public List<ProductRetrieveDTO> executeToSmallCategory(
.map(FavorQuestionCategory::getId)
.toList());
});
List<Product> results =
List<ProductRetrieveDTO> 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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,62 @@
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;
import tify.server.api.user.model.dto.response.OnBoardingStatusResponse;
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;

Expand All @@ -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;
Expand All @@ -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}")
Expand All @@ -87,7 +121,7 @@ public void updateNeighborViewedAt(@PathVariable Long neighborId) {
}

@Operation(summary = "유저 취향 답변 중분류 별 조회")
@GetMapping("/{userId}/tags")
@GetMapping("/{userId}/favors")
public List<UserAnswerVo> getUserTags(
@PathVariable Long userId,
@RequestParam @Parameter(description = "필터로 쓰일 중분류입니다.")
Expand All @@ -108,11 +142,18 @@ public UserInfoVo getUserProfileInfoByToken() {
return userInfoUseCase.executeByToken();
}

@Operation(summary = "대분류 별 유저 취향 조회 필터")
@GetMapping("/{userId}/category")
public List<UserFavorVo> getUserTagsByLargeCategory(
@PathVariable Long userId, @RequestParam LargeCategory largeCategory) {
return userFavorFilterUseCase.execute(userId, largeCategory);
@Operation(summary = "유저 취향 상자 조회")
@GetMapping("/{userId}/tags")
public List<UserFavorBoxVo> 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 = "온보딩")
Expand Down Expand Up @@ -283,4 +324,10 @@ public UserOpinionVo getMyOpinion(
public List<UserOpinionVo> getMyAllOpinion() {
return retrieveUserOpinionUseCase.executeAll();
}

@Operation(summary = "친구들의 취향 상자 정보와 프로필 리스트를 조회합니다.")
@GetMapping("/neighbors/favors")
public List<RetrieveUserFavorBoxVo> getNeighborsFavorBox() {
return retrieveNeighborFavorBoxUseCase.execute();
}
}
15 changes: 15 additions & 0 deletions Api/src/main/java/tify/server/api/user/model/dto/UserFavorDto.java
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
@@ -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<UserFavorDto> userFavorDtoList;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -28,4 +31,8 @@ public class UserOnBoardingRequest {

@NotBlank(message = "상태값을 입력해주세요.")
private String onBoardingState;

@Schema(description = "유저 취향 상자에 들어갈 소분류들입니다.")
@NotNull
private List<UserFavorDto> userFavorDtoList;
}
Loading

0 comments on commit 8636ae2

Please sign in to comment.