basicly implement acl crud ops with roles and resources
This commit is contained in:
94
api/acl_admin/roles_models.go
Normal file
94
api/acl_admin/roles_models.go
Normal file
@@ -0,0 +1,94 @@
|
||||
package api_acladmin
|
||||
|
||||
/*******************************************************************/
|
||||
// used in getRoles()
|
||||
type getRolesResponse []struct {
|
||||
ID uint `json:"id" example:"1"`
|
||||
Name string `json:"name" example:"admin"`
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
// used in getRole()
|
||||
type getRoleResponse struct {
|
||||
ID uint `json:"id" example:"1"`
|
||||
Name string `json:"name" example:"admin"`
|
||||
}
|
||||
|
||||
type getRoleErrorInvalidRoleID struct {
|
||||
Error string `json:"error" example:"INVALID_ROLE_ID"`
|
||||
Details string `json:"details" example:"Role ID must be positive integer"`
|
||||
}
|
||||
|
||||
type getRoleErrorRoleNotFound struct {
|
||||
Error string `json:"error" example:"ROLE_NOT_FOUND"`
|
||||
Details string `json:"details" example:"No role with ID 123"`
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
// used in createRole()
|
||||
type createRoleRequest struct {
|
||||
Name string `json:"name" example:"admin"`
|
||||
}
|
||||
|
||||
type createRoleResponse struct {
|
||||
ID uint `json:"id" example:"1"`
|
||||
Name string `json:"name" example:"admin"`
|
||||
}
|
||||
|
||||
type createRoleErrorRoleAlreadyExists struct {
|
||||
Error string `json:"error" example:"FAILED_TO_CREATE_ROLE"`
|
||||
Details string `json:"details" example:"Role with name 'admin' already exists"`
|
||||
}
|
||||
|
||||
type createRoleErrorInvalidRoleName struct {
|
||||
Error string `json:"error" example:"FAILED_TO_CREATE_ROLE"`
|
||||
Details string `json:"details" example:"Invalid role name"`
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
// used in updateRole()
|
||||
type updateRoleRequest struct {
|
||||
Name string `json:"name" example:"admin"`
|
||||
}
|
||||
|
||||
type updateRoleResponse struct {
|
||||
ID uint `json:"id" example:"1"`
|
||||
Name string `json:"name" example:"admin"`
|
||||
}
|
||||
|
||||
type updateRoleErrorRoleNotFound struct {
|
||||
Error string `json:"error" example:"ROLE_NOT_FOUND"`
|
||||
Details string `json:"details" example:"No role with ID 123"`
|
||||
}
|
||||
|
||||
type updateRoleErrorInvalidRoleID struct {
|
||||
Error string `json:"error" example:"INVALID_ROLE_ID"`
|
||||
Details string `json:"details" example:"Role ID must be positive integer"`
|
||||
}
|
||||
|
||||
type updateRoleErrorInvalidRoleName struct {
|
||||
Error string `json:"error" example:"FAILED_TO_UPDATE_ROLE"`
|
||||
Details string `json:"details" example:"Invalid role name"`
|
||||
}
|
||||
|
||||
type updateRoleErrorRoleNameAlreadyExists struct {
|
||||
Error string `json:"error" example:"FAILED_TO_UPDATE_ROLE"`
|
||||
Details string `json:"details" example:"Role with name 'admin' already exists"`
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
// used in deleteRole()
|
||||
type deleteRoleErrorRoleNotFound struct {
|
||||
Error string `json:"error" example:"ROLE_NOT_FOUND"`
|
||||
Details string `json:"details" example:"No role with ID 123"`
|
||||
}
|
||||
|
||||
type deleteRoleErrorInvalidRoleID struct {
|
||||
Error string `json:"error" example:"INVALID_ROLE_ID"`
|
||||
Details string `json:"details" example:"Role ID must be positive integer"`
|
||||
}
|
||||
|
||||
type deleteRoleErrorRoleInUse struct {
|
||||
Error string `json:"error" example:"FAILED_TO_DELETE_ROLE"`
|
||||
Details string `json:"details" example:"Role with ID 123 is assigned to users and cannot be deleted"`
|
||||
}
|
||||
Reference in New Issue
Block a user