From 22775f1a7b76f70cd7aa2ce243eab1bd610e97a3 Mon Sep 17 00:00:00 2001 From: sung-silver Date: Thu, 31 Oct 2024 17:30:35 +0900 Subject: [PATCH 1/7] =?UTF-8?q?[ADD]=20validate=20=EC=9D=98=EC=A1=B4?= =?UTF-8?q?=EC=84=B1=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- infra/build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/infra/build.gradle.kts b/infra/build.gradle.kts index 788dd24..c1c912d 100644 --- a/infra/build.gradle.kts +++ b/infra/build.gradle.kts @@ -11,6 +11,7 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter") implementation("org.springframework.boot:spring-boot-starter-data-jpa") implementation ("org.springframework.cloud:spring-cloud-starter-openfeign:${property("springOpenFeignVersion")}") + implementation("org.springframework.boot:spring-boot-starter-validation") //db runtimeOnly("com.h2database:h2") From 07d7a5700f0cca7b79e8e623530f6cf2fc3e755b Mon Sep 17 00:00:00 2001 From: sung-silver Date: Thu, 31 Oct 2024 17:42:49 +0900 Subject: [PATCH 2/7] =?UTF-8?q?[FEAT]=20BaseTimeEntity=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infra/jpa/common/BaseTimeEntity.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 infra/src/main/java/sopt/makers/authentication/infra/jpa/common/BaseTimeEntity.java diff --git a/infra/src/main/java/sopt/makers/authentication/infra/jpa/common/BaseTimeEntity.java b/infra/src/main/java/sopt/makers/authentication/infra/jpa/common/BaseTimeEntity.java new file mode 100644 index 0000000..852590c --- /dev/null +++ b/infra/src/main/java/sopt/makers/authentication/infra/jpa/common/BaseTimeEntity.java @@ -0,0 +1,21 @@ +package sopt.makers.authentication.infra.jpa.common; + +import java.time.*; + +import jakarta.persistence.*; + +import org.springframework.data.annotation.*; +import org.springframework.data.jpa.domain.support.*; + +import lombok.*; + +@Getter +@EntityListeners(AuditingEntityListener.class) +@MappedSuperclass +public abstract class BaseTimeEntity { + @CreatedDate + @Column(updatable = false) + private LocalDateTime createdAt; + + @LastModifiedDate private LocalDateTime updatedAt; +} From 9836b944267a68f8e3a2a26dcc3293c51cf2b3ea Mon Sep 17 00:00:00 2001 From: sung-silver Date: Thu, 31 Oct 2024 17:55:57 +0900 Subject: [PATCH 3/7] =?UTF-8?q?[FEAT]=20User=20=EC=97=94=ED=8B=B0=ED=8B=B0?= =?UTF-8?q?=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infra/jpa/user/entity/UserEntity.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserEntity.java diff --git a/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserEntity.java b/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserEntity.java new file mode 100644 index 0000000..868a95b --- /dev/null +++ b/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserEntity.java @@ -0,0 +1,41 @@ +package sopt.makers.authentication.infra.jpa.user.entity; + +import sopt.makers.authentication.infra.jpa.common.*; +import sopt.makers.authentication.user.*; + +import java.time.*; + +import jakarta.persistence.*; +import jakarta.validation.constraints.*; + +import lombok.*; + +@Entity +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Table(name = "USERS") +public class UserEntity extends BaseTimeEntity { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @NotNull String name; + @NotNull String phone; + @NotNull String email; + @NotNull LocalDate birthday; + @NotNull String authPlatformId; + @NotNull AuthPlatform authPlatformType; + @NotNull Boolean isActive; + + public UserEntity(final User user, boolean isActive) { + Profile profile = user.getProfile(); + SocialAccount socialAccount = user.getSocialAccount(); + + this.name = profile.name(); + this.phone = profile.phone(); + this.email = profile.email(); + this.birthday = profile.birthday(); + this.authPlatformId = socialAccount.authPlatformId(); + this.authPlatformType = socialAccount.authPlatformType(); + this.isActive = isActive; + } +} From 821944ae706379506648b84da74eacb1894e4b04 Mon Sep 17 00:00:00 2001 From: sung-silver Date: Thu, 31 Oct 2024 18:07:42 +0900 Subject: [PATCH 4/7] =?UTF-8?q?[FEAT]=20UserActivityHistory=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jpa/user/entity/UserActivityHistory.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserActivityHistory.java diff --git a/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserActivityHistory.java b/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserActivityHistory.java new file mode 100644 index 0000000..8e02629 --- /dev/null +++ b/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserActivityHistory.java @@ -0,0 +1,37 @@ +package sopt.makers.authentication.infra.jpa.user.entity; + +import sopt.makers.authentication.user.*; + +import jakarta.persistence.*; +import jakarta.validation.constraints.*; + +import lombok.*; + +@Entity +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Table(name = "USER_ACTIVITY_HISTORIES") +public class UserActivityHistory { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id") + @NotNull + private UserEntity user; + + @Min(1) + private int generation; + + private Team team; + @NotNull private Part part; + @NotNull private Role role; + + public UserActivityHistory(final UserEntity user, final Activity activity) { + this.user = user; + this.generation = activity.generation(); + this.team = activity.team(); + this.part = activity.part(); + this.role = activity.role(); + } +} From 26acfc5fc9bc33f87e1956cfe79b7866599d1407 Mon Sep 17 00:00:00 2001 From: sung-silver Date: Thu, 31 Oct 2024 18:13:29 +0900 Subject: [PATCH 5/7] =?UTF-8?q?[FEAT]=20UserRegisterInfo=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jpa/user/entity/UserRegisterInfo.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserRegisterInfo.java diff --git a/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserRegisterInfo.java b/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserRegisterInfo.java new file mode 100644 index 0000000..7a035f4 --- /dev/null +++ b/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserRegisterInfo.java @@ -0,0 +1,28 @@ +package sopt.makers.authentication.infra.jpa.user.entity; + +import sopt.makers.authentication.user.*; + +import java.time.*; + +import jakarta.persistence.*; +import jakarta.validation.constraints.*; + +import lombok.*; + +@Entity +@NoArgsConstructor(access = AccessLevel.PROTECTED) +@Table(name = "USER_REGISTER_INFOS") +public class UserRegisterInfo { + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @NotNull private String name; + @NotNull private String phone; + @NotNull private LocalDate birthday; + + @Min(1) + private int generation; + + @NotNull private Part part; +} From b33ba96259908a36e7e009768d382d237ea9fb6a Mon Sep 17 00:00:00 2001 From: sung-silver Date: Thu, 31 Oct 2024 18:22:30 +0900 Subject: [PATCH 6/7] =?UTF-8?q?[CHORE]=20=EC=97=94=ED=8B=B0=ED=8B=B0=20?= =?UTF-8?q?=ED=81=B4=EB=9E=98=EC=8A=A4=20=EB=92=A4=EC=97=90=20Entity=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20=EB=B0=8F=20toDomain=20=EB=A9=94=EC=84=9C?= =?UTF-8?q?=EB=93=9C=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ctivityHistory.java => UserActivityHistoryEntity.java} | 8 ++++++-- ...{UserRegisterInfo.java => UserRegisterInfoEntity.java} | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) rename infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/{UserActivityHistory.java => UserActivityHistoryEntity.java} (78%) rename infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/{UserRegisterInfo.java => UserRegisterInfoEntity.java} (93%) diff --git a/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserActivityHistory.java b/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserActivityHistoryEntity.java similarity index 78% rename from infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserActivityHistory.java rename to infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserActivityHistoryEntity.java index 8e02629..f6f02ad 100644 --- a/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserActivityHistory.java +++ b/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserActivityHistoryEntity.java @@ -10,7 +10,7 @@ @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) @Table(name = "USER_ACTIVITY_HISTORIES") -public class UserActivityHistory { +public class UserActivityHistoryEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; @@ -27,11 +27,15 @@ public class UserActivityHistory { @NotNull private Part part; @NotNull private Role role; - public UserActivityHistory(final UserEntity user, final Activity activity) { + public UserActivityHistoryEntity(final UserEntity user, final Activity activity) { this.user = user; this.generation = activity.generation(); this.team = activity.team(); this.part = activity.part(); this.role = activity.role(); } + + public Activity toDomain() { + return new Activity(generation, team, part); + } } diff --git a/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserRegisterInfo.java b/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserRegisterInfoEntity.java similarity index 93% rename from infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserRegisterInfo.java rename to infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserRegisterInfoEntity.java index 7a035f4..991ef02 100644 --- a/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserRegisterInfo.java +++ b/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserRegisterInfoEntity.java @@ -12,7 +12,7 @@ @Entity @NoArgsConstructor(access = AccessLevel.PROTECTED) @Table(name = "USER_REGISTER_INFOS") -public class UserRegisterInfo { +public class UserRegisterInfoEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; From cd0c108454d9c3a109286bc137d0b539f54f82b3 Mon Sep 17 00:00:00 2001 From: sung-silver Date: Thu, 31 Oct 2024 18:33:43 +0900 Subject: [PATCH 7/7] =?UTF-8?q?[FEAT]=20Enum=20=ED=83=80=EC=9E=85=20?= =?UTF-8?q?=ED=95=84=EB=93=9C=EC=97=90=20Enumerated(EnumType.STRING)=20?= =?UTF-8?q?=EC=96=B4=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98=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 --- .../jpa/user/entity/UserActivityHistoryEntity.java | 11 +++++++++-- .../infra/jpa/user/entity/UserEntity.java | 6 +++++- .../infra/jpa/user/entity/UserRegisterInfoEntity.java | 4 +++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserActivityHistoryEntity.java b/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserActivityHistoryEntity.java index f6f02ad..4d2a3dc 100644 --- a/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserActivityHistoryEntity.java +++ b/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserActivityHistoryEntity.java @@ -23,9 +23,16 @@ public class UserActivityHistoryEntity { @Min(1) private int generation; + @Enumerated(EnumType.STRING) private Team team; - @NotNull private Part part; - @NotNull private Role role; + + @NotNull + @Enumerated(EnumType.STRING) + private Part part; + + @NotNull + @Enumerated(EnumType.STRING) + private Role role; public UserActivityHistoryEntity(final UserEntity user, final Activity activity) { this.user = user; diff --git a/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserEntity.java b/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserEntity.java index 868a95b..2bbd617 100644 --- a/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserEntity.java +++ b/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserEntity.java @@ -23,7 +23,11 @@ public class UserEntity extends BaseTimeEntity { @NotNull String email; @NotNull LocalDate birthday; @NotNull String authPlatformId; - @NotNull AuthPlatform authPlatformType; + + @NotNull + @Enumerated(EnumType.STRING) + AuthPlatform authPlatformType; + @NotNull Boolean isActive; public UserEntity(final User user, boolean isActive) { diff --git a/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserRegisterInfoEntity.java b/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserRegisterInfoEntity.java index 991ef02..fcb9fe4 100644 --- a/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserRegisterInfoEntity.java +++ b/infra/src/main/java/sopt/makers/authentication/infra/jpa/user/entity/UserRegisterInfoEntity.java @@ -24,5 +24,7 @@ public class UserRegisterInfoEntity { @Min(1) private int generation; - @NotNull private Part part; + @NotNull + @Enumerated(EnumType.STRING) + private Part part; }