Add forgot-password SMS reset, client/staff user lists, and regenerate Swagger.
Fold follow-up migrations into init, expose GET /users/clients and /users/staff, and refresh seed data. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
207
docs/docs.go
207
docs/docs.go
@@ -1673,6 +1673,98 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/forgot-password": {
|
||||
"post": {
|
||||
"description": "Finds the user by name and sends an SMS verification code",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"auth"
|
||||
],
|
||||
"summary": "Forgot password",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Forgot password payload",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/auth.ForgotPasswordDTO"
|
||||
}
|
||||
}
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/forgot-password/verify": {
|
||||
"post": {
|
||||
"description": "Confirms the SMS code and sets a new password",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"auth"
|
||||
],
|
||||
"summary": "Reset password",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Reset password payload",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/auth.ResetPasswordDTO"
|
||||
}
|
||||
}
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/loan-orders": {
|
||||
"get": {
|
||||
"security": [
|
||||
@@ -3200,7 +3292,7 @@ const docTemplate = `{
|
||||
},
|
||||
"/login": {
|
||||
"post": {
|
||||
"description": "Authenticates a user by email and password",
|
||||
"description": "Authenticates a user by name or phone, and password",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -5221,7 +5313,7 @@ const docTemplate = `{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Returns paginated users with optional filters",
|
||||
"description": "Returns paginated users with role user, with optional filters",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -5322,29 +5414,22 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/role": {
|
||||
"/users/clients": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Returns paginated users filtered by role",
|
||||
"description": "Returns paginated users from the users table with role user",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"user"
|
||||
],
|
||||
"summary": "List users by role",
|
||||
"summary": "List client users",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "user role",
|
||||
"name": "role",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Filter by username",
|
||||
@@ -5379,8 +5464,61 @@ const docTemplate = `{
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/staff": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Returns paginated users assigned to branches (from branch_user), including each user's branches.",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"user"
|
||||
],
|
||||
"summary": "List staff users",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Filter by username",
|
||||
"name": "username",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"default": 1,
|
||||
"description": "Page number",
|
||||
"name": "page",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"default": 10,
|
||||
"description": "Items per page",
|
||||
"name": "limit",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppSuccess"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
@@ -5589,18 +5727,31 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"auth.ForgotPasswordDTO": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"auth.LoginDTO": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"email",
|
||||
"password"
|
||||
],
|
||||
"properties": {
|
||||
"email": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"phone": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -5644,6 +5795,30 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"auth.ResetPasswordDTO": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"code",
|
||||
"name",
|
||||
"password",
|
||||
"passwordConfirm"
|
||||
],
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string",
|
||||
"minLength": 6
|
||||
},
|
||||
"passwordConfirm": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"auth.UpdateProfileDTO": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
||||
@@ -1667,6 +1667,98 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/forgot-password": {
|
||||
"post": {
|
||||
"description": "Finds the user by name and sends an SMS verification code",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"auth"
|
||||
],
|
||||
"summary": "Forgot password",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Forgot password payload",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/auth.ForgotPasswordDTO"
|
||||
}
|
||||
}
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/forgot-password/verify": {
|
||||
"post": {
|
||||
"description": "Confirms the SMS code and sets a new password",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"auth"
|
||||
],
|
||||
"summary": "Reset password",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "Reset password payload",
|
||||
"name": "body",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/auth.ResetPasswordDTO"
|
||||
}
|
||||
}
|
||||
],
|
||||
"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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/loan-orders": {
|
||||
"get": {
|
||||
"security": [
|
||||
@@ -3194,7 +3286,7 @@
|
||||
},
|
||||
"/login": {
|
||||
"post": {
|
||||
"description": "Authenticates a user by email and password",
|
||||
"description": "Authenticates a user by name or phone, and password",
|
||||
"consumes": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -5215,7 +5307,7 @@
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Returns paginated users with optional filters",
|
||||
"description": "Returns paginated users with role user, with optional filters",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
@@ -5316,29 +5408,22 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/role": {
|
||||
"/users/clients": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Returns paginated users filtered by role",
|
||||
"description": "Returns paginated users from the users table with role user",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"user"
|
||||
],
|
||||
"summary": "List users by role",
|
||||
"summary": "List client users",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "user role",
|
||||
"name": "role",
|
||||
"in": "query",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Filter by username",
|
||||
@@ -5373,8 +5458,61 @@
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"500": {
|
||||
"description": "Internal Server Error",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/users/staff": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"BearerAuth": []
|
||||
}
|
||||
],
|
||||
"description": "Returns paginated users assigned to branches (from branch_user), including each user's branches.",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"user"
|
||||
],
|
||||
"summary": "List staff users",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "string",
|
||||
"description": "Filter by username",
|
||||
"name": "username",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"default": 1,
|
||||
"description": "Page number",
|
||||
"name": "page",
|
||||
"in": "query"
|
||||
},
|
||||
{
|
||||
"type": "integer",
|
||||
"default": 10,
|
||||
"description": "Items per page",
|
||||
"name": "limit",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppSuccess"
|
||||
}
|
||||
},
|
||||
"400": {
|
||||
"description": "Bad Request",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/appresult.AppError"
|
||||
}
|
||||
@@ -5583,18 +5721,31 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"auth.ForgotPasswordDTO": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name"
|
||||
],
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"auth.LoginDTO": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"email",
|
||||
"password"
|
||||
],
|
||||
"properties": {
|
||||
"email": {
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"phone": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -5638,6 +5789,30 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"auth.ResetPasswordDTO": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"code",
|
||||
"name",
|
||||
"password",
|
||||
"passwordConfirm"
|
||||
],
|
||||
"properties": {
|
||||
"code": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string",
|
||||
"minLength": 6
|
||||
},
|
||||
"passwordConfirm": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"auth.UpdateProfileDTO": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
|
||||
@@ -19,14 +19,22 @@ definitions:
|
||||
status:
|
||||
type: boolean
|
||||
type: object
|
||||
auth.ForgotPasswordDTO:
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
required:
|
||||
- name
|
||||
type: object
|
||||
auth.LoginDTO:
|
||||
properties:
|
||||
email:
|
||||
name:
|
||||
type: string
|
||||
password:
|
||||
type: string
|
||||
phone:
|
||||
type: string
|
||||
required:
|
||||
- email
|
||||
- password
|
||||
type: object
|
||||
auth.RefreshTokenDTO:
|
||||
@@ -57,6 +65,23 @@ definitions:
|
||||
- phone
|
||||
- username
|
||||
type: object
|
||||
auth.ResetPasswordDTO:
|
||||
properties:
|
||||
code:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
password:
|
||||
minLength: 6
|
||||
type: string
|
||||
passwordConfirm:
|
||||
type: string
|
||||
required:
|
||||
- code
|
||||
- name
|
||||
- password
|
||||
- passwordConfirm
|
||||
type: object
|
||||
auth.UpdateProfileDTO:
|
||||
properties:
|
||||
avatar:
|
||||
@@ -2313,6 +2338,66 @@ paths:
|
||||
- BearerAuth: []
|
||||
tags:
|
||||
- file-upload
|
||||
/forgot-password:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Finds the user by name and sends an SMS verification code
|
||||
parameters:
|
||||
- description: Forgot password payload
|
||||
in: body
|
||||
name: body
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/auth.ForgotPasswordDTO'
|
||||
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'
|
||||
summary: Forgot password
|
||||
tags:
|
||||
- auth
|
||||
/forgot-password/verify:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Confirms the SMS code and sets a new password
|
||||
parameters:
|
||||
- description: Reset password payload
|
||||
in: body
|
||||
name: body
|
||||
required: true
|
||||
schema:
|
||||
$ref: '#/definitions/auth.ResetPasswordDTO'
|
||||
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'
|
||||
summary: Reset password
|
||||
tags:
|
||||
- auth
|
||||
/loan-orders:
|
||||
get:
|
||||
description: Returns paginated loan orders with optional filters
|
||||
@@ -3295,7 +3380,7 @@ paths:
|
||||
post:
|
||||
consumes:
|
||||
- application/json
|
||||
description: Authenticates a user by email and password
|
||||
description: Authenticates a user by name or phone, and password
|
||||
parameters:
|
||||
- description: Login payload
|
||||
in: body
|
||||
@@ -4585,7 +4670,7 @@ paths:
|
||||
- auth
|
||||
/users:
|
||||
get:
|
||||
description: Returns paginated users with optional filters
|
||||
description: Returns paginated users with role user, with optional filters
|
||||
parameters:
|
||||
- description: Filter by username
|
||||
in: query
|
||||
@@ -4757,15 +4842,10 @@ paths:
|
||||
summary: Update user
|
||||
tags:
|
||||
- user
|
||||
/users/role:
|
||||
/users/clients:
|
||||
get:
|
||||
description: Returns paginated users filtered by role
|
||||
description: Returns paginated users from the users table with role user
|
||||
parameters:
|
||||
- description: user role
|
||||
in: query
|
||||
name: role
|
||||
required: true
|
||||
type: string
|
||||
- description: Filter by username
|
||||
in: query
|
||||
name: username
|
||||
@@ -4791,8 +4871,43 @@ paths:
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
"404":
|
||||
description: Not Found
|
||||
"500":
|
||||
description: Internal Server Error
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: List client users
|
||||
tags:
|
||||
- user
|
||||
/users/staff:
|
||||
get:
|
||||
description: Returns paginated users assigned to branches (from branch_user),
|
||||
including each user's branches.
|
||||
parameters:
|
||||
- description: Filter by username
|
||||
in: query
|
||||
name: username
|
||||
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
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppSuccess'
|
||||
"400":
|
||||
description: Bad Request
|
||||
schema:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
"500":
|
||||
@@ -4801,7 +4916,7 @@ paths:
|
||||
$ref: '#/definitions/appresult.AppError'
|
||||
security:
|
||||
- BearerAuth: []
|
||||
summary: List users by role
|
||||
summary: List staff users
|
||||
tags:
|
||||
- user
|
||||
securityDefinitions:
|
||||
|
||||
Reference in New Issue
Block a user