Compare commits
19
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
619369104c | ||
|
|
4f1408b9d0 | ||
|
|
029eea70cc | ||
|
|
22b1e65385 | ||
|
|
2170c48763 | ||
|
|
c2d1c48aae | ||
|
|
e14958c643 | ||
|
|
da288338cd | ||
|
|
ea430f2468 | ||
|
|
f76f79744a | ||
|
|
19daaff907 | ||
|
|
db94d8f932 | ||
|
|
53618fe362 | ||
|
|
523edffc4e | ||
|
|
c7ddb1a8b0 | ||
|
|
45c9fc814a | ||
|
|
407dc13ac4 | ||
|
|
0c06bf16c2 | ||
|
|
1db39e77d3 |
@@ -1,2 +0,0 @@
|
|||||||
# Shell 脚本使用 LF,避免 Windows 下 CRLF 导致执行失败
|
|
||||||
*.sh text eol=lf
|
|
||||||
@@ -46,11 +46,6 @@ jobs:
|
|||||||
<username>${{ vars.TIMI_NEXUS_USERNAME }}</username>
|
<username>${{ vars.TIMI_NEXUS_USERNAME }}</username>
|
||||||
<password>${{ vars.TIMI_NEXUS_PASSWORD }}</password>
|
<password>${{ vars.TIMI_NEXUS_PASSWORD }}</password>
|
||||||
</server>
|
</server>
|
||||||
<server>
|
|
||||||
<id>e2ins_nexus</id>
|
|
||||||
<username>${{ vars.E2INS_NEXUS_USERNAME }}</username>
|
|
||||||
<password>${{ vars.E2INS_NEXUS_PASSWORD }}</password>
|
|
||||||
</server>
|
|
||||||
</servers>
|
</servers>
|
||||||
</settings>
|
</settings>
|
||||||
EOF
|
EOF
|
||||||
|
|||||||
@@ -4,11 +4,6 @@
|
|||||||
/target
|
/target
|
||||||
/temp
|
/temp
|
||||||
/AGENTS.md
|
/AGENTS.md
|
||||||
/.workbuddy
|
|
||||||
|
|
||||||
# OpenAPI 本地导出(scripts/export-openapi.*)
|
|
||||||
/docs/openapi.local.yaml
|
|
||||||
/docs/openapi.local.json
|
|
||||||
|
|
||||||
multilingualField/
|
multilingualField/
|
||||||
!.mvn/wrapper/maven-wrapper.jar
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
@@ -46,9 +41,5 @@ build/
|
|||||||
### VS Code ###
|
### VS Code ###
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
### Python ###
|
|
||||||
__pycache__/
|
|
||||||
*.py[cod]
|
|
||||||
|
|
||||||
### Mac OS ###
|
### Mac OS ###
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|||||||
Generated
+9
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="SqlDialectMappings">
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/resources/db/migration/timiserver/V1__init_schema.sql" dialect="MariaDB" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/resources/db/migration/timiserver/V2__init_system_data.sql" dialect="GenericSQL" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/resources/mapper/timi-server/gao/GaoEventRecordMapper.xml" dialect="MariaDB" />
|
||||||
|
<file url="PROJECT" dialect="MariaDB" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
/cache
|
||||||
|
/project.local.yml
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
TimiServerAPI 是一个基于 Spring Boot 的高耦合业务后端服务,代码位于 src/main/java/com/imyeyu/api,下分多个业务模块,如 blog、common、gitea、forevermc、journal、minecraft、music、system 等。项目使用多数据源 MySQL(timiserver、gitea、forevermc)、MongoDB、Redis、MyBatis,并引入 Flyway 做数据库迁移。运行环境为 Windows,JDK 21。
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
项目约定:全部沟通、注释、文档使用中文;Java 使用 tab 缩进;注释要求符合 javadoc;优先使用官方 API,不随意引入外部依赖;字符串优先用 formatted(),长动态字符串用 StringBuilder;优先用代码级工具做精确修改;避免盲目通读大文件,先缩小目录和符号范围。
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
Windows / PowerShell 常用命令:`Get-ChildItem -Force` 查看目录,`rg --files` 列文件,`rg -n "PATTERN" PATH` 搜索文本,`mvn -q -DskipTests compile` 做基础编译验证,`git diff -- PATH` 查看改动。配置文件主要在 `src/main/resources`,Java 源码在 `src/main/java`。
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
完成任务后,优先做最小范围验证。Java 侧先尝试 `mvn -q -DskipTests compile`;如果失败,区分是本次改动导致还是项目已有编译问题。不要回滚用户已有改动,不要做破坏性 git 操作。多数据源场景要特别检查 `@Primary`、`@Qualifier` 和自动装配框架(如 Flyway)的绑定关系。
|
||||||
@@ -0,0 +1,154 @@
|
|||||||
|
# the name by which the project can be referenced within Serena
|
||||||
|
project_name: "TimiServerAPI"
|
||||||
|
|
||||||
|
|
||||||
|
# list of languages for which language servers are started; choose from:
|
||||||
|
# al bash clojure cpp csharp
|
||||||
|
# csharp_omnisharp dart elixir elm erlang
|
||||||
|
# fortran fsharp go groovy haskell
|
||||||
|
# haxe java julia kotlin lua
|
||||||
|
# markdown
|
||||||
|
# matlab nix pascal perl php
|
||||||
|
# php_phpactor powershell python python_jedi r
|
||||||
|
# rego ruby ruby_solargraph rust scala
|
||||||
|
# swift terraform toml typescript typescript_vts
|
||||||
|
# vue yaml zig
|
||||||
|
# (This list may be outdated. For the current list, see values of Language enum here:
|
||||||
|
# https://github.com/oraios/serena/blob/main/src/solidlsp/ls_config.py
|
||||||
|
# For some languages, there are alternative language servers, e.g. csharp_omnisharp, ruby_solargraph.)
|
||||||
|
# Note:
|
||||||
|
# - For C, use cpp
|
||||||
|
# - For JavaScript, use typescript
|
||||||
|
# - For Free Pascal/Lazarus, use pascal
|
||||||
|
# Special requirements:
|
||||||
|
# Some languages require additional setup/installations.
|
||||||
|
# See here for details: https://oraios.github.io/serena/01-about/020_programming-languages.html#language-servers
|
||||||
|
# When using multiple languages, the first language server that supports a given file will be used for that file.
|
||||||
|
# The first language is the default language and the respective language server will be used as a fallback.
|
||||||
|
# Note that when using the JetBrains backend, language servers are not used and this list is correspondingly ignored.
|
||||||
|
languages:
|
||||||
|
- java
|
||||||
|
|
||||||
|
# the encoding used by text files in the project
|
||||||
|
# For a list of possible encodings, see https://docs.python.org/3.11/library/codecs.html#standard-encodings
|
||||||
|
encoding: "utf-8"
|
||||||
|
|
||||||
|
# line ending convention to use when writing source files.
|
||||||
|
# Possible values: unset (use global setting), "lf", "crlf", or "native" (platform default)
|
||||||
|
# This does not affect Serena's own files (e.g. memories and configuration files), which always use native line endings.
|
||||||
|
line_ending:
|
||||||
|
|
||||||
|
# The language backend to use for this project.
|
||||||
|
# If not set, the global setting from serena_config.yml is used.
|
||||||
|
# Valid values: LSP, JetBrains
|
||||||
|
# Note: the backend is fixed at startup. If a project with a different backend
|
||||||
|
# is activated post-init, an error will be returned.
|
||||||
|
language_backend:
|
||||||
|
|
||||||
|
# whether to use project's .gitignore files to ignore files
|
||||||
|
ignore_all_files_in_gitignore: true
|
||||||
|
|
||||||
|
# advanced configuration option allowing to configure language server-specific options.
|
||||||
|
# Maps the language key to the options.
|
||||||
|
# Have a look at the docstring of the constructors of the LS implementations within solidlsp (e.g., for C# or PHP) to see which options are available.
|
||||||
|
# No documentation on options means no options are available.
|
||||||
|
ls_specific_settings: {}
|
||||||
|
|
||||||
|
# list of additional paths to ignore in this project.
|
||||||
|
# Same syntax as gitignore, so you can use * and **.
|
||||||
|
# Note: global ignored_paths from serena_config.yml are also applied additively.
|
||||||
|
ignored_paths: []
|
||||||
|
|
||||||
|
# whether the project is in read-only mode
|
||||||
|
# If set to true, all editing tools will be disabled and attempts to use them will result in an error
|
||||||
|
# Added on 2025-04-18
|
||||||
|
read_only: false
|
||||||
|
|
||||||
|
# list of tool names to exclude.
|
||||||
|
# This extends the existing exclusions (e.g. from the global configuration)
|
||||||
|
#
|
||||||
|
# Below is the complete list of tools for convenience.
|
||||||
|
# To make sure you have the latest list of tools, and to view their descriptions,
|
||||||
|
# execute `uv run scripts/print_tool_overview.py`.
|
||||||
|
#
|
||||||
|
# * `activate_project`: Activates a project based on the project name or path.
|
||||||
|
# * `check_onboarding_performed`: Checks whether project onboarding was already performed.
|
||||||
|
# * `create_text_file`: Creates/overwrites a file in the project directory.
|
||||||
|
# * `delete_memory`: Delete a memory file. Should only happen if a user asks for it explicitly,
|
||||||
|
# for example by saying that the information retrieved from a memory file is no longer correct
|
||||||
|
# or no longer relevant for the project.
|
||||||
|
# * `edit_memory`: Replaces content matching a regular expression in a memory.
|
||||||
|
# * `execute_shell_command`: Executes a shell command.
|
||||||
|
# * `find_file`: Finds files in the given relative paths
|
||||||
|
# * `find_referencing_symbols`: Finds symbols that reference the given symbol using the language server backend
|
||||||
|
# * `find_symbol`: Performs a global (or local) search using the language server backend.
|
||||||
|
# * `get_current_config`: Prints the current configuration of the agent, including the active and available projects, tools, contexts, and modes.
|
||||||
|
# * `get_symbols_overview`: Gets an overview of the top-level symbols defined in a given file.
|
||||||
|
# * `initial_instructions`: Provides instructions Serena usage (i.e. the 'Serena Instructions Manual')
|
||||||
|
# for clients that do not read the initial instructions when the MCP server is connected.
|
||||||
|
# * `insert_after_symbol`: Inserts content after the end of the definition of a given symbol.
|
||||||
|
# * `insert_before_symbol`: Inserts content before the beginning of the definition of a given symbol.
|
||||||
|
# * `list_dir`: Lists files and directories in the given directory (optionally with recursion).
|
||||||
|
# * `list_memories`: List available memories. Any memory can be read using the `read_memory` tool.
|
||||||
|
# * `onboarding`: Performs onboarding (identifying the project structure and essential tasks, e.g. for testing or building).
|
||||||
|
# * `read_file`: Reads a file within the project directory.
|
||||||
|
# * `read_memory`: Read the content of a memory file. This tool should only be used if the information
|
||||||
|
# is relevant to the current task. You can infer whether the information
|
||||||
|
# is relevant from the memory file name.
|
||||||
|
# You should not read the same memory file multiple times in the same conversation.
|
||||||
|
# * `rename_memory`: Renames or moves a memory. Moving between project and global scope is supported
|
||||||
|
# (e.g., renaming "global/foo" to "bar" moves it from global to project scope).
|
||||||
|
# * `rename_symbol`: Renames a symbol throughout the codebase using language server refactoring capabilities.
|
||||||
|
# For JB, we use a separate tool.
|
||||||
|
# * `replace_content`: Replaces content in a file (optionally using regular expressions).
|
||||||
|
# * `replace_symbol_body`: Replaces the full definition of a symbol using the language server backend.
|
||||||
|
# * `safe_delete_symbol`:
|
||||||
|
# * `search_for_pattern`: Performs a search for a pattern in the project.
|
||||||
|
# * `write_memory`: Write some information (utf-8-encoded) about this project that can be useful for future tasks to a memory in md format.
|
||||||
|
# The memory name should be meaningful.
|
||||||
|
excluded_tools: []
|
||||||
|
|
||||||
|
# list of tools to include that would otherwise be disabled (particularly optional tools that are disabled by default).
|
||||||
|
# This extends the existing inclusions (e.g. from the global configuration).
|
||||||
|
included_optional_tools: []
|
||||||
|
|
||||||
|
# fixed set of tools to use as the base tool set (if non-empty), replacing Serena's default set of tools.
|
||||||
|
# This cannot be combined with non-empty excluded_tools or included_optional_tools.
|
||||||
|
fixed_tools: []
|
||||||
|
|
||||||
|
# list of mode names to that are always to be included in the set of active modes
|
||||||
|
# The full set of modes to be activated is base_modes + default_modes.
|
||||||
|
# If the setting is undefined, the base_modes from the global configuration (serena_config.yml) apply.
|
||||||
|
# Otherwise, this setting overrides the global configuration.
|
||||||
|
# Set this to [] to disable base modes for this project.
|
||||||
|
# Set this to a list of mode names to always include the respective modes for this project.
|
||||||
|
base_modes:
|
||||||
|
|
||||||
|
# list of mode names that are to be activated by default.
|
||||||
|
# The full set of modes to be activated is base_modes + default_modes.
|
||||||
|
# If the setting is undefined, the default_modes from the global configuration (serena_config.yml) apply.
|
||||||
|
# Otherwise, this overrides the setting from the global configuration (serena_config.yml).
|
||||||
|
# This setting can, in turn, be overridden by CLI parameters (--mode).
|
||||||
|
default_modes:
|
||||||
|
|
||||||
|
# initial prompt for the project. It will always be given to the LLM upon activating the project
|
||||||
|
# (contrary to the memories, which are loaded on demand).
|
||||||
|
initial_prompt: ""
|
||||||
|
|
||||||
|
# time budget (seconds) per tool call for the retrieval of additional symbol information
|
||||||
|
# such as docstrings or parameter information.
|
||||||
|
# This overrides the corresponding setting in the global configuration; see the documentation there.
|
||||||
|
# If null or missing, use the setting from the global configuration.
|
||||||
|
symbol_info_budget:
|
||||||
|
|
||||||
|
# list of regex patterns which, when matched, mark a memory entry as read‑only.
|
||||||
|
# Extends the list from the global configuration, merging the two lists.
|
||||||
|
read_only_memory_patterns: []
|
||||||
|
|
||||||
|
# list of regex patterns for memories to completely ignore.
|
||||||
|
# Matching memories will not appear in list_memories or activate_project output
|
||||||
|
# and cannot be accessed via read_memory or write_memory.
|
||||||
|
# To access ignored memory files, use the read_file tool on the raw file path.
|
||||||
|
# Extends the list from the global configuration, merging the two lists.
|
||||||
|
# Example: ["_archive/.*", "_episodes/.*"]
|
||||||
|
ignored_memory_patterns: []
|
||||||
@@ -5,11 +5,3 @@
|
|||||||
技术栈:SpringBoot MariaDB MyBatis Redis
|
技术栈:SpringBoot MariaDB MyBatis Redis
|
||||||
|
|
||||||
[timijava](https://github.com/imyeyu/timijava)
|
[timijava](https://github.com/imyeyu/timijava)
|
||||||
|
|
||||||
### GAO 客户画像 PDF
|
|
||||||
|
|
||||||
`POST /gao/customer/profile/pdf?id={客户ID}` 返回 `application/pdf`,响应按浏览器内预览处理。调用者需要独立的 `CUSTOMER_PROFILE:READ` 权限,且客户必须在其门店数据范围内;画像读取不再要求分别持有订单、积分或回收物权限。默认不将该权限授予店长或门店管理角色,需要在角色管理中显式授权。
|
|
||||||
|
|
||||||
统计限定客户所属门店。事件包含已核销及无需核销的记录,排除待核销记录,并沿用既有事件查询对历史消费事件的排除规则;上月和本月按服务端时区的自然月计算。订单排除取消单,金额由分换算为元,净收款为已付款减退款。积分月份按流水发生时间统计获得和消费;回收物按品种和单位分别展示,账户流水中的获得、使用及人工调整与回收支付的当前核销状态分别统计。数量、积分和金额均按每四位分组。
|
|
||||||
|
|
||||||
PDF 使用 `templates/GaoCustomerProfile.ftl`,单页展示最多 6 种事件、6 项产品、4 种回收物和 3 条跟进提醒;多出的数据不影响总体汇总。长文本会截断,页面空间不足时会缩小字号;若仍无法排入一页,接口返回错误,不生成多页文件。使用首张 `PHOTO` 附件并按比例转为灰度;无图片或图片格式无法解码时使用占位。字体使用服务器上合法安装的宋体 SimSun,默认路径为 `C:/Windows/Fonts/simsun.ttc`。非 Windows 环境或使用其他路径时,设置 `gao.customer-profile.font-path` 指向包含 SimSun 的 TTC 文件;服务不会自动替换字体,字体缺失时接口返回错误。项目不分发该字体文件。
|
|
||||||
|
|||||||
@@ -1,283 +0,0 @@
|
|||||||
# TimiServerAPI 接口对接说明
|
|
||||||
|
|
||||||
> 接口的路径、方法、参数、请求体、响应体以 `docs/openapi.local.yaml` 为准。本文只补充 OpenAPI 无法完整表达的横切约定:统一响应包装、鉴权、错误码、分页、二进制响应与 SSE。
|
|
||||||
>
|
|
||||||
> 本文不重复 OpenAPI 中的接口清单和字段说明。
|
|
||||||
|
|
||||||
- 服务版本:`1.0.79`
|
|
||||||
- OpenAPI 版本:`3.1.0`
|
|
||||||
- 默认本地地址:`http://localhost:18092`(无 context-path)
|
|
||||||
- OpenAPI JSON:`/v3/api-docs`
|
|
||||||
- OpenAPI YAML:`/v3/api-docs.yaml`
|
|
||||||
- Swagger UI:`/swagger-ui.html`
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 1. 文档快照与覆盖范围
|
|
||||||
|
|
||||||
### 1.1 导出本地快照
|
|
||||||
|
|
||||||
仓库提供两个导出脚本,默认输出 `docs/openapi.local.yaml`:
|
|
||||||
|
|
||||||
```powershell
|
|
||||||
# PowerShell
|
|
||||||
.\scripts\export-openapi.ps1
|
|
||||||
|
|
||||||
# 指定地址与文件名(.json 后缀会导出 JSON)
|
|
||||||
.\scripts\export-openapi.ps1 -BaseUrl http://192.168.1.10:18092 -OutFile docs\openapi.local.json
|
|
||||||
```
|
|
||||||
|
|
||||||
```bash
|
|
||||||
# Bash
|
|
||||||
bash scripts/export-openapi.sh
|
|
||||||
|
|
||||||
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 文件里会包含用户、标签、系统设置等模块的接口。目前已对文件、异步任务与系统设置模块的 8 个 Controller 补充了完整的中文 `@Tag` / `@Operation` / `@Parameter` 描述;这些接口的路径、参数、请求体和响应结构均已包含在 OpenAPI 中。其他模块的接口属于 SpringDoc 自动生成的基础描述,业务语义可能不完整,复杂接口请结合源码或联调确认。
|
|
||||||
|
|
||||||
OpenAPI 中还声明了全局 `Token` 安全要求,但登录、注册等公开接口实际可能不需要登录。**是否需要鉴权以接口实际行为为准**;公开接口已在 OpenAPI 中按操作单独标记 `security`。
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 2. 基础约定
|
|
||||||
|
|
||||||
### 2.1 请求格式
|
|
||||||
|
|
||||||
- 普通接口:`Content-Type: application/json`
|
|
||||||
- 上传类接口:`multipart/form-data`
|
|
||||||
- 字符编码:UTF-8
|
|
||||||
- 时间字段:除特别说明外,均为 **epoch 毫秒**(`long`)
|
|
||||||
- 大小字段:字节(`long`)
|
|
||||||
|
|
||||||
### 2.2 鉴权
|
|
||||||
|
|
||||||
请求头优先使用:
|
|
||||||
|
|
||||||
```http
|
|
||||||
Token: <登录令牌或 API Key>
|
|
||||||
```
|
|
||||||
|
|
||||||
服务端也兼容以下写法:
|
|
||||||
|
|
||||||
```http
|
|
||||||
token: <登录令牌或 API Key>
|
|
||||||
```
|
|
||||||
|
|
||||||
以及 URL 参数:
|
|
||||||
|
|
||||||
```text
|
|
||||||
?token=<登录令牌或 API Key>
|
|
||||||
```
|
|
||||||
|
|
||||||
> 生产环境建议只使用 `Token` 请求头。URL 参数容易进入访问日志、浏览器历史和 Referer。
|
|
||||||
>
|
|
||||||
> 浏览器原生 `EventSource` 不能设置自定义请求头,SSE 场景才使用 `?token=`。
|
|
||||||
|
|
||||||
支持两种凭证:
|
|
||||||
|
|
||||||
1. **登录令牌**:通过登录接口获取,具体接口见 OpenAPI。
|
|
||||||
2. **API Key**:以 `tk_` 开头,格式为 `tk_<8位十六进制>_<32位十六进制>`。API Key 创建后只返回一次明文,不能用于管理 API Key 本身。
|
|
||||||
|
|
||||||
### 2.3 统一响应包装(TimiResponse)
|
|
||||||
|
|
||||||
除二进制、SSE 等特殊接口外,所有 JSON 接口都会被统一包装为:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"code": 20000,
|
|
||||||
"message": "可选,面向用户的提示",
|
|
||||||
"messageCode": "可选,国际化消息键",
|
|
||||||
"data": {}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
字段说明:
|
|
||||||
|
|
||||||
| 字段 | 类型 | 说明 |
|
|
||||||
| --- | --- | --- |
|
|
||||||
| `code` | number | 业务代码,**不是 HTTP 状态码** |
|
|
||||||
| `message` | string | 提示信息,可能根据语言返回不同文案 |
|
|
||||||
| `messageCode` | string | 国际化消息键,可能不存在 |
|
|
||||||
| `data` | any | 业务数据;为 `null` 时通常被省略 |
|
|
||||||
|
|
||||||
判断成功请使用:
|
|
||||||
|
|
||||||
```ts
|
|
||||||
const success = response.code <= 30000; // 20000 成功,20001 表示成功但忽略请求
|
|
||||||
```
|
|
||||||
|
|
||||||
不要只根据 HTTP 状态码判断业务结果。普通 JSON 接口即使业务失败,HTTP 状态通常仍是 `200`。
|
|
||||||
|
|
||||||
### 2.4 错误码
|
|
||||||
|
|
||||||
| code | 含义 |
|
|
||||||
| --- | --- |
|
|
||||||
| `20000` | 成功 |
|
|
||||||
| `20001` | 成功,忽略请求 |
|
|
||||||
| `40000` | 缺少参数 / 未登录 |
|
|
||||||
| `40001` | 参数不合法 |
|
|
||||||
| `40002` | 参数已过期 |
|
|
||||||
| `40100` | 无权限 |
|
|
||||||
| `40101` | 权限错误 |
|
|
||||||
| `40102` | 非法请求 / 请求过于频繁 |
|
|
||||||
| `40301` | 数据已存在 |
|
|
||||||
| `40400` | 数据不存在 |
|
|
||||||
| `40401` | 返回数据异常 |
|
|
||||||
| `40402` | 数据被禁用 |
|
|
||||||
| `40403` | 上游服务超时 |
|
|
||||||
| `50000` | 服务异常 |
|
|
||||||
| `50001` | 不支持的操作 |
|
|
||||||
| `50002` | 服务内部变量缺失 |
|
|
||||||
| `50003` | 服务已关闭 |
|
|
||||||
| `50300` | 服务繁忙 |
|
|
||||||
|
|
||||||
### 2.5 多语言
|
|
||||||
|
|
||||||
可通过以下任一方式指定语言:
|
|
||||||
|
|
||||||
```http
|
|
||||||
Accept-Language: zh-CN
|
|
||||||
```
|
|
||||||
|
|
||||||
```text
|
|
||||||
?lang=zh_CN
|
|
||||||
```
|
|
||||||
|
|
||||||
默认 `zh_CN`。
|
|
||||||
|
|
||||||
### 2.6 分页
|
|
||||||
|
|
||||||
分页接口的请求体通常是 `Page<T>`:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"index": 0,
|
|
||||||
"size": 16,
|
|
||||||
"equalsExample": {},
|
|
||||||
"likesExample": {},
|
|
||||||
"equalsLogic": "AND",
|
|
||||||
"likesLogic": "OR",
|
|
||||||
"orderMap": {
|
|
||||||
"created_at": "DESC"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
- `index`:页码,**从 0 开始**,默认 `0`
|
|
||||||
- `size`:每页数量,默认 `16`;部分接口会限制最大值(例如 100)
|
|
||||||
- `equalsExample`:精确匹配示例
|
|
||||||
- `likesExample`:模糊匹配示例
|
|
||||||
- `equalsLogic`:精确条件连接方式,`AND` / `OR`
|
|
||||||
- `likesLogic`:模糊条件连接方式,`AND` / `OR`
|
|
||||||
- `orderMap`:排序字段与方向,字段通常使用数据库下划线命名
|
|
||||||
|
|
||||||
分页响应通常是 `PageResult<T>`:
|
|
||||||
|
|
||||||
```json
|
|
||||||
{
|
|
||||||
"total": 128,
|
|
||||||
"pages": 8,
|
|
||||||
"list": [],
|
|
||||||
"empty": false,
|
|
||||||
"notEmpty": true
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 3. 特殊响应类型
|
|
||||||
|
|
||||||
### 3.1 二进制响应
|
|
||||||
|
|
||||||
部分接口直接返回二进制数据或字节流,不经过 `TimiResponse`:
|
|
||||||
|
|
||||||
- 成功时直接返回字节流
|
|
||||||
- 失败时使用标准 HTTP 状态码,例如 `400`、`403`、`404`、`500`
|
|
||||||
- 响应头可能包含 `Content-Type`、`Content-Length`、`Content-Disposition`、`ETag`、`Last-Modified`、`Accept-Ranges`、`Content-Range`
|
|
||||||
- 前端应使用 `blob` / `arrayBuffer`,不能按 JSON 解析
|
|
||||||
|
|
||||||
具体哪些接口属于二进制响应,以 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`。事件类型如下:
|
|
||||||
|
|
||||||
| event | 说明 |
|
|
||||||
| --- | --- |
|
|
||||||
| `snapshot` | 连接建立后的当前任务快照 |
|
|
||||||
| `progress` | 状态或进度发生变化 |
|
|
||||||
| `heartbeat` | 心跳,约 15 秒一次 |
|
|
||||||
| `done` | 任务成功,随后服务端关闭连接 |
|
|
||||||
| `error` | 任务失败、被中断、死亡,或订阅异常,随后关闭连接 |
|
|
||||||
|
|
||||||
说明:
|
|
||||||
|
|
||||||
- 事件 `data` 是 JSON,字段和状态枚举以 OpenAPI 中对应的任务模型为准。
|
|
||||||
- 任务结束后服务端主动关闭连接;断线后可回退到 OpenAPI 中的任务详情接口轮询。
|
|
||||||
- 浏览器原生 `EventSource` 不能设置 `Token` 请求头,使用查询参数传递令牌。
|
|
||||||
|
|
||||||
```ts
|
|
||||||
const source = new EventSource(`${sseUrl}?token=${encodeURIComponent(token)}`);
|
|
||||||
|
|
||||||
source.addEventListener("progress", (event) => {
|
|
||||||
const task = JSON.parse(event.data);
|
|
||||||
console.log(task.progress, task.status);
|
|
||||||
});
|
|
||||||
|
|
||||||
source.addEventListener("done", (event) => {
|
|
||||||
const task = JSON.parse(event.data);
|
|
||||||
source.close();
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
其中 `sseUrl` 从 OpenAPI 中对应的 SSE 接口获取。
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 4. AI Agent 对接建议
|
|
||||||
|
|
||||||
1. **优先使用导出的 OpenAPI 文件**,不要只给 `localhost` URL。远程 Agent 无法访问本机地址。可先读 `docs/openapi.index.md` 定位模块和接口,再读取 OpenAPI 中的对应片段,避免整份文档占用上下文。
|
|
||||||
2. 用 OpenAPI 生成 TypeScript 类型和请求客户端,再在客户端层统一补充 `TimiResponse` 包装。
|
|
||||||
3. 不要假设 OpenAPI 的返回类型就是最终响应体;普通 JSON 接口需要取 `data`。
|
|
||||||
4. 二进制接口单独处理:使用 `blob` / `arrayBuffer`,按 HTTP 状态判断成败。
|
|
||||||
5. SSE 单独处理:使用 `EventSource` 或 fetch 流式读取,`Token` 放查询参数。
|
|
||||||
6. 分页接口使用 `Page<T>` / `PageResult<T>`,`index` 从 0 开始。
|
|
||||||
7. 业务错误优先看 `code`,不要只看 HTTP 状态。
|
|
||||||
8. 接口路径、参数和字段结构以 OpenAPI 为准,不要根据本文猜测。
|
|
||||||
|
|
||||||
推荐给 AI Agent 的简要约束:
|
|
||||||
|
|
||||||
```text
|
|
||||||
这是一个 Spring Boot 接口项目。接口路径、参数和响应结构以 OpenAPI 为准。
|
|
||||||
普通 JSON 接口返回 TimiResponse 包装:{ code, message?, messageCode?, data? },
|
|
||||||
code <= 30000 表示成功。鉴权使用 Token 请求头。
|
|
||||||
二进制接口不包装,按 HTTP 状态判断;SSE 接口不包装,Token 放查询参数。
|
|
||||||
分页请求使用 Page<T>,index 从 0 开始。
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 5. 已知限制
|
|
||||||
|
|
||||||
- OpenAPI 的响应 Schema 不包含 `TimiResponse` 包装。
|
|
||||||
- 只有文件、异步任务与系统设置模块的 8 个 Controller 有较完整的中文接口描述,其他模块为基础自动生成信息。
|
|
||||||
- 二进制接口的响应体无法在 OpenAPI 中完整表达,需结合本文和实际响应头处理。
|
|
||||||
- OpenAPI 全局声明了 `Token`,公开接口的实际鉴权行为以接口为准。
|
|
||||||
- 当前没有提交固定的 `docs/openapi.yaml` 版本化文件;需要时使用导出脚本生成本地快照,或后续接入 CI 导出。
|
|
||||||
- `docs/openapi.index.md` 从本地 OpenAPI 快照生成,接口变更后需重新执行导出脚本更新;索引只提供定位信息,字段定义以 OpenAPI 原文为准。
|
|
||||||
@@ -1,814 +0,0 @@
|
|||||||
# 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/create` | create | - | Permission | - | permission-controller |
|
|
||||||
| POST | `/user/permission/create/batch` | createBatch | - | BatchCreateReq | - | permission-controller |
|
|
||||||
| POST | `/user/permission/delete` | delete | id* | - | - | permission-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 |
|
|
||||||
+163
@@ -0,0 +1,163 @@
|
|||||||
|
# HTTP 调试与文档规范
|
||||||
|
|
||||||
|
本目录下的 `.http` 文件同时承担接口调试和接口文档职责,也要保证 AIAgent 能稳定读取
|
||||||
|
|
||||||
|
## 目录分工
|
||||||
|
|
||||||
|
### `.http`
|
||||||
|
|
||||||
|
`.http` 只描述接口级信息:
|
||||||
|
|
||||||
|
1. 接口中文名
|
||||||
|
2. 权限要求
|
||||||
|
3. 前置条件
|
||||||
|
4. 请求参数对应的对象说明
|
||||||
|
5. 返回参数对应的对象说明
|
||||||
|
|
||||||
|
`.http` 不重复展开对象字段明细,复杂字段、嵌套结构、枚举值统一写到 `./object` 下
|
||||||
|
|
||||||
|
### `./object`
|
||||||
|
|
||||||
|
`./object` 只描述对象级信息:
|
||||||
|
|
||||||
|
1. 字段名
|
||||||
|
2. 字段类型
|
||||||
|
3. 字段说明
|
||||||
|
4. 枚举值及含义
|
||||||
|
|
||||||
|
所有模块都可能复用的通用对象必须写在 `./object/common.md`
|
||||||
|
|
||||||
|
按业务领域拆分对象说明文件,例如:
|
||||||
|
|
||||||
|
1. `./object/common.md`
|
||||||
|
2. `./object/user.md`
|
||||||
|
3. `./object/role.md`
|
||||||
|
4. `./object/permission.md`
|
||||||
|
|
||||||
|
不要把同一个对象的字段说明散落到多个文件里
|
||||||
|
|
||||||
|
## 全局约定
|
||||||
|
|
||||||
|
### 返回包装
|
||||||
|
|
||||||
|
除使用 `IgnoreGlobalReturn` 跳过全局包装的方法外,接口默认都会经过
|
||||||
|
[GlobalReturnHandler](E:/IDEAProject/timi-spring/src/main/java/com/imyeyu/spring/util/GlobalReturnHandler.java)
|
||||||
|
统一包装返回
|
||||||
|
|
||||||
|
因此 `.http` 里的 `返回参数` 默认只描述业务 `data` 对象,不再重复赘述全局包装结构
|
||||||
|
|
||||||
|
全局返回包装、通用成功码、错误信息、常见分页壳子等内容统一维护在 `./object/common.md`
|
||||||
|
|
||||||
|
如果接口使用
|
||||||
|
[IgnoreGlobalReturn](E:/IDEAProject/timi-spring/src/main/java/com/imyeyu/spring/annotation/IgnoreGlobalReturn.java)
|
||||||
|
跳过全局包装,必须在对应接口的 `前置条件` 或补充说明里明确写出“该接口不走全局返回包装”
|
||||||
|
|
||||||
|
### 文档真实性
|
||||||
|
|
||||||
|
1. 文档只记录服务端真实行为
|
||||||
|
2. 不写猜测
|
||||||
|
3. 不写“看代码”
|
||||||
|
4. 接口改了就同步更新 `.http` 和 `./object`
|
||||||
|
|
||||||
|
### 变量复用
|
||||||
|
|
||||||
|
能复用的变量统一放在文件顶部,例如 `@user_token`、`@userId`
|
||||||
|
|
||||||
|
## `.http` 模板
|
||||||
|
|
||||||
|
每个接口块固定使用下面格式,不要擅自增删字段名:
|
||||||
|
|
||||||
|
```http
|
||||||
|
### <接口中文名>
|
||||||
|
### 权限:
|
||||||
|
### 前置条件:
|
||||||
|
### 请求参数:
|
||||||
|
### 返回参数:
|
||||||
|
|
||||||
|
POST {{baseUrl}}/path
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{}
|
||||||
|
```
|
||||||
|
|
||||||
|
## `.http` 填写要求
|
||||||
|
|
||||||
|
### 接口中文名
|
||||||
|
|
||||||
|
直接写接口用途,别写成控制器方法名
|
||||||
|
|
||||||
|
### 权限
|
||||||
|
|
||||||
|
1. 优先直接翻译控制器上的真实注解
|
||||||
|
2. 同时存在角色和权限时一起写,例如 `需要 ADMIN 角色 + USER_UPDATE 权限`
|
||||||
|
3. 只有 Token 要求时写 `需要有效 Token`
|
||||||
|
4. 无需登录时直接写 `无需登录`
|
||||||
|
|
||||||
|
### 前置条件
|
||||||
|
|
||||||
|
这里只写接口调用前必须知道的约束,例如:
|
||||||
|
|
||||||
|
1. 需要先登录并回填 `user_token`
|
||||||
|
2. 需要先创建用户再传入 `userId`
|
||||||
|
3. 重复调用可能因为唯一约束失败
|
||||||
|
4. 接口当前实现为空
|
||||||
|
5. 该接口不走全局返回包装
|
||||||
|
|
||||||
|
没有额外限制时写 `无`
|
||||||
|
|
||||||
|
### 请求参数
|
||||||
|
|
||||||
|
只写请求对象名和对象说明文件,不在 `.http` 内展开字段
|
||||||
|
|
||||||
|
推荐格式:
|
||||||
|
|
||||||
|
1. `无`
|
||||||
|
2. `UserCreateRequest,详见 ./object/user.md`
|
||||||
|
3. `Page<UserQuery>,详见 ./object/common.md 和 ./object/user.md`
|
||||||
|
|
||||||
|
### 返回参数
|
||||||
|
|
||||||
|
只写业务返回对象名和对象说明文件,不在 `.http` 内展开字段
|
||||||
|
|
||||||
|
推荐格式:
|
||||||
|
|
||||||
|
1. `无`
|
||||||
|
2. `User,详见 ./object/user.md`
|
||||||
|
3. `PageResult<User>,详见 ./object/common.md 和 ./object/user.md`
|
||||||
|
4. `二进制数据流,该接口不走全局返回包装`
|
||||||
|
|
||||||
|
## `./object` 编写要求
|
||||||
|
|
||||||
|
对象说明统一使用 Markdown 表格,推荐结构如下
|
||||||
|
|
||||||
|
```md
|
||||||
|
## User
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| name | String | 登录名,系统内唯一 |
|
||||||
|
|
||||||
|
## RoleCode
|
||||||
|
|
||||||
|
| 枚举 | 说明 |
|
||||||
|
|---|---|
|
||||||
|
| SYSTEM | 系统 |
|
||||||
|
| ADMIN | 管理员 |
|
||||||
|
```
|
||||||
|
|
||||||
|
### 对象说明规则
|
||||||
|
|
||||||
|
1. 一个对象一个标题,标题名必须和 `.http` 里引用的对象名一致
|
||||||
|
2. 字段说明只写真实存在且调用方需要关心的内容
|
||||||
|
3. 枚举单独列出,不要把枚举值混进普通字段表
|
||||||
|
4. 嵌套对象、列表元素对象也要有独立标题
|
||||||
|
5. 通用壳子对象统一写在 `./object/common.md`
|
||||||
|
|
||||||
|
## 维护要求
|
||||||
|
|
||||||
|
1. 一个控制器通常对应一个 `.http` 文件
|
||||||
|
2. 新增接口时,同步补齐对应 `.http`
|
||||||
|
3. 新增或修改对象字段时,同步更新对应 `./object/*.md`
|
||||||
|
4. 注释语言统一用中文
|
||||||
|
5. 示例请求优先保证可调试,其次才是看起来完整
|
||||||
@@ -0,0 +1,200 @@
|
|||||||
|
### AttachmentController 接口测试
|
||||||
|
### 在 IDEA 中选择 dev 或 prod 环境后执行
|
||||||
|
|
||||||
|
@attachmentId =
|
||||||
|
@attachmentBizType = TEMP_FILE
|
||||||
|
@attachmentBizId = demo-biz-id
|
||||||
|
@attachmentAttachType = SOURCE
|
||||||
|
@attachmentName = demo.png
|
||||||
|
@attachmentFilePath = E:/Temp/demo.png
|
||||||
|
@attachmentTempFileId =
|
||||||
|
|
||||||
|
### 查询附件详情
|
||||||
|
### 前置条件:`id` 必须传有效附件 ID
|
||||||
|
### 请求参数:URL 参数 `id` 为附件 ID
|
||||||
|
### 返回参数:Attachment,详见 ./object/common.md
|
||||||
|
POST {{baseUrl}}/attach/detail?id={{attachmentId}}
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
### 创建附件
|
||||||
|
### 前置条件:回填 `attachmentFilePath` 为本地文件绝对路径
|
||||||
|
### 请求参数:multipart/form-data
|
||||||
|
### 返回参数:Attachment,详见 ./object/common.md
|
||||||
|
POST {{baseUrl}}/attach/create
|
||||||
|
Content-Type: multipart/form-data; boundary=AttachmentCreateBoundary
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
--AttachmentCreateBoundary
|
||||||
|
Content-Disposition: form-data; name="bizType"
|
||||||
|
|
||||||
|
{{attachmentBizType}}
|
||||||
|
--AttachmentCreateBoundary
|
||||||
|
Content-Disposition: form-data; name="bizId"
|
||||||
|
|
||||||
|
{{attachmentBizId}}
|
||||||
|
--AttachmentCreateBoundary
|
||||||
|
Content-Disposition: form-data; name="attachType"
|
||||||
|
|
||||||
|
{{attachmentAttachType}}
|
||||||
|
--AttachmentCreateBoundary
|
||||||
|
Content-Disposition: form-data; name="name"
|
||||||
|
|
||||||
|
{{attachmentName}}
|
||||||
|
--AttachmentCreateBoundary
|
||||||
|
Content-Disposition: form-data; name="file"; filename="demo.png"
|
||||||
|
Content-Type: application/octet-stream
|
||||||
|
|
||||||
|
< {{attachmentFilePath}}
|
||||||
|
--AttachmentCreateBoundary--
|
||||||
|
|
||||||
|
### 更新附件元数据
|
||||||
|
### 前置条件:`id` 必须传有效附件 ID
|
||||||
|
### 请求参数:multipart/form-data
|
||||||
|
### 返回参数:无
|
||||||
|
POST {{baseUrl}}/attach/update
|
||||||
|
Content-Type: multipart/form-data; boundary=AttachmentUpdateMetaBoundary
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
--AttachmentUpdateMetaBoundary
|
||||||
|
Content-Disposition: form-data; name="id"
|
||||||
|
|
||||||
|
{{attachmentId}}
|
||||||
|
--AttachmentUpdateMetaBoundary
|
||||||
|
Content-Disposition: form-data; name="name"
|
||||||
|
|
||||||
|
{{attachmentName}}-updated
|
||||||
|
--AttachmentUpdateMetaBoundary
|
||||||
|
Content-Disposition: form-data; name="attachType"
|
||||||
|
|
||||||
|
{{attachmentAttachType}}
|
||||||
|
--AttachmentUpdateMetaBoundary--
|
||||||
|
|
||||||
|
### 更新附件文件
|
||||||
|
### 前置条件:`id` 必须传有效附件 ID,`attachmentFilePath` 必须传本地文件绝对路径
|
||||||
|
### 请求参数:multipart/form-data
|
||||||
|
### 返回参数:无
|
||||||
|
POST {{baseUrl}}/attach/update
|
||||||
|
Content-Type: multipart/form-data; boundary=AttachmentUpdateFileBoundary
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
--AttachmentUpdateFileBoundary
|
||||||
|
Content-Disposition: form-data; name="id"
|
||||||
|
|
||||||
|
{{attachmentId}}
|
||||||
|
--AttachmentUpdateFileBoundary
|
||||||
|
Content-Disposition: form-data; name="name"
|
||||||
|
|
||||||
|
{{attachmentName}}-file-updated
|
||||||
|
--AttachmentUpdateFileBoundary
|
||||||
|
Content-Disposition: form-data; name="file"; filename="demo.png"
|
||||||
|
Content-Type: application/octet-stream
|
||||||
|
|
||||||
|
< {{attachmentFilePath}}
|
||||||
|
--AttachmentUpdateFileBoundary--
|
||||||
|
|
||||||
|
### 删除附件
|
||||||
|
### 前置条件:`id` 必须传有效附件 ID
|
||||||
|
### 请求参数:URL 参数 `id` 为附件 ID
|
||||||
|
### 返回参数:无
|
||||||
|
POST {{baseUrl}}/attach/delete?id={{attachmentId}}
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
### 按业务查询单个附件
|
||||||
|
### 前置条件:`bizType` 和 `bizId` 必须传有效值
|
||||||
|
### 请求参数:URL 参数 `bizType`、`bizId`
|
||||||
|
### 返回参数:Attachment,详见 ./object/common.md
|
||||||
|
GET {{baseUrl}}/attach/detail/byBiz?bizType={{attachmentBizType}}&bizId={{attachmentBizId}}
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
### 按业务和附件类型查询单个附件
|
||||||
|
### 前置条件:`bizType`、`bizId`、`attachType` 必须传有效值
|
||||||
|
### 请求参数:URL 参数 `bizType`、`bizId`、`attachType`
|
||||||
|
### 返回参数:Attachment,详见 ./object/common.md
|
||||||
|
GET {{baseUrl}}/attach/detail/byAttachType?bizType={{attachmentBizType}}&bizId={{attachmentBizId}}&attachType={{attachmentAttachType}}
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
### 按业务查询附件列表
|
||||||
|
### 前置条件:`bizType` 和 `bizId` 必须传有效值
|
||||||
|
### 请求参数:URL 参数 `bizType`、`bizId`,可重复传 `attachTypeList`
|
||||||
|
### 返回参数:Attachment[]
|
||||||
|
GET {{baseUrl}}/attach/list/byBiz?bizType={{attachmentBizType}}&bizId={{attachmentBizId}}&attachTypeList={{attachmentAttachType}}
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
### 按业务统计附件数量
|
||||||
|
### 前置条件:`bizType` 和 `bizId` 必须传有效值
|
||||||
|
### 请求参数:URL 参数 `bizType`、`bizId`,可重复传 `attachTypeList`
|
||||||
|
### 返回参数:number
|
||||||
|
GET {{baseUrl}}/attach/count/byBiz?bizType={{attachmentBizType}}&bizId={{attachmentBizId}}&attachTypeList={{attachmentAttachType}}
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
### 按业务分页查询附件
|
||||||
|
### 前置条件:`bizType` 和 `bizId` 必须传有效值
|
||||||
|
### 请求参数:URL 参数 `bizType`、`bizId`,可重复传 `attachTypeList`,请求体为 Page
|
||||||
|
### 返回参数:PageResult<Attachment>
|
||||||
|
POST {{baseUrl}}/attach/page/byBiz?bizType={{attachmentBizType}}&bizId={{attachmentBizId}}&attachTypeList={{attachmentAttachType}}
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"index": 0,
|
||||||
|
"size": 10
|
||||||
|
}
|
||||||
|
|
||||||
|
### 按业务差分更新附件
|
||||||
|
### 前置条件:新增项需要传有效 `tempFileId`
|
||||||
|
### 请求参数:BizUpdateReq
|
||||||
|
### 返回参数:无
|
||||||
|
POST {{baseUrl}}/attach/update/byBiz
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"bizType": "{{attachmentBizType}}",
|
||||||
|
"bizId": "{{attachmentBizId}}",
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"id": "{{attachmentId}}",
|
||||||
|
"attachType": "{{attachmentAttachType}}",
|
||||||
|
"name": "{{attachmentName}}-biz-updated"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"tempFileId": "{{attachmentTempFileId}}",
|
||||||
|
"attachType": "{{attachmentAttachType}}",
|
||||||
|
"name": "{{attachmentName}}-from-temp"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
### 按业务删除全部附件
|
||||||
|
### 前置条件:`bizType` 和 `bizId` 必须传有效值
|
||||||
|
### 请求参数:BizDeleteReq
|
||||||
|
### 返回参数:无
|
||||||
|
POST {{baseUrl}}/attach/delete/byBiz
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"bizType": "{{attachmentBizType}}",
|
||||||
|
"bizId": "{{attachmentBizId}}"
|
||||||
|
}
|
||||||
|
|
||||||
|
### 读取附件原图
|
||||||
|
### 前置条件:`attachmentId` 必须传有效附件 ID
|
||||||
|
### 请求参数:路径参数 `id`
|
||||||
|
### 返回参数:附件二进制流
|
||||||
|
GET {{baseUrl}}/attach/read/{{attachmentId}}
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
### 读取附件缩略图
|
||||||
|
### 前置条件:`attachmentId` 必须传有效图片或视频附件 ID
|
||||||
|
### 请求参数:路径参数 `id`,URL 参数 `thumbWidth`、`thumbHeight`
|
||||||
|
### 返回参数:附件二进制流
|
||||||
|
GET {{baseUrl}}/attach/read/{{attachmentId}}?thumbWidth=200&thumbHeight=200
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
### 下载附件
|
||||||
|
### 前置条件:`attachmentId` 必须传有效附件 ID
|
||||||
|
### 请求参数:路径参数 `id`
|
||||||
|
### 返回参数:附件二进制流
|
||||||
|
GET {{baseUrl}}/attach/download/{{attachmentId}}
|
||||||
|
Token: {{user_token}}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
### MultilingualController 接口测试
|
||||||
|
### 在 IDEA 中选择 dev 或 prod 环境后执行
|
||||||
|
|
||||||
|
@multilingualId =
|
||||||
|
@multilingualZhCN = 测试简体中文
|
||||||
|
@multilingualZhTW = 測試繁體中文
|
||||||
|
@multilingualEnUS = Test English
|
||||||
|
@multilingualRuRU = Тест
|
||||||
|
@multilingualJaJP = テスト
|
||||||
|
@multilingualDeDE = Test Deutsch
|
||||||
|
@multilingualKoKR = 테스트
|
||||||
|
|
||||||
|
### 查询多语言详情
|
||||||
|
### 权限:需要 ADMIN 角色 + MULTILINGUAL_READ 权限
|
||||||
|
### 前置条件:需要先登录并回填 `user_token`,URL 参数 `id` 必须传有效多语言 ID
|
||||||
|
### 请求参数:无请求体,URL 参数:`id` 为多语言 ID
|
||||||
|
### 返回参数:Multilingual,详见 ./object/common.md
|
||||||
|
POST {{baseUrl}}/system/multilingual/detail?id={{multilingualId}}
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
### 创建多语言
|
||||||
|
### 权限:需要 ADMIN 角色 + MULTILINGUAL_CREATE 权限
|
||||||
|
### 前置条件:需要先登录并回填 `user_token`
|
||||||
|
### 请求参数:Multilingual,详见 ./object/common.md
|
||||||
|
### 返回参数:Multilingual,详见 ./object/common.md
|
||||||
|
POST {{baseUrl}}/system/multilingual/create
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"zhCN": "{{multilingualZhCN}}",
|
||||||
|
"zhTW": "{{multilingualZhTW}}",
|
||||||
|
"enUS": "{{multilingualEnUS}}",
|
||||||
|
"ruRU": "{{multilingualRuRU}}",
|
||||||
|
"jaJP": "{{multilingualJaJP}}",
|
||||||
|
"deDE": "{{multilingualDeDE}}",
|
||||||
|
"koKR": "{{multilingualKoKR}}"
|
||||||
|
}
|
||||||
|
|
||||||
|
### 更新多语言
|
||||||
|
### 权限:需要 ADMIN 角色 + MULTILINGUAL_UPDATE 权限
|
||||||
|
### 前置条件:需要先登录并回填 `user_token`,`id` 必须存在
|
||||||
|
### 请求参数:Multilingual,详见 ./object/common.md
|
||||||
|
### 返回参数:无
|
||||||
|
POST {{baseUrl}}/system/multilingual/update
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"id": "{{multilingualId}}",
|
||||||
|
"zhCN": "{{multilingualZhCN}}-已更新",
|
||||||
|
"zhTW": "{{multilingualZhTW}}-已更新",
|
||||||
|
"enUS": "{{multilingualEnUS}}-updated",
|
||||||
|
"ruRU": "{{multilingualRuRU}}-updated",
|
||||||
|
"jaJP": "{{multilingualJaJP}}-updated",
|
||||||
|
"deDE": "{{multilingualDeDE}}-updated",
|
||||||
|
"koKR": "{{multilingualKoKR}}-updated"
|
||||||
|
}
|
||||||
|
|
||||||
|
### 删除多语言
|
||||||
|
### 权限:需要 ADMIN 角色 + MULTILINGUAL_DELETE 权限
|
||||||
|
### 前置条件:需要先登录并回填 `user_token`,URL 参数 `id` 必须传有效多语言 ID
|
||||||
|
### 请求参数:无请求体,URL 参数:`id` 为多语言 ID
|
||||||
|
### 返回参数:无
|
||||||
|
POST {{baseUrl}}/system/multilingual/delete?id={{multilingualId}}
|
||||||
|
Token: {{user_token}}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
### GaoRegisterAction 接口测试
|
||||||
|
### 在 IDEA 中选择 dev 或 prod 环境后执行
|
||||||
|
|
||||||
|
@actionId =
|
||||||
|
|
||||||
|
### 分页查询登记行为
|
||||||
|
POST {{baseUrl}}/gao/action/list
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"index": 0,
|
||||||
|
"size": 16
|
||||||
|
}
|
||||||
|
|
||||||
|
### 查询启用行为
|
||||||
|
POST {{baseUrl}}/gao/action/enabled/list
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
### 查询行为详情
|
||||||
|
POST {{baseUrl}}/gao/action/detail?id={{actionId}}
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
### 创建登记行为
|
||||||
|
POST {{baseUrl}}/gao/action/create
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": "签到",
|
||||||
|
"description": "客户到店签到",
|
||||||
|
"enabled": true,
|
||||||
|
"requirePhoto": false,
|
||||||
|
"sort": 10,
|
||||||
|
"permissionCodeList": [
|
||||||
|
"RECORD:CREATE"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
### 更新登记行为
|
||||||
|
POST {{baseUrl}}/gao/action/update
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"id": "{{actionId}}",
|
||||||
|
"name": "物品领取",
|
||||||
|
"description": "登记客户领取物品",
|
||||||
|
"enabled": true,
|
||||||
|
"requirePhoto": true,
|
||||||
|
"sort": 20,
|
||||||
|
"permissionCodeList": [
|
||||||
|
"RECORD:CREATE",
|
||||||
|
"STAT:READ"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
### 删除登记行为
|
||||||
|
POST {{baseUrl}}/gao/action/delete?id={{actionId}}
|
||||||
|
Token: {{user_token}}
|
||||||
@@ -0,0 +1,119 @@
|
|||||||
|
### GaoCustomer 接口测试
|
||||||
|
### 在 IDEA 中选择 dev 或 prod 环境后执行
|
||||||
|
|
||||||
|
@customerId =
|
||||||
|
@introducerCustomerId =
|
||||||
|
@customerCode = GAO-0001
|
||||||
|
|
||||||
|
### 分页查询客户
|
||||||
|
POST {{baseUrl}}/gao/customer/list
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"index": 0,
|
||||||
|
"size": 16
|
||||||
|
}
|
||||||
|
|
||||||
|
### 搜索客户
|
||||||
|
POST {{baseUrl}}/gao/customer/search
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"keyword": "张",
|
||||||
|
"introducerCustomerId": "{{introducerCustomerId}}"
|
||||||
|
}
|
||||||
|
|
||||||
|
### 查询客户详情
|
||||||
|
POST {{baseUrl}}/gao/customer/detail?id={{customerId}}
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
### 按客户编码查询
|
||||||
|
POST {{baseUrl}}/gao/customer/detail/code?code={{customerCode}}
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
### 查询某客户邀请了哪些人
|
||||||
|
POST {{baseUrl}}/gao/customer/invited/list?introducerCustomerId={{customerId}}
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
### 创建客户
|
||||||
|
POST {{baseUrl}}/gao/customer/create
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"code": "{{customerCode}}",
|
||||||
|
"name": "张三",
|
||||||
|
"age": 56,
|
||||||
|
"telephone": "020-88886666",
|
||||||
|
"address": "广州市天河区某街道",
|
||||||
|
"remark": "首诊客户",
|
||||||
|
"disease": "肩颈不适",
|
||||||
|
"conditioningPart": [
|
||||||
|
{
|
||||||
|
"code": "neck",
|
||||||
|
"name": "颈部"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"code": "shoulder",
|
||||||
|
"name": "肩部"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"introducerCustomerId": "{{introducerCustomerId}}"
|
||||||
|
}
|
||||||
|
|
||||||
|
### 更新客户
|
||||||
|
POST {{baseUrl}}/gao/customer/update
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"id": "{{customerId}}",
|
||||||
|
"code": "{{customerCode}}",
|
||||||
|
"name": "张三",
|
||||||
|
"age": 57,
|
||||||
|
"telephone": "020-88886667",
|
||||||
|
"address": "广州市天河区某街道 88 号",
|
||||||
|
"remark": "复诊客户",
|
||||||
|
"disease": "腰背调理",
|
||||||
|
"conditioningPart": {
|
||||||
|
"parts": [
|
||||||
|
"waist",
|
||||||
|
"back"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"introducerCustomerId": "{{introducerCustomerId}}"
|
||||||
|
}
|
||||||
|
|
||||||
|
### 删除客户
|
||||||
|
POST {{baseUrl}}/gao/customer/delete?id={{customerId}}
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
### 创建客户邀请关系
|
||||||
|
POST {{baseUrl}}/gao/customer/invite/create
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"customerId": "{{customerId}}",
|
||||||
|
"introducerCustomerId": "{{introducerCustomerId}}"
|
||||||
|
}
|
||||||
|
|
||||||
|
### 查询客户邀请关系详情
|
||||||
|
POST {{baseUrl}}/gao/customer/invite/detail?customerId={{customerId}}
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
### 更新客户邀请关系
|
||||||
|
POST {{baseUrl}}/gao/customer/invite/update
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"customerId": "{{customerId}}",
|
||||||
|
"introducerCustomerId": "{{introducerCustomerId}}"
|
||||||
|
}
|
||||||
|
|
||||||
|
### 删除客户邀请关系
|
||||||
|
POST {{baseUrl}}/gao/customer/invite/delete?customerId={{customerId}}
|
||||||
|
Token: {{user_token}}
|
||||||
@@ -0,0 +1,86 @@
|
|||||||
|
### GaoRegisterRecord 接口测试
|
||||||
|
### 在 IDEA 中选择 dev 或 prod 环境后执行
|
||||||
|
|
||||||
|
@recordId =
|
||||||
|
@customerId =
|
||||||
|
@customerCode = GAO-0001
|
||||||
|
@actionId =
|
||||||
|
|
||||||
|
### 分页查询登记记录
|
||||||
|
POST {{baseUrl}}/gao/record/list
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"index": 0,
|
||||||
|
"size": 16
|
||||||
|
}
|
||||||
|
|
||||||
|
### 查询登记记录详情
|
||||||
|
POST {{baseUrl}}/gao/record/detail?id={{recordId}}
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
### 创建登记记录,直接传客户 ID
|
||||||
|
POST {{baseUrl}}/gao/record/create
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"customerId": "{{customerId}}",
|
||||||
|
"actionId": "{{actionId}}",
|
||||||
|
"remark": "客户到店签到"
|
||||||
|
}
|
||||||
|
|
||||||
|
### 创建登记记录,扫码后传客户编码
|
||||||
|
POST {{baseUrl}}/gao/record/create
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"customerCode": "{{customerCode}}",
|
||||||
|
"actionId": "{{actionId}}",
|
||||||
|
"remark": "扫码快速登记"
|
||||||
|
}
|
||||||
|
|
||||||
|
### 更新登记记录
|
||||||
|
POST {{baseUrl}}/gao/record/update
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"id": "{{recordId}}",
|
||||||
|
"customerId": "{{customerId}}",
|
||||||
|
"actionId": "{{actionId}}",
|
||||||
|
"remark": "补充备注",
|
||||||
|
"registeredAt": 1785110400
|
||||||
|
}
|
||||||
|
|
||||||
|
### 删除登记记录
|
||||||
|
POST {{baseUrl}}/gao/record/delete?id={{recordId}}
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
### 按日查询某个行为记录
|
||||||
|
POST {{baseUrl}}/gao/record/period/list
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"actionId": "{{actionId}}",
|
||||||
|
"periodType": "DAY",
|
||||||
|
"periodValue": 20260727
|
||||||
|
}
|
||||||
|
|
||||||
|
### 按月统计某个行为记录
|
||||||
|
POST {{baseUrl}}/gao/record/period/stat
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"actionId": "{{actionId}}",
|
||||||
|
"periodType": "MONTH",
|
||||||
|
"periodValue": 202607
|
||||||
|
}
|
||||||
|
|
||||||
|
### 查询客户所有登记统计
|
||||||
|
POST {{baseUrl}}/gao/record/customer/stat?customerId={{customerId}}
|
||||||
|
Token: {{user_token}}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"dev": {
|
||||||
|
"baseUrl": "http://localhost:8091"
|
||||||
|
},
|
||||||
|
"prod": {
|
||||||
|
"baseUrl": "https://api.example.com"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
# 通用对象说明
|
||||||
|
|
||||||
|
## TimiResponse<T>
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| code | Integer | 响应码,`20000` 为成功 |
|
||||||
|
| msg | String | 响应消息 |
|
||||||
|
| data | T | 业务数据体,具体结构由接口返回对象决定 |
|
||||||
|
|
||||||
|
## Page<T>
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| index | int | 页码下标,从 `0` 开始 |
|
||||||
|
| size | long | 每页数量 |
|
||||||
|
| equalsExample | T | 精确匹配示例对象,非空字段参与精确查询 |
|
||||||
|
| likesExample | T | 模糊匹配示例对象,非空字段参与模糊查询 |
|
||||||
|
| equalsLogic | Logic | 精确匹配字段之间的连接逻辑,默认 `AND` |
|
||||||
|
| likesLogic | Logic | 模糊匹配字段之间的连接逻辑,默认 `OR` |
|
||||||
|
| orderMap | LinkedHashMap<String, OrderType> | 排序字段映射,键通常为字段名,值为排序方向 |
|
||||||
|
|
||||||
|
## PageResult<T>
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| total | long | 总数据量 |
|
||||||
|
| pages | int | 总页数 |
|
||||||
|
| list | List<T> | 当前页数据列表 |
|
||||||
|
|
||||||
|
## UUIDEntity
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| id | String | 主键 ID,UUID 字符串 |
|
||||||
|
| createdAt | Long | 创建时间,Unix 时间戳毫秒 |
|
||||||
|
| updatedAt | Long | 更新时间,Unix 时间戳毫秒 |
|
||||||
|
| deletedAt | Long | 删除时间,Unix 时间戳毫秒,未删除时通常为空 |
|
||||||
|
|
||||||
|
## Multilingual
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| id | String | 多语言 ID |
|
||||||
|
| zhCN | String | 简体中文文本 |
|
||||||
|
| zhTW | String | 繁体中文文本 |
|
||||||
|
| enUS | String | 英文文本 |
|
||||||
|
| ruRU | String | 俄文文本 |
|
||||||
|
| jaJP | String | 日文文本 |
|
||||||
|
| deDE | String | 德文文本 |
|
||||||
|
| koKR | String | 韩文文本 |
|
||||||
|
| lastAccessAt | Long | 最后访问时间,Unix 时间戳毫秒 |
|
||||||
|
| createdAt | Long | 创建时间,Unix 时间戳毫秒 |
|
||||||
|
| updatedAt | Long | 更新时间,Unix 时间戳毫秒 |
|
||||||
|
| deletedAt | Long | 删除时间,Unix 时间戳毫秒,未删除时通常为空 |
|
||||||
|
|
||||||
|
## Logic
|
||||||
|
|
||||||
|
| 枚举 | 说明 |
|
||||||
|
|---|---|
|
||||||
|
| AND | 多个条件同时满足 |
|
||||||
|
| OR | 多个条件满足其一 |
|
||||||
|
|
||||||
|
## OrderType
|
||||||
|
|
||||||
|
| 枚举 | 说明 |
|
||||||
|
|---|---|
|
||||||
|
| ASC | 升序 |
|
||||||
|
| DESC | 降序 |
|
||||||
|
|
||||||
|
## ImageType
|
||||||
|
|
||||||
|
| 枚举 | 说明 |
|
||||||
|
|---|---|
|
||||||
|
| AUTO | 双线性 |
|
||||||
|
| SMOOTH | 模糊 |
|
||||||
|
| PIXELATED | 像素 |
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
# 权限对象说明
|
||||||
|
|
||||||
|
## Permission
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| id | String | 权限 ID |
|
||||||
|
| createdAt | Long | 创建时间,Unix 时间戳毫秒 |
|
||||||
|
| updatedAt | Long | 更新时间,Unix 时间戳毫秒 |
|
||||||
|
| deletedAt | Long | 删除时间,Unix 时间戳毫秒 |
|
||||||
|
| code | String | 权限代码,需与数据库 `permission.code` 保持一致 |
|
||||||
|
| nameLangId | String | 权限名称的多语言键 |
|
||||||
|
| description | String | 权限说明 |
|
||||||
|
| name | String | 当前语言下的权限名称 |
|
||||||
|
|
||||||
|
## BatchCreateReq
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| prefixCode | String | 权限代码前缀,例如 `ROLE` |
|
||||||
|
| prefixName | String | 权限名称前缀,例如 `角色` |
|
||||||
|
| types | Type[] | 需要批量生成的权限类型列表,详见 `BatchCreateType` |
|
||||||
|
|
||||||
|
## BatchCreateType
|
||||||
|
|
||||||
|
| 枚举 | 说明 |
|
||||||
|
|---|---|
|
||||||
|
| CREATE | 创建权限 |
|
||||||
|
| READ | 读取权限 |
|
||||||
|
| UPDATE | 更新权限 |
|
||||||
|
| DELETE | 删除权限 |
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
# 角色对象说明
|
||||||
|
|
||||||
|
## Role
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| id | String | 角色 ID |
|
||||||
|
| createdAt | Long | 创建时间,Unix 时间戳毫秒 |
|
||||||
|
| updatedAt | Long | 更新时间,Unix 时间戳毫秒 |
|
||||||
|
| deletedAt | Long | 删除时间,Unix 时间戳毫秒 |
|
||||||
|
| code | String | 角色代码,常见值见 `RoleCode` |
|
||||||
|
| nameLangId | String | 角色名称的多语言键 |
|
||||||
|
| description | String | 角色说明 |
|
||||||
|
| name | String | 当前语言下的角色名称 |
|
||||||
|
| permissionList | List<Permission> | 角色自身直接绑定的权限列表 |
|
||||||
|
| allPermissionList | List<Permission> | 角色全部权限列表,包含继承自子角色的权限 |
|
||||||
|
| childRoleList | List<Role> | 子角色列表 |
|
||||||
|
| permissionIdList | Set<String> | 权限 ID 列表,创建或更新角色时使用 |
|
||||||
|
| childRoleIdList | Set<String> | 子角色 ID 列表,创建或更新角色时使用 |
|
||||||
|
|
||||||
|
## UserRoleAuthorizeReq
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| userId | String | 目标用户 ID |
|
||||||
|
| roleIdList | List<String> | 需要授权的角色 ID 列表 |
|
||||||
|
| roleCodeList | List<String> | 需要授权的角色代码列表 |
|
||||||
|
|
||||||
|
## RoleCode
|
||||||
|
|
||||||
|
| 枚举 | 说明 |
|
||||||
|
|---|---|
|
||||||
|
| SYSTEM | 系统 |
|
||||||
|
| ADMIN | 管理员 |
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
# 用户对象说明
|
||||||
|
|
||||||
|
## User
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| id | String | 用户 ID |
|
||||||
|
| createdAt | Long | 创建时间,Unix 时间戳毫秒 |
|
||||||
|
| updatedAt | Long | 更新时间,Unix 时间戳毫秒 |
|
||||||
|
| deletedAt | Long | 删除时间,Unix 时间戳毫秒 |
|
||||||
|
| name | String | 登录名,系统内唯一 |
|
||||||
|
| nick | String | 用户昵称 |
|
||||||
|
| password | String | 明文密码,请求时填写,响应通常不返回 |
|
||||||
|
| email | String | 邮箱地址 |
|
||||||
|
| emailVerifyAt | Long | 邮箱验证时间,Unix 时间戳毫秒 |
|
||||||
|
| phoneNo | String | 手机号,11 位大陆手机号 |
|
||||||
|
| phoneNoVerifyAt | Long | 手机号验证时间,Unix 时间戳毫秒 |
|
||||||
|
| wrapperType | ImageType | 背景图渲染算法,详见 `ImageType` |
|
||||||
|
| avatarType | ImageType | 头像渲染算法,详见 `ImageType` |
|
||||||
|
| exp | Integer | 经验值 |
|
||||||
|
| sex | Integer | 性别,当前代码未定义枚举说明 |
|
||||||
|
| birthdate | Long | 出生日期,Unix 时间戳毫秒 |
|
||||||
|
| qq | String | QQ 号 |
|
||||||
|
| description | String | 个人说明 |
|
||||||
|
| lastLoginIP | String | 上次登录 IP |
|
||||||
|
| lastLoginAt | Long | 上次登录时间,Unix 时间戳毫秒 |
|
||||||
|
| unmuteAt | Long | 解除禁言时间,Unix 时间戳毫秒 |
|
||||||
|
| unbanAt | Long | 解除封禁时间,Unix 时间戳毫秒 |
|
||||||
|
| roleList | List<String> | 角色代码列表 |
|
||||||
|
| permissionList | List<String> | 权限代码列表 |
|
||||||
|
| attachmentList | List<Attachment> | 附件列表 |
|
||||||
|
| settingList | List<Setting> | 设置列表 |
|
||||||
|
|
||||||
|
## LoginRequest
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| user | String | 用户标识,可能是 UID、邮箱或用户名 |
|
||||||
|
| password | String | 明文密码 |
|
||||||
|
|
||||||
|
## LoginResponse
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| token | String | 登录令牌 |
|
||||||
|
| expireAt | Long | 令牌过期时间,Unix 时间戳毫秒 |
|
||||||
|
| user | User | 当前登录用户 |
|
||||||
|
|
||||||
|
## UpdatePasswordRequest
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| oldValue | String | 原密码 |
|
||||||
|
| newValue | String | 新密码 |
|
||||||
|
|
||||||
|
## PhoneVerifyCodeSendRequest
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| phoneNo | String | 手机号,必须为 11 位大陆手机号 |
|
||||||
|
|
||||||
|
## PhoneVerifyRequest
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| phoneNo | String | 手机号,必须为 11 位大陆手机号 |
|
||||||
|
| verifyCode | String | 6 位数字验证码 |
|
||||||
|
|
||||||
|
## CancelRequest
|
||||||
|
|
||||||
|
| 字段 | 类型 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| password | String | 当前密码,用于确认注销 |
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
### PermissionController 接口测试
|
||||||
|
### 在 IDEA 中选择 dev 或 prod 环境后执行
|
||||||
|
|
||||||
|
@user_token =
|
||||||
|
@permissionId =
|
||||||
|
@permissionCode = TEST_PERMISSION
|
||||||
|
@permissionNameLangId = permission.test.name
|
||||||
|
@permissionDescription = 测试权限
|
||||||
|
@moduleCode = CORE
|
||||||
|
|
||||||
|
### 分页查询权限
|
||||||
|
### 权限:需要 PERMISSION_READ 权限
|
||||||
|
### 前置条件:需要先登录并回填 `user_token`
|
||||||
|
### 请求参数:Page<Permission>,详见 ./http/object/permission.md
|
||||||
|
### 返回参数:PageResult<Permission>,详见 ./http/object/permission.md
|
||||||
|
POST {{baseUrl}}/user/permission/list
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"index": 0,
|
||||||
|
"size": 10,
|
||||||
|
"likesExample": {
|
||||||
|
"code": "{{permissionCode}}",
|
||||||
|
"moduleCode": "{{moduleCode}}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
### 创建权限
|
||||||
|
### 权限:当前代码要求 PERMISSION_READ 权限
|
||||||
|
### 前置条件:需要先登录并回填 `user_token`
|
||||||
|
### 请求参数:Permission,详见 ./http/object/permission.md
|
||||||
|
### 返回参数:无
|
||||||
|
POST {{baseUrl}}/user/permission/create
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"moduleCode": "{{moduleCode}}",
|
||||||
|
"code": "{{permissionCode}}",
|
||||||
|
"nameLangId": "{{permissionNameLangId}}",
|
||||||
|
"description": "{{permissionDescription}}"
|
||||||
|
}
|
||||||
|
|
||||||
|
### 批量创建权限
|
||||||
|
### 权限:需要 PERMISSION_CREATE 权限
|
||||||
|
### 前置条件:需要先登录并回填 `user_token`
|
||||||
|
### 请求参数:BatchCreateReq,详见 ./http/object/permission.md
|
||||||
|
### 返回参数:无
|
||||||
|
POST {{baseUrl}}/user/permission/create/batch
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"moduleCode": "{{moduleCode}}",
|
||||||
|
"prefixCode": "ROLE",
|
||||||
|
"prefixName": "角色",
|
||||||
|
"types": ["CREATE", "READ", "UPDATE", "DELETE"]
|
||||||
|
}
|
||||||
|
|
||||||
|
### 更新权限
|
||||||
|
### 权限:需要 PERMISSION_UPDATE 权限
|
||||||
|
### 前置条件:需要先登录并回填 `user_token`,`id` 必须存在
|
||||||
|
### 请求参数:Permission,详见 ./http/object/permission.md
|
||||||
|
### 返回参数:无
|
||||||
|
POST {{baseUrl}}/user/permission/update
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"id": "{{permissionId}}",
|
||||||
|
"moduleCode": "{{moduleCode}}",
|
||||||
|
"code": "{{permissionCode}}",
|
||||||
|
"nameLangId": "{{permissionNameLangId}}",
|
||||||
|
"description": "测试权限-已更新"
|
||||||
|
}
|
||||||
|
|
||||||
|
### 删除权限
|
||||||
|
### 权限:需要 PERMISSION_DELETE 权限
|
||||||
|
### 前置条件:需要先登录并回填 `user_token`,URL 参数 `id` 必须传有效权限 ID
|
||||||
|
### 请求参数:无请求体,URL 参数:`id` 为权限 ID
|
||||||
|
### 返回参数:无
|
||||||
|
POST {{baseUrl}}/user/permission/delete?id={{permissionId}}
|
||||||
|
Token: {{user_token}}
|
||||||
@@ -0,0 +1,113 @@
|
|||||||
|
### RoleController 接口测试
|
||||||
|
### 在 IDEA 中选择 dev 或 prod 环境后执行
|
||||||
|
|
||||||
|
@permissionId =
|
||||||
|
@roleId =
|
||||||
|
@roleCode = TEST_ROLE
|
||||||
|
@roleNameLangId = role.test.name
|
||||||
|
@roleDescription = 测试角色
|
||||||
|
@childRoleId =
|
||||||
|
@authorizedUserId =
|
||||||
|
@moduleCode = CORE
|
||||||
|
|
||||||
|
### 分页查询角色
|
||||||
|
### 权限:需要 ADMIN 角色 + ROLE_READ 权限
|
||||||
|
### 前置条件:需要先登录并回填 `user_token`
|
||||||
|
### 请求参数:Page<Role>,详见 ./http/object/role.md
|
||||||
|
### 返回参数:PageResult<Role>,详见 ./http/object/role.md
|
||||||
|
POST {{baseUrl}}/user/role/list
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"index": 0,
|
||||||
|
"size": 16,
|
||||||
|
"likesExample": {
|
||||||
|
"moduleCode": "{{moduleCode}}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
### 查询角色详情
|
||||||
|
### 权限:需要 ADMIN 角色 + ROLE_READ 权限
|
||||||
|
### 前置条件:需要先登录并回填 `user_token`,URL 参数 `id` 必须传有效角色 ID
|
||||||
|
### 请求参数:无请求体,URL 参数:`id` 为角色 ID
|
||||||
|
### 返回参数:Role,详见 ./http/object/role.md
|
||||||
|
POST {{baseUrl}}/user/role/detail?id={{roleId}}
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
### 创建角色
|
||||||
|
### 权限:需要 ADMIN 角色 + ROLE_CREATE 权限
|
||||||
|
### 前置条件:需要先登录并回填 `user_token`
|
||||||
|
### 请求参数:Role,详见 ./http/object/role.md
|
||||||
|
### 返回参数:无
|
||||||
|
POST {{baseUrl}}/user/role/create
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"moduleCode": "{{moduleCode}}",
|
||||||
|
"code": "{{roleCode}}",
|
||||||
|
"nameLangId": "{{roleNameLangId}}",
|
||||||
|
"description": "{{roleDescription}}",
|
||||||
|
"permissionIdList": ["{{permissionId}}"],
|
||||||
|
"childRoleIdList": []
|
||||||
|
}
|
||||||
|
|
||||||
|
### 更新角色
|
||||||
|
### 权限:需要 ADMIN 角色 + ROLE_UPDATE 权限
|
||||||
|
### 前置条件:需要先登录并回填 `user_token`,`id` 必须存在
|
||||||
|
### 请求参数:Role,详见 ./http/object/role.md
|
||||||
|
### 返回参数:无
|
||||||
|
POST {{baseUrl}}/user/role/update
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"id": "{{roleId}}",
|
||||||
|
"moduleCode": "{{moduleCode}}",
|
||||||
|
"code": "{{roleCode}}",
|
||||||
|
"nameLangId": "{{roleNameLangId}}",
|
||||||
|
"description": "测试角色-已更新",
|
||||||
|
"permissionIdList": ["{{permissionId}}"],
|
||||||
|
"childRoleIdList": ["{{childRoleId}}"]
|
||||||
|
}
|
||||||
|
|
||||||
|
### 删除角色
|
||||||
|
### 权限:需要 ADMIN 角色 + ROLE_DELETE 权限
|
||||||
|
### 前置条件:需要先登录并回填 `user_token`,URL 参数 `id` 必须传有效角色 ID
|
||||||
|
### 请求参数:无请求体,URL 参数:`id` 为角色 ID
|
||||||
|
### 返回参数:无
|
||||||
|
POST {{baseUrl}}/user/role/delete?id={{roleId}}
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
### 查询用户角色
|
||||||
|
### 权限:需要 ADMIN 角色 + USER_ROLE_READ 权限
|
||||||
|
### 前置条件:需要先登录并回填 `user_token`,URL 参数 `userId` 必须传有效用户 ID
|
||||||
|
### 请求参数:无请求体,URL 参数:`userId` 为用户 ID
|
||||||
|
### 返回参数:List<Role>,详见 ./http/object/role.md
|
||||||
|
POST {{baseUrl}}/user/role/authorized/list?userId={{authorizedUserId}}
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
### 设置用户角色
|
||||||
|
### 权限:需要 ADMIN 角色 + 同时具备 USER_ROLE_CREATE 和 USER_ROLE_DELETE 权限
|
||||||
|
### 前置条件:需要先登录并回填 `user_token`
|
||||||
|
### 请求参数:UserRoleAuthorizeReq,详见 ./http/object/role.md
|
||||||
|
### 返回参数:无
|
||||||
|
POST {{baseUrl}}/user/role/authorized/create
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"userId": "{{authorizedUserId}}",
|
||||||
|
"moduleCode": "{{moduleCode}}",
|
||||||
|
"roleIdList": ["{{roleId}}"],
|
||||||
|
"roleCodeList": ["{{roleCode}}"]
|
||||||
|
}
|
||||||
|
|
||||||
|
### 查询用户已授权权限
|
||||||
|
### 权限:需要 ADMIN 角色 + USER_ROLE_READ 权限
|
||||||
|
### 前置条件:需要先登录并回填 `user_token`,URL 参数 `userId` 必须传有效用户 ID
|
||||||
|
### 请求参数:无请求体,URL 参数:`userId` 为用户 ID
|
||||||
|
### 返回参数:List<Permission>,详见 ./http/object/permission.md
|
||||||
|
POST {{baseUrl}}/user/role/authorized/permission?userId={{authorizedUserId}}
|
||||||
|
Token: {{user_token}}
|
||||||
@@ -0,0 +1,186 @@
|
|||||||
|
### UserController 接口测试
|
||||||
|
### 在 IDEA 中选择 dev 或 prod 环境后执行
|
||||||
|
|
||||||
|
@userId =
|
||||||
|
@name = System
|
||||||
|
@password = u#HA027xq$i9]P}uB]LweJspTb!3oS^.
|
||||||
|
@newPassword = qwe123
|
||||||
|
@nick = 测试用户
|
||||||
|
@email = test@example.com
|
||||||
|
|
||||||
|
### 分页查询用户
|
||||||
|
### 权限:需要 ADMIN 角色 + USER_READ 权限
|
||||||
|
### 前置条件:需要先登录并回填 `user_token`
|
||||||
|
### 请求参数:Page<User>,详见 ./http/object/user.md
|
||||||
|
### 返回参数:PageResult<User>,详见 ./http/object/user.md
|
||||||
|
POST {{baseUrl}}/user/list
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"index": 0,
|
||||||
|
"size": 16
|
||||||
|
}
|
||||||
|
|
||||||
|
### 查询用户详情
|
||||||
|
### 权限:需要 ADMIN 角色 + USER_READ 权限
|
||||||
|
### 前置条件:需要先登录并回填 `user_token`,URL 参数 `id` 必须传有效用户 ID
|
||||||
|
### 请求参数:无请求体,URL 参数:`id` 为用户 ID
|
||||||
|
### 返回参数:User,详见 ./http/object/user.md
|
||||||
|
POST {{baseUrl}}/user/detail?id={{userId}}
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
### 创建用户
|
||||||
|
### 权限:需要 ADMIN 角色 + USER_CREATE 权限
|
||||||
|
### 前置条件:需要先登录并回填 `user_token`,重复用户名通常会失败
|
||||||
|
### 请求参数:User,详见 ./http/object/user.md
|
||||||
|
### 返回参数:无
|
||||||
|
POST {{baseUrl}}/user/create
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": "{{name}}",
|
||||||
|
"nick": "{{nick}}",
|
||||||
|
"email": "{{email}}",
|
||||||
|
"phoneNo": "13800138000",
|
||||||
|
"password": "{{password}}"
|
||||||
|
}
|
||||||
|
|
||||||
|
### 更新用户
|
||||||
|
### 权限:需要 ADMIN 角色 + USER_UPDATE 权限
|
||||||
|
### 前置条件:需要先登录并回填 `user_token`,`id` 必须存在
|
||||||
|
### 请求参数:User,详见 ./http/object/user.md
|
||||||
|
### 返回参数:无
|
||||||
|
POST {{baseUrl}}/user/update
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"id": "{{userId}}",
|
||||||
|
"name": "{{name}}",
|
||||||
|
"nick": "{{nick}}",
|
||||||
|
"email": "{{email}}",
|
||||||
|
"phoneNo": "13800138000"
|
||||||
|
}
|
||||||
|
|
||||||
|
### 删除用户
|
||||||
|
### 权限:需要 ADMIN 角色
|
||||||
|
### 前置条件:需要先登录并回填 `user_token`,URL 参数 `id` 必须传有效用户 ID
|
||||||
|
### 请求参数:无请求体,URL 参数:`id` 为用户 ID
|
||||||
|
### 返回参数:无
|
||||||
|
POST {{baseUrl}}/user/delete?id={{userId}}
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
### 注册
|
||||||
|
### 权限:无需登录
|
||||||
|
### 前置条件:重复用户名通常会失败
|
||||||
|
### 请求参数:User,详见 ./http/object/user.md
|
||||||
|
### 返回参数:LoginResponse,详见 ./http/object/user.md
|
||||||
|
POST {{baseUrl}}/user/register
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"name": "Test",
|
||||||
|
"nick": "测试用户",
|
||||||
|
"phoneNo": "13800138000",
|
||||||
|
"password": "qwe123"
|
||||||
|
}
|
||||||
|
|
||||||
|
### 登录
|
||||||
|
### 权限:无需登录
|
||||||
|
### 前置条件:成功后需要把响应中的 token 回填到 `user_token`
|
||||||
|
### 请求参数:LoginRequest,详见 ./http/object/user.md
|
||||||
|
### 返回参数:LoginResponse,详见 ./http/object/user.md
|
||||||
|
POST {{baseUrl}}/user/login
|
||||||
|
Content-Type: application/json
|
||||||
|
|
||||||
|
{
|
||||||
|
"user": "{{name}}",
|
||||||
|
"password": "{{password}}"
|
||||||
|
}
|
||||||
|
|
||||||
|
> {%
|
||||||
|
client.global.set("user_token", response.body?.data?.token)
|
||||||
|
%}
|
||||||
|
|
||||||
|
### 令牌登录
|
||||||
|
### 权限:需要有效 Token
|
||||||
|
### 前置条件:需要先登录并回填 `user_token`
|
||||||
|
### 请求参数:无
|
||||||
|
### 返回参数:LoginResponse,详见 ./http/object/user.md
|
||||||
|
GET {{baseUrl}}/user/login/token
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
### 登出
|
||||||
|
### 权限:当前控制器未声明 RequiredToken/权限注解,按服务端实际会话处理
|
||||||
|
### 前置条件:当前接口通常用于退出当前登录态
|
||||||
|
### 请求参数:无
|
||||||
|
### 返回参数:无
|
||||||
|
POST {{baseUrl}}/user/logout
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
### 修改当前用户密码
|
||||||
|
### 权限:需要 USER_UPDATE 权限
|
||||||
|
### 前置条件:需要先登录并回填 `user_token`
|
||||||
|
### 请求参数:UpdatePasswordRequest,详见 ./http/object/user.md
|
||||||
|
### 返回参数:无
|
||||||
|
POST {{baseUrl}}/user/update/password
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"oldValue": "{{password}}",
|
||||||
|
"newValue": "{{newPassword}}"
|
||||||
|
}
|
||||||
|
|
||||||
|
### 修改当前用户邮箱
|
||||||
|
### 权限:需要 USER_UPDATE 权限
|
||||||
|
### 前置条件:当前方法体为空,接口尚未实现
|
||||||
|
### 请求参数:无
|
||||||
|
### 返回参数:无
|
||||||
|
POST {{baseUrl}}/user/update/email
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{}
|
||||||
|
|
||||||
|
### 发送当前用户手机号验证码
|
||||||
|
### 权限:需要 USER_UPDATE 权限
|
||||||
|
### 前置条件:需要先登录并回填 `user_token`
|
||||||
|
### 请求参数:PhoneVerifyCodeSendRequest,详见 ./http/object/user.md
|
||||||
|
### 返回参数:无
|
||||||
|
POST {{baseUrl}}/user/phone/verify/send
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"phoneNo": "13800138000"
|
||||||
|
}
|
||||||
|
|
||||||
|
### 验证当前用户手机号
|
||||||
|
### 权限:需要 USER_UPDATE 权限
|
||||||
|
### 前置条件:需要先调用手机号验证码发送接口获取验证码
|
||||||
|
### 请求参数:PhoneVerifyRequest,详见 ./http/object/user.md
|
||||||
|
### 返回参数:无
|
||||||
|
POST {{baseUrl}}/user/phone/verify
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"phoneNo": "13800138000",
|
||||||
|
"verifyCode": "123456"
|
||||||
|
}
|
||||||
|
|
||||||
|
### 注销当前用户
|
||||||
|
### 权限:需要 USER_DELETE 权限
|
||||||
|
### 前置条件:需要先登录并回填 `user_token`
|
||||||
|
### 请求参数:CancelRequest,详见 ./http/object/user.md
|
||||||
|
### 返回参数:无
|
||||||
|
POST {{baseUrl}}/user/cancel
|
||||||
|
Content-Type: application/json
|
||||||
|
Token: {{user_token}}
|
||||||
|
|
||||||
|
{
|
||||||
|
"password": "{{password}}"
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
<groupId>com.imyeyu.timiserverapi</groupId>
|
<groupId>com.imyeyu.timiserverapi</groupId>
|
||||||
<artifactId>TimiServerAPI</artifactId>
|
<artifactId>TimiServerAPI</artifactId>
|
||||||
<version>1.0.81</version>
|
<version>1.0.12</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>TimiServerAPI</name>
|
<name>TimiServerAPI</name>
|
||||||
<description>imyeyu.com API</description>
|
<description>imyeyu.com API</description>
|
||||||
@@ -167,42 +167,13 @@
|
|||||||
<enabled>true</enabled>
|
<enabled>true</enabled>
|
||||||
</snapshots>
|
</snapshots>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
|
||||||
<id>e2ins_nexus</id>
|
|
||||||
<url>https://nexus.e2ins.com/repository/maven-public/</url>
|
|
||||||
<releases>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</releases>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
|
||||||
<groupId>com.openhtmltopdf</groupId>
|
|
||||||
<artifactId>openhtmltopdf-pdfbox</artifactId>
|
|
||||||
<version>1.0.10</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.groovy</groupId>
|
|
||||||
<artifactId>groovy</artifactId>
|
|
||||||
<version>4.0.29</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.imyeyu.spring</groupId>
|
<groupId>com.imyeyu.spring</groupId>
|
||||||
<artifactId>timi-spring</artifactId>
|
<artifactId>timi-spring</artifactId>
|
||||||
<version>0.0.20</version>
|
<version>0.0.19</version>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springdoc</groupId>
|
|
||||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
|
||||||
<version>2.10.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-freemarker</artifactId>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.imyeyu.network</groupId>
|
<groupId>com.imyeyu.network</groupId>
|
||||||
@@ -217,32 +188,17 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.imyeyu.java</groupId>
|
<groupId>com.imyeyu.java</groupId>
|
||||||
<artifactId>timi-java</artifactId>
|
<artifactId>timi-java</artifactId>
|
||||||
<version>0.0.11</version>
|
<version>0.0.7</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.imyeyu.utils</groupId>
|
<groupId>com.imyeyu.utils</groupId>
|
||||||
<artifactId>timi-utils</artifactId>
|
<artifactId>timi-utils</artifactId>
|
||||||
<version>0.0.13</version>
|
<version>0.0.13</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>me.majiajie</groupId>
|
|
||||||
<artifactId>tinypinyin</artifactId>
|
|
||||||
<version>2.0.3</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.6tail</groupId>
|
|
||||||
<artifactId>lunar</artifactId>
|
|
||||||
<version>1.7.8</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.hankcs</groupId>
|
|
||||||
<artifactId>hanlp</artifactId>
|
|
||||||
<version>portable-1.8.4</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.imyeyu.font.icon</groupId>
|
<groupId>com.imyeyu.font.icon</groupId>
|
||||||
<artifactId>timi-icon-font</artifactId>
|
<artifactId>timi-icon-font</artifactId>
|
||||||
<version>0.0.3</version>
|
<version>0.0.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
@@ -256,12 +212,6 @@
|
|||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.h2database</groupId>
|
|
||||||
<artifactId>h2</artifactId>
|
|
||||||
<version>2.3.232</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mariadb.jdbc</groupId>
|
<groupId>org.mariadb.jdbc</groupId>
|
||||||
<artifactId>mariadb-java-client</artifactId>
|
<artifactId>mariadb-java-client</artifactId>
|
||||||
@@ -275,15 +225,6 @@
|
|||||||
<groupId>org.flywaydb</groupId>
|
<groupId>org.flywaydb</groupId>
|
||||||
<artifactId>flyway-mysql</artifactId>
|
<artifactId>flyway-mysql</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.tencentcloudapi</groupId>
|
|
||||||
<artifactId>tencentcloud-sdk-java-sms</artifactId>
|
|
||||||
<version>3.1.1281</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-mail</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-freemarker</artifactId>
|
<artifactId>spring-boot-starter-freemarker</artifactId>
|
||||||
|
|||||||
@@ -1,124 +0,0 @@
|
|||||||
<#
|
|
||||||
.SYNOPSIS
|
|
||||||
导出本地 OpenAPI 文档。
|
|
||||||
|
|
||||||
.DESCRIPTION
|
|
||||||
从本地已启动的服务获取 /v3/api-docs.yaml(或 JSON),写入 docs 目录。
|
|
||||||
默认同时生成面向 AI Agent 的接口索引 docs/openapi.index.md。
|
|
||||||
生成的 OpenAPI 快照已被 .gitignore 忽略;索引文件可按需提交或单独发送。
|
|
||||||
|
|
||||||
.PARAMETER BaseUrl
|
|
||||||
服务地址,默认 http://localhost:18092。
|
|
||||||
|
|
||||||
.PARAMETER OutFile
|
|
||||||
输出文件路径,默认 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]$IndexFile,
|
|
||||||
[switch]$NoIndex
|
|
||||||
)
|
|
||||||
|
|
||||||
$ErrorActionPreference = "Stop"
|
|
||||||
$RootDir = Split-Path -Parent $PSScriptRoot
|
|
||||||
|
|
||||||
if ([string]::IsNullOrWhiteSpace($OutFile)) {
|
|
||||||
$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)) {
|
|
||||||
New-Item -ItemType Directory -Path $OutDir -Force | Out-Null
|
|
||||||
}
|
|
||||||
|
|
||||||
if ([System.IO.Path]::GetExtension($OutFile) -ieq ".json") {
|
|
||||||
$ApiPath = "/v3/api-docs"
|
|
||||||
} else {
|
|
||||||
$ApiPath = "/v3/api-docs.yaml"
|
|
||||||
}
|
|
||||||
|
|
||||||
$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,79 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# 导出本地 OpenAPI 文档,并默认生成面向 AI Agent 的接口索引。
|
|
||||||
#
|
|
||||||
# 用法:
|
|
||||||
# scripts/export-openapi.sh [baseUrl] [outFile] [indexFile]
|
|
||||||
#
|
|
||||||
# 输出文件扩展名为 .json 时导出 JSON,否则导出 YAML。
|
|
||||||
# 索引默认输出到 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")"
|
|
||||||
|
|
||||||
case "$OUT_FILE" in
|
|
||||||
*.json)
|
|
||||||
API_PATH="/v3/api-docs"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
API_PATH="/v3/api-docs.yaml"
|
|
||||||
;;
|
|
||||||
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
|
|
||||||
@@ -1,356 +0,0 @@
|
|||||||
#!/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())
|
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
# GAO 门店智能助手 Dify DSL 配置说明
|
|
||||||
|
|
||||||
`main_agent.yml` 是 Advanced Chat 应用,支持:
|
|
||||||
|
|
||||||
- 知识库规则回答
|
|
||||||
- 实时业务查询 Agent
|
|
||||||
- 规则 + 实时数据混合分析
|
|
||||||
- 带预览和人工确认的写操作
|
|
||||||
|
|
||||||
## 1. MCP Provider
|
|
||||||
|
|
||||||
导入 DSL 后需要配置两个 MCP Provider。
|
|
||||||
|
|
||||||
| DSL 中的 Provider | 后端地址 | 服务密钥 |
|
|
||||||
|---|---|---|
|
|
||||||
| `gao-mcp-server-dev` | `http(s)://<backend>/mcp/gao-ai` | 系统设置 `DIFY_MCP_SERVICE_KEY` |
|
|
||||||
| `gao-mcp-commit-dev` | `http(s)://<backend>/mcp/gao-ai-commit` | 系统设置 `DIFY_MCP_COMMIT_SERVICE_KEY` |
|
|
||||||
|
|
||||||
要求:
|
|
||||||
|
|
||||||
1. `gao-mcp-server-dev` 只暴露查询工具和 `operation_prepare`。
|
|
||||||
2. `gao-mcp-commit-dev` 只暴露 `operation_commit`、`operation_cancel`。
|
|
||||||
3. **提交 Provider 不得绑定到任何 Agent 节点**,只允许 `main_agent.yml` 中的确定性工具节点调用。
|
|
||||||
4. 如果 Dify 中的 Provider ID 与 DSL 不一致,请同时修改 DSL 中 `commit_tool`、`cancel_tool`、`prepare_tool` 的 `provider_id` 和 `provider_name`。
|
|
||||||
|
|
||||||
## 2. 写能力开关
|
|
||||||
|
|
||||||
后端默认关闭写能力:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
gao:
|
|
||||||
ai:
|
|
||||||
write:
|
|
||||||
enabled: true
|
|
||||||
confirmation-ttl-seconds: 600
|
|
||||||
result-ttl-seconds: 1800
|
|
||||||
max-prepares-per-10-minutes: 10
|
|
||||||
max-commits-per-10-minutes: 10
|
|
||||||
order-max-sale-amount: 1000000
|
|
||||||
order-max-discount-rate: 0.30
|
|
||||||
point-adjust-max-abs: 10000
|
|
||||||
stock-change-max-quantity: 1000
|
|
||||||
attachment-max-count: 10
|
|
||||||
attachment-max-size-mb: 10
|
|
||||||
attachment-ttl-seconds: 86400
|
|
||||||
```
|
|
||||||
|
|
||||||
## 3. 附件
|
|
||||||
|
|
||||||
Dify 内置文件上传保持关闭。前端流程:
|
|
||||||
|
|
||||||
1. 调用 `POST /gao/ai/attachment/upload` 上传凭证,获得 `token`。
|
|
||||||
2. 聊天请求携带 `attachmentTokenList`。
|
|
||||||
3. 后端把附件 token 注入 Dify start 输入 `attachmentTokensJson`。
|
|
||||||
4. `operation_prepare` 解析并校验附件,token 不进入模型提示词。
|
|
||||||
|
|
||||||
## 4. 确认流程
|
|
||||||
|
|
||||||
### 文本确认
|
|
||||||
|
|
||||||
1. 用户发起写操作。
|
|
||||||
2. `operation_prepare` 返回 `PENDING_CONFIRMATION`、`previewText`、`requiredPhrase`。
|
|
||||||
3. 下一轮聊天后端注入 `pendingOperationToken` 等 start 输入。
|
|
||||||
4. `pending_gate` 判断是否存在待确认操作。
|
|
||||||
5. `pending_action` 规则判断确认/取消。
|
|
||||||
6. 确认时调用 `operation_commit`;取消时调用 `operation_cancel`。
|
|
||||||
|
|
||||||
### 卡片确认
|
|
||||||
|
|
||||||
1. 后端在 SSE 结束前推送 `operation_preview`。
|
|
||||||
2. 卡片调用 `GET /gao/ai/operation/pending` 恢复状态。
|
|
||||||
3. 确认调用 `POST /gao/ai/operation/commit`。
|
|
||||||
4. 取消调用 `POST /gao/ai/operation/cancel`。
|
|
||||||
|
|
||||||
卡片使用公开 `operationId`,确认 token 不进入浏览器。
|
|
||||||
|
|
||||||
## 5. 安全边界
|
|
||||||
|
|
||||||
- 模型不可传 `storeId`、`operatorUserId`、`requestNo`、`confirmationToken`。
|
|
||||||
- 提交工具只接受确认 token,不接受业务参数。
|
|
||||||
- 破坏性和敏感操作必须精确短语,并重新校验权限、门店、价格、库存和状态。
|
|
||||||
- 物理删除不在操作注册表中。
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,35 @@
|
|||||||
|
package com.imyeyu.api.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启用配置注解
|
||||||
|
*
|
||||||
|
* @author 夜雨
|
||||||
|
* @since 2023-07-15 10:00
|
||||||
|
*/
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface EnableSetting {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author 夜雨
|
||||||
|
* @since 2026-04-27 14:45
|
||||||
|
*/
|
||||||
|
enum Logic {
|
||||||
|
|
||||||
|
AND,
|
||||||
|
|
||||||
|
OR
|
||||||
|
}
|
||||||
|
|
||||||
|
Logic logic() default Logic.AND;
|
||||||
|
|
||||||
|
/** @return 未启用配置时响应消息语言映射键 */
|
||||||
|
String message() default "service.offline";
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.imyeyu.api.annotation;
|
||||||
|
|
||||||
|
import com.imyeyu.api.modules.common.service.SettingService;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.context.annotation.Lazy;
|
||||||
|
import org.springframework.lang.NonNull;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.method.HandlerMethod;
|
||||||
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 启用配置注解处理器
|
||||||
|
*
|
||||||
|
* @author 夜雨
|
||||||
|
* @since 2023-07-15 10:01
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@RequiredArgsConstructor(onConstructor_ = {@Lazy})
|
||||||
|
public class EnableSettingInterceptor implements HandlerInterceptor {
|
||||||
|
|
||||||
|
private final SettingService service;
|
||||||
|
|
||||||
|
public boolean preHandle(@NonNull HttpServletRequest req, @NonNull HttpServletResponse resp, @NonNull Object handler) throws InvocationTargetException, IllegalAccessException {
|
||||||
|
if (handler instanceof HandlerMethod handlerMethod) {
|
||||||
|
EnableSetting annotation = handlerMethod.getMethodAnnotation(EnableSetting.class);
|
||||||
|
if (annotation == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
EnableSetting.Logic logic = annotation.logic();
|
||||||
|
List<Boolean> valueList = new ArrayList<>();
|
||||||
|
for (Method method : annotation.getClass().getMethods()) {
|
||||||
|
if (method.getName().equals("message")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Enum<?>[] enums = (Enum<?>[]) method.invoke(annotation);
|
||||||
|
for (Enum<?> anEnum : enums) {
|
||||||
|
valueList.add(service.getSystem(anEnum).isTrue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (logic == EnableSetting.Logic.AND) {
|
||||||
|
return valueList.stream().allMatch(Boolean::booleanValue);
|
||||||
|
} else {
|
||||||
|
return valueList.stream().anyMatch(Boolean::booleanValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,8 +5,6 @@ import com.imyeyu.api.bean.CorePermissionCode;
|
|||||||
import com.imyeyu.api.bean.ModuleCode;
|
import com.imyeyu.api.bean.ModuleCode;
|
||||||
import com.imyeyu.api.modules.user.service.PermissionChecker;
|
import com.imyeyu.api.modules.user.service.PermissionChecker;
|
||||||
import com.imyeyu.java.TimiJava;
|
import com.imyeyu.java.TimiJava;
|
||||||
import com.imyeyu.java.bean.timi.TimiException;
|
|
||||||
import com.imyeyu.spring.annotation.IgnoreGlobalReturn;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.lang.NonNull;
|
import org.springframework.lang.NonNull;
|
||||||
@@ -14,8 +12,6 @@ import org.springframework.stereotype.Component;
|
|||||||
import org.springframework.web.method.HandlerMethod;
|
import org.springframework.web.method.HandlerMethod;
|
||||||
import org.springframework.web.servlet.HandlerInterceptor;
|
import org.springframework.web.servlet.HandlerInterceptor;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// CORE 权限注解处理器
|
/// CORE 权限注解处理器
|
||||||
///
|
///
|
||||||
@@ -36,28 +32,14 @@ public class RequireCorePermissionInterceptor implements HandlerInterceptor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
RequireCorePermission annotation = handlerMethod.getMethodAnnotation(RequireCorePermission.class);
|
RequireCorePermission annotation = handlerMethod.getMethodAnnotation(RequireCorePermission.class);
|
||||||
if (annotation == null) {
|
|
||||||
annotation = handlerMethod.getBeanType().getAnnotation(RequireCorePermission.class);
|
|
||||||
}
|
|
||||||
if (annotation == null || TimiJava.isEmpty(annotation.value())) {
|
if (annotation == null || TimiJava.isEmpty(annotation.value())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
String[] permissionCodeList = java.util.Arrays.stream(annotation.value()).map(CorePermissionCode::getValue).toArray(String[]::new);
|
String[] permissionCodeList = java.util.Arrays.stream(annotation.value()).map(CorePermissionCode::getValue).toArray(String[]::new);
|
||||||
try {
|
if (annotation.mode() == PermissionMatchMode.ANY) {
|
||||||
if (annotation.mode() == PermissionMatchMode.ANY) {
|
permissionChecker.checkAny(ModuleCode.CORE, permissionCodeList);
|
||||||
permissionChecker.checkAny(ModuleCode.CORE, permissionCodeList);
|
} else {
|
||||||
} else {
|
permissionChecker.checkAll(ModuleCode.CORE, permissionCodeList);
|
||||||
permissionChecker.checkAll(ModuleCode.CORE, permissionCodeList);
|
|
||||||
}
|
|
||||||
} catch (TimiException e) {
|
|
||||||
if (handlerMethod.hasMethodAnnotation(IgnoreGlobalReturn.class) && !resp.isCommitted()) {
|
|
||||||
try {
|
|
||||||
resp.sendError(HttpServletResponse.SC_FORBIDDEN, e.getMessage());
|
|
||||||
} catch (IOException ignored) {
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
package com.imyeyu.api.annotation;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
///
|
|
||||||
///
|
|
||||||
/// @author 夜雨
|
|
||||||
/// @since 2026-09-08 15:22
|
|
||||||
@Target(ElementType.TYPE)
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
public @interface SettingBizType {
|
|
||||||
|
|
||||||
String value();
|
|
||||||
}
|
|
||||||
@@ -45,35 +45,11 @@ public enum CorePermissionCode implements BuiltinPermissionCode {
|
|||||||
TAG_UPDATE("TAG:UPDATE", "标签修改", false, true),
|
TAG_UPDATE("TAG:UPDATE", "标签修改", false, true),
|
||||||
TAG_DELETE("TAG:DELETE", "标签删除", false, true),
|
TAG_DELETE("TAG:DELETE", "标签删除", false, true),
|
||||||
|
|
||||||
ARTICLE_CREATE("ARTICLE:CREATE", "文章创建", false, true),
|
|
||||||
ARTICLE_READ("ARTICLE:READ", "文章读取", false, true),
|
|
||||||
ARTICLE_UPDATE("ARTICLE:UPDATE", "文章修改", false, true),
|
|
||||||
ARTICLE_DELETE("ARTICLE:DELETE", "文章删除", false, true),
|
|
||||||
|
|
||||||
USER_CREATE("USER:CREATE", "用户创建", false, true),
|
USER_CREATE("USER:CREATE", "用户创建", false, true),
|
||||||
USER_READ("USER:READ", "用户读取", false, true),
|
USER_READ("USER:READ", "用户读取", false, true),
|
||||||
USER_UPDATE("USER:UPDATE", "用户修改", false, true),
|
USER_UPDATE("USER:UPDATE", "用户修改", false, true),
|
||||||
USER_DELETE("USER:DELETE", "用户删除", false, true),
|
USER_DELETE("USER:DELETE", "用户删除", false, true),
|
||||||
|
|
||||||
API_KEY_CREATE("API_KEY:CREATE", "API 密钥创建", false, true),
|
|
||||||
API_KEY_READ("API_KEY:READ", "API 密钥读取", false, true),
|
|
||||||
API_KEY_DELETE("API_KEY:DELETE", "API 密钥删除", false, true),
|
|
||||||
|
|
||||||
FEEDBACK_CREATE("FEEDBACK:CREATE", "反馈创建", false, true),
|
|
||||||
FEEDBACK_READ("FEEDBACK:READ", "反馈读取", false, true),
|
|
||||||
FEEDBACK_UPDATE("FEEDBACK:UPDATE", "反馈修改", false, true),
|
|
||||||
FEEDBACK_DELETE("FEEDBACK:DELETE", "反馈删除", false, true),
|
|
||||||
|
|
||||||
NOTIFY_CREATE("NOTIFY:CREATE", "通知创建", false, true),
|
|
||||||
NOTIFY_READ("NOTIFY:READ", "通知读取", false, true),
|
|
||||||
NOTIFY_DELETE("NOTIFY:DELETE", "通知删除", false, true),
|
|
||||||
NOTIFY_CANCEL("NOTIFY:CANCEL", "通知取消", false, true),
|
|
||||||
|
|
||||||
FILE_READ("FILE:READ", "文件读取", false, true),
|
|
||||||
FILE_WRITE("FILE:WRITE", "文件写入", false, true),
|
|
||||||
FILE_DELETE("FILE:DELETE", "文件删除", false, true),
|
|
||||||
FILE_SHARE("FILE:SHARE", "文件分享", false, true),
|
|
||||||
|
|
||||||
USER_ROLE_CREATE("USER_ROLE:CREATE", "用户角色创建", true, true),
|
USER_ROLE_CREATE("USER_ROLE:CREATE", "用户角色创建", true, true),
|
||||||
USER_ROLE_READ("USER_ROLE:READ", "用户角色读取", true, true),
|
USER_ROLE_READ("USER_ROLE:READ", "用户角色读取", true, true),
|
||||||
USER_ROLE_DELETE("USER_ROLE:DELETE", "用户角色删除", true, true);
|
USER_ROLE_DELETE("USER_ROLE:DELETE", "用户角色删除", true, true);
|
||||||
|
|||||||
@@ -10,6 +10,4 @@ public enum ModuleCode {
|
|||||||
CORE,
|
CORE,
|
||||||
|
|
||||||
GAO,
|
GAO,
|
||||||
|
|
||||||
APP,
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,36 +0,0 @@
|
|||||||
package com.imyeyu.api.bean;
|
|
||||||
|
|
||||||
import com.imyeyu.api.annotation.SettingBizType;
|
|
||||||
import com.imyeyu.api.modules.common.entity.Setting;
|
|
||||||
import com.imyeyu.utils.Text;
|
|
||||||
|
|
||||||
///
|
|
||||||
///
|
|
||||||
/// @author 夜雨
|
|
||||||
/// @since 2026-09-08 15:18
|
|
||||||
public interface SettingEnum {
|
|
||||||
|
|
||||||
default String getBizType() {
|
|
||||||
Class<? extends SettingEnum> implEnum = getClass();
|
|
||||||
SettingBizType bizType = implEnum.getAnnotation(SettingBizType.class);
|
|
||||||
if (bizType == null) {
|
|
||||||
return Text.bizClassName(implEnum);
|
|
||||||
}
|
|
||||||
return bizType.value();
|
|
||||||
}
|
|
||||||
|
|
||||||
String name();
|
|
||||||
|
|
||||||
String getDefaultValue();
|
|
||||||
|
|
||||||
Setting.ValueType getValueType();
|
|
||||||
|
|
||||||
/// 配置作用域
|
|
||||||
///
|
|
||||||
/// 业务级配置由业务对象自己维护,启动时不初始化记录
|
|
||||||
///
|
|
||||||
/// @return 配置作用域
|
|
||||||
default Setting.Scope getScope() {
|
|
||||||
return Setting.Scope.SYSTEM;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -4,6 +4,8 @@ import com.fasterxml.jackson.annotation.JsonInclude;
|
|||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.MapperFeature;
|
import com.fasterxml.jackson.databind.MapperFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
|
||||||
|
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
|
||||||
import com.fasterxml.jackson.databind.json.JsonMapper;
|
import com.fasterxml.jackson.databind.json.JsonMapper;
|
||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
import com.imyeyu.utils.Time;
|
import com.imyeyu.utils.Time;
|
||||||
|
|||||||
@@ -1,96 +0,0 @@
|
|||||||
package com.imyeyu.api.config;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.models.Components;
|
|
||||||
import io.swagger.v3.oas.models.OpenAPI;
|
|
||||||
import io.swagger.v3.oas.models.info.Info;
|
|
||||||
import io.swagger.v3.oas.models.security.SecurityRequirement;
|
|
||||||
import io.swagger.v3.oas.models.security.SecurityScheme;
|
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
|
||||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
|
||||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
|
||||||
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
|
|
||||||
import org.springframework.http.converter.HttpMessageConverter;
|
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* OpenAPI 接口文档配置
|
|
||||||
*
|
|
||||||
* @author 夜雨
|
|
||||||
* @since 2026-11-24
|
|
||||||
*/
|
|
||||||
@Configuration
|
|
||||||
public class OpenApiConfig {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 移除 timi-spring 默认的全局返回处理器,由 {@link OpenApiGlobalReturnHandler} 替代。
|
|
||||||
*
|
|
||||||
* <p>默认处理器会把所有响应包装为 TimiResponse,导致 SpringDoc 的接口描述无法被 Swagger UI 解析。</p>
|
|
||||||
*
|
|
||||||
* @return Bean 定义注册后处理器
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public static BeanDefinitionRegistryPostProcessor openApiGlobalReturnHandlerReplacer() {
|
|
||||||
return new BeanDefinitionRegistryPostProcessor() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) {
|
|
||||||
for (String beanName : registry.getBeanDefinitionNames()) {
|
|
||||||
BeanDefinition definition = registry.getBeanDefinition(beanName);
|
|
||||||
if ("globalReturnHandler".equals(beanName)
|
|
||||||
|| "com.imyeyu.spring.util.GlobalReturnHandler".equals(definition.getBeanClassName())) {
|
|
||||||
registry.removeBeanDefinition(beanName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 接口文档信息与认证方式
|
|
||||||
*
|
|
||||||
* @return OpenAPI 配置
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public OpenAPI timiServerOpenAPI() {
|
|
||||||
return new OpenAPI()
|
|
||||||
.info(new Info()
|
|
||||||
.title("TimiServerAPI")
|
|
||||||
.description("夜雨综合数据中心接口")
|
|
||||||
.version("1.0.79"))
|
|
||||||
.components(new Components()
|
|
||||||
.addSecuritySchemes("Token", new SecurityScheme()
|
|
||||||
.name("Token")
|
|
||||||
.type(SecurityScheme.Type.APIKEY)
|
|
||||||
.in(SecurityScheme.In.HEADER)
|
|
||||||
.description("登录令牌或 API Key,也可通过 URL 参数 token 传递")))
|
|
||||||
.addSecurityItem(new SecurityRequirement().addList("Token"));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 注册字节数组消息转换器,确保接口文档以原始 JSON 输出。
|
|
||||||
*
|
|
||||||
* <p>项目的消息转换器配置仅注册了 Jackson 转换器,{@code byte[]} 会被序列化为 Base64 字符串,
|
|
||||||
* 导致 Swagger UI 无法解析接口文档。</p>
|
|
||||||
*
|
|
||||||
* @return Web MVC 配置
|
|
||||||
*/
|
|
||||||
@Bean
|
|
||||||
public WebMvcConfigurer openApiByteArrayMessageConverter() {
|
|
||||||
return new WebMvcConfigurer() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
|
|
||||||
converters.add(0, new ByteArrayHttpMessageConverter());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package com.imyeyu.api.config;
|
|
||||||
|
|
||||||
import com.imyeyu.spring.util.GlobalReturnHandler;
|
|
||||||
import org.springframework.core.MethodParameter;
|
|
||||||
import org.springframework.http.converter.HttpMessageConverter;
|
|
||||||
import org.springframework.lang.NonNull;
|
|
||||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 全局返回处理器,跳过 SpringDoc 接口。
|
|
||||||
*
|
|
||||||
* <p>接口文档响应需要保持原始 JSON 结构,不能包装为 TimiResponse。</p>
|
|
||||||
*
|
|
||||||
* @author 夜雨
|
|
||||||
* @since 2026-11-24
|
|
||||||
*/
|
|
||||||
@RestControllerAdvice
|
|
||||||
public class OpenApiGlobalReturnHandler extends GlobalReturnHandler {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean supports(@NonNull MethodParameter returnType, @NonNull Class<? extends HttpMessageConverter<?>> converterType) {
|
|
||||||
Class<?> containingClass = returnType.getContainingClass();
|
|
||||||
if (containingClass != null && containingClass.getName().startsWith("org.springdoc.")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return super.supports(returnType, converterType);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2,10 +2,6 @@ package com.imyeyu.api.config;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.imyeyu.api.modules.common.entity.Multilingual;
|
import com.imyeyu.api.modules.common.entity.Multilingual;
|
||||||
import com.imyeyu.api.modules.gao.ai.entity.GaoAiSession;
|
|
||||||
import com.imyeyu.api.modules.gao.ai.operation.GaoAiAttachmentToken;
|
|
||||||
import com.imyeyu.api.modules.gao.ai.operation.GaoAiPendingOperation;
|
|
||||||
import com.imyeyu.api.modules.gao.bean.GaoUserInviteCache;
|
|
||||||
import com.imyeyu.spring.bean.RedisConfigParams;
|
import com.imyeyu.spring.bean.RedisConfigParams;
|
||||||
import com.imyeyu.spring.config.AbstractRedisConfig;
|
import com.imyeyu.spring.config.AbstractRedisConfig;
|
||||||
import com.imyeyu.spring.util.Redis;
|
import com.imyeyu.spring.util.Redis;
|
||||||
@@ -21,6 +17,11 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
|||||||
import org.springframework.cache.interceptor.KeyGenerator;
|
import org.springframework.cache.interceptor.KeyGenerator;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.core.serializer.support.DeserializingConverter;
|
||||||
|
import org.springframework.core.serializer.support.SerializingConverter;
|
||||||
|
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||||
|
import org.springframework.data.redis.serializer.SerializationException;
|
||||||
|
import org.springframework.lang.Nullable;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
@@ -104,7 +105,31 @@ public class RedisConfig extends AbstractRedisConfig {
|
|||||||
/** @return 多语言环境,ID: {@link Multilingual} */
|
/** @return 多语言环境,ID: {@link Multilingual} */
|
||||||
@Bean("redisLanguage")
|
@Bean("redisLanguage")
|
||||||
public Redis<String, Multilingual> getLanguageRedisTemplate() {
|
public Redis<String, Multilingual> getLanguageRedisTemplate() {
|
||||||
return getRedis(database, RedisSerializers.STRING, RedisSerializers.jacksonSerializer(jackson, Multilingual.class));
|
return getRedis(database, RedisSerializers.STRING, new RedisSerializer<>() {
|
||||||
|
|
||||||
|
public Multilingual deserialize(@Nullable byte[] bytes) {
|
||||||
|
if (bytes == null || bytes.length == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return (Multilingual) new DeserializingConverter().convert(bytes);
|
||||||
|
} catch (Exception var3) {
|
||||||
|
throw new SerializationException("Cannot deserialize", var3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] serialize(@Nullable Multilingual multilingual) {
|
||||||
|
if (multilingual == null) {
|
||||||
|
return new byte[0];
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
return new SerializingConverter().convert(multilingual);
|
||||||
|
} catch (Exception var3) {
|
||||||
|
throw new SerializationException("Cannot serialize", var3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean("redisCaptcha")
|
@Bean("redisCaptcha")
|
||||||
@@ -177,34 +202,4 @@ public class RedisConfig extends AbstractRedisConfig {
|
|||||||
public Redis<String, String> getClipboardRedisTemplate() {
|
public Redis<String, String> getClipboardRedisTemplate() {
|
||||||
return getRedis(database, RedisSerializers.STRING, RedisSerializers.STRING);
|
return getRedis(database, RedisSerializers.STRING, RedisSerializers.STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return GAO 用户邀请,code: 邀请缓存
|
|
||||||
@Bean("redisGaoUserInvite")
|
|
||||||
public Redis<String, GaoUserInviteCache> getGaoUserInviteRedisTemplate() {
|
|
||||||
return getRedis(database, RedisSerializers.STRING, RedisSerializers.jacksonSerializer(jackson, GaoUserInviteCache.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @return AI 会话,AI 会话 ID: 会话授权内容
|
|
||||||
@Bean("redisGaoAiSession")
|
|
||||||
public Redis<String, GaoAiSession> getGaoAiSessionRedisTemplate() {
|
|
||||||
return getRedis(database, RedisSerializers.STRING, RedisSerializers.jacksonSerializer(jackson, GaoAiSession.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @return AI 待确认操作,token 摘要/公开 ID: 待确认操作
|
|
||||||
@Bean("redisGaoAiOperation")
|
|
||||||
public Redis<String, GaoAiPendingOperation> getGaoAiOperationRedisTemplate() {
|
|
||||||
return getRedis(database, RedisSerializers.STRING, RedisSerializers.jacksonSerializer(jackson, GaoAiPendingOperation.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @return AI 待确认操作索引,用户+门店/来源会话: 公开操作 ID
|
|
||||||
@Bean("redisGaoAiOperationIndex")
|
|
||||||
public Redis<String, String> getGaoAiOperationIndexRedisTemplate() {
|
|
||||||
return getRedis(database, RedisSerializers.STRING, RedisSerializers.STRING);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// @return AI 附件凭证,token 摘要: 附件凭证
|
|
||||||
@Bean("redisGaoAiAttachment")
|
|
||||||
public Redis<String, GaoAiAttachmentToken> getGaoAiAttachmentRedisTemplate() {
|
|
||||||
return getRedis(database, RedisSerializers.STRING, RedisSerializers.jacksonSerializer(jackson, GaoAiAttachmentToken.class));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,22 +32,4 @@ public class ThreadPoolConfig {
|
|||||||
executor.initialize();
|
executor.initialize();
|
||||||
return executor;
|
return executor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 创建操作审计线程池
|
|
||||||
///
|
|
||||||
/// @return 操作审计线程池
|
|
||||||
@Bean(name = "auditTaskExecutor")
|
|
||||||
public ThreadPoolTaskExecutor auditTaskExecutor() {
|
|
||||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
|
||||||
executor.setCorePoolSize(4);
|
|
||||||
executor.setMaxPoolSize(8);
|
|
||||||
executor.setQueueCapacity(2000);
|
|
||||||
executor.setKeepAliveSeconds(60);
|
|
||||||
executor.setWaitForTasksToCompleteOnShutdown(true);
|
|
||||||
executor.setAwaitTerminationSeconds(60);
|
|
||||||
executor.setThreadNamePrefix("audit-task-executor-");
|
|
||||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
|
||||||
executor.initialize();
|
|
||||||
return executor;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,11 +6,12 @@ import com.fasterxml.jackson.databind.MapperFeature;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.json.JsonMapper;
|
import com.fasterxml.jackson.databind.json.JsonMapper;
|
||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
|
import com.imyeyu.api.annotation.EnableSettingInterceptor;
|
||||||
import com.imyeyu.api.annotation.RequestRateLimitInterceptor;
|
import com.imyeyu.api.annotation.RequestRateLimitInterceptor;
|
||||||
import com.imyeyu.api.annotation.RequireCorePermissionInterceptor;
|
import com.imyeyu.api.annotation.RequireCorePermissionInterceptor;
|
||||||
import com.imyeyu.api.modules.app.annotation.RequireAppPermissionInterceptor;
|
|
||||||
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermissionInterceptor;
|
import com.imyeyu.api.modules.gao.annotation.RequireGaoPermissionInterceptor;
|
||||||
import com.imyeyu.api.modules.journal.util.JournalAPIInterceptor;
|
import com.imyeyu.api.modules.journal.util.JournalAPIInterceptor;
|
||||||
|
import com.imyeyu.api.modules.system.util.SystemAPIInterceptor;
|
||||||
import com.imyeyu.spring.annotation.RequestBodyValueArgumentResolver;
|
import com.imyeyu.spring.annotation.RequestBodyValueArgumentResolver;
|
||||||
import com.imyeyu.utils.Time;
|
import com.imyeyu.utils.Time;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -37,11 +38,12 @@ import java.util.List;
|
|||||||
public class WebConfig implements WebMvcConfigurer {
|
public class WebConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
private final ObjectMapper jackson;
|
private final ObjectMapper jackson;
|
||||||
|
private final SystemAPIInterceptor systemAPIInterceptor;
|
||||||
private final JournalAPIInterceptor journalAPIInterceptor;
|
private final JournalAPIInterceptor journalAPIInterceptor;
|
||||||
|
private final EnableSettingInterceptor enableSettingInterceptor;
|
||||||
private final RequestRateLimitInterceptor requestRateLimitInterceptor;
|
private final RequestRateLimitInterceptor requestRateLimitInterceptor;
|
||||||
private final RequireGaoPermissionInterceptor requireGaoPermissionInterceptor;
|
private final RequireGaoPermissionInterceptor requireGaoPermissionInterceptor;
|
||||||
private final RequireCorePermissionInterceptor requireCorePermissionInterceptor;
|
private final RequireCorePermissionInterceptor requireCorePermissionInterceptor;
|
||||||
private final RequireAppPermissionInterceptor requireAppPermissionInterceptor;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 过滤器
|
* 过滤器
|
||||||
@@ -50,10 +52,11 @@ public class WebConfig implements WebMvcConfigurer {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void addInterceptors(InterceptorRegistry registry) {
|
public void addInterceptors(InterceptorRegistry registry) {
|
||||||
|
registry.addInterceptor(systemAPIInterceptor).addPathPatterns(SystemAPIInterceptor.PATH);
|
||||||
registry.addInterceptor(journalAPIInterceptor).addPathPatterns(JournalAPIInterceptor.PATH);
|
registry.addInterceptor(journalAPIInterceptor).addPathPatterns(JournalAPIInterceptor.PATH);
|
||||||
|
registry.addInterceptor(enableSettingInterceptor).addPathPatterns("/**");
|
||||||
registry.addInterceptor(requireCorePermissionInterceptor).addPathPatterns("/**");
|
registry.addInterceptor(requireCorePermissionInterceptor).addPathPatterns("/**");
|
||||||
registry.addInterceptor(requireGaoPermissionInterceptor).addPathPatterns("/**");
|
registry.addInterceptor(requireGaoPermissionInterceptor).addPathPatterns("/**");
|
||||||
registry.addInterceptor(requireAppPermissionInterceptor).addPathPatterns("/**");
|
|
||||||
registry.addInterceptor(requestRateLimitInterceptor).addPathPatterns("/**");
|
registry.addInterceptor(requestRateLimitInterceptor).addPathPatterns("/**");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import org.springframework.transaction.PlatformTransactionManager;
|
|||||||
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.time.OffsetDateTime;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -33,14 +32,17 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@MapperScan(basePackages = {
|
@MapperScan(basePackages = {
|
||||||
|
"com.imyeyu.api.modules.git.mapper",
|
||||||
"com.imyeyu.api.modules.gao.mapper",
|
"com.imyeyu.api.modules.gao.mapper",
|
||||||
|
"com.imyeyu.api.modules.bill.mapper",
|
||||||
"com.imyeyu.api.modules.user.mapper",
|
"com.imyeyu.api.modules.user.mapper",
|
||||||
|
"com.imyeyu.api.modules.blog.mapper",
|
||||||
"com.imyeyu.api.modules.lyric.mapper",
|
"com.imyeyu.api.modules.lyric.mapper",
|
||||||
"com.imyeyu.api.modules.mirror.mapper",
|
"com.imyeyu.api.modules.mirror.mapper",
|
||||||
"com.imyeyu.api.modules.system.mapper",
|
"com.imyeyu.api.modules.system.mapper",
|
||||||
"com.imyeyu.api.modules.common.mapper",
|
"com.imyeyu.api.modules.common.mapper",
|
||||||
"com.imyeyu.api.modules.app.mapper",
|
|
||||||
"com.imyeyu.api.modules.journal.mapper",
|
"com.imyeyu.api.modules.journal.mapper",
|
||||||
|
"com.imyeyu.api.modules.minecraft.mapper"
|
||||||
}, sqlSessionFactoryRef = "timiServerSqlSessionFactory")
|
}, sqlSessionFactoryRef = "timiServerSqlSessionFactory")
|
||||||
public class TimiServerDBConfig {
|
public class TimiServerDBConfig {
|
||||||
|
|
||||||
@@ -56,9 +58,6 @@ public class TimiServerDBConfig {
|
|||||||
dataSource.setMinimumIdle(10);
|
dataSource.setMinimumIdle(10);
|
||||||
dataSource.setMaximumPoolSize(100);
|
dataSource.setMaximumPoolSize(100);
|
||||||
dataSource.setConnectionTestQuery("SELECT 1");
|
dataSource.setConnectionTestQuery("SELECT 1");
|
||||||
// 日统计按后端时区划分日期
|
|
||||||
String offset = OffsetDateTime.now().getOffset().getId();
|
|
||||||
dataSource.setConnectionInitSql("SET time_zone = '%s'".formatted("Z".equals(offset) ? "+00:00" : offset));
|
|
||||||
|
|
||||||
dataSource.setMaxLifetime(Time.S * 180);
|
dataSource.setMaxLifetime(Time.S * 180);
|
||||||
dataSource.setIdleTimeout(Time.S * 120);
|
dataSource.setIdleTimeout(Time.S * 120);
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.app.annotation;
|
|
||||||
|
|
||||||
import com.imyeyu.api.bean.PermissionMatchMode;
|
|
||||||
import com.imyeyu.api.modules.app.bean.AppPermissionCode;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 要求 APP 模块权限
|
|
||||||
///
|
|
||||||
/// @author Codex
|
|
||||||
/// @since 2026-11-06
|
|
||||||
@Target({ElementType.METHOD, ElementType.TYPE})
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
public @interface RequireAppPermission {
|
|
||||||
|
|
||||||
/// 所需权限
|
|
||||||
///
|
|
||||||
/// @return 权限列表
|
|
||||||
AppPermissionCode[] value();
|
|
||||||
|
|
||||||
/// 匹配模式
|
|
||||||
///
|
|
||||||
/// @return 匹配模式
|
|
||||||
PermissionMatchMode mode() default PermissionMatchMode.ALL;
|
|
||||||
}
|
|
||||||
-48
@@ -1,48 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.app.annotation;
|
|
||||||
|
|
||||||
import com.imyeyu.api.bean.ModuleCode;
|
|
||||||
import com.imyeyu.api.bean.PermissionMatchMode;
|
|
||||||
import com.imyeyu.api.modules.app.bean.AppPermissionCode;
|
|
||||||
import com.imyeyu.api.modules.user.service.PermissionChecker;
|
|
||||||
import com.imyeyu.java.TimiJava;
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import org.springframework.lang.NonNull;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import org.springframework.web.method.HandlerMethod;
|
|
||||||
import org.springframework.web.servlet.HandlerInterceptor;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
///
|
|
||||||
/// APP 权限注解处理器
|
|
||||||
///
|
|
||||||
/// @author Codex
|
|
||||||
/// @since 2026-11-06
|
|
||||||
@Component
|
|
||||||
public class RequireAppPermissionInterceptor implements HandlerInterceptor {
|
|
||||||
|
|
||||||
private final PermissionChecker permissionChecker;
|
|
||||||
|
|
||||||
public RequireAppPermissionInterceptor(PermissionChecker permissionChecker) {
|
|
||||||
this.permissionChecker = permissionChecker;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean preHandle(@NonNull HttpServletRequest req, @NonNull HttpServletResponse resp, @NonNull Object handler) {
|
|
||||||
if (!(handler instanceof HandlerMethod handlerMethod)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
RequireAppPermission annotation = handlerMethod.getMethodAnnotation(RequireAppPermission.class);
|
|
||||||
if (annotation == null || TimiJava.isEmpty(annotation.value())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
String[] permissionCodeList = Arrays.stream(annotation.value()).map(AppPermissionCode::getValue).toArray(String[]::new);
|
|
||||||
if (annotation.mode() == PermissionMatchMode.ANY) {
|
|
||||||
permissionChecker.checkAny(ModuleCode.APP, permissionCodeList);
|
|
||||||
} else {
|
|
||||||
permissionChecker.checkAll(ModuleCode.APP, permissionCodeList);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.app.bean;
|
|
||||||
|
|
||||||
import com.imyeyu.api.bean.ModuleCode;
|
|
||||||
import com.imyeyu.api.modules.user.bean.BuiltinPermissionCode;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
///
|
|
||||||
/// APP 模块权限枚举
|
|
||||||
///
|
|
||||||
/// @author Codex
|
|
||||||
/// @since 2026-11-06
|
|
||||||
@Getter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public enum AppPermissionCode implements BuiltinPermissionCode {
|
|
||||||
|
|
||||||
APP_PRODUCT_CREATE("APP_PRODUCT:CREATE", "应用产品创建", false, true),
|
|
||||||
APP_PRODUCT_READ("APP_PRODUCT:READ", "应用产品读取", false, true),
|
|
||||||
APP_PRODUCT_UPDATE("APP_PRODUCT:UPDATE", "应用产品修改", false, true),
|
|
||||||
APP_PRODUCT_DELETE("APP_PRODUCT:DELETE", "应用产品删除", false, true),
|
|
||||||
|
|
||||||
APP_CHANNEL_CREATE("APP_CHANNEL:CREATE", "应用通道创建", false, true),
|
|
||||||
APP_CHANNEL_DELETE("APP_CHANNEL:DELETE", "应用通道删除", false, true),
|
|
||||||
|
|
||||||
APP_RELEASE_CREATE("APP_RELEASE:CREATE", "应用发布创建", false, true),
|
|
||||||
APP_RELEASE_READ("APP_RELEASE:READ", "应用发布读取", false, true),
|
|
||||||
APP_RELEASE_PUBLISH("APP_RELEASE:PUBLISH", "应用发布上线", false, true),
|
|
||||||
APP_RELEASE_ROLLBACK("APP_RELEASE:ROLLBACK", "应用发布回滚", false, true),
|
|
||||||
APP_RELEASE_REVOKE("APP_RELEASE:REVOKE", "应用发布撤回", false, true),
|
|
||||||
APP_RELEASE_DELETE("APP_RELEASE:DELETE", "应用发布删除", false, true);
|
|
||||||
|
|
||||||
private final String value;
|
|
||||||
|
|
||||||
private final String defaultName;
|
|
||||||
|
|
||||||
private final boolean grantToSystem;
|
|
||||||
|
|
||||||
private final boolean grantToAdmin;
|
|
||||||
|
|
||||||
/// 权限模块
|
|
||||||
///
|
|
||||||
/// @return 模块代码
|
|
||||||
@Override
|
|
||||||
public ModuleCode getModuleCode() {
|
|
||||||
return ModuleCode.APP;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,184 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.app.controller;
|
|
||||||
|
|
||||||
import com.imyeyu.api.modules.app.annotation.RequireAppPermission;
|
|
||||||
import com.imyeyu.api.modules.app.bean.AppPermissionCode;
|
|
||||||
import com.imyeyu.api.modules.app.entity.AppChannel;
|
|
||||||
import com.imyeyu.api.modules.app.entity.AppProduct;
|
|
||||||
import com.imyeyu.api.modules.app.entity.AppRelease;
|
|
||||||
import com.imyeyu.api.modules.app.service.AppVersionService;
|
|
||||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
|
||||||
import com.imyeyu.spring.annotation.AOPLog;
|
|
||||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
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;
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 应用发布管理接口
|
|
||||||
///
|
|
||||||
/// 操作人一律取当前登录身份,不接受请求参数指定
|
|
||||||
/// 用 API Key 调用时为密钥归属用户,用登录令牌调用时为登录用户
|
|
||||||
///
|
|
||||||
/// @author Codex
|
|
||||||
/// @since 2026-11-06
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
@RequestMapping("/app")
|
|
||||||
public class AppReleaseController {
|
|
||||||
|
|
||||||
private final AppVersionService service;
|
|
||||||
private final UserLoginService userLoginService;
|
|
||||||
|
|
||||||
/// 查询产品列表
|
|
||||||
///
|
|
||||||
/// @return 产品列表
|
|
||||||
@RequireAppPermission(AppPermissionCode.APP_PRODUCT_READ)
|
|
||||||
@RequestRateLimit
|
|
||||||
@PostMapping("/product/list")
|
|
||||||
public List<AppProduct> productList() {
|
|
||||||
return service.listProducts();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 保存产品
|
|
||||||
///
|
|
||||||
/// @param product 产品
|
|
||||||
/// @return 保存后的产品
|
|
||||||
@AOPLog
|
|
||||||
@RequireAppPermission({AppPermissionCode.APP_PRODUCT_CREATE, AppPermissionCode.APP_PRODUCT_UPDATE})
|
|
||||||
@RequestRateLimit
|
|
||||||
@PostMapping("/product/save")
|
|
||||||
public AppProduct productSave(@RequestBody AppProduct product) {
|
|
||||||
return service.saveProduct(product);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 查询发布列表
|
|
||||||
///
|
|
||||||
/// @param productId 产品 ID
|
|
||||||
/// @return 发布列表
|
|
||||||
@RequireAppPermission(AppPermissionCode.APP_RELEASE_READ)
|
|
||||||
@RequestRateLimit
|
|
||||||
@GetMapping("/release/list")
|
|
||||||
public List<AppRelease> releaseList(@RequestParam String productId) {
|
|
||||||
return service.listReleases(productId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 创建发布记录
|
|
||||||
///
|
|
||||||
/// @param release 发布记录
|
|
||||||
/// @return 创建后的记录
|
|
||||||
@AOPLog
|
|
||||||
@RequireAppPermission(AppPermissionCode.APP_RELEASE_CREATE)
|
|
||||||
@RequestRateLimit
|
|
||||||
@PostMapping("/release/create")
|
|
||||||
public AppRelease releaseCreate(@RequestBody AppRelease release) {
|
|
||||||
return service.create(release, operator());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 发布版本
|
|
||||||
///
|
|
||||||
/// @param releaseId 发布 ID
|
|
||||||
/// @param channelCode 通道代码
|
|
||||||
/// @param grayPermille 灰度比例,万分比
|
|
||||||
/// @param note 变更说明
|
|
||||||
@AOPLog
|
|
||||||
@RequireAppPermission(AppPermissionCode.APP_RELEASE_PUBLISH)
|
|
||||||
@RequestRateLimit
|
|
||||||
@PostMapping("/release/publish")
|
|
||||||
public void publish(
|
|
||||||
@RequestParam String releaseId,
|
|
||||||
@RequestParam(defaultValue = AppVersionService.DEFAULT_CHANNEL) String channelCode,
|
|
||||||
@RequestParam(required = false) Integer grayPermille,
|
|
||||||
@RequestParam(required = false) String note
|
|
||||||
) {
|
|
||||||
service.publish(releaseId, channelCode, grayPermille, operator(), note);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 回滚通道到指定版本
|
|
||||||
///
|
|
||||||
/// @param productId 产品 ID
|
|
||||||
/// @param channelCode 通道代码
|
|
||||||
/// @param targetReleaseId 目标发布 ID
|
|
||||||
@AOPLog
|
|
||||||
@RequireAppPermission(AppPermissionCode.APP_RELEASE_ROLLBACK)
|
|
||||||
@RequestRateLimit
|
|
||||||
@PostMapping("/release/rollback")
|
|
||||||
public void rollback(
|
|
||||||
@RequestParam String productId,
|
|
||||||
@RequestParam(defaultValue = AppVersionService.DEFAULT_CHANNEL) String channelCode,
|
|
||||||
@RequestParam String targetReleaseId
|
|
||||||
) {
|
|
||||||
service.rollback(productId, channelCode, targetReleaseId, operator());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 撤回发布
|
|
||||||
///
|
|
||||||
/// @param releaseId 发布 ID
|
|
||||||
@AOPLog
|
|
||||||
@RequireAppPermission(AppPermissionCode.APP_RELEASE_REVOKE)
|
|
||||||
@RequestRateLimit
|
|
||||||
@PostMapping("/release/revoke")
|
|
||||||
public void revoke(@RequestParam String releaseId) {
|
|
||||||
service.revoke(releaseId, operator());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 查询通道列表
|
|
||||||
///
|
|
||||||
/// @param productId 产品 ID
|
|
||||||
/// @return 通道列表
|
|
||||||
@RequireAppPermission(AppPermissionCode.APP_RELEASE_READ)
|
|
||||||
@RequestRateLimit
|
|
||||||
@GetMapping("/channel/list")
|
|
||||||
public List<AppChannel> channelList(@RequestParam String productId) {
|
|
||||||
return service.listChannels(productId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 删除草稿发布
|
|
||||||
///
|
|
||||||
/// @param releaseId 发布 ID
|
|
||||||
@AOPLog
|
|
||||||
@RequireAppPermission(AppPermissionCode.APP_RELEASE_DELETE)
|
|
||||||
@RequestRateLimit
|
|
||||||
@PostMapping("/release/delete")
|
|
||||||
public void releaseDelete(@RequestParam String releaseId) {
|
|
||||||
service.deleteRelease(releaseId, operator());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 删除通道
|
|
||||||
///
|
|
||||||
/// @param channelId 通道 ID
|
|
||||||
@AOPLog
|
|
||||||
@RequireAppPermission(AppPermissionCode.APP_CHANNEL_DELETE)
|
|
||||||
@RequestRateLimit
|
|
||||||
@PostMapping("/channel/delete")
|
|
||||||
public void channelDelete(@RequestParam String channelId) {
|
|
||||||
service.deleteChannel(channelId, operator());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 删除产品
|
|
||||||
///
|
|
||||||
/// @param productId 产品 ID
|
|
||||||
@AOPLog
|
|
||||||
@RequireAppPermission(AppPermissionCode.APP_PRODUCT_DELETE)
|
|
||||||
@RequestRateLimit
|
|
||||||
@PostMapping("/product/delete")
|
|
||||||
public void productDelete(@RequestParam String productId) {
|
|
||||||
service.deleteProduct(productId, operator());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 取当前操作人
|
|
||||||
///
|
|
||||||
/// 接口都带权限注解,执行到这里一定已登录,取不到会直接抛错
|
|
||||||
///
|
|
||||||
/// @return 当前登录用户 ID
|
|
||||||
private String operator() {
|
|
||||||
return userLoginService.getRequireLoginUserId();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.app.controller;
|
|
||||||
|
|
||||||
import com.imyeyu.api.modules.app.service.AppVersionService;
|
|
||||||
import com.imyeyu.api.modules.app.vo.AppUpdateCheckRequest;
|
|
||||||
import com.imyeyu.api.modules.app.vo.AppUpdateCheckResponse;
|
|
||||||
import com.imyeyu.api.modules.app.vo.AppUpdateNotesResponse;
|
|
||||||
import com.imyeyu.spring.annotation.IgnoreGlobalReturn;
|
|
||||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 应用更新接口
|
|
||||||
///
|
|
||||||
/// 供 Capacitor 插件直接调用,不要求登录态,因此不加权限注解
|
|
||||||
///
|
|
||||||
/// @author Codex
|
|
||||||
/// @since 2026-11-06
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
@RequestMapping("/app/update")
|
|
||||||
public class AppUpdateController {
|
|
||||||
|
|
||||||
private final AppVersionService service;
|
|
||||||
|
|
||||||
/// 检查更新
|
|
||||||
///
|
|
||||||
/// 直接返回插件要求的原始 JSON,不能套通用响应包装
|
|
||||||
///
|
|
||||||
/// @param req 插件上报信息
|
|
||||||
/// @return 插件协议响应
|
|
||||||
@IgnoreGlobalReturn
|
|
||||||
@RequestRateLimit
|
|
||||||
@PostMapping("/check")
|
|
||||||
public AppUpdateCheckResponse check(@RequestBody AppUpdateCheckRequest req) {
|
|
||||||
return service.check(req);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 查询更新日志
|
|
||||||
///
|
|
||||||
/// 返回当前运行版本到目标版本之间的变更说明,供版本历史页使用
|
|
||||||
/// 目标版本与 check 用同一套规则解析,包含灰度与兼容区间,保证「有日志」和「能更新」一致
|
|
||||||
///
|
|
||||||
/// @param req 插件上报信息,version_name 为当前运行版本
|
|
||||||
/// @return 更新日志
|
|
||||||
@RequestRateLimit
|
|
||||||
@PostMapping("/notes")
|
|
||||||
public AppUpdateNotesResponse notes(@RequestBody AppUpdateCheckRequest req) {
|
|
||||||
return service.notes(req);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.app.entity;
|
|
||||||
|
|
||||||
import com.imyeyu.spring.entity.UUIDEntity;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 应用发布通道
|
|
||||||
///
|
|
||||||
/// 通道分别持有热更包和原生包指针
|
|
||||||
///
|
|
||||||
/// @author Codex
|
|
||||||
/// @since 2026-11-06
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class AppChannel extends UUIDEntity {
|
|
||||||
|
|
||||||
/// 产品 ID
|
|
||||||
protected String productId;
|
|
||||||
|
|
||||||
/// 通道代码,如 stable、beta
|
|
||||||
protected String code;
|
|
||||||
|
|
||||||
/// 通道名称
|
|
||||||
protected String name;
|
|
||||||
|
|
||||||
/// 当前热更包发布 ID
|
|
||||||
protected String bundleReleaseId;
|
|
||||||
|
|
||||||
/// 当前原生包发布 ID
|
|
||||||
protected String nativeReleaseId;
|
|
||||||
|
|
||||||
/// 过渡期旧指针
|
|
||||||
protected String releaseId;
|
|
||||||
|
|
||||||
/// 最后操作人用户 ID
|
|
||||||
protected String updatedBy;
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.app.entity;
|
|
||||||
|
|
||||||
import com.imyeyu.spring.entity.UUIDEntity;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 应用产品
|
|
||||||
///
|
|
||||||
/// @author Codex
|
|
||||||
/// @since 2026-11-06
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class AppProduct extends UUIDEntity {
|
|
||||||
|
|
||||||
/// 平台
|
|
||||||
public enum Platform {
|
|
||||||
|
|
||||||
/// Android
|
|
||||||
ANDROID,
|
|
||||||
|
|
||||||
/// iOS
|
|
||||||
IOS
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 产品标识,取 Capacitor appId
|
|
||||||
protected String appKey;
|
|
||||||
|
|
||||||
/// 产品名称
|
|
||||||
protected String name;
|
|
||||||
|
|
||||||
/// 平台
|
|
||||||
protected Platform platform;
|
|
||||||
|
|
||||||
/// 包名
|
|
||||||
protected String packageName;
|
|
||||||
|
|
||||||
/// 检查接口密钥,为空时不校验
|
|
||||||
protected String updateKey;
|
|
||||||
|
|
||||||
/// true 为允许检查更新
|
|
||||||
protected Boolean enabled;
|
|
||||||
}
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.app.entity;
|
|
||||||
|
|
||||||
import com.imyeyu.spring.entity.UUIDEntity;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 应用发布记录
|
|
||||||
///
|
|
||||||
/// 创建后不可变,回滚只改通道指针,不修改本记录
|
|
||||||
///
|
|
||||||
/// @author Codex
|
|
||||||
/// @since 2026-11-06
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class AppRelease extends UUIDEntity {
|
|
||||||
|
|
||||||
/// 产物类型
|
|
||||||
public enum Kind {
|
|
||||||
|
|
||||||
/// 原生安装包
|
|
||||||
NATIVE,
|
|
||||||
|
|
||||||
/// Web 热更包
|
|
||||||
BUNDLE
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 发布状态
|
|
||||||
public enum Status {
|
|
||||||
|
|
||||||
/// 待发布
|
|
||||||
DRAFT,
|
|
||||||
|
|
||||||
/// 已发布
|
|
||||||
PUBLISHED,
|
|
||||||
|
|
||||||
/// 已撤回
|
|
||||||
REVOKED
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 产品 ID
|
|
||||||
protected String productId;
|
|
||||||
|
|
||||||
/// 产物类型
|
|
||||||
protected Kind kind;
|
|
||||||
|
|
||||||
/// 版本号,热更包为 semver
|
|
||||||
protected String versionName;
|
|
||||||
|
|
||||||
/// 原生 versionCode,kind 为 NATIVE 时必填
|
|
||||||
protected Integer versionCode;
|
|
||||||
|
|
||||||
/// 兼容的最低原生 versionCode,kind 为 BUNDLE 时必填
|
|
||||||
protected Integer minVersionCode;
|
|
||||||
|
|
||||||
/// 兼容的最高原生 versionCode,为空表示不限
|
|
||||||
protected Integer maxVersionCode;
|
|
||||||
|
|
||||||
/// 产物附件 ID
|
|
||||||
protected String attachmentId;
|
|
||||||
|
|
||||||
/// 产物字节数
|
|
||||||
protected Long artifactSize;
|
|
||||||
|
|
||||||
/// 产物 SHA-256
|
|
||||||
protected String sha256;
|
|
||||||
|
|
||||||
/// 灰度比例,万分比,10000 为全量
|
|
||||||
protected Integer grayPermille;
|
|
||||||
|
|
||||||
/// true 为强制更新,仅 kind 为 NATIVE 时有效
|
|
||||||
protected Boolean mandatory;
|
|
||||||
|
|
||||||
/// 发布状态
|
|
||||||
protected Status status;
|
|
||||||
|
|
||||||
/// 变更说明
|
|
||||||
protected String note;
|
|
||||||
|
|
||||||
/// 发布人用户 ID
|
|
||||||
protected String createdBy;
|
|
||||||
|
|
||||||
/// 首次发布时间
|
|
||||||
protected Long publishedAt;
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.app.mapper;
|
|
||||||
|
|
||||||
import com.imyeyu.api.modules.app.entity.AppChannel;
|
|
||||||
import com.imyeyu.spring.mapper.BaseMapper;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
import org.apache.ibatis.annotations.Select;
|
|
||||||
import org.apache.ibatis.annotations.Update;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 应用发布通道
|
|
||||||
///
|
|
||||||
/// @author Codex
|
|
||||||
/// @since 2026-11-06
|
|
||||||
public interface AppChannelMapper extends BaseMapper<AppChannel, String> {
|
|
||||||
|
|
||||||
/// 按产品与通道代码查询
|
|
||||||
///
|
|
||||||
/// @param productId 产品 ID
|
|
||||||
/// @param code 通道代码
|
|
||||||
/// @return 通道
|
|
||||||
@Select("SELECT * FROM app_channel WHERE product_id = #{productId} AND code = #{code} AND deleted_at IS NULL LIMIT 1")
|
|
||||||
AppChannel selectByProductAndCode(@Param("productId") String productId, @Param("code") String code);
|
|
||||||
|
|
||||||
/// 按产品查询通道列表
|
|
||||||
///
|
|
||||||
/// @param productId 产品 ID
|
|
||||||
/// @return 通道列表
|
|
||||||
@Select("SELECT * FROM app_channel WHERE product_id = #{productId} AND deleted_at IS NULL ORDER BY code")
|
|
||||||
List<AppChannel> selectByProduct(@Param("productId") String productId);
|
|
||||||
|
|
||||||
/// 切换通道指针
|
|
||||||
///
|
|
||||||
/// @param id 通道 ID
|
|
||||||
/// @param releaseId 目标发布 ID,为空表示指向空
|
|
||||||
/// @param updatedBy 操作人用户 ID
|
|
||||||
/// @param updatedAt 更新时间
|
|
||||||
/// @return 影响行数
|
|
||||||
@Update("UPDATE app_channel SET release_id = #{releaseId}, updated_by = #{updatedBy}, updated_at = #{updatedAt} WHERE id = #{id}")
|
|
||||||
int updateReleaseId(
|
|
||||||
@Param("id") String id,
|
|
||||||
@Param("releaseId") String releaseId,
|
|
||||||
@Param("updatedBy") String updatedBy,
|
|
||||||
@Param("updatedAt") Long updatedAt
|
|
||||||
);
|
|
||||||
/// 按类型切换指针并同步旧指针
|
|
||||||
@Update("UPDATE app_channel SET bundle_release_id = CASE WHEN #{nativeRelease} = false THEN #{releaseId} ELSE bundle_release_id END, native_release_id = CASE WHEN #{nativeRelease} = true THEN #{releaseId} ELSE native_release_id END, release_id = #{releaseId}, updated_by = #{updatedBy}, updated_at = #{updatedAt} WHERE id = #{id}")
|
|
||||||
int updatePointers(@Param("id") String id, @Param("releaseId") String releaseId, @Param("nativeRelease") boolean nativeRelease, @Param("updatedBy") String updatedBy, @Param("updatedAt") Long updatedAt);
|
|
||||||
|
|
||||||
/// 清除所有通道中指向撤回记录的指针
|
|
||||||
@Update("UPDATE app_channel SET bundle_release_id = CASE WHEN bundle_release_id = #{releaseId} THEN NULL ELSE bundle_release_id END, native_release_id = CASE WHEN native_release_id = #{releaseId} THEN NULL ELSE native_release_id END, release_id = CASE WHEN release_id = #{releaseId} THEN NULL ELSE release_id END, updated_by = #{updatedBy}, updated_at = #{updatedAt} WHERE product_id = #{productId} AND deleted_at IS NULL AND (bundle_release_id = #{releaseId} OR native_release_id = #{releaseId} OR release_id = #{releaseId})")
|
|
||||||
int clearRelease(@Param("productId") String productId, @Param("releaseId") String releaseId, @Param("updatedBy") String updatedBy, @Param("updatedAt") Long updatedAt);
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.app.mapper;
|
|
||||||
|
|
||||||
import com.imyeyu.api.modules.app.entity.AppProduct;
|
|
||||||
import com.imyeyu.spring.mapper.BaseMapper;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
import org.apache.ibatis.annotations.Select;
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 应用产品
|
|
||||||
///
|
|
||||||
/// @author Codex
|
|
||||||
/// @since 2026-11-06
|
|
||||||
public interface AppProductMapper extends BaseMapper<AppProduct, String> {
|
|
||||||
|
|
||||||
/// 按产品标识查询
|
|
||||||
///
|
|
||||||
/// @param appKey 产品标识
|
|
||||||
/// @param platform 平台
|
|
||||||
/// @return 产品
|
|
||||||
@Select("SELECT * FROM app_product WHERE app_key = #{appKey} AND platform = #{platform} AND deleted_at IS NULL LIMIT 1")
|
|
||||||
AppProduct selectByAppKey(@Param("appKey") String appKey, @Param("platform") AppProduct.Platform platform);
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.app.mapper;
|
|
||||||
|
|
||||||
import com.imyeyu.api.modules.app.entity.AppRelease;
|
|
||||||
import com.imyeyu.spring.mapper.BaseMapper;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
import org.apache.ibatis.annotations.Select;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 应用发布记录
|
|
||||||
///
|
|
||||||
/// @author Codex
|
|
||||||
/// @since 2026-11-06
|
|
||||||
public interface AppReleaseMapper extends BaseMapper<AppRelease, String> {
|
|
||||||
|
|
||||||
/// 查询产品下已发布的同类型产物
|
|
||||||
///
|
|
||||||
/// @param productId 产品 ID
|
|
||||||
/// @param kind 产物类型
|
|
||||||
/// @return 发布列表,按发布时间倒序
|
|
||||||
@Select("SELECT * FROM app_release WHERE product_id = #{productId} AND kind = #{kind} AND status = 'PUBLISHED' AND deleted_at IS NULL ORDER BY published_at DESC")
|
|
||||||
List<AppRelease> selectPublished(@Param("productId") String productId, @Param("kind") AppRelease.Kind kind);
|
|
||||||
|
|
||||||
/// 按版本号查询
|
|
||||||
///
|
|
||||||
/// @param productId 产品 ID
|
|
||||||
/// @param kind 产物类型
|
|
||||||
/// @param versionName 版本号
|
|
||||||
/// @return 发布记录
|
|
||||||
@Select("SELECT * FROM app_release WHERE product_id = #{productId} AND kind = #{kind} AND version_name = #{versionName} AND deleted_at IS NULL LIMIT 1")
|
|
||||||
AppRelease selectByVersion(
|
|
||||||
@Param("productId") String productId,
|
|
||||||
@Param("kind") AppRelease.Kind kind,
|
|
||||||
@Param("versionName") String versionName
|
|
||||||
);
|
|
||||||
|
|
||||||
/// 查询产品下全部发布记录
|
|
||||||
///
|
|
||||||
/// @param productId 产品 ID
|
|
||||||
/// @return 发布列表,按创建时间倒序
|
|
||||||
@Select("SELECT * FROM app_release WHERE product_id = #{productId} AND deleted_at IS NULL ORDER BY created_at DESC")
|
|
||||||
List<AppRelease> selectByProduct(@Param("productId") String productId);
|
|
||||||
}
|
|
||||||
@@ -1,573 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.app.service;
|
|
||||||
|
|
||||||
import com.imyeyu.api.modules.app.entity.AppChannel;
|
|
||||||
import com.imyeyu.api.modules.app.entity.AppProduct;
|
|
||||||
import com.imyeyu.api.modules.app.entity.AppRelease;
|
|
||||||
import com.imyeyu.api.config.dbsource.TimiServerDBConfig;
|
|
||||||
import com.imyeyu.api.modules.app.mapper.AppChannelMapper;
|
|
||||||
import com.imyeyu.api.modules.app.mapper.AppProductMapper;
|
|
||||||
import com.imyeyu.api.modules.app.mapper.AppReleaseMapper;
|
|
||||||
import com.imyeyu.api.modules.app.vo.AppUpdateCheckRequest;
|
|
||||||
import com.imyeyu.api.modules.app.vo.AppUpdateCheckResponse;
|
|
||||||
import com.imyeyu.api.modules.app.vo.AppUpdateNote;
|
|
||||||
import com.imyeyu.api.modules.app.vo.AppUpdateNotesResponse;
|
|
||||||
import com.imyeyu.api.modules.system.entity.Logger;
|
|
||||||
import com.imyeyu.api.modules.system.service.LoggerService;
|
|
||||||
import com.imyeyu.java.TimiJava;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
|
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.zip.CRC32;
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 应用版本服务
|
|
||||||
///
|
|
||||||
/// 核心只有一个判断:给定设备当前状态和通道,它此刻应该运行哪一份产物
|
|
||||||
///
|
|
||||||
/// @author Codex
|
|
||||||
/// @since 2026-11-06
|
|
||||||
@Slf4j
|
|
||||||
@Service
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class AppVersionService {
|
|
||||||
|
|
||||||
/// 默认通道
|
|
||||||
public static final String DEFAULT_CHANNEL = "stable";
|
|
||||||
|
|
||||||
/// 内置包版本标识
|
|
||||||
public static final String BUILTIN_VERSION = "builtin";
|
|
||||||
|
|
||||||
/// 首个能处理外壳安装包的 Web 包版本
|
|
||||||
///
|
|
||||||
/// 更早的包不认识 shell 标记,只会把 url 当热更 zip 交给插件解压,拿到 APK 必然失败。
|
|
||||||
/// 通道指向原生包时,低于这个版本的设备改为下发热更包,先把它升到能自升级为止
|
|
||||||
public static final String SHELL_AWARE_VERSION = "1.3.2";
|
|
||||||
|
|
||||||
/// 首个按独立字段接收外壳更新的 Web 包版本
|
|
||||||
///
|
|
||||||
/// 从这版起响应把安装包放到 shellUrl,主字段 url 永远给热更包;
|
|
||||||
/// 更早的包只认「主字段 + shell 标记」,所以两套语义要并存到 1.5.0 铺开为止
|
|
||||||
public static final String SHELL_JSON_AWARE_VERSION = "1.5.0";
|
|
||||||
|
|
||||||
/// 更新日志最多返回的版本条数
|
|
||||||
public static final int MAX_NOTES = 8;
|
|
||||||
|
|
||||||
/// 已是最新时展示的版本条数
|
|
||||||
public static final int TAIL_NOTES = 8;
|
|
||||||
|
|
||||||
/// 灰度基数
|
|
||||||
private static final long GRAY_BASE = 10000L;
|
|
||||||
|
|
||||||
private final AppProductMapper productMapper;
|
|
||||||
private final AppChannelMapper channelMapper;
|
|
||||||
private final AppReleaseMapper releaseMapper;
|
|
||||||
private final LoggerService loggerService;
|
|
||||||
|
|
||||||
/// 检查更新
|
|
||||||
///
|
|
||||||
/// @param req 插件上报信息
|
|
||||||
/// @return 插件协议响应,无更新时回显当前版本
|
|
||||||
public AppUpdateCheckResponse check(AppUpdateCheckRequest req) {
|
|
||||||
String currentVersion = currentVersion(req);
|
|
||||||
AppProduct product = resolveProduct(req);
|
|
||||||
if (product == null) {
|
|
||||||
return AppUpdateCheckResponse.none(currentVersion);
|
|
||||||
}
|
|
||||||
int currentCode = parseInt(req.getVersionCode(), 0);
|
|
||||||
AppRelease bundlePointer = resolvePointer(product, req, AppRelease.Kind.BUNDLE);
|
|
||||||
AppRelease nativePointer = resolvePointer(product, req, AppRelease.Kind.NATIVE);
|
|
||||||
AppRelease bundle = bundlePointer == null ? null : resolveBundle(bundlePointer, product, currentCode, currentVersion, req.getDeviceId());
|
|
||||||
AppRelease nativeTarget = nativePointer == null ? null : resolveNative(nativePointer, currentCode);
|
|
||||||
boolean shellAware = 0 <= compareVersion(currentVersion, SHELL_AWARE_VERSION);
|
|
||||||
boolean jsonAware = 0 <= compareVersion(currentVersion, SHELL_JSON_AWARE_VERSION);
|
|
||||||
// 认识 shell 标记但还不认识独立字段的包,主字段继续给安装包
|
|
||||||
if (nativeTarget != null && shellAware && !jsonAware) {
|
|
||||||
return buildResponse(nativeTarget, Boolean.TRUE.equals(nativeTarget.getMandatory()), true);
|
|
||||||
}
|
|
||||||
AppUpdateCheckResponse response = bundle == null ? AppUpdateCheckResponse.none(currentVersion) : buildResponse(bundle, false, false);
|
|
||||||
if (nativeTarget != null && jsonAware) {
|
|
||||||
AppUpdateCheckResponse shell = buildResponse(nativeTarget, false, true);
|
|
||||||
response.setShellUrl(shell.getUrl());
|
|
||||||
response.setShellVersion(shell.getVersion());
|
|
||||||
response.setShellChecksum(shell.getChecksum());
|
|
||||||
response.setShellMandatory(Boolean.TRUE.equals(nativeTarget.getMandatory()));
|
|
||||||
}
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 查询更新日志
|
|
||||||
///
|
|
||||||
/// 区间上界取通道当前版本,不走灰度与兼容区间判断。
|
|
||||||
/// 原因:客户端拿不到原生 versionCode,也无法保证命中灰度分桶,套用检查更新的判定会让日志
|
|
||||||
/// 大面积为空。日志是「这个产品最近发了什么」,不是「你这台设备能装什么」,分发决策仍由 check 负责
|
|
||||||
///
|
|
||||||
/// 有更新时返回 (当前版本, 通道版本] 区间;已是最新时区间为空,改为返回最近 TAIL_NOTES 个版本,
|
|
||||||
/// 否则更新完就看不到任何说明
|
|
||||||
///
|
|
||||||
/// @param req 插件上报信息
|
|
||||||
/// @return 变更说明,按版本号从新到旧
|
|
||||||
public AppUpdateNotesResponse notes(AppUpdateCheckRequest req) {
|
|
||||||
String currentVersion = currentVersion(req);
|
|
||||||
AppProduct product = resolveProduct(req);
|
|
||||||
if (product == null) {
|
|
||||||
return new AppUpdateNotesResponse(null, Collections.emptyList());
|
|
||||||
}
|
|
||||||
AppRelease target = resolvePointer(product, req, AppRelease.Kind.BUNDLE);
|
|
||||||
// 指针为空(刚建通道还没发过热更)时退回最近一次发布,日志不该跟着空
|
|
||||||
if (target == null) {
|
|
||||||
target = latestPublishedBundle(product);
|
|
||||||
}
|
|
||||||
if (target == null) {
|
|
||||||
return new AppUpdateNotesResponse(null, Collections.emptyList());
|
|
||||||
}
|
|
||||||
// 当前版本不低于通道版本:已是最新,或回滚后反而超前
|
|
||||||
boolean upToDate = 0 <= compareVersion(currentVersion, target.getVersionName());
|
|
||||||
List<AppUpdateNote> notes = new ArrayList<>();
|
|
||||||
for (AppRelease item : releaseMapper.selectPublished(product.getId(), AppRelease.Kind.BUNDLE)) {
|
|
||||||
// 上界恒定:不展示比通道版本更新的记录
|
|
||||||
if (0 < compareVersion(item.getVersionName(), target.getVersionName())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// 有更新时才设下界,已是最新则不限
|
|
||||||
if (!upToDate && 0 >= compareVersion(item.getVersionName(), currentVersion)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
notes.add(new AppUpdateNote(item.getVersionName(), item.getNote(), item.getPublishedAt()));
|
|
||||||
}
|
|
||||||
// 按版本号倒序,最新的在最前
|
|
||||||
notes.sort((a, b) -> compareVersion(b.getVersion(), a.getVersion()));
|
|
||||||
int limit = upToDate ? TAIL_NOTES : MAX_NOTES;
|
|
||||||
List<AppUpdateNote> limited = limit < notes.size() ? notes.subList(0, limit) : notes;
|
|
||||||
return new AppUpdateNotesResponse(target.getVersionName(), limited);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 取当前运行的 Web 包版本
|
|
||||||
///
|
|
||||||
/// @param req 插件上报信息
|
|
||||||
/// @return 版本号,未上报时为内置包标识
|
|
||||||
private String currentVersion(AppUpdateCheckRequest req) {
|
|
||||||
return TimiJava.isEmpty(req.getVersionName()) ? BUILTIN_VERSION : req.getVersionName();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 解析并校验产品
|
|
||||||
///
|
|
||||||
/// @param req 插件上报信息
|
|
||||||
/// @return 产品,不存在、已停用或密钥不匹配时为 null
|
|
||||||
private AppProduct resolveProduct(AppUpdateCheckRequest req) {
|
|
||||||
AppProduct product = productMapper.selectByAppKey(req.getAppId(), parsePlatform(req.getPlatform()));
|
|
||||||
if (product == null || !Boolean.TRUE.equals(product.getEnabled())) {
|
|
||||||
log.warn("应用不存在或已停用,appId={}", req.getAppId());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (!TimiJava.isEmpty(product.getUpdateKey()) && !product.getUpdateKey().equals(req.getKey())) {
|
|
||||||
log.warn("更新密钥不匹配,appId={}", req.getAppId());
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return product;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 取通道当前指向的发布记录
|
|
||||||
///
|
|
||||||
/// @param product 产品
|
|
||||||
/// @param req 插件上报信息
|
|
||||||
/// @return 发布记录,通道为空或指向的记录不可用时为 null
|
|
||||||
private AppRelease resolvePointer(AppProduct product, AppUpdateCheckRequest req, AppRelease.Kind kind) {
|
|
||||||
String channelCode = TimiJava.isEmpty(req.getChannel()) ? DEFAULT_CHANNEL : req.getChannel();
|
|
||||||
AppChannel channel = channelMapper.selectByProductAndCode(product.getId(), channelCode);
|
|
||||||
if (channel == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
String id = kind == AppRelease.Kind.BUNDLE ? channel.getBundleReleaseId() : channel.getNativeReleaseId();
|
|
||||||
// 兼容旧代码在回滚期间仅更新旧指针的情况
|
|
||||||
if (TimiJava.isEmpty(id)) {
|
|
||||||
id = channel.getReleaseId();
|
|
||||||
}
|
|
||||||
if (TimiJava.isEmpty(id)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
AppRelease release = releaseMapper.select(id);
|
|
||||||
return release != null && release.getKind() == kind && release.getStatus() == AppRelease.Status.PUBLISHED ? release : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 原生包是否需要更新
|
|
||||||
///
|
|
||||||
/// @param release 通道当前发布记录
|
|
||||||
/// @param currentCode 当前原生 versionCode
|
|
||||||
/// @return 需要更新时返回发布记录,否则返回 null
|
|
||||||
private AppRelease resolveNative(AppRelease release, int currentCode) {
|
|
||||||
if (release.getVersionCode() == null || release.getVersionCode() <= currentCode) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return release;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 热更包是否需要更新
|
|
||||||
///
|
|
||||||
/// @param release 通道当前发布记录
|
|
||||||
/// @param product 产品
|
|
||||||
/// @param currentCode 当前原生 versionCode
|
|
||||||
/// @param currentVersion 当前 Web 包版本
|
|
||||||
/// @param deviceId 设备标识
|
|
||||||
/// @return 需要更新时返回发布记录,否则返回 null
|
|
||||||
private AppRelease resolveBundle(
|
|
||||||
AppRelease release,
|
|
||||||
AppProduct product,
|
|
||||||
int currentCode,
|
|
||||||
String currentVersion,
|
|
||||||
String deviceId
|
|
||||||
) {
|
|
||||||
// 原生版本不在兼容区间内,装了会崩
|
|
||||||
if (release.getMinVersionCode() != null && currentCode < release.getMinVersionCode()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (release.getMaxVersionCode() != null && release.getMaxVersionCode() < currentCode) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
// 已是最新,或低于当前版本时不做降级
|
|
||||||
if (release.getVersionName().equals(currentVersion)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (0 < compareVersion(currentVersion, release.getVersionName())) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
// 灰度分桶不能含 releaseId,否则每次发版都会重排用户
|
|
||||||
if (!hitGray(release.getGrayPermille(), deviceId, product.getAppKey())) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return release;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 取最近一次发布的热更包
|
|
||||||
///
|
|
||||||
/// 通道指向原生包时,更新日志没有「通道版本」可用,改用这里兜底。
|
|
||||||
/// 日志是「这个产品最近发了什么」,与设备能不能装无关,所以不套灰度与兼容区间
|
|
||||||
///
|
|
||||||
/// @param product 产品
|
|
||||||
/// @return 版本最高的已发布热更包,没有则返回 null
|
|
||||||
private AppRelease latestPublishedBundle(AppProduct product) {
|
|
||||||
AppRelease latest = null;
|
|
||||||
for (AppRelease item : releaseMapper.selectPublished(product.getId(), AppRelease.Kind.BUNDLE)) {
|
|
||||||
if (latest == null || 0 < compareVersion(item.getVersionName(), latest.getVersionName())) {
|
|
||||||
latest = item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return latest;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 判断设备是否命中灰度
|
|
||||||
///
|
|
||||||
/// @param grayPermille 灰度比例,万分比
|
|
||||||
/// @param deviceId 设备标识
|
|
||||||
/// @param appKey 产品标识
|
|
||||||
/// @return true 为命中
|
|
||||||
private boolean hitGray(Integer grayPermille, String deviceId, String appKey) {
|
|
||||||
if (grayPermille == null || GRAY_BASE <= grayPermille) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (TimiJava.isEmpty(deviceId)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
CRC32 crc = new CRC32();
|
|
||||||
crc.update((deviceId + ":" + appKey).getBytes(StandardCharsets.UTF_8));
|
|
||||||
return crc.getValue() % GRAY_BASE < grayPermille;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 构造更新响应
|
|
||||||
///
|
|
||||||
/// note 为历史构建号时不下发,避免客户端把它当成更新说明展示
|
|
||||||
///
|
|
||||||
/// @param release 发布记录
|
|
||||||
/// @param mandatory true 为强制更新
|
|
||||||
/// @param shell true 为外壳安装包,客户端需要下载后覆盖安装
|
|
||||||
/// @return 更新响应
|
|
||||||
private AppUpdateCheckResponse buildResponse(AppRelease release, boolean mandatory, boolean shell) {
|
|
||||||
String url = ServletUriComponentsBuilder.fromCurrentContextPath()
|
|
||||||
.path("/attach/download/")
|
|
||||||
.path(release.getAttachmentId())
|
|
||||||
.toUriString();
|
|
||||||
return new AppUpdateCheckResponse(release.getVersionName(), url, release.getSha256(), mandatory, shell, release.getNote(), null, null, null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 比较版本号
|
|
||||||
///
|
|
||||||
/// 只处理数字段,预发布标识按 0 处理
|
|
||||||
///
|
|
||||||
/// @param a 版本 A
|
|
||||||
/// @param b 版本 B
|
|
||||||
/// @return 负数表示 A 小于 B
|
|
||||||
private int compareVersion(String a, String b) {
|
|
||||||
if (BUILTIN_VERSION.equals(a)) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (BUILTIN_VERSION.equals(b)) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
String[] left = a.split("\\.");
|
|
||||||
String[] right = b.split("\\.");
|
|
||||||
int length = Math.max(left.length, right.length);
|
|
||||||
for (int i = 0; i < length; i++) {
|
|
||||||
int x = i < left.length ? parseInt(left[i], 0) : 0;
|
|
||||||
int y = i < right.length ? parseInt(right[i], 0) : 0;
|
|
||||||
if (x != y) {
|
|
||||||
return 0 < Integer.compare(x, y) ? 1 : -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 安全解析整数
|
|
||||||
///
|
|
||||||
/// @param value 原始值
|
|
||||||
/// @param defaultValue 默认值
|
|
||||||
/// @return 解析结果
|
|
||||||
private int parseInt(String value, int defaultValue) {
|
|
||||||
if (TimiJava.isEmpty(value)) {
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return Integer.parseInt(value.trim());
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 解析平台
|
|
||||||
///
|
|
||||||
/// @param platform 平台字符串
|
|
||||||
/// @return 平台枚举
|
|
||||||
private AppProduct.Platform parsePlatform(String platform) {
|
|
||||||
if (TimiJava.isEmpty(platform)) {
|
|
||||||
return AppProduct.Platform.ANDROID;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return AppProduct.Platform.valueOf(platform.trim().toUpperCase());
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
return AppProduct.Platform.ANDROID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 发布版本
|
|
||||||
///
|
|
||||||
/// @param releaseId 发布 ID
|
|
||||||
/// @param channelCode 通道代码
|
|
||||||
/// @param grayPermille 灰度比例,为空时保持原值
|
|
||||||
/// @param operatorId 操作人用户 ID
|
|
||||||
/// @param note 变更说明
|
|
||||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
|
||||||
public void publish(String releaseId, String channelCode, Integer grayPermille, String operatorId, String note) {
|
|
||||||
AppRelease release = releaseMapper.select(releaseId);
|
|
||||||
if (release == null) {
|
|
||||||
throw new IllegalArgumentException("发布记录不存在");
|
|
||||||
}
|
|
||||||
AppChannel channel = channelMapper.selectByProductAndCode(release.getProductId(), channelCode);
|
|
||||||
if (channel == null) {
|
|
||||||
throw new IllegalArgumentException("通道不存在");
|
|
||||||
}
|
|
||||||
checkCompatibility(release);
|
|
||||||
Long now = System.currentTimeMillis();
|
|
||||||
// 发布不指定灰度按全量处理:草稿默认是 0,直接沿用会让所有设备都拿不到包
|
|
||||||
release.setGrayPermille(grayPermille == null ? (int) GRAY_BASE : grayPermille);
|
|
||||||
release.setStatus(AppRelease.Status.PUBLISHED);
|
|
||||||
if (release.getPublishedAt() == null) {
|
|
||||||
release.setPublishedAt(now);
|
|
||||||
}
|
|
||||||
release.setNote(TimiJava.isEmpty(note) ? release.getNote() : note);
|
|
||||||
release.setUpdatedAt(now);
|
|
||||||
releaseMapper.updateSelective(release);
|
|
||||||
channelMapper.updatePointers(channel.getId(), releaseId, release.getKind() == AppRelease.Kind.NATIVE, operatorId, now);
|
|
||||||
log("APP_RELEASE_PUBLISH", releaseId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 回滚通道到指定发布
|
|
||||||
///
|
|
||||||
/// 回滚只改指针,同时把目标版本灰度拉满,否则只有部分设备能回退
|
|
||||||
///
|
|
||||||
/// @param productId 产品 ID
|
|
||||||
/// @param channelCode 通道代码
|
|
||||||
/// @param targetReleaseId 目标发布 ID
|
|
||||||
/// @param operatorId 操作人用户 ID
|
|
||||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
|
||||||
public void rollback(String productId, String channelCode, String targetReleaseId, String operatorId) {
|
|
||||||
AppChannel channel = channelMapper.selectByProductAndCode(productId, channelCode);
|
|
||||||
if (channel == null) {
|
|
||||||
throw new IllegalArgumentException("通道不存在");
|
|
||||||
}
|
|
||||||
AppRelease target = releaseMapper.select(targetReleaseId);
|
|
||||||
if (target == null || !target.getProductId().equals(productId)) {
|
|
||||||
throw new IllegalArgumentException("目标发布不存在");
|
|
||||||
}
|
|
||||||
Long now = System.currentTimeMillis();
|
|
||||||
target.setGrayPermille((int) GRAY_BASE);
|
|
||||||
target.setStatus(AppRelease.Status.PUBLISHED);
|
|
||||||
target.setUpdatedAt(now);
|
|
||||||
releaseMapper.updateSelective(target);
|
|
||||||
channelMapper.updatePointers(channel.getId(), targetReleaseId, target.getKind() == AppRelease.Kind.NATIVE, operatorId, now);
|
|
||||||
log("APP_RELEASE_ROLLBACK", targetReleaseId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 撤回发布
|
|
||||||
///
|
|
||||||
/// @param releaseId 发布 ID
|
|
||||||
/// @param operatorId 操作人用户 ID
|
|
||||||
@Transactional(TimiServerDBConfig.ROLLBACKER)
|
|
||||||
public void revoke(String releaseId, String operatorId) {
|
|
||||||
AppRelease release = releaseMapper.select(releaseId);
|
|
||||||
if (release == null) {
|
|
||||||
throw new IllegalArgumentException("发布记录不存在");
|
|
||||||
}
|
|
||||||
Long now = System.currentTimeMillis();
|
|
||||||
release.setStatus(AppRelease.Status.REVOKED);
|
|
||||||
release.setUpdatedAt(now);
|
|
||||||
releaseMapper.updateSelective(release);
|
|
||||||
channelMapper.clearRelease(release.getProductId(), releaseId, operatorId, now);
|
|
||||||
log("APP_RELEASE_REVOKE", releaseId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 创建发布记录
|
|
||||||
///
|
|
||||||
/// @param release 发布记录
|
|
||||||
/// @param operatorId 操作人用户 ID
|
|
||||||
/// @return 创建后的记录
|
|
||||||
public AppRelease create(AppRelease release, String operatorId) {
|
|
||||||
AppRelease exists = releaseMapper.selectByVersion(release.getProductId(), release.getKind(), release.getVersionName());
|
|
||||||
if (exists != null) {
|
|
||||||
throw new IllegalArgumentException("版本已存在,不可重复使用版本号");
|
|
||||||
}
|
|
||||||
checkCompatibility(release);
|
|
||||||
Long now = System.currentTimeMillis();
|
|
||||||
release.setStatus(AppRelease.Status.DRAFT);
|
|
||||||
release.setGrayPermille(release.getGrayPermille() == null ? 0 : release.getGrayPermille());
|
|
||||||
release.setMandatory(Boolean.TRUE.equals(release.getMandatory()));
|
|
||||||
release.setCreatedBy(operatorId);
|
|
||||||
release.setCreatedAt(now);
|
|
||||||
releaseMapper.insert(release);
|
|
||||||
return release;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 查询产品列表
|
|
||||||
///
|
|
||||||
/// @return 产品列表
|
|
||||||
public List<AppProduct> listProducts() {
|
|
||||||
return productMapper.selectAll();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 保存产品
|
|
||||||
///
|
|
||||||
/// @param product 产品
|
|
||||||
/// @return 保存后的产品
|
|
||||||
public AppProduct saveProduct(AppProduct product) {
|
|
||||||
Long now = System.currentTimeMillis();
|
|
||||||
if (TimiJava.isEmpty(product.getId())) {
|
|
||||||
product.setEnabled(product.getEnabled() == null || product.getEnabled());
|
|
||||||
product.setCreatedAt(now);
|
|
||||||
productMapper.insert(product);
|
|
||||||
return product;
|
|
||||||
}
|
|
||||||
product.setUpdatedAt(now);
|
|
||||||
productMapper.updateSelective(product);
|
|
||||||
return productMapper.select(product.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 查询产品发布列表
|
|
||||||
///
|
|
||||||
/// @param productId 产品 ID
|
|
||||||
/// @return 发布列表
|
|
||||||
public List<AppRelease> listReleases(String productId) {
|
|
||||||
return releaseMapper.selectByProduct(productId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 查询产品通道列表
|
|
||||||
///
|
|
||||||
/// @param productId 产品 ID
|
|
||||||
/// @return 通道列表
|
|
||||||
public List<AppChannel> listChannels(String productId) {
|
|
||||||
return channelMapper.selectByProduct(productId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 删除草稿发布
|
|
||||||
///
|
|
||||||
/// 已发布的版本不允许删除,必须走撤回
|
|
||||||
///
|
|
||||||
/// @param releaseId 发布 ID
|
|
||||||
/// @param operatorId 操作人用户 ID
|
|
||||||
public void deleteRelease(String releaseId, String operatorId) {
|
|
||||||
AppRelease release = releaseMapper.select(releaseId);
|
|
||||||
if (release == null) {
|
|
||||||
throw new IllegalArgumentException("发布记录不存在");
|
|
||||||
}
|
|
||||||
if (release.getStatus() == AppRelease.Status.PUBLISHED) {
|
|
||||||
throw new IllegalArgumentException("已发布的版本不能删除,请先撤回");
|
|
||||||
}
|
|
||||||
releaseMapper.delete(releaseId);
|
|
||||||
log("APP_RELEASE_DELETE", releaseId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 删除通道
|
|
||||||
///
|
|
||||||
/// @param channelId 通道 ID
|
|
||||||
/// @param operatorId 操作人用户 ID
|
|
||||||
public void deleteChannel(String channelId, String operatorId) {
|
|
||||||
AppChannel channel = channelMapper.select(channelId);
|
|
||||||
if (channel == null) {
|
|
||||||
throw new IllegalArgumentException("通道不存在");
|
|
||||||
}
|
|
||||||
if (DEFAULT_CHANNEL.equals(channel.getCode())) {
|
|
||||||
throw new IllegalArgumentException("默认通道不能删除");
|
|
||||||
}
|
|
||||||
channelMapper.destroy(channelId);
|
|
||||||
log("APP_CHANNEL_DELETE", channelId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 删除产品
|
|
||||||
///
|
|
||||||
/// 产品下仍有未删除的发布记录时拒绝删除,避免留下孤儿数据
|
|
||||||
///
|
|
||||||
/// @param productId 产品 ID
|
|
||||||
/// @param operatorId 操作人用户 ID
|
|
||||||
public void deleteProduct(String productId, String operatorId) {
|
|
||||||
AppProduct product = productMapper.select(productId);
|
|
||||||
if (product == null) {
|
|
||||||
throw new IllegalArgumentException("产品不存在");
|
|
||||||
}
|
|
||||||
if (!releaseMapper.selectByProduct(productId).isEmpty()) {
|
|
||||||
throw new IllegalArgumentException("产品下仍有发布记录,不能删除");
|
|
||||||
}
|
|
||||||
productMapper.destroy(productId);
|
|
||||||
log("APP_PRODUCT_DELETE", productId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 校验兼容区间
|
|
||||||
///
|
|
||||||
/// @param release 发布记录
|
|
||||||
private void checkCompatibility(AppRelease release) {
|
|
||||||
if (release.getKind() != AppRelease.Kind.BUNDLE) {
|
|
||||||
if (release.getVersionCode() == null) {
|
|
||||||
throw new IllegalArgumentException("原生包必须指定 versionCode");
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (release.getMinVersionCode() == null) {
|
|
||||||
throw new IllegalArgumentException("热更包必须指定兼容的最低原生 versionCode");
|
|
||||||
}
|
|
||||||
if (release.getMaxVersionCode() != null && release.getMaxVersionCode() < release.getMinVersionCode()) {
|
|
||||||
throw new IllegalArgumentException("兼容区间上限不能小于下限");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 写操作日志
|
|
||||||
///
|
|
||||||
/// @param action 操作标识
|
|
||||||
/// @param result 操作对象
|
|
||||||
private void log(String action, String result) {
|
|
||||||
Logger logger = new Logger(Logger.Module.APP, Logger.Level.INFO, action);
|
|
||||||
logger.setResult(result);
|
|
||||||
loggerService.create(logger);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.app.vo;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 应用更新检查请求
|
|
||||||
///
|
|
||||||
/// 字段名遵循 Capgo 插件的上报协议,不可随意改名
|
|
||||||
///
|
|
||||||
/// @author Codex
|
|
||||||
/// @since 2026-11-06
|
|
||||||
@Data
|
|
||||||
public class AppUpdateCheckRequest {
|
|
||||||
|
|
||||||
/// 平台
|
|
||||||
@JsonProperty("platform")
|
|
||||||
protected String platform;
|
|
||||||
|
|
||||||
/// 设备标识,用于灰度分桶
|
|
||||||
@JsonProperty("device_id")
|
|
||||||
protected String deviceId;
|
|
||||||
|
|
||||||
/// 产品标识,取 Capacitor appId
|
|
||||||
@JsonProperty("app_id")
|
|
||||||
protected String appId;
|
|
||||||
|
|
||||||
/// 当前运行的 Web 包版本,内置包为 builtin
|
|
||||||
@JsonProperty("version_name")
|
|
||||||
protected String versionName;
|
|
||||||
|
|
||||||
/// 当前原生 versionCode
|
|
||||||
@JsonProperty("version_code")
|
|
||||||
protected String versionCode;
|
|
||||||
|
|
||||||
/// 当前原生版本名
|
|
||||||
@JsonProperty("version_build")
|
|
||||||
protected String versionBuild;
|
|
||||||
|
|
||||||
/// 插件版本
|
|
||||||
@JsonProperty("plugin_version")
|
|
||||||
protected String pluginVersion;
|
|
||||||
|
|
||||||
/// 系统版本
|
|
||||||
@JsonProperty("version_os")
|
|
||||||
protected String versionOs;
|
|
||||||
|
|
||||||
/// true 为模拟器
|
|
||||||
@JsonProperty("is_emulator")
|
|
||||||
protected Boolean emulator;
|
|
||||||
|
|
||||||
/// true 为生产包
|
|
||||||
@JsonProperty("is_prod")
|
|
||||||
protected Boolean prod;
|
|
||||||
|
|
||||||
/// 通道代码,为空时取 stable
|
|
||||||
protected String channel;
|
|
||||||
|
|
||||||
/// 检查接口密钥
|
|
||||||
protected String key;
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.app.vo;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 应用更新检查响应
|
|
||||||
///
|
|
||||||
/// Capgo 插件要求 url 必须存在,无更新时回显当前版本号让插件跳过下载
|
|
||||||
///
|
|
||||||
/// @author Codex
|
|
||||||
/// @since 2026-11-06
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
public class AppUpdateCheckResponse {
|
|
||||||
|
|
||||||
/// 版本号
|
|
||||||
protected String version;
|
|
||||||
|
|
||||||
/// 产物下载地址
|
|
||||||
protected String url;
|
|
||||||
|
|
||||||
/// 产物 SHA-256
|
|
||||||
protected String checksum;
|
|
||||||
|
|
||||||
/// 是否为强制更新
|
|
||||||
protected Boolean mandatory;
|
|
||||||
|
|
||||||
/// 是否为外壳安装包
|
|
||||||
///
|
|
||||||
/// 客户端据此判断走热更还是下载安装包。字段名不能叫 kind:
|
|
||||||
/// Capgo 插件把 kind 视为错误响应的标记,收到后会直接判为检查失败
|
|
||||||
protected Boolean shell;
|
|
||||||
|
|
||||||
/// 变更说明,供 App 展示更新日志
|
|
||||||
///
|
|
||||||
/// 字段名不能叫 message:Capgo 插件把 message 当作错误信息,收到会直接判为检查失败
|
|
||||||
protected String note;
|
|
||||||
|
|
||||||
/// 外壳下载地址
|
|
||||||
protected String shellUrl;
|
|
||||||
|
|
||||||
/// 外壳版本
|
|
||||||
protected String shellVersion;
|
|
||||||
|
|
||||||
/// 外壳 SHA-256
|
|
||||||
protected String shellChecksum;
|
|
||||||
|
|
||||||
/// true 为强制更新
|
|
||||||
protected Boolean shellMandatory;
|
|
||||||
|
|
||||||
/// 构建无更新响应,version 与当前一致时插件不会下载
|
|
||||||
///
|
|
||||||
/// @param currentVersion 当前运行的 Web 包版本
|
|
||||||
/// @return 无更新响应
|
|
||||||
public static AppUpdateCheckResponse none(String currentVersion) {
|
|
||||||
return new AppUpdateCheckResponse(currentVersion, "", null, false, null, null, null, null, null, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.app.vo;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 单条版本变更说明
|
|
||||||
///
|
|
||||||
/// @author Codex
|
|
||||||
/// @since 2026-11-13
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class AppUpdateNote {
|
|
||||||
|
|
||||||
/// 版本号
|
|
||||||
protected String version;
|
|
||||||
|
|
||||||
/// 变更说明,来自发布记录的 note
|
|
||||||
protected String note;
|
|
||||||
|
|
||||||
/// 首次发布时间
|
|
||||||
protected Long publishedAt;
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.app.vo;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 应用更新日志响应
|
|
||||||
///
|
|
||||||
/// 供 App 的版本历史页使用,返回当前运行版本到目标版本之间的全部变更说明
|
|
||||||
///
|
|
||||||
/// @author Codex
|
|
||||||
/// @since 2026-11-13
|
|
||||||
@Data
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class AppUpdateNotesResponse {
|
|
||||||
|
|
||||||
/// 目标版本号,为空表示当前没有可更新到的版本
|
|
||||||
protected String version;
|
|
||||||
|
|
||||||
/// 变更说明,按版本号从新到旧
|
|
||||||
protected List<AppUpdateNote> notes;
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.common.bean;
|
|
||||||
|
|
||||||
/// Groovy 脚本执行结果
|
|
||||||
///
|
|
||||||
/// @param <T> 脚本返回值类型
|
|
||||||
/// @author Codex
|
|
||||||
/// @since 2026-09-04
|
|
||||||
public record GroovyScriptExecutionResult<T>(String scriptId, String versionId, Integer version, String checksum, T result) {
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package com.imyeyu.api.modules.common.bean;
|
||||||
|
|
||||||
|
import com.imyeyu.api.modules.common.entity.Setting;
|
||||||
|
import com.imyeyu.java.bean.timi.TimiCode;
|
||||||
|
import com.imyeyu.java.bean.timi.TimiException;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置模块
|
||||||
|
*
|
||||||
|
* @author 夜雨
|
||||||
|
* @since 2026-04-24 00:59
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum SettingModule {
|
||||||
|
|
||||||
|
COMMON(Setting.Module.Common.class),
|
||||||
|
|
||||||
|
DOMAIN(Setting.Module.Domain.class),
|
||||||
|
|
||||||
|
FOREVER_MC(Setting.Module.ForeverMC.class),
|
||||||
|
|
||||||
|
MULTILINGUAL(Setting.Module.Multilingual.class),
|
||||||
|
|
||||||
|
GITEA(Setting.Module.Gitea.class),
|
||||||
|
|
||||||
|
MUSIC(Setting.Module.Music.class),
|
||||||
|
|
||||||
|
JOURNAL(Setting.Module.Journal.class),
|
||||||
|
|
||||||
|
TEMP_FILE(Setting.Module.TempFile.class),
|
||||||
|
|
||||||
|
SYSTEM(Setting.Module.System.class),
|
||||||
|
|
||||||
|
SYSTEM_STATUS(Setting.Module.SystemStatus.class);
|
||||||
|
|
||||||
|
/** 模块枚举类 */
|
||||||
|
final Class<? extends Enum<?>> clazz;
|
||||||
|
|
||||||
|
public static <T extends Enum<?>> SettingModule fromClass(Class<T> clazz) {
|
||||||
|
for (SettingModule value : values()) {
|
||||||
|
if (value.clazz.equals(clazz)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new TimiException(TimiCode.ERROR, "not found System Module: %s".formatted(clazz.getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.common.bean;
|
|
||||||
|
|
||||||
import com.imyeyu.api.annotation.SettingBizType;
|
|
||||||
import com.imyeyu.api.bean.SettingEnum;
|
|
||||||
import com.imyeyu.api.modules.common.entity.Setting;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @author 夜雨
|
|
||||||
* @since 2026-04-24 14:47
|
|
||||||
*/
|
|
||||||
@Getter
|
|
||||||
@SettingBizType("TEMP_FILE")
|
|
||||||
@AllArgsConstructor
|
|
||||||
public enum TempFileSetting implements SettingEnum {
|
|
||||||
|
|
||||||
/** 启用服务 */
|
|
||||||
ENABLE(Boolean.TRUE.toString(), Setting.ValueType.BOOLEAN),
|
|
||||||
|
|
||||||
/** 最小缓存时长 */
|
|
||||||
TTL_MIN("1h", Setting.ValueType.TIME),
|
|
||||||
|
|
||||||
/** 默认缓存时长 */
|
|
||||||
TTL_DEFAULT("3d", Setting.ValueType.TIME),
|
|
||||||
|
|
||||||
/** 最大缓存时长 */
|
|
||||||
TTL_MAX("7d", Setting.ValueType.TIME),
|
|
||||||
|
|
||||||
/** 已过期文件残留时长 */
|
|
||||||
RESIDUE_TTL("90d", Setting.ValueType.TIME),
|
|
||||||
|
|
||||||
/** 每个 IP 限制有效临时文件容量 */
|
|
||||||
LIMIT_SIZE_OF_IP("10 GB", Setting.ValueType.BYTE_SIZE);
|
|
||||||
|
|
||||||
final String defaultValue;
|
|
||||||
|
|
||||||
final Setting.ValueType valueType;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.imyeyu.api.modules.common.bean.attachment;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 夜雨
|
||||||
|
* @since 2025-12-11 18:14
|
||||||
|
*/
|
||||||
|
public class Metadata {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片
|
||||||
|
*
|
||||||
|
* @author 夜雨
|
||||||
|
* @since 2025-12-11 18:15
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public static class Image {
|
||||||
|
|
||||||
|
private int width;
|
||||||
|
|
||||||
|
private int height;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 缩略图
|
||||||
|
*
|
||||||
|
* @author 夜雨
|
||||||
|
* @since 2026-01-04 18:10
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public static class ThumbImage extends Image {
|
||||||
|
|
||||||
|
private String sourceId;
|
||||||
|
|
||||||
|
private String sourceMongoId;
|
||||||
|
|
||||||
|
private String sourceMimeType;
|
||||||
|
|
||||||
|
/** 请求宽度(缓存键之一,null 表示未指定) */
|
||||||
|
private Integer requestWidth;
|
||||||
|
|
||||||
|
/** 请求高度(缓存键之一,null 表示未指定) */
|
||||||
|
private Integer requestHeight;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.common.bean.attachment;
|
|
||||||
|
|
||||||
/// 缩略图缩放模式
|
|
||||||
///
|
|
||||||
/// @author 夜雨
|
|
||||||
/// @since 2026-08-21
|
|
||||||
public enum ThumbnailFitMode {
|
|
||||||
|
|
||||||
/// 保持比例完整放入目标尺寸
|
|
||||||
FIT,
|
|
||||||
|
|
||||||
/// 保持比例裁剪填满目标尺寸
|
|
||||||
COVER,
|
|
||||||
|
|
||||||
/// 强制缩放到目标尺寸,可能导致图片变形
|
|
||||||
STRETCH
|
|
||||||
}
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.common.config;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
|
||||||
import org.springframework.context.annotation.Configuration;
|
|
||||||
|
|
||||||
/// 通知消息队列配置
|
|
||||||
///
|
|
||||||
/// @author 夜雨
|
|
||||||
/// @since 2026-08-20
|
|
||||||
@Data
|
|
||||||
@Configuration
|
|
||||||
@ConfigurationProperties(prefix = "notify.queue")
|
|
||||||
public class NotifyQueueConfig {
|
|
||||||
|
|
||||||
private Mail mail = new Mail();
|
|
||||||
|
|
||||||
private Sms sms = new Sms();
|
|
||||||
|
|
||||||
private Wechat wechat = new Wechat();
|
|
||||||
|
|
||||||
private HTTP http = new HTTP();
|
|
||||||
|
|
||||||
/// 邮件队列配置
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public static class Mail extends Queue {
|
|
||||||
|
|
||||||
private String defaultFrom;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 短信队列配置
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public static class Sms extends Queue {
|
|
||||||
|
|
||||||
private String appId;
|
|
||||||
|
|
||||||
private String sign;
|
|
||||||
|
|
||||||
private String secretId;
|
|
||||||
|
|
||||||
private String secretKey;
|
|
||||||
|
|
||||||
private Captcha captcha;
|
|
||||||
|
|
||||||
/// 短信验证码
|
|
||||||
@Data
|
|
||||||
public static class Captcha {
|
|
||||||
|
|
||||||
private String templateId;
|
|
||||||
|
|
||||||
private int ttlMinute;
|
|
||||||
|
|
||||||
private int argIndex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 微信队列配置
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public static class Wechat extends Queue {
|
|
||||||
}
|
|
||||||
|
|
||||||
/// HTTP 队列配置
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public static class HTTP extends Queue {
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 通用队列配置
|
|
||||||
@Data
|
|
||||||
public static class Queue {
|
|
||||||
|
|
||||||
/// true 为启用
|
|
||||||
private boolean enable;
|
|
||||||
|
|
||||||
private String cron = "0/30 * * * * ?";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,96 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.common.controller;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonView;
|
|
||||||
import com.imyeyu.api.annotation.RequireCorePermission;
|
|
||||||
import com.imyeyu.api.bean.CorePermissionCode;
|
|
||||||
import com.imyeyu.api.modules.common.entity.Article;
|
|
||||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
|
||||||
import com.imyeyu.api.modules.common.service.ArticleService;
|
|
||||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
|
||||||
import com.imyeyu.spring.annotation.AOPLog;
|
|
||||||
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 lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/// 文章接口
|
|
||||||
///
|
|
||||||
/// @author Codex
|
|
||||||
/// @since 2026-09-09
|
|
||||||
@Slf4j
|
|
||||||
@RestController
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
@RequestMapping("/article")
|
|
||||||
public class ArticleController {
|
|
||||||
|
|
||||||
private final ArticleService service;
|
|
||||||
private final AttachmentService attachmentService;
|
|
||||||
|
|
||||||
/// 查询文章列表
|
|
||||||
///
|
|
||||||
/// @param page 分页参数
|
|
||||||
/// @return 文章分页
|
|
||||||
@JsonView(ResponseView.Public.class)
|
|
||||||
@RequestRateLimit
|
|
||||||
@RequireCorePermission(CorePermissionCode.ARTICLE_READ)
|
|
||||||
@PostMapping("/list")
|
|
||||||
public PageResult<Article> list(@RequestBody Page<Article> page) {
|
|
||||||
return service.page(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 查询文章详情
|
|
||||||
///
|
|
||||||
/// @param id 文章 ID
|
|
||||||
/// @return 文章详情
|
|
||||||
@JsonView(ResponseView.Public.class)
|
|
||||||
@RequestRateLimit
|
|
||||||
@RequestMapping("/detail")
|
|
||||||
public Article detail(@RequestParam String id) {
|
|
||||||
Article article = service.get(id);
|
|
||||||
article.setAttachmentList(attachmentService.listByBizId(Attachment.BizType.ARTICLE, article.getId()));
|
|
||||||
return article;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 创建文章
|
|
||||||
///
|
|
||||||
/// @param article 文章
|
|
||||||
/// @return 创建后的文章
|
|
||||||
@AOPLog
|
|
||||||
@JsonView(ResponseView.Public.class)
|
|
||||||
@RequestRateLimit
|
|
||||||
@RequireCorePermission(CorePermissionCode.ARTICLE_CREATE)
|
|
||||||
@PostMapping("/create")
|
|
||||||
public Article create(@RequestBody Article article) {
|
|
||||||
service.create(article);
|
|
||||||
return article;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 更新文章
|
|
||||||
///
|
|
||||||
/// @param article 文章
|
|
||||||
@AOPLog
|
|
||||||
@RequestRateLimit
|
|
||||||
@RequireCorePermission(CorePermissionCode.ARTICLE_UPDATE)
|
|
||||||
@PostMapping("/update")
|
|
||||||
public void update(@RequestBody Article article) {
|
|
||||||
service.update(article);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 删除文章
|
|
||||||
///
|
|
||||||
/// @param id 文章 ID
|
|
||||||
@AOPLog
|
|
||||||
@RequestRateLimit
|
|
||||||
@RequireCorePermission(CorePermissionCode.ARTICLE_DELETE)
|
|
||||||
@PostMapping("/delete")
|
|
||||||
public void delete(@RequestParam String id) {
|
|
||||||
service.delete(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,7 @@
|
|||||||
package com.imyeyu.api.modules.common.controller;
|
package com.imyeyu.api.modules.common.controller;
|
||||||
|
|
||||||
import com.imyeyu.api.modules.common.bean.attachment.ThumbnailFitMode;
|
|
||||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
import com.imyeyu.api.modules.common.entity.Attachment;
|
||||||
import com.imyeyu.api.modules.common.service.AttachmentService;
|
import com.imyeyu.api.modules.common.service.AttachmentService;
|
||||||
import com.imyeyu.api.modules.common.service.AttachmentVariantService;
|
|
||||||
import com.imyeyu.api.modules.common.service.TempFileService;
|
import com.imyeyu.api.modules.common.service.TempFileService;
|
||||||
import com.imyeyu.api.modules.common.vo.attach.TempFileResp;
|
import com.imyeyu.api.modules.common.vo.attach.TempFileResp;
|
||||||
import com.imyeyu.java.TimiJava;
|
import com.imyeyu.java.TimiJava;
|
||||||
@@ -43,7 +41,6 @@ public class AttachmentController {
|
|||||||
|
|
||||||
private final TempFileService tempFileService;
|
private final TempFileService tempFileService;
|
||||||
private final AttachmentService service;
|
private final AttachmentService service;
|
||||||
private final AttachmentVariantService variantService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询附件详情
|
* 查询附件详情
|
||||||
@@ -68,8 +65,6 @@ public class AttachmentController {
|
|||||||
@PostMapping(value = "/create", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
@PostMapping(value = "/create", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||||
public Attachment create(Attachment attachment) {
|
public Attachment create(Attachment attachment) {
|
||||||
service.create(attachment);
|
service.create(attachment);
|
||||||
attachment.setFile(null);
|
|
||||||
attachment.setInputStream(null);
|
|
||||||
return attachment;
|
return attachment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,19 +184,14 @@ public class AttachmentController {
|
|||||||
@AOPLog
|
@AOPLog
|
||||||
@IgnoreGlobalReturn
|
@IgnoreGlobalReturn
|
||||||
@GetMapping({"/read/{id}", "/download/{id}"})
|
@GetMapping({"/read/{id}", "/download/{id}"})
|
||||||
public void readById(
|
public void readById(@PathVariable String id, @RequestParam(required = false) Integer thumbWidth, @RequestParam(required = false) Integer thumbHeight) throws UnsupportedEncodingException {
|
||||||
@PathVariable String id,
|
|
||||||
@RequestParam(required = false) Integer thumbWidth,
|
|
||||||
@RequestParam(required = false) Integer thumbHeight,
|
|
||||||
@RequestParam(defaultValue = "FIT") ThumbnailFitMode fitMode
|
|
||||||
) throws UnsupportedEncodingException {
|
|
||||||
HttpServletResponse resp = TimiSpring.getResponse();
|
HttpServletResponse resp = TimiSpring.getResponse();
|
||||||
Attachment attach = service.get(id);
|
Attachment attach = service.get(id);
|
||||||
if (attach == null) {
|
if (attach == null) {
|
||||||
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
responseAttachment(attach, thumbWidth, thumbHeight, fitMode);
|
responseAttachment(attach, thumbWidth, thumbHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
@AOPLog
|
@AOPLog
|
||||||
@@ -217,31 +207,21 @@ public class AttachmentController {
|
|||||||
public void read(@RequestParam String id) throws UnsupportedEncodingException {
|
public void read(@RequestParam String id) throws UnsupportedEncodingException {
|
||||||
HttpServletResponse resp = TimiSpring.getResponse();
|
HttpServletResponse resp = TimiSpring.getResponse();
|
||||||
Attachment attach = service.get(id);
|
Attachment attach = service.get(id);
|
||||||
if (attach == null) {
|
|
||||||
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (TimiSpring.getRequest().getRequestURI().endsWith("/download")) {
|
if (TimiSpring.getRequest().getRequestURI().endsWith("/download")) {
|
||||||
resp.setHeader("Content-Disposition", Network.getFileDownloadHeader(attach.getName()));
|
resp.setHeader("Content-Disposition", Network.getFileDownloadHeader(attach.getName()));
|
||||||
}
|
}
|
||||||
response(attach, false);
|
response(attach);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void responseAttachment(
|
private void responseAttachment(Attachment attach, Integer thumbWidth, Integer thumbHeight) throws UnsupportedEncodingException {
|
||||||
Attachment attach,
|
HttpServletResponse resp = TimiSpring.getResponse();
|
||||||
Integer thumbWidth,
|
if (attach != null && TimiSpring.getRequest().getRequestURI().endsWith("/download") && attach.getName() != null) {
|
||||||
Integer thumbHeight,
|
resp.setHeader("Content-Disposition", Network.getFileDownloadHeader(attach.getName()));
|
||||||
ThumbnailFitMode fitMode
|
}
|
||||||
) throws UnsupportedEncodingException {
|
responseThumb(attach, thumbWidth, thumbHeight);
|
||||||
responseThumb(attach, thumbWidth, thumbHeight, fitMode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void responseThumb(
|
protected void responseThumb(Attachment attachment, Integer thumbWidth, Integer thumbHeight) {
|
||||||
Attachment attachment,
|
|
||||||
Integer thumbWidth,
|
|
||||||
Integer thumbHeight,
|
|
||||||
ThumbnailFitMode fitMode
|
|
||||||
) throws UnsupportedEncodingException {
|
|
||||||
HttpServletResponse resp = TimiSpring.getResponse();
|
HttpServletResponse resp = TimiSpring.getResponse();
|
||||||
if (TimiJava.isEmpty(attachment)) {
|
if (TimiJava.isEmpty(attachment)) {
|
||||||
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
||||||
@@ -249,67 +229,21 @@ public class AttachmentController {
|
|||||||
}
|
}
|
||||||
if (thumbWidth == null && thumbHeight == null) {
|
if (thumbWidth == null && thumbHeight == null) {
|
||||||
// 原图
|
// 原图
|
||||||
setDownloadHeader(attachment);
|
|
||||||
response(attachment);
|
response(attachment);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 缩略图
|
// 缩略图
|
||||||
Attachment thumb = variantService.fetchThumb(attachment, thumbWidth, thumbHeight, fitMode);
|
Attachment thumb = service.fetchThumb(attachment, thumbWidth, thumbHeight);
|
||||||
setDownloadHeader(thumb);
|
response(TimiJava.defaultIfNull(thumb, attachment));
|
||||||
response(thumb);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setDownloadHeader(Attachment attachment) throws UnsupportedEncodingException {
|
|
||||||
// 路径带 /download 就强制下载:/download/{id} 的结尾是 id,用 endsWith 匹配不到
|
|
||||||
boolean download = TimiSpring.getRequest().getRequestURI().contains("/download");
|
|
||||||
if (attachment != null && download && attachment.getName() != null) {
|
|
||||||
TimiSpring.getResponse().setHeader("Content-Disposition", Network.getFileDownloadHeader(attachment.getName()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 设置附件缓存头并处理条件请求
|
|
||||||
///
|
|
||||||
/// @param attachment 实际响应附件
|
|
||||||
/// @return true 表示客户端缓存仍有效,已返回 304
|
|
||||||
private boolean responseCache(Attachment attachment) {
|
|
||||||
HttpServletResponse resp = TimiSpring.getResponse();
|
|
||||||
resp.setHeader("Cache-Control", "private, no-cache");
|
|
||||||
String md5 = attachment.getMd5();
|
|
||||||
if (md5 == null || md5.isBlank()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
String etag = "\"%s\"".formatted(md5);
|
|
||||||
resp.setHeader("ETag", etag);
|
|
||||||
String ifNoneMatch = TimiSpring.getHeader("If-None-Match");
|
|
||||||
if (ifNoneMatch == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
for (String value : ifNoneMatch.split(",")) {
|
|
||||||
String candidate = value.trim();
|
|
||||||
if ("*".equals(candidate) || etag.equals(candidate) || ("W/" + etag).equals(candidate)) {
|
|
||||||
resp.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void response(Attachment attachment) {
|
protected void response(Attachment attachment) {
|
||||||
response(attachment, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void response(Attachment attachment, boolean cacheable) {
|
|
||||||
HttpServletResponse resp = TimiSpring.getResponse();
|
HttpServletResponse resp = TimiSpring.getResponse();
|
||||||
try {
|
try {
|
||||||
if (TimiJava.isEmpty(attachment)) {
|
if (TimiJava.isEmpty(attachment)) {
|
||||||
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!cacheable) {
|
|
||||||
resp.setHeader("Cache-Control", "private, no-store");
|
|
||||||
} else if (responseCache(attachment)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
resp.setContentType(attachment.getMimeType());
|
resp.setContentType(attachment.getMimeType());
|
||||||
attachment.doResponse();
|
attachment.doResponse();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -1,100 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.common.controller;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonView;
|
|
||||||
import com.imyeyu.api.annotation.RequireCorePermission;
|
|
||||||
import com.imyeyu.api.bean.CorePermissionCode;
|
|
||||||
import com.imyeyu.api.modules.common.entity.Feedback;
|
|
||||||
import com.imyeyu.api.modules.common.service.FeedbackService;
|
|
||||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
|
||||||
import com.imyeyu.spring.TimiSpring;
|
|
||||||
import com.imyeyu.spring.annotation.AOPLog;
|
|
||||||
import com.imyeyu.spring.annotation.CaptchaValid;
|
|
||||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
|
||||||
import com.imyeyu.spring.bean.CaptchaData;
|
|
||||||
import com.imyeyu.spring.bean.Page;
|
|
||||||
import com.imyeyu.spring.bean.PageResult;
|
|
||||||
import com.imyeyu.spring.util.ResponseView;
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/// 通用反馈接口
|
|
||||||
///
|
|
||||||
/// @author Codex
|
|
||||||
/// @since 2026-08-19
|
|
||||||
@RestController
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
@RequestMapping("/feedback")
|
|
||||||
public class FeedbackController {
|
|
||||||
|
|
||||||
private final FeedbackService service;
|
|
||||||
private final UserLoginService userLoginService;
|
|
||||||
|
|
||||||
/// 提交反馈。登录用户和匿名用户均需提交图形验证码,匿名用户按 IP 限流
|
|
||||||
///
|
|
||||||
/// @param captchaData 带图形验证码的反馈请求
|
|
||||||
@AOPLog
|
|
||||||
@JsonView(ResponseView.Public.class)
|
|
||||||
@CaptchaValid
|
|
||||||
@RequestRateLimit(value = 3, inSeconds = 60)
|
|
||||||
@PostMapping("/create")
|
|
||||||
public void create(@RequestBody @Valid CaptchaData<Feedback> captchaData) {
|
|
||||||
Feedback feedback = captchaData.getData();
|
|
||||||
feedback.setIp(TimiSpring.getRequestIP());
|
|
||||||
if (userLoginService.isLogged()) {
|
|
||||||
feedback.setUserId(userLoginService.getRequireLoginUserId());
|
|
||||||
}
|
|
||||||
service.create(feedback);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 查询反馈列表
|
|
||||||
///
|
|
||||||
/// @param page 分页参数
|
|
||||||
/// @return 反馈分页
|
|
||||||
@JsonView(ResponseView.Admin.class)
|
|
||||||
@RequestRateLimit
|
|
||||||
@RequireCorePermission(CorePermissionCode.FEEDBACK_READ)
|
|
||||||
@PostMapping("/list")
|
|
||||||
public PageResult<Feedback> list(@RequestBody Page<Feedback> page) {
|
|
||||||
return service.page(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 查询反馈详情
|
|
||||||
///
|
|
||||||
/// @param id 反馈 ID
|
|
||||||
/// @return 反馈详情
|
|
||||||
@JsonView(ResponseView.Admin.class)
|
|
||||||
@RequestRateLimit
|
|
||||||
@RequireCorePermission(CorePermissionCode.FEEDBACK_READ)
|
|
||||||
@PostMapping("/detail")
|
|
||||||
public Feedback detail(@RequestParam String id) {
|
|
||||||
return service.get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 更新反馈
|
|
||||||
///
|
|
||||||
/// @param feedback 反馈
|
|
||||||
@AOPLog
|
|
||||||
@RequestRateLimit
|
|
||||||
@RequireCorePermission(CorePermissionCode.FEEDBACK_UPDATE)
|
|
||||||
@PostMapping("/update")
|
|
||||||
public void update(@RequestBody Feedback feedback) {
|
|
||||||
feedback.setRespondedBy(userLoginService.getRequireLoginUserId());
|
|
||||||
service.update(feedback);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 删除反馈
|
|
||||||
///
|
|
||||||
/// @param id 反馈 ID
|
|
||||||
@AOPLog
|
|
||||||
@RequestRateLimit
|
|
||||||
@RequireCorePermission(CorePermissionCode.FEEDBACK_DELETE)
|
|
||||||
@PostMapping("/delete")
|
|
||||||
public void delete(@RequestParam String id) {
|
|
||||||
service.delete(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.imyeyu.api.modules.common.controller;
|
package com.imyeyu.api.modules.common.controller;
|
||||||
|
|
||||||
import com.imyeyu.api.modules.common.vo.ClientLogRequest;
|
|
||||||
import com.imyeyu.api.modules.system.entity.Logger;
|
import com.imyeyu.api.modules.system.entity.Logger;
|
||||||
import com.imyeyu.api.modules.system.service.LoggerService;
|
import com.imyeyu.api.modules.system.service.LoggerService;
|
||||||
import com.imyeyu.spring.annotation.AOPLog;
|
import com.imyeyu.spring.annotation.AOPLog;
|
||||||
@@ -30,9 +29,7 @@ public class LoggerController {
|
|||||||
@AOPLog
|
@AOPLog
|
||||||
@RequiredToken
|
@RequiredToken
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
public void create(@Valid @RequestBody ClientLogRequest request) {
|
public void create(@Valid @RequestBody Logger logger) {
|
||||||
Logger logger = Logger.info(Logger.Module.COMMON, "CLIENT_LOG");
|
|
||||||
logger.setContent(request.getContent());
|
|
||||||
service.create(logger);
|
service.create(logger);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,250 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.common.controller;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonView;
|
|
||||||
import com.imyeyu.api.annotation.RequireCorePermission;
|
|
||||||
import com.imyeyu.api.bean.CorePermissionCode;
|
|
||||||
import com.imyeyu.api.modules.common.entity.Notify;
|
|
||||||
import com.imyeyu.api.modules.common.entity.NotifyDetail;
|
|
||||||
import com.imyeyu.api.modules.common.service.NotifyDetailService;
|
|
||||||
import com.imyeyu.api.modules.common.service.NotifyService;
|
|
||||||
import com.imyeyu.api.modules.common.service.SmsService;
|
|
||||||
import com.imyeyu.api.modules.common.vo.NotifyManagementItem;
|
|
||||||
import com.imyeyu.api.modules.user.entity.User;
|
|
||||||
import com.imyeyu.api.modules.user.service.UserLoginService;
|
|
||||||
import com.imyeyu.api.modules.user.service.UserService;
|
|
||||||
import com.imyeyu.java.TimiJava;
|
|
||||||
import com.imyeyu.spring.annotation.AOPLog;
|
|
||||||
import com.imyeyu.spring.annotation.CaptchaValid;
|
|
||||||
import com.imyeyu.spring.annotation.RequestRateLimit;
|
|
||||||
import com.imyeyu.spring.annotation.RequiredToken;
|
|
||||||
import com.imyeyu.spring.bean.CaptchaData;
|
|
||||||
import com.imyeyu.spring.bean.Page;
|
|
||||||
import com.imyeyu.spring.bean.PageResult;
|
|
||||||
import com.imyeyu.spring.util.ResponseView;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
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;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
/// 通知接口
|
|
||||||
///
|
|
||||||
/// @author 夜雨
|
|
||||||
/// @since 2026-08-20
|
|
||||||
@RestController
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
@RequestMapping("/notify")
|
|
||||||
public class NotifyController {
|
|
||||||
|
|
||||||
|
|
||||||
private final SmsService smsService;
|
|
||||||
private final UserService userService;
|
|
||||||
private final NotifyService service;
|
|
||||||
private final UserLoginService userLoginService;
|
|
||||||
private final NotifyDetailService detailService;
|
|
||||||
|
|
||||||
/// 创建通知,同时创建通知详情
|
|
||||||
///
|
|
||||||
/// @param notify 通知及通知详情
|
|
||||||
/// @return 创建后的通知
|
|
||||||
@RequireCorePermission(CorePermissionCode.NOTIFY_CREATE)
|
|
||||||
@RequiredToken
|
|
||||||
@PostMapping("/create")
|
|
||||||
public Notify create(@RequestBody Notify notify) {
|
|
||||||
String sendFrom = userLoginService.isLogged() ? userLoginService.getRequireLoginUserId() : null;
|
|
||||||
notify.setCreatedBy(sendFrom);
|
|
||||||
for (NotifyDetail detail : notify.getDetailList()) {
|
|
||||||
detail.setNotifyId(notify.getId());
|
|
||||||
if (TimiJava.isNotEmpty(sendFrom)) {
|
|
||||||
detail.setSendFrom(sendFrom);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
service.create(notify);
|
|
||||||
return notify;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 查询通知详情
|
|
||||||
///
|
|
||||||
/// @param id 通知 ID
|
|
||||||
/// @return 通知及通知详情
|
|
||||||
@JsonView(ResponseView.Public.class)
|
|
||||||
@RequireCorePermission(CorePermissionCode.NOTIFY_READ)
|
|
||||||
@RequiredToken
|
|
||||||
@RequestMapping("/detail")
|
|
||||||
public Notify detail(@RequestParam String id) {
|
|
||||||
return fillDetailList(service.get(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 查询管理端通知列表
|
|
||||||
///
|
|
||||||
/// @param page 分页参数
|
|
||||||
/// @return 管理端通知列表
|
|
||||||
@JsonView(ResponseView.Admin.class)
|
|
||||||
@RequireCorePermission(CorePermissionCode.NOTIFY_READ)
|
|
||||||
@RequiredToken
|
|
||||||
@PostMapping("/management/list")
|
|
||||||
public PageResult<NotifyManagementItem> managementList(@RequestBody(required = false) Page<Notify> page) {
|
|
||||||
return service.pageManagement(page, userLoginService.getRequireLoginUserId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 查询管理端通知详情及收件人
|
|
||||||
///
|
|
||||||
/// @param id 通知 ID
|
|
||||||
/// @return 通知详情及收件人
|
|
||||||
@JsonView(ResponseView.Admin.class)
|
|
||||||
@RequireCorePermission(CorePermissionCode.NOTIFY_READ)
|
|
||||||
@RequiredToken
|
|
||||||
@PostMapping("/management/detail")
|
|
||||||
public Notify managementDetail(@RequestParam String id) {
|
|
||||||
return fillDetailList(service.getManagement(id, userLoginService.getRequireLoginUserId()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 删除通知及其通知详情
|
|
||||||
///
|
|
||||||
/// @param id 通知 ID
|
|
||||||
@RequireCorePermission(CorePermissionCode.NOTIFY_DELETE)
|
|
||||||
@RequiredToken
|
|
||||||
@PostMapping("/delete")
|
|
||||||
public void delete(@RequestParam String id) {
|
|
||||||
service.delete(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 取消尚未成功发送的通知详情
|
|
||||||
///
|
|
||||||
/// @param id 通知 ID
|
|
||||||
@RequireCorePermission(CorePermissionCode.NOTIFY_CANCEL)
|
|
||||||
@RequiredToken
|
|
||||||
@PostMapping("/cancel")
|
|
||||||
public void cancel(@RequestParam String id) {
|
|
||||||
service.cancel(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 删除管理端通知及其通知详情
|
|
||||||
///
|
|
||||||
/// @param id 通知 ID
|
|
||||||
@RequireCorePermission(CorePermissionCode.NOTIFY_DELETE)
|
|
||||||
@RequiredToken
|
|
||||||
@PostMapping("/management/delete")
|
|
||||||
public void managementDelete(@RequestParam String id) {
|
|
||||||
service.deleteManagement(id, userLoginService.getRequireLoginUserId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 取消管理端尚未成功发送的通知
|
|
||||||
///
|
|
||||||
/// @param id 通知 ID
|
|
||||||
@RequireCorePermission(CorePermissionCode.NOTIFY_CANCEL)
|
|
||||||
@RequiredToken
|
|
||||||
@PostMapping("/management/cancel")
|
|
||||||
public void managementCancel(@RequestParam String id) {
|
|
||||||
service.cancelManagement(id, userLoginService.getRequireLoginUserId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@AOPLog
|
|
||||||
@CaptchaValid
|
|
||||||
@RequestRateLimit(value = 1, inSeconds = 59)
|
|
||||||
@PostMapping("/sms/captcha/create")
|
|
||||||
public String smsCaptchaCreate(@RequestBody CaptchaData<Notify> req) {
|
|
||||||
return smsService.captchaCreate(req.getData());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 查询当前用户的站内通知
|
|
||||||
///
|
|
||||||
/// @param page 分页参数
|
|
||||||
/// @param unreadOnly true 为只查询未读通知
|
|
||||||
/// @return 站内通知分页结果
|
|
||||||
@RequireCorePermission(CorePermissionCode.NOTIFY_READ)
|
|
||||||
@RequiredToken
|
|
||||||
@PostMapping("/internal/internal")
|
|
||||||
public PageResult<NotifyDetail> listInternal(
|
|
||||||
@RequestBody(required = false) Page<NotifyDetail> page,
|
|
||||||
@RequestParam(defaultValue = "false") boolean unreadOnly
|
|
||||||
) {
|
|
||||||
return detailService.pageInternalByUserId(page, userLoginService.getRequireLoginUserId(), unreadOnly);
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonView(ResponseView.Public.class)
|
|
||||||
@RequireCorePermission(CorePermissionCode.NOTIFY_READ)
|
|
||||||
@RequiredToken
|
|
||||||
@PostMapping("/internal/detail")
|
|
||||||
public NotifyDetail internalDetail(@RequestParam String id) {
|
|
||||||
NotifyDetail detail = detailService.getInternalByUserId(id, userLoginService.getRequireLoginUserId());
|
|
||||||
if (TimiJava.isNotEmpty(detail.getSendFrom())) {
|
|
||||||
detail.setFromUser(userService.get(detail.getSendFrom()));
|
|
||||||
}
|
|
||||||
if (TimiJava.isNotEmpty(detail.getSendTo())) {
|
|
||||||
detail.setToUser(userService.get(detail.getSendTo()));
|
|
||||||
}
|
|
||||||
return detail;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 隐藏当前用户的一条站内通知
|
|
||||||
///
|
|
||||||
/// @param id 通知详情 ID
|
|
||||||
@RequireCorePermission(CorePermissionCode.NOTIFY_READ)
|
|
||||||
@RequiredToken
|
|
||||||
@PostMapping("/internal/delete")
|
|
||||||
public void deleteInternal(@RequestParam String id) {
|
|
||||||
detailService.hideInternalByUserId(id, userLoginService.getRequireLoginUserId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 查询当前用户未读通知数量
|
|
||||||
///
|
|
||||||
/// @return 未读通知数量
|
|
||||||
@RequireCorePermission(CorePermissionCode.NOTIFY_READ)
|
|
||||||
@RequiredToken
|
|
||||||
@PostMapping("/internal/unread/count")
|
|
||||||
public long countUnreadSite() {
|
|
||||||
return detailService.countUnreadSiteByUserId(userLoginService.getRequireLoginUserId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 标记当前用户的一条站内通知已读
|
|
||||||
///
|
|
||||||
/// @param id 通知详情 ID
|
|
||||||
@RequireCorePermission(CorePermissionCode.NOTIFY_READ)
|
|
||||||
@RequiredToken
|
|
||||||
@PostMapping("/internal/read")
|
|
||||||
public void markSiteRead(@RequestParam String id) {
|
|
||||||
detailService.markSiteRead(userLoginService.getRequireLoginUserId(), id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 标记当前用户全部站内通知已读
|
|
||||||
@RequireCorePermission(CorePermissionCode.NOTIFY_READ)
|
|
||||||
@RequiredToken
|
|
||||||
@PostMapping("/internal/read/all")
|
|
||||||
public void markAllSiteRead() {
|
|
||||||
detailService.markAllSiteRead(userLoginService.getRequireLoginUserId());
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 回填通知详情中的用户信息
|
|
||||||
///
|
|
||||||
/// @param notify 通知
|
|
||||||
/// @return 已回填用户信息的通知
|
|
||||||
private Notify fillDetailList(Notify notify) {
|
|
||||||
if (notify == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
List<NotifyDetail> detailList = detailService.listByNotifyId(notify.getId());
|
|
||||||
Set<String> userIdSet = detailList.stream()
|
|
||||||
.filter(item -> item.getMsgType() == NotifyDetail.MsgType.INTERNAL)
|
|
||||||
.flatMap(item -> Stream.of(item.getSendFrom(), item.getSendTo()))
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
Map<String, User> userMap = userService.mapByIdList(userIdSet);
|
|
||||||
for (NotifyDetail detail : detailList) {
|
|
||||||
if (TimiJava.isNotEmpty(detail.getSendFrom())) {
|
|
||||||
detail.setFromUser(userMap.get(detail.getSendFrom()));
|
|
||||||
}
|
|
||||||
if (TimiJava.isNotEmpty(detail.getSendTo())) {
|
|
||||||
detail.setToUser(userMap.get(detail.getSendTo()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
notify.setDetailList(detailList);
|
|
||||||
return notify;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,65 +10,33 @@ import com.imyeyu.spring.annotation.RequestRateLimit;
|
|||||||
import com.imyeyu.spring.bean.Page;
|
import com.imyeyu.spring.bean.Page;
|
||||||
import com.imyeyu.spring.bean.PageResult;
|
import com.imyeyu.spring.bean.PageResult;
|
||||||
import com.imyeyu.spring.util.ResponseView;
|
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.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
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
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@RequestMapping("/setting")
|
@RequestMapping("/system/setting")
|
||||||
public class SettingController {
|
public class SettingController {
|
||||||
|
|
||||||
private final SettingService service;
|
private final SettingService service;
|
||||||
|
|
||||||
/**
|
|
||||||
* 查询公开配置映射
|
|
||||||
*
|
|
||||||
* @param bizType 业务类型
|
|
||||||
* @param bizId 业务 ID,可为空
|
|
||||||
* @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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询配置列表
|
* 查询配置列表
|
||||||
*
|
*
|
||||||
* @param page 分页查询
|
* @param page 分页查询
|
||||||
* @return 配置列表
|
* @return 配置列表
|
||||||
*/
|
*/
|
||||||
@Operation(summary = "查询配置列表", description = "分页查询配置,需要 SETTING:READ 权限。")
|
|
||||||
@JsonView(ResponseView.Admin.class)
|
@JsonView(ResponseView.Admin.class)
|
||||||
@RequestRateLimit
|
@RequestRateLimit
|
||||||
@RequireCorePermission(CorePermissionCode.SETTING_READ)
|
@RequireCorePermission(CorePermissionCode.SETTING_READ)
|
||||||
@@ -83,14 +51,10 @@ public class SettingController {
|
|||||||
* @param id 配置 ID
|
* @param id 配置 ID
|
||||||
* @return 配置详情
|
* @return 配置详情
|
||||||
*/
|
*/
|
||||||
@Operation(summary = "查询配置详情", description = "按配置 ID 查询配置,需要 SETTING:READ 权限。")
|
|
||||||
@JsonView(ResponseView.Admin.class)
|
@JsonView(ResponseView.Admin.class)
|
||||||
@RequestRateLimit
|
@RequestRateLimit
|
||||||
@RequireCorePermission(CorePermissionCode.SETTING_READ)
|
|
||||||
@PostMapping("/detail")
|
@PostMapping("/detail")
|
||||||
public Setting detail(
|
public Setting detail(@RequestBody String id) {
|
||||||
@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "配置 ID", required = true)
|
|
||||||
@RequestBody String id) {
|
|
||||||
return service.get(id);
|
return service.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,10 +64,8 @@ public class SettingController {
|
|||||||
* @param setting 配置
|
* @param setting 配置
|
||||||
* @return 配置
|
* @return 配置
|
||||||
*/
|
*/
|
||||||
@Operation(summary = "创建配置", description = "创建配置,需要 SETTING:CREATE 权限。")
|
|
||||||
@AOPLog
|
@AOPLog
|
||||||
@JsonView(ResponseView.Admin.class)
|
@JsonView(ResponseView.Admin.class)
|
||||||
@RequireCorePermission(CorePermissionCode.SETTING_CREATE)
|
|
||||||
@RequestRateLimit
|
@RequestRateLimit
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
public Setting create(@RequestBody Setting setting) {
|
public Setting create(@RequestBody Setting setting) {
|
||||||
@@ -116,10 +78,8 @@ public class SettingController {
|
|||||||
*
|
*
|
||||||
* @param setting 配置
|
* @param setting 配置
|
||||||
*/
|
*/
|
||||||
@Operation(summary = "更新配置", description = "更新配置,需要 SETTING:UPDATE 权限。")
|
|
||||||
@AOPLog
|
@AOPLog
|
||||||
@RequestRateLimit
|
@RequestRateLimit
|
||||||
@RequireCorePermission(CorePermissionCode.SETTING_UPDATE)
|
|
||||||
@PostMapping("/update")
|
@PostMapping("/update")
|
||||||
public void update(@RequestBody Setting setting) {
|
public void update(@RequestBody Setting setting) {
|
||||||
service.update(setting);
|
service.update(setting);
|
||||||
@@ -130,14 +90,11 @@ public class SettingController {
|
|||||||
*
|
*
|
||||||
* @param id 配置 ID
|
* @param id 配置 ID
|
||||||
*/
|
*/
|
||||||
@Operation(summary = "删除配置", description = "按配置 ID 删除配置,需要 SETTING:DELETE 权限。")
|
|
||||||
@AOPLog
|
@AOPLog
|
||||||
@RequestRateLimit
|
@RequestRateLimit
|
||||||
@RequireCorePermission(CorePermissionCode.SETTING_DELETE)
|
@RequireCorePermission(CorePermissionCode.SETTING_DELETE)
|
||||||
@PostMapping("/delete")
|
@PostMapping("/delete")
|
||||||
public void delete(
|
public void delete(@RequestBody String id) {
|
||||||
@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "配置 ID", required = true)
|
|
||||||
@RequestBody String id) {
|
|
||||||
service.delete(id);
|
service.delete(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.imyeyu.api.modules.common.entity;
|
package com.imyeyu.api.modules.common.entity;
|
||||||
|
|
||||||
import com.imyeyu.api.modules.common.bean.attachment.SettingSupport;
|
import com.imyeyu.api.modules.common.bean.attachment.SettingSupport;
|
||||||
import com.imyeyu.api.modules.user.entity.User;
|
|
||||||
import com.imyeyu.spring.annotation.table.PageIgnore;
|
import com.imyeyu.spring.annotation.table.PageIgnore;
|
||||||
import com.imyeyu.spring.annotation.table.Transient;
|
import com.imyeyu.spring.annotation.table.Transient;
|
||||||
import com.imyeyu.spring.entity.UUIDEntity;
|
import com.imyeyu.spring.entity.UUIDEntity;
|
||||||
@@ -29,17 +28,7 @@ public class Article extends UUIDEntity implements SettingSupport {
|
|||||||
public enum BizType {
|
public enum BizType {
|
||||||
|
|
||||||
/** 博客 */
|
/** 博客 */
|
||||||
BLOG,
|
BLOG
|
||||||
|
|
||||||
/// GAO 门店日记
|
|
||||||
GAO_STORE_DIARY,
|
|
||||||
|
|
||||||
GAO_HELP,
|
|
||||||
|
|
||||||
GAO_SYSTEM,
|
|
||||||
|
|
||||||
/// 反馈
|
|
||||||
FEEDBACK
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -60,19 +49,6 @@ public class Article extends UUIDEntity implements SettingSupport {
|
|||||||
TIP_TAP
|
TIP_TAP
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 文章状态
|
|
||||||
public enum Status {
|
|
||||||
|
|
||||||
/// 草稿
|
|
||||||
DART,
|
|
||||||
|
|
||||||
/// 正常
|
|
||||||
NORMAL,
|
|
||||||
|
|
||||||
/// 隐藏
|
|
||||||
HIDDEN
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 业务类型 */
|
/** 业务类型 */
|
||||||
protected BizType bizType;
|
protected BizType bizType;
|
||||||
|
|
||||||
@@ -82,8 +58,8 @@ public class Article extends UUIDEntity implements SettingSupport {
|
|||||||
/** 标题 */
|
/** 标题 */
|
||||||
protected String title;
|
protected String title;
|
||||||
|
|
||||||
/** 描述 */
|
/** 摘要 */
|
||||||
protected String description;
|
protected String digest;
|
||||||
|
|
||||||
/** 正文类型 */
|
/** 正文类型 */
|
||||||
protected ContentType contentType;
|
protected ContentType contentType;
|
||||||
@@ -98,21 +74,9 @@ public class Article extends UUIDEntity implements SettingSupport {
|
|||||||
/** 喜欢数量 */
|
/** 喜欢数量 */
|
||||||
protected Integer likes;
|
protected Integer likes;
|
||||||
|
|
||||||
/** 文章状态 */
|
|
||||||
protected Status status;
|
|
||||||
|
|
||||||
/// 最后更新用户 ID
|
|
||||||
protected String updatedBy;
|
|
||||||
|
|
||||||
@Transient
|
|
||||||
protected User updater;
|
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
protected List<Setting> settingList;
|
protected List<Setting> settingList;
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
protected List<Comment> commentList;
|
protected List<Comment> commentList;
|
||||||
|
|
||||||
@Transient
|
|
||||||
protected List<Attachment> attachmentList;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,49 +30,15 @@ public class Attachment extends UUIDEntity {
|
|||||||
/// @since 2026-07-17 20:52
|
/// @since 2026-07-17 20:52
|
||||||
public enum BizType {
|
public enum BizType {
|
||||||
|
|
||||||
ARTICLE,
|
|
||||||
|
|
||||||
NOTIFY_DETAIL,
|
|
||||||
|
|
||||||
USER,
|
USER,
|
||||||
|
|
||||||
GAO_CUSTOMER,
|
GAO_CUSTOMER,
|
||||||
|
|
||||||
GAO_PRODUCT,
|
|
||||||
|
|
||||||
GAO_PRODUCT_SKU,
|
|
||||||
|
|
||||||
GAO_EVENT_RECORD,
|
GAO_EVENT_RECORD,
|
||||||
|
|
||||||
GAO_FUND_RECORD,
|
|
||||||
|
|
||||||
GAO_STOCK_RECORD,
|
|
||||||
|
|
||||||
GAO_ORDER_FULFILLMENT,
|
|
||||||
|
|
||||||
GAO_SALES_ORDER,
|
|
||||||
|
|
||||||
GAO_POINT_REDEMPTION,
|
|
||||||
|
|
||||||
GAO_POINT_REDEMPTION_RETURN,
|
|
||||||
|
|
||||||
GAO_RECYCLE_ITEM,
|
|
||||||
|
|
||||||
GAO_RECYCLE_EXCHANGE,
|
|
||||||
|
|
||||||
GAO_RECYCLE_EXCHANGE_REVOKE,
|
|
||||||
|
|
||||||
GAO_RECYCLE_PAYMENT,
|
|
||||||
|
|
||||||
GAO_CUSTOMER_FOLLOW_UP_REMINDER,
|
|
||||||
|
|
||||||
GAO_DATA_EXPORT,
|
|
||||||
|
|
||||||
TEMP_FILE,
|
TEMP_FILE,
|
||||||
|
|
||||||
MIRROR,
|
MIRROR
|
||||||
|
|
||||||
APP_RELEASE
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected BizType bizType;
|
protected BizType bizType;
|
||||||
|
|||||||
@@ -1,68 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.common.entity;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
||||||
import com.imyeyu.api.modules.common.bean.attachment.ThumbnailFitMode;
|
|
||||||
import com.imyeyu.spring.annotation.table.AutoUUID;
|
|
||||||
import com.imyeyu.spring.annotation.table.Id;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
/// 附件缩略图变体记录
|
|
||||||
///
|
|
||||||
/// @author 夜雨
|
|
||||||
/// @since 2026-08-21
|
|
||||||
@Data
|
|
||||||
public class AttachmentVariant {
|
|
||||||
|
|
||||||
/// 变体 ID
|
|
||||||
@Id
|
|
||||||
@AutoUUID
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
/// 源附件 ID
|
|
||||||
private String sourceAttachmentId;
|
|
||||||
|
|
||||||
/// 源文件版本,使用源 GridFS ID
|
|
||||||
private String sourceMongoId;
|
|
||||||
|
|
||||||
/// 源文件摘要
|
|
||||||
private String sourceMd5;
|
|
||||||
|
|
||||||
/// 请求宽度,0 表示未指定
|
|
||||||
private int requestWidth;
|
|
||||||
|
|
||||||
/// 请求高度,0 表示未指定
|
|
||||||
private int requestHeight;
|
|
||||||
|
|
||||||
/// 缩放模式
|
|
||||||
private ThumbnailFitMode fitMode;
|
|
||||||
|
|
||||||
/// 输出格式
|
|
||||||
private String outputFormat;
|
|
||||||
|
|
||||||
/// 缩略图算法版本
|
|
||||||
private String algorithmVersion;
|
|
||||||
|
|
||||||
/// 缩略图 GridFS ID
|
|
||||||
private String mongoId;
|
|
||||||
|
|
||||||
/// 缩略图名称
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
/// 缩略图 MIME 类型
|
|
||||||
private String mimeType;
|
|
||||||
|
|
||||||
/// 缩略图元数据
|
|
||||||
private ObjectNode metadata;
|
|
||||||
|
|
||||||
/// 缩略图大小
|
|
||||||
private long size;
|
|
||||||
|
|
||||||
/// 缩略图摘要
|
|
||||||
private String md5;
|
|
||||||
|
|
||||||
/// 创建时间
|
|
||||||
private long createdAt;
|
|
||||||
|
|
||||||
/// 过期时间
|
|
||||||
private long expireAt;
|
|
||||||
}
|
|
||||||
@@ -1,61 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.common.entity;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
|
||||||
import com.imyeyu.spring.annotation.table.AutoUUID;
|
|
||||||
import com.imyeyu.spring.annotation.table.Id;
|
|
||||||
import com.imyeyu.spring.entity.Creatable;
|
|
||||||
import com.imyeyu.spring.entity.Destroyable;
|
|
||||||
import com.imyeyu.spring.entity.IDEntity;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/// 通知基础队列实体
|
|
||||||
///
|
|
||||||
/// @author 夜雨
|
|
||||||
/// @since 2026-08-20
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
public class BaseQueueEntity implements IDEntity<String>, Creatable, Destroyable {
|
|
||||||
|
|
||||||
/** 主键 */
|
|
||||||
@Id
|
|
||||||
@AutoUUID
|
|
||||||
protected String id;
|
|
||||||
|
|
||||||
/** 所属通知详情 ID */
|
|
||||||
protected String notifyDetailId;
|
|
||||||
|
|
||||||
/** 内容 */
|
|
||||||
protected String content;
|
|
||||||
|
|
||||||
/** 参数 */
|
|
||||||
protected JsonNode args;
|
|
||||||
|
|
||||||
/** 发送去向 */
|
|
||||||
protected String sendTo;
|
|
||||||
|
|
||||||
/** 发送时间 */
|
|
||||||
protected Long sendAt;
|
|
||||||
|
|
||||||
/** 剩余重试次数 */
|
|
||||||
protected Integer retry;
|
|
||||||
|
|
||||||
/** 超时时间 */
|
|
||||||
protected Long timeoutAt;
|
|
||||||
|
|
||||||
/** 创建时间 */
|
|
||||||
protected Long createdAt;
|
|
||||||
|
|
||||||
/// 从通知详情创建队列实体
|
|
||||||
///
|
|
||||||
/// @param detail 通知详情
|
|
||||||
public BaseQueueEntity(NotifyDetail detail) {
|
|
||||||
notifyDetailId = detail.getId();
|
|
||||||
content = detail.getContent();
|
|
||||||
args = detail.getArgs();
|
|
||||||
sendTo = detail.getSendTo();
|
|
||||||
sendAt = detail.getSendAt();
|
|
||||||
retry = detail.getRetry();
|
|
||||||
timeoutAt = detail.getTimeoutAt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.common.entity;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonView;
|
|
||||||
import com.imyeyu.api.bean.ModuleCode;
|
|
||||||
import com.imyeyu.spring.annotation.table.Transient;
|
|
||||||
import com.imyeyu.spring.entity.UUIDEntity;
|
|
||||||
import com.imyeyu.spring.util.ResponseView;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/// 通用反馈
|
|
||||||
///
|
|
||||||
/// @author Codex
|
|
||||||
/// @since 2026-08-19
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class Feedback extends UUIDEntity {
|
|
||||||
|
|
||||||
/// 反馈处理状态
|
|
||||||
public enum Status {
|
|
||||||
|
|
||||||
/// 待处理
|
|
||||||
PENDING,
|
|
||||||
|
|
||||||
/// 已回复
|
|
||||||
REPLIED,
|
|
||||||
|
|
||||||
/// 已关闭
|
|
||||||
CLOSED
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 所属模块
|
|
||||||
@JsonView(ResponseView.Public.class)
|
|
||||||
private ModuleCode module;
|
|
||||||
|
|
||||||
/// 提交用户 ID,匿名反馈为 null
|
|
||||||
@JsonView(ResponseView.Admin.class)
|
|
||||||
private String userId;
|
|
||||||
|
|
||||||
/// 反馈内容文章 ID
|
|
||||||
@JsonView(ResponseView.Public.class)
|
|
||||||
private String contentId;
|
|
||||||
|
|
||||||
/// 联系方式
|
|
||||||
@JsonView(ResponseView.Public.class)
|
|
||||||
private String contact;
|
|
||||||
|
|
||||||
/// 提交 IP
|
|
||||||
@JsonView(ResponseView.Admin.class)
|
|
||||||
private String ip;
|
|
||||||
|
|
||||||
/// 处理状态
|
|
||||||
@JsonView(ResponseView.Public.class)
|
|
||||||
private Status status;
|
|
||||||
|
|
||||||
/// 管理员回复文章 ID
|
|
||||||
@JsonView(ResponseView.Public.class)
|
|
||||||
private String responseId;
|
|
||||||
|
|
||||||
/// 回复用户 ID
|
|
||||||
@JsonView(ResponseView.Admin.class)
|
|
||||||
private String respondedBy;
|
|
||||||
|
|
||||||
/// 回复时间
|
|
||||||
@JsonView(ResponseView.Public.class)
|
|
||||||
private Long respondedAt;
|
|
||||||
|
|
||||||
/// 管理员回复文章
|
|
||||||
@Transient
|
|
||||||
@JsonView(ResponseView.Public.class)
|
|
||||||
private Article content;
|
|
||||||
|
|
||||||
/// 管理员回复文章
|
|
||||||
@Transient
|
|
||||||
@JsonView(ResponseView.Public.class)
|
|
||||||
private Article response;
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.common.entity;
|
|
||||||
|
|
||||||
import com.imyeyu.spring.annotation.table.Transient;
|
|
||||||
import com.imyeyu.spring.entity.UUIDEntity;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
/// Groovy 脚本
|
|
||||||
///
|
|
||||||
/// @author Codex
|
|
||||||
/// @since 2026-09-04
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class GroovyScript extends UUIDEntity {
|
|
||||||
|
|
||||||
///
|
|
||||||
///
|
|
||||||
/// @author 夜雨
|
|
||||||
/// @since 2026/9/4 14:54
|
|
||||||
public enum BizType {
|
|
||||||
|
|
||||||
/// GAO 积分规则
|
|
||||||
GAO_POINT_RULE
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 业务归属
|
|
||||||
private BizType bizType;
|
|
||||||
|
|
||||||
/// 业务内唯一代码
|
|
||||||
private String code;
|
|
||||||
|
|
||||||
/// 名称
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
/// 说明
|
|
||||||
private String description;
|
|
||||||
|
|
||||||
/// true 为允许执行已发布版本
|
|
||||||
private Boolean enabled;
|
|
||||||
|
|
||||||
/// 当前发布版本 ID
|
|
||||||
private String publishedVersionId;
|
|
||||||
|
|
||||||
@Transient
|
|
||||||
private GroovyScriptVersion latest;
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.common.entity;
|
|
||||||
|
|
||||||
import com.imyeyu.spring.entity.UUIDEntity;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
/// Groovy 脚本版本
|
|
||||||
///
|
|
||||||
/// @author Codex
|
|
||||||
/// @since 2026-09-04
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class GroovyScriptVersion extends UUIDEntity {
|
|
||||||
|
|
||||||
/// 脚本 ID
|
|
||||||
private String scriptId;
|
|
||||||
|
|
||||||
/// 版本号
|
|
||||||
private Integer version;
|
|
||||||
|
|
||||||
/// 脚本内容
|
|
||||||
private String content;
|
|
||||||
|
|
||||||
/// 脚本内容 SHA-256
|
|
||||||
private String checksum;
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.common.entity;
|
|
||||||
|
|
||||||
import com.imyeyu.spring.annotation.table.Table;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
/// HTTP 回调队列
|
|
||||||
///
|
|
||||||
/// @author 夜雨
|
|
||||||
/// @since 2026-08-20
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@Table("http_queue")
|
|
||||||
public class HTTPQueue extends BaseQueueEntity {
|
|
||||||
|
|
||||||
/** HTTP 请求方法 */
|
|
||||||
protected String method;
|
|
||||||
|
|
||||||
/// 从通知详情创建 HTTP 队列
|
|
||||||
///
|
|
||||||
/// @param detail 通知详情
|
|
||||||
public HTTPQueue(NotifyDetail detail) {
|
|
||||||
super(detail);
|
|
||||||
method = "POST";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.common.entity;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/// 邮件发送队列
|
|
||||||
///
|
|
||||||
/// @author 夜雨
|
|
||||||
/// @since 2026-08-20
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class MailQueue extends BaseQueueEntity {
|
|
||||||
|
|
||||||
/** 邮件标题 */
|
|
||||||
protected String subject;
|
|
||||||
|
|
||||||
/** 邮件附件 */
|
|
||||||
protected String attachments;
|
|
||||||
|
|
||||||
/** 发送来源 */
|
|
||||||
protected String sendFrom;
|
|
||||||
|
|
||||||
/// 从通知详情创建邮件队列
|
|
||||||
///
|
|
||||||
/// @param detail 通知详情
|
|
||||||
public MailQueue(NotifyDetail detail) {
|
|
||||||
super(detail);
|
|
||||||
subject = detail.getSubject();
|
|
||||||
sendFrom = detail.getSendFrom();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 邮件附件
|
|
||||||
@Data
|
|
||||||
public static class Attachment {
|
|
||||||
|
|
||||||
/** 附件类型 */
|
|
||||||
private Type type;
|
|
||||||
|
|
||||||
/** 附件值 */
|
|
||||||
private String value;
|
|
||||||
|
|
||||||
/// 附件来源类型
|
|
||||||
public enum Type {
|
|
||||||
|
|
||||||
/** 系统附件 */
|
|
||||||
E2INS_ATTACH,
|
|
||||||
|
|
||||||
/** URL 附件 */
|
|
||||||
URL
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
package com.imyeyu.api.modules.common.entity;
|
package com.imyeyu.api.modules.common.entity;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import com.imyeyu.java.bean.Language;
|
import com.imyeyu.java.bean.Language;
|
||||||
import com.imyeyu.spring.annotation.table.Column;
|
|
||||||
import com.imyeyu.spring.entity.UUIDEntity;
|
import com.imyeyu.spring.entity.UUIDEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
@@ -17,18 +15,6 @@ public class Multilingual extends UUIDEntity {
|
|||||||
|
|
||||||
protected String zhCN;
|
protected String zhCN;
|
||||||
|
|
||||||
@Column("zh_cn_pinyin_full")
|
|
||||||
@JsonIgnore
|
|
||||||
protected String zhCNPinyinFull;
|
|
||||||
|
|
||||||
@Column("zh_cn_pinyin_initial")
|
|
||||||
@JsonIgnore
|
|
||||||
protected String zhCNPinyinInitial;
|
|
||||||
|
|
||||||
@Column("zh_cn_pinyin_mixed")
|
|
||||||
@JsonIgnore
|
|
||||||
protected String zhCNPinyinMixed;
|
|
||||||
|
|
||||||
protected String zhTW;
|
protected String zhTW;
|
||||||
|
|
||||||
protected String enUS;
|
protected String enUS;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package com.imyeyu.api.modules.common.entity;
|
package com.imyeyu.api.modules.common.entity;
|
||||||
|
|
||||||
|
import com.imyeyu.spring.annotation.table.AutoUUID;
|
||||||
|
import com.imyeyu.spring.annotation.table.Id;
|
||||||
import com.imyeyu.spring.annotation.table.Transient;
|
import com.imyeyu.spring.annotation.table.Transient;
|
||||||
import com.imyeyu.spring.entity.UUIDEntity;
|
import com.imyeyu.spring.entity.UUIDEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -17,14 +19,19 @@ import java.util.List;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class Notify extends UUIDEntity {
|
public class Notify extends UUIDEntity {
|
||||||
|
|
||||||
|
/** 主键 */
|
||||||
|
@Id
|
||||||
|
@AutoUUID
|
||||||
|
private String id;
|
||||||
|
|
||||||
/** 业务类型 */
|
/** 业务类型 */
|
||||||
private String bizType;
|
private String bizType;
|
||||||
|
|
||||||
/** 业务提醒类型 */
|
/** 提醒业务类型 */
|
||||||
private String bizRemindedType;
|
private String bizRemindedType;
|
||||||
|
|
||||||
/** 业务提醒查重键 */
|
/** 提醒业务 ID */
|
||||||
private String bizRemindedKey;
|
private String bizRemindedId;
|
||||||
|
|
||||||
/** 参数 */
|
/** 参数 */
|
||||||
private String args;
|
private String args;
|
||||||
|
|||||||
@@ -1,24 +1,11 @@
|
|||||||
package com.imyeyu.api.modules.common.entity;
|
package com.imyeyu.api.modules.common.entity;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonView;
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
|
||||||
import com.imyeyu.api.TimiServerAPI;
|
|
||||||
import com.imyeyu.api.modules.common.service.BaseQueueService;
|
|
||||||
import com.imyeyu.api.modules.common.service.HTTPQueueService;
|
|
||||||
import com.imyeyu.api.modules.common.service.MailQueueService;
|
|
||||||
import com.imyeyu.api.modules.common.service.SmsQueueService;
|
|
||||||
import com.imyeyu.api.modules.common.service.WechatQueueService;
|
|
||||||
import com.imyeyu.api.modules.user.entity.User;
|
|
||||||
import com.imyeyu.spring.annotation.table.Transient;
|
import com.imyeyu.spring.annotation.table.Transient;
|
||||||
import com.imyeyu.spring.entity.UUIDEntity;
|
import com.imyeyu.spring.entity.UUIDEntity;
|
||||||
import com.imyeyu.spring.util.ResponseView;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通知详情
|
* 通知详情
|
||||||
*
|
*
|
||||||
@@ -38,32 +25,13 @@ public class NotifyDetail extends UUIDEntity {
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum MsgType {
|
public enum MsgType {
|
||||||
|
|
||||||
/** 站内通知,不进入外部消息队列 */
|
SMS,
|
||||||
INTERNAL(null),
|
|
||||||
|
|
||||||
SMS(SmsQueueService.class),
|
MAIL,
|
||||||
|
|
||||||
MAIL(MailQueueService.class),
|
HTTP,
|
||||||
|
|
||||||
HTTP(HTTPQueueService.class),
|
WECHAT;
|
||||||
|
|
||||||
WECHAT(WechatQueueService.class);
|
|
||||||
|
|
||||||
private final Class<? extends BaseQueueService<?>> queueServiceClass;
|
|
||||||
|
|
||||||
/// 获取消息队列服务
|
|
||||||
///
|
|
||||||
/// @return 消息队列服务
|
|
||||||
public BaseQueueService<?> getService() {
|
|
||||||
return TimiServerAPI.applicationContext.getBean(queueServiceClass);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 判断是否需要外部消息队列
|
|
||||||
///
|
|
||||||
/// @return true 为需要外部消息队列
|
|
||||||
public boolean isQueue() {
|
|
||||||
return queueServiceClass != null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -85,94 +53,45 @@ public class NotifyDetail extends UUIDEntity {
|
|||||||
FAIL
|
FAIL
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 内容类型
|
|
||||||
///
|
|
||||||
/// @author 夜雨
|
|
||||||
/// @since 2026-08-24
|
|
||||||
public enum ContentType {
|
|
||||||
|
|
||||||
/** 纯文本 */
|
|
||||||
TEXT,
|
|
||||||
|
|
||||||
/** TipTap 富文本 */
|
|
||||||
TIP_TAP
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 所属通知 ID */
|
/** 所属通知 ID */
|
||||||
@JsonView(ResponseView.Public.class)
|
|
||||||
private String notifyId;
|
private String notifyId;
|
||||||
|
|
||||||
/** 消息类型 */
|
/** 消息类型 */
|
||||||
@JsonView(ResponseView.Public.class)
|
|
||||||
private MsgType msgType;
|
private MsgType msgType;
|
||||||
|
|
||||||
/** 模板 ID */
|
/** 模板 ID */
|
||||||
@JsonView(ResponseView.Admin.class)
|
|
||||||
private String templateId;
|
private String templateId;
|
||||||
|
|
||||||
/** 标题 */
|
/** 标题 */
|
||||||
@JsonView(ResponseView.Public.class)
|
|
||||||
private String subject;
|
private String subject;
|
||||||
|
|
||||||
/** 内容 */
|
/** 内容 */
|
||||||
@JsonView(ResponseView.Public.class)
|
private String data;
|
||||||
private String content;
|
|
||||||
|
|
||||||
/// 内容类型
|
|
||||||
@JsonView(ResponseView.Public.class)
|
|
||||||
private ContentType contentType;
|
|
||||||
|
|
||||||
/** 参数 */
|
/** 参数 */
|
||||||
@JsonView(ResponseView.Public.class)
|
private String args;
|
||||||
private JsonNode args;
|
|
||||||
|
|
||||||
/** 发送来源 */
|
/** 发送来源 */
|
||||||
@JsonView(ResponseView.Public.class)
|
|
||||||
private String sendFrom;
|
private String sendFrom;
|
||||||
|
|
||||||
/** 发送去向 */
|
/** 发送去向 */
|
||||||
@JsonView(ResponseView.Public.class)
|
|
||||||
private String sendTo;
|
private String sendTo;
|
||||||
|
|
||||||
/** 发送时间 */
|
/** 发送时间 */
|
||||||
@JsonView(ResponseView.Public.class)
|
|
||||||
private Long sendAt;
|
private Long sendAt;
|
||||||
|
|
||||||
/** 重试计数 */
|
/** 重试计数 */
|
||||||
@JsonView(ResponseView.Admin.class)
|
|
||||||
private Integer retry;
|
private Integer retry;
|
||||||
|
|
||||||
/** 超时时间 */
|
/** 超时时间 */
|
||||||
@JsonView(ResponseView.Admin.class)
|
|
||||||
private Long timeoutAt;
|
private Long timeoutAt;
|
||||||
|
|
||||||
/** 结果描述 */
|
/** 结果描述 */
|
||||||
@JsonView(ResponseView.Admin.class)
|
|
||||||
private String resultDesc;
|
private String resultDesc;
|
||||||
|
|
||||||
/** 状态 */
|
/** 状态 */
|
||||||
@JsonView(ResponseView.Public.class)
|
|
||||||
private Status status;
|
private Status status;
|
||||||
|
|
||||||
/** 已读时间,站内通知未读时为空 */
|
|
||||||
@JsonView(ResponseView.Public.class)
|
|
||||||
private Long readAt;
|
|
||||||
|
|
||||||
/// 收件人隐藏时间,仅站内通知生效
|
|
||||||
@JsonIgnore
|
|
||||||
private Long hiddenAt;
|
|
||||||
|
|
||||||
@Transient
|
@Transient
|
||||||
protected Notify notify;
|
protected Notify notify;
|
||||||
|
|
||||||
@Transient
|
|
||||||
protected User fromUser;
|
|
||||||
|
|
||||||
@Transient
|
|
||||||
protected User toUser;
|
|
||||||
|
|
||||||
/// 媒体附件列表
|
|
||||||
@JsonView(ResponseView.Public.class)
|
|
||||||
@Transient
|
|
||||||
protected List<Attachment> attachmentList;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||||
import com.imyeyu.api.TimiServerAPI;
|
import com.imyeyu.api.TimiServerAPI;
|
||||||
|
import com.imyeyu.api.modules.common.bean.SettingModule;
|
||||||
import com.imyeyu.spring.annotation.table.Transient;
|
import com.imyeyu.spring.annotation.table.Transient;
|
||||||
import com.imyeyu.spring.entity.UUIDEntity;
|
import com.imyeyu.spring.entity.UUIDEntity;
|
||||||
import com.imyeyu.spring.util.ResponseView;
|
import com.imyeyu.spring.util.ResponseView;
|
||||||
@@ -61,9 +62,6 @@ public class Setting extends UUIDEntity {
|
|||||||
/** 时间 */
|
/** 时间 */
|
||||||
TIME,
|
TIME,
|
||||||
|
|
||||||
/// 字节大小
|
|
||||||
BYTE_SIZE,
|
|
||||||
|
|
||||||
/** 时长 */
|
/** 时长 */
|
||||||
DURATION,
|
DURATION,
|
||||||
|
|
||||||
@@ -77,19 +75,6 @@ public class Setting extends UUIDEntity {
|
|||||||
JSON_OBJECT
|
JSON_OBJECT
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 配置作用域
|
|
||||||
///
|
|
||||||
/// @author Codex
|
|
||||||
/// @since 2026-11-16
|
|
||||||
public enum Scope {
|
|
||||||
|
|
||||||
/// 系统级,bizId 固定为全零 UUID,启动时自动初始化
|
|
||||||
SYSTEM,
|
|
||||||
|
|
||||||
/// 业务级,bizId 为业务对象 ID,启动时不初始化
|
|
||||||
BUSINESS
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonView(ResponseView.Public.class)
|
@JsonView(ResponseView.Public.class)
|
||||||
private String bizType;
|
private String bizType;
|
||||||
|
|
||||||
@@ -117,6 +102,16 @@ public class Setting extends UUIDEntity {
|
|||||||
@Transient
|
@Transient
|
||||||
private Enum<?> keyRaw;
|
private Enum<?> keyRaw;
|
||||||
|
|
||||||
|
public Setting(Enum<?> key) {
|
||||||
|
setKeyRaw(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Setting(Enum<?> key, Object value, ValueType valueType) {
|
||||||
|
setKeyRaw(key);
|
||||||
|
this.value = value.toString();
|
||||||
|
this.valueType = valueType;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 以字符串形式返回配置值
|
* 以字符串形式返回配置值
|
||||||
*
|
*
|
||||||
@@ -226,4 +221,298 @@ public class Setting extends UUIDEntity {
|
|||||||
throw new IllegalArgumentException("setting value is not valid json: %s".formatted(value), e);
|
throw new IllegalArgumentException("setting value is not valid json: %s".formatted(value), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setKeyRaw(Enum<?> key) {
|
||||||
|
this.keyRaw = key;
|
||||||
|
this.bizType = SettingModule.fromClass(key.getClass()).toString();
|
||||||
|
this.code = key.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean is(Enum<?> key) {
|
||||||
|
return SettingModule.fromClass(key.getClass()).toString().equals(bizType) && key.toString().equals(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author 夜雨
|
||||||
|
* @since 2026-04-24 14:23
|
||||||
|
*/
|
||||||
|
public static final class Module {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author 夜雨
|
||||||
|
* @since 2026-04-24 15:39
|
||||||
|
*/
|
||||||
|
public enum Common {
|
||||||
|
|
||||||
|
/** 微信收款码 */
|
||||||
|
WECHAT_RECEIVE_QR_CODE
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 域名
|
||||||
|
*
|
||||||
|
* @author 夜雨
|
||||||
|
* @since 2026-04-26 17:18
|
||||||
|
*/
|
||||||
|
public enum Domain {
|
||||||
|
|
||||||
|
ROOT,
|
||||||
|
|
||||||
|
API,
|
||||||
|
|
||||||
|
GIT,
|
||||||
|
|
||||||
|
BLOG,
|
||||||
|
|
||||||
|
SPACE,
|
||||||
|
|
||||||
|
FOREVER_MC
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author 夜雨
|
||||||
|
* @since 2026-04-24 15:14
|
||||||
|
*/
|
||||||
|
public enum Blog {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author 夜雨
|
||||||
|
* @since 2026-04-24 15:03
|
||||||
|
*/
|
||||||
|
public enum User {
|
||||||
|
|
||||||
|
/** 启用登录 */
|
||||||
|
ENABLE_LOGIN,
|
||||||
|
|
||||||
|
/** 启用注册 */
|
||||||
|
ENABLE_REGISTER,
|
||||||
|
|
||||||
|
/** 允许数据更新 */
|
||||||
|
ENABLE_PROFILE_UPDATE,
|
||||||
|
|
||||||
|
/** 令牌有效期 */
|
||||||
|
TOKEN_TTL
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author 夜雨
|
||||||
|
* @since 2026-04-24 15:21
|
||||||
|
*/
|
||||||
|
public enum Comment {
|
||||||
|
|
||||||
|
/** 启用服务 */
|
||||||
|
ENABLE
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author 夜雨
|
||||||
|
* @since 2026-04-24 15:03
|
||||||
|
*/
|
||||||
|
public enum ICP {
|
||||||
|
|
||||||
|
IMYEYU_COM
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author 夜雨
|
||||||
|
* @since 2026-04-24 15:01
|
||||||
|
*/
|
||||||
|
public enum ForeverMC {
|
||||||
|
|
||||||
|
PLAYER_BIND_MAX,
|
||||||
|
|
||||||
|
LOGIN_TOKEN_TTL
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author 夜雨
|
||||||
|
* @since 2026-04-24 14:57
|
||||||
|
*/
|
||||||
|
public enum Multilingual {
|
||||||
|
|
||||||
|
/** 翻译 API */
|
||||||
|
TRANSLATE_API,
|
||||||
|
|
||||||
|
/** 翻译 AppId */
|
||||||
|
TRANSLATE_APP_ID,
|
||||||
|
|
||||||
|
/** 翻译密钥 */
|
||||||
|
TRANSLATE_KEY,
|
||||||
|
|
||||||
|
/** 翻译计划任务表达式 */
|
||||||
|
TRANSLATE_CORN,
|
||||||
|
|
||||||
|
/** 缓存时长 */
|
||||||
|
CACHE_TTL
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author 夜雨
|
||||||
|
* @since 2026-04-24 14:55
|
||||||
|
*/
|
||||||
|
public enum Gitea {
|
||||||
|
|
||||||
|
/** 接口地址 */
|
||||||
|
API,
|
||||||
|
|
||||||
|
/** 关于页面所属文章 ID */
|
||||||
|
ABOUT_ARTICLE_ID,
|
||||||
|
|
||||||
|
/** 仓库文件地址 */
|
||||||
|
REPOSITORY_PATH
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author 夜雨
|
||||||
|
* @since 2026-04-24 14:52
|
||||||
|
*/
|
||||||
|
public enum Music {
|
||||||
|
|
||||||
|
/** 启用服务 */
|
||||||
|
ENABLE,
|
||||||
|
|
||||||
|
/** 通信消息最大帧长度 */
|
||||||
|
MAX_FRAME_LENGTH,
|
||||||
|
|
||||||
|
/** 受控端 IP */
|
||||||
|
PLAYER_IP,
|
||||||
|
|
||||||
|
/** 受控端端口 */
|
||||||
|
PLAYER_PORT,
|
||||||
|
|
||||||
|
/** 控制端 IP */
|
||||||
|
CONTROLLER_IP,
|
||||||
|
|
||||||
|
/** 控制端端口 */
|
||||||
|
CONTROLLER_PORT,
|
||||||
|
|
||||||
|
/** 控制端入口地址 */
|
||||||
|
CONTROLLER_URI,
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author 夜雨
|
||||||
|
* @since 2026-04-24 14:49
|
||||||
|
*/
|
||||||
|
public enum Journal {
|
||||||
|
|
||||||
|
/** 启用服务 */
|
||||||
|
ENABLE,
|
||||||
|
|
||||||
|
/** 审核中 */
|
||||||
|
REVIEWING,
|
||||||
|
|
||||||
|
/** 访问密钥 */
|
||||||
|
KEY,
|
||||||
|
|
||||||
|
/** 微信小程序 AppId */
|
||||||
|
APP_ID,
|
||||||
|
|
||||||
|
/** 微信小程序 AppSecret */
|
||||||
|
APP_SECRET,
|
||||||
|
|
||||||
|
/** 备忘录内容 */
|
||||||
|
MEMO,
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author 夜雨
|
||||||
|
* @since 2026-04-24 14:47
|
||||||
|
*/
|
||||||
|
public enum TempFile {
|
||||||
|
|
||||||
|
/** 启用服务 */
|
||||||
|
ENABLE,
|
||||||
|
|
||||||
|
/** 最小缓存时长 */
|
||||||
|
TTL_MIN,
|
||||||
|
|
||||||
|
/** 默认缓存时长 */
|
||||||
|
TTL_DEFAULT,
|
||||||
|
|
||||||
|
/** 最大缓存时长 */
|
||||||
|
TTL_MAX,
|
||||||
|
|
||||||
|
/** 已过期文件残留时长 */
|
||||||
|
RESIDUE_TTL,
|
||||||
|
|
||||||
|
/** 每个 IP 限制有效临时文件容量 */
|
||||||
|
LIMIT_SIZE_OF_IP
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author 夜雨
|
||||||
|
* @since 2026-04-27 14:35
|
||||||
|
*/
|
||||||
|
public enum FileSync {
|
||||||
|
|
||||||
|
ENABLE,
|
||||||
|
|
||||||
|
CRON,
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author 夜雨
|
||||||
|
* @since 2026-04-24 14:23
|
||||||
|
*/
|
||||||
|
public enum System {
|
||||||
|
|
||||||
|
/** 文件系统基准路径 */
|
||||||
|
FILE_BASE_PATH,
|
||||||
|
|
||||||
|
/** 设置缓存时长 */
|
||||||
|
SETTING_TTL,
|
||||||
|
|
||||||
|
/** 哀悼滤镜 */
|
||||||
|
ENABLE_MOURN_FILTER,
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @author 夜雨
|
||||||
|
* @since 2026-04-24 14:23
|
||||||
|
*/
|
||||||
|
public enum SystemStatus {
|
||||||
|
|
||||||
|
/** 状态采集数据量 */
|
||||||
|
LIMIT,
|
||||||
|
|
||||||
|
/** 状态采集网卡 */
|
||||||
|
NETWORK_MAC,
|
||||||
|
|
||||||
|
/** 状态采集频率 */
|
||||||
|
RATE,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.common.entity;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/// 短信发送队列
|
|
||||||
///
|
|
||||||
/// @author 夜雨
|
|
||||||
/// @since 2026-08-20
|
|
||||||
@Data
|
|
||||||
@NoArgsConstructor
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class SmsQueue extends BaseQueueEntity {
|
|
||||||
|
|
||||||
/** 短信模板 ID */
|
|
||||||
protected String templateId;
|
|
||||||
|
|
||||||
/// 从通知详情创建短信队列
|
|
||||||
///
|
|
||||||
/// @param detail 通知详情
|
|
||||||
public SmsQueue(NotifyDetail detail) {
|
|
||||||
super(detail);
|
|
||||||
templateId = detail.getTemplateId();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.imyeyu.api.modules.common.entity;
|
package com.imyeyu.api.modules.common.entity;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
||||||
import com.imyeyu.api.annotation.MultilingualField;
|
import com.imyeyu.api.annotation.MultilingualField;
|
||||||
import com.imyeyu.spring.annotation.table.Transient;
|
import com.imyeyu.spring.annotation.table.Transient;
|
||||||
import com.imyeyu.spring.entity.UUIDEntity;
|
import com.imyeyu.spring.entity.UUIDEntity;
|
||||||
@@ -15,21 +14,6 @@ import lombok.EqualsAndHashCode;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class Tag extends UUIDEntity {
|
public class Tag extends UUIDEntity {
|
||||||
|
|
||||||
///
|
|
||||||
///
|
|
||||||
/// @author 夜雨
|
|
||||||
/// @since 2026-08-12 16:49
|
|
||||||
public enum OwnerType {
|
|
||||||
|
|
||||||
GAO_STORE
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 归属类型
|
|
||||||
protected OwnerType ownerType;
|
|
||||||
|
|
||||||
/// 归属 ID
|
|
||||||
protected String ownerId;
|
|
||||||
|
|
||||||
/// 名称多语言 ID
|
/// 名称多语言 ID
|
||||||
protected String nameLangId;
|
protected String nameLangId;
|
||||||
|
|
||||||
@@ -41,9 +25,4 @@ public class Tag extends UUIDEntity {
|
|||||||
/// 中文名称
|
/// 中文名称
|
||||||
@Transient
|
@Transient
|
||||||
protected String zhCN;
|
protected String zhCN;
|
||||||
|
|
||||||
/// 当前查询业务下的使用量
|
|
||||||
@Transient
|
|
||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
|
||||||
protected Long useCount;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.common.entity;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
/// 微信消息发送队列
|
|
||||||
///
|
|
||||||
/// @author 夜雨
|
|
||||||
/// @since 2026-08-20
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
public class WechatQueue extends BaseQueueEntity {
|
|
||||||
|
|
||||||
/// 从通知详情创建微信队列
|
|
||||||
///
|
|
||||||
/// @param detail 通知详情
|
|
||||||
public WechatQueue(NotifyDetail detail) {
|
|
||||||
super(detail);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -32,12 +32,30 @@ public interface AttachmentMapper extends BaseMapper<Attachment, String>, RawMap
|
|||||||
|
|
||||||
List<Attachment> selectByBizId(Attachment.BizType bizType, String bizId, List<String> attachTypes, Page<Attachment> page);
|
List<Attachment> selectByBizId(Attachment.BizType bizType, String bizId, List<String> attachTypes, Page<Attachment> page);
|
||||||
|
|
||||||
List<Attachment> selectAllByBizIdList(Attachment.BizType bizType, Collection<String> bizIdList, List<String> attachTypes);
|
List<Attachment> selectByBizIdList(Attachment.BizType bizType, Collection<String> bizIdList, List<String> attachTypes);
|
||||||
|
|
||||||
List<Attachment> selectImageByBizIdList(Attachment.BizType bizType, Collection<String> bizIdList, String attachType);
|
|
||||||
|
|
||||||
long countByBizId(Attachment.BizType bizType, String bizId, List<String> attachTypes);
|
long countByBizId(Attachment.BizType bizType, String bizId, List<String> attachTypes);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按源附件 ID 与请求尺寸查询已缓存缩略图
|
||||||
|
*
|
||||||
|
* @param bizType 源附件业务类型
|
||||||
|
* @param sourceId 源附件 ID
|
||||||
|
* @param requestWidth 请求宽度,{@code null} 表示未指定
|
||||||
|
* @param requestHeight 请求高度,{@code null} 表示未指定
|
||||||
|
* @return 缩略图附件,不存在返回 {@code null}
|
||||||
|
*/
|
||||||
|
Attachment selectThumb(Attachment.BizType bizType, String sourceId, Integer requestWidth, Integer requestHeight);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询源附件的所有未销毁缩略图(含已软删除)
|
||||||
|
*
|
||||||
|
* @param sourceId 源附件 ID
|
||||||
|
* @return 缩略图列表
|
||||||
|
*/
|
||||||
|
@Select("SELECT * FROM attachment WHERE biz_id = #{sourceId} AND attach_type = 'THUMB' AND is_destroyed = FALSE")
|
||||||
|
List<Attachment> selectThumbsBySourceId(String sourceId);
|
||||||
|
|
||||||
@Select("SELECT * FROM attachment WHERE `is_destroyed` = FALSE AND `destroy_at` < " + UNIX_TIME)
|
@Select("SELECT * FROM attachment WHERE `is_destroyed` = FALSE AND `destroy_at` < " + UNIX_TIME)
|
||||||
List<Attachment> selectNeedDestroy();
|
List<Attachment> selectNeedDestroy();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,86 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.common.mapper;
|
|
||||||
|
|
||||||
import com.imyeyu.api.modules.common.entity.Attachment;
|
|
||||||
import com.imyeyu.api.modules.common.entity.AttachmentVariant;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/// 附件缩略图变体 Mapper
|
|
||||||
///
|
|
||||||
/// @author 夜雨
|
|
||||||
/// @since 2026-08-21
|
|
||||||
public interface AttachmentVariantMapper {
|
|
||||||
|
|
||||||
/// 查询有效缩略图附件
|
|
||||||
///
|
|
||||||
/// @param sourceAttachmentId 源附件 ID
|
|
||||||
/// @param sourceMongoId 源 GridFS ID
|
|
||||||
/// @param requestWidth 请求宽度,0 表示未指定
|
|
||||||
/// @param requestHeight 请求高度,0 表示未指定
|
|
||||||
/// @param fitMode 缩放模式
|
|
||||||
/// @param outputFormat 输出格式
|
|
||||||
/// @param algorithmVersion 算法版本
|
|
||||||
/// @param now 当前时间
|
|
||||||
/// @return 缩略图附件
|
|
||||||
Attachment selectValidAttachment(
|
|
||||||
@Param("sourceAttachmentId") String sourceAttachmentId,
|
|
||||||
@Param("sourceMongoId") String sourceMongoId,
|
|
||||||
@Param("requestWidth") int requestWidth,
|
|
||||||
@Param("requestHeight") int requestHeight,
|
|
||||||
@Param("fitMode") String fitMode,
|
|
||||||
@Param("outputFormat") String outputFormat,
|
|
||||||
@Param("algorithmVersion") String algorithmVersion,
|
|
||||||
@Param("now") long now
|
|
||||||
);
|
|
||||||
|
|
||||||
/// 查询指定变体记录,不判断是否过期
|
|
||||||
///
|
|
||||||
/// @param sourceAttachmentId 源附件 ID
|
|
||||||
/// @param sourceMongoId 源 GridFS ID
|
|
||||||
/// @param requestWidth 请求宽度,0 表示未指定
|
|
||||||
/// @param requestHeight 请求高度,0 表示未指定
|
|
||||||
/// @param fitMode 缩放模式
|
|
||||||
/// @param outputFormat 输出格式
|
|
||||||
/// @param algorithmVersion 算法版本
|
|
||||||
/// @return 变体记录
|
|
||||||
AttachmentVariant selectByKey(
|
|
||||||
@Param("sourceAttachmentId") String sourceAttachmentId,
|
|
||||||
@Param("sourceMongoId") String sourceMongoId,
|
|
||||||
@Param("requestWidth") int requestWidth,
|
|
||||||
@Param("requestHeight") int requestHeight,
|
|
||||||
@Param("fitMode") String fitMode,
|
|
||||||
@Param("outputFormat") String outputFormat,
|
|
||||||
@Param("algorithmVersion") String algorithmVersion
|
|
||||||
);
|
|
||||||
|
|
||||||
/// 查询源附件的所有变体
|
|
||||||
///
|
|
||||||
/// @param sourceAttachmentId 源附件 ID
|
|
||||||
/// @return 变体列表
|
|
||||||
List<AttachmentVariant> selectBySourceAttachmentId(@Param("sourceAttachmentId") String sourceAttachmentId);
|
|
||||||
|
|
||||||
/// 查询已过期变体
|
|
||||||
///
|
|
||||||
/// @param now 当前时间
|
|
||||||
/// @return 已过期变体列表
|
|
||||||
List<AttachmentVariant> selectExpired(@Param("now") long now);
|
|
||||||
|
|
||||||
/// 新增变体
|
|
||||||
///
|
|
||||||
/// @param variant 变体
|
|
||||||
void insert(AttachmentVariant variant);
|
|
||||||
|
|
||||||
/// 延长缩略图变体的过期时间
|
|
||||||
///
|
|
||||||
/// @param id 变体 ID
|
|
||||||
/// @param now 当前时间
|
|
||||||
/// @param expireAt 新的过期时间
|
|
||||||
/// @return 更新记录数
|
|
||||||
int updateExpireAt(@Param("id") String id, @Param("now") long now, @Param("expireAt") long expireAt);
|
|
||||||
|
|
||||||
/// 删除变体
|
|
||||||
///
|
|
||||||
/// @param id 变体 ID
|
|
||||||
void delete(@Param("id") String id);
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.common.mapper;
|
|
||||||
|
|
||||||
import com.imyeyu.api.modules.common.entity.BaseQueueEntity;
|
|
||||||
import com.imyeyu.api.modules.common.util.QueueSQLProvider;
|
|
||||||
import com.imyeyu.spring.mapper.BaseMapper;
|
|
||||||
import org.apache.ibatis.annotations.DeleteProvider;
|
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
import org.apache.ibatis.annotations.SelectProvider;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/// 通知队列基础 Mapper
|
|
||||||
///
|
|
||||||
/// @param <T> 队列实体类型
|
|
||||||
/// @author 夜雨
|
|
||||||
/// @since 2026-08-20
|
|
||||||
public interface BaseQueueMapper<T extends BaseQueueEntity> extends BaseMapper<T, String> {
|
|
||||||
|
|
||||||
/** 查询已到发送时间的队列 */
|
|
||||||
@SelectProvider(type = QueueSQLProvider.class, method = "listReadyQueue")
|
|
||||||
List<T> listReadyQueue();
|
|
||||||
|
|
||||||
/** 根据通知详情 ID 物理删除队列 */
|
|
||||||
@DeleteProvider(type = QueueSQLProvider.class, method = "destroyByNotifyDetailId")
|
|
||||||
void destroyByNotifyDetailId(@Param("notifyDetailId") String notifyDetailId);
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.common.mapper;
|
|
||||||
|
|
||||||
import com.imyeyu.api.modules.common.entity.Feedback;
|
|
||||||
import com.imyeyu.spring.mapper.BaseMapper;
|
|
||||||
|
|
||||||
/// 通用反馈 Mapper
|
|
||||||
///
|
|
||||||
/// @author Codex
|
|
||||||
/// @since 2026-08-19
|
|
||||||
public interface FeedbackMapper extends BaseMapper<Feedback, String> {
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.common.mapper;
|
|
||||||
|
|
||||||
import com.imyeyu.api.modules.common.entity.GroovyScript;
|
|
||||||
import com.imyeyu.spring.mapper.BaseMapper;
|
|
||||||
|
|
||||||
/// Groovy 脚本 Mapper
|
|
||||||
///
|
|
||||||
/// @author Codex
|
|
||||||
/// @since 2026-09-04
|
|
||||||
public interface GroovyScriptMapper extends BaseMapper<GroovyScript, String> {
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.common.mapper;
|
|
||||||
|
|
||||||
import com.imyeyu.api.modules.common.entity.GroovyScriptVersion;
|
|
||||||
import com.imyeyu.spring.mapper.BaseMapper;
|
|
||||||
import org.apache.ibatis.annotations.Select;
|
|
||||||
|
|
||||||
/// Groovy 脚本版本 Mapper
|
|
||||||
///
|
|
||||||
/// @author Codex
|
|
||||||
/// @since 2026-09-04
|
|
||||||
public interface GroovyScriptVersionMapper extends BaseMapper<GroovyScriptVersion, String> {
|
|
||||||
|
|
||||||
@Select("SELECT * FROM `groovy_script_version` WHERE `script_id` = #{scriptId} " + NOT_DELETE + " ORDER BY `version` DESC " + LIMIT_1)
|
|
||||||
GroovyScriptVersion selectLatest(String scriptId);
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.common.mapper;
|
|
||||||
|
|
||||||
import com.imyeyu.api.modules.common.entity.HTTPQueue;
|
|
||||||
|
|
||||||
/// HTTP 队列 Mapper
|
|
||||||
///
|
|
||||||
/// @author 夜雨
|
|
||||||
/// @since 2026-08-20
|
|
||||||
public interface HTTPQueueMapper extends BaseQueueMapper<HTTPQueue> {
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
package com.imyeyu.api.modules.common.mapper;
|
|
||||||
|
|
||||||
import com.imyeyu.api.modules.common.entity.MailQueue;
|
|
||||||
|
|
||||||
/// 邮件队列 Mapper
|
|
||||||
///
|
|
||||||
/// @author 夜雨
|
|
||||||
/// @since 2026-08-20
|
|
||||||
public interface MailQueueMapper extends BaseQueueMapper<MailQueue> {
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user