Yimaru-BackEnd/internal/domain/rbac.go

64 lines
1.6 KiB
Go

package domain
import "time"
type Permission struct {
ID int64 `json:"id"`
Key string `json:"key"`
Name string `json:"name"`
Description string `json:"description"`
GroupName string `json:"group_name"`
CreatedAt time.Time `json:"created_at"`
}
type RoleRecord struct {
ID int64 `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
IsSystem bool `json:"is_system"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at,omitempty"`
}
type RoleWithPermissions struct {
RoleRecord
Permissions []Permission `json:"permissions"`
}
type RoleListFilter struct {
Query string
IsSystem *bool
Page int64
PageSize int64
}
type CreateRoleReq struct {
Name string `json:"name" validate:"required,min=2,max=100"`
Description string `json:"description"`
}
type UpdateRoleReq struct {
Name string `json:"name" validate:"required,min=2,max=100"`
Description string `json:"description"`
}
type SetRolePermissionsReq struct {
PermissionIDs []int64 `json:"permission_ids" validate:"required"`
}
type PermissionSeed struct {
Key string
Name string
Description string
GroupName string
}
// Activity log constants for RBAC
const (
ActionRoleCreated ActivityAction = "ROLE_CREATED"
ActionRoleUpdated ActivityAction = "ROLE_UPDATED"
ActionRoleDeleted ActivityAction = "ROLE_DELETED"
ActionRolePermissionsSet ActivityAction = "ROLE_PERMISSIONS_SET"
ResourceRole ResourceType = "ROLE"
)