feat(user_np): 更新用户认证接口路径与实现

- 修改登录接口路径为 /auth/user/{username}/login,并更新对应处理函数
- 修改注册接口路径为 /auth/user/{username},并更新对应处理函数
- 将修改密码接口从 PUT /auth/password 改为 PATCH /auth/user/{username}
- 新增删除用户接口 DELETE /auth/user/{username}
- 新增获取用户信息接口 GET /auth/user/{username}/info
- 更新请求体结构,移除冗余的 username 字段,使用路径参数传递用户名
- 实现 DeleteUser、UpdatePassword 等新接口逻辑
- 调整 OpenAPI 文档中各接口的 operationId 和参数定义
This commit is contained in:
zzy
2025-09-27 16:25:37 +08:00
parent 9cab95c0f7
commit cf47ef66c3
2 changed files with 81 additions and 30 deletions

View File

@ -12,10 +12,18 @@ security:
- ApiKeyAuth: []
paths:
/auth/login:
/auth/user/{username}/login:
parameters:
- name: username
in: path
example: user_name
required: true
schema:
type: string
post:
summary: 用户登录
description: 使用用户名和密码进行登录
operationId: UserLogin
requestBody:
required: true
content:
@ -34,10 +42,19 @@ paths:
'401':
description: 认证失败
/auth/register:
/auth/user/{username}:
parameters:
- name: username
in: path
example: user_name
required: true
schema:
type: string
post:
summary: 用户注册
description: 创建新用户账户
operationId: UserRegister
requestBody:
required: true
content:
@ -52,10 +69,10 @@ paths:
'409':
description: 用户名已存在
/auth/password:
put:
patch:
summary: 修改密码
description: 修改已登录用户的密码
operationId: updatePassword
security:
- ApiKeyAuth: []
requestBody:
@ -72,7 +89,26 @@ paths:
'401':
description: 认证失败
/auth/info:
delete:
summary: 删除用户
description: 删除用户
operationId: deleteUser
security:
- ApiKeyAuth: []
responses:
'200':
description: 用户注销成功
'401':
description: 认证失败
/auth/user/{username}/info:
parameters:
- name: username
in: path
example: user_name
required: true
schema:
type: string
get:
summary: 获取用户信息
description: 获取用户信息 json object
@ -116,11 +152,8 @@ components:
LoginRequest:
type: object
required:
- username
- password
properties:
username:
type: string
password:
type: string
@ -136,11 +169,8 @@ components:
RegisterRequest:
type: object
required:
- username
- password
properties:
username:
type: string
password:
type: string
email:
@ -151,14 +181,11 @@ components:
required:
- old_password
- new_password
- user_name
properties:
old_password:
type: string
new_password:
type: string
user_name:
type: string
Error:
type: object