Skip to content

Commit

Permalink
Merge pull request #54 from Domitory-CheckMate/feature/53-post
Browse files Browse the repository at this point in the history
[fix]  정렬기준 default 값 변경
  • Loading branch information
RyuKwanKon authored Jan 19, 2024
2 parents b9e926f + 4a3f72a commit a62f2ae
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 41 deletions.
Original file line number Diff line number Diff line change
@@ -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<CallType> {
public CallTypeConverter() {
super(CallType.class);
}
}
Original file line number Diff line number Diff line change
@@ -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<EarPhoneType> {
public EarPhoneTypeConverter() {
super(EarPhoneType.class);
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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())
Expand All @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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())
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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())
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down

0 comments on commit a62f2ae

Please sign in to comment.