From ac97f3d4265c78e6a006adc8297b0f8f377197c3 Mon Sep 17 00:00:00 2001 From: ckyeon Date: Fri, 18 Aug 2023 21:28:14 +0900 Subject: [PATCH 01/17] feat(BaseEntity): add date base entity --- .../sequence/anonymous/common/BaseEntity.java | 24 +++++++++++++++++++ .../sequence/anonymous/user/domain/User.java | 12 +++------- 2 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 src/main/java/com/sequence/anonymous/common/BaseEntity.java diff --git a/src/main/java/com/sequence/anonymous/common/BaseEntity.java b/src/main/java/com/sequence/anonymous/common/BaseEntity.java new file mode 100644 index 0000000..e45f2fd --- /dev/null +++ b/src/main/java/com/sequence/anonymous/common/BaseEntity.java @@ -0,0 +1,24 @@ +package com.sequence.anonymous.common; + +import jakarta.persistence.Column; +import jakarta.persistence.EntityListeners; +import jakarta.persistence.MappedSuperclass; +import lombok.Getter; +import org.springframework.data.annotation.CreatedDate; +import org.springframework.data.annotation.LastModifiedDate; +import org.springframework.data.jpa.domain.support.AuditingEntityListener; + +import java.time.LocalDateTime; + +@Getter +@EntityListeners(AuditingEntityListener.class) +@MappedSuperclass +public class BaseEntity { + + @CreatedDate + @Column(updatable = false) + private LocalDateTime createdAt; + + @LastModifiedDate + private LocalDateTime updatedAt; +} diff --git a/src/main/java/com/sequence/anonymous/user/domain/User.java b/src/main/java/com/sequence/anonymous/user/domain/User.java index 50c88bc..542d209 100644 --- a/src/main/java/com/sequence/anonymous/user/domain/User.java +++ b/src/main/java/com/sequence/anonymous/user/domain/User.java @@ -1,19 +1,13 @@ package com.sequence.anonymous.user.domain; import com.google.common.base.Preconditions; -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.validation.constraints.Email; +import com.sequence.anonymous.common.BaseEntity; +import jakarta.persistence.*; import lombok.Getter; @Entity @Getter -public class User { +public class User extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) From 81be6dff543e9f6aee308dda67369da569ea367e Mon Sep 17 00:00:00 2001 From: ckyeon Date: Fri, 18 Aug 2023 21:47:20 +0900 Subject: [PATCH 02/17] feat(Gender): add gender enum --- .../java/com/sequence/anonymous/user/domain/Gender.java | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/main/java/com/sequence/anonymous/user/domain/Gender.java diff --git a/src/main/java/com/sequence/anonymous/user/domain/Gender.java b/src/main/java/com/sequence/anonymous/user/domain/Gender.java new file mode 100644 index 0000000..9573224 --- /dev/null +++ b/src/main/java/com/sequence/anonymous/user/domain/Gender.java @@ -0,0 +1,6 @@ +package com.sequence.anonymous.user.domain; + +public enum Gender { + FEMALE, + MALE +} From 7abb93e274ba930535caab7780ae42deac5a97a2 Mon Sep 17 00:00:00 2001 From: ckyeon Date: Fri, 18 Aug 2023 22:00:14 +0900 Subject: [PATCH 03/17] feat(User): add default columns --- .../sequence/anonymous/user/domain/User.java | 38 +++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/sequence/anonymous/user/domain/User.java b/src/main/java/com/sequence/anonymous/user/domain/User.java index 542d209..d08a4dd 100644 --- a/src/main/java/com/sequence/anonymous/user/domain/User.java +++ b/src/main/java/com/sequence/anonymous/user/domain/User.java @@ -19,30 +19,62 @@ public class User extends BaseEntity { @Enumerated(EnumType.STRING) private OAuth2Provider provider; - @Column(length = 40) + @Column(length = 40, unique = true) private String email; + @Column(length = 20) + private String name; + + private Integer age; + + @Column(length = 10) + @Enumerated(EnumType.STRING) + private Gender gender; + @Column(length = 15) @Enumerated(EnumType.STRING) private Role role; + private Boolean withdrawal; + + private Boolean profileInitialized; + protected User() { } public User(String providerId, OAuth2Provider provider, String email) { - this(null, providerId, provider, email, Role.ROLE_USER); + this(null, providerId, provider, email, null, null, null, Role.ROLE_USER, false, false); } - private User(Long id, String providerId, OAuth2Provider provider, String email, Role role) { + private User(Long id, String providerId, OAuth2Provider provider, String email, String name, Integer age, Gender gender, Role role, Boolean withdrawal, Boolean profileInitialized) { Preconditions.checkArgument(providerId != null, "providerId must be provided."); Preconditions.checkArgument(provider != null, "provider must be provided."); Preconditions.checkArgument(email != null, "email must be provided."); Preconditions.checkArgument(role != null, "role must be provided."); + Preconditions.checkArgument(withdrawal != null, "withdrawal must be provided."); + Preconditions.checkArgument(profileInitialized != null, "initialized must be provided."); this.id = id; this.providerId = providerId; this.provider = provider; + this.name = name; + this.age = age; + this.gender = gender; this.email = email; this.role = role; + this.withdrawal = withdrawal; + this.profileInitialized = profileInitialized; + } + + public void initializeProfile(String name, Integer age, Gender gender) { + Preconditions.checkArgument(name != null, "name must be provided."); + Preconditions.checkArgument(age != null, "age must be provided."); + Preconditions.checkArgument(gender != null, "gender must be provided."); + + this.name = name; + this.age = age; + this.gender = gender; + + this.profileInitialized = true; } } From b92c548ef60323e95cf65667879297f9835dd52b Mon Sep 17 00:00:00 2001 From: ckyeon Date: Sat, 26 Aug 2023 16:25:33 +0900 Subject: [PATCH 04/17] feat(Entity): enable jpa auditing --- src/main/java/com/sequence/anonymous/AnonymousApplication.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/sequence/anonymous/AnonymousApplication.java b/src/main/java/com/sequence/anonymous/AnonymousApplication.java index 18cc3ea..4f24107 100644 --- a/src/main/java/com/sequence/anonymous/AnonymousApplication.java +++ b/src/main/java/com/sequence/anonymous/AnonymousApplication.java @@ -4,8 +4,10 @@ import io.swagger.v3.oas.annotations.servers.Server; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.data.jpa.repository.config.EnableJpaAuditing; @SpringBootApplication +@EnableJpaAuditing @OpenAPIDefinition(servers = {@Server(url = "/")}) public class AnonymousApplication { From c1596e4cb3f0bd7398e7f2d12fb087581cf0914a Mon Sep 17 00:00:00 2001 From: ckyeon Date: Sat, 26 Aug 2023 16:28:07 +0900 Subject: [PATCH 05/17] feat(User): add skeleton classes --- .../anonymous/user/application/UserService.java | 12 ++++++++++++ .../user/presentation/UserController.java | 14 ++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 src/main/java/com/sequence/anonymous/user/application/UserService.java create mode 100644 src/main/java/com/sequence/anonymous/user/presentation/UserController.java diff --git a/src/main/java/com/sequence/anonymous/user/application/UserService.java b/src/main/java/com/sequence/anonymous/user/application/UserService.java new file mode 100644 index 0000000..07d048e --- /dev/null +++ b/src/main/java/com/sequence/anonymous/user/application/UserService.java @@ -0,0 +1,12 @@ +package com.sequence.anonymous.user.application; + +import com.sequence.anonymous.user.domain.repository.UserRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@RequiredArgsConstructor +@Service +public class UserService { + + private final UserRepository userRepository; +} diff --git a/src/main/java/com/sequence/anonymous/user/presentation/UserController.java b/src/main/java/com/sequence/anonymous/user/presentation/UserController.java new file mode 100644 index 0000000..4b8c437 --- /dev/null +++ b/src/main/java/com/sequence/anonymous/user/presentation/UserController.java @@ -0,0 +1,14 @@ +package com.sequence.anonymous.user.presentation; + +import com.sequence.anonymous.user.application.UserService; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RequiredArgsConstructor +@RestController +@RequestMapping("/users") +public class UserController { + + private final UserService userService; +} From be1ac67c48c8f07ca9039427d4a3fda6a1dc871a Mon Sep 17 00:00:00 2001 From: ckyeon Date: Sun, 27 Aug 2023 19:03:51 +0900 Subject: [PATCH 06/17] feat(MatchPost): add status enum --- .../com/sequence/anonymous/matchpost/domain/MatchPost.java | 2 ++ .../com/sequence/anonymous/matchpost/domain/Status.java | 6 ++++++ 2 files changed, 8 insertions(+) create mode 100644 src/main/java/com/sequence/anonymous/matchpost/domain/MatchPost.java create mode 100644 src/main/java/com/sequence/anonymous/matchpost/domain/Status.java diff --git a/src/main/java/com/sequence/anonymous/matchpost/domain/MatchPost.java b/src/main/java/com/sequence/anonymous/matchpost/domain/MatchPost.java new file mode 100644 index 0000000..65c87cd --- /dev/null +++ b/src/main/java/com/sequence/anonymous/matchpost/domain/MatchPost.java @@ -0,0 +1,2 @@ +package com.sequence.anonymous.matchpost.domain;public class MatchPost { +} diff --git a/src/main/java/com/sequence/anonymous/matchpost/domain/Status.java b/src/main/java/com/sequence/anonymous/matchpost/domain/Status.java new file mode 100644 index 0000000..f823a29 --- /dev/null +++ b/src/main/java/com/sequence/anonymous/matchpost/domain/Status.java @@ -0,0 +1,6 @@ +package com.sequence.anonymous.matchpost.domain; + +public enum Status { + RECRUIT, + DONE +} From c80adb180d9223ed4742d2edd603cd5728c3550c Mon Sep 17 00:00:00 2001 From: ckyeon Date: Sun, 27 Aug 2023 19:24:06 +0900 Subject: [PATCH 07/17] feat(MatchPost): add default entity --- .../anonymous/matchpost/domain/MatchPost.java | 56 ++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sequence/anonymous/matchpost/domain/MatchPost.java b/src/main/java/com/sequence/anonymous/matchpost/domain/MatchPost.java index 65c87cd..1743141 100644 --- a/src/main/java/com/sequence/anonymous/matchpost/domain/MatchPost.java +++ b/src/main/java/com/sequence/anonymous/matchpost/domain/MatchPost.java @@ -1,2 +1,56 @@ -package com.sequence.anonymous.matchpost.domain;public class MatchPost { +package com.sequence.anonymous.matchpost.domain; + +import com.google.common.base.Preconditions; +import com.sequence.anonymous.common.BaseEntity; +import jakarta.persistence.*; +import jakarta.validation.constraints.NotNull; +import lombok.Getter; + +@Getter +@Entity +public class MatchPost extends BaseEntity { + + @NotNull + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(length = 50) + @NotNull + private String title; + + @Column(length = 50) + @NotNull + private String introduce; + + @Column(length = 50) + @NotNull + private String appeal; + + @Enumerated(EnumType.STRING) + @Column(length = 10) + @NotNull + private Status status; + + protected MatchPost() { + } + + public MatchPost(String title, String introduce, String appeal) { + this(null, title, introduce, appeal, Status.RECRUIT); + } + + private MatchPost(Long id, String title, String introduce, String appeal, Status status) { + Preconditions.checkArgument(title != null, "title must be provided."); + Preconditions.checkArgument(introduce != null, "introduce must be provided."); + Preconditions.checkArgument(appeal != null, "appeal must be provided."); + Preconditions.checkArgument(status != null, "status must be provided."); + + Preconditions.checkArgument(title.isEmpty(), "title must not be empty."); + + this.id = id; + this.title = title; + this.introduce = introduce; + this.appeal = appeal; + this.status = status; + } } From 44e50a2c64d0dc33188a69753e612179c201c4da Mon Sep 17 00:00:00 2001 From: ckyeon Date: Sun, 27 Aug 2023 19:26:33 +0900 Subject: [PATCH 08/17] feat(MatchPost): add skeleton classes --- .../matchpost/application/MatchPostService.java | 12 ++++++++++++ .../domain/repository/MatchPostRepository.java | 9 +++++++++ .../presentation/MatchPostController.java | 14 ++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 src/main/java/com/sequence/anonymous/matchpost/application/MatchPostService.java create mode 100644 src/main/java/com/sequence/anonymous/matchpost/domain/repository/MatchPostRepository.java create mode 100644 src/main/java/com/sequence/anonymous/matchpost/presentation/MatchPostController.java diff --git a/src/main/java/com/sequence/anonymous/matchpost/application/MatchPostService.java b/src/main/java/com/sequence/anonymous/matchpost/application/MatchPostService.java new file mode 100644 index 0000000..bfe2597 --- /dev/null +++ b/src/main/java/com/sequence/anonymous/matchpost/application/MatchPostService.java @@ -0,0 +1,12 @@ +package com.sequence.anonymous.matchpost.application; + +import com.sequence.anonymous.matchpost.domain.repository.MatchPostRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@RequiredArgsConstructor +@Service +public class MatchPostService { + + private final MatchPostRepository matchPostRepository; +} diff --git a/src/main/java/com/sequence/anonymous/matchpost/domain/repository/MatchPostRepository.java b/src/main/java/com/sequence/anonymous/matchpost/domain/repository/MatchPostRepository.java new file mode 100644 index 0000000..bd6822d --- /dev/null +++ b/src/main/java/com/sequence/anonymous/matchpost/domain/repository/MatchPostRepository.java @@ -0,0 +1,9 @@ +package com.sequence.anonymous.matchpost.domain.repository; + +import com.sequence.anonymous.matchpost.domain.MatchPost; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface MatchPostRepository extends JpaRepository { +} diff --git a/src/main/java/com/sequence/anonymous/matchpost/presentation/MatchPostController.java b/src/main/java/com/sequence/anonymous/matchpost/presentation/MatchPostController.java new file mode 100644 index 0000000..2a4674e --- /dev/null +++ b/src/main/java/com/sequence/anonymous/matchpost/presentation/MatchPostController.java @@ -0,0 +1,14 @@ +package com.sequence.anonymous.matchpost.presentation; + +import com.sequence.anonymous.matchpost.application.MatchPostService; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RequiredArgsConstructor +@RestController +@RequestMapping("/match-posts") +public class MatchPostController { + + private final MatchPostService matchPostService; +} From 37d4d8817ef90206ab76d2ad2702fab19554a032 Mon Sep 17 00:00:00 2001 From: ckyeon Date: Wed, 30 Aug 2023 00:44:38 +0900 Subject: [PATCH 09/17] feat(Chat): add entity --- .../sequence/anonymous/chat/domain/Chat.java | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/main/java/com/sequence/anonymous/chat/domain/Chat.java diff --git a/src/main/java/com/sequence/anonymous/chat/domain/Chat.java b/src/main/java/com/sequence/anonymous/chat/domain/Chat.java new file mode 100644 index 0000000..5731742 --- /dev/null +++ b/src/main/java/com/sequence/anonymous/chat/domain/Chat.java @@ -0,0 +1,35 @@ +package com.sequence.anonymous.chat.domain; + +import com.google.common.base.Preconditions; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import lombok.Getter; + +import java.util.UUID; + +@Getter +@Entity +public class Chat { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private UUID identifier; + + protected Chat() { + } + + public Chat(UUID identifier) { + this(null, identifier); + } + + private Chat(Long id, UUID identifier) { + Preconditions.checkArgument(identifier != null, "identifier must be provided."); + + this.id = id; + this.identifier = identifier; + } +} From 8f20e8748c66795a802f74b41c327d3b4d7f3d55 Mon Sep 17 00:00:00 2001 From: ckyeon Date: Wed, 30 Aug 2023 00:46:51 +0900 Subject: [PATCH 10/17] feat(Chat): add skeleton classes --- .../anonymous/chat/application/ChatService.java | 12 ++++++++++++ .../chat/domain/repository/ChatRepository.java | 9 +++++++++ .../chat/presentation/ChatController.java | 14 ++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 src/main/java/com/sequence/anonymous/chat/application/ChatService.java create mode 100644 src/main/java/com/sequence/anonymous/chat/domain/repository/ChatRepository.java create mode 100644 src/main/java/com/sequence/anonymous/chat/presentation/ChatController.java diff --git a/src/main/java/com/sequence/anonymous/chat/application/ChatService.java b/src/main/java/com/sequence/anonymous/chat/application/ChatService.java new file mode 100644 index 0000000..ebacac8 --- /dev/null +++ b/src/main/java/com/sequence/anonymous/chat/application/ChatService.java @@ -0,0 +1,12 @@ +package com.sequence.anonymous.chat.application; + +import com.sequence.anonymous.chat.domain.repository.ChatRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@RequiredArgsConstructor +@Service +public class ChatService { + + private final ChatRepository chatRepository; +} diff --git a/src/main/java/com/sequence/anonymous/chat/domain/repository/ChatRepository.java b/src/main/java/com/sequence/anonymous/chat/domain/repository/ChatRepository.java new file mode 100644 index 0000000..63d4610 --- /dev/null +++ b/src/main/java/com/sequence/anonymous/chat/domain/repository/ChatRepository.java @@ -0,0 +1,9 @@ +package com.sequence.anonymous.chat.domain.repository; + +import com.sequence.anonymous.chat.domain.Chat; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface ChatRepository extends JpaRepository { +} diff --git a/src/main/java/com/sequence/anonymous/chat/presentation/ChatController.java b/src/main/java/com/sequence/anonymous/chat/presentation/ChatController.java new file mode 100644 index 0000000..ddd388d --- /dev/null +++ b/src/main/java/com/sequence/anonymous/chat/presentation/ChatController.java @@ -0,0 +1,14 @@ +package com.sequence.anonymous.chat.presentation; + +import com.sequence.anonymous.chat.application.ChatService; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RequiredArgsConstructor +@RestController +@RequestMapping("/chats") +public class ChatController { + + private final ChatService chatService; +} From 37ca4d56068e27ccd6b608115819965cb68e6063 Mon Sep 17 00:00:00 2001 From: ckyeon Date: Wed, 30 Aug 2023 00:51:56 +0900 Subject: [PATCH 11/17] refactor(User): move package user.domain to user.domain.user --- .../com/sequence/anonymous/security/CustomOAuth2User.java | 2 +- .../anonymous/security/CustomOAuth2UserInfoFactory.java | 2 +- .../com/sequence/anonymous/security/CustomOidcUser.java | 2 +- .../anonymous/security/service/CustomOAuth2UserService.java | 4 ++-- .../anonymous/security/service/CustomOidcUserService.java | 4 ++-- .../java/com/sequence/anonymous/user/domain/Gender.java | 6 ------ .../anonymous/user/domain/repository/UserRepository.java | 2 +- .../com/sequence/anonymous/user/domain/user/Gender.java | 6 ++++++ .../anonymous/user/domain/{ => user}/OAuth2Provider.java | 2 +- .../com/sequence/anonymous/user/domain/{ => user}/Role.java | 2 +- .../com/sequence/anonymous/user/domain/{ => user}/User.java | 2 +- 11 files changed, 17 insertions(+), 17 deletions(-) delete mode 100644 src/main/java/com/sequence/anonymous/user/domain/Gender.java create mode 100644 src/main/java/com/sequence/anonymous/user/domain/user/Gender.java rename src/main/java/com/sequence/anonymous/user/domain/{ => user}/OAuth2Provider.java (88%) rename src/main/java/com/sequence/anonymous/user/domain/{ => user}/Role.java (79%) rename src/main/java/com/sequence/anonymous/user/domain/{ => user}/User.java (97%) diff --git a/src/main/java/com/sequence/anonymous/security/CustomOAuth2User.java b/src/main/java/com/sequence/anonymous/security/CustomOAuth2User.java index 2afe54e..e715a95 100644 --- a/src/main/java/com/sequence/anonymous/security/CustomOAuth2User.java +++ b/src/main/java/com/sequence/anonymous/security/CustomOAuth2User.java @@ -1,7 +1,7 @@ package com.sequence.anonymous.security; import com.google.common.base.Preconditions; -import com.sequence.anonymous.user.domain.Role; +import com.sequence.anonymous.user.domain.user.Role; import java.io.Serializable; import java.util.Collection; import java.util.Map; diff --git a/src/main/java/com/sequence/anonymous/security/CustomOAuth2UserInfoFactory.java b/src/main/java/com/sequence/anonymous/security/CustomOAuth2UserInfoFactory.java index 8c41dfa..92ea2de 100644 --- a/src/main/java/com/sequence/anonymous/security/CustomOAuth2UserInfoFactory.java +++ b/src/main/java/com/sequence/anonymous/security/CustomOAuth2UserInfoFactory.java @@ -4,7 +4,7 @@ import com.sequence.anonymous.security.userinfo.GithubOAuth2UserInfo; import com.sequence.anonymous.security.userinfo.GoogleOAuth2UserInfo; import com.sequence.anonymous.security.userinfo.KakaoOAuth2UserInfo; -import com.sequence.anonymous.user.domain.OAuth2Provider; +import com.sequence.anonymous.user.domain.user.OAuth2Provider; import java.util.Map; public class CustomOAuth2UserInfoFactory { diff --git a/src/main/java/com/sequence/anonymous/security/CustomOidcUser.java b/src/main/java/com/sequence/anonymous/security/CustomOidcUser.java index 9da0223..7be2202 100644 --- a/src/main/java/com/sequence/anonymous/security/CustomOidcUser.java +++ b/src/main/java/com/sequence/anonymous/security/CustomOidcUser.java @@ -1,6 +1,6 @@ package com.sequence.anonymous.security; -import com.sequence.anonymous.user.domain.Role; +import com.sequence.anonymous.user.domain.user.Role; import java.util.Map; import org.springframework.security.oauth2.core.oidc.OidcIdToken; import org.springframework.security.oauth2.core.oidc.OidcUserInfo; diff --git a/src/main/java/com/sequence/anonymous/security/service/CustomOAuth2UserService.java b/src/main/java/com/sequence/anonymous/security/service/CustomOAuth2UserService.java index 3648270..c21473a 100644 --- a/src/main/java/com/sequence/anonymous/security/service/CustomOAuth2UserService.java +++ b/src/main/java/com/sequence/anonymous/security/service/CustomOAuth2UserService.java @@ -3,8 +3,8 @@ import com.sequence.anonymous.security.CustomOAuth2User; import com.sequence.anonymous.security.CustomOAuth2UserInfoFactory; import com.sequence.anonymous.security.userinfo.CustomOAuth2UserInfo; -import com.sequence.anonymous.user.domain.OAuth2Provider; -import com.sequence.anonymous.user.domain.User; +import com.sequence.anonymous.user.domain.user.OAuth2Provider; +import com.sequence.anonymous.user.domain.user.User; import com.sequence.anonymous.user.domain.repository.UserRepository; import java.util.Map; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/sequence/anonymous/security/service/CustomOidcUserService.java b/src/main/java/com/sequence/anonymous/security/service/CustomOidcUserService.java index 003fa31..92bf7be 100644 --- a/src/main/java/com/sequence/anonymous/security/service/CustomOidcUserService.java +++ b/src/main/java/com/sequence/anonymous/security/service/CustomOidcUserService.java @@ -3,8 +3,8 @@ import com.sequence.anonymous.security.CustomOAuth2UserInfoFactory; import com.sequence.anonymous.security.CustomOidcUser; import com.sequence.anonymous.security.userinfo.CustomOAuth2UserInfo; -import com.sequence.anonymous.user.domain.OAuth2Provider; -import com.sequence.anonymous.user.domain.User; +import com.sequence.anonymous.user.domain.user.OAuth2Provider; +import com.sequence.anonymous.user.domain.user.User; import com.sequence.anonymous.user.domain.repository.UserRepository; import java.util.Map; import lombok.RequiredArgsConstructor; diff --git a/src/main/java/com/sequence/anonymous/user/domain/Gender.java b/src/main/java/com/sequence/anonymous/user/domain/Gender.java deleted file mode 100644 index 9573224..0000000 --- a/src/main/java/com/sequence/anonymous/user/domain/Gender.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.sequence.anonymous.user.domain; - -public enum Gender { - FEMALE, - MALE -} diff --git a/src/main/java/com/sequence/anonymous/user/domain/repository/UserRepository.java b/src/main/java/com/sequence/anonymous/user/domain/repository/UserRepository.java index 290c406..0edecb8 100644 --- a/src/main/java/com/sequence/anonymous/user/domain/repository/UserRepository.java +++ b/src/main/java/com/sequence/anonymous/user/domain/repository/UserRepository.java @@ -1,6 +1,6 @@ package com.sequence.anonymous.user.domain.repository; -import com.sequence.anonymous.user.domain.User; +import com.sequence.anonymous.user.domain.user.User; import java.util.Optional; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/com/sequence/anonymous/user/domain/user/Gender.java b/src/main/java/com/sequence/anonymous/user/domain/user/Gender.java new file mode 100644 index 0000000..9e7916d --- /dev/null +++ b/src/main/java/com/sequence/anonymous/user/domain/user/Gender.java @@ -0,0 +1,6 @@ +package com.sequence.anonymous.user.domain.user; + +public enum Gender { + FEMALE, + MALE +} diff --git a/src/main/java/com/sequence/anonymous/user/domain/OAuth2Provider.java b/src/main/java/com/sequence/anonymous/user/domain/user/OAuth2Provider.java similarity index 88% rename from src/main/java/com/sequence/anonymous/user/domain/OAuth2Provider.java rename to src/main/java/com/sequence/anonymous/user/domain/user/OAuth2Provider.java index ec4c974..569f435 100644 --- a/src/main/java/com/sequence/anonymous/user/domain/OAuth2Provider.java +++ b/src/main/java/com/sequence/anonymous/user/domain/user/OAuth2Provider.java @@ -1,4 +1,4 @@ -package com.sequence.anonymous.user.domain; +package com.sequence.anonymous.user.domain.user; import org.springframework.security.oauth2.client.userinfo.OAuth2UserRequest; diff --git a/src/main/java/com/sequence/anonymous/user/domain/Role.java b/src/main/java/com/sequence/anonymous/user/domain/user/Role.java similarity index 79% rename from src/main/java/com/sequence/anonymous/user/domain/Role.java rename to src/main/java/com/sequence/anonymous/user/domain/user/Role.java index 3ba617a..87f5bbd 100644 --- a/src/main/java/com/sequence/anonymous/user/domain/Role.java +++ b/src/main/java/com/sequence/anonymous/user/domain/user/Role.java @@ -1,4 +1,4 @@ -package com.sequence.anonymous.user.domain; +package com.sequence.anonymous.user.domain.user; public enum Role { ROLE_USER("USER"), diff --git a/src/main/java/com/sequence/anonymous/user/domain/User.java b/src/main/java/com/sequence/anonymous/user/domain/user/User.java similarity index 97% rename from src/main/java/com/sequence/anonymous/user/domain/User.java rename to src/main/java/com/sequence/anonymous/user/domain/user/User.java index d08a4dd..4e09ac7 100644 --- a/src/main/java/com/sequence/anonymous/user/domain/User.java +++ b/src/main/java/com/sequence/anonymous/user/domain/user/User.java @@ -1,4 +1,4 @@ -package com.sequence.anonymous.user.domain; +package com.sequence.anonymous.user.domain.user; import com.google.common.base.Preconditions; import com.sequence.anonymous.common.BaseEntity; From 9e09ed3e4fa55ad10c8c07780d5f0fcfff7da1bd Mon Sep 17 00:00:00 2001 From: ckyeon Date: Wed, 30 Aug 2023 00:55:34 +0900 Subject: [PATCH 12/17] feat(Tag): add entity --- .../anonymous/user/domain/tag/Tag.java | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/main/java/com/sequence/anonymous/user/domain/tag/Tag.java diff --git a/src/main/java/com/sequence/anonymous/user/domain/tag/Tag.java b/src/main/java/com/sequence/anonymous/user/domain/tag/Tag.java new file mode 100644 index 0000000..683c2f8 --- /dev/null +++ b/src/main/java/com/sequence/anonymous/user/domain/tag/Tag.java @@ -0,0 +1,21 @@ +package com.sequence.anonymous.user.domain.tag; + +import jakarta.persistence.*; +import jakarta.validation.constraints.NotNull; +import lombok.Getter; + +@Getter +@Entity +public class Tag { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(unique = true, insertable = false, updatable = false, length = 10) + @NotNull + private String name; + + protected Tag() { + } +} From 48e5768b4222034ff2f6e22591b0e6cdd74544d9 Mon Sep 17 00:00:00 2001 From: ckyeon Date: Wed, 30 Aug 2023 01:29:05 +0900 Subject: [PATCH 13/17] feat(Tag): add skeleton classes --- .../anonymous/user/application/TagService.java | 12 ++++++++++++ .../user/domain/repository/TagRepository.java | 7 +++++++ .../anonymous/user/presentation/TagController.java | 14 ++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 src/main/java/com/sequence/anonymous/user/application/TagService.java create mode 100644 src/main/java/com/sequence/anonymous/user/domain/repository/TagRepository.java create mode 100644 src/main/java/com/sequence/anonymous/user/presentation/TagController.java diff --git a/src/main/java/com/sequence/anonymous/user/application/TagService.java b/src/main/java/com/sequence/anonymous/user/application/TagService.java new file mode 100644 index 0000000..1c86463 --- /dev/null +++ b/src/main/java/com/sequence/anonymous/user/application/TagService.java @@ -0,0 +1,12 @@ +package com.sequence.anonymous.user.application; + +import com.sequence.anonymous.user.domain.repository.TagRepository; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +@RequiredArgsConstructor +@Service +public class TagService { + + private final TagRepository tagRepository; +} diff --git a/src/main/java/com/sequence/anonymous/user/domain/repository/TagRepository.java b/src/main/java/com/sequence/anonymous/user/domain/repository/TagRepository.java new file mode 100644 index 0000000..7cea0fa --- /dev/null +++ b/src/main/java/com/sequence/anonymous/user/domain/repository/TagRepository.java @@ -0,0 +1,7 @@ +package com.sequence.anonymous.user.domain.repository; + +import com.sequence.anonymous.user.domain.tag.Tag; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface TagRepository extends JpaRepository { +} diff --git a/src/main/java/com/sequence/anonymous/user/presentation/TagController.java b/src/main/java/com/sequence/anonymous/user/presentation/TagController.java new file mode 100644 index 0000000..6c905f2 --- /dev/null +++ b/src/main/java/com/sequence/anonymous/user/presentation/TagController.java @@ -0,0 +1,14 @@ +package com.sequence.anonymous.user.presentation; + +import com.sequence.anonymous.user.application.TagService; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RequiredArgsConstructor +@RestController +@RequestMapping("/tags") +public class TagController { + + private final TagService tagService; +} From c880b0d3b49b9f2a22e48b105e422a75c54a4db0 Mon Sep 17 00:00:00 2001 From: ckyeon Date: Wed, 30 Aug 2023 01:36:47 +0900 Subject: [PATCH 14/17] feat(Chat): move package chat to matchpost --- .../{chat => matchpost}/application/ChatService.java | 4 ++-- .../sequence/anonymous/{chat => matchpost}/domain/Chat.java | 2 +- .../{chat => matchpost}/domain/repository/ChatRepository.java | 4 ++-- .../{chat => matchpost}/presentation/ChatController.java | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) rename src/main/java/com/sequence/anonymous/{chat => matchpost}/application/ChatService.java (60%) rename src/main/java/com/sequence/anonymous/{chat => matchpost}/domain/Chat.java (93%) rename src/main/java/com/sequence/anonymous/{chat => matchpost}/domain/repository/ChatRepository.java (63%) rename src/main/java/com/sequence/anonymous/{chat => matchpost}/presentation/ChatController.java (71%) diff --git a/src/main/java/com/sequence/anonymous/chat/application/ChatService.java b/src/main/java/com/sequence/anonymous/matchpost/application/ChatService.java similarity index 60% rename from src/main/java/com/sequence/anonymous/chat/application/ChatService.java rename to src/main/java/com/sequence/anonymous/matchpost/application/ChatService.java index ebacac8..98609b5 100644 --- a/src/main/java/com/sequence/anonymous/chat/application/ChatService.java +++ b/src/main/java/com/sequence/anonymous/matchpost/application/ChatService.java @@ -1,6 +1,6 @@ -package com.sequence.anonymous.chat.application; +package com.sequence.anonymous.matchpost.application; -import com.sequence.anonymous.chat.domain.repository.ChatRepository; +import com.sequence.anonymous.matchpost.domain.repository.ChatRepository; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; diff --git a/src/main/java/com/sequence/anonymous/chat/domain/Chat.java b/src/main/java/com/sequence/anonymous/matchpost/domain/Chat.java similarity index 93% rename from src/main/java/com/sequence/anonymous/chat/domain/Chat.java rename to src/main/java/com/sequence/anonymous/matchpost/domain/Chat.java index 5731742..46ae6fb 100644 --- a/src/main/java/com/sequence/anonymous/chat/domain/Chat.java +++ b/src/main/java/com/sequence/anonymous/matchpost/domain/Chat.java @@ -1,4 +1,4 @@ -package com.sequence.anonymous.chat.domain; +package com.sequence.anonymous.matchpost.domain; import com.google.common.base.Preconditions; import jakarta.persistence.Entity; diff --git a/src/main/java/com/sequence/anonymous/chat/domain/repository/ChatRepository.java b/src/main/java/com/sequence/anonymous/matchpost/domain/repository/ChatRepository.java similarity index 63% rename from src/main/java/com/sequence/anonymous/chat/domain/repository/ChatRepository.java rename to src/main/java/com/sequence/anonymous/matchpost/domain/repository/ChatRepository.java index 63d4610..a8bfe3e 100644 --- a/src/main/java/com/sequence/anonymous/chat/domain/repository/ChatRepository.java +++ b/src/main/java/com/sequence/anonymous/matchpost/domain/repository/ChatRepository.java @@ -1,6 +1,6 @@ -package com.sequence.anonymous.chat.domain.repository; +package com.sequence.anonymous.matchpost.domain.repository; -import com.sequence.anonymous.chat.domain.Chat; +import com.sequence.anonymous.matchpost.domain.Chat; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/src/main/java/com/sequence/anonymous/chat/presentation/ChatController.java b/src/main/java/com/sequence/anonymous/matchpost/presentation/ChatController.java similarity index 71% rename from src/main/java/com/sequence/anonymous/chat/presentation/ChatController.java rename to src/main/java/com/sequence/anonymous/matchpost/presentation/ChatController.java index ddd388d..494ab6d 100644 --- a/src/main/java/com/sequence/anonymous/chat/presentation/ChatController.java +++ b/src/main/java/com/sequence/anonymous/matchpost/presentation/ChatController.java @@ -1,6 +1,6 @@ -package com.sequence.anonymous.chat.presentation; +package com.sequence.anonymous.matchpost.presentation; -import com.sequence.anonymous.chat.application.ChatService; +import com.sequence.anonymous.matchpost.application.ChatService; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; From 53f88e1e9f623eb2b9716fe50c50f35daa37d6f0 Mon Sep 17 00:00:00 2001 From: ckyeon Date: Wed, 30 Aug 2023 02:08:40 +0900 Subject: [PATCH 15/17] feat(UserTag): add entity --- .../anonymous/user/domain/user/UserTag.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/main/java/com/sequence/anonymous/user/domain/user/UserTag.java diff --git a/src/main/java/com/sequence/anonymous/user/domain/user/UserTag.java b/src/main/java/com/sequence/anonymous/user/domain/user/UserTag.java new file mode 100644 index 0000000..3b8b753 --- /dev/null +++ b/src/main/java/com/sequence/anonymous/user/domain/user/UserTag.java @@ -0,0 +1,39 @@ +package com.sequence.anonymous.user.domain.user; + +import com.google.common.base.Preconditions; +import com.sequence.anonymous.user.domain.tag.Tag; +import jakarta.persistence.*; +import lombok.Getter; + +@Getter +@Entity +public class UserTag { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne + @JoinColumn(name = "user_id") + private User user; + + @ManyToOne + @JoinColumn(name = "tag_id") + private Tag tag; + + protected UserTag() { + } + + public UserTag(User user, Tag tag) { + this(null, user, tag); + } + + private UserTag(Long id, User user, Tag tag) { + Preconditions.checkArgument(user != null, "user must be provided."); + Preconditions.checkArgument(tag != null, "tag must be provided."); + + this.id = id; + this.user = user; + this.tag = tag; + } +} From a783df66889577f67e19d814caa54d20a0147ede Mon Sep 17 00:00:00 2001 From: ckyeon Date: Wed, 30 Aug 2023 02:26:46 +0900 Subject: [PATCH 16/17] feat(UserChat): add entity --- .../anonymous/user/domain/user/UserChat.java | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/main/java/com/sequence/anonymous/user/domain/user/UserChat.java diff --git a/src/main/java/com/sequence/anonymous/user/domain/user/UserChat.java b/src/main/java/com/sequence/anonymous/user/domain/user/UserChat.java new file mode 100644 index 0000000..a85ab59 --- /dev/null +++ b/src/main/java/com/sequence/anonymous/user/domain/user/UserChat.java @@ -0,0 +1,39 @@ +package com.sequence.anonymous.user.domain.user; + +import com.google.common.base.Preconditions; +import com.sequence.anonymous.matchpost.domain.Chat; +import jakarta.persistence.*; +import lombok.Getter; + +@Getter +@Entity +public class UserChat { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne + @JoinColumn(name = "user_id") + private User user; + + @ManyToOne + @JoinColumn(name = "chat_id") + private Chat chat; + + protected UserChat() { + } + + public UserChat(User user, Chat chat) { + this(null, user, chat); + } + + private UserChat(Long id, User user, Chat chat) { + Preconditions.checkArgument(user != null, "user must be provided."); + Preconditions.checkArgument(chat != null, "chat must be provided."); + + this.id = id; + this.user = user; + this.chat = chat; + } +} From 7481d43ffb7bd2093a02905e3161298fd31bb6db Mon Sep 17 00:00:00 2001 From: ckyeon Date: Fri, 15 Sep 2023 00:17:35 +0900 Subject: [PATCH 17/17] refactor(User): change isProfileInitialized column to method --- .../sequence/anonymous/user/domain/user/User.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/sequence/anonymous/user/domain/user/User.java b/src/main/java/com/sequence/anonymous/user/domain/user/User.java index 4e09ac7..09b6760 100644 --- a/src/main/java/com/sequence/anonymous/user/domain/user/User.java +++ b/src/main/java/com/sequence/anonymous/user/domain/user/User.java @@ -37,22 +37,19 @@ public class User extends BaseEntity { private Boolean withdrawal; - private Boolean profileInitialized; - protected User() { } public User(String providerId, OAuth2Provider provider, String email) { - this(null, providerId, provider, email, null, null, null, Role.ROLE_USER, false, false); + this(null, providerId, provider, email, null, null, null, Role.ROLE_USER, false); } - private User(Long id, String providerId, OAuth2Provider provider, String email, String name, Integer age, Gender gender, Role role, Boolean withdrawal, Boolean profileInitialized) { + private User(Long id, String providerId, OAuth2Provider provider, String email, String name, Integer age, Gender gender, Role role, Boolean withdrawal) { Preconditions.checkArgument(providerId != null, "providerId must be provided."); Preconditions.checkArgument(provider != null, "provider must be provided."); Preconditions.checkArgument(email != null, "email must be provided."); Preconditions.checkArgument(role != null, "role must be provided."); Preconditions.checkArgument(withdrawal != null, "withdrawal must be provided."); - Preconditions.checkArgument(profileInitialized != null, "initialized must be provided."); this.id = id; this.providerId = providerId; @@ -63,7 +60,6 @@ private User(Long id, String providerId, OAuth2Provider provider, String email, this.email = email; this.role = role; this.withdrawal = withdrawal; - this.profileInitialized = profileInitialized; } public void initializeProfile(String name, Integer age, Gender gender) { @@ -74,7 +70,9 @@ public void initializeProfile(String name, Integer age, Gender gender) { this.name = name; this.age = age; this.gender = gender; + } - this.profileInitialized = true; + public boolean isProfileInitialized() { + return (name != null) && (age != null) && (gender != null); } }