Some checks failed
CI / Build & Test (push) Failing after 33s
- 37 个端点全部添加 godoc Swagger 注解(RBAC 11 / Org 5 / Audit 1 / Settings 7 / Notification 7) - 重新生成 docs/(swagger.json/yaml/docs.go) - M8 质量横切:IP 限流、安全头、Body 限制、结构化日志增强、优雅关闭 - 新增 Dockerfile 多阶段构建 + .dockerignore - 新增 testutil 测试工具包 - 修复 testutil.go 编译错误
1474 lines
35 KiB
YAML
1474 lines
35 KiB
YAML
basePath: /api/v1
|
||
definitions:
|
||
domain.AssignRoleRequest:
|
||
properties:
|
||
role_id:
|
||
type: integer
|
||
required:
|
||
- role_id
|
||
type: object
|
||
domain.ChangePasswordRequest:
|
||
properties:
|
||
new_password:
|
||
maxLength: 128
|
||
minLength: 8
|
||
type: string
|
||
old_password:
|
||
type: string
|
||
required:
|
||
- new_password
|
||
- old_password
|
||
type: object
|
||
domain.CreateNotificationRequest:
|
||
properties:
|
||
content:
|
||
type: string
|
||
title:
|
||
type: string
|
||
type:
|
||
type: string
|
||
user_id:
|
||
type: integer
|
||
required:
|
||
- title
|
||
- user_id
|
||
type: object
|
||
domain.CreateRoleRequest:
|
||
properties:
|
||
description:
|
||
type: string
|
||
name:
|
||
type: string
|
||
required:
|
||
- name
|
||
type: object
|
||
domain.CreateTenantRequest:
|
||
properties:
|
||
name:
|
||
type: string
|
||
slug:
|
||
type: string
|
||
required:
|
||
- name
|
||
- slug
|
||
type: object
|
||
domain.LoginRequest:
|
||
properties:
|
||
email:
|
||
type: string
|
||
password:
|
||
type: string
|
||
required:
|
||
- email
|
||
- password
|
||
type: object
|
||
domain.NotificationDTO:
|
||
properties:
|
||
content:
|
||
type: string
|
||
created_at:
|
||
type: string
|
||
id:
|
||
type: integer
|
||
is_read:
|
||
type: boolean
|
||
tenant_id:
|
||
type: string
|
||
title:
|
||
type: string
|
||
type:
|
||
type: string
|
||
user_id:
|
||
type: integer
|
||
type: object
|
||
domain.PermissionDTO:
|
||
properties:
|
||
code:
|
||
type: string
|
||
description:
|
||
type: string
|
||
id:
|
||
type: integer
|
||
module:
|
||
type: string
|
||
name:
|
||
type: string
|
||
type: object
|
||
domain.RegisterRequest:
|
||
properties:
|
||
email:
|
||
type: string
|
||
nickname:
|
||
type: string
|
||
password:
|
||
maxLength: 128
|
||
minLength: 8
|
||
type: string
|
||
username:
|
||
maxLength: 64
|
||
minLength: 3
|
||
type: string
|
||
required:
|
||
- email
|
||
- password
|
||
- username
|
||
type: object
|
||
domain.RoleDTO:
|
||
properties:
|
||
description:
|
||
type: string
|
||
id:
|
||
type: integer
|
||
is_system:
|
||
type: boolean
|
||
name:
|
||
type: string
|
||
permissions:
|
||
items:
|
||
$ref: '#/definitions/domain.PermissionDTO'
|
||
type: array
|
||
tenant_id:
|
||
type: string
|
||
type: object
|
||
domain.SetRolePermissionsRequest:
|
||
properties:
|
||
permission_ids:
|
||
items:
|
||
type: integer
|
||
type: array
|
||
required:
|
||
- permission_ids
|
||
type: object
|
||
domain.SettingDTO:
|
||
properties:
|
||
id:
|
||
type: integer
|
||
key:
|
||
type: string
|
||
scope:
|
||
type: string
|
||
tenant_id:
|
||
type: string
|
||
type:
|
||
type: string
|
||
updated_at:
|
||
type: string
|
||
updated_by:
|
||
type: integer
|
||
value:
|
||
type: string
|
||
type: object
|
||
domain.TenantDTO:
|
||
properties:
|
||
created_at:
|
||
type: string
|
||
id:
|
||
type: string
|
||
name:
|
||
type: string
|
||
slug:
|
||
type: string
|
||
status:
|
||
type: integer
|
||
updated_at:
|
||
type: string
|
||
type: object
|
||
domain.TokenPair:
|
||
properties:
|
||
access_token:
|
||
type: string
|
||
expires_in:
|
||
type: integer
|
||
refresh_token:
|
||
type: string
|
||
type: object
|
||
domain.UpdateRoleRequest:
|
||
properties:
|
||
description:
|
||
type: string
|
||
name:
|
||
type: string
|
||
type: object
|
||
domain.UpdateSettingRequest:
|
||
properties:
|
||
type:
|
||
type: string
|
||
value:
|
||
type: string
|
||
required:
|
||
- value
|
||
type: object
|
||
domain.UpdateTenantRequest:
|
||
properties:
|
||
name:
|
||
type: string
|
||
slug:
|
||
type: string
|
||
status:
|
||
type: integer
|
||
type: object
|
||
domain.UserDTO:
|
||
properties:
|
||
avatar:
|
||
type: string
|
||
email:
|
||
type: string
|
||
id:
|
||
type: integer
|
||
nickname:
|
||
type: string
|
||
status:
|
||
type: integer
|
||
tenant_id:
|
||
type: string
|
||
username:
|
||
type: string
|
||
type: object
|
||
response.Response:
|
||
properties:
|
||
code:
|
||
type: integer
|
||
data: {}
|
||
message:
|
||
type: string
|
||
trace_id:
|
||
type: string
|
||
type: object
|
||
host: localhost:2222
|
||
info:
|
||
contact: {}
|
||
description: MengStack 平台 API 文档
|
||
title: MengStack API
|
||
version: 0.1.0
|
||
paths:
|
||
/api/v1/audit/logs:
|
||
get:
|
||
description: 分页查询审计日志,支持按用户、操作、资源筛选
|
||
parameters:
|
||
- description: 按用户 ID 筛选
|
||
in: query
|
||
name: user_id
|
||
type: integer
|
||
- description: 按操作筛选
|
||
in: query
|
||
name: action
|
||
type: string
|
||
- description: 按资源类型筛选
|
||
in: query
|
||
name: resource
|
||
type: string
|
||
- description: 页码(默认 1)
|
||
in: query
|
||
name: page
|
||
type: integer
|
||
- description: 每页条数(默认 20)
|
||
in: query
|
||
name: page_size
|
||
type: integer
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"500":
|
||
description: Internal Server Error
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 查询审计日志
|
||
tags:
|
||
- Audit
|
||
/api/v1/notifications:
|
||
post:
|
||
consumes:
|
||
- application/json
|
||
description: 向指定用户发送通知
|
||
parameters:
|
||
- description: 通知内容
|
||
in: body
|
||
name: request
|
||
required: true
|
||
schema:
|
||
$ref: '#/definitions/domain.CreateNotificationRequest'
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
allOf:
|
||
- $ref: '#/definitions/response.Response'
|
||
- properties:
|
||
data:
|
||
$ref: '#/definitions/domain.NotificationDTO'
|
||
type: object
|
||
"400":
|
||
description: Bad Request
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 创建通知
|
||
tags:
|
||
- Notification
|
||
/api/v1/notifications/{id}:
|
||
delete:
|
||
description: 删除指定通知
|
||
parameters:
|
||
- description: 通知 ID
|
||
in: path
|
||
name: id
|
||
required: true
|
||
type: integer
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"400":
|
||
description: Bad Request
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"404":
|
||
description: Not Found
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 删除通知
|
||
tags:
|
||
- Notification
|
||
get:
|
||
description: 根据 ID 获取指定通知的详细信息
|
||
parameters:
|
||
- description: 通知 ID
|
||
in: path
|
||
name: id
|
||
required: true
|
||
type: integer
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
allOf:
|
||
- $ref: '#/definitions/response.Response'
|
||
- properties:
|
||
data:
|
||
$ref: '#/definitions/domain.NotificationDTO'
|
||
type: object
|
||
"400":
|
||
description: Bad Request
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"404":
|
||
description: Not Found
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 获取通知详情
|
||
tags:
|
||
- Notification
|
||
/api/v1/notifications/{id}/read:
|
||
put:
|
||
description: 将指定通知标记为已读
|
||
parameters:
|
||
- description: 通知 ID
|
||
in: path
|
||
name: id
|
||
required: true
|
||
type: integer
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"400":
|
||
description: Bad Request
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"404":
|
||
description: Not Found
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 标记通知已读
|
||
tags:
|
||
- Notification
|
||
/api/v1/notifications/read-all:
|
||
put:
|
||
description: 将当前用户的所有通知标记为已读
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"500":
|
||
description: Internal Server Error
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 全部标记已读
|
||
tags:
|
||
- Notification
|
||
/api/v1/notifications/unread-count:
|
||
get:
|
||
description: 获取当前用户的未读通知数量
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"500":
|
||
description: Internal Server Error
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 获取未读通知数
|
||
tags:
|
||
- Notification
|
||
/api/v1/notifications/user/{userId}:
|
||
get:
|
||
description: 分页获取指定用户的通知列表
|
||
parameters:
|
||
- description: 用户 ID
|
||
in: path
|
||
name: userId
|
||
required: true
|
||
type: integer
|
||
- description: 页码(默认 1)
|
||
in: query
|
||
name: page
|
||
type: integer
|
||
- description: 每页条数(默认 20)
|
||
in: query
|
||
name: page_size
|
||
type: integer
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"400":
|
||
description: Bad Request
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"500":
|
||
description: Internal Server Error
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 获取用户通知列表
|
||
tags:
|
||
- Notification
|
||
/api/v1/org/tenants:
|
||
get:
|
||
description: 获取系统中的所有租户列表
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
allOf:
|
||
- $ref: '#/definitions/response.Response'
|
||
- properties:
|
||
data:
|
||
items:
|
||
$ref: '#/definitions/domain.TenantDTO'
|
||
type: array
|
||
type: object
|
||
"500":
|
||
description: Internal Server Error
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 列出所有租户
|
||
tags:
|
||
- Org
|
||
post:
|
||
consumes:
|
||
- application/json
|
||
description: 创建新的租户(组织),需提供名称和 slug
|
||
parameters:
|
||
- description: 租户信息
|
||
in: body
|
||
name: request
|
||
required: true
|
||
schema:
|
||
$ref: '#/definitions/domain.CreateTenantRequest'
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
allOf:
|
||
- $ref: '#/definitions/response.Response'
|
||
- properties:
|
||
data:
|
||
$ref: '#/definitions/domain.TenantDTO'
|
||
type: object
|
||
"400":
|
||
description: Bad Request
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"409":
|
||
description: Conflict
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 创建租户
|
||
tags:
|
||
- Org
|
||
/api/v1/org/tenants/{id}:
|
||
delete:
|
||
description: 删除指定租户及其所有关联数据
|
||
parameters:
|
||
- description: 租户 ID (UUID)
|
||
in: path
|
||
name: id
|
||
required: true
|
||
type: string
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"400":
|
||
description: Bad Request
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"404":
|
||
description: Not Found
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 删除租户
|
||
tags:
|
||
- Org
|
||
get:
|
||
description: 根据 ID 获取指定租户的详细信息
|
||
parameters:
|
||
- description: 租户 ID (UUID)
|
||
in: path
|
||
name: id
|
||
required: true
|
||
type: string
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
allOf:
|
||
- $ref: '#/definitions/response.Response'
|
||
- properties:
|
||
data:
|
||
$ref: '#/definitions/domain.TenantDTO'
|
||
type: object
|
||
"400":
|
||
description: Bad Request
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"404":
|
||
description: Not Found
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 获取租户详情
|
||
tags:
|
||
- Org
|
||
put:
|
||
consumes:
|
||
- application/json
|
||
description: 更新租户的名称、slug 或状态
|
||
parameters:
|
||
- description: 租户 ID (UUID)
|
||
in: path
|
||
name: id
|
||
required: true
|
||
type: string
|
||
- description: 更新内容
|
||
in: body
|
||
name: request
|
||
required: true
|
||
schema:
|
||
$ref: '#/definitions/domain.UpdateTenantRequest'
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
allOf:
|
||
- $ref: '#/definitions/response.Response'
|
||
- properties:
|
||
data:
|
||
$ref: '#/definitions/domain.TenantDTO'
|
||
type: object
|
||
"400":
|
||
description: Bad Request
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"404":
|
||
description: Not Found
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 更新租户
|
||
tags:
|
||
- Org
|
||
/api/v1/rbac/permissions:
|
||
get:
|
||
description: 获取所有权限列表,可按模块筛选
|
||
parameters:
|
||
- description: 按模块筛选
|
||
in: query
|
||
name: module
|
||
type: string
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
allOf:
|
||
- $ref: '#/definitions/response.Response'
|
||
- properties:
|
||
data:
|
||
items:
|
||
$ref: '#/definitions/domain.PermissionDTO'
|
||
type: array
|
||
type: object
|
||
"500":
|
||
description: Internal Server Error
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 列出权限
|
||
tags:
|
||
- RBAC
|
||
/api/v1/rbac/roles:
|
||
get:
|
||
description: 获取当前租户下的所有角色
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
allOf:
|
||
- $ref: '#/definitions/response.Response'
|
||
- properties:
|
||
data:
|
||
items:
|
||
$ref: '#/definitions/domain.RoleDTO'
|
||
type: array
|
||
type: object
|
||
"500":
|
||
description: Internal Server Error
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 列出角色
|
||
tags:
|
||
- RBAC
|
||
post:
|
||
consumes:
|
||
- application/json
|
||
description: 在当前租户下创建新角色
|
||
parameters:
|
||
- description: 角色信息
|
||
in: body
|
||
name: request
|
||
required: true
|
||
schema:
|
||
$ref: '#/definitions/domain.CreateRoleRequest'
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
allOf:
|
||
- $ref: '#/definitions/response.Response'
|
||
- properties:
|
||
data:
|
||
$ref: '#/definitions/domain.RoleDTO'
|
||
type: object
|
||
"400":
|
||
description: Bad Request
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"409":
|
||
description: Conflict
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 创建角色
|
||
tags:
|
||
- RBAC
|
||
/api/v1/rbac/roles/{id}:
|
||
delete:
|
||
description: 删除指定角色(系统角色不可删除)
|
||
parameters:
|
||
- description: 角色 ID
|
||
in: path
|
||
name: id
|
||
required: true
|
||
type: integer
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"400":
|
||
description: Bad Request
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"403":
|
||
description: Forbidden
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 删除角色
|
||
tags:
|
||
- RBAC
|
||
get:
|
||
description: 根据 ID 获取角色信息,包含权限列表
|
||
parameters:
|
||
- description: 角色 ID
|
||
in: path
|
||
name: id
|
||
required: true
|
||
type: integer
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
allOf:
|
||
- $ref: '#/definitions/response.Response'
|
||
- properties:
|
||
data:
|
||
$ref: '#/definitions/domain.RoleDTO'
|
||
type: object
|
||
"400":
|
||
description: Bad Request
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"404":
|
||
description: Not Found
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 获取角色详情
|
||
tags:
|
||
- RBAC
|
||
put:
|
||
consumes:
|
||
- application/json
|
||
description: 更新角色名称或描述
|
||
parameters:
|
||
- description: 角色 ID
|
||
in: path
|
||
name: id
|
||
required: true
|
||
type: integer
|
||
- description: 更新内容
|
||
in: body
|
||
name: request
|
||
required: true
|
||
schema:
|
||
$ref: '#/definitions/domain.UpdateRoleRequest'
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
allOf:
|
||
- $ref: '#/definitions/response.Response'
|
||
- properties:
|
||
data:
|
||
$ref: '#/definitions/domain.RoleDTO'
|
||
type: object
|
||
"400":
|
||
description: Bad Request
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"404":
|
||
description: Not Found
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 更新角色
|
||
tags:
|
||
- RBAC
|
||
/api/v1/rbac/roles/{id}/permissions:
|
||
get:
|
||
description: 获取指定角色已分配的权限列表
|
||
parameters:
|
||
- description: 角色 ID
|
||
in: path
|
||
name: id
|
||
required: true
|
||
type: integer
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
allOf:
|
||
- $ref: '#/definitions/response.Response'
|
||
- properties:
|
||
data:
|
||
items:
|
||
$ref: '#/definitions/domain.PermissionDTO'
|
||
type: array
|
||
type: object
|
||
"400":
|
||
description: Bad Request
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"404":
|
||
description: Not Found
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 获取角色权限列表
|
||
tags:
|
||
- RBAC
|
||
put:
|
||
consumes:
|
||
- application/json
|
||
description: 为角色批量设置权限(覆盖原有权限)
|
||
parameters:
|
||
- description: 角色 ID
|
||
in: path
|
||
name: id
|
||
required: true
|
||
type: integer
|
||
- description: 权限 ID 列表
|
||
in: body
|
||
name: request
|
||
required: true
|
||
schema:
|
||
$ref: '#/definitions/domain.SetRolePermissionsRequest'
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"400":
|
||
description: Bad Request
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"404":
|
||
description: Not Found
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 设置角色权限
|
||
tags:
|
||
- RBAC
|
||
/api/v1/rbac/users/{userId}/roles:
|
||
get:
|
||
description: 获取指定用户的所有角色及权限
|
||
parameters:
|
||
- description: 用户 ID
|
||
in: path
|
||
name: userId
|
||
required: true
|
||
type: integer
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
allOf:
|
||
- $ref: '#/definitions/response.Response'
|
||
- properties:
|
||
data:
|
||
items:
|
||
$ref: '#/definitions/domain.RoleDTO'
|
||
type: array
|
||
type: object
|
||
"400":
|
||
description: Bad Request
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"404":
|
||
description: Not Found
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 获取用户角色
|
||
tags:
|
||
- RBAC
|
||
post:
|
||
consumes:
|
||
- application/json
|
||
description: 为指定用户分配一个角色
|
||
parameters:
|
||
- description: 用户 ID
|
||
in: path
|
||
name: userId
|
||
required: true
|
||
type: integer
|
||
- description: 角色 ID
|
||
in: body
|
||
name: request
|
||
required: true
|
||
schema:
|
||
$ref: '#/definitions/domain.AssignRoleRequest'
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"400":
|
||
description: Bad Request
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"409":
|
||
description: Conflict
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 分配角色给用户
|
||
tags:
|
||
- RBAC
|
||
/api/v1/rbac/users/{userId}/roles/{roleId}:
|
||
delete:
|
||
description: 从指定用户移除一个角色
|
||
parameters:
|
||
- description: 用户 ID
|
||
in: path
|
||
name: userId
|
||
required: true
|
||
type: integer
|
||
- description: 角色 ID
|
||
in: path
|
||
name: roleId
|
||
required: true
|
||
type: integer
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"400":
|
||
description: Bad Request
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"404":
|
||
description: Not Found
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 移除用户角色
|
||
tags:
|
||
- RBAC
|
||
/api/v1/settings:
|
||
get:
|
||
description: 获取所有全局配置项
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
allOf:
|
||
- $ref: '#/definitions/response.Response'
|
||
- properties:
|
||
data:
|
||
items:
|
||
$ref: '#/definitions/domain.SettingDTO'
|
||
type: array
|
||
type: object
|
||
"500":
|
||
description: Internal Server Error
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 列出全局配置
|
||
tags:
|
||
- Settings
|
||
/api/v1/settings/global/{key}:
|
||
get:
|
||
description: 根据 key 获取全局(非租户)配置项
|
||
parameters:
|
||
- description: 配置键名
|
||
in: path
|
||
name: key
|
||
required: true
|
||
type: string
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
allOf:
|
||
- $ref: '#/definitions/response.Response'
|
||
- properties:
|
||
data:
|
||
$ref: '#/definitions/domain.SettingDTO'
|
||
type: object
|
||
"400":
|
||
description: Bad Request
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"404":
|
||
description: Not Found
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 获取全局配置
|
||
tags:
|
||
- Settings
|
||
put:
|
||
consumes:
|
||
- application/json
|
||
description: 创建或更新全局配置项
|
||
parameters:
|
||
- description: 配置键名
|
||
in: path
|
||
name: key
|
||
required: true
|
||
type: string
|
||
- description: 配置值
|
||
in: body
|
||
name: request
|
||
required: true
|
||
schema:
|
||
$ref: '#/definitions/domain.UpdateSettingRequest'
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"400":
|
||
description: Bad Request
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 更新全局配置
|
||
tags:
|
||
- Settings
|
||
/api/v1/settings/tenant:
|
||
get:
|
||
description: 获取当前租户的所有配置项
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
allOf:
|
||
- $ref: '#/definitions/response.Response'
|
||
- properties:
|
||
data:
|
||
items:
|
||
$ref: '#/definitions/domain.SettingDTO'
|
||
type: array
|
||
type: object
|
||
"500":
|
||
description: Internal Server Error
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 列出租户配置
|
||
tags:
|
||
- Settings
|
||
/api/v1/settings/tenant/{key}:
|
||
delete:
|
||
description: 删除当前租户的指定配置项
|
||
parameters:
|
||
- description: 配置键名
|
||
in: path
|
||
name: key
|
||
required: true
|
||
type: string
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"400":
|
||
description: Bad Request
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"404":
|
||
description: Not Found
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 删除租户配置
|
||
tags:
|
||
- Settings
|
||
get:
|
||
description: 根据 key 获取当前租户的配置项
|
||
parameters:
|
||
- description: 配置键名
|
||
in: path
|
||
name: key
|
||
required: true
|
||
type: string
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
allOf:
|
||
- $ref: '#/definitions/response.Response'
|
||
- properties:
|
||
data:
|
||
$ref: '#/definitions/domain.SettingDTO'
|
||
type: object
|
||
"400":
|
||
description: Bad Request
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"404":
|
||
description: Not Found
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 获取租户配置
|
||
tags:
|
||
- Settings
|
||
put:
|
||
consumes:
|
||
- application/json
|
||
description: 创建或更新当前租户的配置项
|
||
parameters:
|
||
- description: 配置键名
|
||
in: path
|
||
name: key
|
||
required: true
|
||
type: string
|
||
- description: 配置值
|
||
in: body
|
||
name: request
|
||
required: true
|
||
schema:
|
||
$ref: '#/definitions/domain.UpdateSettingRequest'
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"400":
|
||
description: Bad Request
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 更新租户配置
|
||
tags:
|
||
- Settings
|
||
/auth/login:
|
||
post:
|
||
consumes:
|
||
- application/json
|
||
description: 使用邮箱和密码登录,返回 JWT token
|
||
parameters:
|
||
- description: 登录信息
|
||
in: body
|
||
name: request
|
||
required: true
|
||
schema:
|
||
$ref: '#/definitions/domain.LoginRequest'
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
allOf:
|
||
- $ref: '#/definitions/response.Response'
|
||
- properties:
|
||
data:
|
||
$ref: '#/definitions/domain.TokenPair'
|
||
type: object
|
||
"400":
|
||
description: Bad Request
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"401":
|
||
description: Unauthorized
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
summary: 用户登录
|
||
tags:
|
||
- Auth
|
||
/auth/refresh:
|
||
post:
|
||
consumes:
|
||
- application/json
|
||
description: 使用 refresh_token 获取新的 token 对
|
||
parameters:
|
||
- description: '{ \'
|
||
in: body
|
||
name: request
|
||
required: true
|
||
schema:
|
||
type: object
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
allOf:
|
||
- $ref: '#/definitions/response.Response'
|
||
- properties:
|
||
data:
|
||
$ref: '#/definitions/domain.TokenPair'
|
||
type: object
|
||
"400":
|
||
description: Bad Request
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"401":
|
||
description: Unauthorized
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
summary: 刷新 Token
|
||
tags:
|
||
- Auth
|
||
/auth/register:
|
||
post:
|
||
consumes:
|
||
- application/json
|
||
description: 使用邮箱、用户名和密码注册新用户,返回 JWT token
|
||
parameters:
|
||
- description: 注册信息
|
||
in: body
|
||
name: request
|
||
required: true
|
||
schema:
|
||
$ref: '#/definitions/domain.RegisterRequest'
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
allOf:
|
||
- $ref: '#/definitions/response.Response'
|
||
- properties:
|
||
data:
|
||
$ref: '#/definitions/domain.TokenPair'
|
||
type: object
|
||
"400":
|
||
description: Bad Request
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"409":
|
||
description: Conflict
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
summary: 用户注册
|
||
tags:
|
||
- Auth
|
||
/health:
|
||
get:
|
||
description: 检查 PostgreSQL 和 Redis 连接状态
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
properties:
|
||
database:
|
||
type: string
|
||
redis:
|
||
type: string
|
||
status:
|
||
type: string
|
||
timestamp:
|
||
type: integer
|
||
trace_id:
|
||
type: string
|
||
version:
|
||
type: string
|
||
type: object
|
||
summary: 健康检查
|
||
tags:
|
||
- System
|
||
/password:
|
||
post:
|
||
consumes:
|
||
- application/json
|
||
description: 使用旧密码验证后设置新密码
|
||
parameters:
|
||
- description: 密码修改请求
|
||
in: body
|
||
name: request
|
||
required: true
|
||
schema:
|
||
$ref: '#/definitions/domain.ChangePasswordRequest'
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"400":
|
||
description: Bad Request
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"401":
|
||
description: Unauthorized
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 修改密码
|
||
tags:
|
||
- Auth
|
||
/ping:
|
||
get:
|
||
description: 返回 pong,用于验证认证和多租户中间件是否正常
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 健康探测
|
||
tags:
|
||
- System
|
||
/profile:
|
||
get:
|
||
description: 返回当前认证用户的个人资料
|
||
produces:
|
||
- application/json
|
||
responses:
|
||
"200":
|
||
description: OK
|
||
schema:
|
||
allOf:
|
||
- $ref: '#/definitions/response.Response'
|
||
- properties:
|
||
data:
|
||
$ref: '#/definitions/domain.UserDTO'
|
||
type: object
|
||
"401":
|
||
description: Unauthorized
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
"404":
|
||
description: Not Found
|
||
schema:
|
||
$ref: '#/definitions/response.Response'
|
||
security:
|
||
- Bearer: []
|
||
- TenantID: []
|
||
summary: 获取当前用户信息
|
||
tags:
|
||
- Auth
|
||
securityDefinitions:
|
||
Bearer:
|
||
description: Bearer <token>
|
||
in: header
|
||
name: Authorization
|
||
type: apiKey
|
||
TenantID:
|
||
description: 租户 ID(受保护接口必填)
|
||
in: header
|
||
name: X-Tenant-ID
|
||
type: apiKey
|
||
swagger: "2.0"
|