Compare commits
12
Commits
85966705b3
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
684d7e19dc | ||
|
|
19544b1fd2 | ||
|
|
34d9b189d2 | ||
|
|
247535000b | ||
|
|
57422a64f2 | ||
|
|
164dc4aef1 | ||
|
|
765561aad2 | ||
|
|
23204f3a48 | ||
|
|
02193b2ad1 | ||
|
|
62a2bbfe44 | ||
|
|
dd82259221 | ||
|
|
3f4a85a3d3 |
@@ -46,5 +46,9 @@ build/
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Python ###
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
||||
|
||||
+15
-3
@@ -36,9 +36,11 @@ bash scripts/export-openapi.sh http://192.168.1.10:18092 docs/openapi.local.json
|
||||
|
||||
`docs/openapi.local.*` 是本地快照,已在 `.gitignore` 中忽略,不应提交。需要给远程 AI Agent 使用时,优先发送该文件,而不是 `localhost` 地址。
|
||||
|
||||
导出脚本会同时生成面向 AI Agent 的接口索引 `docs/openapi.index.md`:按业务模块列出接口的方法、路径、摘要、参数、请求体与响应 schema。索引体积远小于完整 OpenAPI,适合先用于定位,再读取 OpenAPI 中的对应片段。PowerShell 使用 `-NoIndex`、Bash 使用 `SKIP_INDEX=1` 可跳过索引生成。
|
||||
|
||||
### 1.2 覆盖范围说明
|
||||
|
||||
SpringDoc 会扫描项目中的全部 Controller,因此 OpenAPI 文件里会包含用户、标签、系统设置等模块的接口。本次只对文件模块与异步任务模块的 7 个 Controller 补充了完整的中文 `@Tag` / `@Operation` / `@Parameter` 描述;这些接口的路径、参数、请求体和响应结构均已包含在 OpenAPI 中。其他模块的接口属于 SpringDoc 自动生成的基础描述,业务语义可能不完整,复杂接口请结合源码或联调确认。
|
||||
SpringDoc 会扫描项目中的全部 Controller,因此 OpenAPI 文件里会包含用户、标签、系统设置等模块的接口。目前已对文件、异步任务与系统设置模块的 8 个 Controller 补充了完整的中文 `@Tag` / `@Operation` / `@Parameter` 描述;这些接口的路径、参数、请求体和响应结构均已包含在 OpenAPI 中。其他模块的接口属于 SpringDoc 自动生成的基础描述,业务语义可能不完整,复杂接口请结合源码或联调确认。
|
||||
|
||||
OpenAPI 中还声明了全局 `Token` 安全要求,但登录、注册等公开接口实际可能不需要登录。**是否需要鉴权以接口实际行为为准**;公开接口已在 OpenAPI 中按操作单独标记 `security`。
|
||||
|
||||
@@ -203,6 +205,15 @@ Accept-Language: zh-CN
|
||||
|
||||
具体哪些接口属于二进制响应,以 OpenAPI 中定义的响应 `Content-Type` 为准。
|
||||
|
||||
#### 缩略图预览
|
||||
|
||||
`GET /system/file/preview/{path}` 仅支持图片和视频,其他类型返回 `400`。图片和视频统一返回缩略图:
|
||||
|
||||
- `size`:缩略图最大边长(像素),范围 `32-512`,默认 `256`
|
||||
- `v`:缓存版本号,建议传文件列表返回的 `etag`;传入后响应使用一年强缓存,不传时缓存一天
|
||||
- 响应 `Content-Type` 为 `image/jpeg` 或 `image/png`;PNG/GIF 源图使用 PNG,其余使用 JPEG
|
||||
- 支持 `If-None-Match` 条件请求,`ETag` 已包含缩略图尺寸和算法版本
|
||||
|
||||
### 3.2 SSE
|
||||
|
||||
部分长任务接口使用 `text/event-stream`,不经过 `TimiResponse`。事件类型如下:
|
||||
@@ -241,7 +252,7 @@ source.addEventListener("done", (event) => {
|
||||
|
||||
## 4. AI Agent 对接建议
|
||||
|
||||
1. **优先使用导出的 OpenAPI 文件**,不要只给 `localhost` URL。远程 Agent 无法访问本机地址。
|
||||
1. **优先使用导出的 OpenAPI 文件**,不要只给 `localhost` URL。远程 Agent 无法访问本机地址。可先读 `docs/openapi.index.md` 定位模块和接口,再读取 OpenAPI 中的对应片段,避免整份文档占用上下文。
|
||||
2. 用 OpenAPI 生成 TypeScript 类型和请求客户端,再在客户端层统一补充 `TimiResponse` 包装。
|
||||
3. 不要假设 OpenAPI 的返回类型就是最终响应体;普通 JSON 接口需要取 `data`。
|
||||
4. 二进制接口单独处理:使用 `blob` / `arrayBuffer`,按 HTTP 状态判断成败。
|
||||
@@ -265,7 +276,8 @@ code <= 30000 表示成功。鉴权使用 Token 请求头。
|
||||
## 5. 已知限制
|
||||
|
||||
- OpenAPI 的响应 Schema 不包含 `TimiResponse` 包装。
|
||||
- 只有文件模块和异步任务模块的 7 个 Controller 有较完整的中文接口描述,其他模块为基础自动生成信息。
|
||||
- 只有文件、异步任务与系统设置模块的 8 个 Controller 有较完整的中文接口描述,其他模块为基础自动生成信息。
|
||||
- 二进制接口的响应体无法在 OpenAPI 中完整表达,需结合本文和实际响应头处理。
|
||||
- OpenAPI 全局声明了 `Token`,公开接口的实际鉴权行为以接口为准。
|
||||
- 当前没有提交固定的 `docs/openapi.yaml` 版本化文件;需要时使用导出脚本生成本地快照,或后续接入 CI 导出。
|
||||
- `docs/openapi.index.md` 从本地 OpenAPI 快照生成,接口变更后需重新执行导出脚本更新;索引只提供定位信息,字段定义以 OpenAPI 原文为准。
|
||||
|
||||
@@ -0,0 +1,811 @@
|
||||
# TimiServerAPI 接口索引
|
||||
|
||||
> 本文件由 `scripts/openapi-index.py` 从 OpenAPI 快照生成,请勿手工编辑。
|
||||
> 数据来源:`docs/openapi.local.yaml`。完整字段定义以 OpenAPI 原文为准。
|
||||
|
||||
- 服务版本:`1.0.79`
|
||||
- OpenAPI 版本:`3.1.0`
|
||||
- 路径数:464
|
||||
- 接口数:466(同一路径的同一处理器会合并多个 HTTP 方法)
|
||||
- 模块数:36
|
||||
|
||||
## 使用说明
|
||||
|
||||
- 先按模块定位接口,再读取 `docs/openapi.local.yaml` 中对应的 `path` 或 `components/schemas`,不要整文件加载。
|
||||
- 参数列中 `*` 表示必填;`header:`、`cookie:` 为参数位置前缀,其余为 path/query 参数。
|
||||
- 摘要前的 `[公开]` 表示 OpenAPI 中显式标记为无需登录;未标记的接口默认使用 `Token` 鉴权。
|
||||
- 方法列出现多个 HTTP 方法,表示 Controller 使用了未限定 method 的 `@RequestMapping`。
|
||||
- 请求体和响应列展示顶层 schema 名称;`binary` 表示二进制响应,`SSE` 表示 `text/event-stream`。
|
||||
- 普通 JSON 接口的响应仍由 `TimiResponse` 包装,鉴权、错误码、分页等约定见 `docs/api-integration.md`。
|
||||
|
||||
## 模块导航
|
||||
|
||||
| 模块 | 接口数 | 路径前缀 |
|
||||
| --- | ---: | --- |
|
||||
| [`gao-ai`](#module-gao-ai) | 8 | `/gao/ai/` |
|
||||
| [`gao-customer`](#module-gao-customer) | 41 | `/gao/customer/` |
|
||||
| [`gao-data-export`](#module-gao-data-export) | 3 | `/gao/data-export/` |
|
||||
| [`gao-event`](#module-gao-event) | 20 | `/gao/event/` |
|
||||
| [`gao-fund`](#module-gao-fund) | 5 | `/gao/fund/` |
|
||||
| [`gao-notify`](#module-gao-notify) | 2 | `/gao/notify/` |
|
||||
| [`gao-order`](#module-gao-order) | 13 | `/gao/order/` |
|
||||
| [`gao-package`](#module-gao-package) | 6 | `/gao/package/` |
|
||||
| [`gao-point`](#module-gao-point) | 11 | `/gao/point/` |
|
||||
| [`gao-product`](#module-gao-product) | 51 | `/gao/product/` |
|
||||
| [`gao-recycle`](#module-gao-recycle) | 32 | `/gao/recycle/` |
|
||||
| [`gao-report`](#module-gao-report) | 1 | `/gao/report/` |
|
||||
| [`gao-role`](#module-gao-role) | 2 | `/gao/role/` |
|
||||
| [`gao-sales`](#module-gao-sales) | 27 | `/gao/sales/` |
|
||||
| [`gao-store`](#module-gao-store) | 28 | `/gao/store/` |
|
||||
| [`gao-tag`](#module-gao-tag) | 7 | `/gao/tag/` |
|
||||
| [`gao-user`](#module-gao-user) | 10 | `/gao/user/` |
|
||||
| [`system`](#module-system) | 48 | `/system/` |
|
||||
| [`user`](#module-user) | 44 | `/user/` |
|
||||
| [`app`](#module-app) | 13 | `/app/` |
|
||||
| [`.well-known`](#module-.well-known) | 6 | `/.well-known/` |
|
||||
| [`article`](#module-article) | 5 | `/article/` |
|
||||
| [`attach`](#module-attach) | 14 | `/attach/` |
|
||||
| [`captcha`](#module-captcha) | 2 | `/captcha/` |
|
||||
| [`comment`](#module-comment) | 13 | `/comment/` |
|
||||
| [`feedback`](#module-feedback) | 5 | `/feedback/` |
|
||||
| [`fmc`](#module-fmc) | 1 | `/fmc/` |
|
||||
| [`icon`](#module-icon) | 4 | `/icon/` |
|
||||
| [`journal`](#module-journal) | 7 | `/journal/` |
|
||||
| [`log`](#module-log) | 1 | `/log/` |
|
||||
| [`mcp`](#module-mcp) | 5 | `/mcp/` |
|
||||
| [`mirror`](#module-mirror) | 2 | `/mirror/` |
|
||||
| [`notify`](#module-notify) | 15 | `/notify/` |
|
||||
| [`root`](#module-root) | 1 | `/` |
|
||||
| [`setting`](#module-setting) | 6 | `/setting/` |
|
||||
| [`tag`](#module-tag) | 7 | `/tag/` |
|
||||
|
||||
<a id="module-gao-ai"></a>
|
||||
## gao-ai
|
||||
|
||||
共 8 个接口,路径前缀 `/gao/ai/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/gao/ai/attachment/upload` | upload | storeId | object{file} (multipart/form-data) | Array<GaoAiAttachmentView> | gao-ai-operation-controller |
|
||||
| POST | `/gao/ai/chat` | chat | - | GaoAiChatRequest | SSE | gao-ai-chat-controller |
|
||||
| POST | `/gao/ai/conversation/delete` | deleteConversation | conversationId* | - | - | gao-ai-chat-controller |
|
||||
| POST | `/gao/ai/conversation/list` | listConversation | - | GaoAiConversationListRequest | JsonNode | gao-ai-chat-controller |
|
||||
| POST | `/gao/ai/conversation/read` | readConversation | - | GaoAiConversationReadRequest | JsonNode | gao-ai-chat-controller |
|
||||
| POST | `/gao/ai/operation/cancel` | cancel | - | GaoAiOperationCommitRequest | GaoAiToolResult | gao-ai-operation-controller |
|
||||
| POST | `/gao/ai/operation/commit` | commit | - | GaoAiOperationCommitRequest | GaoAiToolResult | gao-ai-operation-controller |
|
||||
| GET | `/gao/ai/operation/pending` | pending | conversationId, storeId | - | GaoAiToolResult | gao-ai-operation-controller |
|
||||
|
||||
<a id="module-gao-customer"></a>
|
||||
## gao-customer
|
||||
|
||||
共 41 个接口,路径前缀 `/gao/customer/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/gao/customer/chart/customer/disease/word` | customerDiseaseWord | - | GaoCustomerDiseaseWordReq | Array<GaoCustomerDiseaseWordView> | gao-customer-chart-controller |
|
||||
| POST | `/gao/customer/chart/event/record/calendar` | eventRecordCalendar | - | GaoCustomerChartReq | Array<GaoEventRecordCalendarView> | gao-customer-chart-controller |
|
||||
| POST | `/gao/customer/chart/event/record/daily` | eventRecordDaily | - | GaoCustomerChartReq | Array<GaoEventRecordDailyStatView> | gao-customer-chart-controller |
|
||||
| POST | `/gao/customer/consumption-record/list` | list | - | GaoCustomerConsumptionRecordPage | GaoCustomerConsumptionRecordPageResult | gao-customer-consumption-record-controller |
|
||||
| POST | `/gao/customer/create` | create | - | GaoCustomer_Public | string | gao-customer-controller |
|
||||
| POST | `/gao/customer/delete` | delete | id* | - | - | gao-customer-controller |
|
||||
| POST | `/gao/customer/detail` | detail | id* | - | GaoCustomer_Public | gao-customer-controller |
|
||||
| POST | `/gao/customer/find/code` | findByCode | storeId*, code* | - | GaoCustomer_Public | gao-customer-controller |
|
||||
| POST | `/gao/customer/find/id` | findById | id* | - | GaoCustomer_Public | gao-customer-controller |
|
||||
| POST | `/gao/customer/find/name` | findByName | storeId*, name* | - | GaoCustomer_Public | gao-customer-controller |
|
||||
| POST | `/gao/customer/follow-up-reminder/complete` | complete | id* | - | - | gao-customer-follow-up-reminder-controller |
|
||||
| POST | `/gao/customer/follow-up-reminder/create` | create | - | GaoCustomerFollowUpReminder | string | gao-customer-follow-up-reminder-controller |
|
||||
| POST | `/gao/customer/follow-up-reminder/delete` | delete | id* | - | - | gao-customer-follow-up-reminder-controller |
|
||||
| POST | `/gao/customer/follow-up-reminder/detail` | detail | id* | - | GaoCustomerFollowUpReminder_Public | gao-customer-follow-up-reminder-controller |
|
||||
| POST | `/gao/customer/follow-up-reminder/list` | list | - | GaoCustomerFollowUpReminderPage_Public | GaoCustomerFollowUpReminderPageResult_Public | gao-customer-follow-up-reminder-controller |
|
||||
| POST | `/gao/customer/follow-up-reminder/update` | update | - | GaoCustomerFollowUpReminder | - | gao-customer-follow-up-reminder-controller |
|
||||
| POST | `/gao/customer/invite/delete` | deleteInvite | customerId* | - | - | gao-customer-controller |
|
||||
| POST | `/gao/customer/invite/save` | saveInvite | introducerCustomerId*, customerId* | - | - | gao-customer-controller |
|
||||
| POST | `/gao/customer/invited/list` | listInvited | introducerCustomerId* | - | Array<GaoCustomer_Public> | gao-customer-controller |
|
||||
| POST | `/gao/customer/list` | list | - | GaoCustomerPage_Public | PageResultGaoCustomer_Public | gao-customer-controller |
|
||||
| POST | `/gao/customer/package/cancel` | cancel | - | GaoCustomerPackageCancelRequest | GaoCustomerPackage | gao-customer-package-controller |
|
||||
| POST | `/gao/customer/package/detail` | detail | id* | - | GaoCustomerPackage | gao-customer-package-controller |
|
||||
| POST | `/gao/customer/package/list` | list | - | GaoCustomerPackagePage | PageResultGaoCustomerPackage | gao-customer-package-controller |
|
||||
| POST | `/gao/customer/package/purchase` | purchase | - | GaoCustomerPackagePurchaseRequest | GaoCustomerPackage | gao-customer-package-controller |
|
||||
| POST | `/gao/customer/point/account/detail` | detailById | id*, storeId | - | GaoPointAccount | gao-point-account-controller |
|
||||
| POST | `/gao/customer/point/account/detail/customer` | detail | customerId*, storeId | - | GaoPointAccount | gao-point-account-controller |
|
||||
| POST | `/gao/customer/point/account/list` | list | - | GaoPointAccountPage | PageResultGaoPointAccount | gao-point-account-controller |
|
||||
| POST | `/gao/customer/point/adjust` | adjust | - | GaoPointAdjustRequest | - | gao-point-ledger-controller |
|
||||
| POST | `/gao/customer/point/ledger/detail` | detail | id*, storeId | - | GaoPointLedger | gao-point-ledger-controller |
|
||||
| POST | `/gao/customer/point/ledger/list` | list | - | GaoPointLedgerPage | PageResultGaoPointLedger | gao-point-ledger-controller |
|
||||
| POST | `/gao/customer/point/rule/create` | create | - | GaoPointRule | string | gao-point-rule-controller |
|
||||
| POST | `/gao/customer/point/rule/delete` | delete | id* | - | - | gao-point-rule-controller |
|
||||
| POST | `/gao/customer/point/rule/detail` | detail | id* | - | GaoPointRule | gao-point-rule-controller |
|
||||
| POST | `/gao/customer/point/rule/list` | list | - | PageGaoPointRule | PageResultGaoPointRule | gao-point-rule-controller |
|
||||
| POST | `/gao/customer/point/rule/script/list` | scriptList | - | - | Array<GroovyScript> | gao-point-rule-controller |
|
||||
| POST | `/gao/customer/point/rule/sort` | sort | - | Array<string> | - | gao-point-rule-controller |
|
||||
| POST | `/gao/customer/point/rule/update` | update | - | GaoPointRule | - | gao-point-rule-controller |
|
||||
| POST | `/gao/customer/profile/pdf` | pdf | id* | - | - | gao-customer-profile-controller |
|
||||
| POST | `/gao/customer/state/daily` | dailyStat | - | GaoCustomerTrendStateReq | Array<GaoCustomerDailyStateView> | gao-customer-controller |
|
||||
| POST | `/gao/customer/state/gender` | genderStat | storeId* | - | Array<GaoCustomerGenderStatView> | gao-customer-controller |
|
||||
| POST | `/gao/customer/update` | update | - | GaoCustomer | - | gao-customer-controller |
|
||||
|
||||
<a id="module-gao-data-export"></a>
|
||||
## gao-data-export
|
||||
|
||||
共 3 个接口,路径前缀 `/gao/data-export/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/gao/data-export/stat` | stat | - | GaoDataExportStatRequest | GaoDataExportStatView | gao-data-export-controller |
|
||||
| POST | `/gao/data-export/task` | create | - | GaoDataExportCreateRequest | GaoDataExportTaskView | gao-data-export-controller |
|
||||
| GET | `/gao/data-export/task/{taskId}` | detail | taskId* | - | GaoDataExportTaskView | gao-data-export-controller |
|
||||
|
||||
<a id="module-gao-event"></a>
|
||||
## gao-event
|
||||
|
||||
共 20 个接口,路径前缀 `/gao/event/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/gao/event/create` | create | - | GaoEvent | - | gao-event-controller |
|
||||
| POST | `/gao/event/delete` | delete | id* | - | - | gao-event-controller |
|
||||
| POST | `/gao/event/detail` | detail | id* | - | GaoEvent | gao-event-controller |
|
||||
| POST | `/gao/event/list` | list | - | PageGaoEvent | PageResultGaoEvent | gao-event-controller |
|
||||
| POST | `/gao/event/list/history` | listHistory | - | PageGaoEvent | PageResultGaoEvent | gao-event-controller |
|
||||
| POST | `/gao/event/list/valid` | listValid | storeId* | - | Array<GaoEvent> | gao-event-controller |
|
||||
| POST | `/gao/event/options/update` | updateOptions | id* | Array<GaoEventOptionGroup> | - | gao-event-controller |
|
||||
| POST | `/gao/event/record/create` | create | - | GaoEventRecord | - | gao-event-record-controller |
|
||||
| POST | `/gao/event/record/create/batch` | createBatch | - | Array<GaoEventRecord> | - | gao-event-record-controller |
|
||||
| POST | `/gao/event/record/create/customer` | createWithCustomer | - | GaoCustomer | - | gao-event-record-controller |
|
||||
| POST | `/gao/event/record/delete` | delete | id* | - | - | gao-event-record-controller |
|
||||
| POST | `/gao/event/record/detail` | detail | id* | - | GaoEventRecord_Public | gao-event-record-controller |
|
||||
| POST | `/gao/event/record/list` | list | - | GaoEventRecordPage_Public | GaoEventRecordPageResult_Public | gao-event-record-controller |
|
||||
| POST | `/gao/event/record/month/pdf` | export | eventId*, month* | - | - | gao-event-month-export-controller |
|
||||
| POST | `/gao/event/record/option/stat` | optionStat | - | GaoEventRecordPage | Array<GaoEventOptionStatView> | gao-event-record-controller |
|
||||
| POST | `/gao/event/record/rank` | eventRank | - | GaoEventRecordRankPage | PageResultGaoCustomerEventRankView | gao-event-record-controller |
|
||||
| POST | `/gao/event/record/update` | update | - | GaoEventRecord | - | gao-event-record-controller |
|
||||
| POST | `/gao/event/record/verify` | verify | id* | - | - | gao-event-record-controller |
|
||||
| POST | `/gao/event/sort` | sort | - | Array<string> | - | gao-event-controller |
|
||||
| POST | `/gao/event/update` | update | - | GaoEvent | - | gao-event-controller |
|
||||
|
||||
<a id="module-gao-fund"></a>
|
||||
## gao-fund
|
||||
|
||||
共 5 个接口,路径前缀 `/gao/fund/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/gao/fund/record/detail` | detail | id* | - | GaoFundRecord | gao-fund-record-controller |
|
||||
| POST | `/gao/fund/record/list` | list | - | GaoFundRecordPage | PageResultGaoFundRecord | gao-fund-record-controller |
|
||||
| POST | `/gao/fund/record/my-receive/detail` | detailMyReceive | id* | - | GaoFundRecord | gao-fund-record-controller |
|
||||
| POST | `/gao/fund/record/my-receive/list` | listMyReceive | - | GaoFundRecordPage | PageResultGaoFundRecord | gao-fund-record-controller |
|
||||
| POST | `/gao/fund/record/revoke` | revoke | - | GaoFundRevokeRequest | GaoFundRecord | gao-fund-record-controller |
|
||||
|
||||
<a id="module-gao-notify"></a>
|
||||
## gao-notify
|
||||
|
||||
共 2 个接口,路径前缀 `/gao/notify/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/gao/notify/create` | create | - | Notify | Notify | gao-notify-controller |
|
||||
| POST | `/gao/notify/recipient/list` | recipientList | - | PageGaoUser_Public | PageResultGaoUser_Public | gao-notify-controller |
|
||||
|
||||
<a id="module-gao-order"></a>
|
||||
## gao-order
|
||||
|
||||
共 13 个接口,路径前缀 `/gao/order/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/gao/order/fulfillment/cancel` | cancel | - | GaoOrderFulfillmentActionRequest | GaoOrderFulfillment | gao-order-fulfillment-controller |
|
||||
| POST | `/gao/order/fulfillment/create` | create | - | GaoOrderFulfillmentCreateRequest | GaoOrderFulfillment | gao-order-fulfillment-controller |
|
||||
| POST | `/gao/order/fulfillment/create-and-verify` | createAndVerify | - | GaoOrderFulfillmentCreateRequest | GaoOrderFulfillment | gao-order-fulfillment-controller |
|
||||
| POST | `/gao/order/fulfillment/detail` | detail | id* | - | GaoOrderFulfillment | gao-order-fulfillment-controller |
|
||||
| POST | `/gao/order/fulfillment/list` | list | - | GaoOrderFulfillmentPage | PageResultGaoOrderFulfillment | gao-order-fulfillment-controller |
|
||||
| POST | `/gao/order/fulfillment/prepare-stock` | prepareStock | - | GaoOrderFulfillmentPrepareStockRequest | GaoOrderFulfillment | gao-order-fulfillment-controller |
|
||||
| POST | `/gao/order/fulfillment/quick/create` | createQuickFulfillment | - | GaoQuickFulfillmentCreateRequest | Array<GaoOrderFulfillment> | gao-order-fulfillment-controller |
|
||||
| POST | `/gao/order/fulfillment/quick/sku-list` | listQuickFulfillmentSku | - | GaoQuickFulfillmentCustomerRequest | Array<GaoQuickFulfillmentSkuView> | gao-order-fulfillment-controller |
|
||||
| POST | `/gao/order/fulfillment/quick/source-order-list` | listQuickFulfillmentSourceOrder | - | GaoQuickFulfillmentSourceOrderListRequest | Array<GaoQuickFulfillmentSourceOrderView> | gao-order-fulfillment-controller |
|
||||
| POST | `/gao/order/fulfillment/reject` | reject | - | GaoOrderFulfillmentActionRequest | GaoOrderFulfillment | gao-order-fulfillment-controller |
|
||||
| POST | `/gao/order/fulfillment/return` | returnGoods | - | GaoOrderFulfillmentReturnRequest | GaoOrderFulfillment | gao-order-fulfillment-controller |
|
||||
| POST | `/gao/order/fulfillment/revoke` | revoke | - | GaoOrderFulfillmentRevokeRequest | GaoOrderFulfillment | gao-order-fulfillment-controller |
|
||||
| POST | `/gao/order/fulfillment/verify` | verify | - | GaoOrderFulfillmentActionRequest | GaoOrderFulfillment | gao-order-fulfillment-controller |
|
||||
|
||||
<a id="module-gao-package"></a>
|
||||
## gao-package
|
||||
|
||||
共 6 个接口,路径前缀 `/gao/package/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/gao/package/config/create` | create | - | GaoPackageConfig | string | gao-package-config-controller |
|
||||
| POST | `/gao/package/config/delete` | delete | id* | - | - | gao-package-config-controller |
|
||||
| POST | `/gao/package/config/detail` | detail | id* | - | GaoPackageConfig | gao-package-config-controller |
|
||||
| POST | `/gao/package/config/list` | list | - | GaoPackageConfigPage | PageResultGaoPackageConfig | gao-package-config-controller |
|
||||
| POST | `/gao/package/config/list/valid` | listValid | storeId* | - | Array<GaoPackageConfig> | gao-package-config-controller |
|
||||
| POST | `/gao/package/config/update` | update | - | GaoPackageConfig | - | gao-package-config-controller |
|
||||
|
||||
<a id="module-gao-point"></a>
|
||||
## gao-point
|
||||
|
||||
共 11 个接口,路径前缀 `/gao/point/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/gao/point/redeem-sku/create` | create | - | GaoPointRedeemSkuRequest | GaoPointRedeemSku | gao-point-redeem-sku-controller |
|
||||
| POST | `/gao/point/redeem-sku/delete` | delete | id*, storeId | - | - | gao-point-redeem-sku-controller |
|
||||
| POST | `/gao/point/redeem-sku/detail` | detail | id*, storeId | - | GaoPointRedeemSku | gao-point-redeem-sku-controller |
|
||||
| POST | `/gao/point/redeem-sku/disable` | disable | id*, storeId | - | - | gao-point-redeem-sku-controller |
|
||||
| POST | `/gao/point/redeem-sku/list` | list | - | GaoPointRedeemSkuPage | GaoPointRedeemSkuPageResult | gao-point-redeem-sku-controller |
|
||||
| POST | `/gao/point/redeem-sku/update` | update | - | GaoPointRedeemSkuRequest | GaoPointRedeemSku | gao-point-redeem-sku-controller |
|
||||
| POST | `/gao/point/redemption/create` | create | - | GaoPointRedemptionCreateRequest | GaoPointRedemption | gao-point-redemption-controller |
|
||||
| POST | `/gao/point/redemption/detail` | detail | id*, storeId | - | GaoPointRedemption | gao-point-redemption-controller |
|
||||
| POST | `/gao/point/redemption/list` | list | - | GaoPointRedemptionPage | PageResultGaoPointRedemption | gao-point-redemption-controller |
|
||||
| POST | `/gao/point/redemption/return` | returnRedemption | - | GaoPointRedemptionReturnRequest | GaoPointRedemption | gao-point-redemption-controller |
|
||||
| POST | `/gao/point/redemption/return/list` | returnList | redemptionId*, storeId | - | Array<GaoPointRedemptionReturn> | gao-point-redemption-controller |
|
||||
|
||||
<a id="module-gao-product"></a>
|
||||
## gao-product
|
||||
|
||||
共 51 个接口,路径前缀 `/gao/product/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/gao/product/category/create` | categoryCreate | - | GaoProductCategory | string | gao-product-controller |
|
||||
| POST | `/gao/product/category/disable` | categoryDisable | id* | - | - | gao-product-controller |
|
||||
| POST | `/gao/product/category/list` | categoryList | - | GaoProductCategoryPage | PageResultGaoProductCategory | gao-product-controller |
|
||||
| POST | `/gao/product/category/sort` | categorySort | - | Array<string> | - | gao-product-controller |
|
||||
| POST | `/gao/product/category/update` | categoryUpdate | - | GaoProductCategory | - | gao-product-controller |
|
||||
| POST | `/gao/product/chart/fulfillment/daily` | fulfillmentDaily | - | GaoProductChartReq | Array<GaoProductFulfillmentDailyStatView> | gao-product-chart-controller |
|
||||
| POST | `/gao/product/chart/fulfillment/rank` | fulfillmentRank | - | GaoProductChartReq | Array<GaoProductFulfillmentRankView> | gao-product-chart-controller |
|
||||
| POST | `/gao/product/chart/sales/daily` | salesDaily | - | GaoProductChartReq | Array<GaoProductSalesDailyStatView> | gao-product-chart-controller |
|
||||
| POST | `/gao/product/chart/sales/rank` | salesRank | - | GaoProductChartReq | Array<GaoProductSalesRankView> | gao-product-chart-controller |
|
||||
| POST | `/gao/product/chart/sales/unit/rank` | unitSalesRank | - | GaoProductChartReq | Array<GaoProductUnitSalesRankView> | gao-product-chart-controller |
|
||||
| POST | `/gao/product/chart/stock/health` | stockHealth | - | GaoProductChartReq | Array<GaoProductStockHealthView> | gao-product-chart-controller |
|
||||
| POST | `/gao/product/chart/stock/movement/daily` | stockMovementDaily | - | GaoProductChartReq | Array<GaoProductStockMovementDailyStatView> | gao-product-chart-controller |
|
||||
| POST | `/gao/product/chart/structure/category` | category | - | GaoProductChartReq | Array<GaoProductCategoryStatView> | gao-product-chart-controller |
|
||||
| POST | `/gao/product/chart/structure/type` | type | - | GaoProductChartReq | Array<GaoProductTypeStatView> | gao-product-chart-controller |
|
||||
| POST | `/gao/product/create` | create | - | GaoProduct | string | gao-product-controller |
|
||||
| POST | `/gao/product/delete` | delete | id* | - | - | gao-product-controller |
|
||||
| POST | `/gao/product/detail` | detail | id* | - | GaoProduct | gao-product-controller |
|
||||
| POST | `/gao/product/disable` | disable | id* | - | - | gao-product-controller |
|
||||
| POST | `/gao/product/list` | list | - | GaoProductPage | PageResultGaoProduct | gao-product-controller |
|
||||
| POST | `/gao/product/sellable/list` | sellableList | - | GaoProductPage | Array<GaoProduct> | gao-product-controller |
|
||||
| POST | `/gao/product/sku/chart/fulfillment/daily` | fulfillmentDaily | - | GaoProductChartReq | Array<GaoProductSkuFulfillmentDailyStatView> | gao-product-sku-chart-controller |
|
||||
| POST | `/gao/product/sku/chart/fulfillment/rank` | fulfillmentRank | - | GaoProductChartReq | Array<GaoProductSkuFulfillmentRankView> | gao-product-sku-chart-controller |
|
||||
| POST | `/gao/product/sku/chart/sales/daily` | salesDaily | - | GaoProductChartReq | Array<GaoProductSkuSalesDailyStatView> | gao-product-sku-chart-controller |
|
||||
| POST | `/gao/product/sku/chart/sales/rank` | salesRank | - | GaoProductChartReq | Array<GaoProductSkuSalesRankView> | gao-product-sku-chart-controller |
|
||||
| POST | `/gao/product/sku/chart/sales/unit/rank` | unitSalesRank | - | GaoProductChartReq | Array<GaoProductSkuUnitSalesRankView> | gao-product-sku-chart-controller |
|
||||
| POST | `/gao/product/sku/chart/stock/health` | stockHealth | - | GaoProductChartReq | Array<GaoProductSkuStockHealthView> | gao-product-sku-chart-controller |
|
||||
| POST | `/gao/product/sku/chart/stock/movement/daily` | stockMovementDaily | - | GaoProductChartReq | Array<GaoProductSkuStockMovementDailyStatView> | gao-product-sku-chart-controller |
|
||||
| POST | `/gao/product/sku/create` | skuCreate | - | GaoProductSku | string | gao-product-controller |
|
||||
| POST | `/gao/product/sku/detail` | skuDetail | id* | - | GaoProductSku | gao-product-controller |
|
||||
| POST | `/gao/product/sku/disable` | skuDisable | id* | - | - | gao-product-controller |
|
||||
| POST | `/gao/product/sku/fulfillment-list` | skuFulfillmentList | - | Array<string> | Array<GaoProductSkuFulfillmentView> | gao-product-controller |
|
||||
| POST | `/gao/product/sku/update` | skuUpdate | - | GaoProductSku | - | gao-product-controller |
|
||||
| POST | `/gao/product/spec/create` | specCreate | - | GaoProductSpec | string | gao-product-controller |
|
||||
| POST | `/gao/product/spec/list` | specList | productId* | - | Array<GaoProductSpec> | gao-product-controller |
|
||||
| POST | `/gao/product/spec/update` | specUpdate | - | GaoProductSpec | - | gao-product-controller |
|
||||
| POST | `/gao/product/spec/value/create` | specValueCreate | - | GaoProductSpecValue | string | gao-product-controller |
|
||||
| POST | `/gao/product/spec/value/update` | specValueUpdate | - | GaoProductSpecValue | - | gao-product-controller |
|
||||
| POST | `/gao/product/stock/batch-detail` | batchDetail | - | GaoProductStockBatchRequest | Array<GaoProductStock> | gao-product-stock-controller |
|
||||
| POST | `/gao/product/stock/detail` | detail | storeId, skuId* | - | GaoProductStock | gao-product-stock-controller |
|
||||
| POST | `/gao/product/stock/initial-in` | initialIn | - | GaoProductStockChangeRequest | GaoProductStock | gao-product-stock-controller |
|
||||
| POST | `/gao/product/stock/list` | list | - | GaoProductStockPage | PageResultGaoProductStock | gao-product-stock-controller |
|
||||
| POST | `/gao/product/stock/manual-in` | manualIn | - | GaoProductStockChangeRequest | GaoProductStock | gao-product-stock-controller |
|
||||
| POST | `/gao/product/stock/manual-in/batch` | manualInBatch | - | GaoProductStockManualInBatchRequest | Array<GaoProductStock> | gao-product-stock-controller |
|
||||
| POST | `/gao/product/stock/manual-out` | manualOut | - | GaoProductStockChangeRequest | GaoProductStock | gao-product-stock-controller |
|
||||
| POST | `/gao/product/stock/manual-revoke` | manualRevoke | - | GaoProductStockManualRevokeRequest | GaoProductStock | gao-product-stock-controller |
|
||||
| POST | `/gao/product/stock/product-list` | productList | - | GaoProductStockPage | PageResultGaoProductStockProductView | gao-product-stock-controller |
|
||||
| POST | `/gao/product/stock/record/detail` | recordDetail | id* | - | GaoProductStockRecord | gao-product-stock-controller |
|
||||
| POST | `/gao/product/stock/record/list` | recordList | - | GaoProductStockRecordPage | GaoProductStockRecordPageResult | gao-product-stock-controller |
|
||||
| POST | `/gao/product/stock/stocktake-gain` | stocktakeGain | - | GaoProductStockChangeRequest | GaoProductStock | gao-product-stock-controller |
|
||||
| POST | `/gao/product/stock/stocktake-loss` | stocktakeLoss | - | GaoProductStockChangeRequest | GaoProductStock | gao-product-stock-controller |
|
||||
| POST | `/gao/product/update` | update | - | GaoProduct | - | gao-product-controller |
|
||||
|
||||
<a id="module-gao-recycle"></a>
|
||||
## gao-recycle
|
||||
|
||||
共 32 个接口,路径前缀 `/gao/recycle/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/gao/recycle/account/customers` | customers | - | GaoRecycleAccountCustomerPage | GaoRecycleAccountCustomerPageResult | gao-recycle-account-controller |
|
||||
| POST | `/gao/recycle/account/items` | accountItems | storeId* | - | Array<GaoRecycleItem> | gao-recycle-account-controller |
|
||||
| POST | `/gao/recycle/account/list` | list | storeId*, customerId* | - | Array<GaoRecycleAccount> | gao-recycle-account-controller |
|
||||
| POST | `/gao/recycle/account/yield/delete` | deleteYield | storeId*, skuId*, recycleItemId* | - | - | gao-recycle-account-controller |
|
||||
| POST | `/gao/recycle/account/yield/list` | yields | storeId*, skuId* | - | Array<GaoRecycleProductYield> | gao-recycle-account-controller |
|
||||
| POST | `/gao/recycle/account/yield/product/list` | yieldsByProduct | storeId*, productId* | - | Array<GaoRecycleProductYield> | gao-recycle-account-controller |
|
||||
| POST | `/gao/recycle/account/yield/save` | saveYield | storeId*, skuId*, recycleItemId*, quantityPerBase* | - | - | gao-recycle-account-controller |
|
||||
| POST | `/gao/recycle/config/item/detail` | itemDetail | storeId, id* | - | GaoRecycleItem | gao-recycle-config-controller |
|
||||
| POST | `/gao/recycle/config/item/save` | saveItem | - | GaoRecycleItemRequest | GaoRecycleItem | gao-recycle-config-controller |
|
||||
| POST | `/gao/recycle/config/items` | items | storeId, status, keyword, offset, limit | - | PageResultGaoRecycleItem | gao-recycle-config-controller |
|
||||
| POST | `/gao/recycle/config/rule/delete` | deleteRule | storeId, id* | - | - | gao-recycle-config-controller |
|
||||
| POST | `/gao/recycle/config/rule/detail` | ruleDetail | storeId, id* | - | GaoRecycleExchangeRule | gao-recycle-config-controller |
|
||||
| POST | `/gao/recycle/config/rule/save` | saveRule | - | GaoRecycleExchangeRuleRequest | GaoRecycleExchangeRule | gao-recycle-config-controller |
|
||||
| POST | `/gao/recycle/config/rules` | rules | storeId, status, recycleItemId, skuId, keyword, offset, limit | - | PageResultGaoRecycleExchangeRule | gao-recycle-config-controller |
|
||||
| POST | `/gao/recycle/config/rules/active` | activeRules | storeId, recycleItemId, skuId, keyword, offset, limit | - | PageResultGaoRecycleExchangeRule | gao-recycle-config-controller |
|
||||
| POST | `/gao/recycle/exchange/create` | create | - | GaoRecycleExchangeCreateRequest | GaoRecycleExchange | gao-recycle-exchange-write-controller |
|
||||
| POST | `/gao/recycle/exchange/detail` | detail | id* | - | GaoRecycleExchangeDetail | gao-recycle-exchange-query-controller |
|
||||
| POST | `/gao/recycle/ledger/adjust` | adjust | - | GaoRecycleAccountAdjustRequest | - | gao-recycle-ledger-controller |
|
||||
| POST | `/gao/recycle/ledger/detail` | detail | id* | - | GaoRecycleLedger | gao-recycle-ledger-controller |
|
||||
| POST | `/gao/recycle/ledger/list` | list | - | GaoRecycleLedgerPage | PageResultGaoRecycleLedger | gao-recycle-ledger-controller |
|
||||
| POST | `/gao/recycle/payment/cancel` | cancel | - | GaoRecyclePaymentRequest | GaoRecyclePayment | gao-recycle-payment-controller |
|
||||
| POST | `/gao/recycle/payment/create` | create | - | GaoRecyclePaymentRequest | GaoRecyclePayment | gao-recycle-payment-controller |
|
||||
| POST | `/gao/recycle/payment/create-and-verify` | createAndVerify | - | GaoRecyclePaymentRequest | GaoRecyclePayment | gao-recycle-payment-controller |
|
||||
| POST | `/gao/recycle/payment/detail` | detail | id* | - | GaoRecyclePayment | gao-recycle-payment-controller |
|
||||
| POST | `/gao/recycle/payment/list` | list | orderId* | - | Array<GaoRecyclePayment> | gao-recycle-payment-controller |
|
||||
| POST | `/gao/recycle/payment/reject` | reject | - | GaoRecyclePaymentRequest | GaoRecyclePayment | gao-recycle-payment-controller |
|
||||
| POST | `/gao/recycle/payment/revoke` | revoke | - | GaoRecyclePaymentRequest | GaoRecyclePayment | gao-recycle-payment-controller |
|
||||
| POST | `/gao/recycle/payment/search` | search | storeId, customerId, orderId, status, beginAt, endAt, offset, limit | - | Array<GaoRecyclePayment> | gao-recycle-payment-controller |
|
||||
| POST | `/gao/recycle/payment/transactions` | transactions | orderId* | - | Array<GaoOrderTransactionView> | gao-recycle-payment-controller |
|
||||
| POST | `/gao/recycle/payment/verify` | verify | - | GaoRecyclePaymentRequest | GaoRecyclePayment | gao-recycle-payment-controller |
|
||||
| POST | `/gao/recycle/stat/exchange` | exchange | storeId, startAt*, endAt* | - | Array<GaoRecycleExchangeStatView> | gao-recycle-stat-controller |
|
||||
| POST | `/gao/recycle/stat/recycle` | recycle | storeId, startAt*, endAt* | - | Array<GaoRecycleStatView> | gao-recycle-stat-controller |
|
||||
|
||||
<a id="module-gao-report"></a>
|
||||
## gao-report
|
||||
|
||||
共 1 个接口,路径前缀 `/gao/report/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/gao/report/options/customers` | customers | storeId, keyword, offset | - | Array<GaoReportOption> | gao-report-option-controller |
|
||||
|
||||
<a id="module-gao-role"></a>
|
||||
## gao-role
|
||||
|
||||
共 2 个接口,路径前缀 `/gao/role/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/gao/role/available/list` | availableList | - | - | Array<Role> | gao-role-controller |
|
||||
| POST | `/gao/role/management/list` | managementList | - | - | Array<Role> | gao-role-controller |
|
||||
|
||||
<a id="module-gao-sales"></a>
|
||||
## gao-sales
|
||||
|
||||
共 27 个接口,路径前缀 `/gao/sales/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/gao/sales/order/cancel` | cancel | - | GaoSalesOrderCancelRequest | GaoSalesOrder | gao-sales-order-controller |
|
||||
| POST | `/gao/sales/order/chart/customer/calendar` | calendar | - | GaoSalesOrderChartReq | Array<GaoSalesOrderCalendarStatView> | gao-sales-order-chart-controller |
|
||||
| POST | `/gao/sales/order/chart/customer/consumption/daily` | consumptionDaily | - | GaoSalesOrderChartReq | Array<GaoSalesOrderConsumptionDailyStatView> | gao-sales-order-chart-controller |
|
||||
| POST | `/gao/sales/order/chart/customer/product/rank` | customerProductRank | - | GaoSalesOrderChartReq | Array<GaoCustomerOrderProductRankView> | gao-sales-order-chart-controller |
|
||||
| POST | `/gao/sales/order/chart/customer/rank` | customerRank | - | GaoSalesOrderChartReq | Array<GaoCustomerOrderRankView> | gao-sales-order-chart-controller |
|
||||
| POST | `/gao/sales/order/chart/customer/repeat/daily` | repeatDaily | - | GaoSalesOrderChartReq | Array<GaoCustomerRepeatDailyStatView> | gao-sales-order-chart-controller |
|
||||
| POST | `/gao/sales/order/chart/customer/repeat/interval` | repeatInterval | - | GaoSalesOrderChartReq | Array<GaoCustomerRepeatIntervalStatView> | gao-sales-order-chart-controller |
|
||||
| POST | `/gao/sales/order/chart/customer/sku/rank` | customerSkuRank | - | GaoSalesOrderChartReq | Array<GaoCustomerOrderSkuRankView> | gao-sales-order-chart-controller |
|
||||
| POST | `/gao/sales/order/chart/daily` | daily | - | GaoSalesOrderChartReq | Array<GaoSalesOrderDailyStatView> | gao-sales-order-chart-controller |
|
||||
| POST | `/gao/sales/order/chart/payment` | payment | - | GaoSalesOrderChartReq | Array<GaoSalesOrderPaymentStatView> | gao-sales-order-chart-controller |
|
||||
| POST | `/gao/sales/order/chart/receivable` | receivable | - | GaoSalesOrderChartReq | GaoSalesOrderReceivableStatView | gao-sales-order-chart-controller |
|
||||
| POST | `/gao/sales/order/chart/status` | status | - | GaoSalesOrderChartReq | Array<GaoSalesOrderStatusStatView> | gao-sales-order-chart-controller |
|
||||
| POST | `/gao/sales/order/chart/type` | type | - | GaoSalesOrderChartReq | Array<GaoSalesOrderTypeStatView> | gao-sales-order-chart-controller |
|
||||
| POST | `/gao/sales/order/customer-product/list` | customerProductList | - | GaoCustomerProductPage | PageResultGaoCustomerProductCustomerView | gao-sales-order-controller |
|
||||
| POST | `/gao/sales/order/detail` | detail | id* | - | GaoSalesOrder | gao-sales-order-controller |
|
||||
| POST | `/gao/sales/order/direct-product/create` | createDirectProduct | - | GaoDirectProductOrderCreateRequest | GaoSalesOrder | gao-sales-order-controller |
|
||||
| POST | `/gao/sales/order/fund/revoke` | revoke | - | GaoOrderPaymentRevokeRequest | GaoFundRecord | gao-sales-order-controller |
|
||||
| POST | `/gao/sales/order/list` | list | - | GaoSalesOrderPage | PageResultGaoSalesOrder | gao-sales-order-controller |
|
||||
| POST | `/gao/sales/order/payment/cancel` | cancelPayment | - | GaoOrderPaymentActionRequest | GaoFundRecord | gao-sales-order-controller |
|
||||
| POST | `/gao/sales/order/payment/receive` | receive | - | GaoOrderPaymentReceiveRequest | GaoFundRecord | gao-sales-order-controller |
|
||||
| POST | `/gao/sales/order/payment/receive-and-verify` | receiveAndVerify | - | GaoOrderPaymentReceiveRequest | GaoFundRecord | gao-sales-order-controller |
|
||||
| POST | `/gao/sales/order/payment/reject` | reject | - | GaoOrderPaymentActionRequest | GaoFundRecord | gao-sales-order-controller |
|
||||
| POST | `/gao/sales/order/payment/verify` | verify | id* | - | GaoFundRecord | gao-sales-order-controller |
|
||||
| POST | `/gao/sales/order/refund` | refund | - | GaoOrderPaymentRefundRequest | GaoFundRecord | gao-sales-order-controller |
|
||||
| POST | `/gao/sales/order/refund/confirm-none` | confirmNoRefund | - | GaoOrderPaymentNoRefundRequest | GaoFundRecord | gao-sales-order-controller |
|
||||
| POST | `/gao/sales/order/summary` | summary | - | GaoSalesOrderPage | GaoSalesOrderReceivableStatView | gao-sales-order-controller |
|
||||
| POST | `/gao/sales/order/update` | update | - | GaoSalesOrderUpdateRequest | GaoSalesOrder | gao-sales-order-controller |
|
||||
|
||||
<a id="module-gao-store"></a>
|
||||
## gao-store
|
||||
|
||||
共 28 个接口,路径前缀 `/gao/store/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/gao/store/business/day/calendar` | calendar | storeId*, beginDateValue*, endDateValue* | - | Array<GaoStoreBusinessDay> | gao-store-business-day-controller |
|
||||
| POST | `/gao/store/business/day/create` | create | - | GaoStoreBusinessDay | string | gao-store-business-day-controller |
|
||||
| POST | `/gao/store/business/day/delete` | delete | id* | - | - | gao-store-business-day-controller |
|
||||
| POST | `/gao/store/business/day/detail` | detail | id* | - | GaoStoreBusinessDay | gao-store-business-day-controller |
|
||||
| POST | `/gao/store/business/day/list` | list | - | PageGaoStoreBusinessDay | PageResultGaoStoreBusinessDay | gao-store-business-day-controller |
|
||||
| POST | `/gao/store/business/day/update` | update | - | GaoStoreBusinessDay | - | gao-store-business-day-controller |
|
||||
| POST | `/gao/store/chart/customer/age` | customerAge | storeId* | - | Array<GaoCustomerAgeStatView> | gao-store-chart-controller |
|
||||
| POST | `/gao/store/chart/customer/daily` | customerDaily | - | GaoStoreChartReq | Array<GaoCustomerDailyStateView> | gao-store-chart-controller |
|
||||
| POST | `/gao/store/chart/customer/gender` | customerGender | storeId* | - | Array<GaoCustomerGenderStatView> | gao-store-chart-controller |
|
||||
| POST | `/gao/store/chart/event/record/calendar` | eventRecordCalendar | - | GaoStoreChartReq | Array<GaoEventRecordCalendarView> | gao-store-chart-controller |
|
||||
| POST | `/gao/store/chart/event/record/daily` | eventRecordDaily | - | GaoStoreChartReq | Array<GaoEventRecordDailyStatView> | gao-store-chart-controller |
|
||||
| POST | `/gao/store/chart/event/record/number-value/daily` | eventRecordNumberValueDaily | - | GaoStoreChartReq | Array<GaoEventRecordNumberValueDailyStatView> | gao-store-chart-controller |
|
||||
| POST | `/gao/store/chart/point/ledger/daily` | pointDaily | - | GaoStoreChartReq | Array<GaoPointDailyStatView> | gao-store-chart-controller |
|
||||
| POST | `/gao/store/chart/point/redemption/product/rank` | pointRedemptionProductRank | - | GaoStoreChartReq | Array<GaoPointRedemptionProductRankView> | gao-store-chart-controller |
|
||||
| POST | `/gao/store/create` | create | - | GaoStore | string | gao-store-controller |
|
||||
| POST | `/gao/store/delete` | delete | id* | - | - | gao-store-controller |
|
||||
| POST | `/gao/store/detail` | detail | id* | - | GaoStore | gao-store-controller |
|
||||
| POST | `/gao/store/diary/create` | create | - | Article | string | gao-store-diary-controller |
|
||||
| POST | `/gao/store/diary/delete` | delete | id* | - | - | gao-store-diary-controller |
|
||||
| POST | `/gao/store/diary/detail` | detail | id* | - | Article_Public | gao-store-diary-controller |
|
||||
| POST | `/gao/store/diary/list` | list | - | GaoStoreDiaryPage_Public | PageResultArticle_Public | gao-store-diary-controller |
|
||||
| POST | `/gao/store/diary/update` | update | - | Article | - | gao-store-diary-controller |
|
||||
| POST | `/gao/store/list` | list | - | PageGaoStore | PageResultGaoStore | gao-store-controller |
|
||||
| POST | `/gao/store/setting/map` | map | - | Array<string> | Map<String, Setting> | gao-store-setting-controller |
|
||||
| POST | `/gao/store/setting/update` | update | - | Array<Setting> | - | gao-store-setting-controller |
|
||||
| POST | `/gao/store/sort` | sort | - | Array<string> | - | gao-store-controller |
|
||||
| POST | `/gao/store/update` | update | - | GaoStore | - | gao-store-controller |
|
||||
| POST | `/gao/store/user` | getLoginStore | - | - | GaoStore | gao-store-controller |
|
||||
|
||||
<a id="module-gao-tag"></a>
|
||||
## gao-tag
|
||||
|
||||
共 7 个接口,路径前缀 `/gao/tag/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/gao/tag/apply` | apply | - | TagApply | - | gao-tag-controller |
|
||||
| POST | `/gao/tag/create` | create | - | Tag_Public | Tag_Public | gao-tag-controller |
|
||||
| POST | `/gao/tag/delete` | delete | id* | - | - | gao-tag-controller |
|
||||
| POST | `/gao/tag/detail` | detail | id* | - | Tag_Public | gao-tag-controller |
|
||||
| POST | `/gao/tag/list` | list | - | PageTag_Public | PageResultTag_Public | gao-tag-controller |
|
||||
| GET | `/gao/tag/list/biz/id` | listByBizType | bizType*, bizId* | - | Array<Tag_Public> | gao-tag-controller |
|
||||
| POST | `/gao/tag/update` | update | - | Tag | - | gao-tag-controller |
|
||||
|
||||
<a id="module-gao-user"></a>
|
||||
## gao-user
|
||||
|
||||
共 10 个接口,路径前缀 `/gao/user/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/gao/user/create` | create | - | GaoUser_Public | GaoUser_Public | gao-user-controller |
|
||||
| POST | `/gao/user/delete` | delete | id* | - | - | gao-user-controller |
|
||||
| POST | `/gao/user/detail` | detail | id* | - | GaoUser_Public | gao-user-controller |
|
||||
| POST | `/gao/user/invite` | invite | - | GaoUserInviteCreateRequest | GaoUserInviteCreateResponse | gao-user-controller |
|
||||
| POST | `/gao/user/invite/register` | registerByInvite | - | GaoUserInviteRegisterRequest_Public | LoginResponse_Public | gao-user-controller |
|
||||
| POST | `/gao/user/invite/validate` | validateInvite | - | GaoUserInviteValidateRequest | GaoUserInviteValidateResponse | gao-user-controller |
|
||||
| POST | `/gao/user/list` | list | - | PageGaoUser_Public | PageResultGaoUser_Public | gao-user-controller |
|
||||
| POST | `/gao/user/role/list` | roleList | - | - | Array<Role> | gao-user-controller |
|
||||
| POST | `/gao/user/transfer/store` | transferStore | - | GaoUser_Public | GaoUser_Public | gao-user-controller |
|
||||
| POST | `/gao/user/update` | update | - | GaoUser_Public | GaoUser_Public | gao-user-controller |
|
||||
|
||||
<a id="module-system"></a>
|
||||
## system
|
||||
|
||||
共 48 个接口,路径前缀 `/system/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| GET | `/system/docker/container` | listContainers | - | - | Array<DockerContainerSummaryView> | docker-controller |
|
||||
| GET | `/system/docker/container/{containerId}/history` | getContainerHistory | containerId*, window | - | DockerContainerHistoryView | docker-controller |
|
||||
| GET | `/system/docker/container/{containerId}/status` | getContainerStatus | containerId* | - | DockerContainerStatusView | docker-controller |
|
||||
| POST | `/system/file/copy` | 创建复制任务 | - | ArchiveRequest | string | 系统-文件归档 |
|
||||
| POST | `/system/file/cut` | 创建移动任务 | - | ArchiveRequest | string | 系统-文件归档 |
|
||||
| POST | `/system/file/delete` | 删除到回收站 | - | FileListRequest | Array<FileTrash> | 系统-文件回收站 |
|
||||
| GET/HEAD | `/system/file/download/{path}` | 下载文件 | path* | - | - | 系统-文件内容 |
|
||||
| GET | `/system/file/exist` | 判断路径是否存在 | path* | - | boolean | 系统-文件 |
|
||||
| GET | `/system/file/hash` | 计算文件 SHA-256 | path* | - | FileHash | 系统-文件 |
|
||||
| GET | `/system/file/list` | 获取目录列表 | path | - | Array<ServerFile> | 系统-文件 |
|
||||
| POST | `/system/file/mkdir` | 创建目录 | - | MkdirRequest | ServerFile | 系统-文件 |
|
||||
| GET | `/system/file/object/{path}` | 获取文件属性 | path* | - | ServerFile | 系统-文件 |
|
||||
| GET | `/system/file/preview/{path}` | 预览文件 | path* | - | - | 系统-文件内容 |
|
||||
| GET | `/system/file/read/{path}` | 读取文件 | path* | - | - | 系统-文件内容 |
|
||||
| POST | `/system/file/rename` | 重命名或移动 | - | RenameRequest | ServerFile | 系统-文件 |
|
||||
| POST | `/system/file/search` | 搜索文件 | - | SearchRequest | SearchResult | 系统-文件 |
|
||||
| GET | `/system/file/share` | 获取分享列表 | - | - | Array<FileShare> | 系统-文件分享 |
|
||||
| POST | `/system/file/share` | 创建文件分享 | - | ShareCreateRequest | FileShare | 系统-文件分享 |
|
||||
| DELETE | `/system/file/share/{id}` | 取消文件分享 | id* | - | FileShare | 系统-文件分享 |
|
||||
| GET/HEAD | `/system/file/share/{token}/download` | [公开] 下载分享文件 | token*, password | - | - | 系统-文件分享 |
|
||||
| POST | `/system/file/size` | 统计目录大小 | - | PathRequest | string | 系统-文件 |
|
||||
| POST | `/system/file/tar` | 创建 TAR 压缩任务 | - | ArchiveRequest | string | 系统-文件归档 |
|
||||
| GET | `/system/file/trash` | 获取回收站列表 | - | - | Array<FileTrash> | 系统-文件回收站 |
|
||||
| DELETE | `/system/file/trash` | 清空回收站 | - | - | integer | 系统-文件回收站 |
|
||||
| POST | `/system/file/trash/restore` | 恢复回收站文件 | - | IdRequest | ServerFile | 系统-文件回收站 |
|
||||
| DELETE | `/system/file/trash/{id}` | 彻底删除回收站记录 | id* | - | - | 系统-文件回收站 |
|
||||
| POST | `/system/file/untar` | 创建 TAR 解压任务 | - | UnarchiveRequest | string | 系统-文件归档 |
|
||||
| POST | `/system/file/unzip` | 创建 ZIP 解压任务 | - | UnarchiveRequest | string | 系统-文件归档 |
|
||||
| POST | `/system/file/upload` | 上传文件 | path*, name*, overwrite | object{file} | ServerFile | 系统-文件上传 |
|
||||
| POST | `/system/file/upload/chunk` | 上传分片 | uploadId*, index* | object{file} | - | 系统-文件上传 |
|
||||
| POST | `/system/file/upload/complete` | 完成分片上传 | - | UploadCompleteRequest | ServerFile | 系统-文件上传 |
|
||||
| POST | `/system/file/upload/init` | 初始化分片上传 | - | UploadInitRequest | UploadInit | 系统-文件上传 |
|
||||
| POST | `/system/file/zip` | 创建 ZIP 压缩任务 | - | ArchiveRequest | string | 系统-文件归档 |
|
||||
| POST | `/system/multilingual/create` | create | - | Multilingual_Admin | Multilingual_Admin | multilingual-controller |
|
||||
| POST | `/system/multilingual/delete` | delete | id* | - | - | multilingual-controller |
|
||||
| POST | `/system/multilingual/detail` | detail | id* | - | Multilingual_Admin | multilingual-controller |
|
||||
| POST | `/system/multilingual/update` | update | - | Multilingual | - | multilingual-controller |
|
||||
| GET | `/system/server/status` | getStatus | metrics | - | SystemStatusSnapshotView | system-controller |
|
||||
| GET | `/system/server/status/history` | getStatusHistory | window, metrics | - | SystemStatusHistoryView | system-controller |
|
||||
| POST | `/system/task/debug` | 创建调试任务 | second | - | string | 系统-异步任务 |
|
||||
| GET | `/system/task/detail` | 获取任务详情 | uuid* | - | AbstractAsyncTask | 系统-异步任务 |
|
||||
| GET | `/system/task/events` | 订阅任务事件 | uuid* | - | SSE | 系统-异步任务 |
|
||||
| POST | `/system/task/interrupt` | 中断任务 | uuid* | - | - | 系统-异步任务 |
|
||||
| POST | `/system/task/list` | 获取任务列表 | - | - | Array<AsyncTaskView> | 系统-异步任务 |
|
||||
| POST | `/system/task/pause` | 暂停任务 | uuid* | - | - | 系统-异步任务 |
|
||||
| POST | `/system/task/start` | 启动任务 | uuid* | - | - | 系统-异步任务 |
|
||||
| GET | `/system/ups/history` | getHistory | window | - | UpsHistoryView | ups-controller |
|
||||
| GET | `/system/ups/status` | getStatus | - | - | UpsStatusView | ups-controller |
|
||||
|
||||
<a id="module-user"></a>
|
||||
## user
|
||||
|
||||
共 44 个接口,路径前缀 `/user/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/user/api-key/create` | create | - | CreateRequest | CreateResult | user-api-key-controller |
|
||||
| POST | `/user/api-key/delete` | delete | id* | - | - | user-api-key-controller |
|
||||
| POST | `/user/api-key/list` | list | - | - | Array<KeyInfo> | user-api-key-controller |
|
||||
| POST | `/user/api-key/revoke` | revoke | id* | - | - | user-api-key-controller |
|
||||
| POST | `/user/cancel` | cancel | - | CancelRequest | - | user-controller |
|
||||
| POST | `/user/create` | create | - | User | - | user-controller |
|
||||
| POST | `/user/current/update` | updateCurrent | - | User | LoginResponse | user-controller |
|
||||
| GET/HEAD/POST/PUT/PATCH/DELETE/OPTIONS | `/user/delete` | delete | id* | - | - | user-controller |
|
||||
| GET/HEAD/POST/PUT/PATCH/DELETE/OPTIONS | `/user/detail` | detail | id* | - | User | user-controller |
|
||||
| POST | `/user/list` | list | - | PageUser | PageResultUser | user-controller |
|
||||
| POST | `/user/login` | login | - | CaptchaDataLoginRequest_Public | LoginResponse_Public | user-controller |
|
||||
| POST | `/user/login/sms` | loginBySms | - | SmsCaptchaVerifyRequest_Public | LoginResponse_Public | user-controller |
|
||||
| GET/HEAD/POST/PUT/PATCH/DELETE/OPTIONS | `/user/login/token` | token | - | - | LoginResponse_Public | user-controller |
|
||||
| POST | `/user/logout` | logout | - | - | - | user-controller |
|
||||
| POST | `/user/permission/grantable/list` | listGrantable | moduleCode* | - | Array<Permission> | permission-controller |
|
||||
| POST | `/user/permission/list` | list | - | PagePermission | PageResultPermission | permission-controller |
|
||||
| POST | `/user/permission/update` | update | - | Permission | - | permission-controller |
|
||||
| POST | `/user/phone/verify` | verifyPhone | - | PhoneVerifyRequest | - | user-controller |
|
||||
| POST | `/user/phone/verify/send` | sendPhoneCode | - | PhoneVerifyCodeSendRequest | - | user-controller |
|
||||
| POST | `/user/register` | register | - | CaptchaDataUser_Public | LoginResponse_Public | user-controller |
|
||||
| POST | `/user/role/authorized/create` | authorizeUserRole | - | UserRoleAuthorizeRequest | - | role-controller |
|
||||
| POST | `/user/role/authorized/list` | listUserRole | moduleCode, userId* | - | Array<Role> | role-controller |
|
||||
| POST | `/user/role/authorized/permission` | listAuthorizedPermission | userId* | - | Array<Permission> | role-controller |
|
||||
| POST | `/user/role/create` | create | - | Role | - | role-controller |
|
||||
| POST | `/user/role/current/detail/list` | listCurrentRoleDetail | moduleCode | - | Array<Role> | role-controller |
|
||||
| POST | `/user/role/delegation/grantable/list` | listGrantableDelegationPermission | roleId* | - | Array<Permission> | role-controller |
|
||||
| POST | `/user/role/delegation/list` | listDelegationPermission | roleId* | - | Array<Permission> | role-controller |
|
||||
| POST | `/user/role/delegation/update` | updateRoleDelegation | - | Role | - | role-controller |
|
||||
| POST | `/user/role/delete` | delete | id* | - | - | role-controller |
|
||||
| POST | `/user/role/detail` | detail | id* | - | Role | role-controller |
|
||||
| POST | `/user/role/grantable/list` | listGrantableRole | moduleCode* | - | Array<Role> | role-controller |
|
||||
| POST | `/user/role/list` | list | - | PageRole | PageResultRole | role-controller |
|
||||
| POST | `/user/role/manageable/list` | listManageableRole | moduleCode* | - | Array<Role> | role-controller |
|
||||
| POST | `/user/role/parent/create/grantable/list` | listCreateGrantableParentRole | moduleCode* | - | Array<Role> | role-controller |
|
||||
| POST | `/user/role/parent/grantable/list` | listGrantableParentRole | roleId* | - | Array<Role> | role-controller |
|
||||
| POST | `/user/role/parent/update` | updateRoleParent | - | Role | - | role-controller |
|
||||
| POST | `/user/role/permission/grantable/list` | listGrantableRolePermission | roleId* | - | Array<Permission> | role-controller |
|
||||
| POST | `/user/role/update` | update | - | Role | - | role-controller |
|
||||
| POST | `/user/update` | update | - | User | - | user-controller |
|
||||
| POST | `/user/update/email` | updateEmail | - | - | - | user-controller |
|
||||
| POST | `/user/update/password` | updatePassword | - | UpdatePasswordRequest | - | user-controller |
|
||||
|
||||
<a id="module-app"></a>
|
||||
## app
|
||||
|
||||
共 13 个接口,路径前缀 `/app/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/app/channel/delete` | channelDelete | channelId* | - | - | app-release-controller |
|
||||
| GET | `/app/channel/list` | channelList | productId* | - | Array<AppChannel> | app-release-controller |
|
||||
| POST | `/app/product/delete` | productDelete | productId* | - | - | app-release-controller |
|
||||
| POST | `/app/product/list` | productList | - | - | Array<AppProduct> | app-release-controller |
|
||||
| POST | `/app/product/save` | productSave | - | AppProduct | AppProduct | app-release-controller |
|
||||
| POST | `/app/release/create` | releaseCreate | - | AppRelease | AppRelease | app-release-controller |
|
||||
| POST | `/app/release/delete` | releaseDelete | releaseId* | - | - | app-release-controller |
|
||||
| GET | `/app/release/list` | releaseList | productId* | - | Array<AppRelease> | app-release-controller |
|
||||
| POST | `/app/release/publish` | publish | releaseId*, channelCode, grayPermille, note | - | - | app-release-controller |
|
||||
| POST | `/app/release/revoke` | revoke | releaseId* | - | - | app-release-controller |
|
||||
| POST | `/app/release/rollback` | rollback | productId*, channelCode, targetReleaseId* | - | - | app-release-controller |
|
||||
| POST | `/app/update/check` | check | - | AppUpdateCheckRequest | AppUpdateCheckResponse | app-update-controller |
|
||||
| POST | `/app/update/notes` | notes | - | AppUpdateCheckRequest | AppUpdateNotesResponse | app-update-controller |
|
||||
|
||||
<a id="module-.well-known"></a>
|
||||
## .well-known
|
||||
|
||||
共 6 个接口,路径前缀 `/.well-known/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| GET | `/.well-known/oauth-authorization-server` | notSupported | - | - | - | gao-ai-mcp-o-auth-discovery-controller |
|
||||
| GET | `/.well-known/oauth-authorization-server/mcp/gao-ai` | notSupported | - | - | - | gao-ai-mcp-o-auth-discovery-controller |
|
||||
| GET | `/.well-known/oauth-protected-resource` | notSupported | - | - | - | gao-ai-mcp-o-auth-discovery-controller |
|
||||
| GET | `/.well-known/oauth-protected-resource/mcp/gao-ai` | notSupported | - | - | - | gao-ai-mcp-o-auth-discovery-controller |
|
||||
| GET | `/.well-known/openid-configuration` | notSupported | - | - | - | gao-ai-mcp-o-auth-discovery-controller |
|
||||
| GET | `/.well-known/openid-configuration/mcp/gao-ai` | notSupported | - | - | - | gao-ai-mcp-o-auth-discovery-controller |
|
||||
|
||||
<a id="module-article"></a>
|
||||
## article
|
||||
|
||||
共 5 个接口,路径前缀 `/article/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/article/create` | create | - | Article_Public | Article_Public | article-controller |
|
||||
| POST | `/article/delete` | delete | id* | - | - | article-controller |
|
||||
| GET/HEAD/POST/PUT/PATCH/DELETE/OPTIONS | `/article/detail` | detail | id* | - | Article_Public | article-controller |
|
||||
| POST | `/article/list` | list | - | PageArticle_Public | PageResultArticle_Public | article-controller |
|
||||
| POST | `/article/update` | update | - | Article | - | article-controller |
|
||||
|
||||
<a id="module-attach"></a>
|
||||
## attach
|
||||
|
||||
共 14 个接口,路径前缀 `/attach/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| GET | `/attach/count/biz` | countByBiz | bizType*, bizId*, attachTypeList | - | integer | attachment-controller |
|
||||
| POST | `/attach/create` | create | - | Attachment (multipart/form-data) | Attachment | attachment-controller |
|
||||
| POST | `/attach/delete` | delete | id* | - | - | attachment-controller |
|
||||
| POST | `/attach/detail` | detail | id* | - | Attachment | attachment-controller |
|
||||
| GET | `/attach/detail/byAttachType` | detailByAttachType | bizType*, bizId*, attachType* | - | Attachment | attachment-controller |
|
||||
| GET | `/attach/detail/byBiz` | detailByBiz | bizType*, bizId* | - | Attachment | attachment-controller |
|
||||
| GET | `/attach/download/{id}` | readById | id*, thumbWidth, thumbHeight, fitMode | - | - | attachment-controller |
|
||||
| GET | `/attach/list/biz` | listByBiz | bizType*, bizId*, attachTypeList | - | Array<Attachment> | attachment-controller |
|
||||
| POST | `/attach/page/biz` | pageByBiz | bizType*, bizId*, attachTypeList | PageAttachment | PageResultAttachment | attachment-controller |
|
||||
| GET | `/attach/read/{id}` | readById | id*, thumbWidth, thumbHeight, fitMode | - | - | attachment-controller |
|
||||
| GET | `/attach/temp/download` | read | id* | - | - | attachment-controller |
|
||||
| GET | `/attach/temp/read` | read | id* | - | - | attachment-controller |
|
||||
| POST | `/attach/temp/upload` | upload | file*, ttl | - | Array<TempFileResp> | attachment-controller |
|
||||
| POST | `/attach/update` | update | - | Attachment (multipart/form-data) | - | attachment-controller |
|
||||
|
||||
<a id="module-captcha"></a>
|
||||
## captcha
|
||||
|
||||
共 2 个接口,路径前缀 `/captcha/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| GET | `/captcha` | captcha | width*, height* | - | Result | common-controller |
|
||||
| GET | `/captcha/img` | captchaImg | width*, height* | - | - | common-controller |
|
||||
|
||||
<a id="module-comment"></a>
|
||||
## comment
|
||||
|
||||
共 13 个接口,路径前缀 `/comment/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/comment/create` | create | - | CommentCreateReq_Public | Comment_Public | comment-controller |
|
||||
| POST | `/comment/delete` | delete | id*, userId* | - | - | comment-controller |
|
||||
| GET | `/comment/detail/tree` | detailTree | id*, currentUserId | - | Comment_Public | comment-controller |
|
||||
| GET | `/comment/flat/list` | listFlatRoot | bizType*, bizId*, offset, currentUserId | - | FlatCommentListResp_Public | comment-controller |
|
||||
| GET | `/comment/flat/thread` | getFlatThread | commentId*, offset, currentUserId | - | CommentThreadResp_Public | comment-controller |
|
||||
| POST | `/comment/layer/list` | listLayer | currentUserId | CommentLayerQueryReq_Public | CommentLayerResp_Public | comment-controller |
|
||||
| POST | `/comment/like` | like | commentId*, userId* | - | - | comment-controller |
|
||||
| POST | `/comment/like/list` | listLikedRecord | userId* | PageUserBehaviorRecord_Public | PageResultUserBehaviorRecord_Public | comment-controller |
|
||||
| GET | `/comment/nested/children` | getNestedChildren | commentId*, offset, currentUserId | - | CommentLayerResp_Public | comment-controller |
|
||||
| GET | `/comment/nested/detail` | getNestedDetail | commentId*, currentUserId | - | CommentNodeResp_Public | comment-controller |
|
||||
| GET | `/comment/nested/list` | listNestedRoot | bizType*, bizId*, offset, currentUserId | - | NestedCommentListResp_Public | comment-controller |
|
||||
| POST | `/comment/reply` | reply | - | CommentReplyReq_Public | Comment_Public | comment-controller |
|
||||
| POST | `/comment/unlike` | unlike | commentId*, userId* | - | - | comment-controller |
|
||||
|
||||
<a id="module-feedback"></a>
|
||||
## feedback
|
||||
|
||||
共 5 个接口,路径前缀 `/feedback/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/feedback/create` | create | - | CaptchaDataFeedback_Public | - | feedback-controller |
|
||||
| POST | `/feedback/delete` | delete | id* | - | - | feedback-controller |
|
||||
| POST | `/feedback/detail` | detail | id* | - | Feedback_Admin | feedback-controller |
|
||||
| POST | `/feedback/list` | list | - | PageFeedback_Admin | PageResultFeedback_Admin | feedback-controller |
|
||||
| POST | `/feedback/update` | update | - | Feedback | - | feedback-controller |
|
||||
|
||||
<a id="module-fmc"></a>
|
||||
## fmc
|
||||
|
||||
共 1 个接口,路径前缀 `/fmc/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/fmc/server/report` | report | - | - | - | server-controller |
|
||||
|
||||
<a id="module-icon"></a>
|
||||
## icon
|
||||
|
||||
共 4 个接口,路径前缀 `/icon/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| GET | `/icon/export/ttf` | exportTtf | - | - | - | icon-controller |
|
||||
| GET | `/icon/name/list` | listName | - | - | Array<string> | icon-controller |
|
||||
| GET | `/icon/svg/map` | mapSvg | - | - | Map<String, string> | icon-controller |
|
||||
| GET | `/icon/unicode/map` | mapUnicode | - | - | Map<String, string> | icon-controller |
|
||||
|
||||
<a id="module-journal"></a>
|
||||
## journal
|
||||
|
||||
共 7 个接口,路径前缀 `/journal/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| GET | `/journal/tool/memo` | getMemo | - | - | string | tool-controller |
|
||||
| POST | `/journal/tool/memo/update` | updateMemo | data* | - | - | tool-controller |
|
||||
| POST | `/journal/travel/create` | create | - | Travel | - | travel-controller |
|
||||
| POST | `/journal/travel/delete` | delete | - | string | - | travel-controller |
|
||||
| POST | `/journal/travel/list` | list | - | PageTravel | PageResultTravel | travel-controller |
|
||||
| POST | `/journal/travel/update` | update | - | Travel | - | travel-controller |
|
||||
| GET | `/journal/travel/{id}` | detail | id* | - | Travel | travel-controller |
|
||||
|
||||
<a id="module-log"></a>
|
||||
## log
|
||||
|
||||
共 1 个接口,路径前缀 `/log/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/log/create` | create | - | ClientLogRequest | - | logger-controller |
|
||||
|
||||
<a id="module-mcp"></a>
|
||||
## mcp
|
||||
|
||||
共 5 个接口,路径前缀 `/mcp/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/mcp/gao-ai` | handle | header:Authorization, header:X-Timi-AI-Session | JsonNode | object | gao-ai-mcp-controller |
|
||||
| POST | `/mcp/gao-ai-commit` | handle | header:Authorization, header:X-Timi-AI-Session | JsonNode | object | gao-ai-mcp-commit-controller |
|
||||
| GET | `/mcp/gao-ai/.well-known/oauth-authorization-server` | notSupported | - | - | - | gao-ai-mcp-o-auth-discovery-controller |
|
||||
| GET | `/mcp/gao-ai/.well-known/oauth-protected-resource` | notSupported | - | - | - | gao-ai-mcp-o-auth-discovery-controller |
|
||||
| GET | `/mcp/gao-ai/.well-known/openid-configuration` | notSupported | - | - | - | gao-ai-mcp-o-auth-discovery-controller |
|
||||
|
||||
<a id="module-mirror"></a>
|
||||
## mirror
|
||||
|
||||
共 2 个接口,路径前缀 `/mirror/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| GET | `/mirror/list` | list | - | - | Array<MirrorView> | mirror-controller |
|
||||
| GET | `/mirror/{mirrorName}` | get | mirrorName* | - | JsonNode | mirror-controller |
|
||||
|
||||
<a id="module-notify"></a>
|
||||
## notify
|
||||
|
||||
共 15 个接口,路径前缀 `/notify/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/notify/cancel` | cancel | id* | - | - | notify-controller |
|
||||
| POST | `/notify/create` | create | - | Notify | Notify | notify-controller |
|
||||
| POST | `/notify/delete` | delete | id* | - | - | notify-controller |
|
||||
| GET/HEAD/POST/PUT/PATCH/DELETE/OPTIONS | `/notify/detail` | detail | id* | - | Notify_Public | notify-controller |
|
||||
| POST | `/notify/internal/delete` | deleteInternal | id* | - | - | notify-controller |
|
||||
| POST | `/notify/internal/detail` | internalDetail | id* | - | NotifyDetail_Public | notify-controller |
|
||||
| POST | `/notify/internal/internal` | listInternal | unreadOnly | PageNotifyDetail | PageResultNotifyDetail | notify-controller |
|
||||
| POST | `/notify/internal/read` | markSiteRead | id* | - | - | notify-controller |
|
||||
| POST | `/notify/internal/read/all` | markAllSiteRead | - | - | - | notify-controller |
|
||||
| POST | `/notify/internal/unread/count` | countUnreadSite | - | - | integer | notify-controller |
|
||||
| POST | `/notify/management/cancel` | managementCancel | id* | - | - | notify-controller |
|
||||
| POST | `/notify/management/delete` | managementDelete | id* | - | - | notify-controller |
|
||||
| POST | `/notify/management/detail` | managementDetail | id* | - | Notify_Admin | notify-controller |
|
||||
| POST | `/notify/management/list` | managementList | - | PageNotify_Admin | PageResultNotifyManagementItem_Admin | notify-controller |
|
||||
| POST | `/notify/sms/captcha/create` | smsCaptchaCreate | - | CaptchaDataNotify | string | notify-controller |
|
||||
|
||||
<a id="module-root"></a>
|
||||
## root
|
||||
|
||||
共 1 个接口,路径前缀 `/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| GET/HEAD/POST/PUT/PATCH/DELETE/OPTIONS | `/` | root | - | - | string | common-controller |
|
||||
|
||||
<a id="module-setting"></a>
|
||||
## setting
|
||||
|
||||
共 6 个接口,路径前缀 `/setting/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/setting/create` | 创建配置 | - | Setting_Admin | Setting_Admin | 系统-配置 |
|
||||
| POST | `/setting/delete` | 删除配置 | - | string | - | 系统-配置 |
|
||||
| POST | `/setting/detail` | 查询配置详情 | - | string | Setting_Admin | 系统-配置 |
|
||||
| POST | `/setting/list` | 查询配置列表 | - | PageSetting_Admin | PageResultSetting_Admin | 系统-配置 |
|
||||
| GET/HEAD/POST/PUT/PATCH/DELETE/OPTIONS | `/setting/map` | [公开] 查询公开配置映射 | bizType*, bizId, code | - | Map<String, Setting_Public> | 系统-配置 |
|
||||
| POST | `/setting/update` | 更新配置 | - | Setting | - | 系统-配置 |
|
||||
|
||||
<a id="module-tag"></a>
|
||||
## tag
|
||||
|
||||
共 7 个接口,路径前缀 `/tag/`。
|
||||
|
||||
| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| POST | `/tag/apply` | apply | - | TagApply | - | tag-controller |
|
||||
| POST | `/tag/create` | create | - | Tag_Public | Tag_Public | tag-controller |
|
||||
| POST | `/tag/delete` | delete | id* | - | - | tag-controller |
|
||||
| POST | `/tag/detail` | detail | id* | - | Tag_Public | tag-controller |
|
||||
| POST | `/tag/list` | list | - | PageTag_Public | PageResultTag_Public | tag-controller |
|
||||
| GET | `/tag/list/biz/id` | listByBizType | bizType*, bizId* | - | Array<Tag_Public> | tag-controller |
|
||||
| POST | `/tag/update` | update | - | Tag | - | tag-controller |
|
||||
@@ -0,0 +1,7 @@
|
||||
# Lombok 全局配置
|
||||
|
||||
config.stopBubbling = true
|
||||
|
||||
# 将字段上的 @Qualifier 复制到 @RequiredArgsConstructor 生成的构造器参数,
|
||||
# 避免多个同泛型 Redis Bean 注入歧义
|
||||
lombok.copyableAnnotations += org.springframework.beans.factory.annotation.Qualifier
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
<groupId>com.imyeyu.timiserverapi</groupId>
|
||||
<artifactId>TimiServerAPI</artifactId>
|
||||
<version>1.0.80</version>
|
||||
<version>1.0.82</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>TimiServerAPI</name>
|
||||
<description>imyeyu.com API</description>
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<#
|
||||
<#
|
||||
.SYNOPSIS
|
||||
导出本地 OpenAPI 文档。
|
||||
|
||||
.DESCRIPTION
|
||||
从本地已启动的服务获取 /v3/api-docs.yaml(或 JSON),写入 docs 目录。
|
||||
生成的文件已被 .gitignore 忽略,不会提交。
|
||||
默认同时生成面向 AI Agent 的接口索引 docs/openapi.index.md。
|
||||
生成的 OpenAPI 快照已被 .gitignore 忽略;索引文件可按需提交或单独发送。
|
||||
|
||||
.PARAMETER BaseUrl
|
||||
服务地址,默认 http://localhost:18092。
|
||||
@@ -13,25 +14,41 @@
|
||||
输出文件路径,默认 docs/openapi.local.yaml。
|
||||
扩展名为 .json 时导出 JSON,否则导出 YAML。
|
||||
|
||||
.PARAMETER IndexFile
|
||||
接口索引输出路径,默认 docs/openapi.index.md。
|
||||
|
||||
.PARAMETER NoIndex
|
||||
跳过接口索引生成。
|
||||
|
||||
.EXAMPLE
|
||||
.\scripts\export-openapi.ps1
|
||||
|
||||
.EXAMPLE
|
||||
.\scripts\export-openapi.ps1 -BaseUrl http://192.168.1.10:18092 -OutFile docs/openapi.local.json
|
||||
|
||||
.EXAMPLE
|
||||
.\scripts\export-openapi.ps1 -NoIndex
|
||||
#>
|
||||
param(
|
||||
[string]$BaseUrl = "http://localhost:18092",
|
||||
[string]$OutFile
|
||||
[string]$OutFile,
|
||||
[string]$IndexFile,
|
||||
[switch]$NoIndex
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$RootDir = Split-Path -Parent $PSScriptRoot
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($OutFile)) {
|
||||
$OutFile = Join-Path (Split-Path -Parent $PSScriptRoot) "docs\openapi.local.yaml"
|
||||
$OutFile = Join-Path $RootDir "docs\openapi.local.yaml"
|
||||
}
|
||||
if ([string]::IsNullOrWhiteSpace($IndexFile)) {
|
||||
$IndexFile = Join-Path $RootDir "docs\openapi.index.md"
|
||||
}
|
||||
|
||||
$BaseUrl = $BaseUrl.TrimEnd("/")
|
||||
$OutFile = [System.IO.Path]::GetFullPath($OutFile)
|
||||
$IndexFile = [System.IO.Path]::GetFullPath($IndexFile)
|
||||
$OutDir = Split-Path -Parent $OutFile
|
||||
|
||||
if (-not (Test-Path -LiteralPath $OutDir)) {
|
||||
@@ -48,3 +65,60 @@ $Url = "$BaseUrl$ApiPath"
|
||||
Write-Host "Fetching $Url"
|
||||
Invoke-WebRequest -Uri $Url -OutFile $OutFile -UseBasicParsing
|
||||
Write-Host "OpenAPI exported to $OutFile"
|
||||
|
||||
if ($NoIndex) {
|
||||
exit 0
|
||||
}
|
||||
|
||||
if ($IndexFile -eq $OutFile) {
|
||||
Write-Warning "接口索引不能与 OpenAPI 输出文件相同,跳过接口索引生成。"
|
||||
exit 0
|
||||
}
|
||||
|
||||
$IndexScript = Join-Path $PSScriptRoot "openapi-index.py"
|
||||
if (-not (Test-Path -LiteralPath $IndexScript)) {
|
||||
Write-Warning "未找到 $IndexScript,跳过接口索引生成。"
|
||||
exit 0
|
||||
}
|
||||
|
||||
$Python = $null
|
||||
foreach ($Candidate in @("python", "python3")) {
|
||||
$Command = Get-Command $Candidate -ErrorAction SilentlyContinue
|
||||
if ($Command) {
|
||||
$Python = $Command.Source
|
||||
break
|
||||
}
|
||||
}
|
||||
if (-not $Python) {
|
||||
Write-Warning "未找到 Python,跳过接口索引生成。安装 Python 或使用 -NoIndex 关闭该提示。"
|
||||
exit 0
|
||||
}
|
||||
|
||||
$IndexDir = Split-Path -Parent $IndexFile
|
||||
if (-not (Test-Path -LiteralPath $IndexDir)) {
|
||||
New-Item -ItemType Directory -Path $IndexDir -Force | Out-Null
|
||||
}
|
||||
|
||||
$IndexInput = $OutFile
|
||||
$TempIndexInput = $null
|
||||
if ([System.IO.Path]::GetExtension($OutFile) -ine ".json") {
|
||||
$TempIndexInput = [System.IO.Path]::GetTempFileName()
|
||||
try {
|
||||
Invoke-WebRequest -Uri "$BaseUrl/v3/api-docs" -OutFile $TempIndexInput -UseBasicParsing
|
||||
$IndexInput = $TempIndexInput
|
||||
} catch {
|
||||
Write-Warning "获取 OpenAPI JSON 失败,跳过接口索引生成:$($_.Exception.Message)"
|
||||
$IndexInput = $null
|
||||
}
|
||||
}
|
||||
|
||||
if ($IndexInput) {
|
||||
& $Python $IndexScript $IndexInput $IndexFile
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Warning "接口索引生成失败(退出码 $LASTEXITCODE)。"
|
||||
}
|
||||
}
|
||||
|
||||
if ($TempIndexInput -and (Test-Path -LiteralPath $TempIndexInput)) {
|
||||
Remove-Item -LiteralPath $TempIndexInput -Force
|
||||
}
|
||||
|
||||
@@ -1,17 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
# 导出本地 OpenAPI 文档。
|
||||
# 导出本地 OpenAPI 文档,并默认生成面向 AI Agent 的接口索引。
|
||||
#
|
||||
# 用法:
|
||||
# scripts/export-openapi.sh [baseUrl] [outFile]
|
||||
# scripts/export-openapi.sh [baseUrl] [outFile] [indexFile]
|
||||
#
|
||||
# 输出文件扩展名为 .json 时导出 JSON,否则导出 YAML。
|
||||
# 生成的文件已被 .gitignore 忽略,不会提交。
|
||||
# 索引默认输出到 docs/openapi.index.md;设置 SKIP_INDEX=1 可跳过。
|
||||
# 生成的 OpenAPI 快照已被 .gitignore 忽略;索引文件可按需提交或单独发送。
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
BASE_URL="${1:-http://localhost:18092}"
|
||||
OUT_FILE="${2:-$ROOT_DIR/docs/openapi.local.yaml}"
|
||||
INDEX_FILE="${3:-$ROOT_DIR/docs/openapi.index.md}"
|
||||
|
||||
BASE_URL="${BASE_URL%/}"
|
||||
mkdir -p "$(dirname "$OUT_FILE")"
|
||||
@@ -28,3 +30,50 @@ esac
|
||||
echo "Fetching ${BASE_URL}${API_PATH}"
|
||||
curl -fsS "${BASE_URL}${API_PATH}" -o "$OUT_FILE"
|
||||
echo "OpenAPI exported to $OUT_FILE"
|
||||
|
||||
if [[ "${SKIP_INDEX:-0}" == "1" ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ "$INDEX_FILE" == "$OUT_FILE" ]]; then
|
||||
echo "warning: 接口索引不能与 OpenAPI 输出文件相同,跳过接口索引生成。" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
INDEX_SCRIPT="$ROOT_DIR/scripts/openapi-index.py"
|
||||
if [[ ! -f "$INDEX_SCRIPT" ]]; then
|
||||
echo "warning: 未找到 $INDEX_SCRIPT,跳过接口索引生成。" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
PYTHON="$(command -v python3 2>/dev/null || command -v python 2>/dev/null || true)"
|
||||
if [[ -z "$PYTHON" ]]; then
|
||||
echo "warning: 未找到 Python,跳过接口索引生成。安装 Python 或设置 SKIP_INDEX=1 关闭该提示。" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
INDEX_INPUT="$OUT_FILE"
|
||||
TEMP_JSON=""
|
||||
cleanup() {
|
||||
if [[ -n "$TEMP_JSON" ]]; then
|
||||
rm -f "$TEMP_JSON"
|
||||
fi
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
if [[ "$OUT_FILE" != *.json ]]; then
|
||||
TEMP_JSON="$(mktemp)"
|
||||
if curl -fsS "${BASE_URL}/v3/api-docs" -o "$TEMP_JSON"; then
|
||||
INDEX_INPUT="$TEMP_JSON"
|
||||
else
|
||||
echo "warning: 获取 OpenAPI JSON 失败,跳过接口索引生成。" >&2
|
||||
INDEX_INPUT=""
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -n "$INDEX_INPUT" ]]; then
|
||||
mkdir -p "$(dirname "$INDEX_FILE")"
|
||||
if ! "$PYTHON" "$INDEX_SCRIPT" "$INDEX_INPUT" "$INDEX_FILE"; then
|
||||
echo "warning: 接口索引生成失败。" >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -0,0 +1,356 @@
|
||||
#!/usr/bin/env python3
|
||||
"""从 OpenAPI 文档生成供 AI Agent 使用的接口索引。
|
||||
|
||||
默认优先读取 JSON(标准库即可解析);读取 YAML 时需要安装 PyYAML。
|
||||
导出脚本会优先传入 /v3/api-docs 的 JSON,避免额外依赖。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
HTTP_METHODS = ("get", "head", "post", "put", "patch", "delete", "options", "trace")
|
||||
REQUEST_MEDIA = ("application/json", "multipart/form-data", "application/x-www-form-urlencoded", "*/*")
|
||||
RESPONSE_MEDIA = ("application/json", "*/*", "text/event-stream", "application/octet-stream")
|
||||
|
||||
|
||||
def load_spec(path: Path) -> dict[str, Any]:
|
||||
text = path.read_text(encoding="utf-8")
|
||||
try:
|
||||
data = json.loads(text)
|
||||
except json.JSONDecodeError:
|
||||
try:
|
||||
import yaml
|
||||
except ImportError as exc:
|
||||
raise SystemExit(
|
||||
"无法解析 YAML:请安装 PyYAML(pip install pyyaml),"
|
||||
"或改用 /v3/api-docs 的 JSON 输出。"
|
||||
) from exc
|
||||
data = yaml.safe_load(text)
|
||||
if not isinstance(data, dict):
|
||||
raise SystemExit("OpenAPI 文档格式不正确:根节点必须是对象")
|
||||
return data
|
||||
|
||||
|
||||
def resolve(spec: dict[str, Any], value: Any) -> Any:
|
||||
"""解析本地 $ref,最多跟随 32 层,避免循环引用。"""
|
||||
for _ in range(32):
|
||||
if not isinstance(value, dict) or "$ref" not in value:
|
||||
return value
|
||||
ref = value["$ref"]
|
||||
if not isinstance(ref, str) or not ref.startswith("#/"):
|
||||
return value
|
||||
current: Any = spec
|
||||
for part in ref[2:].split("/"):
|
||||
part = part.replace("~1", "/").replace("~0", "~")
|
||||
if not isinstance(current, dict) or part not in current:
|
||||
return value
|
||||
current = current[part]
|
||||
value = current
|
||||
return value
|
||||
|
||||
|
||||
def ref_name(ref: str) -> str:
|
||||
return ref.rsplit("/", 1)[-1].replace("~1", "/").replace("~0", "~")
|
||||
|
||||
|
||||
def schema_label(spec: dict[str, Any], schema: Any, depth: int = 0) -> str:
|
||||
if not isinstance(schema, dict) or depth > 4:
|
||||
return "-"
|
||||
if "$ref" in schema:
|
||||
return ref_name(str(schema["$ref"]))
|
||||
schema_type = schema.get("type")
|
||||
if isinstance(schema_type, list):
|
||||
schema_type = "/".join(str(item) for item in schema_type)
|
||||
if schema_type == "array":
|
||||
return f"Array<{schema_label(spec, schema.get('items'), depth + 1)}>"
|
||||
if schema_type == "object" or "properties" in schema:
|
||||
additional = schema.get("additionalProperties")
|
||||
if isinstance(additional, dict):
|
||||
return f"Map<String, {schema_label(spec, additional, depth + 1)}>"
|
||||
if additional is True:
|
||||
return "Map<String, any>"
|
||||
properties = schema.get("properties")
|
||||
if isinstance(properties, dict) and properties:
|
||||
names = list(properties)
|
||||
if len(names) > 8:
|
||||
names = names[:8] + ["..."]
|
||||
return "object{" + ", ".join(names) + "}"
|
||||
return "object"
|
||||
for keyword in ("oneOf", "anyOf", "allOf"):
|
||||
items = schema.get(keyword)
|
||||
if isinstance(items, list) and items:
|
||||
joiner = " | " if keyword == "oneOf" else " & "
|
||||
return "(" + joiner.join(schema_label(spec, item, depth + 1) for item in items) + ")"
|
||||
if schema_type == "string" and schema.get("format") in ("binary", "byte"):
|
||||
return "binary"
|
||||
if schema_type:
|
||||
return str(schema_type)
|
||||
return "-"
|
||||
|
||||
|
||||
def pick_media(content: Any, preferred: tuple[str, ...]) -> tuple[str | None, Any]:
|
||||
if not isinstance(content, dict) or not content:
|
||||
return None, None
|
||||
for media in preferred:
|
||||
if media in content:
|
||||
return media, content[media]
|
||||
media = next(iter(content))
|
||||
return media, content[media]
|
||||
|
||||
|
||||
def request_label(spec: dict[str, Any], operation: dict[str, Any]) -> str:
|
||||
body = resolve(spec, operation.get("requestBody"))
|
||||
if not isinstance(body, dict):
|
||||
return "-"
|
||||
media, entry = pick_media(body.get("content"), REQUEST_MEDIA)
|
||||
if media is None:
|
||||
return "-"
|
||||
schema = entry.get("schema") if isinstance(entry, dict) else None
|
||||
label = schema_label(spec, schema)
|
||||
if label == "-":
|
||||
return media
|
||||
if media in ("application/json", "*/*"):
|
||||
return label
|
||||
return f"{label} ({media})"
|
||||
|
||||
|
||||
def response_label(spec: dict[str, Any], operation: dict[str, Any]) -> str:
|
||||
responses = operation.get("responses")
|
||||
if not isinstance(responses, dict) or not responses:
|
||||
return "-"
|
||||
response = None
|
||||
for code in ("200", "201", "202", "204"):
|
||||
if code in responses:
|
||||
response = responses[code]
|
||||
break
|
||||
if response is None:
|
||||
for code, candidate in responses.items():
|
||||
if str(code).startswith("2"):
|
||||
response = candidate
|
||||
break
|
||||
if response is None and "default" in responses:
|
||||
response = responses["default"]
|
||||
response = resolve(spec, response)
|
||||
if not isinstance(response, dict):
|
||||
return "-"
|
||||
media, entry = pick_media(response.get("content"), RESPONSE_MEDIA)
|
||||
if media is None:
|
||||
return "-"
|
||||
if media == "text/event-stream":
|
||||
return "SSE"
|
||||
schema = entry.get("schema") if isinstance(entry, dict) else None
|
||||
label = schema_label(spec, schema)
|
||||
if label == "-":
|
||||
return media
|
||||
if media in ("application/json", "*/*"):
|
||||
return label
|
||||
return f"{label} ({media})"
|
||||
|
||||
|
||||
def parameter_label(spec: dict[str, Any], path_item: dict[str, Any], operation: dict[str, Any]) -> str:
|
||||
merged: dict[tuple[str, str], dict[str, Any]] = {}
|
||||
for source in (path_item.get("parameters"), operation.get("parameters")):
|
||||
if not isinstance(source, list):
|
||||
continue
|
||||
for raw in source:
|
||||
parameter = resolve(spec, raw)
|
||||
if not isinstance(parameter, dict):
|
||||
continue
|
||||
name = parameter.get("name")
|
||||
location = parameter.get("in")
|
||||
if name and location:
|
||||
merged[(str(name), str(location))] = parameter
|
||||
if not merged:
|
||||
return "-"
|
||||
parts = []
|
||||
for (name, location), parameter in merged.items():
|
||||
prefix = ""
|
||||
if location in ("header", "cookie"):
|
||||
prefix = f"{location}:"
|
||||
suffix = "*" if parameter.get("required") else ""
|
||||
parts.append(f"{prefix}{name}{suffix}")
|
||||
return ", ".join(parts)
|
||||
|
||||
|
||||
def cell(value: Any) -> str:
|
||||
text = "" if value is None else str(value)
|
||||
text = re.sub(r"\s+", " ", text).strip()
|
||||
text = text.replace("|", "\\|")
|
||||
return text or "-"
|
||||
|
||||
|
||||
def module_key(path: str) -> str:
|
||||
segments = [segment for segment in path.split("/") if segment]
|
||||
if not segments:
|
||||
return "root"
|
||||
if segments[0] == "gao" and len(segments) > 1:
|
||||
return f"gao-{segments[1]}"
|
||||
return segments[0]
|
||||
|
||||
|
||||
def module_prefix(key: str) -> str:
|
||||
if key == "root":
|
||||
return "/"
|
||||
if key.startswith("gao-"):
|
||||
return f"/gao/{key[4:]}/"
|
||||
return f"/{key}/"
|
||||
|
||||
|
||||
def module_sort(key: str) -> tuple[int, str]:
|
||||
if key.startswith("gao-"):
|
||||
return 0, key
|
||||
order = {"system": 1, "user": 2, "app": 3}
|
||||
return order.get(key, 4), key
|
||||
|
||||
|
||||
def collect_operations(spec: dict[str, Any]) -> list[dict[str, Any]]:
|
||||
paths = spec.get("paths")
|
||||
if not isinstance(paths, dict):
|
||||
return []
|
||||
operations = []
|
||||
for path, path_item in paths.items():
|
||||
if not isinstance(path_item, dict):
|
||||
continue
|
||||
path_item = resolve(spec, path_item)
|
||||
if not isinstance(path_item, dict):
|
||||
continue
|
||||
for method in HTTP_METHODS:
|
||||
operation = path_item.get(method)
|
||||
if not isinstance(operation, dict):
|
||||
continue
|
||||
operation = resolve(spec, operation)
|
||||
if not isinstance(operation, dict):
|
||||
continue
|
||||
summary = operation.get("summary") or operation.get("operationId") or ""
|
||||
if operation.get("summary") is None and isinstance(summary, str):
|
||||
summary = re.sub(r"_\d+$", "", summary)
|
||||
if operation.get("deprecated"):
|
||||
summary = f"[已废弃] {summary}"
|
||||
public = operation["security"] == [] if "security" in operation else not spec.get("security")
|
||||
if public:
|
||||
summary = f"[公开] {summary}"
|
||||
operations.append({
|
||||
"methods": [method.upper()],
|
||||
"path": path,
|
||||
"summary": summary,
|
||||
"parameters": parameter_label(spec, path_item, operation),
|
||||
"request": request_label(spec, operation),
|
||||
"response": response_label(spec, operation),
|
||||
"tag": ", ".join(operation.get("tags") or []),
|
||||
"module": module_key(path),
|
||||
"order": (path, HTTP_METHODS.index(method)),
|
||||
})
|
||||
# 同一个处理器的多个 HTTP 方法(如 @RequestMapping 未限定 method)合并为一行。
|
||||
merged: dict[tuple[Any, ...], dict[str, Any]] = {}
|
||||
for operation in operations:
|
||||
key = (
|
||||
operation["path"],
|
||||
operation["summary"],
|
||||
operation["parameters"],
|
||||
operation["request"],
|
||||
operation["response"],
|
||||
operation["tag"],
|
||||
operation["module"],
|
||||
)
|
||||
if key in merged:
|
||||
merged[key]["methods"].append(operation["methods"][0])
|
||||
else:
|
||||
merged[key] = operation
|
||||
return list(merged.values())
|
||||
|
||||
|
||||
def render(spec: dict[str, Any], source: str) -> str:
|
||||
info = spec.get("info") if isinstance(spec.get("info"), dict) else {}
|
||||
title = info.get("title") or "OpenAPI"
|
||||
version = info.get("version") or "-"
|
||||
openapi_version = spec.get("openapi") or "-"
|
||||
paths = spec.get("paths") if isinstance(spec.get("paths"), dict) else {}
|
||||
operations = collect_operations(spec)
|
||||
groups: dict[str, list[dict[str, Any]]] = {}
|
||||
for operation in operations:
|
||||
groups.setdefault(operation["module"], []).append(operation)
|
||||
for items in groups.values():
|
||||
items.sort(key=lambda item: item["order"])
|
||||
|
||||
lines = [
|
||||
f"# {title} 接口索引",
|
||||
"",
|
||||
"> 本文件由 `scripts/openapi-index.py` 从 OpenAPI 快照生成,请勿手工编辑。",
|
||||
f"> 数据来源:`{source}`。完整字段定义以 OpenAPI 原文为准。",
|
||||
"",
|
||||
f"- 服务版本:`{version}`",
|
||||
f"- OpenAPI 版本:`{openapi_version}`",
|
||||
f"- 路径数:{len(paths)}",
|
||||
f"- 接口数:{len(operations)}(同一路径的同一处理器会合并多个 HTTP 方法)",
|
||||
f"- 模块数:{len(groups)}",
|
||||
"",
|
||||
"## 使用说明",
|
||||
"",
|
||||
"- 先按模块定位接口,再读取 `docs/openapi.local.yaml` 中对应的 `path` 或 `components/schemas`,不要整文件加载。",
|
||||
"- 参数列中 `*` 表示必填;`header:`、`cookie:` 为参数位置前缀,其余为 path/query 参数。",
|
||||
"- 摘要前的 `[公开]` 表示 OpenAPI 中显式标记为无需登录;未标记的接口默认使用 `Token` 鉴权。",
|
||||
"- 方法列出现多个 HTTP 方法,表示 Controller 使用了未限定 method 的 `@RequestMapping`。",
|
||||
"- 请求体和响应列展示顶层 schema 名称;`binary` 表示二进制响应,`SSE` 表示 `text/event-stream`。",
|
||||
"- 普通 JSON 接口的响应仍由 `TimiResponse` 包装,鉴权、错误码、分页等约定见 `docs/api-integration.md`。",
|
||||
"",
|
||||
"## 模块导航",
|
||||
"",
|
||||
"| 模块 | 接口数 | 路径前缀 |",
|
||||
"| --- | ---: | --- |",
|
||||
]
|
||||
for key in sorted(groups, key=module_sort):
|
||||
lines.append(f"| [`{cell(key)}`](#module-{key}) | {len(groups[key])} | `{module_prefix(key)}` |")
|
||||
|
||||
for key in sorted(groups, key=module_sort):
|
||||
lines.extend([
|
||||
"",
|
||||
f'<a id="module-{key}"></a>',
|
||||
f"## {key}",
|
||||
"",
|
||||
f"共 {len(groups[key])} 个接口,路径前缀 `{module_prefix(key)}`。",
|
||||
"",
|
||||
"| 方法 | 路径 | 摘要 | 参数 | 请求体 | 响应 | Tag |",
|
||||
"| --- | --- | --- | --- | --- | --- | --- |",
|
||||
])
|
||||
for operation in groups[key]:
|
||||
lines.append(
|
||||
"| {method} | `{path}` | {summary} | {parameters} | {request} | {response} | {tag} |".format(
|
||||
method="/".join(operation["methods"]),
|
||||
path=cell(operation["path"]),
|
||||
summary=cell(operation["summary"]),
|
||||
parameters=cell(operation["parameters"]),
|
||||
request=cell(operation["request"]),
|
||||
response=cell(operation["response"]),
|
||||
tag=cell(operation["tag"]),
|
||||
)
|
||||
)
|
||||
lines.append("")
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description="从 OpenAPI 文档生成 AI Agent 接口索引")
|
||||
parser.add_argument("input", type=Path, help="OpenAPI JSON/YAML 文件")
|
||||
parser.add_argument("output", type=Path, help="输出的 Markdown 文件")
|
||||
parser.add_argument(
|
||||
"--source-label",
|
||||
default="docs/openapi.local.yaml",
|
||||
help="索引中显示的数据来源(默认 docs/openapi.local.yaml)",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
spec = load_spec(args.input)
|
||||
args.output.parent.mkdir(parents=True, exist_ok=True)
|
||||
args.output.write_text(render(spec, args.source_label), encoding="utf-8", newline="\n")
|
||||
print(f"OpenAPI index written to {args.output}")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -11,10 +11,8 @@ import lombok.AllArgsConstructor;
|
||||
@AllArgsConstructor
|
||||
public enum CorePermissionCode implements BuiltinPermissionCode {
|
||||
|
||||
PERMISSION_CREATE("PERMISSION:CREATE", "权限创建", false, true),
|
||||
PERMISSION_READ("PERMISSION:READ", "权限读取", false, true),
|
||||
PERMISSION_UPDATE("PERMISSION:UPDATE", "权限修改", false, true),
|
||||
PERMISSION_DELETE("PERMISSION:DELETE", "权限删除", false, true),
|
||||
|
||||
ROLE_CREATE("ROLE:CREATE", "角色创建", false, true),
|
||||
ROLE_READ("ROLE:READ", "角色读取", false, true),
|
||||
@@ -29,10 +27,8 @@ public enum CorePermissionCode implements BuiltinPermissionCode {
|
||||
ROLE_PERMISSION_INHERIT_READ("ROLE_PERMISSION_INHERIT:READ", "角色权限继承读取", false, true),
|
||||
ROLE_PERMISSION_INHERIT_DELETE("ROLE_PERMISSION_INHERIT:DELETE", "角色权限继承删除", false, true),
|
||||
|
||||
SETTING_CREATE("SETTING:CREATE", "设置创建", false, true),
|
||||
SETTING_READ("SETTING:READ", "设置读取", false, true),
|
||||
SETTING_UPDATE("SETTING:UPDATE", "设置修改", false, true),
|
||||
SETTING_DELETE("SETTING:DELETE", "设置删除", false, true),
|
||||
|
||||
MULTILINGUAL_CREATE("MULTILINGUAL:CREATE", "多语言创建", false, true),
|
||||
MULTILINGUAL_READ("MULTILINGUAL:READ", "多语言读取", false, true),
|
||||
|
||||
@@ -10,6 +10,10 @@ import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||
import com.imyeyu.spring.bean.Page;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import com.imyeyu.spring.util.ResponseView;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirements;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -21,12 +25,11 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author 夜雨
|
||||
* @since 2026-04-23 16:31
|
||||
*/
|
||||
/// 系统配置接口
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-04-23 16:31
|
||||
@Tag(name = "系统-配置", description = "系统配置公开查询与管理接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@@ -43,12 +46,17 @@ public class SettingController {
|
||||
* @param code 配置代码列表,可为空
|
||||
* @return 公开配置映射
|
||||
*/
|
||||
@Operation(summary = "查询公开配置映射", description = "按业务类型查询公开配置,返回以配置代码为键的映射;无需登录。")
|
||||
@SecurityRequirements
|
||||
@JsonView(ResponseView.Public.class)
|
||||
@RequestRateLimit
|
||||
@RequestMapping("/map")
|
||||
public Map<String, Setting> map(
|
||||
@Parameter(description = "业务类型", required = true)
|
||||
@RequestParam String bizType,
|
||||
@Parameter(description = "业务 ID,系统级配置省略")
|
||||
@RequestParam(required = false) String bizId,
|
||||
@Parameter(description = "配置代码列表,省略时返回全部公开配置")
|
||||
@RequestParam(required = false) List<String> code
|
||||
) {
|
||||
return service.mapPublic(bizType, bizId, code);
|
||||
@@ -60,6 +68,7 @@ public class SettingController {
|
||||
* @param page 分页查询
|
||||
* @return 配置列表
|
||||
*/
|
||||
@Operation(summary = "查询配置列表", description = "分页查询配置,需要 SETTING:READ 权限。")
|
||||
@JsonView(ResponseView.Admin.class)
|
||||
@RequestRateLimit
|
||||
@RequireCorePermission(CorePermissionCode.SETTING_READ)
|
||||
@@ -74,35 +83,23 @@ public class SettingController {
|
||||
* @param id 配置 ID
|
||||
* @return 配置详情
|
||||
*/
|
||||
@Operation(summary = "查询配置详情", description = "按配置 ID 查询配置,需要 SETTING:READ 权限。")
|
||||
@JsonView(ResponseView.Admin.class)
|
||||
@RequestRateLimit
|
||||
@RequireCorePermission(CorePermissionCode.SETTING_READ)
|
||||
@PostMapping("/detail")
|
||||
public Setting detail(@RequestBody String id) {
|
||||
public Setting detail(
|
||||
@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "配置 ID", required = true)
|
||||
@RequestBody String id) {
|
||||
return service.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建配置
|
||||
*
|
||||
* @param setting 配置
|
||||
* @return 配置
|
||||
*/
|
||||
@AOPLog
|
||||
@JsonView(ResponseView.Admin.class)
|
||||
@RequireCorePermission(CorePermissionCode.SETTING_CREATE)
|
||||
@RequestRateLimit
|
||||
@PostMapping("/create")
|
||||
public Setting create(@RequestBody Setting setting) {
|
||||
service.create(setting);
|
||||
return setting;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新配置
|
||||
*
|
||||
* @param setting 配置
|
||||
*/
|
||||
@Operation(summary = "更新配置", description = "更新配置,需要 SETTING:UPDATE 权限。")
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireCorePermission(CorePermissionCode.SETTING_UPDATE)
|
||||
@@ -110,17 +107,4 @@ public class SettingController {
|
||||
public void update(@RequestBody Setting setting) {
|
||||
service.update(setting);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除配置
|
||||
*
|
||||
* @param id 配置 ID
|
||||
*/
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireCorePermission(CorePermissionCode.SETTING_DELETE)
|
||||
@PostMapping("/delete")
|
||||
public void delete(@RequestBody String id) {
|
||||
service.delete(id);
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -46,11 +46,11 @@ public class GaoAiOperationServiceImplement implements GaoAiOperationService {
|
||||
private final ObjectMapper jackson;
|
||||
private final List<GaoAiOperationHandler> handlerList;
|
||||
|
||||
// @Qualifier("redisLocker")
|
||||
private Redis<String, Integer> locker;
|
||||
@Qualifier("redisLocker")
|
||||
private final Redis<String, Integer> locker;
|
||||
|
||||
// @Qualifier("redisRateLimit")
|
||||
private Redis<String, Integer> rateLimitRedis;
|
||||
@Qualifier("redisRateLimit")
|
||||
private final Redis<String, Integer> rateLimitRedis;
|
||||
|
||||
private Map<GaoAiOperation, GaoAiOperationHandler> handlerMap;
|
||||
|
||||
|
||||
+6
-6
@@ -30,14 +30,14 @@ public class GaoAiPendingOperationServiceImplement implements GaoAiPendingOperat
|
||||
|
||||
private final GaoAiProperties properties;
|
||||
|
||||
// @Qualifier("redisGaoAiOperation")
|
||||
private Redis<String, GaoAiPendingOperation> redis;
|
||||
@Qualifier("redisGaoAiOperation")
|
||||
private final Redis<String, GaoAiPendingOperation> redis;
|
||||
|
||||
// @Qualifier("redisGaoAiOperationIndex")
|
||||
private Redis<String, String> indexRedis;
|
||||
@Qualifier("redisGaoAiOperationIndex")
|
||||
private final Redis<String, String> indexRedis;
|
||||
|
||||
// @Qualifier("redisLocker")
|
||||
private Redis<String, Integer> locker;
|
||||
@Qualifier("redisLocker")
|
||||
private final Redis<String, Integer> locker;
|
||||
|
||||
private final SecureRandom secureRandom = new SecureRandom();
|
||||
|
||||
|
||||
@@ -67,6 +67,21 @@ public class GaoCustomerController {
|
||||
@PostMapping("/detail")
|
||||
@JsonView(ResponseView.Public.class)
|
||||
public GaoCustomer detail(@RequestParam String id) {
|
||||
return detailInternal(id);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.CUSTOMER_READ)
|
||||
@PostMapping("/detail/list")
|
||||
@JsonView(ResponseView.Public.class)
|
||||
public List<GaoCustomer> detailList(@RequestBody List<String> idList) {
|
||||
TimiException.requiredTrue(idList != null && !idList.isEmpty(), "not found customer.idList");
|
||||
TimiException.requiredTrue(idList.size() <= 50, "customer.idList too large");
|
||||
return idList.stream().distinct().map(this::detailInternal).toList();
|
||||
}
|
||||
|
||||
private GaoCustomer detailInternal(String id) {
|
||||
GaoCustomer customer = service.get(id);
|
||||
TimiException.required(customer, "not found customer");
|
||||
storeScopeService.checkStoreId(customer.getStoreId());
|
||||
|
||||
@@ -71,6 +71,26 @@ public class GaoFundRecordController {
|
||||
return result;
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.FUND_RECORD_READ)
|
||||
@PostMapping("/detail/list")
|
||||
public List<GaoFundRecord> detailList(@RequestBody List<String> idList) {
|
||||
TimiException.requiredTrue(idList != null && !idList.isEmpty(), "not found fundRecord.idList");
|
||||
TimiException.requiredTrue(idList.size() <= 50, "fundRecord.idList too large");
|
||||
return idList.stream().distinct().map(this::detail).toList();
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.FUND_RECEIVE_CREATE)
|
||||
@PostMapping("/my-receive/detail/list")
|
||||
public List<GaoFundRecord> detailMyReceiveList(@RequestBody List<String> idList) {
|
||||
TimiException.requiredTrue(idList != null && !idList.isEmpty(), "not found fundRecord.idList");
|
||||
TimiException.requiredTrue(idList.size() <= 50, "fundRecord.idList too large");
|
||||
return idList.stream().distinct().map(this::detailMyReceive).toList();
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.FUND_RECEIVE_CREATE)
|
||||
|
||||
+10
@@ -83,6 +83,16 @@ public class GaoOrderFulfillmentController {
|
||||
return result;
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.ORDER_FULFILLMENT_READ)
|
||||
@PostMapping("/detail/list")
|
||||
public List<GaoOrderFulfillment> detailList(@RequestBody List<String> idList) {
|
||||
TimiException.requiredTrue(idList != null && !idList.isEmpty(), "not found fulfillment.idList");
|
||||
TimiException.requiredTrue(idList.size() <= 50, "fulfillment.idList too large");
|
||||
return idList.stream().distinct().map(this::detail).toList();
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@PostMapping("/create")
|
||||
|
||||
@@ -75,6 +75,16 @@ public class GaoPackageConfigController {
|
||||
return config;
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.PACKAGE_CONFIG_READ)
|
||||
@PostMapping("/detail/list")
|
||||
public List<GaoPackageConfig> detailList(@RequestBody List<String> idList) {
|
||||
TimiException.requiredTrue(idList != null && !idList.isEmpty(), "not found packageConfig.idList");
|
||||
TimiException.requiredTrue(idList.size() <= 50, "packageConfig.idList too large");
|
||||
return idList.stream().distinct().map(this::detail).toList();
|
||||
}
|
||||
|
||||
private void fillTransient(List<GaoPackageConfig> configList, boolean includeProductDetail) {
|
||||
if (configList == null || configList.isEmpty()) {
|
||||
return;
|
||||
|
||||
@@ -18,6 +18,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/// GAO 积分兑换 SKU 配置接口
|
||||
///
|
||||
/// @author Codex
|
||||
@@ -52,6 +54,18 @@ public class GaoPointRedeemSkuController {
|
||||
return service.detail(storeScopeService.resolveStoreId(storeId), id);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.POINT_REDEEM_SKU_MANAGE)
|
||||
@PostMapping("/detail/list")
|
||||
public List<GaoPointRedeemSku> detailList(@RequestBody List<String> idList,
|
||||
@RequestParam(required = false) String storeId) {
|
||||
TimiException.requiredTrue(idList != null && !idList.isEmpty(), "not found redeemSku.idList");
|
||||
TimiException.requiredTrue(idList.size() <= 50, "redeemSku.idList too large");
|
||||
String resolvedStoreId = storeScopeService.resolveStoreId(storeId);
|
||||
return idList.stream().distinct().map(id -> service.detail(resolvedStoreId, id)).toList();
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.POINT_REDEEM_SKU_MANAGE)
|
||||
|
||||
@@ -114,6 +114,16 @@ public class GaoProductController {
|
||||
return result;
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.PRODUCT_READ)
|
||||
@PostMapping("/detail/list")
|
||||
public List<GaoProduct> detailList(@RequestBody List<String> idList) {
|
||||
TimiException.requiredTrue(idList != null && !idList.isEmpty(), "not found product.idList");
|
||||
TimiException.requiredTrue(idList.size() <= 50, "product.idList too large");
|
||||
return idList.stream().distinct().map(this::detail).toList();
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.PRODUCT_CREATE)
|
||||
@@ -171,6 +181,16 @@ public class GaoProductController {
|
||||
return result;
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.PRODUCT_READ)
|
||||
@PostMapping("/sku/detail/list")
|
||||
public List<GaoProductSku> skuDetailList(@RequestBody List<String> idList) {
|
||||
TimiException.requiredTrue(idList != null && !idList.isEmpty(), "not found sku.idList");
|
||||
TimiException.requiredTrue(idList.size() <= 50, "sku.idList too large");
|
||||
return idList.stream().distinct().map(this::skuDetail).toList();
|
||||
}
|
||||
|
||||
/// 批量查询履约所需的 SKU 信息
|
||||
///
|
||||
/// @param idList SKU ID 列表
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.imyeyu.api.modules.gao.entity.GaoRecycleExchangeRule;
|
||||
import com.imyeyu.api.modules.gao.service.GaoRecycleConfigService;
|
||||
import com.imyeyu.api.modules.gao.vo.recycle.GaoRecycleItemRequest;
|
||||
import com.imyeyu.api.modules.gao.vo.recycle.GaoRecycleExchangeRuleRequest;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import com.imyeyu.spring.annotation.AOPLog;
|
||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -17,6 +18,8 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/// 回收物和兑换规则接口
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@@ -73,6 +76,17 @@ public class GaoRecycleConfigController {
|
||||
return service.ruleDetail(storeId, id);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.RECYCLE_EXCHANGE_CONFIG_MANAGE)
|
||||
@PostMapping("/rule/detail/list")
|
||||
public List<GaoRecycleExchangeRule> ruleDetailList(@RequestBody List<String> idList,
|
||||
@RequestParam(required = false) String storeId) {
|
||||
TimiException.requiredTrue(idList != null && !idList.isEmpty(), "not found recycleRule.idList");
|
||||
TimiException.requiredTrue(idList.size() <= 50, "recycleRule.idList too large");
|
||||
return idList.stream().distinct().map(id -> service.ruleDetail(storeId, id)).toList();
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.RECYCLE_EXCHANGE_CONFIG_MANAGE)
|
||||
|
||||
@@ -37,6 +37,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/// GAO 销售订单和资金接口
|
||||
///
|
||||
/// @author Codex
|
||||
@@ -100,6 +102,16 @@ public class GaoSalesOrderController {
|
||||
return result;
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.SALES_ORDER_READ)
|
||||
@PostMapping("/detail/list")
|
||||
public List<GaoSalesOrder> detailList(@RequestBody List<String> idList) {
|
||||
TimiException.requiredTrue(idList != null && !idList.isEmpty(), "not found salesOrder.idList");
|
||||
TimiException.requiredTrue(idList.size() <= 50, "salesOrder.idList too large");
|
||||
return idList.stream().distinct().map(this::detail).toList();
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequestRateLimit
|
||||
@RequireGaoPermission(GaoPermissionCode.SALES_ORDER_CREATE)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.imyeyu.api.modules.system.bean;
|
||||
|
||||
import com.imyeyu.api.modules.system.util.FilePreview;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.tika.Tika;
|
||||
@@ -103,12 +104,7 @@ public class ServerFile implements Serializable {
|
||||
this.mimeType = TIKA.detect(this.name);
|
||||
this.category = FileCategory.of(this.mimeType, this.extension, false);
|
||||
this.etag = String.format("\"%x-%x\"", this.size, this.modifiedAt);
|
||||
this.canPreview = switch (this.mimeType) {
|
||||
case "image/png", "image/jpeg", "image/gif", "image/webp", "image/bmp",
|
||||
"video/mp4", "video/quicktime", "video/webm",
|
||||
"application/pdf", "text/plain" -> true;
|
||||
default -> false;
|
||||
};
|
||||
this.canPreview = FilePreview.supports(this.mimeType);
|
||||
} else {
|
||||
this.size = 0L;
|
||||
this.modifiedAt = absolute.toFile().lastModified();
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.imyeyu.api.annotation.RequireCorePermission;
|
||||
import com.imyeyu.api.bean.CorePermissionCode;
|
||||
import com.imyeyu.api.modules.system.service.FileContentService;
|
||||
import com.imyeyu.spring.annotation.IgnoreGlobalReturn;
|
||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -15,11 +14,15 @@ import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 文件内容接口
|
||||
*
|
||||
* <p>读取、下载与预览均输出二进制内容,浏览器会按 Range 对同一文件分多次请求,
|
||||
* 请求次数取决于播放和下载行为,因此不使用 {@code @RequestRateLimit} 按请求次数限流。
|
||||
*
|
||||
* @author 夜雨
|
||||
* @version 2026-11-24
|
||||
*/
|
||||
@@ -32,7 +35,6 @@ public class FileContentController {
|
||||
private final FileContentService contentService;
|
||||
|
||||
@Operation(summary = "读取文件", description = "以内联方式输出文件内容,支持 Range 与条件请求。")
|
||||
@RequestRateLimit
|
||||
@RequireCorePermission(CorePermissionCode.FILE_READ)
|
||||
@IgnoreGlobalReturn
|
||||
@GetMapping("/read/{*path}")
|
||||
@@ -44,7 +46,6 @@ public class FileContentController {
|
||||
}
|
||||
|
||||
@Operation(summary = "下载文件", description = "以附件方式输出文件内容,支持 Range 与 HEAD 请求。")
|
||||
@RequestRateLimit
|
||||
@RequireCorePermission(CorePermissionCode.FILE_READ)
|
||||
@IgnoreGlobalReturn
|
||||
@RequestMapping(value = "/download/{*path}", method = {RequestMethod.GET, RequestMethod.HEAD})
|
||||
@@ -55,15 +56,18 @@ public class FileContentController {
|
||||
FileBinaryResponder.serve(resp, () -> contentService.serve(req, resp, path, true));
|
||||
}
|
||||
|
||||
@Operation(summary = "预览文件", description = "图片和视频返回 PNG 缩略图,PDF 与文本返回原始内容。")
|
||||
@RequestRateLimit
|
||||
@Operation(summary = "预览文件", description = "图片和视频返回缩略图,其他类型不支持。")
|
||||
@RequireCorePermission(CorePermissionCode.FILE_READ)
|
||||
@IgnoreGlobalReturn
|
||||
@GetMapping("/preview/{*path}")
|
||||
public void preview(
|
||||
HttpServletRequest req, HttpServletResponse resp,
|
||||
@Parameter(description = "文件虚拟路径,以 / 开头", required = true)
|
||||
@PathVariable("path") String path) {
|
||||
FileBinaryResponder.serve(resp, () -> contentService.preview(req, resp, path));
|
||||
@PathVariable("path") String path,
|
||||
@Parameter(description = "缩略图最大边长(像素),范围 32-512,默认 256", example = "256")
|
||||
@RequestParam(value = "size", required = false, defaultValue = "256") int size,
|
||||
@Parameter(description = "缓存版本号,建议传文件列表返回的 etag;传入后使用长期强缓存")
|
||||
@RequestParam(value = "v", required = false) String version) {
|
||||
FileBinaryResponder.serve(resp, () -> contentService.preview(req, resp, path, size, version));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.imyeyu.api.modules.system.service;
|
||||
|
||||
import com.imyeyu.api.modules.system.util.FilePreview;
|
||||
import com.imyeyu.api.modules.system.util.ResourceHandler;
|
||||
import com.imyeyu.java.bean.timi.TimiCode;
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
@@ -28,6 +29,8 @@ public class FileContentService {
|
||||
"text/html", "application/xhtml+xml", "image/svg+xml",
|
||||
"application/javascript", "text/javascript", "application/x-javascript"
|
||||
);
|
||||
private static final String PREVIEW_CACHE_CONTROL = "private, max-age=86400";
|
||||
private static final String PREVIEW_IMMUTABLE_CACHE_CONTROL = "private, max-age=31536000, immutable";
|
||||
|
||||
private final FileStorageService storage;
|
||||
private final ThumbnailService thumbnailService;
|
||||
@@ -56,7 +59,7 @@ public class FileContentService {
|
||||
resp.setHeader("ETag", info.etag());
|
||||
resp.setDateHeader("Last-Modified", info.modifiedAt());
|
||||
resp.setHeader("Cache-Control", "private, max-age=0, must-revalidate");
|
||||
if (notModified(req, info)) {
|
||||
if (notModified(req, info.etag())) {
|
||||
resp.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
|
||||
return;
|
||||
}
|
||||
@@ -80,50 +83,48 @@ public class FileContentService {
|
||||
}
|
||||
}
|
||||
|
||||
/// 输出预览图。图片/视频走缩略图缓存,PDF/文本直接内联。
|
||||
public void preview(HttpServletRequest req, HttpServletResponse resp, String virtualPath) {
|
||||
/// 输出预览图。仅图片和视频支持,按请求尺寸生成缩略图。
|
||||
///
|
||||
/// @param size 缩略图最大边长
|
||||
/// @param version 缓存版本号,建议传文件列表返回的 etag;传入后使用长期强缓存
|
||||
public void preview(HttpServletRequest req, HttpServletResponse resp, String virtualPath, int size, String version) {
|
||||
ThumbnailService.requireValidSize(size);
|
||||
ContentInfo info = info(virtualPath);
|
||||
if (info.attachment()) {
|
||||
if (info.attachment() || !FilePreview.supports(info.mimeType())) {
|
||||
throw new TimiException(TimiCode.ARG_BAD, "该文件类型不支持在线预览");
|
||||
}
|
||||
resp.setHeader("ETag", info.etag());
|
||||
String etag = previewEtag(info, size);
|
||||
resp.setHeader("ETag", etag);
|
||||
resp.setDateHeader("Last-Modified", info.modifiedAt());
|
||||
if (notModified(req, info)) {
|
||||
resp.setHeader("Cache-Control", version == null || version.isBlank()
|
||||
? PREVIEW_CACHE_CONTROL : PREVIEW_IMMUTABLE_CACHE_CONTROL);
|
||||
if (notModified(req, etag)) {
|
||||
resp.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
|
||||
return;
|
||||
}
|
||||
if (info.mimeType().startsWith("image/") || info.mimeType().startsWith("video/")) {
|
||||
Path thumbnail = thumbnailService.thumbnail(info.path(), info.mimeType());
|
||||
try {
|
||||
resp.setContentType("image/png");
|
||||
resp.setHeader("X-Content-Type-Options", "nosniff");
|
||||
resp.setHeader("Cache-Control", "private, max-age=86400");
|
||||
resp.setContentLengthLong(Files.size(thumbnail));
|
||||
Files.copy(thumbnail, resp.getOutputStream());
|
||||
} catch (IOException e) {
|
||||
throw new TimiException(TimiCode.ERROR, "生成预览失败");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ("application/pdf".equals(info.mimeType()) || "text/plain".equals(info.mimeType())) {
|
||||
resp.setContentType(info.mimeType());
|
||||
Path thumbnail = thumbnailService.thumbnail(info.path(), info.mimeType(), size);
|
||||
try {
|
||||
resp.setContentType(contentType(thumbnail));
|
||||
resp.setHeader("X-Content-Type-Options", "nosniff");
|
||||
resp.setHeader("Content-Disposition", "inline; filename*=UTF-8''" +
|
||||
java.net.URLEncoder.encode(info.path().getFileName().toString(), java.nio.charset.StandardCharsets.UTF_8).replace("+", "%20"));
|
||||
resp.setContentLengthLong(info.size());
|
||||
try {
|
||||
Files.copy(info.path(), resp.getOutputStream());
|
||||
} catch (IOException e) {
|
||||
throw new TimiException(TimiCode.ERROR, "读取文件失败");
|
||||
}
|
||||
return;
|
||||
resp.setContentLengthLong(Files.size(thumbnail));
|
||||
Files.copy(thumbnail, resp.getOutputStream());
|
||||
} catch (IOException e) {
|
||||
throw new TimiException(TimiCode.ERROR, "生成预览失败");
|
||||
}
|
||||
throw new TimiException(TimiCode.ARG_BAD, "该文件类型不支持预览");
|
||||
}
|
||||
|
||||
private boolean notModified(HttpServletRequest req, ContentInfo info) {
|
||||
private String previewEtag(ContentInfo info, int size) {
|
||||
return "\"%s-%s-%d\"".formatted(
|
||||
ThumbnailService.ALGORITHM_VERSION, info.etag().replace("\"", ""), size);
|
||||
}
|
||||
|
||||
private String contentType(Path thumbnail) {
|
||||
return thumbnail.getFileName().toString().endsWith(".png") ? "image/png" : "image/jpeg";
|
||||
}
|
||||
|
||||
private boolean notModified(HttpServletRequest req, String etag) {
|
||||
String ifNoneMatch = req.getHeader("If-None-Match");
|
||||
return ifNoneMatch != null && ifNoneMatch.contains(info.etag());
|
||||
return ifNoneMatch != null && ifNoneMatch.contains(etag);
|
||||
}
|
||||
|
||||
public record ContentInfo(Path path, String mimeType, long size, long modifiedAt, String etag,
|
||||
|
||||
@@ -16,44 +16,60 @@ import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
/// 缩略图缓存服务。
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ThumbnailService {
|
||||
|
||||
private static final int SIZE = 256;
|
||||
/// 缩略图算法版本,算法或输出格式变化时递增,使旧缓存和浏览器缓存失效
|
||||
public static final String ALGORITHM_VERSION = "v2";
|
||||
|
||||
/// 允许的缩略图最小边长
|
||||
public static final int MIN_SIZE = 32;
|
||||
|
||||
/// 允许的缩略图最大边长
|
||||
public static final int MAX_SIZE = 512;
|
||||
|
||||
private static final double JPEG_QUALITY = 0.82;
|
||||
private static final long MAX_PIXELS = 50_000_000L;
|
||||
|
||||
private final FileStorageService storage;
|
||||
|
||||
public Path thumbnail(Path source, String mimeType) {
|
||||
/// 同一缩略图的并发生成任务,避免平铺列表同时请求同一文件时重复解码
|
||||
private final ConcurrentMap<String, CompletableFuture<Path>> generating = new ConcurrentHashMap<>();
|
||||
|
||||
/// 校验缩略图尺寸是否在允许范围内。
|
||||
public static void requireValidSize(int size) {
|
||||
if (size < MIN_SIZE || MAX_SIZE < size) {
|
||||
throw new TimiException(TimiCode.ARG_BAD, "缩略图尺寸必须在 " + MIN_SIZE + "-" + MAX_SIZE + " 之间");
|
||||
}
|
||||
}
|
||||
|
||||
/// 获取缩略图缓存路径,缓存不存在时生成。
|
||||
///
|
||||
/// @param source 源文件
|
||||
/// @param mimeType 源文件 MIME 类型
|
||||
/// @param size 缩略图最大边长
|
||||
/// @return 缩略图文件
|
||||
public Path thumbnail(Path source, String mimeType, int size) {
|
||||
requireValidSize(size);
|
||||
String format = outputFormat(mimeType);
|
||||
try {
|
||||
long modifiedAt = Files.getLastModifiedTime(source).toMillis();
|
||||
long size = Files.size(source);
|
||||
String key = sha256(source.toAbsolutePath() + "|" + modifiedAt + "|" + size + "|" + SIZE);
|
||||
Path target = storage.thumbnailPath().resolve(key + ".png");
|
||||
String key = cacheKey(source, size, format);
|
||||
Path target = storage.thumbnailPath().resolve(key + "." + format);
|
||||
if (Files.isRegularFile(target)) {
|
||||
return target;
|
||||
}
|
||||
Files.createDirectories(target.getParent());
|
||||
if (mimeType.startsWith("video/")) {
|
||||
Picture picture;
|
||||
try {
|
||||
picture = FrameGrab.getFrameAtSec(source.toFile(), 0);
|
||||
} catch (Exception e) {
|
||||
picture = FrameGrab.getFrameAtSec(source.toFile(), 1);
|
||||
}
|
||||
BufferedImage image = AWTUtil.toBufferedImage(picture);
|
||||
ImageIO.write(image, "png", target.toFile());
|
||||
} else {
|
||||
validatePixelCount(source);
|
||||
Thumbnails.of(source.toFile()).size(SIZE, SIZE).outputFormat("png").toFile(target.toFile());
|
||||
}
|
||||
return target;
|
||||
return generateOnce(key, target, source, mimeType, size, format);
|
||||
} catch (TimiException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
@@ -61,8 +77,137 @@ public class ThumbnailService {
|
||||
}
|
||||
}
|
||||
|
||||
/// 在完整解码前检查图片像素数,避免超大图片耗尽内存。
|
||||
private void validatePixelCount(Path source) throws IOException {
|
||||
private Path generateOnce(String key, Path target, Path source, String mimeType, int size, String format) {
|
||||
CompletableFuture<Path> future = new CompletableFuture<>();
|
||||
CompletableFuture<Path> running = generating.putIfAbsent(key, future);
|
||||
if (running != null) {
|
||||
return await(running);
|
||||
}
|
||||
try {
|
||||
if (Files.isRegularFile(target)) {
|
||||
future.complete(target);
|
||||
return target;
|
||||
}
|
||||
Path result = generate(source, mimeType, size, format, target);
|
||||
future.complete(result);
|
||||
return result;
|
||||
} catch (Throwable e) {
|
||||
future.completeExceptionally(e);
|
||||
if (e instanceof TimiException te) {
|
||||
throw te;
|
||||
}
|
||||
if (e instanceof RuntimeException re) {
|
||||
throw re;
|
||||
}
|
||||
if (e instanceof Error error) {
|
||||
throw error;
|
||||
}
|
||||
throw new TimiException(TimiCode.ERROR, "生成缩略图失败");
|
||||
} finally {
|
||||
generating.remove(key, future);
|
||||
}
|
||||
}
|
||||
|
||||
private Path await(CompletableFuture<Path> future) {
|
||||
try {
|
||||
return future.get();
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new TimiException(TimiCode.ERROR, "生成缩略图失败");
|
||||
} catch (ExecutionException e) {
|
||||
Throwable cause = e.getCause();
|
||||
if (cause instanceof TimiException te) {
|
||||
throw te;
|
||||
}
|
||||
if (cause instanceof RuntimeException re) {
|
||||
throw re;
|
||||
}
|
||||
if (cause instanceof Error error) {
|
||||
throw error;
|
||||
}
|
||||
throw new TimiException(TimiCode.ERROR, "生成缩略图失败");
|
||||
}
|
||||
}
|
||||
|
||||
private Path generate(Path source, String mimeType, int size, String format, Path target) throws IOException {
|
||||
Files.createDirectories(target.getParent());
|
||||
Path temp = Files.createTempFile(target.getParent(), "thumb-", "." + format);
|
||||
try {
|
||||
if (mimeType.startsWith("video/")) {
|
||||
BufferedImage frame = videoFrame(source);
|
||||
write(Thumbnails.of(frame), boundedSize(frame.getWidth(), frame.getHeight(), size), format, temp);
|
||||
} else {
|
||||
int[] dimensions = imageDimensions(source);
|
||||
write(Thumbnails.of(source.toFile()).useExifOrientation(true),
|
||||
boundedSize(dimensions[0], dimensions[1], size), format, temp);
|
||||
}
|
||||
move(temp, target);
|
||||
return target;
|
||||
} catch (TimiException e) {
|
||||
throw e;
|
||||
} catch (IOException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw new IOException("生成缩略图失败", e);
|
||||
} finally {
|
||||
Files.deleteIfExists(temp);
|
||||
}
|
||||
}
|
||||
|
||||
/// 小图不放大,避免生成模糊且更大的缩略图。
|
||||
private int boundedSize(int width, int height, int size) {
|
||||
return Math.min(size, Math.max(width, height));
|
||||
}
|
||||
|
||||
private void write(Thumbnails.Builder<?> builder, int size, String format, Path target) throws IOException {
|
||||
builder.size(size, size).outputFormat(format);
|
||||
if ("jpg".equals(format)) {
|
||||
builder.outputQuality(JPEG_QUALITY);
|
||||
}
|
||||
builder.toFile(target.toFile());
|
||||
}
|
||||
|
||||
private BufferedImage videoFrame(Path source) throws Exception {
|
||||
Picture picture;
|
||||
try {
|
||||
picture = FrameGrab.getFrameAtSec(source.toFile(), 0);
|
||||
} catch (Exception e) {
|
||||
picture = FrameGrab.getFrameAtSec(source.toFile(), 1);
|
||||
}
|
||||
if (picture == null) {
|
||||
throw new IOException("无法读取视频帧");
|
||||
}
|
||||
return AWTUtil.toBufferedImage(picture);
|
||||
}
|
||||
|
||||
/// 使用原子移动避免其他请求读到写了一半的缩略图。
|
||||
private void move(Path temp, Path target) throws IOException {
|
||||
try {
|
||||
Files.move(temp, target, StandardCopyOption.ATOMIC_MOVE);
|
||||
} catch (IOException e) {
|
||||
if (Files.isRegularFile(target)) {
|
||||
return;
|
||||
}
|
||||
Files.move(temp, target, StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
}
|
||||
|
||||
/// PNG/GIF 源图输出 PNG,其余输出 JPEG(视频帧也使用 JPEG)。
|
||||
private String outputFormat(String mimeType) {
|
||||
return switch (mimeType) {
|
||||
case "image/png", "image/gif" -> "png";
|
||||
default -> "jpg";
|
||||
};
|
||||
}
|
||||
|
||||
private String cacheKey(Path source, int size, String format) throws IOException {
|
||||
long modifiedAt = Files.getLastModifiedTime(source).toMillis();
|
||||
long fileSize = Files.size(source);
|
||||
return sha256(ALGORITHM_VERSION + "|" + source.toAbsolutePath() + "|" + modifiedAt + "|" + fileSize + "|" + size + "|" + format);
|
||||
}
|
||||
|
||||
/// 在完整解码前检查图片像素数,避免超大图片耗尽内存,并返回原始尺寸。
|
||||
private int[] imageDimensions(Path source) throws IOException {
|
||||
try (ImageInputStream input = ImageIO.createImageInputStream(source.toFile())) {
|
||||
if (input == null) {
|
||||
throw new IOException("无法读取图片");
|
||||
@@ -74,10 +219,12 @@ public class ThumbnailService {
|
||||
ImageReader reader = readers.next();
|
||||
try {
|
||||
reader.setInput(input, true, true);
|
||||
long pixels = (long) reader.getWidth(0) * reader.getHeight(0);
|
||||
if (MAX_PIXELS < pixels) {
|
||||
int width = reader.getWidth(0);
|
||||
int height = reader.getHeight(0);
|
||||
if (MAX_PIXELS < (long) width * height) {
|
||||
throw new TimiException(TimiCode.ARG_BAD, "图片像素过大");
|
||||
}
|
||||
return new int[]{width, height};
|
||||
} finally {
|
||||
reader.dispose();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.imyeyu.api.modules.system.util;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/// 文件缩略图预览类型判定。
|
||||
///
|
||||
/// 只包含当前缩略图生成链路实际支持的图片和视频类型,避免列表把不可预览的文件标记为可预览。
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-11-25
|
||||
public final class FilePreview {
|
||||
|
||||
private static final Set<String> MIME_TYPES = Set.of(
|
||||
"image/png", "image/jpeg", "image/gif", "image/bmp",
|
||||
"video/mp4", "video/quicktime", "video/webm"
|
||||
);
|
||||
|
||||
private FilePreview() {
|
||||
}
|
||||
|
||||
/// 是否为支持缩略图预览的类型。
|
||||
public static boolean supports(String mimeType) {
|
||||
return MIME_TYPES.contains(mimeType);
|
||||
}
|
||||
}
|
||||
@@ -7,10 +7,12 @@ import com.imyeyu.api.modules.user.entity.Permission;
|
||||
import com.imyeyu.api.modules.user.service.AuthorizationScopeService;
|
||||
import com.imyeyu.api.modules.user.service.PermissionService;
|
||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
||||
import com.imyeyu.api.modules.user.vo.permission.BatchCreateReq;
|
||||
import com.imyeyu.spring.annotation.AOPLog;
|
||||
import com.imyeyu.spring.bean.Page;
|
||||
import com.imyeyu.spring.bean.PageResult;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -21,12 +23,13 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 权限 SDK 控制器
|
||||
*
|
||||
* @author 夜雨
|
||||
* @since 2025-11-02 09:54
|
||||
*/
|
||||
/// 权限接口
|
||||
///
|
||||
/// 权限由系统代码定义,不支持创建和删除,仅提供查询与展示信息维护。
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2025-11-02 09:54
|
||||
@Tag(name = "用户-权限", description = "系统内置权限查询与展示信息维护接口")
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@@ -37,43 +40,27 @@ public class PermissionController {
|
||||
private final UserLoginService userLoginService;
|
||||
private final AuthorizationScopeService authorizationScopeService;
|
||||
|
||||
@Operation(summary = "分页查询权限", description = "分页查询系统内置权限。权限由代码定义,不支持创建和删除。")
|
||||
@RequireCorePermission(CorePermissionCode.PERMISSION_READ)
|
||||
@PostMapping("/list")
|
||||
public PageResult<Permission> list(@RequestBody Page<Permission> page) {
|
||||
return service.page(page);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询可授权权限", description = "查询当前用户在指定模块下可授予角色的权限。")
|
||||
@RequireCorePermission(CorePermissionCode.ROLE_PERMISSION_READ)
|
||||
@PostMapping("/grantable/list")
|
||||
public List<Permission> listGrantable(@RequestParam ModuleCode moduleCode) {
|
||||
public List<Permission> listGrantable(
|
||||
@Parameter(description = "模块代码", required = true)
|
||||
@RequestParam ModuleCode moduleCode) {
|
||||
return authorizationScopeService.listGrantablePermission(userLoginService.getRequireLoginUserId(), moduleCode);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequireCorePermission(CorePermissionCode.PERMISSION_READ)
|
||||
@PostMapping("/create")
|
||||
public void create(@RequestBody Permission permission) {
|
||||
service.create(permission);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequireCorePermission(CorePermissionCode.PERMISSION_CREATE)
|
||||
@PostMapping("/create/batch")
|
||||
public void createBatch(@RequestBody BatchCreateReq req) {
|
||||
service.create(req);
|
||||
}
|
||||
|
||||
@Operation(summary = "修改权限展示信息", description = "仅修改权限名称和说明;权限代码及内置属性由代码定义,不允许通过接口修改。")
|
||||
@AOPLog
|
||||
@RequireCorePermission(CorePermissionCode.PERMISSION_UPDATE)
|
||||
@PostMapping("/update")
|
||||
public void update(@RequestBody Permission permission) {
|
||||
service.update(permission);
|
||||
}
|
||||
|
||||
@AOPLog
|
||||
@RequireCorePermission(CorePermissionCode.PERMISSION_DELETE)
|
||||
@PostMapping("/delete")
|
||||
public void delete(@RequestParam("id") String id) {
|
||||
service.delete(id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.imyeyu.api.modules.user.entity.Permission;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
import com.imyeyu.api.bean.ModuleCode;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -18,4 +19,10 @@ public interface PermissionMapper extends BaseMapper<Permission, String> {
|
||||
List<Permission> selectByIdList(@Param("idList") List<String> idList);
|
||||
|
||||
List<Permission> selectByModuleCode(@Param("moduleCode") ModuleCode moduleCode);
|
||||
|
||||
/// 查询所有未删除权限的模块与代码,用于启动漂移检查
|
||||
///
|
||||
/// @return 权限列表,仅填充 moduleCode、code
|
||||
@Select("SELECT `module_code`, `code` FROM `permission` WHERE `deleted_at` IS NULL")
|
||||
List<Permission> selectActiveCodeList();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.imyeyu.api.modules.user.service;
|
||||
|
||||
import com.imyeyu.api.modules.user.entity.Permission;
|
||||
import com.imyeyu.api.modules.user.vo.permission.BatchCreateReq;
|
||||
import com.imyeyu.api.bean.ModuleCode;
|
||||
import com.imyeyu.spring.service.BaseService;
|
||||
|
||||
@@ -13,11 +12,6 @@ import java.util.List;
|
||||
/// @since 2026-05-13 14:46
|
||||
public interface PermissionService extends BaseService<Permission, String> {
|
||||
|
||||
/// 批量创建权限
|
||||
///
|
||||
/// @param req 批量创建请求
|
||||
void create(BatchCreateReq req);
|
||||
|
||||
/// 查询角色权限
|
||||
///
|
||||
/// @param roleId 角色 ID
|
||||
|
||||
+10
-31
@@ -2,27 +2,20 @@ package com.imyeyu.api.modules.user.service.implement;
|
||||
|
||||
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
||||
import com.imyeyu.api.bean.ModuleCode;
|
||||
import com.imyeyu.api.modules.common.mapper.MultilingualMapper;
|
||||
import com.imyeyu.api.modules.common.service.MultilingualService;
|
||||
import com.imyeyu.api.modules.user.bean.AuthOwnerType;
|
||||
import com.imyeyu.api.modules.user.entity.Permission;
|
||||
import com.imyeyu.api.modules.user.mapper.PermissionMapper;
|
||||
import com.imyeyu.api.modules.user.mapper.RolePermissionMapper;
|
||||
import com.imyeyu.api.modules.user.service.PermissionService;
|
||||
import com.imyeyu.api.modules.user.vo.permission.BatchCreateReq;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.lang.message.MessageResolver;
|
||||
import com.imyeyu.spring.TimiSpring;
|
||||
import com.imyeyu.spring.mapper.BaseMapper;
|
||||
import com.imyeyu.spring.service.AbstractEntityService;
|
||||
import com.imyeyu.utils.Time;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/// 权限服务实现
|
||||
///
|
||||
@@ -35,9 +28,7 @@ public class PermissionServiceImplement extends AbstractEntityService<Permission
|
||||
private final PermissionMapper mapper;
|
||||
private final RolePermissionMapper rolePermissionMapper;
|
||||
|
||||
private final MultilingualMapper multilingualMapper;
|
||||
private final MultilingualService multilingualService;
|
||||
private final MessageResolver messageResolver;
|
||||
|
||||
@Override
|
||||
protected BaseMapper<Permission, String> mapper() {
|
||||
@@ -52,31 +43,19 @@ public class PermissionServiceImplement extends AbstractEntityService<Permission
|
||||
super.create(permission);
|
||||
}
|
||||
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void create(BatchCreateReq req) {
|
||||
if (TimiJava.isEmpty(req.getTypes())) {
|
||||
return;
|
||||
}
|
||||
List<Permission> permissionList = new ArrayList<>();
|
||||
for (BatchCreateReq.Type type : req.getTypes()) {
|
||||
Permission permission = new Permission();
|
||||
permission.setId(UUID.randomUUID().toString());
|
||||
permission.setModuleCode(req.getModuleCode());
|
||||
permission.setCode(req.getPrefixCode() + "_" + type.name());
|
||||
permission.setName(req.getPrefixName() + messageResolver.resolve(type.name().toLowerCase(), null, TimiSpring.getLanguage()));
|
||||
fillPermissionDefault(permission);
|
||||
permission.setCreatedAt(Time.now());
|
||||
permissionList.add(permission);
|
||||
}
|
||||
for (Permission permission : permissionList) {
|
||||
super.create(permission);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
||||
@Override
|
||||
public void update(Permission permission) {
|
||||
// 权限代码及内置属性由代码定义维护,接口只允许修改名称和说明
|
||||
permission.setModuleCode(null);
|
||||
permission.setCode(null);
|
||||
permission.setBuiltin(null);
|
||||
permission.setProtectedPermission(null);
|
||||
permission.setOwnerType(null);
|
||||
permission.setOwnerId(null);
|
||||
permission.setCreatedBy(null);
|
||||
permission.setCreatedAt(null);
|
||||
permission.setDeletedAt(null);
|
||||
permission.setNameLangId(multilingualService.createIfDifferent(permission.getNameLangId(), permission.getName()));
|
||||
mapper.updateSelective(permission);
|
||||
}
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.imyeyu.api.modules.user.vo.permission;
|
||||
|
||||
import com.imyeyu.api.bean.ModuleCode;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 批量创建权限请求
|
||||
*
|
||||
* @author 夜雨
|
||||
* @since 2025-11-18 16:49
|
||||
*/
|
||||
@Data
|
||||
public class BatchCreateReq {
|
||||
|
||||
private ModuleCode moduleCode;
|
||||
|
||||
/**
|
||||
* 权限类型枚举
|
||||
*
|
||||
* @author 夜雨
|
||||
* @since 2025-11-18 16:50
|
||||
*/
|
||||
public enum Type {
|
||||
|
||||
CREATE,
|
||||
|
||||
READ,
|
||||
|
||||
UPDATE,
|
||||
|
||||
DELETE
|
||||
}
|
||||
|
||||
private String prefixCode;
|
||||
|
||||
private String prefixName;
|
||||
|
||||
private Type[] types;
|
||||
}
|
||||
@@ -34,12 +34,16 @@ import com.imyeyu.api.modules.user.service.UserService;
|
||||
import com.imyeyu.java.TimiJava;
|
||||
import com.imyeyu.utils.Text;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -48,10 +52,14 @@ import java.util.Map;
|
||||
* @author 夜雨
|
||||
* @since 2026-06-05 15:45
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class InitBuiltinUser implements ApplicationRunner {
|
||||
|
||||
@Value("${spring.profiles.active:prod}")
|
||||
private String activeProfile;
|
||||
|
||||
private final RoleService roleService;
|
||||
private final UserService userService;
|
||||
private final LoggerService loggerService;
|
||||
@@ -77,6 +85,7 @@ public class InitBuiltinUser implements ApplicationRunner {
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
// 先同步所有内建权限和角色,再补齐继承与默认授权关系
|
||||
Map<String, Permission> permissionMap = initBuiltinPermissionMap();
|
||||
checkBuiltinPermissionDrift(permissionMap);
|
||||
Map<String, Role> roleMap = initBuiltinRoleMap();
|
||||
bindBuiltinRolePermissionInherit(roleMap);
|
||||
bindBuiltinRoleParent(roleMap);
|
||||
@@ -139,6 +148,10 @@ public class InitBuiltinUser implements ApplicationRunner {
|
||||
fillBuiltinPermission(permission, item);
|
||||
permissionService.create(permission);
|
||||
permission = permissionMapper.selectByExample(example);
|
||||
if (permission == null) {
|
||||
String key = BuiltinAuthRegistry.toPermissionKey(item.getModuleCode(), item.getValue());
|
||||
throw new IllegalStateException("内建权限初始化失败:" + key);
|
||||
}
|
||||
} else {
|
||||
fillBuiltinPermission(permission, item);
|
||||
permissionMapper.updateSelective(permission);
|
||||
@@ -148,6 +161,35 @@ public class InitBuiltinUser implements ApplicationRunner {
|
||||
return permissionMap;
|
||||
}
|
||||
|
||||
/// 检查数据库中存在但未在注册中心定义的权限
|
||||
///
|
||||
/// 生产环境仅告警,其他环境阻止启动,避免开发阶段出现代码与数据库漂移
|
||||
///
|
||||
/// @param permissionMap 已同步的内建权限映射
|
||||
private void checkBuiltinPermissionDrift(Map<String, Permission> permissionMap) {
|
||||
List<String> staleKeys = permissionMapper.selectActiveCodeList().stream()
|
||||
.map(item -> BuiltinAuthRegistry.toPermissionKey(item.getModuleCode(), item.getCode()))
|
||||
.filter(key -> !permissionMap.containsKey(key))
|
||||
.sorted()
|
||||
.toList();
|
||||
if (staleKeys.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
String message = "检测到未在 BuiltinAuthRegistry 中注册的权限:%s".formatted(String.join(", ", staleKeys));
|
||||
if (isProductionProfile()) {
|
||||
log.warn("{};已跳过自动删除,请确认是否漏写 Flyway 迁移", message);
|
||||
return;
|
||||
}
|
||||
throw new IllegalStateException(message + ";请补充注册定义或通过 Flyway 迁移移除");
|
||||
}
|
||||
|
||||
/// @return true 为生产环境
|
||||
private boolean isProductionProfile() {
|
||||
return Arrays.stream(activeProfile.split(","))
|
||||
.map(String::trim)
|
||||
.anyMatch(profile -> profile.startsWith("prod"));
|
||||
}
|
||||
|
||||
/// 按内建定义补齐角色表,不存在才创建
|
||||
///
|
||||
/// @return 模块加角色代码到角色实体的映射
|
||||
|
||||
@@ -341,6 +341,10 @@ public class MultilingualFieldBinder {
|
||||
}
|
||||
|
||||
private boolean isSimpleValueType(Class<?> clazz) {
|
||||
// 泛型字段在反射中表现为 Object,实际值仍需按运行时类型继续遍历
|
||||
if (Object.class == clazz) {
|
||||
return false;
|
||||
}
|
||||
if (clazz.isPrimitive() || clazz.isEnum() || clazz.isAnnotation()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.imyeyu.api.util;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.core.MethodParameter;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.server.ServerHttpRequest;
|
||||
@@ -14,11 +16,15 @@ import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
|
||||
/**
|
||||
* 统一处理响应中的多语言字段回填
|
||||
*
|
||||
* <p>必须在全局返回包装处理器之前执行,否则响应体已被包装为 TimiResponse,
|
||||
* 其 {@code data} 字段声明为泛型 {@code T}(反射类型为 Object),无法继续向下遍历。</p>
|
||||
*
|
||||
* @author 夜雨
|
||||
* @since 2026-07-17 00:00
|
||||
*/
|
||||
@Component
|
||||
@RestControllerAdvice
|
||||
@Order(Ordered.HIGHEST_PRECEDENCE)
|
||||
@RequiredArgsConstructor
|
||||
public class MultilingualResponseBodyAdvice implements ResponseBodyAdvice<Object> {
|
||||
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
-- 权限由系统代码硬约束,移除已废弃的权限创建、删除权限及其授权关系
|
||||
|
||||
UPDATE `role_permission` role_permission
|
||||
JOIN `permission` permission ON permission.`id` = role_permission.`permission_id`
|
||||
SET role_permission.`deleted_at` = UNIX_TIMESTAMP() * 1000
|
||||
WHERE permission.`module_code` = 'CORE'
|
||||
AND permission.`code` IN ('PERMISSION:CREATE', 'PERMISSION:DELETE')
|
||||
AND role_permission.`deleted_at` IS NULL;
|
||||
|
||||
UPDATE `role_permission_delegation` delegation
|
||||
JOIN `permission` permission ON permission.`id` = delegation.`permission_id`
|
||||
SET delegation.`deleted_at` = UNIX_TIMESTAMP() * 1000
|
||||
WHERE permission.`module_code` = 'CORE'
|
||||
AND permission.`code` IN ('PERMISSION:CREATE', 'PERMISSION:DELETE')
|
||||
AND delegation.`deleted_at` IS NULL;
|
||||
|
||||
UPDATE `permission`
|
||||
SET `deleted_at` = UNIX_TIMESTAMP() * 1000
|
||||
WHERE `module_code` = 'CORE'
|
||||
AND `code` IN ('PERMISSION:CREATE', 'PERMISSION:DELETE')
|
||||
AND `deleted_at` IS NULL;
|
||||
@@ -0,0 +1,39 @@
|
||||
-- 清理已从 BuiltinAuthRegistry 移除的历史权限及其授权关系
|
||||
-- ROLE_RELATION:* 已由 ROLE_PERMISSION_INHERIT:* 取代
|
||||
-- STORE/CUSTOMER/EVENT_RECORD:EXPORT 已由 DATA_EXPORT 取代
|
||||
-- SETTING:CREATE/DELETE 功能已移除
|
||||
|
||||
UPDATE `role_permission` role_permission
|
||||
JOIN `permission` permission ON permission.`id` = role_permission.`permission_id`
|
||||
SET role_permission.`deleted_at` = UNIX_TIMESTAMP() * 1000
|
||||
WHERE role_permission.`deleted_at` IS NULL
|
||||
AND (
|
||||
(permission.`module_code` = 'CORE'
|
||||
AND permission.`code` IN ('ROLE_RELATION:CREATE', 'ROLE_RELATION:READ', 'ROLE_RELATION:DELETE',
|
||||
'SETTING:CREATE', 'SETTING:DELETE'))
|
||||
OR (permission.`module_code` = 'GAO'
|
||||
AND permission.`code` IN ('CUSTOMER:EXPORT', 'EVENT_RECORD:EXPORT', 'STORE:EXPORT'))
|
||||
);
|
||||
|
||||
UPDATE `role_permission_delegation` delegation
|
||||
JOIN `permission` permission ON permission.`id` = delegation.`permission_id`
|
||||
SET delegation.`deleted_at` = UNIX_TIMESTAMP() * 1000
|
||||
WHERE delegation.`deleted_at` IS NULL
|
||||
AND (
|
||||
(permission.`module_code` = 'CORE'
|
||||
AND permission.`code` IN ('ROLE_RELATION:CREATE', 'ROLE_RELATION:READ', 'ROLE_RELATION:DELETE',
|
||||
'SETTING:CREATE', 'SETTING:DELETE'))
|
||||
OR (permission.`module_code` = 'GAO'
|
||||
AND permission.`code` IN ('CUSTOMER:EXPORT', 'EVENT_RECORD:EXPORT', 'STORE:EXPORT'))
|
||||
);
|
||||
|
||||
UPDATE `permission`
|
||||
SET `deleted_at` = UNIX_TIMESTAMP() * 1000
|
||||
WHERE `deleted_at` IS NULL
|
||||
AND (
|
||||
(`module_code` = 'CORE'
|
||||
AND `code` IN ('ROLE_RELATION:CREATE', 'ROLE_RELATION:READ', 'ROLE_RELATION:DELETE',
|
||||
'SETTING:CREATE', 'SETTING:DELETE'))
|
||||
OR (`module_code` = 'GAO'
|
||||
AND `code` IN ('CUSTOMER:EXPORT', 'EVENT_RECORD:EXPORT', 'STORE:EXPORT'))
|
||||
);
|
||||
@@ -8,6 +8,8 @@ import org.junit.jupiter.api.io.TempDir;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.mock.web.MockHttpServletResponse;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
@@ -19,8 +21,11 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/// 文件内容服务测试。
|
||||
class FileContentServiceTest {
|
||||
@@ -58,7 +63,36 @@ class FileContentServiceTest {
|
||||
Files.writeString(temp.resolve("a.html"), "<script>alert(1)</script>", StandardCharsets.UTF_8);
|
||||
|
||||
assertThrows(TimiException.class, () -> service.preview(new MockHttpServletRequest(),
|
||||
new MockHttpServletResponse(), "/a.html"));
|
||||
new MockHttpServletResponse(), "/a.html", 256, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsPdfPreview() throws IOException {
|
||||
Files.writeString(temp.resolve("a.pdf"), "%PDF-1.4", StandardCharsets.UTF_8);
|
||||
|
||||
assertThrows(TimiException.class, () -> service.preview(new MockHttpServletRequest(),
|
||||
new MockHttpServletResponse(), "/a.pdf", 256, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void previewsImageWithRequestedSize() throws Exception {
|
||||
Path source = temp.resolve("a.png");
|
||||
ImageIO.write(new BufferedImage(8, 8, BufferedImage.TYPE_INT_RGB), "png", source.toFile());
|
||||
Path thumbnail = temp.resolve("thumb.png");
|
||||
Files.write(thumbnail, new byte[]{1, 2, 3});
|
||||
|
||||
ThumbnailService thumbnailService = mock(ThumbnailService.class);
|
||||
when(thumbnailService.thumbnail(any(), eq("image/png"), eq(128))).thenReturn(thumbnail);
|
||||
FileContentService service = new FileContentService(FileTestSupport.storage(temp, Map.of()),
|
||||
thumbnailService, resourceHandler);
|
||||
MockHttpServletResponse resp = new MockHttpServletResponse();
|
||||
|
||||
service.preview(new MockHttpServletRequest(), resp, "/a.png", 128, "etag");
|
||||
|
||||
assertEquals("image/png", resp.getContentType());
|
||||
assertEquals(3, resp.getContentAsByteArray().length);
|
||||
assertTrue(resp.getHeader("ETag").contains("-128"));
|
||||
assertTrue(resp.getHeader("Cache-Control").contains("immutable"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.imyeyu.api.modules.system.service;
|
||||
|
||||
import com.imyeyu.java.bean.timi.TimiException;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
/// 缩略图缓存服务测试。
|
||||
class ThumbnailServiceTest {
|
||||
|
||||
@TempDir
|
||||
Path temp;
|
||||
|
||||
private ThumbnailService service;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() throws Exception {
|
||||
service = new ThumbnailService(FileTestSupport.storage(temp, Map.of()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void generatesPngForPngSource() throws Exception {
|
||||
Path source = temp.resolve("a.png");
|
||||
ImageIO.write(new BufferedImage(100, 50, BufferedImage.TYPE_INT_RGB), "png", source.toFile());
|
||||
|
||||
Path thumbnail = service.thumbnail(source, "image/png", 32);
|
||||
|
||||
assertTrue(Files.isRegularFile(thumbnail));
|
||||
assertTrue(thumbnail.getFileName().toString().endsWith(".png"));
|
||||
BufferedImage image = ImageIO.read(thumbnail.toFile());
|
||||
assertEquals(32, image.getWidth());
|
||||
assertEquals(16, image.getHeight());
|
||||
}
|
||||
|
||||
@Test
|
||||
void generatesJpegForJpegSource() throws Exception {
|
||||
Path source = temp.resolve("a.jpg");
|
||||
ImageIO.write(new BufferedImage(100, 50, BufferedImage.TYPE_INT_RGB), "jpg", source.toFile());
|
||||
|
||||
Path thumbnail = service.thumbnail(source, "image/jpeg", 64);
|
||||
|
||||
assertTrue(Files.isRegularFile(thumbnail));
|
||||
assertTrue(thumbnail.getFileName().toString().endsWith(".jpg"));
|
||||
BufferedImage image = ImageIO.read(thumbnail.toFile());
|
||||
assertEquals(64, image.getWidth());
|
||||
assertEquals(32, image.getHeight());
|
||||
}
|
||||
|
||||
@Test
|
||||
void reusesCachedThumbnail() throws Exception {
|
||||
Path source = temp.resolve("a.png");
|
||||
ImageIO.write(new BufferedImage(100, 50, BufferedImage.TYPE_INT_RGB), "png", source.toFile());
|
||||
|
||||
Path first = service.thumbnail(source, "image/png", 64);
|
||||
Path second = service.thumbnail(source, "image/png", 64);
|
||||
|
||||
assertEquals(first, second);
|
||||
}
|
||||
|
||||
@Test
|
||||
void cachesEachSizeSeparately() throws Exception {
|
||||
Path source = temp.resolve("a.png");
|
||||
ImageIO.write(new BufferedImage(100, 50, BufferedImage.TYPE_INT_RGB), "png", source.toFile());
|
||||
|
||||
assertNotEquals(service.thumbnail(source, "image/png", 64),
|
||||
service.thumbnail(source, "image/png", 128));
|
||||
}
|
||||
|
||||
@Test
|
||||
void doesNotUpscaleSmallImage() throws Exception {
|
||||
Path source = temp.resolve("small.png");
|
||||
ImageIO.write(new BufferedImage(20, 10, BufferedImage.TYPE_INT_RGB), "png", source.toFile());
|
||||
|
||||
Path thumbnail = service.thumbnail(source, "image/png", 256);
|
||||
|
||||
BufferedImage image = ImageIO.read(thumbnail.toFile());
|
||||
assertEquals(20, image.getWidth());
|
||||
assertEquals(10, image.getHeight());
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsInvalidSize() {
|
||||
assertThrows(TimiException.class, () -> service.thumbnail(temp.resolve("a.png"), "image/png", 8));
|
||||
assertThrows(TimiException.class, () -> service.thumbnail(temp.resolve("a.png"), "image/png", 1024));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.imyeyu.api.util;
|
||||
|
||||
import com.imyeyu.api.modules.common.entity.Multilingual;
|
||||
import com.imyeyu.api.modules.common.entity.Tag;
|
||||
import com.imyeyu.api.modules.common.service.MultilingualService;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.mock.web.MockHttpServletRequest;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/// 响应多语言字段回填测试
|
||||
///
|
||||
/// @author 夜雨
|
||||
/// @since 2026-11-26
|
||||
class MultilingualFieldBinderTest {
|
||||
|
||||
@AfterEach
|
||||
void resetRequestContext() {
|
||||
RequestContextHolder.resetRequestAttributes();
|
||||
}
|
||||
|
||||
/// 泛型包装对象的 data 字段在反射中表现为 Object,仍需继续向下回填
|
||||
@Test
|
||||
void bindsMultilingualFieldThroughObjectTypedWrapper() {
|
||||
MockHttpServletRequest request = new MockHttpServletRequest();
|
||||
request.addHeader("Accept-Language", "zh-CN");
|
||||
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request));
|
||||
|
||||
MultilingualService service = mock(MultilingualService.class);
|
||||
Multilingual multilingual = new Multilingual();
|
||||
multilingual.setId("lang-1");
|
||||
multilingual.setZhCN("标签");
|
||||
when(service.listByIdList(List.of("lang-1"))).thenReturn(List.of(multilingual));
|
||||
|
||||
Tag tag = new Tag();
|
||||
tag.setNameLangId("lang-1");
|
||||
|
||||
MultilingualFieldBinder binder = new MultilingualFieldBinder(service);
|
||||
binder.bind(new ObjectDataWrapper(tag));
|
||||
|
||||
assertEquals("标签", tag.getName());
|
||||
}
|
||||
|
||||
/// 模拟 TimiResponse 等泛型包装对象
|
||||
private record ObjectDataWrapper(Object data) {
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user