#16 board : change entity, erd
This commit is contained in:
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 29 KiB |
@@ -0,0 +1,18 @@
|
||||
package com.example.board.config;
|
||||
|
||||
import com.example.board.domain.UserAccount;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.rest.webmvc.config.RepositoryRestConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class DataRestConfig {
|
||||
|
||||
@Bean
|
||||
public RepositoryRestConfigurer repositoryRestConfigurer() {
|
||||
return RepositoryRestConfigurer.withConfig((config, cors) ->
|
||||
config.exposeIdsFor(UserAccount.class)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,7 +26,8 @@ public class Article extends AuditingFields {
|
||||
|
||||
@Setter
|
||||
@ManyToOne(optional = false)
|
||||
private UserAccount userAccount;
|
||||
@JoinColumn(name = "userId")
|
||||
private UserAccount userAccount; // 유저 정보 (ID)
|
||||
|
||||
@Setter
|
||||
@Column(nullable = false)
|
||||
|
||||
@@ -23,6 +23,7 @@ public class ArticleComment extends AuditingFields {
|
||||
|
||||
@Setter
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(name = "userId")
|
||||
private UserAccount userAccount;
|
||||
|
||||
@Setter
|
||||
|
||||
@@ -18,12 +18,9 @@ import java.util.Objects;
|
||||
@Entity
|
||||
public class UserAccount extends AuditingFields {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Setter
|
||||
@Column(nullable = false, length = 50)
|
||||
@Column(length = 50)
|
||||
private String userId;
|
||||
|
||||
@Setter
|
||||
@Column(nullable = false)
|
||||
private String userPassword;
|
||||
@@ -56,12 +53,12 @@ public class UserAccount extends AuditingFields {
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof UserAccount userAccount)) return false;
|
||||
return id != null && id.equals(userAccount.id);
|
||||
return userId != null && userId.equals(userAccount.userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id);
|
||||
return Objects.hash(userId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import com.example.board.domain.UserAccount;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
public record UserAccountDto(
|
||||
Long id,
|
||||
String userId,
|
||||
String userPassword,
|
||||
String email,
|
||||
@@ -16,17 +15,16 @@ public record UserAccountDto(
|
||||
LocalDateTime modifiedAt,
|
||||
String modifiedBy
|
||||
) {
|
||||
public static UserAccountDto of(Long id, String userId, String userPassword, String email, String nickname, String memo) {
|
||||
return new UserAccountDto(id, userId, userPassword, email, nickname, memo, null, null, null, null);
|
||||
public static UserAccountDto of(String userId, String userPassword, String email, String nickname, String memo) {
|
||||
return new UserAccountDto(userId, userPassword, email, nickname, memo, null, null, null, null);
|
||||
}
|
||||
|
||||
public static UserAccountDto of(Long id, String userId, String userPassword, String email, String nickname, String memo, LocalDateTime createdAt, String createdBy, LocalDateTime modifiedAt, String modifiedBy) {
|
||||
return new UserAccountDto(id, userId, userPassword, email, nickname, memo, createdAt, createdBy, modifiedAt, modifiedBy);
|
||||
public static UserAccountDto of(String userId, String userPassword, String email, String nickname, String memo, LocalDateTime createdAt, String createdBy, LocalDateTime modifiedAt, String modifiedBy) {
|
||||
return new UserAccountDto(userId, userPassword, email, nickname, memo, createdAt, createdBy, modifiedAt, modifiedBy);
|
||||
}
|
||||
|
||||
public static UserAccountDto from(UserAccount entity) {
|
||||
return new UserAccountDto(
|
||||
entity.getId(),
|
||||
entity.getUserId(),
|
||||
entity.getUserPassword(),
|
||||
entity.getEmail(),
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -225,7 +225,6 @@ class ArticleControllerTest {
|
||||
|
||||
private UserAccountDto createUserAccountDto() {
|
||||
return UserAccountDto.of(
|
||||
1L,
|
||||
"bobby",
|
||||
"1234",
|
||||
"bobby@email.com",
|
||||
|
||||
@@ -148,7 +148,6 @@ class ArticleCommentServiceTest {
|
||||
|
||||
private UserAccountDto createUserAccountDto() {
|
||||
return UserAccountDto.of(
|
||||
1L,
|
||||
"bobby",
|
||||
"password",
|
||||
"bobby@mail.com",
|
||||
|
||||
@@ -247,7 +247,6 @@ class ArticleServiceTest {
|
||||
|
||||
private UserAccountDto createUserAccountDto() {
|
||||
return UserAccountDto.of(
|
||||
1L,
|
||||
"bobby",
|
||||
"password",
|
||||
"bobby@mail.com",
|
||||
|
||||
Reference in New Issue
Block a user