package com.lincfusion.udyamlinc.master; import jakarta.persistence.*; import lombok.*; /** Console RBAC. Permissions are a comma-separated set of MODULE:ACTION keys. */ @Entity @Table(name = "role", indexes = @Index(name = "ix_role_code", columnList = "code", unique = true)) @Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder public class Role { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; /** FIELD_OFFICER | SUPERVISOR | OWNER */ @Column(nullable = false, unique = true, length = 32) private String code; @Column(nullable = false, length = 64) private String name; /** e.g. "PORTFOLIO:VIEW,ALERT:ACT,VISIT:LOG" */ @Column(length = 600) private String permissions; /** System roles cannot be deleted from the console. */ private Boolean systemRole; private Boolean active; @PrePersist void onCreate() { if (active == null) active = Boolean.TRUE; if (systemRole == null) systemRole = Boolean.FALSE; } }