package entity import ( "time" "gorm.io/gorm" ) // 数据范围并集优先级(数值越大权限越大) const ( DataScopeSelf int16 = 1 DataScopeDept int16 = 2 DataScopeDeptTree int16 = 3 DataScopeAll int16 = 4 ) // Role 角色 iam_role type Role struct { ID string `json:"id" gorm:"primaryKey;type:varchar(36);not null"` TenantID string `json:"tenant_id" gorm:"size:36;not null;index:idx_role_tenant"` RoleCode string `json:"role_code" gorm:"size:64;not null"` RoleName string `json:"role_name" gorm:"size:128;not null"` DataScope int16 `json:"data_scope" gorm:"default:4"` // 1本人 2本部门 3本部门及子部门 4全部 Description string `json:"description" gorm:"size:512"` IsBuiltin bool `json:"is_builtin" gorm:"default:false"` Status int16 `json:"status" gorm:"default:1"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt gorm.DeletedAt `json:"-" gorm:"index"` } func (Role) TableName() string { return "iam_role" } // RoleMenu 角色菜单 iam_role_menu type RoleMenu struct { ID string `json:"id" gorm:"primaryKey;type:varchar(36);not null"` RoleID string `json:"role_id" gorm:"size:36;not null;uniqueIndex:uk_role_menu"` MenuID string `json:"menu_id" gorm:"size:36;not null;uniqueIndex:uk_role_menu"` CreatedAt time.Time `json:"created_at"` } func (RoleMenu) TableName() string { return "iam_role_menu" }