add role based permissions
This commit is contained in:
@@ -9,9 +9,8 @@ import (
|
||||
type PermissionResponse struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
Code string `json:"code"`
|
||||
Action string `json:"action,omitempty"`
|
||||
Description *string `json:"description,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
type CreatePermissionRequest struct {
|
||||
@@ -55,3 +54,54 @@ type UpdateRoleRequest struct {
|
||||
type ListRolesResponse struct {
|
||||
Roles []RoleWithPermissionsResponse `json:"roles"`
|
||||
}
|
||||
|
||||
// Module contracts
|
||||
type ModuleResponse struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Code string `json:"code"`
|
||||
}
|
||||
|
||||
type ModuleWithPermissionsResponse struct {
|
||||
Module ModuleResponse `json:"module"`
|
||||
Permissions []PermissionResponse `json:"permissions"`
|
||||
}
|
||||
|
||||
type PermissionsGroupedResponse struct {
|
||||
Data []ModuleWithPermissionsResponse `json:"data"`
|
||||
}
|
||||
|
||||
// New Role contracts for the required API
|
||||
type ModulePermissionInput struct {
|
||||
Module string `json:"module" binding:"required"`
|
||||
Actions []string `json:"actions" binding:"required"`
|
||||
}
|
||||
|
||||
type CreateOrUpdateRoleRequest struct {
|
||||
Name string `json:"name" binding:"required"`
|
||||
Code string `json:"code" binding:"required"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Permissions []ModulePermissionInput `json:"permissions" binding:"required"`
|
||||
}
|
||||
|
||||
type RoleDetailResponse struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Code string `json:"code"`
|
||||
Description string `json:"description,omitempty"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
Permissions []RolePermissionModuleResponse `json:"permissions"`
|
||||
}
|
||||
|
||||
type RolePermissionModuleResponse struct {
|
||||
Module ModuleResponse `json:"module"`
|
||||
Actions []PermissionActionResponse `json:"actions"`
|
||||
}
|
||||
|
||||
type PermissionActionResponse struct {
|
||||
ID uuid.UUID `json:"id"`
|
||||
Action string `json:"action"`
|
||||
Code string `json:"code"`
|
||||
Description string `json:"description,omitempty"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user