[회원 정보 업데이트] Member 엔티티에 name 및 email 필드 추가, 관련 DTO 및 서비스 로직 수정. 사용자 역할에서 USER 제거 및 검증 어노테이션 추가.

This commit is contained in:
2025-08-22 10:48:14 +09:00
parent 9e7929da6b
commit a4c14c69f0
6 changed files with 25 additions and 16 deletions

View File

@@ -7,10 +7,12 @@
oid bigint not null,
updated_at timestamp(6) not null,
updated_oid bigint,
role varchar(40) not null check (role in ('MEMBER','ADMIN','USER','SYSTEM_ADMIN')),
role varchar(40) not null check (role in ('MEMBER','ADMIN','SYSTEM_ADMIN')),
name varchar(100) not null,
password varchar(100) not null,
user_id varchar(100) not null,
refresh_token varchar(200),
email varchar(255) not null,
primary key (oid)
);

View File

@@ -6,6 +6,7 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Email;
@Data
@Builder
@@ -18,4 +19,11 @@ public class CreateMemberRequestDto {
@NotBlank(message = "비밀번호는 필수입니다.")
private String password;
@NotBlank(message = "사용자명은 필수입니다.")
private String name;
@NotBlank(message = "이메일은 필수입니다.")
@Email(message = "올바른 이메일 형식이 아닙니다.")
private String email;
}

View File

@@ -22,6 +22,8 @@ public class MemberDto implements UserDetails {
private Long oid;
private String userId;
private String password;
private String name;
private String email;
private MemberRole role;
private Boolean useFlag;
private String refreshToken;
@@ -39,21 +41,11 @@ public class MemberDto implements UserDetails {
return this.userId;
}
@Override
public boolean isAccountNonExpired() {
return true;
}
@Override
public boolean isAccountNonLocked() {
return this.useFlag != null && this.useFlag;
}
@Override
public boolean isCredentialsNonExpired() {
return true;
}
@Override
public boolean isEnabled() {
return this.useFlag != null && this.useFlag;

View File

@@ -30,6 +30,12 @@ public class Member extends BaseEntity {
@Column(name = "password", nullable = false, length = 100)
private String password;
@Column(name = "name", nullable = false, length = 100)
private String name;
@Column(name = "email", nullable = false, length = 255)
private String email;
@Enumerated(EnumType.STRING)
@Column(name = "role", nullable = false, length = 40)
private MemberRole role;

View File

@@ -12,7 +12,6 @@ public enum MemberRole {
MEMBER("MEMBER", "일반 회원"),
ADMIN("ADMIN", "관리자"),
USER("USER", "사용자"),
SYSTEM_ADMIN("SYSTEM_ADMIN", "시스템 관리자");
private final String value;

View File

@@ -43,15 +43,17 @@ public class MemberServiceImpl implements MemberService {
@Override
@Transactional
public MemberDto createMember(MemberDto memberDTO) {
public MemberDto createMember(MemberDto memberDto) {
// userId 중복 체크
if (memberRepository.existsByUserId(memberDTO.getUserId())) {
if (memberRepository.existsByUserId(memberDto.getUserId())) {
throw new ApiException(ApiResponseCode.USER_ID_DUPLICATE);
}
Member member = Member.builder()
.userId(memberDTO.getUserId())
.password(bCryptPasswordEncoder.encode(memberDTO.getPassword()))
.userId(memberDto.getUserId())
.password(bCryptPasswordEncoder.encode(memberDto.getPassword()))
.name(memberDto.getName())
.email(memberDto.getEmail())
.role(MemberRole.getDefault())
.build();