사용자 역할 변경 이력 엔티티 및 레포지토리 추가:
eapim-portal CI (from elink-portal-common) / build (push) Has been cancelled

- UserRoleHistory 엔티티 정의 및 필드 매핑
- UserRoleHistoryRepository 조회 메서드 구현
This commit is contained in:
Rinjae
2026-07-27 20:11:20 +09:00
parent 94724d3952
commit e3619b385f
2 changed files with 89 additions and 0 deletions
@@ -0,0 +1,76 @@
package com.eactive.apim.portal.portaluser.entity;
import com.eactive.eai.data.converter.LocalDateTimeToStringConverter14;
import lombok.Data;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.Parameter;
import org.hibernate.annotations.GenericGenerator;
import javax.persistence.*;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* 사용자 역할(권한) 변경 감사 이력.
*
* <p>법인 관리자 위임/회수, 소속 제외 등으로 {@code PortalUser.roleCode} 가 변경될 때
* 이전 역할 → 새 역할, 변경 유형, 변경 수행자(관리자)를 이력으로 남긴다.
* {@link UserPasswordHistory} 와 동일한 저장 패턴(시퀀스 PK, 14자리 문자열 일시)을 따른다.</p>
*/
@Data
@Entity
@Table(name = "ptl_user_role_history")
public class UserRoleHistory implements Serializable, com.eactive.eai.data.Data {
private static final long serialVersionUID = 1L;
@Id
@GenericGenerator(
name = "ptl_user_role_history_seq_gen",
strategy = "com.eactive.eai.rms.data.jpa.SchemaPrefixedSequenceGenerator",
parameters = {
@Parameter(name = "sequence_name", value = "PTL_USER_ROLE_HISTORY_SEQ"),
@Parameter(name = "initial_value", value = "1"),
@Parameter(name = "increment_size", value = "1")
}
)
@GeneratedValue(
strategy = GenerationType.SEQUENCE,
generator = "ptl_user_role_history_seq_gen"
)
@Column(name = "id", columnDefinition = "number(19)")
private Long id;
@Column(name = "user_id", length = 255, nullable = false)
@Comment("대상 사용자 ID(loginId)")
private String userId;
@Column(name = "before_role", length = 30)
@Comment("변경 전 역할")
private String beforeRole;
@Column(name = "after_role", length = 30, nullable = false)
@Comment("변경 후 역할")
private String afterRole;
@Column(name = "change_type", length = 30, nullable = false)
@Comment("변경 유형(MANAGER_ASSIGN/MANAGER_REVOKE/ORG_REMOVE 등)")
private String changeType;
@Column(name = "changed_by", length = 255, nullable = false)
@Comment("변경 수행자(loginId)")
private String changedBy;
@Column(name = "change_date", length = 14, nullable = false)
@Comment("변경 일시")
@Convert(converter = LocalDateTimeToStringConverter14.class)
private LocalDateTime changeDate;
@Column(name = "created_by", length = 255, nullable = false)
@Comment("생성자")
private String createdBy;
@Column(name = "created_date", length = 14, nullable = false)
@Comment("생성일시")
@Convert(converter = LocalDateTimeToStringConverter14.class)
private LocalDateTime createdDate;
}
@@ -0,0 +1,13 @@
package com.eactive.apim.portal.portaluser.repository;
import com.eactive.apim.portal.portaluser.entity.UserRoleHistory;
import com.eactive.eai.rms.data.EMSDataSource;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
@EMSDataSource
public interface UserRoleHistoryRepository extends JpaRepository<UserRoleHistory, Long> {
List<UserRoleHistory> findByUserIdOrderByChangeDateDesc(String userId);
}