diff --git a/src/main/java/org/gachon/checkmate/domain/checkList/converter/LifePatterTypeConverter.java b/src/main/java/org/gachon/checkmate/domain/checkList/converter/LifePatterTypeConverter.java deleted file mode 100644 index 64b9720..0000000 --- a/src/main/java/org/gachon/checkmate/domain/checkList/converter/LifePatterTypeConverter.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.gachon.checkmate.domain.checkList.converter; - -import jakarta.persistence.Converter; -import org.gachon.checkmate.domain.checkList.entity.LifePatterType; -import org.gachon.checkmate.global.utils.AbstractEnumCodeAttributeConverter; - -@Converter -public class LifePatterTypeConverter extends AbstractEnumCodeAttributeConverter { - public LifePatterTypeConverter() { - super(LifePatterType.class); - } -} diff --git a/src/main/java/org/gachon/checkmate/domain/checkList/converter/LifePatternTypeConverter.java b/src/main/java/org/gachon/checkmate/domain/checkList/converter/LifePatternTypeConverter.java new file mode 100644 index 0000000..afc3d35 --- /dev/null +++ b/src/main/java/org/gachon/checkmate/domain/checkList/converter/LifePatternTypeConverter.java @@ -0,0 +1,12 @@ +package org.gachon.checkmate.domain.checkList.converter; + +import jakarta.persistence.Converter; +import org.gachon.checkmate.domain.checkList.entity.LifePatternType; +import org.gachon.checkmate.global.utils.AbstractEnumCodeAttributeConverter; + +@Converter +public class LifePatternTypeConverter extends AbstractEnumCodeAttributeConverter { + public LifePatternTypeConverter() { + super(LifePatternType.class); + } +} diff --git a/src/main/java/org/gachon/checkmate/domain/checkList/converter/SmokeTypeConverter.java b/src/main/java/org/gachon/checkmate/domain/checkList/converter/SmokeTypeConverter.java new file mode 100644 index 0000000..28acddf --- /dev/null +++ b/src/main/java/org/gachon/checkmate/domain/checkList/converter/SmokeTypeConverter.java @@ -0,0 +1,12 @@ +package org.gachon.checkmate.domain.checkList.converter; + +import jakarta.persistence.Converter; +import org.gachon.checkmate.domain.checkList.entity.SmokeType; +import org.gachon.checkmate.global.utils.AbstractEnumCodeAttributeConverter; + +@Converter +public class SmokeTypeConverter extends AbstractEnumCodeAttributeConverter { + public SmokeTypeConverter() { + super(SmokeType.class); + } +} diff --git a/src/main/java/org/gachon/checkmate/domain/checkList/dto/request/CheckListRequestDto.java b/src/main/java/org/gachon/checkmate/domain/checkList/dto/request/CheckListRequestDto.java index 03ce426..9426ff7 100644 --- a/src/main/java/org/gachon/checkmate/domain/checkList/dto/request/CheckListRequestDto.java +++ b/src/main/java/org/gachon/checkmate/domain/checkList/dto/request/CheckListRequestDto.java @@ -6,9 +6,10 @@ public record CheckListRequestDto( CleanType cleanType, DrinkType drinkType, HomeType homeType, - LifePatterType lifePatterType, + LifePatternType lifePatternType, NoiseType noiseType, - SleepType sleepType + SleepType sleepType, + SmokeType smokeType ) { } diff --git a/src/main/java/org/gachon/checkmate/domain/checkList/dto/response/CheckListResponseDto.java b/src/main/java/org/gachon/checkmate/domain/checkList/dto/response/CheckListResponseDto.java index 6dfc399..f970bf4 100644 --- a/src/main/java/org/gachon/checkmate/domain/checkList/dto/response/CheckListResponseDto.java +++ b/src/main/java/org/gachon/checkmate/domain/checkList/dto/response/CheckListResponseDto.java @@ -9,14 +9,16 @@ public record CheckListResponseDto( String homeType, String lifePatterType, String noiseType, - String sleepType + String sleepType, + String smokeType ) { public static CheckListResponseDto of(String cleanType, String drinkType, String homeType, String lifePatterType, String noiseType, - String sleepType) { + String sleepType, + String smokeType) { return CheckListResponseDto.builder() .cleanType(cleanType) .drinkType(drinkType) @@ -24,6 +26,7 @@ public static CheckListResponseDto of(String cleanType, .lifePatterType(lifePatterType) .noiseType(noiseType) .sleepType(sleepType) + .smokeType(smokeType) .build(); } } diff --git a/src/main/java/org/gachon/checkmate/domain/checkList/entity/CheckList.java b/src/main/java/org/gachon/checkmate/domain/checkList/entity/CheckList.java index 2d6760a..9c00f02 100644 --- a/src/main/java/org/gachon/checkmate/domain/checkList/entity/CheckList.java +++ b/src/main/java/org/gachon/checkmate/domain/checkList/entity/CheckList.java @@ -23,12 +23,14 @@ public class CheckList extends BaseTimeEntity { private DrinkType drinkType; @Convert(converter = HomeTypeConverter.class) private HomeType homeType; - @Convert(converter = LifePatterTypeConverter.class) - private LifePatterType lifePatterType; + @Convert(converter = LifePatternTypeConverter.class) + private LifePatternType lifePatternType; @Convert(converter = NoiseTypeConverter.class) private NoiseType noiseType; @Convert(converter = SleepTypeConverter.class) private SleepType sleepType; + @Convert(converter = SmokeTypeConverter.class) + private SmokeType smokeType; @OneToOne(fetch = FetchType.LAZY) @JoinColumn(name = "user_id") private User user; @@ -38,9 +40,10 @@ public static CheckList createCheckList(User user, CheckListRequestDto checkList .cleanType(checkListRequestDto.cleanType()) .drinkType(checkListRequestDto.drinkType()) .homeType(checkListRequestDto.homeType()) - .lifePatterType(checkListRequestDto.lifePatterType()) + .lifePatternType(checkListRequestDto.lifePatternType()) .noiseType(checkListRequestDto.noiseType()) .sleepType(checkListRequestDto.sleepType()) + .smokeType(checkListRequestDto.smokeType()) .user(user) .build(); user.setCheckList(checkList); @@ -51,7 +54,7 @@ public void updateCheckList(CheckListRequestDto checkListRequestDto) { this.cleanType = checkListRequestDto.cleanType(); this.drinkType = checkListRequestDto.drinkType(); this.homeType = checkListRequestDto.homeType(); - this.lifePatterType = checkListRequestDto.lifePatterType(); + this.lifePatternType = checkListRequestDto.lifePatternType(); this.noiseType = checkListRequestDto.noiseType(); this.sleepType = checkListRequestDto.sleepType(); } diff --git a/src/main/java/org/gachon/checkmate/domain/checkList/entity/LifePatterType.java b/src/main/java/org/gachon/checkmate/domain/checkList/entity/LifePatternType.java similarity index 88% rename from src/main/java/org/gachon/checkmate/domain/checkList/entity/LifePatterType.java rename to src/main/java/org/gachon/checkmate/domain/checkList/entity/LifePatternType.java index 1f3778b..405842d 100644 --- a/src/main/java/org/gachon/checkmate/domain/checkList/entity/LifePatterType.java +++ b/src/main/java/org/gachon/checkmate/domain/checkList/entity/LifePatternType.java @@ -7,7 +7,7 @@ @AllArgsConstructor(access = AccessLevel.PRIVATE) @Getter -public enum LifePatterType implements EnumField { +public enum LifePatternType implements EnumField { MORNING("1", "아침형 인간"), EVENING("2", "저녁형 인간"); private String code; diff --git a/src/main/java/org/gachon/checkmate/domain/checkList/entity/PostCheckList.java b/src/main/java/org/gachon/checkmate/domain/checkList/entity/PostCheckList.java index f6d36ff..e23efc2 100644 --- a/src/main/java/org/gachon/checkmate/domain/checkList/entity/PostCheckList.java +++ b/src/main/java/org/gachon/checkmate/domain/checkList/entity/PostCheckList.java @@ -23,12 +23,14 @@ public class PostCheckList extends BaseTimeEntity { private DrinkType drinkType; @Convert(converter = HomeTypeConverter.class) private HomeType homeType; - @Convert(converter = LifePatterTypeConverter.class) - private LifePatterType lifePatterType; + @Convert(converter = LifePatternTypeConverter.class) + private LifePatternType lifePatternType; @Convert(converter = NoiseTypeConverter.class) private NoiseType noiseType; @Convert(converter = SleepTypeConverter.class) private SleepType sleepType; + @Convert(converter = SmokeTypeConverter.class) + private SmokeType smokeType; @OneToOne(fetch = FetchType.LAZY) @JoinColumn(name = "post_id") private Post post; @@ -38,9 +40,10 @@ public static PostCheckList createPostCheckList(CheckListRequestDto checkListReq .cleanType(checkListRequestDto.cleanType()) .drinkType(checkListRequestDto.drinkType()) .homeType(checkListRequestDto.homeType()) - .lifePatterType(checkListRequestDto.lifePatterType()) + .lifePatternType(checkListRequestDto.lifePatternType()) .noiseType(checkListRequestDto.noiseType()) .sleepType(checkListRequestDto.sleepType()) + .smokeType(checkListRequestDto.smokeType()) .post(post) .build(); post.setPostCheckList(checkList); @@ -51,8 +54,9 @@ public void updatePostCheckList(CheckListRequestDto checkListRequestDto) { this.cleanType = checkListRequestDto.cleanType(); this.drinkType = checkListRequestDto.drinkType(); this.homeType = checkListRequestDto.homeType(); - this.lifePatterType = checkListRequestDto.lifePatterType(); + this.lifePatternType = checkListRequestDto.lifePatternType(); this.noiseType = checkListRequestDto.noiseType(); this.sleepType = checkListRequestDto.sleepType(); + this.smokeType = checkListRequestDto.smokeType(); } } diff --git a/src/main/java/org/gachon/checkmate/domain/checkList/entity/SmokeType.java b/src/main/java/org/gachon/checkmate/domain/checkList/entity/SmokeType.java new file mode 100644 index 0000000..fba772c --- /dev/null +++ b/src/main/java/org/gachon/checkmate/domain/checkList/entity/SmokeType.java @@ -0,0 +1,17 @@ +package org.gachon.checkmate.domain.checkList.entity; + +import lombok.AccessLevel; +import lombok.AllArgsConstructor; +import lombok.Getter; +import org.gachon.checkmate.global.utils.EnumField; + +@AllArgsConstructor(access = AccessLevel.PRIVATE) +@Getter +public enum SmokeType implements EnumField { + SMOKE("1", "흡연자 선호"), + NONE("2", "비흡연자 선호"); + + private final String code; + private final String desc; +} + diff --git a/src/main/java/org/gachon/checkmate/domain/checkList/service/CheckListService.java b/src/main/java/org/gachon/checkmate/domain/checkList/service/CheckListService.java index b396bc2..6001099 100644 --- a/src/main/java/org/gachon/checkmate/domain/checkList/service/CheckListService.java +++ b/src/main/java/org/gachon/checkmate/domain/checkList/service/CheckListService.java @@ -44,9 +44,10 @@ public CheckListResponseDto getCheckList(Long userId) { return CheckListResponseDto.of(checkList.getCleanType().getDesc(), checkList.getDrinkType().getDesc(), checkList.getHomeType().getDesc(), - checkList.getLifePatterType().getDesc(), + checkList.getLifePatternType().getDesc(), checkList.getNoiseType().getDesc(), - checkList.getSleepType().getDesc()); + checkList.getSleepType().getDesc(), + checkList.getSmokeType().getDesc()); } private User findByIdOrThrow(Long userId) { diff --git a/src/main/java/org/gachon/checkmate/domain/member/entity/User.java b/src/main/java/org/gachon/checkmate/domain/member/entity/User.java index 855e362..a29c92d 100644 --- a/src/main/java/org/gachon/checkmate/domain/member/entity/User.java +++ b/src/main/java/org/gachon/checkmate/domain/member/entity/User.java @@ -13,6 +13,8 @@ import java.util.ArrayList; import java.util.List; +import static org.gachon.checkmate.domain.member.entity.UserState.JOIN; + @NoArgsConstructor(access = AccessLevel.PROTECTED) @AllArgsConstructor(access = AccessLevel.PRIVATE) @Builder(access = AccessLevel.PRIVATE) @@ -55,6 +57,7 @@ public static User createUser(String email, String storedPassword, String name, .major(major) .mbtiType(mbti) .gender(gender) + .userState(JOIN) .build(); } diff --git a/src/main/java/org/gachon/checkmate/domain/post/service/PostService.java b/src/main/java/org/gachon/checkmate/domain/post/service/PostService.java index 76108af..7ea7727 100644 --- a/src/main/java/org/gachon/checkmate/domain/post/service/PostService.java +++ b/src/main/java/org/gachon/checkmate/domain/post/service/PostService.java @@ -130,9 +130,10 @@ private CheckListResponseDto createCheckListResponseDto(PostCheckList postCheckL postCheckList.getCleanType().getDesc(), postCheckList.getDrinkType().getDesc(), postCheckList.getHomeType().getDesc(), - postCheckList.getLifePatterType().getDesc(), + postCheckList.getLifePatternType().getDesc(), postCheckList.getNoiseType().getDesc(), - postCheckList.getSleepType().getDesc() + postCheckList.getSleepType().getDesc(), + postCheckList.getSmokeType().getDesc() ); } @@ -156,7 +157,7 @@ private int getAccuracy(PostCheckList postCheckList, CheckList checkList) { count += getRateForFrequencyElement(postCheckList.getCleanType().getCode(), checkList.getCleanType().getCode(), 4); count += getRateForFrequencyElement(postCheckList.getDrinkType().getCode(), checkList.getDrinkType().getCode(), 3); count += getRateForFrequencyElement(postCheckList.getHomeType().getCode(), checkList.getHomeType().getCode(), 3); - count = postCheckList.getLifePatterType().equals(checkList.getLifePatterType()) ? count + 1 : count; + count = postCheckList.getLifePatternType().equals(checkList.getLifePatternType()) ? count + 1 : count; count = postCheckList.getNoiseType().equals(checkList.getNoiseType()) ? count + 1 : count; count = postCheckList.getSleepType().equals(checkList.getSleepType()) ? count + 1 : count; return (int) (count / 6) * 100; diff --git a/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java b/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java index e352f31..7cb2339 100644 --- a/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java +++ b/src/main/java/org/gachon/checkmate/domain/scrap/service/ScrapService.java @@ -70,7 +70,7 @@ private int getAccuracy(PostCheckList postCheckList, CheckList checkList) { count += getRateForFrequencyElement(postCheckList.getCleanType().getCode(), checkList.getCleanType().getCode(), 4); count += getRateForFrequencyElement(postCheckList.getDrinkType().getCode(), checkList.getDrinkType().getCode(), 3); count += getRateForFrequencyElement(postCheckList.getHomeType().getCode(), checkList.getHomeType().getCode(), 3); - count = postCheckList.getLifePatterType().equals(checkList.getLifePatterType()) ? count + 1 : count; + count = postCheckList.getLifePatternType().equals(checkList.getLifePatternType()) ? count + 1 : count; count = postCheckList.getNoiseType().equals(checkList.getNoiseType()) ? count + 1 : count; count = postCheckList.getSleepType().equals(checkList.getSleepType()) ? count + 1 : count; return (int) (count / 6) * 100;