This commit is contained in:
ryan
2026-06-08 08:19:22 +08:00
parent 4b72419a96
commit 9d0f9f0576
42 changed files with 1412 additions and 809 deletions
+174 -77
View File
@@ -1164,6 +1164,79 @@ const docTemplate = `{
}
}
}
},
"post": {
"security": [
{
"SessionCookie": []
}
],
"description": "创建一个本地密码登录的新用户,需要管理员权限",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "创建用户",
"parameters": [
{
"description": "创建用户参数",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/user.createUserRequest"
}
}
],
"responses": {
"200": {
"description": "创建成功",
"schema": {
"allOf": [
{
"$ref": "#/definitions/util.ResponseAny"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/user.user"
}
}
}
]
}
},
"400": {
"description": "参数错误或用户名已存在",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
},
"401": {
"description": "未登录",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
},
"403": {
"description": "无管理员权限",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
},
"500": {
"description": "内部错误",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
}
}
}
},
"/api/v1/admin/users/{id}/status": {
@@ -2223,6 +2296,64 @@ const docTemplate = `{
}
}
},
"/api/v1/user/change-password": {
"post": {
"description": "修改当前登录用户的密码。修改成功后,如果是首次明文登录的升级提示,则清除修改密码的提示状态。",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "修改用户密码",
"parameters": [
{
"description": "修改密码请求参数",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/user.changePasswordRequest"
}
}
],
"responses": {
"200": {
"description": "修改密码成功",
"schema": {
"allOf": [
{
"$ref": "#/definitions/util.ResponseAny"
},
{
"type": "object",
"properties": {
"data": {
"type": "string"
}
}
}
]
}
},
"400": {
"description": "原密码错误或新密码不符合要求",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
},
"401": {
"description": "请先登录",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
}
}
}
},
"/api/v1/user/login": {
"post": {
"description": "使用用户名和密码登录,登录成功后建立 Session。若管理员已关闭密码登录功能则返回错误。",
@@ -2665,23 +2796,6 @@ const docTemplate = `{
"TaskExecutionStatusFailed"
]
},
"model.TrustLevel": {
"type": "integer",
"enum": [
0,
1,
2,
3,
4
],
"x-enum-varnames": [
"TrustLevelNewUser",
"TrustLevelBasicUser",
"TrustLevelUser",
"TrustLevelActiveUser",
"TrustLevelLeader"
]
},
"model.Upload": {
"type": "object",
"properties": {
@@ -2834,54 +2948,21 @@ const docTemplate = `{
"oauth.BasicUserInfo": {
"type": "object",
"properties": {
"available_balance": {
"type": "number"
},
"avatar_url": {
"type": "string"
},
"community_balance": {
"type": "number"
},
"daily_limit": {
"type": "integer"
},
"id": {
"type": "integer"
},
"is_admin": {
"type": "boolean"
},
"need_change_password": {
"type": "boolean"
},
"nickname": {
"type": "string"
},
"pay_level": {
"type": "string"
},
"pay_score": {
"type": "integer"
},
"pending_balance": {
"type": "number"
},
"remain_quota": {
"type": "number"
},
"total_community": {
"type": "number"
},
"total_payment": {
"type": "number"
},
"total_receive": {
"type": "number"
},
"total_transfer": {
"type": "number"
},
"trust_level": {
"$ref": "#/definitions/model.TrustLevel"
},
"username": {
"type": "string"
}
@@ -3051,6 +3132,17 @@ const docTemplate = `{
}
}
},
"user.changePasswordRequest": {
"type": "object",
"properties": {
"new_password": {
"type": "string"
},
"old_password": {
"type": "string"
}
}
},
"user.createTokenRequest": {
"type": "object",
"properties": {
@@ -3059,6 +3151,35 @@ const docTemplate = `{
}
}
},
"user.createUserRequest": {
"type": "object",
"required": [
"password",
"username"
],
"properties": {
"is_active": {
"type": "boolean"
},
"is_admin": {
"type": "boolean"
},
"nickname": {
"type": "string",
"maxLength": 64
},
"password": {
"type": "string",
"maxLength": 64,
"minLength": 8
},
"username": {
"type": "string",
"maxLength": 64,
"minLength": 3
}
}
},
"user.listUsersResponse": {
"type": "object",
"properties": {
@@ -3123,15 +3244,9 @@ const docTemplate = `{
"user.user": {
"type": "object",
"properties": {
"available_balance": {
"type": "number"
},
"avatar_url": {
"type": "string"
},
"community_balance": {
"type": "number"
},
"created_at": {
"type": "string"
},
@@ -3150,24 +3265,6 @@ const docTemplate = `{
"nickname": {
"type": "string"
},
"pay_score": {
"type": "integer"
},
"total_community": {
"type": "number"
},
"total_payment": {
"type": "number"
},
"total_receive": {
"type": "number"
},
"total_transfer": {
"type": "number"
},
"trust_level": {
"$ref": "#/definitions/model.TrustLevel"
},
"updated_at": {
"type": "string"
},
+174 -77
View File
@@ -1157,6 +1157,79 @@
}
}
}
},
"post": {
"security": [
{
"SessionCookie": []
}
],
"description": "创建一个本地密码登录的新用户,需要管理员权限",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"admin"
],
"summary": "创建用户",
"parameters": [
{
"description": "创建用户参数",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/user.createUserRequest"
}
}
],
"responses": {
"200": {
"description": "创建成功",
"schema": {
"allOf": [
{
"$ref": "#/definitions/util.ResponseAny"
},
{
"type": "object",
"properties": {
"data": {
"$ref": "#/definitions/user.user"
}
}
}
]
}
},
"400": {
"description": "参数错误或用户名已存在",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
},
"401": {
"description": "未登录",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
},
"403": {
"description": "无管理员权限",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
},
"500": {
"description": "内部错误",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
}
}
}
},
"/api/v1/admin/users/{id}/status": {
@@ -2216,6 +2289,64 @@
}
}
},
"/api/v1/user/change-password": {
"post": {
"description": "修改当前登录用户的密码。修改成功后,如果是首次明文登录的升级提示,则清除修改密码的提示状态。",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"user"
],
"summary": "修改用户密码",
"parameters": [
{
"description": "修改密码请求参数",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/user.changePasswordRequest"
}
}
],
"responses": {
"200": {
"description": "修改密码成功",
"schema": {
"allOf": [
{
"$ref": "#/definitions/util.ResponseAny"
},
{
"type": "object",
"properties": {
"data": {
"type": "string"
}
}
}
]
}
},
"400": {
"description": "原密码错误或新密码不符合要求",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
},
"401": {
"description": "请先登录",
"schema": {
"$ref": "#/definitions/util.ResponseAny"
}
}
}
}
},
"/api/v1/user/login": {
"post": {
"description": "使用用户名和密码登录,登录成功后建立 Session。若管理员已关闭密码登录功能则返回错误。",
@@ -2658,23 +2789,6 @@
"TaskExecutionStatusFailed"
]
},
"model.TrustLevel": {
"type": "integer",
"enum": [
0,
1,
2,
3,
4
],
"x-enum-varnames": [
"TrustLevelNewUser",
"TrustLevelBasicUser",
"TrustLevelUser",
"TrustLevelActiveUser",
"TrustLevelLeader"
]
},
"model.Upload": {
"type": "object",
"properties": {
@@ -2827,54 +2941,21 @@
"oauth.BasicUserInfo": {
"type": "object",
"properties": {
"available_balance": {
"type": "number"
},
"avatar_url": {
"type": "string"
},
"community_balance": {
"type": "number"
},
"daily_limit": {
"type": "integer"
},
"id": {
"type": "integer"
},
"is_admin": {
"type": "boolean"
},
"need_change_password": {
"type": "boolean"
},
"nickname": {
"type": "string"
},
"pay_level": {
"type": "string"
},
"pay_score": {
"type": "integer"
},
"pending_balance": {
"type": "number"
},
"remain_quota": {
"type": "number"
},
"total_community": {
"type": "number"
},
"total_payment": {
"type": "number"
},
"total_receive": {
"type": "number"
},
"total_transfer": {
"type": "number"
},
"trust_level": {
"$ref": "#/definitions/model.TrustLevel"
},
"username": {
"type": "string"
}
@@ -3044,6 +3125,17 @@
}
}
},
"user.changePasswordRequest": {
"type": "object",
"properties": {
"new_password": {
"type": "string"
},
"old_password": {
"type": "string"
}
}
},
"user.createTokenRequest": {
"type": "object",
"properties": {
@@ -3052,6 +3144,35 @@
}
}
},
"user.createUserRequest": {
"type": "object",
"required": [
"password",
"username"
],
"properties": {
"is_active": {
"type": "boolean"
},
"is_admin": {
"type": "boolean"
},
"nickname": {
"type": "string",
"maxLength": 64
},
"password": {
"type": "string",
"maxLength": 64,
"minLength": 8
},
"username": {
"type": "string",
"maxLength": 64,
"minLength": 3
}
}
},
"user.listUsersResponse": {
"type": "object",
"properties": {
@@ -3116,15 +3237,9 @@
"user.user": {
"type": "object",
"properties": {
"available_balance": {
"type": "number"
},
"avatar_url": {
"type": "string"
},
"community_balance": {
"type": "number"
},
"created_at": {
"type": "string"
},
@@ -3143,24 +3258,6 @@
"nickname": {
"type": "string"
},
"pay_score": {
"type": "integer"
},
"total_community": {
"type": "number"
},
"total_payment": {
"type": "number"
},
"total_receive": {
"type": "number"
},
"total_transfer": {
"type": "number"
},
"trust_level": {
"$ref": "#/definitions/model.TrustLevel"
},
"updated_at": {
"type": "string"
},
+109 -54
View File
@@ -156,20 +156,6 @@ definitions:
- TaskExecutionStatusRunning
- TaskExecutionStatusSucceeded
- TaskExecutionStatusFailed
model.TrustLevel:
enum:
- 0
- 1
- 2
- 3
- 4
type: integer
x-enum-varnames:
- TrustLevelNewUser
- TrustLevelBasicUser
- TrustLevelUser
- TrustLevelActiveUser
- TrustLevelLeader
model.Upload:
properties:
created_at:
@@ -276,38 +262,16 @@ definitions:
type: object
oauth.BasicUserInfo:
properties:
available_balance:
type: number
avatar_url:
type: string
community_balance:
type: number
daily_limit:
type: integer
id:
type: integer
is_admin:
type: boolean
need_change_password:
type: boolean
nickname:
type: string
pay_level:
type: string
pay_score:
type: integer
pending_balance:
type: number
remain_quota:
type: number
total_community:
type: number
total_payment:
type: number
total_receive:
type: number
total_transfer:
type: number
trust_level:
$ref: '#/definitions/model.TrustLevel'
username:
type: string
type: object
@@ -421,11 +385,39 @@ definitions:
total:
type: integer
type: object
user.changePasswordRequest:
properties:
new_password:
type: string
old_password:
type: string
type: object
user.createTokenRequest:
properties:
name:
type: string
type: object
user.createUserRequest:
properties:
is_active:
type: boolean
is_admin:
type: boolean
nickname:
maxLength: 64
type: string
password:
maxLength: 64
minLength: 8
type: string
username:
maxLength: 64
minLength: 3
type: string
required:
- password
- username
type: object
user.listUsersResponse:
properties:
total:
@@ -467,12 +459,8 @@ definitions:
type: object
user.user:
properties:
available_balance:
type: number
avatar_url:
type: string
community_balance:
type: number
created_at:
type: string
id:
@@ -485,18 +473,6 @@ definitions:
type: string
nickname:
type: string
pay_score:
type: integer
total_community:
type: number
total_payment:
type: number
total_receive:
type: number
total_transfer:
type: number
trust_level:
$ref: '#/definitions/model.TrustLevel'
updated_at:
type: string
username:
@@ -1208,6 +1184,50 @@ paths:
summary: 获取用户列表
tags:
- admin
post:
consumes:
- application/json
description: 创建一个本地密码登录的新用户,需要管理员权限
parameters:
- description: 创建用户参数
in: body
name: request
required: true
schema:
$ref: '#/definitions/user.createUserRequest'
produces:
- application/json
responses:
"200":
description: 创建成功
schema:
allOf:
- $ref: '#/definitions/util.ResponseAny'
- properties:
data:
$ref: '#/definitions/user.user'
type: object
"400":
description: 参数错误或用户名已存在
schema:
$ref: '#/definitions/util.ResponseAny'
"401":
description: 未登录
schema:
$ref: '#/definitions/util.ResponseAny'
"403":
description: 无管理员权限
schema:
$ref: '#/definitions/util.ResponseAny'
"500":
description: 内部错误
schema:
$ref: '#/definitions/util.ResponseAny'
security:
- SessionCookie: []
summary: 创建用户
tags:
- admin
/api/v1/admin/users/{id}/status:
put:
consumes:
@@ -1838,6 +1858,41 @@ paths:
summary: 轮换一个 AccessToken
tags:
- user
/api/v1/user/change-password:
post:
consumes:
- application/json
description: 修改当前登录用户的密码。修改成功后,如果是首次明文登录的升级提示,则清除修改密码的提示状态。
parameters:
- description: 修改密码请求参数
in: body
name: request
required: true
schema:
$ref: '#/definitions/user.changePasswordRequest'
produces:
- application/json
responses:
"200":
description: 修改密码成功
schema:
allOf:
- $ref: '#/definitions/util.ResponseAny'
- properties:
data:
type: string
type: object
"400":
description: 原密码错误或新密码不符合要求
schema:
$ref: '#/definitions/util.ResponseAny'
"401":
description: 请先登录
schema:
$ref: '#/definitions/util.ResponseAny'
summary: 修改用户密码
tags:
- user
/api/v1/user/login:
post:
consumes: