chore: sync local updates

This commit is contained in:
2026-05-16 19:03:36 +08:00
parent 37983f3b60
commit f1417891ac
101 changed files with 4626 additions and 307 deletions

View File

@@ -5,7 +5,7 @@
],
"swagger": "2.0",
"info": {
"description": "商品、下单、站点统计、收藏与客服聊天用户登录由萌芽账户认证中心SproutGate校验。监听地址以 HTTP_LISTEN_ADDR 为准。",
"description": "萌芽小店电商后端 HTTP API商品、下单结账、订单与支付、站点统计与访问、维护模式、收藏、用户/管理员聊天、萌芽支付 Webhook以及管理端商品/订单/站点与运维状态等。用户身份由萌芽账户认证中心SproutGate签发令牌并完成校验。\n\n**运行环境与基地址**\n- **本地开发**:监听地址由环境变量 `HTTP_LISTEN_ADDR` 决定,未设置时默认为 `:8080`,即常见入口 `http://localhost:8080`。可在浏览器打开 `http://localhost:8080/swagger/index.html` 查看本页同款文档并调试。\n- **生产部署**:线上前台/API 域名为 `https://store.shumengya.top`HTTPS。若前面还有网关、路径前缀或端口映射请在拼接请求 URL 时以实际对外发布地址为准Swagger 中默认 Host 为本地,联调线上时请将浏览器地址或客户端 Base URL 换成生产基地址。\n\n**说明**:本 OpenAPI 由代码注释生成;与进程真实监听、反向代理头无关,仅作契约参考。",
"title": "萌芽小店 API",
"contact": {},
"version": "1.0.0-go"
@@ -15,14 +15,14 @@
"paths": {
"/": {
"get": {
"description": "返回服务描述、主要路径指引与版本(非 OpenAPI 详尽列表,完整契约见 /swagger。",
"description": "访问服务根路径 `/` 返回 JSON服务简介、本地与生产环境说明、主要业务路由分组、运行版本与时间戳。完整请求/响应模型请使用 Swagger UI`GET /swagger/index.html`。本地一般为 `http://localhost:8080/`,生产域名为 `https://store.shumengya.top/`。",
"produces": [
"application/json"
],
"tags": [
"元信息"
],
"summary": "API 根信息与端点索引",
"summary": "根路径 API 说明与路由索引",
"responses": {
"200": {
"description": "OK",
@@ -41,13 +41,14 @@
"AdminToken": []
}
],
"description": "返回每个有过消息的用户账号等信息,供客服选择会话;需管理令牌 `X-Admin-Token`。",
"produces": [
"application/json"
],
"tags": [
"管理端-聊天"
],
"summary": "全部会话列表",
"summary": "管理端:列出全部聊天会话",
"responses": {
"200": {
"description": "OK",
@@ -78,17 +79,18 @@
"AdminToken": []
}
],
"description": "路径参数 `account` 为用户账号标识;返回按时间排列的消息数组;需管理令牌。",
"produces": [
"application/json"
],
"tags": [
"管理端-聊天"
],
"summary": "指定用户聊天记录",
"summary": "管理端:查看某用户的完整聊天记录",
"parameters": [
{
"type": "string",
"description": "用户账号",
"description": "用户账号(路径)",
"name": "account",
"in": "path",
"required": true
@@ -127,6 +129,7 @@
"AdminToken": []
}
],
"description": "路径为对方账号JSON body 含 `content`;写入后用户侧拉取可见。",
"consumes": [
"application/json"
],
@@ -136,17 +139,17 @@
"tags": [
"管理端-聊天"
],
"summary": "管理员回复",
"summary": "管理端:向用户回复一条消息",
"parameters": [
{
"type": "string",
"description": "用户账号",
"description": "用户账号(路径)",
"name": "account",
"in": "path",
"required": true
},
{
"description": "回复内容",
"description": "回复正文 JSON",
"name": "body",
"in": "body",
"required": true,
@@ -188,17 +191,18 @@
"AdminToken": []
}
],
"description": "删除该账号在系统中的全部聊天消息记录;不可恢复请谨慎使用。",
"produces": [
"application/json"
],
"tags": [
"管理端-聊天"
],
"summary": "清空会话",
"summary": "管理端:清空与某用户的会话",
"parameters": [
{
"type": "string",
"description": "用户账号",
"description": "用户账号(路径)",
"name": "account",
"in": "path",
"required": true
@@ -239,13 +243,14 @@
"AdminToken": []
}
],
"description": "返回数据库中订单全量列表(含敏感字段),供后台管理;需 `X-Admin-Token`。",
"produces": [
"application/json"
],
"tags": [
"管理端-订单"
],
"summary": "全部订单(管理)",
"summary": "管理端获取全部订单",
"responses": {
"200": {
"description": "OK",
@@ -275,17 +280,18 @@
"AdminToken": []
}
],
"description": "按路径中的订单 ID 删除记录;不可恢复请谨慎操作。",
"produces": [
"application/json"
],
"tags": [
"管理端-订单"
],
"summary": "删除订单",
"summary": "管理端删除指定订单",
"parameters": [
{
"type": "string",
"description": "订单 ID",
"description": "订单ID",
"name": "id",
"in": "path",
"required": true
@@ -326,13 +332,14 @@
"AdminToken": []
}
],
"description": "含下架商品、卡密字段等完整数据,仅限管理令牌访问。需在请求头携带 `X-Admin-Token`。",
"produces": [
"application/json"
],
"tags": [
"管理端-商品"
],
"summary": "全部商品(管理)",
"summary": "管理端获取全部商品列表",
"responses": {
"200": {
"description": "OK",
@@ -360,6 +367,7 @@
"AdminToken": []
}
],
"description": "提交完整商品载荷:价格、卡密/固定内容、收款码链接、是否上架等。校验失败返回 400。",
"consumes": [
"application/json"
],
@@ -369,10 +377,10 @@
"tags": [
"管理端-商品"
],
"summary": "创建商品",
"summary": "管理端创建商品",
"parameters": [
{
"description": "商品字段",
"description": "商品字段(含可选卡密、截图、收款码等)",
"name": "body",
"in": "body",
"required": true,
@@ -416,6 +424,7 @@
"AdminToken": []
}
],
"description": "路径参数为商品 ID请求体为整包覆盖式更新以服务端绑定逻辑为准。未找到则 404。",
"consumes": [
"application/json"
],
@@ -425,17 +434,17 @@
"tags": [
"管理端-商品"
],
"summary": "更新商品",
"summary": "管理端更新商品",
"parameters": [
{
"type": "string",
"description": "商品 ID",
"description": "商品ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "商品字段",
"description": "待写入的商品字段",
"name": "body",
"in": "body",
"required": true,
@@ -483,17 +492,18 @@
"AdminToken": []
}
],
"description": "按 ID 永久删除商品记录(影响以数据库外键/业务逻辑为准),需管理令牌。",
"produces": [
"application/json"
],
"tags": [
"管理端-商品"
],
"summary": "删除商品",
"summary": "管理端删除商品",
"parameters": [
{
"type": "string",
"description": "商品 ID",
"description": "商品ID",
"name": "id",
"in": "path",
"required": true
@@ -528,6 +538,7 @@
"AdminToken": []
}
],
"description": "PATCH 请求体为 `{ \"active\": true|false }`,用于快速上下架而不改其它字段。",
"consumes": [
"application/json"
],
@@ -537,17 +548,17 @@
"tags": [
"管理端-商品"
],
"summary": "切换上架状态",
"summary": "管理端切换商品上架状态",
"parameters": [
{
"type": "string",
"description": "商品 ID",
"description": "商品ID",
"name": "id",
"in": "path",
"required": true
},
{
"description": "{active}",
"description": "上架开关 { \\",
"name": "body",
"in": "body",
"required": true,
@@ -591,6 +602,7 @@
"AdminToken": []
}
],
"description": "打开维护后前台可展示原因文案;需管理令牌。请求体含 `maintenance` 布尔与可选 `reason`。",
"consumes": [
"application/json"
],
@@ -600,10 +612,10 @@
"tags": [
"管理端-站点"
],
"summary": "设置维护模式",
"summary": "设置全站维护模式",
"parameters": [
{
"description": "维护开关与原因",
"description": "maintenance 与 reason",
"name": "body",
"in": "body",
"required": true,
@@ -647,13 +659,14 @@
"AdminToken": []
}
],
"description": "返回当前站点发件配置;密码字段以占位符脱敏显示,不会返回明文。",
"produces": [
"application/json"
],
"tags": [
"管理端-站点"
],
"summary": "获取 SMTP 配置",
"summary": "获取发信 SMTP 配置(脱敏)",
"responses": {
"200": {
"description": "OK",
@@ -681,6 +694,7 @@
"AdminToken": []
}
],
"description": "写入 SMTP 主机、端口、账号等;若密码仍为脱敏占位符则保留库中已有密码(实现细节见服务逻辑)。",
"consumes": [
"application/json"
],
@@ -690,10 +704,10 @@
"tags": [
"管理端-站点"
],
"summary": "保存 SMTP 配置",
"summary": "保存发信 SMTP 配置",
"parameters": [
{
"description": "SMTP 字段",
"description": "SMTP 连接与发件人信息",
"name": "body",
"in": "body",
"required": true,
@@ -737,13 +751,14 @@
"AdminToken": []
}
],
"description": "聚合展示配置摘要、数据库/MySQL、RabbitMQ、Redis 等探测结果与进程启动时间,便于运维排查;需管理令牌。",
"produces": [
"application/json"
],
"tags": [
"管理端-系统"
],
"summary": "系统运行状态",
"summary": "管理端系统运行状态与依赖探活",
"responses": {
"200": {
"description": "OK",
@@ -763,7 +778,7 @@
},
"/api/admin/verify": {
"post": {
"description": "响应为 {\"valid\": true/false},不泄露真实口令。",
"description": "请求体 JSON 含 `token` 字段;响应仅返回 `{\"valid\": true|false}`,不会返回真实口令或敏感信息。",
"consumes": [
"application/json"
],
@@ -773,10 +788,10 @@
"tags": [
"管理端-认证"
],
"summary": "校验管理令牌",
"summary": "校验管理令牌是否有效",
"parameters": [
{
"description": "待校验 token",
"description": "待校验的管理员 tokenJSON",
"name": "body",
"in": "body",
"required": true,
@@ -802,13 +817,14 @@
"BearerAuth": []
}
],
"description": "需在请求头携带有效的 `Authorization: Bearer \u003ctoken\u003e`。返回该登录用户在客服系统中与管理员往来的全部消息列表。",
"produces": [
"application/json"
],
"tags": [
"聊天(用户)"
],
"summary": "我的聊天消息",
"summary": "拉取当前用户聊天记录",
"responses": {
"200": {
"description": "OK",
@@ -836,6 +852,7 @@
"BearerAuth": []
}
],
"description": "需在请求头携带 Bearer。正文为 JSON `content` 字段;可能因频率限制返回 429。",
"consumes": [
"application/json"
],
@@ -845,10 +862,10 @@
"tags": [
"聊天(用户)"
],
"summary": "发送用户消息",
"summary": "用户发送聊天消息",
"parameters": [
{
"description": "消息正文",
"description": "消息正文JSON",
"name": "body",
"in": "body",
"required": true,
@@ -893,6 +910,7 @@
},
"/api/checkout": {
"post": {
"description": "根据商品配置决定是否需要登录(`requireLogin`)。可附带 `Authorization: Bearer` 以关联账号、限购与通知邮箱。付费订单走萌芽支付时需商品已配置收款码;同一商品在他人待支付锁定期内可能返回 409同一账号存在待支付单时也可能冲突。成功返回订单概要及二维码链接等。",
"consumes": [
"application/json"
],
@@ -902,16 +920,16 @@
"tags": [
"订单"
],
"summary": "结账创建订单",
"summary": "结账创建订单",
"parameters": [
{
"type": "string",
"description": "Bearer 用户 token部分商品必填",
"description": "可选;格式 Bearer + 空格 + token部分商品必填",
"name": "Authorization",
"in": "header"
},
{
"description": "结账参数",
"description": "结账请求体:商品、数量、联系方式等",
"name": "body",
"in": "body",
"required": true,
@@ -946,7 +964,7 @@
}
},
"409": {
"description": "库存锁定冲突或同用户待支付",
"description": "库存锁定冲突(他人正在支付)或同账号待支付单未满间隔",
"schema": {
"$ref": "#/definitions/handlers.SwaggerErrorBody"
}
@@ -962,6 +980,7 @@
},
"/api/health": {
"get": {
"description": "用于负载均衡或编排探活:`status` 恒为 ok 表示 HTTP 服务存活;`rabbitmq` 为 `disabled`(未启用消息队列客户端)、`ok`(连接可用)或以 `error:` 开头的错误片段。",
"produces": [
"application/json"
],
@@ -971,7 +990,7 @@
"summary": "健康检查",
"responses": {
"200": {
"description": "status okrabbitmq 为 disabled|ok|error:...",
"description": "status okrabbitmq 为 disabledokerror: 前缀错误信息",
"schema": {
"type": "object",
"additionalProperties": true
@@ -987,13 +1006,14 @@
"BearerAuth": []
}
],
"description": "必须携带有效 Bearer。列表中处于待支付状态的订单不会包含已分配卡密等敏感字段防止泄露。",
"produces": [
"application/json"
],
"tags": [
"订单"
],
"summary": "的订单",
"summary": "查询当前登录用户的订单列表",
"responses": {
"200": {
"description": "OK",
@@ -1018,17 +1038,18 @@
},
"/api/orders/{id}/cancel": {
"post": {
"description": "仅对允许取消的状态生效(如待支付);已完成订单会冲突。成功时释放预留库存/卡密占用。请勿在公网暴露此能力时省略鉴权策略(实现以代码为准)。",
"produces": [
"application/json"
],
"tags": [
"订单"
],
"summary": "取消订单",
"summary": "取消待支付订单",
"parameters": [
{
"type": "string",
"description": "订单 ID",
"description": "订单ID",
"name": "id",
"in": "path",
"required": true
@@ -1064,17 +1085,18 @@
},
"/api/orders/{id}/confirm": {
"post": {
"description": "用于用户侧「确认」动作:已完成订单直接返回数据;待支付时若仍未到账则 409已取消或超时 410。手动发货等场景下会触发邮件通知若配置。",
"produces": [
"application/json"
],
"tags": [
"订单"
],
"summary": "确认订单",
"summary": "确认订单(核销/完成流程)",
"parameters": [
{
"type": "string",
"description": "订单 ID",
"description": "订单ID",
"name": "id",
"in": "path",
"required": true
@@ -1094,13 +1116,13 @@
}
},
"409": {
"description": "待支付到账等",
"description": "待支付但金额未核对到账等",
"schema": {
"$ref": "#/definitions/handlers.SwaggerErrorBody"
}
},
"410": {
"description": "已取消或超时",
"description": "订单已取消或已超过待支付时限",
"schema": {
"$ref": "#/definitions/handlers.SwaggerErrorBody"
}
@@ -1110,17 +1132,18 @@
},
"/api/orders/{id}/payment-status": {
"get": {
"description": "供前端轮询待支付订单:返回状态、应付快照、过期时间等;不包含卡密等敏感发货内容。路径参数为订单 ID。",
"produces": [
"application/json"
],
"tags": [
"订单"
],
"summary": "订单支付状态",
"summary": "查询订单支付状态(轮询)",
"parameters": [
{
"type": "string",
"description": "订单 ID",
"description": "订单ID",
"name": "id",
"in": "path",
"required": true
@@ -1144,13 +1167,14 @@
},
"/api/products": {
"get": {
"description": "返回当前处于「上架」状态的商品集合,仅包含前台展示所需字段(不含卡密、管理字段等)。无需登录。",
"produces": [
"application/json"
],
"tags": [
"公开"
],
"summary": "上架商品列表",
"summary": "获取上架商品列表",
"responses": {
"200": {
"description": "OK",
@@ -1169,17 +1193,18 @@
},
"/api/products/{id}/view": {
"post": {
"description": "对指定商品增加浏览计数;是否计入由服务端对访客指纹去重策略决定,用于热门统计。路径参数为商品 ID。",
"produces": [
"application/json"
],
"tags": [
"公开"
],
"summary": "记录商品浏览",
"summary": "记录商品浏览次数",
"parameters": [
{
"type": "string",
"description": "商品 ID",
"description": "商品ID(路径)",
"name": "id",
"in": "path",
"required": true
@@ -1203,13 +1228,14 @@
},
"/api/site/maintenance": {
"get": {
"description": "返回当前是否开启全站维护、以及展示给前端的维护原因文案(公开接口,无需管理令牌)。",
"produces": [
"application/json"
],
"tags": [
"公开"
],
"summary": "维护模式状态",
"summary": "获取维护模式状态",
"responses": {
"200": {
"description": "OK",
@@ -1228,13 +1254,14 @@
},
"/api/site/visit": {
"post": {
"description": "记录访客一次访问并累加全站访问计数;是否计入由服务端指纹等策略决定,响应中含最新总访问量与本次是否计入。",
"produces": [
"application/json"
],
"tags": [
"公开"
],
"summary": "记录站点访问",
"summary": "上报一次站点访问",
"responses": {
"200": {
"description": "OK",
@@ -1253,13 +1280,14 @@
},
"/api/stats": {
"get": {
"description": "返回全站累计订单数与累计访问量(公开读,用于首页展示等)。",
"produces": [
"application/json"
],
"tags": [
"公开"
],
"summary": "站点统计",
"summary": "获取站点聚合统计",
"responses": {
"200": {
"description": "OK",
@@ -1278,6 +1306,7 @@
},
"/api/webhooks/mengya-pay": {
"post": {
"description": "由支付渠道/转发服务 POST 原始 JSON服务端解析到账金额并尝试匹配待支付订单。若配置 `WEBHOOK_MENGYA_SECRET`,请求头 `X-Webhook-Secret` 必须与其一致。本地联调与生产 `https://store.shumengya.top` 均使用同一路径,由部署时的域名与 TLS 决定回调 URL。",
"consumes": [
"application/json"
],
@@ -1287,11 +1316,11 @@
"tags": [
"Webhook"
],
"summary": "萌芽支付 Webhook",
"summary": "萌芽支付到账 Webhook",
"parameters": [
{
"type": "string",
"description": "与 WEBHOOK_MENGYA_SECRET 一致",
"description": "与进程环境变量 WEBHOOK_MENGYA_SECRET 一致;未配置密钥时可不填",
"name": "X-Webhook-Secret",
"in": "header"
}
@@ -1331,13 +1360,14 @@
"BearerAuth": []
}
],
"description": "需 Bearer 登录。返回该账号已收藏的商品 ID 数组(顺序由存储实现决定)。",
"produces": [
"application/json"
],
"tags": [
"收藏"
],
"summary": "收藏列表",
"summary": "获取当前用户收藏列表",
"responses": {
"200": {
"description": "OK",
@@ -1365,6 +1395,7 @@
"BearerAuth": []
}
],
"description": "需 Bearer。请求体为 `{ \"productId\": \"...\" }`;幂等语义由存储层实现(重复添加可忽略或报错以实际为准)。",
"consumes": [
"application/json"
],
@@ -1374,10 +1405,10 @@
"tags": [
"收藏"
],
"summary": "添加收藏",
"summary": "添加商品到收藏",
"parameters": [
{
"description": "商品 ID",
"description": "包含 productId 的 JSON",
"name": "body",
"in": "body",
"required": true,
@@ -1421,17 +1452,18 @@
"BearerAuth": []
}
],
"description": "需 Bearer。路径参数为要移除的商品 ID。",
"produces": [
"application/json"
],
"tags": [
"收藏"
],
"summary": "移除收藏",
"summary": "从收藏中移除商品",
"parameters": [
{
"type": "string",
"description": "商品 ID",
"description": "商品ID(路径)",
"name": "id",
"in": "path",
"required": true
@@ -2153,19 +2185,19 @@
},
"securityDefinitions": {
"AdminToken": {
"description": "管理端令牌(也可使用 Authorization 头或 query token,见各接口说明)",
"description": "管理端访问令牌:与进程环境变量 `ADMIN_TOKEN` 一致。部分管理路由也可使用 `Authorization` 头或 Query `token`(以具体路由实现为准)。",
"type": "apiKey",
"name": "X-Admin-Token",
"in": "header"
},
"BearerAuth": {
"description": "用户访问令牌,格式: Bearer 空格 + token",
"description": "用户访问令牌:请求头 `Authorization`,值为 `Bearer ` 后接 SproutGate 返回的 JWT/access token部分公开接口可不携带",
"type": "apiKey",
"name": "Authorization",
"in": "header"
},
"WebhookSecret": {
"description": "服务端 WEBHOOK_MENGYA_SECRET 一致时校验萌芽支付 Webhook",
"description": "服务端配置了 `WEBHOOK_MENGYA_SECRET` 时,萌芽支付到账回调 `POST /api/webhooks/mengya-pay` 需携带本头且值与密钥完全一致,否则返回 403。",
"type": "apiKey",
"name": "X-Webhook-Secret",
"in": "header"