Add branch_user table and branch-user assignment endpoints

Introduces a branch_user join table linking branches to users, plus
create/delete API endpoints under the auth module for managing branch
assignments. The create response includes the branch's localized name
via a join. Regenerated swagger docs to include the new endpoints.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-08 15:02:05 +05:00
parent 1337175e5d
commit 77bc4025d3
9 changed files with 462 additions and 3 deletions

View File

@@ -15,6 +15,109 @@ const docTemplate = `{
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/branch-users": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "Creates a branch-user assignment",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"auth"
],
"summary": "Assign user to branch",
"parameters": [
{
"description": "Branch-user payload",
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/auth.CreateBranchUserDTO"
}
}
],
"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"
}
}
}
}
},
"/branch-users/{id}": {
"delete": {
"security": [
{
"BearerAuth": []
}
],
"description": "Deletes a branch-user assignment",
"produces": [
"application/json"
],
"tags": [
"auth"
],
"summary": "Remove user from branch",
"parameters": [
{
"type": "integer",
"description": "Branch-user ID",
"name": "id",
"in": "path",
"required": true
}
],
"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"
}
}
}
}
},
"/branches": {
"get": {
"security": [
@@ -2765,6 +2868,21 @@ const docTemplate = `{
}
}
},
"auth.CreateBranchUserDTO": {
"type": "object",
"required": [
"branchId",
"userId"
],
"properties": {
"branchId": {
"type": "integer"
},
"userId": {
"type": "integer"
}
}
},
"auth.LoginDTO": {
"type": "object",
"required": [