changed role permission
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

This commit is contained in:
guwandyk committed 2026-09-26 16:34:28 +05:00
1 parent f0ecf23879
commit 323e131216
74 files changed
+2915 -4713

No files matched your search

+200 -415
View File
@@ -1400,58 +1400,32 @@ definitions:
- sberBankFeeTmt
- tvebFeeUsd
type: object
permission.CreatePermissionDTO:
properties:
code:
type: string
guardName:
enum:
- web
- operator
- admin
type: string
module:
type: string
name:
type: string
required:
- code
- guardName
- module
- name
type: object
permission.UpdatePermissionDTO:
properties:
code:
type: string
guardName:
enum:
- web
- operator
- admin
type: string
module:
type: string
name:
type: string
required:
- code
- guardName
- module
- name
type: object
permissionrole.SetRolePermissionsDTO:
properties:
permissionIds:
items:
type: integer
type: array
roleId:
type: integer
required:
- permissionIds
- roleId
type: object
perm.Code:
enum:
- dashboard
- cards
- loans
- users
- roles
- branches
- provinces
- currencies
- payment-settings
- backups
- activity-logs
type: string
x-enum-varnames:
- Dashboard
- Cards
- Loans
- Users
- Roles
- Branches
- Provinces
- Currencies
- PaymentSettings
- Backups
- ActivityLogs
province.CreateProvinceDTO:
properties:
active:
@@ -1485,6 +1459,24 @@ definitions:
- name
- region
type: object
rbac.Scope:
enum:
- own
- branch
- all
type: string
x-enum-comments:
ScopeAll: every branch
ScopeBranch: records of the caller's branch_user branches
ScopeOwn: only records the caller owns (clients)
x-enum-descriptions:
- only records the caller owns (clients)
- records of the caller's branch_user branches
- every branch
x-enum-varnames:
- ScopeOwn
- ScopeBranch
- ScopeAll
reasonscard.CreateReasonCardDTO:
properties:
active:
@@ -1516,46 +1508,46 @@ definitions:
role.CreateRoleDTO:
properties:
code:
type: string
guardName:
enum:
- web
- operator
- admin
maxLength: 64
type: string
name:
type: string
permissions:
items:
$ref: '#/definitions/perm.Code'
type: array
scope:
allOf:
- $ref: '#/definitions/rbac.Scope'
enum:
- own
- branch
- all
required:
- code
- guardName
- name
- permissions
- scope
type: object
role.UpdateRoleDTO:
properties:
code:
type: string
guardName:
enum:
- web
- operator
- admin
type: string
name:
type: string
permissions:
items:
$ref: '#/definitions/perm.Code'
type: array
scope:
allOf:
- $ref: '#/definitions/rbac.Scope'
enum:
- own
- branch
- all
required:
- code
- guardName
- name
type: object
roleusers.CreateRoleUserDTO:
properties:
roleId:
type: integer
userId:
type: integer
required:
- roleId
- userId
- permissions
- scope
type: object
shared.LocalizedText:
properties:
@@ -1585,7 +1577,11 @@ definitions:
phone:
type: string
role:
description: Role is a role code; RoleId wins when both are sent. Neither
→ "user".
type: string
roleId:
type: integer
username:
type: string
required:
@@ -1594,6 +1590,13 @@ definitions:
- password
- username
type: object
user.SetUserRoleDTO:
properties:
roleId:
type: integer
required:
- roleId
type: object
user.UpdateUserDTO:
properties:
active:
@@ -1611,7 +1614,12 @@ definitions:
phone:
type: string
role:
description: |-
Role is a role code; RoleId wins when both are sent. Neither keeps
the user's current role.
type: string
roleId:
type: integer
username:
type: string
required:
@@ -1857,7 +1865,7 @@ paths:
/activity-logs:
get:
description: Returns a paginated audit trail of user actions (create/update/delete).
Each log includes the actor's username and role from role_user.
Each log includes the actor's username and role code.
parameters:
- description: Filter by user ID
in: query
@@ -5135,99 +5143,11 @@ paths:
summary: Update payment settings
tags:
- payment-settings
/permission-roles/{id}:
delete:
description: Deletes a permission-role assignment
parameters:
- description: Permission-role ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/appresult.AppSuccess'
"400":
description: Bad Request
schema:
$ref: '#/definitions/appresult.AppError'
"404":
description: Not Found
schema:
$ref: '#/definitions/appresult.AppError'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/appresult.AppError'
security:
- BearerAuth: []
summary: Remove permission from role
tags:
- permission-roles
/permission-roles/bulk:
post:
consumes:
- application/json
description: Replaces roleId's whole permission set with permissionIds - pairs
not listed are removed, missing ones are added, an empty list clears all permissions
from the role
parameters:
- description: Role + the permission IDs it should have
in: body
name: body
required: true
schema:
$ref: '#/definitions/permissionrole.SetRolePermissionsDTO'
produces:
- application/json
responses:
"201":
description: Created
schema:
$ref: '#/definitions/appresult.AppSuccess'
"400":
description: Bad Request
schema:
$ref: '#/definitions/appresult.AppError'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/appresult.AppError'
security:
- BearerAuth: []
summary: Set a role's permissions
tags:
- permission-roles
/permissions:
get:
description: Returns paginated permissions with optional filters
parameters:
- description: Filter by name
in: query
name: permission_name
type: string
- description: Filter by guard (web, operator, admin)
in: query
name: guard_name
type: string
- description: Filter by saha (cards, loans, …)
in: query
name: module
type: string
- default: 1
description: Page number
in: query
name: page
type: integer
- default: 10
description: Items per page
in: query
name: limit
type: integer
description: 'Returns the permission catalog: one code per module, in display
order. Holding a code grants read and write in that module; the role''s scope
decides which records.'
produces:
- application/json
responses:
@@ -5235,179 +5155,11 @@ paths:
description: OK
schema:
$ref: '#/definitions/appresult.AppSuccess'
"400":
description: Bad Request
schema:
$ref: '#/definitions/appresult.AppError'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/appresult.AppError'
security:
- BearerAuth: []
summary: List permissions
tags:
- permission
post:
consumes:
- application/json
description: Creates a new permission
parameters:
- description: Permission payload
in: body
name: body
required: true
schema:
$ref: '#/definitions/permission.CreatePermissionDTO'
produces:
- application/json
responses:
"201":
description: Created
schema:
$ref: '#/definitions/appresult.AppSuccess'
"400":
description: Bad Request
schema:
$ref: '#/definitions/appresult.AppError'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/appresult.AppError'
security:
- BearerAuth: []
summary: Create permission
tags:
- permission
/permissions/{id}:
delete:
description: Deletes a permission
parameters:
- description: Permission ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/appresult.AppSuccess'
"400":
description: Bad Request
schema:
$ref: '#/definitions/appresult.AppError'
"404":
description: Not Found
schema:
$ref: '#/definitions/appresult.AppError'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/appresult.AppError'
security:
- BearerAuth: []
summary: Delete permission
tags:
- permission
get:
description: Returns a single permission
parameters:
- description: Permission ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/appresult.AppSuccess'
"400":
description: Bad Request
schema:
$ref: '#/definitions/appresult.AppError'
"404":
description: Not Found
schema:
$ref: '#/definitions/appresult.AppError'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/appresult.AppError'
security:
- BearerAuth: []
summary: Get permission by ID
tags:
- permission
put:
consumes:
- application/json
description: Updates an existing permission
parameters:
- description: Permission ID
in: path
name: id
required: true
type: integer
- description: Permission payload
in: body
name: body
required: true
schema:
$ref: '#/definitions/permission.UpdatePermissionDTO'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/appresult.AppSuccess'
"400":
description: Bad Request
schema:
$ref: '#/definitions/appresult.AppError'
"404":
description: Not Found
schema:
$ref: '#/definitions/appresult.AppError'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/appresult.AppError'
security:
- BearerAuth: []
summary: Update permission
tags:
- permission
/permissions/tree:
get:
description: Returns permissions grouped as guard → module (saha) → permissions
parameters:
- description: Filter by guard (web, operator, admin)
in: query
name: guard_name
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/appresult.AppSuccess'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/appresult.AppError'
security:
- BearerAuth: []
summary: Permission tree
tags:
- permission
/profile:
get:
description: Returns the authenticated user's profile with role, branches, and
@@ -5888,77 +5640,11 @@ paths:
summary: Verify phone
tags:
- auth
/role-users:
post:
consumes:
- application/json
description: Creates a role-user assignment, or updates the user's existing
role if one is already assigned
parameters:
- description: Role-user payload
in: body
name: body
required: true
schema:
$ref: '#/definitions/roleusers.CreateRoleUserDTO'
produces:
- application/json
responses:
"201":
description: Created
schema:
$ref: '#/definitions/appresult.AppSuccess'
"400":
description: Bad Request
schema:
$ref: '#/definitions/appresult.AppError'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/appresult.AppError'
security:
- BearerAuth: []
summary: Assign user to role
tags:
- role-users
/role-users/{id}:
delete:
description: Deletes a role-user assignment
parameters:
- description: Role-user ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/appresult.AppSuccess'
"400":
description: Bad Request
schema:
$ref: '#/definitions/appresult.AppError'
"404":
description: Not Found
schema:
$ref: '#/definitions/appresult.AppError'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/appresult.AppError'
security:
- BearerAuth: []
summary: Remove user from role
tags:
- role-users
/roles:
get:
description: Returns paginated roles with optional filters
parameters:
- description: Filter by name
- description: Filter by name or code
in: query
name: role_name
type: string
@@ -5995,7 +5681,9 @@ paths:
post:
consumes:
- application/json
description: Creates a new role
description: Creates a role with a scope (own, branch, all) and its permission
codes. The caller cannot create a role wider than their own scope or holding
permissions they lack.
parameters:
- description: Role payload
in: body
@@ -6014,6 +5702,14 @@ paths:
description: Bad Request
schema:
$ref: '#/definitions/appresult.AppError'
"403":
description: Forbidden
schema:
$ref: '#/definitions/appresult.AppError'
"409":
description: Conflict
schema:
$ref: '#/definitions/appresult.AppError'
"500":
description: Internal Server Error
schema:
@@ -6025,7 +5721,8 @@ paths:
- role
/roles/{id}:
delete:
description: Deletes a role
description: Deletes a role. System roles and roles still assigned to users
cannot be deleted.
parameters:
- description: Role ID
in: path
@@ -6043,10 +5740,18 @@ paths:
description: Bad Request
schema:
$ref: '#/definitions/appresult.AppError'
"403":
description: Forbidden
schema:
$ref: '#/definitions/appresult.AppError'
"404":
description: Not Found
schema:
$ref: '#/definitions/appresult.AppError'
"409":
description: Conflict
schema:
$ref: '#/definitions/appresult.AppError'
"500":
description: Internal Server Error
schema:
@@ -6091,7 +5796,9 @@ paths:
put:
consumes:
- application/json
description: Updates an existing role
description: Replaces the role's name, scope and whole permission set. System
roles keep their scope; the caller must be able to grant the role both before
and after the change.
parameters:
- description: Role ID
in: path
@@ -6115,6 +5822,10 @@ paths:
description: Bad Request
schema:
$ref: '#/definitions/appresult.AppError'
"403":
description: Forbidden
schema:
$ref: '#/definitions/appresult.AppError'
"404":
description: Not Found
schema:
@@ -6160,9 +5871,9 @@ paths:
- auth
/users:
get:
description: Returns paginated users, including roleId. Admin-guard callers
(admin, superadmin, and other admin-guard roles) see users of every role;
branch-scoped operators see role=user only, scoped to their branches.
description: Returns paginated users, including roleId. All-scope callers see
users of every role; branch-scope callers see role=user only, scoped to their
branches.
parameters:
- description: Search by username, first name, or last name
in: query
@@ -6205,7 +5916,9 @@ paths:
post:
consumes:
- application/json
description: Creates a new user
description: 'Creates a new user. The role (roleId or role code, default "user")
must be one the caller could grant: no wider scope, no permission the caller
lacks, superadmin only from a superadmin.'
parameters:
- description: User payload
in: body
@@ -6224,6 +5937,10 @@ paths:
description: Bad Request
schema:
$ref: '#/definitions/appresult.AppError'
"403":
description: Forbidden
schema:
$ref: '#/definitions/appresult.AppError'
"500":
description: Internal Server Error
schema:
@@ -6235,7 +5952,8 @@ paths:
- user
/users/{id}:
delete:
description: Deletes a user
description: Deletes a user. Callers cannot delete themselves, a user whose
role they could not grant, or the last superadmin.
parameters:
- description: User ID
in: path
@@ -6253,10 +5971,18 @@ paths:
description: Bad Request
schema:
$ref: '#/definitions/appresult.AppError'
"403":
description: Forbidden
schema:
$ref: '#/definitions/appresult.AppError'
"404":
description: Not Found
schema:
$ref: '#/definitions/appresult.AppError'
"409":
description: Conflict
schema:
$ref: '#/definitions/appresult.AppError'
"500":
description: Internal Server Error
schema:
@@ -6302,7 +6028,9 @@ paths:
put:
consumes:
- application/json
description: Updates an existing user
description: Updates an existing user. Sending roleId or role changes the role
(same rules as create); sending neither keeps it. Callers cannot manage a
user whose role they could not grant, nor change their own role.
parameters:
- description: User ID
in: path
@@ -6326,10 +6054,18 @@ paths:
description: Bad Request
schema:
$ref: '#/definitions/appresult.AppError'
"403":
description: Forbidden
schema:
$ref: '#/definitions/appresult.AppError'
"404":
description: Not Found
schema:
$ref: '#/definitions/appresult.AppError'
"409":
description: Conflict
schema:
$ref: '#/definitions/appresult.AppError'
"500":
description: Internal Server Error
schema:
@@ -6339,6 +6075,55 @@ paths:
summary: Update user
tags:
- user
/users/{id}/role:
put:
consumes:
- application/json
description: Gives the user exactly one role. Same rules as create/update.
parameters:
- description: User ID
in: path
name: id
required: true
type: integer
- description: Role
in: body
name: body
required: true
schema:
$ref: '#/definitions/user.SetUserRoleDTO'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/appresult.AppSuccess'
"400":
description: Bad Request
schema:
$ref: '#/definitions/appresult.AppError'
"403":
description: Forbidden
schema:
$ref: '#/definitions/appresult.AppError'
"404":
description: Not Found
schema:
$ref: '#/definitions/appresult.AppError'
"409":
description: Conflict
schema:
$ref: '#/definitions/appresult.AppError'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/appresult.AppError'
security:
- BearerAuth: []
summary: Set user role
tags:
- user
/users/clients:
get:
description: Returns paginated client users (role user, not assigned to any