Refactor role management API endpoints and update Swagger documentation
- Removed the deprecated /example/helloworld endpoint from Swagger. - Updated the /roles endpoint to include GET and POST methods for retrieving and creating roles. - Added detailed documentation for role-related endpoints including assigning and removing permissions, and managing roles for users. - Introduced new DTOs for role creation, updating, and permission management. - Updated response schemas to ensure consistency across role management operations. - Enhanced validation requirements for role and permission requests.
This commit is contained in:
parent
53a8456e79
commit
8fe9a5bb5c
630
docs/docs.go
630
docs/docs.go
|
|
@ -465,29 +465,6 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"/example/helloworld": {
|
||||
"get": {
|
||||
"description": "do ping",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"example"
|
||||
],
|
||||
"summary": "ping example",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/maintenance-groups": {
|
||||
"get": {
|
||||
"description": "Get all maintenance groups",
|
||||
|
|
@ -948,6 +925,319 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"/roles": {
|
||||
"get": {
|
||||
"description": "Get paginated list of roles. Supports filtering and pagination.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Roles"
|
||||
],
|
||||
"summary": "Get all roles",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Filter by name (partial match)",
|
||||
"name": "name",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Page number (default: 1)",
|
||||
"name": "page",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Page size (default: 10)",
|
||||
"name": "page_size",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/utils.ResponseWithPagination"
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"description": "Create a new role.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Roles"
|
||||
],
|
||||
"summary": "Create a new role",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Role create payload",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.RoleCreateRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/utils.Response"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/roles/{id}": {
|
||||
"get": {
|
||||
"description": "Get details of a role by ID.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Roles"
|
||||
],
|
||||
"summary": "Get role by ID",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Role ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/utils.Response"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"description": "Update a role by ID.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Roles"
|
||||
],
|
||||
"summary": "Update a role",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Role ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Role update payload",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.RoleUpdateRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/utils.Response"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"description": "Delete a role by ID.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Roles"
|
||||
],
|
||||
"summary": "Delete a role",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Role ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/roles/{id}/assign-permissions": {
|
||||
"post": {
|
||||
"description": "Assign permissions to a role by role ID.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Roles"
|
||||
],
|
||||
"summary": "Assign permissions to role",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Role ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Assign permissions payload",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.AssignPermissionRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/roles/{id}/remove-permissions": {
|
||||
"post": {
|
||||
"description": "Remove permissions from a role by role ID.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Roles"
|
||||
],
|
||||
"summary": "Remove permissions from role",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Role ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Remove permissions payload",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.RemovePermissionRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users": {
|
||||
"get": {
|
||||
"security": [
|
||||
|
|
@ -1299,6 +1589,146 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/{id}/assign-roles": {
|
||||
"post": {
|
||||
"description": "Assign roles to a user by user ID.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Roles"
|
||||
],
|
||||
"summary": "Assign roles to user",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "User ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Assign roles payload",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.AssignRoleRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/{id}/remove-roles": {
|
||||
"post": {
|
||||
"description": "Remove roles from a user by user ID.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Roles"
|
||||
],
|
||||
"summary": "Remove roles from user",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "User ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Remove roles payload",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.RemoveRoleRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/{id}/roles": {
|
||||
"get": {
|
||||
"description": "Get all roles assigned to a user by user ID.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Roles"
|
||||
],
|
||||
"summary": "Get roles by user ID",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "User ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/utils.ResponseWithPagination"
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
|
|
@ -1316,6 +1746,36 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"dto.AssignPermissionRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"permission_ids"
|
||||
],
|
||||
"properties": {
|
||||
"permission_ids": {
|
||||
"description": "RoleID string ` + "`" + `json:\"role_id\" binding:\"required,uuid4\"` + "`" + `",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.AssignRoleRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"role_ids"
|
||||
],
|
||||
"properties": {
|
||||
"role_ids": {
|
||||
"description": "UserID string ` + "`" + `json:\"user_id\" binding:\"required,uuid4\"` + "`" + `",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.MaintGroupCreateRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
@ -1446,7 +1906,7 @@ const docTemplate = `{
|
|||
"mode": {
|
||||
"type": "string",
|
||||
"maxLength": 20,
|
||||
"minLength": 8
|
||||
"minLength": 1
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
|
|
@ -1468,7 +1928,7 @@ const docTemplate = `{
|
|||
},
|
||||
"url": {
|
||||
"type": "string",
|
||||
"minLength": 8
|
||||
"minLength": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -1483,7 +1943,7 @@ const docTemplate = `{
|
|||
"mode": {
|
||||
"type": "string",
|
||||
"maxLength": 20,
|
||||
"minLength": 2
|
||||
"minLength": 1
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
|
|
@ -1505,7 +1965,7 @@ const docTemplate = `{
|
|||
},
|
||||
"url": {
|
||||
"type": "string",
|
||||
"minLength": 8
|
||||
"minLength": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -1523,6 +1983,122 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"dto.RemovePermissionRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"permission_ids"
|
||||
],
|
||||
"properties": {
|
||||
"permission_ids": {
|
||||
"description": "RoleID string ` + "`" + `json:\"role_id\" binding:\"required,uuid4\"` + "`" + `",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.RemoveRoleRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"role_ids"
|
||||
],
|
||||
"properties": {
|
||||
"role_ids": {
|
||||
"description": "UserID string ` + "`" + `json:\"user_id\" binding:\"required,uuid4\"` + "`" + `",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.RoleCreateRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"client_id",
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"client_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"home_url": {
|
||||
"type": "string"
|
||||
},
|
||||
"icon_url": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"permissions": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"role_menus": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"role_permissions": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
},
|
||||
"user_roles": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"users": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.RoleUpdateRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"client_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"home_url": {
|
||||
"type": "string"
|
||||
},
|
||||
"icon_url": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"permissions": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.SendVerificationEmailRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
|
|||
|
|
@ -459,29 +459,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/example/helloworld": {
|
||||
"get": {
|
||||
"description": "do ping",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"example"
|
||||
],
|
||||
"summary": "ping example",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/maintenance-groups": {
|
||||
"get": {
|
||||
"description": "Get all maintenance groups",
|
||||
|
|
@ -942,6 +919,319 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"/roles": {
|
||||
"get": {
|
||||
"description": "Get paginated list of roles. Supports filtering and pagination.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Roles"
|
||||
],
|
||||
"summary": "Get all roles",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Filter by name (partial match)",
|
||||
"name": "name",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Page number (default: 1)",
|
||||
"name": "page",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"description": "Page size (default: 10)",
|
||||
"name": "page_size",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/utils.ResponseWithPagination"
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"description": "Create a new role.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Roles"
|
||||
],
|
||||
"summary": "Create a new role",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Role create payload",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.RoleCreateRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/utils.Response"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/roles/{id}": {
|
||||
"get": {
|
||||
"description": "Get details of a role by ID.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Roles"
|
||||
],
|
||||
"summary": "Get role by ID",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Role ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/utils.Response"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"put": {
|
||||
"description": "Update a role by ID.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Roles"
|
||||
],
|
||||
"summary": "Update a role",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Role ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Role update payload",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.RoleUpdateRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/utils.Response"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"delete": {
|
||||
"description": "Delete a role by ID.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Roles"
|
||||
],
|
||||
"summary": "Delete a role",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Role ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/roles/{id}/assign-permissions": {
|
||||
"post": {
|
||||
"description": "Assign permissions to a role by role ID.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Roles"
|
||||
],
|
||||
"summary": "Assign permissions to role",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Role ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Assign permissions payload",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.AssignPermissionRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/roles/{id}/remove-permissions": {
|
||||
"post": {
|
||||
"description": "Remove permissions from a role by role ID.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Roles"
|
||||
],
|
||||
"summary": "Remove permissions from role",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Role ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Remove permissions payload",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.RemovePermissionRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users": {
|
||||
"get": {
|
||||
"security": [
|
||||
|
|
@ -1293,6 +1583,146 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/{id}/assign-roles": {
|
||||
"post": {
|
||||
"description": "Assign roles to a user by user ID.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Roles"
|
||||
],
|
||||
"summary": "Assign roles to user",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "User ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Assign roles payload",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.AssignRoleRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/{id}/remove-roles": {
|
||||
"post": {
|
||||
"description": "Remove roles from a user by user ID.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Roles"
|
||||
],
|
||||
"summary": "Remove roles from user",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "User ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"description": "Remove roles payload",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/dto.RemoveRoleRequest"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/{id}/roles": {
|
||||
"get": {
|
||||
"description": "Get all roles assigned to a user by user ID.",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"Roles"
|
||||
],
|
||||
"summary": "Get roles by user ID",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "User ID",
|
||||
"name": "id",
|
||||
"in": "path",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/utils.ResponseWithPagination"
|
||||
}
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"type": "object",
|
||||
"additionalProperties": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
|
|
@ -1310,6 +1740,36 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"dto.AssignPermissionRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"permission_ids"
|
||||
],
|
||||
"properties": {
|
||||
"permission_ids": {
|
||||
"description": "RoleID string `json:\"role_id\" binding:\"required,uuid4\"`",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.AssignRoleRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"role_ids"
|
||||
],
|
||||
"properties": {
|
||||
"role_ids": {
|
||||
"description": "UserID string `json:\"user_id\" binding:\"required,uuid4\"`",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.MaintGroupCreateRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
@ -1440,7 +1900,7 @@
|
|||
"mode": {
|
||||
"type": "string",
|
||||
"maxLength": 20,
|
||||
"minLength": 8
|
||||
"minLength": 1
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
|
|
@ -1462,7 +1922,7 @@
|
|||
},
|
||||
"url": {
|
||||
"type": "string",
|
||||
"minLength": 8
|
||||
"minLength": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -1477,7 +1937,7 @@
|
|||
"mode": {
|
||||
"type": "string",
|
||||
"maxLength": 20,
|
||||
"minLength": 2
|
||||
"minLength": 1
|
||||
},
|
||||
"name": {
|
||||
"type": "string",
|
||||
|
|
@ -1499,7 +1959,7 @@
|
|||
},
|
||||
"url": {
|
||||
"type": "string",
|
||||
"minLength": 8
|
||||
"minLength": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -1517,6 +1977,122 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"dto.RemovePermissionRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"permission_ids"
|
||||
],
|
||||
"properties": {
|
||||
"permission_ids": {
|
||||
"description": "RoleID string `json:\"role_id\" binding:\"required,uuid4\"`",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.RemoveRoleRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"role_ids"
|
||||
],
|
||||
"properties": {
|
||||
"role_ids": {
|
||||
"description": "UserID string `json:\"user_id\" binding:\"required,uuid4\"`",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.RoleCreateRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"client_id",
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"client_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"home_url": {
|
||||
"type": "string"
|
||||
},
|
||||
"icon_url": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"permissions": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"role_menus": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"role_permissions": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
},
|
||||
"user_roles": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"users": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.RoleUpdateRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"client_id": {
|
||||
"type": "string"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"home_url": {
|
||||
"type": "string"
|
||||
},
|
||||
"icon_url": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"permissions": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"type": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dto.SendVerificationEmailRequest": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
|
|
|||
|
|
@ -9,6 +9,26 @@ definitions:
|
|||
required:
|
||||
- menu_ids
|
||||
type: object
|
||||
dto.AssignPermissionRequest:
|
||||
properties:
|
||||
permission_ids:
|
||||
description: RoleID string `json:"role_id" binding:"required,uuid4"`
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- permission_ids
|
||||
type: object
|
||||
dto.AssignRoleRequest:
|
||||
properties:
|
||||
role_ids:
|
||||
description: UserID string `json:"user_id" binding:"required,uuid4"`
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- role_ids
|
||||
type: object
|
||||
dto.MaintGroupCreateRequest:
|
||||
properties:
|
||||
client_id:
|
||||
|
|
@ -95,7 +115,7 @@ definitions:
|
|||
type: string
|
||||
mode:
|
||||
maxLength: 20
|
||||
minLength: 8
|
||||
minLength: 1
|
||||
type: string
|
||||
name:
|
||||
maxLength: 100
|
||||
|
|
@ -111,7 +131,7 @@ definitions:
|
|||
maxLength: 10
|
||||
type: string
|
||||
url:
|
||||
minLength: 8
|
||||
minLength: 1
|
||||
type: string
|
||||
required:
|
||||
- mode
|
||||
|
|
@ -127,7 +147,7 @@ definitions:
|
|||
type: string
|
||||
mode:
|
||||
maxLength: 20
|
||||
minLength: 2
|
||||
minLength: 1
|
||||
type: string
|
||||
name:
|
||||
maxLength: 100
|
||||
|
|
@ -143,7 +163,7 @@ definitions:
|
|||
maxLength: 10
|
||||
type: string
|
||||
url:
|
||||
minLength: 8
|
||||
minLength: 1
|
||||
type: string
|
||||
type: object
|
||||
dto.RemoveMenusFromClientRequest:
|
||||
|
|
@ -155,6 +175,83 @@ definitions:
|
|||
required:
|
||||
- menu_ids
|
||||
type: object
|
||||
dto.RemovePermissionRequest:
|
||||
properties:
|
||||
permission_ids:
|
||||
description: RoleID string `json:"role_id" binding:"required,uuid4"`
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- permission_ids
|
||||
type: object
|
||||
dto.RemoveRoleRequest:
|
||||
properties:
|
||||
role_ids:
|
||||
description: UserID string `json:"user_id" binding:"required,uuid4"`
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- role_ids
|
||||
type: object
|
||||
dto.RoleCreateRequest:
|
||||
properties:
|
||||
client_id:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
home_url:
|
||||
type: string
|
||||
icon_url:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
permissions:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
role_menus:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
role_permissions:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
type:
|
||||
type: string
|
||||
user_roles:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
users:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
required:
|
||||
- client_id
|
||||
- name
|
||||
type: object
|
||||
dto.RoleUpdateRequest:
|
||||
properties:
|
||||
client_id:
|
||||
type: string
|
||||
description:
|
||||
type: string
|
||||
home_url:
|
||||
type: string
|
||||
icon_url:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
permissions:
|
||||
items:
|
||||
type: string
|
||||
type: array
|
||||
type:
|
||||
type: string
|
||||
type: object
|
||||
dto.SendVerificationEmailRequest:
|
||||
properties:
|
||||
email:
|
||||
|
|
@ -595,21 +692,6 @@ paths:
|
|||
summary: Remove menus from client
|
||||
tags:
|
||||
- Clients
|
||||
/example/helloworld:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
description: do ping
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
type: string
|
||||
summary: ping example
|
||||
tags:
|
||||
- example
|
||||
/maintenance-groups:
|
||||
get:
|
||||
consumes:
|
||||
|
|
@ -916,6 +998,216 @@ paths:
|
|||
summary: Get menu by name
|
||||
tags:
|
||||
- Menus
|
||||
/roles:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Get paginated list of roles. Supports filtering and pagination.
|
||||
parameters:
|
||||
- description: Filter by name (partial match)
|
||||
in: query
|
||||
name: name
|
||||
type: string
|
||||
- description: 'Page number (default: 1)'
|
||||
in: query
|
||||
name: page
|
||||
type: integer
|
||||
- description: 'Page size (default: 10)'
|
||||
in: query
|
||||
name: page_size
|
||||
type: integer
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/definitions/utils.ResponseWithPagination'
|
||||
type: array
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
additionalProperties: true
|
||||
type: object
|
||||
summary: Get all roles
|
||||
tags:
|
||||
- Roles
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Create a new role.
|
||||
parameters:
|
||||
- description: Role create payload
|
||||
in: body
|
||||
name: body
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/dto.RoleCreateRequest'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/utils.Response'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
additionalProperties: true
|
||||
type: object
|
||||
summary: Create a new role
|
||||
tags:
|
||||
- Roles
|
||||
/roles/{id}:
|
||||
delete:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Delete a role by ID.
|
||||
parameters:
|
||||
- description: Role ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
additionalProperties: true
|
||||
type: object
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
additionalProperties: true
|
||||
type: object
|
||||
summary: Delete a role
|
||||
tags:
|
||||
- Roles
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Get details of a role by ID.
|
||||
parameters:
|
||||
- description: Role ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/utils.Response'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
additionalProperties: true
|
||||
type: object
|
||||
summary: Get role by ID
|
||||
tags:
|
||||
- Roles
|
||||
put:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Update a role by ID.
|
||||
parameters:
|
||||
- description: Role ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
- description: Role update payload
|
||||
in: body
|
||||
name: body
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/dto.RoleUpdateRequest'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/utils.Response'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
additionalProperties: true
|
||||
type: object
|
||||
summary: Update a role
|
||||
tags:
|
||||
- Roles
|
||||
/roles/{id}/assign-permissions:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Assign permissions to a role by role ID.
|
||||
parameters:
|
||||
- description: Role ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
- description: Assign permissions payload
|
||||
in: body
|
||||
name: body
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/dto.AssignPermissionRequest'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
additionalProperties: true
|
||||
type: object
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
additionalProperties: true
|
||||
type: object
|
||||
summary: Assign permissions to role
|
||||
tags:
|
||||
- Roles
|
||||
/roles/{id}/remove-permissions:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Remove permissions from a role by role ID.
|
||||
parameters:
|
||||
- description: Role ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
- description: Remove permissions payload
|
||||
in: body
|
||||
name: body
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/dto.RemovePermissionRequest'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
additionalProperties: true
|
||||
type: object
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
additionalProperties: true
|
||||
type: object
|
||||
summary: Remove permissions from role
|
||||
tags:
|
||||
- Roles
|
||||
/users:
|
||||
delete:
|
||||
consumes:
|
||||
|
|
@ -1037,6 +1329,100 @@ paths:
|
|||
summary: Get user by ID
|
||||
tags:
|
||||
- Users
|
||||
/users/{id}/assign-roles:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Assign roles to a user by user ID.
|
||||
parameters:
|
||||
- description: User ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
- description: Assign roles payload
|
||||
in: body
|
||||
name: body
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/dto.AssignRoleRequest'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
additionalProperties: true
|
||||
type: object
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
additionalProperties: true
|
||||
type: object
|
||||
summary: Assign roles to user
|
||||
tags:
|
||||
- Roles
|
||||
/users/{id}/remove-roles:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Remove roles from a user by user ID.
|
||||
parameters:
|
||||
- description: User ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
- description: Remove roles payload
|
||||
in: body
|
||||
name: body
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/dto.RemoveRoleRequest'
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
additionalProperties: true
|
||||
type: object
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
additionalProperties: true
|
||||
type: object
|
||||
summary: Remove roles from user
|
||||
tags:
|
||||
- Roles
|
||||
/users/{id}/roles:
|
||||
get:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Get all roles assigned to a user by user ID.
|
||||
parameters:
|
||||
- description: User ID
|
||||
in: path
|
||||
name: id
|
||||
required: true
|
||||
type: string
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/definitions/utils.ResponseWithPagination'
|
||||
type: array
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
additionalProperties: true
|
||||
type: object
|
||||
summary: Get roles by user ID
|
||||
tags:
|
||||
- Roles
|
||||
/users/me:
|
||||
get:
|
||||
consumes:
|
||||
|
|
|
|||
|
|
@ -35,15 +35,17 @@ type (
|
|||
}
|
||||
)
|
||||
|
||||
// PingExample godoc
|
||||
// @Summary ping example
|
||||
// @Schemes
|
||||
// @Description do ping
|
||||
// @Tags example
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {string} Helloworld
|
||||
// @Router /example/helloworld [get]
|
||||
// AssignPermissionsToRole godoc
|
||||
// @Summary Assign permissions to role
|
||||
// @Description Assign permissions to a role by role ID.
|
||||
// @Tags Roles
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Role ID"
|
||||
// @Param body body dto.AssignPermissionRequest true "Assign permissions payload"
|
||||
// @Success 200 {object} map[string]interface{}
|
||||
// @Failure 400 {object} map[string]interface{}
|
||||
// @Router /roles/{id}/assign-permissions [post]
|
||||
func (r *roleController) AssignPermissionsToRole(ctx *gin.Context) {
|
||||
var req dto.AssignPermissionRequest
|
||||
roleId := ctx.Param("id")
|
||||
|
|
@ -61,7 +63,17 @@ func (r *roleController) AssignPermissionsToRole(ctx *gin.Context) {
|
|||
ctx.JSON(http.StatusOK, res)
|
||||
}
|
||||
|
||||
// AssignRoleToUser implements RoleController.
|
||||
// AssignRolesToUser godoc
|
||||
// @Summary Assign roles to user
|
||||
// @Description Assign roles to a user by user ID.
|
||||
// @Tags Roles
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "User ID"
|
||||
// @Param body body dto.AssignRoleRequest true "Assign roles payload"
|
||||
// @Success 200 {object} map[string]interface{}
|
||||
// @Failure 400 {object} map[string]interface{}
|
||||
// @Router /users/{id}/assign-roles [post]
|
||||
func (r *roleController) AssignRolesToUser(ctx *gin.Context) {
|
||||
var req dto.AssignRoleRequest
|
||||
userId := ctx.Param("id")
|
||||
|
|
@ -81,7 +93,16 @@ func (r *roleController) AssignRolesToUser(ctx *gin.Context) {
|
|||
ctx.JSON(http.StatusOK, res)
|
||||
}
|
||||
|
||||
// CreateRole implements RoleController.
|
||||
// CreateRole godoc
|
||||
// @Summary Create a new role
|
||||
// @Description Create a new role.
|
||||
// @Tags Roles
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param body body dto.RoleCreateRequest true "Role create payload"
|
||||
// @Success 200 {object} utils.Response
|
||||
// @Failure 400 {object} map[string]interface{}
|
||||
// @Router /roles [post]
|
||||
func (r *roleController) CreateRole(ctx *gin.Context) {
|
||||
var role dto.RoleCreateRequest
|
||||
if err := ctx.ShouldBind(&role); err != nil {
|
||||
|
|
@ -102,7 +123,16 @@ func (r *roleController) CreateRole(ctx *gin.Context) {
|
|||
|
||||
}
|
||||
|
||||
// DeleteRole implements RoleController.
|
||||
// DeleteRole godoc
|
||||
// @Summary Delete a role
|
||||
// @Description Delete a role by ID.
|
||||
// @Tags Roles
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Role ID"
|
||||
// @Success 200 {object} map[string]interface{}
|
||||
// @Failure 400 {object} map[string]interface{}
|
||||
// @Router /roles/{id} [delete]
|
||||
func (r *roleController) DeleteRole(ctx *gin.Context) {
|
||||
var roleID string = ctx.Param("id")
|
||||
err := r.roleService.DeleteRole(ctx.Request.Context(), roleID)
|
||||
|
|
@ -115,7 +145,16 @@ func (r *roleController) DeleteRole(ctx *gin.Context) {
|
|||
ctx.JSON(http.StatusOK, res)
|
||||
}
|
||||
|
||||
// GetRoleByID implements RoleController.
|
||||
// GetRoleByID godoc
|
||||
// @Summary Get role by ID
|
||||
// @Description Get details of a role by ID.
|
||||
// @Tags Roles
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Role ID"
|
||||
// @Success 200 {object} utils.Response
|
||||
// @Failure 400 {object} map[string]interface{}
|
||||
// @Router /roles/{id} [get]
|
||||
func (r *roleController) GetRoleByID(ctx *gin.Context) {
|
||||
var roleID string = ctx.Param("id")
|
||||
result, err := r.roleService.GetRoleByID(ctx.Request.Context(), roleID)
|
||||
|
|
@ -129,7 +168,18 @@ func (r *roleController) GetRoleByID(ctx *gin.Context) {
|
|||
ctx.JSON(http.StatusOK, res)
|
||||
}
|
||||
|
||||
// GetRoles implements RoleController.
|
||||
// GetRoles godoc
|
||||
// @Summary Get all roles
|
||||
// @Description Get paginated list of roles. Supports filtering and pagination.
|
||||
// @Tags Roles
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param name query string false "Filter by name (partial match)"
|
||||
// @Param page query int false "Page number (default: 1)"
|
||||
// @Param page_size query int false "Page size (default: 10)"
|
||||
// @Success 200 {array} utils.ResponseWithPagination
|
||||
// @Failure 400 {object} map[string]interface{}
|
||||
// @Router /roles [get]
|
||||
func (r *roleController) GetRoles(ctx *gin.Context) {
|
||||
clientId := ctx.MustGet("client_id").(string)
|
||||
// logrus.Info("Client ID: ", clientId)
|
||||
|
|
@ -154,7 +204,16 @@ func (r *roleController) GetRoles(ctx *gin.Context) {
|
|||
ctx.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
// GetRolesByUserID implements RoleController.
|
||||
// GetRolesByUserID godoc
|
||||
// @Summary Get roles by user ID
|
||||
// @Description Get all roles assigned to a user by user ID.
|
||||
// @Tags Roles
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "User ID"
|
||||
// @Success 200 {array} utils.ResponseWithPagination
|
||||
// @Failure 400 {object} map[string]interface{}
|
||||
// @Router /users/{id}/roles [get]
|
||||
func (r *roleController) GetRolesByUserID(ctx *gin.Context) {
|
||||
userId := ctx.Param("id")
|
||||
logrus.Info("Fetching roles for User ID: ", userId)
|
||||
|
|
@ -169,7 +228,17 @@ func (r *roleController) GetRolesByUserID(ctx *gin.Context) {
|
|||
ctx.JSON(http.StatusOK, res)
|
||||
}
|
||||
|
||||
// RemovePermissionsFromRole implements RoleController.
|
||||
// RemovePermissionsFromRole godoc
|
||||
// @Summary Remove permissions from role
|
||||
// @Description Remove permissions from a role by role ID.
|
||||
// @Tags Roles
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Role ID"
|
||||
// @Param body body dto.RemovePermissionRequest true "Remove permissions payload"
|
||||
// @Success 200 {object} map[string]interface{}
|
||||
// @Failure 400 {object} map[string]interface{}
|
||||
// @Router /roles/{id}/remove-permissions [post]
|
||||
func (r *roleController) RemovePermissionsFromRole(ctx *gin.Context) {
|
||||
var req dto.RemovePermissionRequest
|
||||
roleId := ctx.Param("id")
|
||||
|
|
@ -187,7 +256,17 @@ func (r *roleController) RemovePermissionsFromRole(ctx *gin.Context) {
|
|||
ctx.JSON(http.StatusOK, res)
|
||||
}
|
||||
|
||||
// RemoveRoleFromUser implements RoleController.
|
||||
// RemoveRolesFromUser godoc
|
||||
// @Summary Remove roles from user
|
||||
// @Description Remove roles from a user by user ID.
|
||||
// @Tags Roles
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "User ID"
|
||||
// @Param body body dto.RemoveRoleRequest true "Remove roles payload"
|
||||
// @Success 200 {object} map[string]interface{}
|
||||
// @Failure 400 {object} map[string]interface{}
|
||||
// @Router /users/{id}/remove-roles [post]
|
||||
func (r *roleController) RemoveRolesFromUser(ctx *gin.Context) {
|
||||
var req dto.RemoveRoleRequest
|
||||
userId := ctx.Param("id")
|
||||
|
|
@ -205,7 +284,17 @@ func (r *roleController) RemoveRolesFromUser(ctx *gin.Context) {
|
|||
ctx.JSON(http.StatusOK, res)
|
||||
}
|
||||
|
||||
// UpdateRole implements RoleController.
|
||||
// UpdateRole godoc
|
||||
// @Summary Update a role
|
||||
// @Description Update a role by ID.
|
||||
// @Tags Roles
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Role ID"
|
||||
// @Param body body dto.RoleUpdateRequest true "Role update payload"
|
||||
// @Success 200 {object} utils.Response
|
||||
// @Failure 400 {object} map[string]interface{}
|
||||
// @Router /roles/{id} [put]
|
||||
func (r *roleController) UpdateRole(ctx *gin.Context) {
|
||||
var req dto.RoleUpdateRequest
|
||||
if err := ctx.ShouldBind(&req); err != nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue