diff --git a/src/main/java/wanted/media/user/controller/UserController.java b/src/main/java/wanted/media/user/controller/UserController.java new file mode 100644 index 0000000..867ccff --- /dev/null +++ b/src/main/java/wanted/media/user/controller/UserController.java @@ -0,0 +1,14 @@ +package wanted.media.user.controller; + +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import wanted.media.user.service.UserService; + +@RestController +@RequestMapping("/user") +@RequiredArgsConstructor +public class UserController { + + private final UserService userService; +} diff --git a/src/main/java/wanted/media/user/domain/Code.java b/src/main/java/wanted/media/user/domain/Code.java new file mode 100644 index 0000000..75bd557 --- /dev/null +++ b/src/main/java/wanted/media/user/domain/Code.java @@ -0,0 +1,34 @@ +package wanted.media.user.domain; + +import jakarta.persistence.*; +import jakarta.validation.constraints.Size; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import org.springframework.data.annotation.CreatedDate; + +import java.time.LocalDateTime; + +@NoArgsConstructor +@AllArgsConstructor +@Getter +@Entity +@Table(name = "codes") +public class Code { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(nullable = false) + private Long codeId; + + @OneToOne + @JoinColumn(name = "user_id") + private User user; + + @Size(max = 10) + @Column(nullable = false) + private String authCode; + + @CreatedDate + private LocalDateTime createdTime; +} diff --git a/src/main/java/wanted/media/user/domain/Grade.java b/src/main/java/wanted/media/user/domain/Grade.java new file mode 100644 index 0000000..f52dd75 --- /dev/null +++ b/src/main/java/wanted/media/user/domain/Grade.java @@ -0,0 +1,5 @@ +package wanted.media.user.domain; + +public enum Grade { + NORMAL_USER, PREMIUM_USER; +} diff --git a/src/main/java/wanted/media/user/domain/Token.java b/src/main/java/wanted/media/user/domain/Token.java new file mode 100644 index 0000000..81fc2f5 --- /dev/null +++ b/src/main/java/wanted/media/user/domain/Token.java @@ -0,0 +1,26 @@ +package wanted.media.user.domain; + +import jakarta.persistence.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; + +@NoArgsConstructor +@AllArgsConstructor +@Getter +@Entity +@Table(name = "tokens") +public class Token { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(nullable = false) + private Long tokenId; + + @Column(nullable = false) + private String refreshToken; + + @ManyToOne(fetch = FetchType.LAZY) + @JoinColumn(name = "user_id", nullable = false) + private User user; +} diff --git a/src/main/java/wanted/media/user/domain/User.java b/src/main/java/wanted/media/user/domain/User.java index e415dfd..4e2b0a0 100644 --- a/src/main/java/wanted/media/user/domain/User.java +++ b/src/main/java/wanted/media/user/domain/User.java @@ -1,8 +1,10 @@ package wanted.media.user.domain; import jakarta.persistence.*; +import jakarta.validation.constraints.Size; import lombok.AllArgsConstructor; import lombok.Builder; +import lombok.Getter; import lombok.NoArgsConstructor; import java.util.UUID; @@ -11,6 +13,7 @@ @AllArgsConstructor @Builder @Entity +@Getter @Table(name = "users") public class User { @Id @@ -18,4 +21,19 @@ public class User { @Column(name = "user_id", nullable = false) private UUID userId; + @Column(unique = true, nullable = false) + @Size(max = 50) + private String account; + + @Size(max = 200) + @Column(nullable = false) + private String email; + + @Size(max = 200) + @Column(nullable = false) + private String password; + + @Enumerated(EnumType.STRING) + @Column(nullable = false) + private Grade grade; } diff --git a/src/main/java/wanted/media/user/repository/UserRepository.java b/src/main/java/wanted/media/user/repository/UserRepository.java new file mode 100644 index 0000000..51fa606 --- /dev/null +++ b/src/main/java/wanted/media/user/repository/UserRepository.java @@ -0,0 +1,9 @@ +package wanted.media.user.repository; + +import org.springframework.data.jpa.repository.JpaRepository; +import wanted.media.user.domain.User; + +import java.util.UUID; + +public interface UserRepository extends JpaRepository { +} diff --git a/src/main/java/wanted/media/user/service/UserService.java b/src/main/java/wanted/media/user/service/UserService.java new file mode 100644 index 0000000..e642526 --- /dev/null +++ b/src/main/java/wanted/media/user/service/UserService.java @@ -0,0 +1,12 @@ +package wanted.media.user.service; + +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; +import wanted.media.user.repository.UserRepository; + +@Service +@RequiredArgsConstructor +public class UserService { + + private final UserRepository userRepository; +}