接口响应与文档文案全部改为英文

- 错误响应、健康检查等运行时文案改为英文
- 种子数据英文化,新增迁移 v5 更新存量内置数据(不覆盖手工修改)
- Swagger 注释与 docs/ 文档全英文化
- 补充英文文案断言与 v5 迁移测试
This commit is contained in:
2026-09-20 02:13:17 +08:00
parent b683fb293e
commit 2858d3c0f7
16 files changed
+603 -489

No files matched your search

+112 -112
View File
@@ -17,7 +17,7 @@ const docTemplate = `{
"paths": {
"/auth/login": {
"post": {
"description": "使用用户名或邮箱登录,成功返回 JWT(有效期见 auth.token_ttl)与用户信息。",
"description": "Login with username or email; returns a JWT (TTL from auth.token_ttl) and the user.",
"consumes": [
"application/json"
],
@@ -30,7 +30,7 @@ const docTemplate = `{
"summary": "Login",
"parameters": [
{
"description": "登录凭证",
"description": "Login credentials",
"name": "credentials",
"in": "body",
"required": true,
@@ -47,19 +47,19 @@ const docTemplate = `{
}
},
"400": {
"description": "参数无效",
"description": "invalid request",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"401": {
"description": "账号或密码错误",
"description": "incorrect account or password",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"403": {
"description": "账号已被禁用",
"description": "account disabled",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
@@ -75,7 +75,7 @@ const docTemplate = `{
},
"/auth/register": {
"post": {
"description": "公开注册,创建普通用户并默认加入普通用户组(id 1)。username 长度 3-50 且唯一,email 唯一,password 长度 6-72",
"description": "Public registration. Creates a regular user in the default user group (id 1). username is 3-50 chars and unique; email is unique; password is 6-72 chars.",
"consumes": [
"application/json"
],
@@ -88,7 +88,7 @@ const docTemplate = `{
"summary": "Register",
"parameters": [
{
"description": "注册信息",
"description": "Registration payload",
"name": "user",
"in": "body",
"required": true,
@@ -105,13 +105,13 @@ const docTemplate = `{
}
},
"400": {
"description": "参数无效",
"description": "invalid request",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"409": {
"description": "用户名或邮箱已存在",
"description": "username or email already exists",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
@@ -127,7 +127,7 @@ const docTemplate = `{
},
"/health": {
"get": {
"description": "检查服务与数据库连接状态;数据库不可用时返回 503。",
"description": "Check service and database connectivity; returns 503 when the database is unavailable.",
"produces": [
"application/json"
],
@@ -158,7 +158,7 @@ const docTemplate = `{
"BearerAuth": []
}
],
"description": "分页查询便签列表,按 id 倒序返回。page 从 1 开始;page_size 取值 1-100,默认 20",
"description": "List notes ordered by id DESC. page starts at 1; page_size is 1-100, default 20.",
"produces": [
"application/json"
],
@@ -170,14 +170,14 @@ const docTemplate = `{
{
"type": "integer",
"example": 1,
"description": "页码,默认 1",
"description": "Page number, default 1",
"name": "page",
"in": "query"
},
{
"type": "integer",
"example": 20,
"description": "每页数量,默认 20,最大 100",
"description": "Page size, default 20, max 100",
"name": "page_size",
"in": "query"
}
@@ -190,13 +190,13 @@ const docTemplate = `{
}
},
"401": {
"description": "未登录或登录已过期",
"description": "unauthorized or session expired",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"403": {
"description": "账号已被禁用",
"description": "account disabled",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
@@ -215,7 +215,7 @@ const docTemplate = `{
"BearerAuth": []
}
],
"description": "创建便签。title 必填且最长 200 字符,content 可选。",
"description": "Create a note. title is required (max 200 chars); content is optional.",
"consumes": [
"application/json"
],
@@ -228,7 +228,7 @@ const docTemplate = `{
"summary": "Create a note",
"parameters": [
{
"description": "便签内容",
"description": "Note payload",
"name": "note",
"in": "body",
"required": true,
@@ -245,19 +245,19 @@ const docTemplate = `{
}
},
"400": {
"description": "参数无效",
"description": "invalid request",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"401": {
"description": "未登录或登录已过期",
"description": "unauthorized or session expired",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"403": {
"description": "账号已被禁用",
"description": "account disabled",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
@@ -278,7 +278,7 @@ const docTemplate = `{
"BearerAuth": []
}
],
"description": "按 id 查询单个便签。",
"description": "Get a note by id.",
"produces": [
"application/json"
],
@@ -290,7 +290,7 @@ const docTemplate = `{
{
"type": "integer",
"example": 1,
"description": "便签 ID",
"description": "Note ID",
"name": "id",
"in": "path",
"required": true
@@ -304,25 +304,25 @@ const docTemplate = `{
}
},
"400": {
"description": "id 无效",
"description": "invalid id",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"401": {
"description": "未登录或登录已过期",
"description": "unauthorized or session expired",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"403": {
"description": "账号已被禁用",
"description": "account disabled",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"404": {
"description": "记录不存在",
"description": "record not found",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
@@ -341,7 +341,7 @@ const docTemplate = `{
"BearerAuth": []
}
],
"description": "全量更新便签的 title content,字段校验规则同创建。",
"description": "Update title and content; validation is the same as create.",
"consumes": [
"application/json"
],
@@ -356,13 +356,13 @@ const docTemplate = `{
{
"type": "integer",
"example": 1,
"description": "便签 ID",
"description": "Note ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "便签内容",
"description": "Note payload",
"name": "note",
"in": "body",
"required": true,
@@ -379,25 +379,25 @@ const docTemplate = `{
}
},
"400": {
"description": "参数无效或 id 无效",
"description": "invalid request or id",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"401": {
"description": "未登录或登录已过期",
"description": "unauthorized or session expired",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"403": {
"description": "账号已被禁用",
"description": "account disabled",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"404": {
"description": "记录不存在",
"description": "record not found",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
@@ -416,7 +416,7 @@ const docTemplate = `{
"BearerAuth": []
}
],
"description": "按 id 删除便签,成功时返回 204 且无响应体。",
"description": "Delete a note by id; returns 204 with no body on success.",
"produces": [
"application/json"
],
@@ -428,7 +428,7 @@ const docTemplate = `{
{
"type": "integer",
"example": 1,
"description": "便签 ID",
"description": "Note ID",
"name": "id",
"in": "path",
"required": true
@@ -436,28 +436,28 @@ const docTemplate = `{
],
"responses": {
"204": {
"description": "删除成功"
"description": "Deleted"
},
"400": {
"description": "id 无效",
"description": "invalid id",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"401": {
"description": "未登录或登录已过期",
"description": "unauthorized or session expired",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"403": {
"description": "账号已被禁用",
"description": "account disabled",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"404": {
"description": "记录不存在",
"description": "record not found",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
@@ -478,7 +478,7 @@ const docTemplate = `{
"BearerAuth": []
}
],
"description": "分页查询用户组列表,按 id 升序返回。page 从 1 开始;page_size 取值 1-100,默认 20",
"description": "List user groups ordered by id ASC. page starts at 1; page_size is 1-100, default 20.",
"produces": [
"application/json"
],
@@ -490,14 +490,14 @@ const docTemplate = `{
{
"type": "integer",
"example": 1,
"description": "页码,默认 1",
"description": "Page number, default 1",
"name": "page",
"in": "query"
},
{
"type": "integer",
"example": 20,
"description": "每页数量,默认 20,最大 100",
"description": "Page size, default 20, max 100",
"name": "page_size",
"in": "query"
}
@@ -510,13 +510,13 @@ const docTemplate = `{
}
},
"401": {
"description": "未登录或登录已过期",
"description": "unauthorized or session expired",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"403": {
"description": "需要管理员权限或账号已被禁用",
"description": "admin permission required or account disabled",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
@@ -535,7 +535,7 @@ const docTemplate = `{
"BearerAuth": []
}
],
"description": "创建用户组。name 必填且唯一(最长 50 字符),description 可选(最长 255 字符);id 由服务端分配。",
"description": "Create a user group. name is required and unique (max 50 chars); description is optional (max 255 chars); id is assigned by the server.",
"consumes": [
"application/json"
],
@@ -548,7 +548,7 @@ const docTemplate = `{
"summary": "Create a user group",
"parameters": [
{
"description": "用户组信息",
"description": "User group payload",
"name": "group",
"in": "body",
"required": true,
@@ -565,25 +565,25 @@ const docTemplate = `{
}
},
"400": {
"description": "参数无效",
"description": "invalid request",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"401": {
"description": "未登录或登录已过期",
"description": "unauthorized or session expired",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"403": {
"description": "需要管理员权限或账号已被禁用",
"description": "admin permission required or account disabled",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"409": {
"description": "用户组名称已存在",
"description": "user group name already exists",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
@@ -604,7 +604,7 @@ const docTemplate = `{
"BearerAuth": []
}
],
"description": "按 id 查询单个用户组,id 0 为内置 admin 组。",
"description": "Get a user group by id; id 0 is the built-in admin group.",
"produces": [
"application/json"
],
@@ -616,7 +616,7 @@ const docTemplate = `{
{
"type": "integer",
"example": 1,
"description": "用户组 ID",
"description": "User group ID",
"name": "id",
"in": "path",
"required": true
@@ -630,25 +630,25 @@ const docTemplate = `{
}
},
"400": {
"description": "id 无效",
"description": "invalid id",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"401": {
"description": "未登录或登录已过期",
"description": "unauthorized or session expired",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"403": {
"description": "需要管理员权限或账号已被禁用",
"description": "admin permission required or account disabled",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"404": {
"description": "记录不存在",
"description": "record not found",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
@@ -667,7 +667,7 @@ const docTemplate = `{
"BearerAuth": []
}
],
"description": "更新用户组的 name descriptionname 必填且唯一。",
"description": "Update a user group's name and description; name is required and unique.",
"consumes": [
"application/json"
],
@@ -682,13 +682,13 @@ const docTemplate = `{
{
"type": "integer",
"example": 1,
"description": "用户组 ID",
"description": "User group ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "用户组信息",
"description": "User group payload",
"name": "group",
"in": "body",
"required": true,
@@ -705,31 +705,31 @@ const docTemplate = `{
}
},
"400": {
"description": "参数无效或 id 无效",
"description": "invalid request or id",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"401": {
"description": "未登录或登录已过期",
"description": "unauthorized or session expired",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"403": {
"description": "需要管理员权限或账号已被禁用",
"description": "admin permission required or account disabled",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"404": {
"description": "记录不存在",
"description": "record not found",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"409": {
"description": "用户组名称已存在",
"description": "user group name already exists",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
@@ -748,7 +748,7 @@ const docTemplate = `{
"BearerAuth": []
}
],
"description": "按 id 删除用户组,成功时返回 204 且无响应体。系统内置组或组内仍有用户时返回 409。",
"description": "Delete a user group by id; returns 204 with no body on success. Returns 409 for system groups or when the group still has members.",
"produces": [
"application/json"
],
@@ -760,7 +760,7 @@ const docTemplate = `{
{
"type": "integer",
"example": 2,
"description": "用户组 ID",
"description": "User group ID",
"name": "id",
"in": "path",
"required": true
@@ -768,34 +768,34 @@ const docTemplate = `{
],
"responses": {
"204": {
"description": "删除成功"
"description": "Deleted"
},
"400": {
"description": "id 无效",
"description": "invalid id",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"401": {
"description": "未登录或登录已过期",
"description": "unauthorized or session expired",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"403": {
"description": "需要管理员权限或账号已被禁用",
"description": "admin permission required or account disabled",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"404": {
"description": "记录不存在",
"description": "record not found",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"409": {
"description": "系统内置组不可删除或用户组内仍有用户",
"description": "system group cannot be deleted or group still has members",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
@@ -816,7 +816,7 @@ const docTemplate = `{
"BearerAuth": []
}
],
"description": "分页查询用户列表(含所属用户组),按 id 倒序返回。page 从 1 开始;page_size 取值 1-100,默认 20",
"description": "List users with their groups, ordered by id DESC. page starts at 1; page_size is 1-100, default 20.",
"produces": [
"application/json"
],
@@ -828,14 +828,14 @@ const docTemplate = `{
{
"type": "integer",
"example": 1,
"description": "页码,默认 1",
"description": "Page number, default 1",
"name": "page",
"in": "query"
},
{
"type": "integer",
"example": 20,
"description": "每页数量,默认 20,最大 100",
"description": "Page size, default 20, max 100",
"name": "page_size",
"in": "query"
}
@@ -848,13 +848,13 @@ const docTemplate = `{
}
},
"401": {
"description": "未登录或登录已过期",
"description": "unauthorized or session expired",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"403": {
"description": "需要管理员权限或账号已被禁用",
"description": "admin permission required or account disabled",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
@@ -873,7 +873,7 @@ const docTemplate = `{
"BearerAuth": []
}
],
"description": "创建用户并关联用户组。usernameemail 唯一,password 长度 6-72;不传 group_ids 时默认加入普通用户组(id 1)。",
"description": "Create a user and assign groups. username and email are unique; password is 6-72 chars; defaults to the regular user group (id 1) when group_ids is omitted.",
"consumes": [
"application/json"
],
@@ -886,7 +886,7 @@ const docTemplate = `{
"summary": "Create a user",
"parameters": [
{
"description": "用户信息",
"description": "User payload",
"name": "user",
"in": "body",
"required": true,
@@ -903,25 +903,25 @@ const docTemplate = `{
}
},
"400": {
"description": "参数无效或用户组不存在",
"description": "invalid request or user group not found",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"401": {
"description": "未登录或登录已过期",
"description": "unauthorized or session expired",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"403": {
"description": "需要管理员权限或账号已被禁用",
"description": "admin permission required or account disabled",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"409": {
"description": "用户名或邮箱已存在",
"description": "username or email already exists",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
@@ -942,7 +942,7 @@ const docTemplate = `{
"BearerAuth": []
}
],
"description": "按 id 查询用户(含所属用户组)。",
"description": "Get a user by id, including groups.",
"produces": [
"application/json"
],
@@ -954,7 +954,7 @@ const docTemplate = `{
{
"type": "integer",
"example": 1,
"description": "用户 ID",
"description": "User ID",
"name": "id",
"in": "path",
"required": true
@@ -968,25 +968,25 @@ const docTemplate = `{
}
},
"400": {
"description": "id 无效",
"description": "invalid id",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"401": {
"description": "未登录或登录已过期",
"description": "unauthorized or session expired",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"403": {
"description": "需要管理员权限或账号已被禁用",
"description": "admin permission required or account disabled",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"404": {
"description": "记录不存在",
"description": "record not found",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
@@ -1005,7 +1005,7 @@ const docTemplate = `{
"BearerAuth": []
}
],
"description": "更新用户信息,仅更新请求中提供的字段。传 group_ids 会整体替换用户组;password 非空时重置密码。",
"description": "Update user fields. group_ids replaces all groups; a non-empty password resets the password.",
"consumes": [
"application/json"
],
@@ -1020,13 +1020,13 @@ const docTemplate = `{
{
"type": "integer",
"example": 1,
"description": "用户 ID",
"description": "User ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "待更新字段",
"description": "Fields to update",
"name": "user",
"in": "body",
"required": true,
@@ -1043,25 +1043,25 @@ const docTemplate = `{
}
},
"400": {
"description": "参数无效、id 无效或用户组不存在",
"description": "invalid request, id, or user group not found",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"401": {
"description": "未登录或登录已过期",
"description": "unauthorized or session expired",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"403": {
"description": "需要管理员权限或账号已被禁用",
"description": "admin permission required or account disabled",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"404": {
"description": "记录不存在",
"description": "record not found",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
@@ -1080,7 +1080,7 @@ const docTemplate = `{
"BearerAuth": []
}
],
"description": "按 id 删除用户及其用户组成员关系,成功时返回 204 且无响应体。",
"description": "Delete a user and their group memberships; returns 204 with no body on success.",
"produces": [
"application/json"
],
@@ -1092,7 +1092,7 @@ const docTemplate = `{
{
"type": "integer",
"example": 1,
"description": "用户 ID",
"description": "User ID",
"name": "id",
"in": "path",
"required": true
@@ -1100,28 +1100,28 @@ const docTemplate = `{
],
"responses": {
"204": {
"description": "删除成功"
"description": "Deleted"
},
"400": {
"description": "id 无效",
"description": "invalid id",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"401": {
"description": "未登录或登录已过期",
"description": "unauthorized or session expired",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"403": {
"description": "需要管理员权限或账号已被禁用",
"description": "admin permission required or account disabled",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
},
"404": {
"description": "记录不存在",
"description": "record not found",
"schema": {
"$ref": "#/definitions/httpx.ErrorResponse"
}
@@ -1142,7 +1142,7 @@ const docTemplate = `{
"properties": {
"error": {
"type": "string",
"example": "数据库不可用"
"example": "database unavailable"
},
"status": {
"type": "string",
@@ -1215,7 +1215,7 @@ const docTemplate = `{
"properties": {
"error": {
"type": "string",
"example": "记录不存在"
"example": "record not found"
}
}
},
@@ -1328,12 +1328,12 @@ const docTemplate = `{
"properties": {
"content": {
"type": "string",
"example": "牛奶、鸡蛋"
"example": "Milk, eggs"
},
"title": {
"type": "string",
"maxLength": 200,
"example": "购物清单"
"example": "Shopping list"
}
}
},
@@ -1483,19 +1483,19 @@ const docTemplate = `{
"description": {
"type": "string",
"maxLength": 255,
"example": "负责日常运营"
"example": "Handles daily operations"
},
"name": {
"type": "string",
"maxLength": 50,
"example": "运营组"
"example": "Operations"
}
}
}
},
"securityDefinitions": {
"BearerAuth": {
"description": "Bearer JWT,格式:Bearer {token},通过 /auth/login 获取",
"description": "Bearer JWT, format: Bearer {token}, obtained from /auth/login",
"type": "apiKey",
"name": "Authorization",
"in": "header"
@@ -1510,7 +1510,7 @@ var SwaggerInfo = &swag.Spec{
BasePath: "/api",
Schemes: []string{},
Title: "Rill API",
Description: "Rill 服务端 HTTP API 文档,所有接口以配置项 api.prefix(默认 /api)为前缀,请求与响应均为 JSON\nSwagger 页面:{prefix}/swagger/index.htmlOpenAPI JSON{prefix}/swagger/doc.json\n healthswagger、auth 外,其余接口需要 Bearer JWT:先调用 /auth/login 获取 token,再在请求头携带 Authorization: Bearer {token}",
Description: "Rill server HTTP API documentation. All endpoints are prefixed with api.prefix (default /api); requests and responses are JSON.\nSwagger UI: {prefix}/swagger/index.html; OpenAPI JSON: {prefix}/swagger/doc.json.\nExcept for health, swagger, and auth, all endpoints require a Bearer JWT: call /auth/login to get a token, then send Authorization: Bearer {token}.",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",