Files
online-backend/internal/identity/role/dto.go
GuwandykA 323e131216
Some checks failed
CI/CD / Vet, test, build (push) Has been cancelled
CI/CD / Docker image (push) Has been cancelled
CI/CD / Deploy binary to server (push) Has been cancelled
changed role permission
2026-09-26 16:34:28 +05:00

57 lines
1.7 KiB
Go

package role
import (
"time"
"online-back/internal/identity/rbac"
"online-back/internal/identity/rbac/perm"
)
type RoleDTO struct {
Id int64 `json:"id"`
Code string `json:"code"`
Name string `json:"name"`
Scope rbac.Scope `json:"scope"`
IsSuper bool `json:"isSuper"`
IsSystem bool `json:"isSystem"`
Permissions []perm.Code `json:"permissions"`
UsersCount int64 `json:"usersCount"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
func (r RoleDTO) Info() rbac.RoleInfo {
return rbac.RoleInfo{
ID: r.Id, Code: r.Code, Scope: r.Scope, IsSuper: r.IsSuper, IsSystem: r.IsSystem, Perms: r.Permissions,
}
}
// CreateRoleDTO: scope is own (clients, only their records), branch (the
// user's branch_user branches) or all (every branch). Permissions are
// module codes from GET /permissions.
type CreateRoleDTO struct {
Code string `json:"code" binding:"required,max=64"`
Name string `json:"name" binding:"required"`
Scope rbac.Scope `json:"scope" binding:"required,oneof=own branch all"`
Permissions []perm.Code `json:"permissions" binding:"required"`
}
// UpdateRoleDTO replaces name, scope and the whole permission set. The code
// is fixed at create time.
type UpdateRoleDTO struct {
Name string `json:"name" binding:"required"`
Scope rbac.Scope `json:"scope" binding:"required,oneof=own branch all"`
Permissions []perm.Code `json:"permissions" binding:"required"`
}
type ListFilter struct {
RoleName string
Page int
Limit int
}
type ListRoleDTO struct {
Count int64 `json:"count"`
Roles []RoleDTO `json:"roles"`
}