From f639edb84c281af7eaffc4f1eede1de916eb5944 Mon Sep 17 00:00:00 2001 From: jun02160 Date: Tue, 2 Jan 2024 01:58:19 +0900 Subject: [PATCH 1/7] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20fix:=20Error=20->=20Ex?= =?UTF-8?q?ception=EC=9C=BC=EB=A1=9C=20=EB=B3=80=EA=B2=BD=20#6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/mission/exception/MissionException.java | 6 +++--- .../domain/user/exception/UserException.java | 6 +++--- .../motivooServer/global/advice/BusinessException.java | 10 +++++----- .../global/advice/BusinessExceptionType.java | 4 ++++ .../org/motivooServer/global/advice/ErrorResponse.java | 6 +++--- .../global/advice/GlobalExceptionHandler.java | 6 +++--- 6 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/main/java/sopt/org/motivooServer/domain/mission/exception/MissionException.java b/src/main/java/sopt/org/motivooServer/domain/mission/exception/MissionException.java index 6ca0f1ed..d4b5dda7 100644 --- a/src/main/java/sopt/org/motivooServer/domain/mission/exception/MissionException.java +++ b/src/main/java/sopt/org/motivooServer/domain/mission/exception/MissionException.java @@ -1,11 +1,11 @@ package sopt.org.motivooServer.domain.mission.exception; -import sopt.org.motivooServer.global.advice.ErrorType; import sopt.org.motivooServer.global.advice.BusinessException; +import sopt.org.motivooServer.global.advice.BusinessExceptionType; public class MissionException extends BusinessException { - public MissionException(ErrorType errorType) { - super(errorType); + public MissionException(BusinessExceptionType exceptionType) { + super(exceptionType); } } diff --git a/src/main/java/sopt/org/motivooServer/domain/user/exception/UserException.java b/src/main/java/sopt/org/motivooServer/domain/user/exception/UserException.java index 94b9e1d0..56932196 100644 --- a/src/main/java/sopt/org/motivooServer/domain/user/exception/UserException.java +++ b/src/main/java/sopt/org/motivooServer/domain/user/exception/UserException.java @@ -1,11 +1,11 @@ package sopt.org.motivooServer.domain.user.exception; -import sopt.org.motivooServer.global.advice.ErrorType; import sopt.org.motivooServer.global.advice.BusinessException; +import sopt.org.motivooServer.global.advice.BusinessExceptionType; public class UserException extends BusinessException { - public UserException(ErrorType errorType) { - super(errorType); + public UserException(BusinessExceptionType exceptionType) { + super(exceptionType); } } diff --git a/src/main/java/sopt/org/motivooServer/global/advice/BusinessException.java b/src/main/java/sopt/org/motivooServer/global/advice/BusinessException.java index 1fdb8c0f..e9b2e354 100644 --- a/src/main/java/sopt/org/motivooServer/global/advice/BusinessException.java +++ b/src/main/java/sopt/org/motivooServer/global/advice/BusinessException.java @@ -5,14 +5,14 @@ @Getter public class BusinessException extends RuntimeException { - private final ErrorType errorType; + private final BusinessExceptionType exceptionType; - public BusinessException(ErrorType errorType) { - super(errorType.getMessage()); - this.errorType = errorType; + public BusinessException(BusinessExceptionType exceptionType) { + super(exceptionType.message()); + this.exceptionType = exceptionType; } public int getHttpStatus() { - return errorType.getHttpStatusCode(); + return exceptionType.status().value(); } } \ No newline at end of file diff --git a/src/main/java/sopt/org/motivooServer/global/advice/BusinessExceptionType.java b/src/main/java/sopt/org/motivooServer/global/advice/BusinessExceptionType.java index 4b39d50a..2017bfc4 100644 --- a/src/main/java/sopt/org/motivooServer/global/advice/BusinessExceptionType.java +++ b/src/main/java/sopt/org/motivooServer/global/advice/BusinessExceptionType.java @@ -5,4 +5,8 @@ public interface BusinessExceptionType { HttpStatus status(); String message(); + + default int getHttpStatusCode() { + return status().value(); + } } diff --git a/src/main/java/sopt/org/motivooServer/global/advice/ErrorResponse.java b/src/main/java/sopt/org/motivooServer/global/advice/ErrorResponse.java index 8e0f7095..d838d7ff 100644 --- a/src/main/java/sopt/org/motivooServer/global/advice/ErrorResponse.java +++ b/src/main/java/sopt/org/motivooServer/global/advice/ErrorResponse.java @@ -14,10 +14,10 @@ public static ErrorResponse of(ErrorType errorType) { ); } - public static ErrorResponse of(ErrorType errorType, String message) { + public static ErrorResponse of(BusinessExceptionType exceptionType) { return new ErrorResponse( - errorType.getHttpStatusCode(), - message, + exceptionType.getHttpStatusCode(), + exceptionType.message(), false ); } diff --git a/src/main/java/sopt/org/motivooServer/global/advice/GlobalExceptionHandler.java b/src/main/java/sopt/org/motivooServer/global/advice/GlobalExceptionHandler.java index 8d6ff11c..e327b330 100644 --- a/src/main/java/sopt/org/motivooServer/global/advice/GlobalExceptionHandler.java +++ b/src/main/java/sopt/org/motivooServer/global/advice/GlobalExceptionHandler.java @@ -24,11 +24,11 @@ public class GlobalExceptionHandler { * Custom Error */ @ExceptionHandler(BusinessException.class) - public ResponseEntity handleCustomException(final BusinessException e) { + public ResponseEntity handleBusinessException(final BusinessException e) { - log.error("🚨🚨🚨 CustomException occured: {} 🚨🚨🚨", e.getMessage()); + log.error("🚨🚨🚨 BusinessException occured: {} 🚨🚨🚨", e.getMessage()); return ResponseEntity.status(e.getHttpStatus()) - .body(ErrorResponse.of(e.getErrorType(), e.getMessage())); + .body(ErrorResponse.of(e.getExceptionType())); } } From 03a91408050a332d0d1a7737ae8d40296ca9a521 Mon Sep 17 00:00:00 2001 From: jun02160 Date: Tue, 2 Jan 2024 02:26:27 +0900 Subject: [PATCH 2/7] =?UTF-8?q?=E2=9C=A8=20feat:=20User=20=EC=97=94?= =?UTF-8?q?=ED=8B=B0=ED=8B=B0=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80=20#6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/user/entity/User.java | 52 +++++++++++++++++++ .../domain/user/entity/UserType.java | 27 ++++++++++ .../user/exception/UserExceptionType.java | 10 +++- 3 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 src/main/java/sopt/org/motivooServer/domain/user/entity/User.java create mode 100644 src/main/java/sopt/org/motivooServer/domain/user/entity/UserType.java diff --git a/src/main/java/sopt/org/motivooServer/domain/user/entity/User.java b/src/main/java/sopt/org/motivooServer/domain/user/entity/User.java new file mode 100644 index 00000000..b434684a --- /dev/null +++ b/src/main/java/sopt/org/motivooServer/domain/user/entity/User.java @@ -0,0 +1,52 @@ +package sopt.org.motivooServer.domain.user.entity; + +import org.hibernate.annotations.SQLDelete; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; +import sopt.org.motivooServer.domain.common.BaseTimeEntity; +import sopt.org.motivooServer.domain.parentchild.Parentchild; + +@Entity +@Table(name = "`user`") +@SQLDelete(sql = "UPDATE user SET user.deleted=true WHERE user_id=?") +public class User extends BaseTimeEntity { + + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "user_id") + private Long id; + + private String username; + + private Integer age; + + @Enumerated(EnumType.STRING) + @Column(nullable = false) + private UserType userType; + + @Column(nullable = false) + private Boolean deleted = Boolean.FALSE; + + @ManyToOne + @JoinColumn(name = "parentchild_id") + private Parentchild parentchild; + + @Column(nullable = false) + private Long socialId; + + private String socialNickname; + + private String socialAccessToken; + + @Enumerated(EnumType.STRING) + @Column(nullable = false) + private SocialPlatform socialPlatform; +} diff --git a/src/main/java/sopt/org/motivooServer/domain/user/entity/UserType.java b/src/main/java/sopt/org/motivooServer/domain/user/entity/UserType.java new file mode 100644 index 00000000..324e5e01 --- /dev/null +++ b/src/main/java/sopt/org/motivooServer/domain/user/entity/UserType.java @@ -0,0 +1,27 @@ +package sopt.org.motivooServer.domain.user.entity; + +import static sopt.org.motivooServer.domain.user.exception.UserExceptionType.*; + +import java.util.Arrays; + +import lombok.AccessLevel; +import lombok.RequiredArgsConstructor; +import sopt.org.motivooServer.domain.user.exception.UserException; + +@RequiredArgsConstructor(access = AccessLevel.PRIVATE) +public enum UserType { + + PARENT("λΆ€λͺ¨"), + CHILD("μžλ…€"), + NONE("μ—†μŒ") + ; + + private final String value; + + public static UserType of(String value) { + return Arrays.stream(UserType.values()) + .filter(userType -> value.equals(userType.value)) + .findFirst() + .orElseThrow(() -> new UserException(INVALID_USER_TYPE)); + } +} diff --git a/src/main/java/sopt/org/motivooServer/domain/user/exception/UserExceptionType.java b/src/main/java/sopt/org/motivooServer/domain/user/exception/UserExceptionType.java index f5278c85..f9420db0 100644 --- a/src/main/java/sopt/org/motivooServer/domain/user/exception/UserExceptionType.java +++ b/src/main/java/sopt/org/motivooServer/domain/user/exception/UserExceptionType.java @@ -3,14 +3,20 @@ import org.springframework.http.HttpStatus; import lombok.AccessLevel; -import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.RequiredArgsConstructor; import sopt.org.motivooServer.global.advice.BusinessExceptionType; @Getter -@AllArgsConstructor(access = AccessLevel.PRIVATE) +@RequiredArgsConstructor(access = AccessLevel.PRIVATE) public enum UserExceptionType implements BusinessExceptionType { + /** + * 400 Bad Request + */ + INVALID_USER_TYPE(HttpStatus.BAD_REQUEST, "μœ νš¨ν•˜μ§€ μ•Šμ€ νšŒμ› μœ ν˜•μž…λ‹ˆλ‹€."), + INVALID_SOCIAL_PLATFORM(HttpStatus.BAD_REQUEST, "μœ νš¨ν•˜μ§€ μ•Šμ€ μ†Œμ…œ ν”Œλž«νΌμž…λ‹ˆλ‹€."), + /** * 404 Not Found */ From 5a671f5f31ec632eed6f4e28b4c0cc53c3a6df75 Mon Sep 17 00:00:00 2001 From: jun02160 Date: Tue, 2 Jan 2024 02:27:04 +0900 Subject: [PATCH 3/7] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20fix:=20@RequiredArgsCo?= =?UTF-8?q?nstructor=EB=A1=9C=20=EC=83=9D=EC=84=B1=EC=9E=90=20=EC=96=B4?= =?UTF-8?q?=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=20=EB=B3=80=EA=B2=BD=20#6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/mission/exception/MissionExceptionType.java | 4 ++-- .../java/sopt/org/motivooServer/global/advice/ErrorType.java | 4 ++-- .../sopt/org/motivooServer/global/response/ApiResponse.java | 1 - .../sopt/org/motivooServer/global/response/SuccessType.java | 4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/sopt/org/motivooServer/domain/mission/exception/MissionExceptionType.java b/src/main/java/sopt/org/motivooServer/domain/mission/exception/MissionExceptionType.java index 56b2c7d0..c385ccb3 100644 --- a/src/main/java/sopt/org/motivooServer/domain/mission/exception/MissionExceptionType.java +++ b/src/main/java/sopt/org/motivooServer/domain/mission/exception/MissionExceptionType.java @@ -3,12 +3,12 @@ import org.springframework.http.HttpStatus; import lombok.AccessLevel; -import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.RequiredArgsConstructor; import sopt.org.motivooServer.global.advice.BusinessExceptionType; @Getter -@AllArgsConstructor(access = AccessLevel.PRIVATE) +@RequiredArgsConstructor(access = AccessLevel.PRIVATE) public enum MissionExceptionType implements BusinessExceptionType { /** diff --git a/src/main/java/sopt/org/motivooServer/global/advice/ErrorType.java b/src/main/java/sopt/org/motivooServer/global/advice/ErrorType.java index 097d5e45..aa62397e 100644 --- a/src/main/java/sopt/org/motivooServer/global/advice/ErrorType.java +++ b/src/main/java/sopt/org/motivooServer/global/advice/ErrorType.java @@ -3,11 +3,11 @@ import org.springframework.http.HttpStatus; import lombok.AccessLevel; -import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.RequiredArgsConstructor; @Getter -@AllArgsConstructor(access = AccessLevel.PRIVATE) +@RequiredArgsConstructor(access = AccessLevel.PRIVATE) public enum ErrorType { /** diff --git a/src/main/java/sopt/org/motivooServer/global/response/ApiResponse.java b/src/main/java/sopt/org/motivooServer/global/response/ApiResponse.java index 552ae6d2..5f13f273 100644 --- a/src/main/java/sopt/org/motivooServer/global/response/ApiResponse.java +++ b/src/main/java/sopt/org/motivooServer/global/response/ApiResponse.java @@ -14,7 +14,6 @@ @Getter @Builder @RequiredArgsConstructor(access = AccessLevel.PRIVATE) -@AllArgsConstructor(access = AccessLevel.PRIVATE) @JsonPropertyOrder({"code", "message", "success", "data"}) public class ApiResponse { diff --git a/src/main/java/sopt/org/motivooServer/global/response/SuccessType.java b/src/main/java/sopt/org/motivooServer/global/response/SuccessType.java index 39769482..20df00c2 100644 --- a/src/main/java/sopt/org/motivooServer/global/response/SuccessType.java +++ b/src/main/java/sopt/org/motivooServer/global/response/SuccessType.java @@ -3,11 +3,11 @@ import org.springframework.http.HttpStatus; import lombok.AccessLevel; -import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.RequiredArgsConstructor; @Getter -@AllArgsConstructor(access = AccessLevel.PRIVATE) +@RequiredArgsConstructor(access = AccessLevel.PRIVATE) public enum SuccessType { /** From e1d4b56549f29be6835c1f211520ab7e3da3884e Mon Sep 17 00:00:00 2001 From: jun02160 Date: Tue, 2 Jan 2024 02:37:46 +0900 Subject: [PATCH 4/7] =?UTF-8?q?=E2=9C=A8=20feat:=20Health,=20Parentchild?= =?UTF-8?q?=20=EC=97=94=ED=8B=B0=ED=8B=B0=20=EC=B6=94=EA=B0=80=20#6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/common/BaseTimeEntity.java | 23 ++++++++++ .../domain/health/ExerciseFrequency.java | 6 +++ .../domain/health/ExerciseTime.java | 6 +++ .../domain/health/ExerciseType.java | 6 +++ .../motivooServer/domain/health/Health.java | 46 +++++++++++++++++++ .../domain/health/HealthNote.java | 29 ++++++++++++ .../health/exception/HealthException.java | 11 +++++ .../health/exception/HealthExceptionType.java | 37 +++++++++++++++ .../exception/MissionExceptionType.java | 2 - .../domain/parentchild/Parentchild.java | 22 +++++++++ .../domain/user/entity/SocialPlatform.java | 25 ++++++++++ .../user/exception/UserExceptionType.java | 2 - 12 files changed, 211 insertions(+), 4 deletions(-) create mode 100644 src/main/java/sopt/org/motivooServer/domain/common/BaseTimeEntity.java create mode 100644 src/main/java/sopt/org/motivooServer/domain/health/ExerciseFrequency.java create mode 100644 src/main/java/sopt/org/motivooServer/domain/health/ExerciseTime.java create mode 100644 src/main/java/sopt/org/motivooServer/domain/health/ExerciseType.java create mode 100644 src/main/java/sopt/org/motivooServer/domain/health/Health.java create mode 100644 src/main/java/sopt/org/motivooServer/domain/health/HealthNote.java create mode 100644 src/main/java/sopt/org/motivooServer/domain/health/exception/HealthException.java create mode 100644 src/main/java/sopt/org/motivooServer/domain/health/exception/HealthExceptionType.java create mode 100644 src/main/java/sopt/org/motivooServer/domain/parentchild/Parentchild.java create mode 100644 src/main/java/sopt/org/motivooServer/domain/user/entity/SocialPlatform.java diff --git a/src/main/java/sopt/org/motivooServer/domain/common/BaseTimeEntity.java b/src/main/java/sopt/org/motivooServer/domain/common/BaseTimeEntity.java new file mode 100644 index 00000000..84672e2e --- /dev/null +++ b/src/main/java/sopt/org/motivooServer/domain/common/BaseTimeEntity.java @@ -0,0 +1,23 @@ +package sopt.org.motivooServer.domain.common; + +import java.time.LocalDateTime; + +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import jakarta.persistence.EntityListeners; +import jakarta.persistence.MappedSuperclass; +import lombok.Getter; + +@Getter +@MappedSuperclass +@EntityListeners(AuditingEntityListener.class) +public abstract class BaseTimeEntity { + + @CreatedDate + private LocalDateTime createdAt; + + @LastModifiedDate + private LocalDateTime updatedAt; +} diff --git a/src/main/java/sopt/org/motivooServer/domain/health/ExerciseFrequency.java b/src/main/java/sopt/org/motivooServer/domain/health/ExerciseFrequency.java new file mode 100644 index 00000000..5e96d014 --- /dev/null +++ b/src/main/java/sopt/org/motivooServer/domain/health/ExerciseFrequency.java @@ -0,0 +1,6 @@ +package sopt.org.motivooServer.domain.health; + +public enum ExerciseFrequency { + + // 1회 미만 | 1~2회 | 3~4회 | 5회 이상 +} diff --git a/src/main/java/sopt/org/motivooServer/domain/health/ExerciseTime.java b/src/main/java/sopt/org/motivooServer/domain/health/ExerciseTime.java new file mode 100644 index 00000000..c3754a5e --- /dev/null +++ b/src/main/java/sopt/org/motivooServer/domain/health/ExerciseTime.java @@ -0,0 +1,6 @@ +package sopt.org.motivooServer.domain.health; + +public enum ExerciseTime { + + // 30λΆ„ 미만 | 30λΆ„~1μ‹œκ°„ | 1μ‹œκ°„~2μ‹œκ°„ | 2μ‹œκ°„ 이상 +} diff --git a/src/main/java/sopt/org/motivooServer/domain/health/ExerciseType.java b/src/main/java/sopt/org/motivooServer/domain/health/ExerciseType.java new file mode 100644 index 00000000..16de7aa5 --- /dev/null +++ b/src/main/java/sopt/org/motivooServer/domain/health/ExerciseType.java @@ -0,0 +1,6 @@ +package sopt.org.motivooServer.domain.health; + +public enum ExerciseType { + + // 고강도 | 쀑강도 | 저강도 +} diff --git a/src/main/java/sopt/org/motivooServer/domain/health/Health.java b/src/main/java/sopt/org/motivooServer/domain/health/Health.java new file mode 100644 index 00000000..6d880961 --- /dev/null +++ b/src/main/java/sopt/org/motivooServer/domain/health/Health.java @@ -0,0 +1,46 @@ +package sopt.org.motivooServer.domain.health; + +import java.util.ArrayList; +import java.util.List; + +import jakarta.persistence.Column; +import jakarta.persistence.ElementCollection; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToOne; +import sopt.org.motivooServer.domain.common.BaseTimeEntity; +import sopt.org.motivooServer.domain.user.entity.User; + +@Entity +public class Health extends BaseTimeEntity { + + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "health_id") + private Long id; + + @OneToOne + @JoinColumn(name = "user_id") + private User user; + + @Enumerated(EnumType.STRING) + @Column(nullable = false) + private ExerciseType exerciseType; + + @Enumerated(EnumType.STRING) + @Column(nullable = false) + private ExerciseFrequency exerciseFrequency; + + @Enumerated(EnumType.STRING) + @Column(nullable = false) + private ExerciseTime exerciseTime; + + @Enumerated(EnumType.STRING) + @Column(nullable = false) + @ElementCollection + private List healthNotes = new ArrayList<>(); +} diff --git a/src/main/java/sopt/org/motivooServer/domain/health/HealthNote.java b/src/main/java/sopt/org/motivooServer/domain/health/HealthNote.java new file mode 100644 index 00000000..92a8cd74 --- /dev/null +++ b/src/main/java/sopt/org/motivooServer/domain/health/HealthNote.java @@ -0,0 +1,29 @@ +package sopt.org.motivooServer.domain.health; + +import static sopt.org.motivooServer.domain.health.exception.HealthExceptionType.*; + +import java.util.Arrays; + +import lombok.AccessLevel; +import lombok.RequiredArgsConstructor; +import sopt.org.motivooServer.domain.health.exception.HealthException; + +@RequiredArgsConstructor(access = AccessLevel.PRIVATE) +public enum HealthNote { + + WAIST("ν—ˆλ¦¬"), + KNEE("무릎"), + NECK("λͺ©"), + WRIST("손λͺ©"), + SHOULDER("μ–΄κΉ¨"), + ANKLE("발λͺ©"); + + private final String value; + + public static HealthNote of(String value) { + return Arrays.stream(HealthNote.values()) + .filter(healthNote -> value.equals(healthNote.value)) + .findFirst() + .orElseThrow(() -> new HealthException(INVALID_HEALTH_NOTE)); + } +} diff --git a/src/main/java/sopt/org/motivooServer/domain/health/exception/HealthException.java b/src/main/java/sopt/org/motivooServer/domain/health/exception/HealthException.java new file mode 100644 index 00000000..9395a443 --- /dev/null +++ b/src/main/java/sopt/org/motivooServer/domain/health/exception/HealthException.java @@ -0,0 +1,11 @@ +package sopt.org.motivooServer.domain.health.exception; + +import sopt.org.motivooServer.global.advice.BusinessException; +import sopt.org.motivooServer.global.advice.BusinessExceptionType; + +public class HealthException extends BusinessException { + + public HealthException(BusinessExceptionType exceptionType) { + super(exceptionType); + } +} diff --git a/src/main/java/sopt/org/motivooServer/domain/health/exception/HealthExceptionType.java b/src/main/java/sopt/org/motivooServer/domain/health/exception/HealthExceptionType.java new file mode 100644 index 00000000..dc320a6d --- /dev/null +++ b/src/main/java/sopt/org/motivooServer/domain/health/exception/HealthExceptionType.java @@ -0,0 +1,37 @@ +package sopt.org.motivooServer.domain.health.exception; + +import org.springframework.http.HttpStatus; + +import lombok.AccessLevel; +import lombok.RequiredArgsConstructor; +import sopt.org.motivooServer.global.advice.BusinessExceptionType; + +@RequiredArgsConstructor(access = AccessLevel.PRIVATE) +public enum HealthExceptionType implements BusinessExceptionType { + + /** + * 400 Bad Request + */ + INVALID_HEALTH_NOTE(HttpStatus.BAD_REQUEST, "μœ νš¨ν•˜μ§€ μ•ŠλŠ” 건강 μ£Όμ˜μ‚¬ν•­μž…λ‹ˆλ‹€."), + + /** + * 404 Not Found + */ + HEALTH_NOT_FOUND(HttpStatus.NOT_FOUND, "μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” κ±΄κ°•μ •λ³΄μž…λ‹ˆλ‹€.") + + + ; + + private final HttpStatus status; + private final String message; + + @Override + public HttpStatus status() { + return this.status; + } + + @Override + public String message() { + return this.message; + } +} diff --git a/src/main/java/sopt/org/motivooServer/domain/mission/exception/MissionExceptionType.java b/src/main/java/sopt/org/motivooServer/domain/mission/exception/MissionExceptionType.java index c385ccb3..3a279c28 100644 --- a/src/main/java/sopt/org/motivooServer/domain/mission/exception/MissionExceptionType.java +++ b/src/main/java/sopt/org/motivooServer/domain/mission/exception/MissionExceptionType.java @@ -3,11 +3,9 @@ import org.springframework.http.HttpStatus; import lombok.AccessLevel; -import lombok.Getter; import lombok.RequiredArgsConstructor; import sopt.org.motivooServer.global.advice.BusinessExceptionType; -@Getter @RequiredArgsConstructor(access = AccessLevel.PRIVATE) public enum MissionExceptionType implements BusinessExceptionType { diff --git a/src/main/java/sopt/org/motivooServer/domain/parentchild/Parentchild.java b/src/main/java/sopt/org/motivooServer/domain/parentchild/Parentchild.java new file mode 100644 index 00000000..0bbbb832 --- /dev/null +++ b/src/main/java/sopt/org/motivooServer/domain/parentchild/Parentchild.java @@ -0,0 +1,22 @@ +package sopt.org.motivooServer.domain.parentchild; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import sopt.org.motivooServer.domain.common.BaseTimeEntity; + +@Entity +public class Parentchild extends BaseTimeEntity { + + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "parentchild_id") + private Long id; + + @Column(nullable = false) + private Boolean isMatched; + + @Column(nullable = false) + private String inviteCode; +} diff --git a/src/main/java/sopt/org/motivooServer/domain/user/entity/SocialPlatform.java b/src/main/java/sopt/org/motivooServer/domain/user/entity/SocialPlatform.java new file mode 100644 index 00000000..a6f40b64 --- /dev/null +++ b/src/main/java/sopt/org/motivooServer/domain/user/entity/SocialPlatform.java @@ -0,0 +1,25 @@ +package sopt.org.motivooServer.domain.user.entity; + +import static sopt.org.motivooServer.domain.user.exception.UserExceptionType.*; + +import java.util.Arrays; + +import lombok.AccessLevel; +import lombok.RequiredArgsConstructor; +import sopt.org.motivooServer.domain.user.exception.UserException; + +@RequiredArgsConstructor(access = AccessLevel.PRIVATE) +public enum SocialPlatform { + + KAKAO("카카였"), + APPLE("μ• ν”Œ"); + + private final String value; + + public static SocialPlatform of(String value) { + return Arrays.stream(SocialPlatform.values()) + .filter(socialPlatform -> value.equals(socialPlatform.value)) + .findFirst() + .orElseThrow(() -> new UserException(INVALID_SOCIAL_PLATFORM)); + } +} diff --git a/src/main/java/sopt/org/motivooServer/domain/user/exception/UserExceptionType.java b/src/main/java/sopt/org/motivooServer/domain/user/exception/UserExceptionType.java index f9420db0..07255bf3 100644 --- a/src/main/java/sopt/org/motivooServer/domain/user/exception/UserExceptionType.java +++ b/src/main/java/sopt/org/motivooServer/domain/user/exception/UserExceptionType.java @@ -3,11 +3,9 @@ import org.springframework.http.HttpStatus; import lombok.AccessLevel; -import lombok.Getter; import lombok.RequiredArgsConstructor; import sopt.org.motivooServer.global.advice.BusinessExceptionType; -@Getter @RequiredArgsConstructor(access = AccessLevel.PRIVATE) public enum UserExceptionType implements BusinessExceptionType { From cd132d9b7097531f21c8cc718503695d7ca03a27 Mon Sep 17 00:00:00 2001 From: jun02160 Date: Tue, 2 Jan 2024 13:19:59 +0900 Subject: [PATCH 5/7] =?UTF-8?q?=E2=9C=A8=20feat:=20=EC=97=94=ED=8B=B0?= =?UTF-8?q?=ED=8B=B0=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?=EB=B0=8F=20=EC=97=B0=EA=B4=80=EA=B4=80=EA=B3=84=20=EB=A7=A4?= =?UTF-8?q?=ED=95=91=20#6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{ => entity}/ExerciseFrequency.java | 2 +- .../health/{ => entity}/ExerciseTime.java | 2 +- .../health/{ => entity}/ExerciseType.java | 2 +- .../domain/health/{ => entity}/Health.java | 2 +- .../health/{ => entity}/HealthNote.java | 2 +- .../mission/entity/CompletedStatus.java | 16 ++++++ .../domain/mission/entity/Mission.java | 29 +++++++++++ .../domain/mission/entity/MissionType.java | 10 ++++ .../domain/mission/entity/UserMission.java | 50 +++++++++++++++++++ .../parentchild/{ => entity}/Parentchild.java | 2 +- .../exception/ParentchildException.java | 11 ++++ .../exception/ParentchildExceptionType.java | 32 ++++++++++++ .../domain/step/entity/Step.java | 26 ++++++++++ .../domain/step/exception/StepException.java | 11 ++++ .../step/exception/StepExceptionType.java | 36 +++++++++++++ .../domain/user/entity/User.java | 29 +++++++++-- 16 files changed, 251 insertions(+), 11 deletions(-) rename src/main/java/sopt/org/motivooServer/domain/health/{ => entity}/ExerciseFrequency.java (61%) rename src/main/java/sopt/org/motivooServer/domain/health/{ => entity}/ExerciseTime.java (65%) rename src/main/java/sopt/org/motivooServer/domain/health/{ => entity}/ExerciseType.java (56%) rename src/main/java/sopt/org/motivooServer/domain/health/{ => entity}/Health.java (95%) rename src/main/java/sopt/org/motivooServer/domain/health/{ => entity}/HealthNote.java (92%) create mode 100644 src/main/java/sopt/org/motivooServer/domain/mission/entity/CompletedStatus.java create mode 100644 src/main/java/sopt/org/motivooServer/domain/mission/entity/Mission.java create mode 100644 src/main/java/sopt/org/motivooServer/domain/mission/entity/MissionType.java create mode 100644 src/main/java/sopt/org/motivooServer/domain/mission/entity/UserMission.java rename src/main/java/sopt/org/motivooServer/domain/parentchild/{ => entity}/Parentchild.java (90%) create mode 100644 src/main/java/sopt/org/motivooServer/domain/parentchild/exception/ParentchildException.java create mode 100644 src/main/java/sopt/org/motivooServer/domain/parentchild/exception/ParentchildExceptionType.java create mode 100644 src/main/java/sopt/org/motivooServer/domain/step/entity/Step.java create mode 100644 src/main/java/sopt/org/motivooServer/domain/step/exception/StepException.java create mode 100644 src/main/java/sopt/org/motivooServer/domain/step/exception/StepExceptionType.java diff --git a/src/main/java/sopt/org/motivooServer/domain/health/ExerciseFrequency.java b/src/main/java/sopt/org/motivooServer/domain/health/entity/ExerciseFrequency.java similarity index 61% rename from src/main/java/sopt/org/motivooServer/domain/health/ExerciseFrequency.java rename to src/main/java/sopt/org/motivooServer/domain/health/entity/ExerciseFrequency.java index 5e96d014..c8b48770 100644 --- a/src/main/java/sopt/org/motivooServer/domain/health/ExerciseFrequency.java +++ b/src/main/java/sopt/org/motivooServer/domain/health/entity/ExerciseFrequency.java @@ -1,4 +1,4 @@ -package sopt.org.motivooServer.domain.health; +package sopt.org.motivooServer.domain.health.entity; public enum ExerciseFrequency { diff --git a/src/main/java/sopt/org/motivooServer/domain/health/ExerciseTime.java b/src/main/java/sopt/org/motivooServer/domain/health/entity/ExerciseTime.java similarity index 65% rename from src/main/java/sopt/org/motivooServer/domain/health/ExerciseTime.java rename to src/main/java/sopt/org/motivooServer/domain/health/entity/ExerciseTime.java index c3754a5e..f4151d48 100644 --- a/src/main/java/sopt/org/motivooServer/domain/health/ExerciseTime.java +++ b/src/main/java/sopt/org/motivooServer/domain/health/entity/ExerciseTime.java @@ -1,4 +1,4 @@ -package sopt.org.motivooServer.domain.health; +package sopt.org.motivooServer.domain.health.entity; public enum ExerciseTime { diff --git a/src/main/java/sopt/org/motivooServer/domain/health/ExerciseType.java b/src/main/java/sopt/org/motivooServer/domain/health/entity/ExerciseType.java similarity index 56% rename from src/main/java/sopt/org/motivooServer/domain/health/ExerciseType.java rename to src/main/java/sopt/org/motivooServer/domain/health/entity/ExerciseType.java index 16de7aa5..9664790e 100644 --- a/src/main/java/sopt/org/motivooServer/domain/health/ExerciseType.java +++ b/src/main/java/sopt/org/motivooServer/domain/health/entity/ExerciseType.java @@ -1,4 +1,4 @@ -package sopt.org.motivooServer.domain.health; +package sopt.org.motivooServer.domain.health.entity; public enum ExerciseType { diff --git a/src/main/java/sopt/org/motivooServer/domain/health/Health.java b/src/main/java/sopt/org/motivooServer/domain/health/entity/Health.java similarity index 95% rename from src/main/java/sopt/org/motivooServer/domain/health/Health.java rename to src/main/java/sopt/org/motivooServer/domain/health/entity/Health.java index 6d880961..357e099e 100644 --- a/src/main/java/sopt/org/motivooServer/domain/health/Health.java +++ b/src/main/java/sopt/org/motivooServer/domain/health/entity/Health.java @@ -1,4 +1,4 @@ -package sopt.org.motivooServer.domain.health; +package sopt.org.motivooServer.domain.health.entity; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/sopt/org/motivooServer/domain/health/HealthNote.java b/src/main/java/sopt/org/motivooServer/domain/health/entity/HealthNote.java similarity index 92% rename from src/main/java/sopt/org/motivooServer/domain/health/HealthNote.java rename to src/main/java/sopt/org/motivooServer/domain/health/entity/HealthNote.java index 92a8cd74..09483148 100644 --- a/src/main/java/sopt/org/motivooServer/domain/health/HealthNote.java +++ b/src/main/java/sopt/org/motivooServer/domain/health/entity/HealthNote.java @@ -1,4 +1,4 @@ -package sopt.org.motivooServer.domain.health; +package sopt.org.motivooServer.domain.health.entity; import static sopt.org.motivooServer.domain.health.exception.HealthExceptionType.*; diff --git a/src/main/java/sopt/org/motivooServer/domain/mission/entity/CompletedStatus.java b/src/main/java/sopt/org/motivooServer/domain/mission/entity/CompletedStatus.java new file mode 100644 index 00000000..778520a3 --- /dev/null +++ b/src/main/java/sopt/org/motivooServer/domain/mission/entity/CompletedStatus.java @@ -0,0 +1,16 @@ +package sopt.org.motivooServer.domain.mission.entity; + +import lombok.AccessLevel; +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor(access = AccessLevel.PRIVATE) +public enum CompletedStatus { + + SUCCESS("성곡"), + FAIL("μ‹€νŒ¨"), + IN_PROGRESS("진행쀑"); + + private final String value; +} diff --git a/src/main/java/sopt/org/motivooServer/domain/mission/entity/Mission.java b/src/main/java/sopt/org/motivooServer/domain/mission/entity/Mission.java new file mode 100644 index 00000000..f38ad37c --- /dev/null +++ b/src/main/java/sopt/org/motivooServer/domain/mission/entity/Mission.java @@ -0,0 +1,29 @@ +package sopt.org.motivooServer.domain.mission.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import sopt.org.motivooServer.domain.common.BaseTimeEntity; + +@Entity +public class Mission extends BaseTimeEntity { + + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "mission_id") + private Long id; + + @Column(nullable = false) + private String content; + + @Enumerated(EnumType.STRING) + @Column(nullable = false) + private MissionType type; + + @Column(columnDefinition = "TEXT") + private String descriptionUrl; + +} diff --git a/src/main/java/sopt/org/motivooServer/domain/mission/entity/MissionType.java b/src/main/java/sopt/org/motivooServer/domain/mission/entity/MissionType.java new file mode 100644 index 00000000..8591b0de --- /dev/null +++ b/src/main/java/sopt/org/motivooServer/domain/mission/entity/MissionType.java @@ -0,0 +1,10 @@ +package sopt.org.motivooServer.domain.mission.entity; + +import lombok.AccessLevel; +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor(access = AccessLevel.PRIVATE) +public enum MissionType { + + +} diff --git a/src/main/java/sopt/org/motivooServer/domain/mission/entity/UserMission.java b/src/main/java/sopt/org/motivooServer/domain/mission/entity/UserMission.java new file mode 100644 index 00000000..d028b1d5 --- /dev/null +++ b/src/main/java/sopt/org/motivooServer/domain/mission/entity/UserMission.java @@ -0,0 +1,50 @@ +package sopt.org.motivooServer.domain.mission.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.EnumType; +import jakarta.persistence.Enumerated; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToOne; +import lombok.Getter; +import sopt.org.motivooServer.domain.common.BaseTimeEntity; +import sopt.org.motivooServer.domain.user.entity.User; + +@Getter +@Entity +public class UserMission extends BaseTimeEntity { + + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "user_mission_id") + private Long id; + + @Column(nullable = false) + private Double completedRate; + + @Enumerated(EnumType.STRING) + @Column(nullable = false) + private CompletedStatus completedStatus; + + @Column(columnDefinition = "TEXT") + private String imgUrl; + + @OneToOne + @JoinColumn(name = "mission_id", nullable = false) + private Mission mission; + + @ManyToOne + @JoinColumn(name = "user_id") + private User user; + + public void setUser(User user) { + this.user = user; + + if (!user.getUserMissions().contains(this)) { + user.getUserMissions().add(this); + } + } +} diff --git a/src/main/java/sopt/org/motivooServer/domain/parentchild/Parentchild.java b/src/main/java/sopt/org/motivooServer/domain/parentchild/entity/Parentchild.java similarity index 90% rename from src/main/java/sopt/org/motivooServer/domain/parentchild/Parentchild.java rename to src/main/java/sopt/org/motivooServer/domain/parentchild/entity/Parentchild.java index 0bbbb832..9006ef15 100644 --- a/src/main/java/sopt/org/motivooServer/domain/parentchild/Parentchild.java +++ b/src/main/java/sopt/org/motivooServer/domain/parentchild/entity/Parentchild.java @@ -1,4 +1,4 @@ -package sopt.org.motivooServer.domain.parentchild; +package sopt.org.motivooServer.domain.parentchild.entity; import jakarta.persistence.Column; import jakarta.persistence.Entity; diff --git a/src/main/java/sopt/org/motivooServer/domain/parentchild/exception/ParentchildException.java b/src/main/java/sopt/org/motivooServer/domain/parentchild/exception/ParentchildException.java new file mode 100644 index 00000000..8e760a2e --- /dev/null +++ b/src/main/java/sopt/org/motivooServer/domain/parentchild/exception/ParentchildException.java @@ -0,0 +1,11 @@ +package sopt.org.motivooServer.domain.parentchild.exception; + +import sopt.org.motivooServer.global.advice.BusinessException; +import sopt.org.motivooServer.global.advice.BusinessExceptionType; + +public class ParentchildException extends BusinessException { + + public ParentchildException(BusinessExceptionType exceptionType) { + super(exceptionType); + } +} diff --git a/src/main/java/sopt/org/motivooServer/domain/parentchild/exception/ParentchildExceptionType.java b/src/main/java/sopt/org/motivooServer/domain/parentchild/exception/ParentchildExceptionType.java new file mode 100644 index 00000000..ec31d5b0 --- /dev/null +++ b/src/main/java/sopt/org/motivooServer/domain/parentchild/exception/ParentchildExceptionType.java @@ -0,0 +1,32 @@ +package sopt.org.motivooServer.domain.parentchild.exception; + +import org.springframework.http.HttpStatus; + +import lombok.AccessLevel; +import lombok.RequiredArgsConstructor; +import sopt.org.motivooServer.global.advice.BusinessExceptionType; + +@RequiredArgsConstructor(access = AccessLevel.PRIVATE) +public enum ParentchildExceptionType implements BusinessExceptionType { + + /** + * 404 Not Found + */ + PARENTCHILD_NOT_FOUND(HttpStatus.NOT_FOUND, "μ‘΄μž¬ν•˜μ§€ μ•ŠλŠ” λΆ€λͺ¨-μžλ…€ κ΄€κ³„μž…λ‹ˆλ‹€.") + + + ; + + private final HttpStatus status; + private final String message; + + @Override + public HttpStatus status() { + return this.status; + } + + @Override + public String message() { + return this.message; + } +} diff --git a/src/main/java/sopt/org/motivooServer/domain/step/entity/Step.java b/src/main/java/sopt/org/motivooServer/domain/step/entity/Step.java new file mode 100644 index 00000000..e9ddd5d5 --- /dev/null +++ b/src/main/java/sopt/org/motivooServer/domain/step/entity/Step.java @@ -0,0 +1,26 @@ +package sopt.org.motivooServer.domain.step.entity; + +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.JoinColumn; +import jakarta.persistence.OneToOne; +import sopt.org.motivooServer.domain.common.BaseTimeEntity; +import sopt.org.motivooServer.domain.user.entity.User; + +@Entity +public class Step extends BaseTimeEntity { + + @Id @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "step_id") + private Long id; + + @Column(nullable = false) + private Integer count; + + @OneToOne + @JoinColumn(name = "user_id") + private User user; +} diff --git a/src/main/java/sopt/org/motivooServer/domain/step/exception/StepException.java b/src/main/java/sopt/org/motivooServer/domain/step/exception/StepException.java new file mode 100644 index 00000000..3a1cddcf --- /dev/null +++ b/src/main/java/sopt/org/motivooServer/domain/step/exception/StepException.java @@ -0,0 +1,11 @@ +package sopt.org.motivooServer.domain.step.exception; + +import sopt.org.motivooServer.global.advice.BusinessException; +import sopt.org.motivooServer.global.advice.BusinessExceptionType; + +public class StepException extends BusinessException { + + public StepException(BusinessExceptionType exceptionType) { + super(exceptionType); + } +} diff --git a/src/main/java/sopt/org/motivooServer/domain/step/exception/StepExceptionType.java b/src/main/java/sopt/org/motivooServer/domain/step/exception/StepExceptionType.java new file mode 100644 index 00000000..c49eb9d2 --- /dev/null +++ b/src/main/java/sopt/org/motivooServer/domain/step/exception/StepExceptionType.java @@ -0,0 +1,36 @@ +package sopt.org.motivooServer.domain.step.exception; + +import org.springframework.http.HttpStatus; + +import lombok.AccessLevel; +import lombok.RequiredArgsConstructor; +import sopt.org.motivooServer.global.advice.BusinessExceptionType; + +@RequiredArgsConstructor(access = AccessLevel.PRIVATE) +public enum StepExceptionType implements BusinessExceptionType { + + /** + * 400 Bad Request + */ + + + /** + * 404 Not Found + */ + + + ; + + private final HttpStatus status; + private final String message; + + @Override + public HttpStatus status() { + return this.status; + } + + @Override + public String message() { + return this.message; + } +} diff --git a/src/main/java/sopt/org/motivooServer/domain/user/entity/User.java b/src/main/java/sopt/org/motivooServer/domain/user/entity/User.java index b434684a..b0a13b2f 100644 --- a/src/main/java/sopt/org/motivooServer/domain/user/entity/User.java +++ b/src/main/java/sopt/org/motivooServer/domain/user/entity/User.java @@ -1,5 +1,8 @@ package sopt.org.motivooServer.domain.user.entity; +import java.util.ArrayList; +import java.util.List; + import org.hibernate.annotations.SQLDelete; import jakarta.persistence.Column; @@ -11,10 +14,14 @@ import jakarta.persistence.Id; import jakarta.persistence.JoinColumn; import jakarta.persistence.ManyToOne; +import jakarta.persistence.OneToMany; import jakarta.persistence.Table; +import lombok.Getter; import sopt.org.motivooServer.domain.common.BaseTimeEntity; -import sopt.org.motivooServer.domain.parentchild.Parentchild; +import sopt.org.motivooServer.domain.mission.entity.UserMission; +import sopt.org.motivooServer.domain.parentchild.entity.Parentchild; +@Getter @Entity @Table(name = "`user`") @SQLDelete(sql = "UPDATE user SET user.deleted=true WHERE user_id=?") @@ -35,10 +42,6 @@ public class User extends BaseTimeEntity { @Column(nullable = false) private Boolean deleted = Boolean.FALSE; - @ManyToOne - @JoinColumn(name = "parentchild_id") - private Parentchild parentchild; - @Column(nullable = false) private Long socialId; @@ -49,4 +52,20 @@ public class User extends BaseTimeEntity { @Enumerated(EnumType.STRING) @Column(nullable = false) private SocialPlatform socialPlatform; + + + @ManyToOne + @JoinColumn(name = "parentchild_id") + private Parentchild parentchild; + + @OneToMany(mappedBy = "user") + private List userMissions = new ArrayList<>(); + + + public void addUserMission(UserMission userMission) { + this.userMissions.add(userMission); + if (userMission.getUser() != this) { + userMission.setUser(this); + } + } } From 2249284bddd91489938f9e5d13167ea17a3b775e Mon Sep 17 00:00:00 2001 From: jun02160 Date: Tue, 2 Jan 2024 13:31:45 +0900 Subject: [PATCH 6/7] =?UTF-8?q?=F0=9F=90=9B=20bugfix:=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=EC=9E=90=EC=97=90=20=EC=9D=98=ED=95=9C=20=EB=B9=8C=EB=93=9C=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=EC=82=AC=ED=95=AD=20=EC=88=98=EC=A0=95=20#6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sopt/org/motivooServer/global/response/ApiResponse.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/main/java/sopt/org/motivooServer/global/response/ApiResponse.java b/src/main/java/sopt/org/motivooServer/global/response/ApiResponse.java index 5f13f273..b973cb1e 100644 --- a/src/main/java/sopt/org/motivooServer/global/response/ApiResponse.java +++ b/src/main/java/sopt/org/motivooServer/global/response/ApiResponse.java @@ -9,11 +9,10 @@ import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Getter; -import lombok.RequiredArgsConstructor; @Getter @Builder -@RequiredArgsConstructor(access = AccessLevel.PRIVATE) +@AllArgsConstructor(access = AccessLevel.PRIVATE) @JsonPropertyOrder({"code", "message", "success", "data"}) public class ApiResponse { From 48b46999b210e54dc120d8a0776bf4f2b9d9d1d1 Mon Sep 17 00:00:00 2001 From: jun02160 Date: Tue, 2 Jan 2024 15:57:04 +0900 Subject: [PATCH 7/7] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20fix:=20=EC=9D=BC?= =?UTF-8?q?=EB=B6=80=20=EB=88=84=EB=9D=BD=20=ED=95=84=EB=93=9C=20=EB=B0=98?= =?UTF-8?q?=EC=98=81=20#6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sopt/org/motivooServer/domain/health/entity/Health.java | 3 +++ .../org/motivooServer/domain/mission/entity/UserMission.java | 1 + .../java/sopt/org/motivooServer/domain/user/entity/User.java | 4 +++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/sopt/org/motivooServer/domain/health/entity/Health.java b/src/main/java/sopt/org/motivooServer/domain/health/entity/Health.java index 357e099e..70f697bb 100644 --- a/src/main/java/sopt/org/motivooServer/domain/health/entity/Health.java +++ b/src/main/java/sopt/org/motivooServer/domain/health/entity/Health.java @@ -27,6 +27,9 @@ public class Health extends BaseTimeEntity { @JoinColumn(name = "user_id") private User user; + @Column(nullable = false) + private Boolean isExercise; + @Enumerated(EnumType.STRING) @Column(nullable = false) private ExerciseType exerciseType; diff --git a/src/main/java/sopt/org/motivooServer/domain/mission/entity/UserMission.java b/src/main/java/sopt/org/motivooServer/domain/mission/entity/UserMission.java index d028b1d5..c628ad11 100644 --- a/src/main/java/sopt/org/motivooServer/domain/mission/entity/UserMission.java +++ b/src/main/java/sopt/org/motivooServer/domain/mission/entity/UserMission.java @@ -40,6 +40,7 @@ public class UserMission extends BaseTimeEntity { @JoinColumn(name = "user_id") private User user; + //== 연관관계 λ©”μ„œλ“œ ==// public void setUser(User user) { this.user = user; diff --git a/src/main/java/sopt/org/motivooServer/domain/user/entity/User.java b/src/main/java/sopt/org/motivooServer/domain/user/entity/User.java index b0a13b2f..18a7f97f 100644 --- a/src/main/java/sopt/org/motivooServer/domain/user/entity/User.java +++ b/src/main/java/sopt/org/motivooServer/domain/user/entity/User.java @@ -1,5 +1,6 @@ package sopt.org.motivooServer.domain.user.entity; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; @@ -37,7 +38,7 @@ public class User extends BaseTimeEntity { @Enumerated(EnumType.STRING) @Column(nullable = false) - private UserType userType; + private UserType type; @Column(nullable = false) private Boolean deleted = Boolean.FALSE; @@ -62,6 +63,7 @@ public class User extends BaseTimeEntity { private List userMissions = new ArrayList<>(); + //== 연관관계 λ©”μ„œλ“œ ==// public void addUserMission(UserMission userMission) { this.userMissions.add(userMission); if (userMission.getUser() != this) {