Skip to content

Commit

Permalink
[상대 프로필] 상대 프로필 조회시 선호조건도 제공된다.(#92) (#97)
Browse files Browse the repository at this point in the history
* feat: 다른 사용자 프로필 조회 응답 DTO에 선호조건 포함(#92)

다른 사용자 프로필 조회시 해당 사용자 선호조건 또한 응답에 포함

* feat: 다른 사용자 프로필 조회 로직, 응답에 선호조건 포함토록 수정(#92)

* feat: 선호하는 나이/키 상한,하한 필드 wrapper 타입으로 변경(#92)

해당 필드들은 nullable하므로 wrapper 타입으로 변경
  • Loading branch information
Minjae-An authored May 27, 2024
1 parent bb55d5b commit 44f8bae
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Getter;
import yeonba.be.user.entity.User;
import yeonba.be.user.entity.UserPreference;

@Getter
@AllArgsConstructor
Expand Down Expand Up @@ -68,9 +70,69 @@ public class UserProfileResponse {
example = "여우상")
private String lookAlikeAnimalName;

@Schema(
type = "number",
description = "선호하는 나이 하한, null일 수 있음",
example = "20")
private Integer preferredAgeLowerBound;

@Schema(
type = "number",
description = "선호하는 나이 상한, null일 수 있음",
example = "30")
private Integer preferredAgeUpperBound;

@Schema(
type = "number",
description = "선호하는 키 하한, null일 수 있음",
example = "150")
private Integer preferredHeightLowerBound;

@Schema(
type = "number",
description = "선호하는 키 상한, null일 수 있음",
example = "180")
private Integer preferredHeightUpperBound;

@Schema(
type = "string",
description = "선호하는 mbti",
example = "ISTJ")
private String preferredMbti;

@Schema(
type = "string",
description = "선호하는 체형",
example = "마른체형")
private String preferredBodyType;

@Schema(
type = "boolean",
description = "이전 화살 전송 여부",
example = "false")
private boolean isAlreadySentArrow;

public static UserProfileResponse from(
User user, UserPreference userPreference, boolean isAlreadySentArrow) {

return new UserProfileResponse(
user.getProfilePhotoUrls(),
user.getGenderString(),
user.getNickname(),
user.getArrow(),
user.getAge(),
user.getHeight(),
user.getArea().getName(),
user.getPhotoSyncRate(),
user.getVocalRange().getClassification(),
user.getAnimal().getName(),
userPreference.getAgeLowerBound(),
userPreference.getAgeUpperBound(),
userPreference.getHeightLowerBound(),
userPreference.getHeightUpperBound(),
userPreference.getMbti(),
userPreference.getBodyType(),
isAlreadySentArrow
);
}
}
19 changes: 6 additions & 13 deletions be/src/main/java/yeonba/be/user/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import yeonba.be.user.repository.user.UserCommand;
import yeonba.be.user.repository.user.UserQuery;
import yeonba.be.user.repository.userpreference.UserPreferenceCommand;
import yeonba.be.user.repository.userpreference.UserPreferenceQuery;
import yeonba.be.user.repository.userrecommendation.UserRecommendationCommand;
import yeonba.be.user.repository.userrecommendation.UserRecommendationQuery;
import yeonba.be.user.repository.vocalrange.VocalRangeQuery;
Expand All @@ -54,6 +55,7 @@ public class UserService {
private final AreaQuery areaQuery;
private final ArrowQuery arrowQuery;
private final UserQuery userQuery;
private final UserPreferenceQuery userPreferenceQuery;
private final UserRecommendationQuery userRecommendationQuery;
private final VocalRangeQuery vocalRangeQuery;

Expand All @@ -63,22 +65,13 @@ public class UserService {
public UserProfileResponse getTargetUserProfile(long userId, long targetUserId) {

User user = userQuery.findById(userId);
User targetUser = userQuery.findById(targetUserId);

// 조회하는 사용자 정보, 선호조건, 이전 화살 송신 여부 조회
User targetUser = userQuery.findById(targetUserId);
UserPreference targetUserPreference = userPreferenceQuery.findByUser(targetUser);
boolean isAlreadySentArrow = arrowQuery.isArrowTransactionExist(user, targetUser);

return new UserProfileResponse(
targetUser.getProfilePhotoUrls(),
targetUser.getGenderString(),
targetUser.getNickname(),
targetUser.getArrow(),
targetUser.getAge(),
targetUser.getHeight(),
targetUser.getArea().getName(),
targetUser.getPhotoSyncRate(),
targetUser.getVocalRange().getClassification(),
targetUser.getAnimal().getName(),
isAlreadySentArrow);
return UserProfileResponse.from(targetUser, targetUserPreference, isAlreadySentArrow);
}

public User saveUser(UserJoinRequest request) {
Expand Down

0 comments on commit 44f8bae

Please sign in to comment.