Skip to content

Commit

Permalink
THT-Server-282 [App] 종교 및 흡연 여부 조회 시 한글값으로 변경 (#283)
Browse files Browse the repository at this point in the history
* feat: 유저 상세 조회 응답값 변경
* feat: 메인 화면 조회에 유저 정보 추가
  • Loading branch information
thalals authored Feb 23, 2025
1 parent e877ef7 commit 4d29090
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public record MainScreenUserInfoResponse(
int age,
String address,
boolean isBirthDay,
String smoking,
String drinking,
String religion,
List<IdealTypeResponse> idealTypeResponseList,
List<InterestResponse> interestResponses,
List<UserProfilePhotoResponse> userProfilePhotos,
Expand All @@ -30,6 +33,9 @@ public static MainScreenUserInfoResponse of(final MainScreenUserInfoMapper mappe
ConvertAgeUtils.covertBeforeBirthAge(mapper.birthDay()),
mapper.address(),
isBirthDay(mapper.birthDay()),
mapper.smoking().getDesc(),
mapper.drinking().getDesc(),
mapper.religion().getDesc(),
mapper.idealTypeMapper().stream().map(IdealTypeResponse::of).toList(),
mapper.interestMapper().stream().map(InterestResponse::of).toList(),
mapper.userProfilePhotoMapper().stream().map(UserProfilePhotoResponse::of).toList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.tht.domain.entity.idealtype.IdealTypeMapper;
import com.tht.domain.entity.interesst.InterestMapper;
import com.tht.enums.user.Gender;
import com.tht.enums.user.UserFrequency;
import com.tht.enums.user.UserReligion;
import com.tht.domain.entity.user.User;
import com.tht.domain.entity.user.UserAgreement;
import com.tht.domain.entity.user.UserLocationInfo;
import com.tht.domain.entity.user.UserProfilePhoto;
import com.tht.enums.user.Gender;
import com.tht.thtapis.facade.idealtype.response.IdealTypeResponse;
import com.tht.thtapis.facade.interest.response.InterestResponse;
import com.tht.thtcommonutils.utils.ConvertAgeUtils;
Expand All @@ -30,9 +28,9 @@ public record UserDetailResponse(
@JsonProperty("prefer_gender")
Gender preferGender,
int tall,
UserFrequency smoking,
UserFrequency drinking,
UserReligion religion,
String smoking,
String drinking,
String religion,
List<IdealTypeResponse> idealTypeList,
List<InterestResponse> interestsList,
List<UserProfilePhotoResponse> userProfilePhotos,
Expand All @@ -59,9 +57,9 @@ public static UserDetailResponse of(
user.getGender(),
user.getPreferGender(),
user.getTall(),
user.getSmoking(),
user.getDrinking(),
user.getReligion(),
user.getSmoking().getDesc(),
user.getDrinking().getDesc(),
user.getReligion().getDesc(),
idealTypeMappers.stream().map(IdealTypeResponse::of).toList(),
interestMappers.stream().map(InterestResponse::of).toList(),
profilePhotoMappers.stream().map(UserProfilePhotoResponse::of).toList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.epages.restdocs.apispec.ResourceSnippetParameters;
import com.epages.restdocs.apispec.Schema;
import com.tht.enums.user.UserFrequency;
import com.tht.enums.user.UserReligion;
import com.tht.thtapis.controller.config.ControllerTestConfig;
import com.tht.thtapis.controller.config.WithCustomMockUser;
import com.tht.thtapis.facade.user.UserFacade;
Expand All @@ -17,6 +19,8 @@
import org.springframework.test.web.servlet.ResultActions;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;

import java.util.Arrays;

import static com.epages.restdocs.apispec.MockMvcRestDocumentationWrapper.document;
import static com.epages.restdocs.apispec.ResourceDocumentation.resource;
import static org.mockito.ArgumentMatchers.any;
Expand Down Expand Up @@ -72,6 +76,13 @@ void getMainScreenUserList() throws Exception {
fieldWithPath("userInfos[].age").description("나이"),
fieldWithPath("userInfos[].address").description("주소"),
fieldWithPath("userInfos[].isBirthDay").description("생일 여부"),
fieldWithPath("userInfos[].smoking")
.description(String.format("흡연 여부 - %s", Arrays.stream(UserFrequency.values())
.map(UserFrequency::getDesc).toList())),
fieldWithPath("userInfos[].drinking").description(String.format("술 - %s", Arrays.stream(UserFrequency.values())
.map(UserFrequency::getDesc).toList())),
fieldWithPath("userInfos[].religion").description(String.format("종교 - %s", Arrays.stream(UserReligion.values())
.map(UserReligion::getDesc).toList())),
fieldWithPath("userInfos[].idealTypeResponseList").description("선택한 이상형 리스트"),
fieldWithPath("userInfos[].idealTypeResponseList[].idx").description("이상형 idx"),
fieldWithPath("userInfos[].idealTypeResponseList[].name").description("이상형 명칭"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.springframework.test.web.servlet.ResultActions;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -153,10 +154,13 @@ void getUserDetails() throws Exception {
fieldWithPath("gender").description(String.format("성별 - %s", EnumDocsUtils.getTypesFieldList(Gender.class))),
fieldWithPath("prefer_gender").description(String.format("선호 성별 - %s", EnumDocsUtils.getTypesFieldList(Gender.class))),
fieldWithPath("tall").description("키"),
fieldWithPath("smoking").description(String.format("흡연 여부 - %s", EnumDocsUtils.getTypesFieldList(UserFrequency.class))),
fieldWithPath("drinking").description(String.format("술 - %s", EnumDocsUtils.getTypesFieldList(UserFrequency.class))),
fieldWithPath("religion").description(String.format("종교 - %s", EnumDocsUtils.getTypesFieldList(UserReligion.class))),

fieldWithPath("smoking")
.description(String.format("흡연 여부 - %s", Arrays.stream(UserFrequency.values())
.map(UserFrequency::getDesc).toList())),
fieldWithPath("drinking").description(String.format("술 - %s", Arrays.stream(UserFrequency.values())
.map(UserFrequency::getDesc).toList())),
fieldWithPath("religion").description(String.format("종교 - %s", Arrays.stream(UserReligion.values())
.map(UserReligion::getDesc).toList())),
fieldWithPath("idealTypeList").description("선택한 이상형 리스트"),
fieldWithPath("idealTypeList[].idx").description("이상형 idx"),
fieldWithPath("idealTypeList[].name").description("이상형 명칭"),
Expand Down Expand Up @@ -771,12 +775,12 @@ void docsDeviceKey() throws Exception {

//given
mockMvc.perform(
patch("/user/device-key")
.header("Authorization", "Bearer {ACCESS_TOKEN}")
.contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON)
.content(requestBody)
).andDo(
patch("/user/device-key")
.header("Authorization", "Bearer {ACCESS_TOKEN}")
.contentType(MediaType.APPLICATION_JSON)
.accept(MediaType.APPLICATION_JSON)
.content(requestBody)
).andDo(
document("유저 디바이스키 갱신 api docs",
preprocessRequest(prettyPrint()),
preprocessResponse(prettyPrint()),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.tht.thtapis.fixture.main;

import com.tht.enums.user.UserFrequency;
import com.tht.enums.user.UserReligion;
import com.tht.thtapis.facade.idealtype.response.IdealTypeResponse;
import com.tht.thtapis.facade.interest.response.InterestResponse;
import com.tht.thtapis.facade.user.response.MainScreenUserInfoResponse;
Expand All @@ -17,6 +19,9 @@ public class MainScreenUserInfoResponseFixture {
private static final int age = 24;
private static final String address = "인천광역시 부평구 ";
private static final boolean isBirthDay = true;
private final static UserFrequency smoking = UserFrequency.SOMETIMES;
private final static UserFrequency drinking = UserFrequency.SOMETIMES;
private final static UserReligion religion = UserReligion.CATHOLICISM;
private static final List<IdealTypeResponse> idealTypeResponseList = List.of(
IdealTypeFixture.responseMake());
private static final List<InterestResponse> interestResponses = List.of(
Expand All @@ -35,6 +40,9 @@ public static MainScreenUserInfoResponse make() {
age,
address,
isBirthDay,
smoking.getDesc(),
drinking.getDesc(),
religion.getDesc(),
idealTypeResponseList,
interestResponses,
userProfilePhotoResponses,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public static UserDetailResponse make() {
gender,
preferGender,
tall,
smoking,
drinking,
religion,
smoking.getDesc(),
drinking.getDesc(),
religion.getDesc(),
idealTypeList,
interestsList,
userProfilePhotos,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.querydsl.core.annotations.QueryProjection;
import com.tht.domain.entity.idealtype.IdealTypeMapper;
import com.tht.domain.entity.interesst.InterestMapper;
import com.tht.enums.user.UserFrequency;
import com.tht.enums.user.UserReligion;

import java.time.LocalDate;
import java.util.Set;
Expand All @@ -12,6 +14,9 @@ public record MainScreenUserInfoMapper(
String userUuid,
LocalDate birthDay,
String address,
UserFrequency smoking,
UserFrequency drinking,
UserReligion religion,
Set<IdealTypeMapper> idealTypeMapper,
Set<InterestMapper> interestMapper,
Set<UserProfilePhotoMapper> userProfilePhotoMapper,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ public List<MainScreenUserInfoMapper> findAllMatchingFallingUser(
user.userUuid,
user.birthDay,
userLocationInfo.address,
user.smoking,
user.drinking,
user.religion,
GroupBy.set(
new QIdealTypeMapper(
idealType.idx,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@
import com.tht.enums.EnumModel;
import com.tht.enums.EnumStateNotFoundException;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@AllArgsConstructor
public enum UserFrequency implements EnumModel {

NONE("NONE"),
SOMETIMES("SOMETIMES"),
FREQUENTLY("FREQUENTLY");
NONE("NONE", "안 함"),
SOMETIMES("SOMETIMES", "가끔"),
FREQUENTLY("FREQUENTLY", "자주");

private final String value;
@Getter
private final String desc;

@JsonCreator
public static UserFrequency toConverter(final String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,23 @@
import com.tht.enums.EnumModel;
import com.tht.enums.EnumStateNotFoundException;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@AllArgsConstructor
public enum UserReligion implements EnumModel {

NONE("NONE"),
CHRISTIAN("CHRISTIAN"),
CATHOLICISM("CATHOLICISM"),
BUDDHISM("BUDDHISM"),
WON_BUDDHISM("WON_BUDDHISM"),
OTHER("OTHER");
NONE("NONE", "무교"),
CHRISTIAN("CHRISTIAN", "기독교"),
CATHOLICISM("CATHOLICISM", "천주교"),
BUDDHISM("BUDDHISM", "불교"),
WON_BUDDHISM("WON_BUDDHISM", "원불"),
OTHER("OTHER", "기타");

private final String value;
@Getter
private final String desc;

@JsonCreator
public static UserReligion toConverter(final String name) {
Expand Down

0 comments on commit 4d29090

Please sign in to comment.