From 17c56b73afb9f46a636cdbc7bc6fd18ea6a33731 Mon Sep 17 00:00:00 2001 From: RyuKwanKon Date: Sun, 14 Jan 2024 01:47:23 +0900 Subject: [PATCH] =?UTF-8?q?[fix]=20#43=20=EC=9E=A0=EC=9E=90=EB=A6=AC=20?= =?UTF-8?q?=EC=9C=A0=ED=98=95=20=EC=A4=91=EB=B3=B5=20enum=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/CheckListRequestDto.java | 5 ++- .../dto/response/CheckListResponseDto.java | 37 ++++++++++--------- .../domain/checkList/entity/CheckList.java | 22 ++++++++--- .../checkList/entity/PostCheckList.java | 20 ++++++++-- .../checkList/service/CheckListService.java | 8 +--- 5 files changed, 58 insertions(+), 34 deletions(-) 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 9426ff7..1461b01 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 @@ -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 ) { 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 ec4d058..bf26a14 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 @@ -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( @@ -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(); } @@ -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(); } 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 78f152e..cde2799 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 @@ -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(); @@ -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(); } } 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 e23efc2..c9584c4 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 @@ -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) @@ -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(); @@ -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(); } } 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 6001099..6883ad9 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 @@ -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) {