Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[상대 프로필] 상대 프로필 조회시 선호조건도 제공된다.(#92) #97

Merged
merged 5 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading