TA 역할 Spring 경계 smoke (role-ta-live-1522-001)
This commit is contained in:
parent
d23319f837
commit
8ef79bc9ae
1 changed files with 69 additions and 0 deletions
|
|
@ -0,0 +1,69 @@
|
|||
package com.klaroworks.runtime.rolematrix.domain;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/** 역할 매트릭스 엔티티 */
|
||||
@Entity
|
||||
@Table(name = "role_matrices")
|
||||
public class RoleMatrix {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable = false, unique = true)
|
||||
private String name;
|
||||
|
||||
@Column(length = 1000)
|
||||
private String description;
|
||||
|
||||
@ElementCollection(fetch = FetchType.EAGER)
|
||||
@CollectionTable(name = "role_matrix_permissions", joinColumns = @JoinColumn(name = "role_matrix_id"))
|
||||
@Column(name = "permission_id")
|
||||
private List<String> permissionIds = new ArrayList<>();
|
||||
|
||||
@Column(nullable = false, updatable = false)
|
||||
private Instant createdAt;
|
||||
|
||||
@Column(nullable = false)
|
||||
private Instant updatedAt;
|
||||
|
||||
@Version
|
||||
private Long version;
|
||||
|
||||
protected RoleMatrix() {}
|
||||
|
||||
private RoleMatrix(String name, String description) {
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.createdAt = Instant.now();
|
||||
this.updatedAt = Instant.now();
|
||||
}
|
||||
|
||||
public static RoleMatrix create(String name, String description) {
|
||||
return new RoleMatrix(name, description);
|
||||
}
|
||||
|
||||
public void update(String name, String description) {
|
||||
if (name != null) this.name = name;
|
||||
if (description != null) this.description = description;
|
||||
this.updatedAt = Instant.now();
|
||||
}
|
||||
|
||||
public void syncPermissions(List<String> permissionIds) {
|
||||
this.permissionIds.clear();
|
||||
if (permissionIds != null) this.permissionIds.addAll(permissionIds);
|
||||
this.updatedAt = Instant.now();
|
||||
}
|
||||
|
||||
public Long getId() { return id; }
|
||||
public String getName() { return name; }
|
||||
public String getDescription() { return description; }
|
||||
public List<String> getPermissionIds() { return List.copyOf(permissionIds); }
|
||||
public Instant getCreatedAt() { return createdAt; }
|
||||
public Instant getUpdatedAt() { return updatedAt; }
|
||||
public Long getVersion() { return version; }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue