Skip to content

Commit

Permalink
[fix] #43 잠자리 유형 중복 enum 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
RyuKwanKon committed Jan 13, 2024
1 parent 455f954 commit 17c56b7
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ public record CheckListRequestDto(
HomeType homeType,
LifePatternType lifePatternType,
NoiseType noiseType,
SleepType sleepType,
SleepGridingType sleepGridingType,
SleepSnoreType sleepSnoreType,
SleepTalkingType sleepTalkingType,
SleepTurningType sleepTurningType,
SmokeType smokeType

) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.gachon.checkmate.domain.checkList.dto.response;

import lombok.Builder;
import org.gachon.checkmate.domain.checkList.entity.PostCheckList;
import org.gachon.checkmate.domain.checkList.entity.*;

@Builder
public record CheckListResponseDto(
Expand All @@ -10,24 +10,24 @@ public record CheckListResponseDto(
String homeType,
String lifePatterType,
String noiseType,
String sleepType,
String sleepGridingType,
String sleepSnoreType,
String sleepTalkingType,
String sleepTurningType,
String smokeType
) {
public static CheckListResponseDto of(String cleanType,
String drinkType,
String homeType,
String lifePatterType,
String noiseType,
String sleepType,
String smokeType) {
public static CheckListResponseDto of(CheckList checkList) {
return CheckListResponseDto.builder()
.cleanType(cleanType)
.drinkType(drinkType)
.homeType(homeType)
.lifePatterType(lifePatterType)
.noiseType(noiseType)
.sleepType(sleepType)
.smokeType(smokeType)
.cleanType(checkList.getCleanType().getDesc())
.drinkType(checkList.getDrinkType().getDesc())
.homeType(checkList.getHomeType().getDesc())
.lifePatterType(checkList.getLifePatternType().getDesc())
.noiseType(checkList.getNoiseType().getDesc())
.sleepGridingType(checkList.getSleepGridingType().getDesc())
.sleepSnoreType(checkList.getSleepSnoreType().getDesc())
.sleepTalkingType(checkList.getSleepTalkingType().getDesc())
.sleepTurningType(checkList.getSleepTurningType().getDesc())
.smokeType(checkList.getSmokeType().getDesc())
.build();
}

Expand All @@ -38,7 +38,10 @@ public static CheckListResponseDto ofPostCheckList(PostCheckList checkList) {
.homeType(checkList.getHomeType().getDesc())
.lifePatterType(checkList.getLifePatternType().getDesc())
.noiseType(checkList.getNoiseType().getDesc())
.sleepType(checkList.getSleepType().getDesc())
.sleepGridingType(checkList.getSleepGridingType().getDesc())
.sleepSnoreType(checkList.getSleepSnoreType().getDesc())
.sleepTalkingType(checkList.getSleepTalkingType().getDesc())
.sleepTurningType(checkList.getSleepTurningType().getDesc())
.smokeType(checkList.getSmokeType().getDesc())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,31 @@ public class CheckList extends BaseTimeEntity {
private LifePatternType lifePatternType;
@Convert(converter = NoiseTypeConverter.class)
private NoiseType noiseType;
@Convert(converter = SleepTypeConverter.class)
private SleepType sleepType;
@Convert(converter = SleepGridingTypeConverter.class)
private SleepGridingType sleepGridingType;
@Convert(converter = SleepSnoreTypeConverter.class)
private SleepSnoreType sleepSnoreType;
@Convert(converter = SleepTalkingTypeConverter.class)
private SleepTalkingType sleepTalkingType;
@Convert(converter = SleepTurningTypeConverter.class)
private SleepTurningType sleepTurningType;
@Convert(converter = SmokeTypeConverter.class)
private SmokeType smokeType;
@OneToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "user_id")
private User user;

public static CheckList createCheckList(User user, CheckListRequestDto checkListRequestDto){
public static CheckList createCheckList(User user, CheckListRequestDto checkListRequestDto) {
CheckList checkList = CheckList.builder()
.cleanType(checkListRequestDto.cleanType())
.drinkType(checkListRequestDto.drinkType())
.homeType(checkListRequestDto.homeType())
.lifePatternType(checkListRequestDto.lifePatternType())
.noiseType(checkListRequestDto.noiseType())
.sleepType(checkListRequestDto.sleepType())
.sleepGridingType(checkListRequestDto.sleepGridingType())
.sleepSnoreType(checkListRequestDto.sleepSnoreType())
.sleepTalkingType(checkListRequestDto.sleepTalkingType())
.sleepTurningType(checkListRequestDto.sleepTurningType())
.smokeType(checkListRequestDto.smokeType())
.user(user)
.build();
Expand All @@ -56,7 +65,10 @@ public void updateCheckList(CheckListRequestDto checkListRequestDto) {
this.homeType = checkListRequestDto.homeType();
this.lifePatternType = checkListRequestDto.lifePatternType();
this.noiseType = checkListRequestDto.noiseType();
this.sleepType = checkListRequestDto.sleepType();
this.sleepGridingType = checkListRequestDto.sleepGridingType();
this.sleepSnoreType = checkListRequestDto.sleepSnoreType();
this.sleepTalkingType = checkListRequestDto.sleepTalkingType();
this.sleepTurningType = checkListRequestDto.sleepTurningType();
this.smokeType = checkListRequestDto.smokeType();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ public class PostCheckList extends BaseTimeEntity {
private LifePatternType lifePatternType;
@Convert(converter = NoiseTypeConverter.class)
private NoiseType noiseType;
@Convert(converter = SleepTypeConverter.class)
private SleepType sleepType;
@Convert(converter = SleepGridingTypeConverter.class)
private SleepGridingType sleepGridingType;
@Convert(converter = SleepSnoreTypeConverter.class)
private SleepSnoreType sleepSnoreType;
@Convert(converter = SleepTalkingTypeConverter.class)
private SleepTalkingType sleepTalkingType;
@Convert(converter = SleepTurningTypeConverter.class)
private SleepTurningType sleepTurningType;
@Convert(converter = SmokeTypeConverter.class)
private SmokeType smokeType;
@OneToOne(fetch = FetchType.LAZY)
Expand All @@ -42,7 +48,10 @@ public static PostCheckList createPostCheckList(CheckListRequestDto checkListReq
.homeType(checkListRequestDto.homeType())
.lifePatternType(checkListRequestDto.lifePatternType())
.noiseType(checkListRequestDto.noiseType())
.sleepType(checkListRequestDto.sleepType())
.sleepGridingType(checkListRequestDto.sleepGridingType())
.sleepSnoreType(checkListRequestDto.sleepSnoreType())
.sleepTalkingType(checkListRequestDto.sleepTalkingType())
.sleepTurningType(checkListRequestDto.sleepTurningType())
.smokeType(checkListRequestDto.smokeType())
.post(post)
.build();
Expand All @@ -56,7 +65,10 @@ public void updatePostCheckList(CheckListRequestDto checkListRequestDto) {
this.homeType = checkListRequestDto.homeType();
this.lifePatternType = checkListRequestDto.lifePatternType();
this.noiseType = checkListRequestDto.noiseType();
this.sleepType = checkListRequestDto.sleepType();
this.sleepGridingType = checkListRequestDto.sleepGridingType();
this.sleepSnoreType = checkListRequestDto.sleepSnoreType();
this.sleepTalkingType = checkListRequestDto.sleepTalkingType();
this.sleepTurningType = checkListRequestDto.sleepTurningType();
this.smokeType = checkListRequestDto.smokeType();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,7 @@ public void updateCheckList(Long userId, CheckListRequestDto checkListRequestDto
public CheckListResponseDto getCheckList(Long userId) {
User user = findByIdOrThrow(userId);
CheckList checkList = user.getCheckList();
return CheckListResponseDto.of(checkList.getCleanType().getDesc(),
checkList.getDrinkType().getDesc(),
checkList.getHomeType().getDesc(),
checkList.getLifePatternType().getDesc(),
checkList.getNoiseType().getDesc(),
checkList.getSleepType().getDesc(),
checkList.getSmokeType().getDesc());
return CheckListResponseDto.of(checkList);
}

private User findByIdOrThrow(Long userId) {
Expand Down

0 comments on commit 17c56b7

Please sign in to comment.