[회원 역할 제거] MemberRole 관련 코드 삭제제

This commit is contained in:
2025-08-27 16:29:08 +09:00
parent 31aed4bda0
commit 92be6caf80
10 changed files with 13 additions and 75 deletions

View File

@@ -69,7 +69,6 @@
oid bigint not null,
updated_at timestamp(6) not null,
updated_oid bigint,
role varchar(40) not null check (role in ('MEMBER','ADMIN','SYSTEM_ADMIN')),
login_ip varchar(45),
name varchar(100) not null,
password varchar(100) not null,

View File

@@ -14,6 +14,5 @@ import java.time.LocalDateTime;
public class LoginResponseDto {
private String userId;
private String role;
private LocalDateTime lastLoginAt;
}

View File

@@ -1,6 +1,5 @@
package com.bio.bio_backend.domain.base.member.dto;
import com.bio.bio_backend.domain.base.member.enums.MemberRole;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@@ -24,7 +23,6 @@ public class MemberDto implements UserDetails {
private String password;
private String name;
private String email;
private MemberRole role;
private Boolean useFlag;
private String refreshToken;
private String loginIp;
@@ -34,7 +32,7 @@ public class MemberDto implements UserDetails {
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return Collections.singletonList(new SimpleGrantedAuthority("ROLE_" + this.role.getValue()));
return Collections.singletonList(new SimpleGrantedAuthority("ROLE_USER"));
}
@Override

View File

@@ -1,6 +1,5 @@
package com.bio.bio_backend.domain.base.member.entity;
import com.bio.bio_backend.domain.base.member.enums.MemberRole;
import com.bio.bio_backend.global.constants.AppConstants;
import com.bio.bio_backend.global.entity.BaseEntity;
import jakarta.persistence.*;
@@ -37,9 +36,7 @@ public class Member extends BaseEntity {
@Column(name = "email", nullable = false, length = 255)
private String email;
@Enumerated(EnumType.STRING)
@Column(name = "role", nullable = false, length = 40)
private MemberRole role;
@Column(name = "use_flag", nullable = false)
@Builder.Default

View File

@@ -1,38 +0,0 @@
package com.bio.bio_backend.domain.base.member.enums;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
/**
* 회원 역할을 정의하는 Enum
*/
@Getter
@RequiredArgsConstructor
public enum MemberRole {
MEMBER("MEMBER", "일반 회원"),
ADMIN("ADMIN", "관리자"),
SYSTEM_ADMIN("SYSTEM_ADMIN", "시스템 관리자");
private final String value;
private final String description;
/**
* 문자열 값으로부터 MemberRole을 찾는 메서드
*/
public static MemberRole fromValue(String value) {
for (MemberRole role : values()) {
if (role.value.equals(value)) {
return role;
}
}
throw new IllegalArgumentException("Unknown MemberRole value: " + value);
}
/**
* 기본 역할 반환
*/
public static MemberRole getDefault() {
return MEMBER;
}
}

View File

@@ -16,10 +16,9 @@ public interface MemberMapper {
/**
* CreateMemberRequestDto를 MemberDto로 변환
* 기본값 설정: role = MemberRole.MEMBER, useFlag = true
* 기본값 설정: useFlag = true
*/
@Mapping(target = "oid", ignore = true)
@Mapping(target = "role", expression = "java(com.bio.bio_backend.domain.base.member.enums.MemberRole.getDefault())")
@Mapping(target = "useFlag", constant = "true")
@Mapping(target = "refreshToken", ignore = true)
@Mapping(target = "loginIp", ignore = true)

View File

@@ -2,7 +2,6 @@ package com.bio.bio_backend.domain.base.member.service;
import com.bio.bio_backend.domain.base.member.dto.MemberDto;
import com.bio.bio_backend.domain.base.member.entity.Member;
import com.bio.bio_backend.domain.base.member.enums.MemberRole;
import com.bio.bio_backend.domain.base.member.mapper.MemberMapper;
import com.bio.bio_backend.domain.base.member.repository.MemberRepository;
import com.bio.bio_backend.global.exception.ApiException;
@@ -50,7 +49,6 @@ public class MemberServiceImpl implements MemberService {
.password(bCryptPasswordEncoder.encode(memberDto.getPassword()))
.name(memberDto.getName())
.email(memberDto.getEmail())
.role(MemberRole.getDefault())
.build();
member.setCreatedOid(AppConstants.ADMIN_OID);

View File

@@ -64,8 +64,8 @@ public class JwtTokenIssuanceFilter extends UsernamePasswordAuthenticationFilter
MemberDto member = (MemberDto) userDetails;
// 토큰 생성
String accessToken = jwtUtils.createAccessToken(member.getUserId(), member.getRole().getValue());
String refreshToken = jwtUtils.createRefreshToken(member.getUserId(), member.getRole().getValue(), httpUtils.getClientIp());
String accessToken = jwtUtils.createAccessToken(member.getUserId());
String refreshToken = jwtUtils.createRefreshToken(member.getUserId(), httpUtils.getClientIp());
member.setRefreshToken(refreshToken);
member.setLoginIp(httpUtils.getClientIp());
@@ -85,7 +85,6 @@ public class JwtTokenIssuanceFilter extends UsernamePasswordAuthenticationFilter
LoginResponseDto memberData = new LoginResponseDto();
memberData.setUserId(member.getUserId());
memberData.setRole(member.getRole().getValue());
memberData.setLastLoginAt(member.getLastLoginAt());
// login 성공 메시지 전송

View File

@@ -36,10 +36,9 @@ public class JwtUtils {
}
// Token 생성
public String generateToken(String username, String role, long expirationTime) {
public String generateToken(String username, long expirationTime) {
return Jwts.builder()
.subject(username)
.claim("role", role)
.issuedAt(new Date(System.currentTimeMillis()))
.expiration(new Date(System.currentTimeMillis() + expirationTime))
.signWith(getSigningKey())
@@ -47,10 +46,9 @@ public class JwtUtils {
}
// Token 생성(IP 정보 포함)
public String generateToken(String username, String role, String clientIp, long expirationTime) {
public String generateToken(String username, String clientIp, long expirationTime) {
return Jwts.builder()
.subject(username)
.claim("role", role)
.claim("ip", clientIp) // IP 정보 추가
.issuedAt(new Date(System.currentTimeMillis()))
.expiration(new Date(System.currentTimeMillis() + expirationTime))
@@ -59,15 +57,15 @@ public class JwtUtils {
}
// Access Token 생성
public String createAccessToken(String username, String role) {
public String createAccessToken(String username) {
long expirationTime = Long.parseLong(Objects.requireNonNull(env.getProperty("token.expiration_time_access")));
return generateToken(username, role, expirationTime);
return generateToken(username, expirationTime);
}
// Refresh Token 생성 시 IP 정보 포함
public String createRefreshToken(String username, String role, String clientIp) {
public String createRefreshToken(String username, String clientIp) {
long expirationTime = Long.parseLong(Objects.requireNonNull(env.getProperty("token.expiration_time_refresh")));
return generateToken(username, role, clientIp, expirationTime);
return generateToken(username, clientIp, expirationTime);
}
// Token 검증
@@ -126,11 +124,7 @@ public class JwtUtils {
return extractAllClaims(token).getSubject();
}
// Role 정보 추출
public String extractRole(String token) {
Claims claims = extractAllClaims(token);
return claims.get("role", String.class);
}
public Claims extractAllClaims(String token) {
return Jwts.parser()

View File

@@ -57,12 +57,5 @@ public class SecurityUtils {
return authentication != null && authentication.isAuthenticated();
}
/**
* 현재 인증된 사용자의 역할을 반환합니다.
* @return 역할 문자열
*/
public static String getCurrentUserRole() {
MemberDto member = getCurrentMember();
return member != null ? member.getRole().name() : null;
}
}