diff --git a/src/main/java/org/gachon/checkmate/domain/checkList/converter/CallTypeConverter.java b/src/main/java/org/gachon/checkmate/domain/checkList/converter/CallTypeConverter.java new file mode 100644 index 0000000..d56620c --- /dev/null +++ b/src/main/java/org/gachon/checkmate/domain/checkList/converter/CallTypeConverter.java @@ -0,0 +1,12 @@ +package org.gachon.checkmate.domain.checkList.converter; + +import jakarta.persistence.Converter; +import org.gachon.checkmate.domain.checkList.entity.CallType; +import org.gachon.checkmate.global.utils.AbstractEnumCodeAttributeConverter; + +@Converter +public class CallTypeConverter extends AbstractEnumCodeAttributeConverter { + public CallTypeConverter() { + super(CallType.class); + } +} diff --git a/src/main/java/org/gachon/checkmate/domain/checkList/converter/EarPhoneTypeConverter.java b/src/main/java/org/gachon/checkmate/domain/checkList/converter/EarPhoneTypeConverter.java new file mode 100644 index 0000000..ada6b22 --- /dev/null +++ b/src/main/java/org/gachon/checkmate/domain/checkList/converter/EarPhoneTypeConverter.java @@ -0,0 +1,12 @@ +package org.gachon.checkmate.domain.checkList.converter; + +import jakarta.persistence.Converter; +import org.gachon.checkmate.domain.checkList.entity.EarPhoneType; +import org.gachon.checkmate.global.utils.AbstractEnumCodeAttributeConverter; + +@Converter +public class EarPhoneTypeConverter extends AbstractEnumCodeAttributeConverter { + public EarPhoneTypeConverter() { + super(EarPhoneType.class); + } +} diff --git a/src/main/java/org/gachon/checkmate/domain/checkList/converter/NoiseTypeConverter.java b/src/main/java/org/gachon/checkmate/domain/checkList/converter/NoiseTypeConverter.java deleted file mode 100644 index 96656a3..0000000 --- a/src/main/java/org/gachon/checkmate/domain/checkList/converter/NoiseTypeConverter.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.NoiseType; -import org.gachon.checkmate.global.utils.AbstractEnumCodeAttributeConverter; - -@Converter -public class NoiseTypeConverter extends AbstractEnumCodeAttributeConverter { - public NoiseTypeConverter() { - super(NoiseType.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 1461b01..79f1221 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 @@ -7,7 +7,8 @@ public record CheckListRequestDto( DrinkType drinkType, HomeType homeType, LifePatternType lifePatternType, - NoiseType noiseType, + CallType callType, + EarPhoneType earPhoneType, SleepGridingType sleepGridingType, SleepSnoreType sleepSnoreType, SleepTalkingType sleepTalkingType, 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 bf26a14..2966e82 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,7 +9,8 @@ public record CheckListResponseDto( String drinkType, String homeType, String lifePatterType, - String noiseType, + String callType, + String earPhoneType, String sleepGridingType, String sleepSnoreType, String sleepTalkingType, @@ -22,7 +23,8 @@ public static CheckListResponseDto of(CheckList checkList) { .drinkType(checkList.getDrinkType().getDesc()) .homeType(checkList.getHomeType().getDesc()) .lifePatterType(checkList.getLifePatternType().getDesc()) - .noiseType(checkList.getNoiseType().getDesc()) + .callType(checkList.getCallType().getCode()) + .earPhoneType(checkList.getEarPhoneType().getCode()) .sleepGridingType(checkList.getSleepGridingType().getDesc()) .sleepSnoreType(checkList.getSleepSnoreType().getDesc()) .sleepTalkingType(checkList.getSleepTalkingType().getDesc()) @@ -37,7 +39,8 @@ public static CheckListResponseDto ofPostCheckList(PostCheckList checkList) { .drinkType(checkList.getDrinkType().getDesc()) .homeType(checkList.getHomeType().getDesc()) .lifePatterType(checkList.getLifePatternType().getDesc()) - .noiseType(checkList.getNoiseType().getDesc()) + .callType(checkList.getCallType().getCode()) + .earPhoneType(checkList.getEarPhoneType().getCode()) .sleepGridingType(checkList.getSleepGridingType().getDesc()) .sleepSnoreType(checkList.getSleepSnoreType().getDesc()) .sleepTalkingType(checkList.getSleepTalkingType().getDesc()) diff --git a/src/main/java/org/gachon/checkmate/domain/checkList/entity/NoiseType.java b/src/main/java/org/gachon/checkmate/domain/checkList/entity/CallType.java similarity index 60% rename from src/main/java/org/gachon/checkmate/domain/checkList/entity/NoiseType.java rename to src/main/java/org/gachon/checkmate/domain/checkList/entity/CallType.java index d748b73..e05bd0e 100644 --- a/src/main/java/org/gachon/checkmate/domain/checkList/entity/NoiseType.java +++ b/src/main/java/org/gachon/checkmate/domain/checkList/entity/CallType.java @@ -7,16 +7,15 @@ @AllArgsConstructor(access = AccessLevel.PRIVATE) @Getter -public enum NoiseType implements EnumField { - EARPHONE("1", "이어폰 필수"), - OUTSIDE("2", "전화는 밖에서"), - SHORT("3", "전화는 짧게"), - ANYWAY("4", "상관없음"); +public enum CallType implements EnumField { + OUTSIDE("1", "통화는 밖에서"), + INSIDE("2", "5분 이내는 안에서"), + ANYWAY("3", "상관없음"); private final String code; private final String desc; - public int compareRateTo(NoiseType e) { + public int compareRateTo(CallType e) { return this.equals(e) ? 1 : 0; } } 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 cde2799..d1f62a4 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 @@ -25,8 +25,10 @@ public class CheckList extends BaseTimeEntity { private HomeType homeType; @Convert(converter = LifePatternTypeConverter.class) private LifePatternType lifePatternType; - @Convert(converter = NoiseTypeConverter.class) - private NoiseType noiseType; + @Convert(converter = CallTypeConverter.class) + private CallType callType; + @Convert(converter = EarPhoneTypeConverter.class) + private EarPhoneType earPhoneType; @Convert(converter = SleepGridingTypeConverter.class) private SleepGridingType sleepGridingType; @Convert(converter = SleepSnoreTypeConverter.class) @@ -47,7 +49,8 @@ public static CheckList createCheckList(User user, CheckListRequestDto checkList .drinkType(checkListRequestDto.drinkType()) .homeType(checkListRequestDto.homeType()) .lifePatternType(checkListRequestDto.lifePatternType()) - .noiseType(checkListRequestDto.noiseType()) + .callType(checkListRequestDto.callType()) + .earPhoneType(checkListRequestDto.earPhoneType()) .sleepGridingType(checkListRequestDto.sleepGridingType()) .sleepSnoreType(checkListRequestDto.sleepSnoreType()) .sleepTalkingType(checkListRequestDto.sleepTalkingType()) @@ -64,7 +67,8 @@ public void updateCheckList(CheckListRequestDto checkListRequestDto) { this.drinkType = checkListRequestDto.drinkType(); this.homeType = checkListRequestDto.homeType(); this.lifePatternType = checkListRequestDto.lifePatternType(); - this.noiseType = checkListRequestDto.noiseType(); + this.callType = checkListRequestDto.callType(); + this.earPhoneType = checkListRequestDto.earPhoneType(); this.sleepGridingType = checkListRequestDto.sleepGridingType(); this.sleepSnoreType = checkListRequestDto.sleepSnoreType(); this.sleepTalkingType = checkListRequestDto.sleepTalkingType(); diff --git a/src/main/java/org/gachon/checkmate/domain/checkList/entity/CleanType.java b/src/main/java/org/gachon/checkmate/domain/checkList/entity/CleanType.java index fb99d4a..7b7bcbc 100644 --- a/src/main/java/org/gachon/checkmate/domain/checkList/entity/CleanType.java +++ b/src/main/java/org/gachon/checkmate/domain/checkList/entity/CleanType.java @@ -18,7 +18,7 @@ public enum CleanType implements EnumField { private final String desc; private final int size = 5; - public int compareRateTo(CleanType e) { - return 1 - Math.abs(Integer.parseInt(this.getCode()) - Integer.parseInt(e.getCode())) / (this.size - 1); + public double compareRateTo(CleanType e) { + return 1 - (double) Math.abs(Integer.parseInt(this.getCode()) - Integer.parseInt(e.getCode())) / (this.size - 1); } } diff --git a/src/main/java/org/gachon/checkmate/domain/checkList/entity/DrinkType.java b/src/main/java/org/gachon/checkmate/domain/checkList/entity/DrinkType.java index b8a29f8..cbf3577 100644 --- a/src/main/java/org/gachon/checkmate/domain/checkList/entity/DrinkType.java +++ b/src/main/java/org/gachon/checkmate/domain/checkList/entity/DrinkType.java @@ -17,7 +17,7 @@ public enum DrinkType implements EnumField { private final String desc; private final int size = 4; - public int compareRateTo(DrinkType e) { - return 1 - Math.abs(Integer.parseInt(this.getCode()) - Integer.parseInt(e.getCode())) / (this.size - 1); + public double compareRateTo(DrinkType e) { + return 1 - (double) Math.abs(Integer.parseInt(this.getCode()) - Integer.parseInt(e.getCode())) / (this.size - 1); } } diff --git a/src/main/java/org/gachon/checkmate/domain/checkList/entity/EarPhoneType.java b/src/main/java/org/gachon/checkmate/domain/checkList/entity/EarPhoneType.java new file mode 100644 index 0000000..aaa29d5 --- /dev/null +++ b/src/main/java/org/gachon/checkmate/domain/checkList/entity/EarPhoneType.java @@ -0,0 +1,20 @@ +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 EarPhoneType implements EnumField { + NEED("1", "이어폰 필수"), + NOT_NEED("2", "상관없음"); + + private final String code; + private final String desc; + + public int compareRateTo(EarPhoneType e) { + return this.equals(e) ? 1 : 0; + } +} diff --git a/src/main/java/org/gachon/checkmate/domain/checkList/entity/HomeType.java b/src/main/java/org/gachon/checkmate/domain/checkList/entity/HomeType.java index 408b315..42e1558 100644 --- a/src/main/java/org/gachon/checkmate/domain/checkList/entity/HomeType.java +++ b/src/main/java/org/gachon/checkmate/domain/checkList/entity/HomeType.java @@ -17,7 +17,7 @@ public enum HomeType implements EnumField { private final String desc; private final int size = 4; - public int compareRateTo(HomeType e) { - return 1 - Math.abs(Integer.parseInt(this.getCode()) - Integer.parseInt(e.getCode())) / (this.size - 1); + public double compareRateTo(HomeType e) { + return 1 - (double) Math.abs(Integer.parseInt(this.getCode()) - Integer.parseInt(e.getCode())) / (this.size - 1); } } 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 c9584c4..71225eb 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 @@ -25,8 +25,10 @@ public class PostCheckList extends BaseTimeEntity { private HomeType homeType; @Convert(converter = LifePatternTypeConverter.class) private LifePatternType lifePatternType; - @Convert(converter = NoiseTypeConverter.class) - private NoiseType noiseType; + @Convert(converter = CallTypeConverter.class) + private CallType callType; + @Convert(converter = EarPhoneTypeConverter.class) + private EarPhoneType earPhoneType; @Convert(converter = SleepGridingTypeConverter.class) private SleepGridingType sleepGridingType; @Convert(converter = SleepSnoreTypeConverter.class) @@ -47,7 +49,8 @@ public static PostCheckList createPostCheckList(CheckListRequestDto checkListReq .drinkType(checkListRequestDto.drinkType()) .homeType(checkListRequestDto.homeType()) .lifePatternType(checkListRequestDto.lifePatternType()) - .noiseType(checkListRequestDto.noiseType()) + .callType(checkListRequestDto.callType()) + .earPhoneType(checkListRequestDto.earPhoneType()) .sleepGridingType(checkListRequestDto.sleepGridingType()) .sleepSnoreType(checkListRequestDto.sleepSnoreType()) .sleepTalkingType(checkListRequestDto.sleepTalkingType()) @@ -64,7 +67,8 @@ public void updatePostCheckList(CheckListRequestDto checkListRequestDto) { this.drinkType = checkListRequestDto.drinkType(); this.homeType = checkListRequestDto.homeType(); this.lifePatternType = checkListRequestDto.lifePatternType(); - this.noiseType = checkListRequestDto.noiseType(); + this.callType = checkListRequestDto.callType(); + this.earPhoneType = checkListRequestDto.earPhoneType(); this.sleepGridingType = checkListRequestDto.sleepGridingType(); this.sleepSnoreType = checkListRequestDto.sleepSnoreType(); this.sleepTalkingType = checkListRequestDto.sleepTalkingType(); diff --git a/src/main/java/org/gachon/checkmate/domain/checkList/utils/MatchRateCalculator.java b/src/main/java/org/gachon/checkmate/domain/checkList/utils/MatchRateCalculator.java index fd061da..2982197 100644 --- a/src/main/java/org/gachon/checkmate/domain/checkList/utils/MatchRateCalculator.java +++ b/src/main/java/org/gachon/checkmate/domain/checkList/utils/MatchRateCalculator.java @@ -5,18 +5,19 @@ public class MatchRateCalculator { public static int getAccuracy(PostCheckList postCheckList, CheckList checkList) { - int count = 0; + double count = 0; count += postCheckList.getCleanType().compareRateTo(checkList.getCleanType()); count += postCheckList.getDrinkType().compareRateTo(checkList.getDrinkType()); count += postCheckList.getHomeType().compareRateTo(checkList.getHomeType()); count += postCheckList.getLifePatternType().compareRateTo(checkList.getLifePatternType()); - count += postCheckList.getNoiseType().compareRateTo(checkList.getNoiseType()); + count += postCheckList.getCallType().compareRateTo(checkList.getCallType()); + count += postCheckList.getEarPhoneType().compareRateTo(checkList.getEarPhoneType()); count += postCheckList.getSleepGridingType().compareRateTo(checkList.getSleepGridingType()); count += postCheckList.getSleepSnoreType().compareRateTo(checkList.getSleepSnoreType()); count += postCheckList.getSleepTalkingType().compareRateTo(checkList.getSleepTalkingType()); count += postCheckList.getSleepTurningType().compareRateTo(checkList.getSleepTurningType()); count += postCheckList.getSmokeType().compareRateTo(checkList.getSmokeType()); - return (int) (count / 10) * 100; + return (int) (count * 100) / 11; } } diff --git a/src/main/java/org/gachon/checkmate/domain/post/utils/PostSortType.java b/src/main/java/org/gachon/checkmate/domain/post/utils/PostSortType.java index 5e096c2..43546b3 100644 --- a/src/main/java/org/gachon/checkmate/domain/post/utils/PostSortType.java +++ b/src/main/java/org/gachon/checkmate/domain/post/utils/PostSortType.java @@ -8,8 +8,8 @@ @AllArgsConstructor(access = AccessLevel.PRIVATE) @Getter public enum PostSortType implements EnumField { - ACCURACY("1", "accuracy"), - REGISTER("2", "register"), + REGISTER("1", "register"), + ACCURACY("2", "accuracy"), REMAIN_DATE("3", "remain date"), SCRAP("4", "scrap");