-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat] users 공통 코드 작성 #7
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
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 org.springframework.data.annotation.CreatedDate; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Getter | ||
@Builder | ||
@Entity | ||
@Table(name = "codes") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DB 테이블을 추가하셨다면 노션에 ERD도 변경 해주시면 좋을 것 같아요 ~ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 노션에 추가해놓겠습니다! |
||
public class Code { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "code_id", nullable = false) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
private Long codeId; | ||
|
||
@OneToOne | ||
@JoinColumn(name = "user_id") | ||
private User user; | ||
|
||
@Size(max = 10) | ||
@Column(name = "auth_code", nullable = false) | ||
private String authCode; | ||
|
||
@CreatedDate | ||
@Column(name = "created_time") | ||
private LocalDateTime createdTime; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package wanted.media.user.domain; | ||
|
||
public enum Grade { | ||
NORMAL_USER, PREMIUM_USER; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package wanted.media.user.domain; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@Getter | ||
@Builder | ||
@Entity | ||
@Table(name = "tokens") | ||
public class Token { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name = "token_id", nullable = false) | ||
private Long tokenId; | ||
|
||
@Column(name = "refresh_token", nullable = false) | ||
private String refreshToken; | ||
|
||
@ManyToOne | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여기도 즉시로딩과 지연로딩에 대해 찾아보시고 적용해주시면 좋을 것 같습니다! |
||
@JoinColumn(name = "user_id", nullable = false) | ||
private User user; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package wanted.media.user.repository; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
import wanted.media.user.domain.User; | ||
|
||
import java.util.UUID; | ||
|
||
@Repository | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여기도 어노테이션 제거 해주셔도 됩니다~ |
||
public interface UserRepository extends JpaRepository<User, UUID> { | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Builder
는 사용하실 때 달아두면 좋을 것 같습니다 ~