@agile-team/wl-skills-kit 2.3.4 → 2.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/README.md +16 -10
- package/files/.cursor/mcp.json +8 -8
- package/files/.github/guides/README.md +13 -13
- package/files/.github/guides/architecture.md +555 -555
- package/files/.github/guides/mcp-setup.md +109 -109
- package/files/.github/guides/usage.md +184 -184
- package/files/.github/reports/README.md +65 -65
- package/files/.github/reports/SYS_DICT_INFO.md +50 -50
- package/files/.github/reports/SYS_MENU_INFO.md +247 -247
- package/files/.github/reports/SYS_PERMISSION_INFO.md +20 -20
- package/files/.github/reports//347/273/204/344/273/266/346/217/220/345/217/226/345/273/272/350/256/256.md +33 -33
- package/files/.github/reports//350/247/204/350/214/203/345/256/241/346/237/245/346/212/245/345/221/212.md +44 -44
- package/files/.github/skills/_compat/README.md +108 -108
- package/files/.github/skills/_compat/headers/agents.txt +8 -8
- package/files/.github/skills/_compat/headers/claude-code.txt +7 -7
- package/files/.github/skills/_compat/headers/cline.txt +7 -7
- package/files/.github/skills/_compat/headers/cursor-mdc.txt +16 -16
- package/files/.github/skills/_compat/headers/cursor-rules.txt +7 -7
- package/files/.github/skills/_compat/headers/github-copilot.txt +1 -1
- package/files/.github/skills/_compat/headers/kiro.txt +10 -10
- package/files/.github/skills/_compat/headers/qoder.txt +8 -8
- package/files/.github/skills/_compat/headers/trae.txt +11 -11
- package/files/.github/skills/_compat/headers/windsurf.txt +7 -7
- package/files/.github/skills/_registry.md +81 -81
- package/files/.github/skills/core/api-contract/SKILL.md +344 -344
- package/files/.github/skills/core/api-contract/USAGE.md +110 -110
- package/files/.github/skills/core/convention-audit/SKILL.md +189 -189
- package/files/.github/skills/core/convention-audit/USAGE.md +99 -99
- package/files/.github/skills/core/page-codegen/SKILL.md +973 -973
- package/files/.github/skills/core/page-codegen/USAGE.md +102 -102
- package/files/.github/skills/core/page-codegen/templates/_index.md +46 -46
- package/files/.github/skills/core/page-codegen/templates/domains/_CONTRIBUTING.md +107 -107
- package/files/.github/skills/core/page-codegen/templates/domains/produce/TPL-OPERATION-STATION.md +442 -442
- package/files/.github/skills/core/page-codegen/templates/domains/sale/README.md +26 -26
- package/files/.github/skills/core/page-codegen/templates/universal/TPL-CHANGE-HISTORY.md +276 -276
- package/files/.github/skills/core/page-codegen/templates/universal/TPL-DETAIL-TABS.md +1145 -1145
- package/files/.github/skills/core/page-codegen/templates/universal/TPL-DRIVEN.md +309 -309
- package/files/.github/skills/core/page-codegen/templates/universal/TPL-FORM-ROUTE.md +436 -436
- package/files/.github/skills/core/page-codegen/templates/universal/TPL-LIST.md +191 -191
- package/files/.github/skills/core/page-codegen/templates/universal/TPL-MASTER-DETAIL.md +148 -148
- package/files/.github/skills/core/page-codegen/templates/universal/TPL-RECORD-FORM.md +376 -376
- package/files/.github/skills/core/page-codegen/templates/universal/TPL-TREE-LIST.md +186 -186
- package/files/.github/skills/core/prototype-scan/SKILL.md +498 -498
- package/files/.github/skills/core/prototype-scan/USAGE.md +95 -95
- package/files/.github/skills/core/template-extract/SKILL.md +139 -139
- package/files/.github/skills/core/template-extract/USAGE.md +93 -93
- package/files/.github/skills/domain/README.md +51 -51
- package/files/.github/skills/sync/env.local.json +0 -5
- package/files/.github/skills/sync/menu-sync/SKILL.md +263 -263
- package/files/.github/skills/sync/menu-sync/USAGE.md +104 -104
- package/files/.github/skills/sync/menu-sync/env/env.local.json +7 -7
- package/files/.github/skills/sync/menu-sync/env/guide.md +99 -99
- package/files/.github/skills/sync/permission-sync/SKILL.md +239 -0
- package/files/.github/skills/sync/permission-sync/USAGE.md +93 -0
- package/files/.github/standards/01-toolchain.md +57 -57
- package/files/.github/standards/02-code-structure.md +111 -111
- package/files/.github/standards/03-comments.md +53 -53
- package/files/.github/standards/04-coding-basics.md +33 -33
- package/files/.github/standards/05-logging.md +38 -38
- package/files/.github/standards/06-security.md +44 -44
- package/files/.github/standards/07-config.md +52 -52
- package/files/.github/standards/08-git.md +60 -60
- package/files/.github/standards/09-typescript.md +71 -71
- package/files/.github/standards/10-pinia.md +57 -57
- package/files/.github/standards/11-form-validation.md +81 -81
- package/files/.github/standards/12-base-table.md +153 -153
- package/files/.github/standards/13-platform-components.md +123 -123
- package/files/.github/standards/index.md +89 -89
- package/files/.kiro/settings/mcp.json +8 -8
- package/files/.mcp.json +8 -8
- package/files/.vscode/mcp.json +9 -9
- package/files/demo/produce/aiflow/mmwr-customer-apply-change-history/data.ts +196 -196
- package/files/demo/produce/aiflow/mmwr-customer-apply-change-history/index.scss +150 -150
- package/files/demo/produce/aiflow/mmwr-customer-apply-change-history/index.vue +79 -79
- package/files/docs/jh-date-range.md +257 -257
- package/files/docs/jh-date.md +222 -222
- package/files/docs/jh-dept-picker.md +190 -190
- package/files/docs/jh-drag-row.md +590 -590
- package/files/docs/jh-file-upload.md +216 -216
- package/files/docs/jh-picker.md +218 -218
- package/files/docs/jh-select.md +148 -148
- package/files/docs/jh-text.md +248 -248
- package/files/docs/jh-user-picker.md +197 -197
- package/files/src/components/global/C_RightToolbar/data.ts +228 -228
- package/files/src/components/global/C_RightToolbar/index.scss +44 -44
- package/files/src/components/global/C_Splitter/index.scss +61 -61
- package/files/src/components/global/C_SvgIcon/index.scss +15 -15
- package/files/src/components/global/C_TagStatus/index.scss +20 -20
- package/files/src/components/global/C_Tree/data.ts +61 -61
- package/files/src/components/local/c_listModal/index.scss +4 -4
- package/mcp/api/roleApi.js +60 -0
- package/mcp/server.js +125 -5
- package/mcp/tools/permissionSync.js +321 -0
- package/package.json +1 -1
- package/files/.github/skills/sync/permission-sync/SKILL.draft.md +0 -91
|
@@ -1,344 +1,344 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: api-contract
|
|
3
|
-
description: "Use when: designing API contracts between frontend and backend based on prototype page inventory, defining request/response field structures, establishing naming conventions, and generating an api.md file per page for team alignment before coding. Triggers on: api contract, interface design, 接口约定, 前后端对齐, 字段定义, 接口设计, api.md."
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Skill: 接口约定(api-contract)
|
|
7
|
-
|
|
8
|
-
基于《页面清单》为每个页面生成 `api.md` 文件,放在**页面目录下**(和 index.vue 同级)。
|
|
9
|
-
|
|
10
|
-
**双重作用:**
|
|
11
|
-
|
|
12
|
-
1. **前端** — data.ts 中 `API_CONFIG` 的 URL 和字段名直接基于 api.md
|
|
13
|
-
2. **后端** — 拿到 api.md 直接出接口(Controller + Service + Entity),字段名一致,联调零成本
|
|
14
|
-
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
## 全局规范
|
|
18
|
-
|
|
19
|
-
### URL 命名
|
|
20
|
-
|
|
21
|
-
```
|
|
22
|
-
/[服务缩写]/[资源名CamelCase]/[操作]
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
| 服务缩写 | 含义 | 示例 |
|
|
26
|
-
| -------- | -------- | ------------------------------------ |
|
|
27
|
-
| pm | 生产管理 | `/pm/omptMillPlanOrder/list` |
|
|
28
|
-
| mmwr | 精整作业 | `/mmwr/mmwrTechFinish/queryTechList` |
|
|
29
|
-
| mmsm | 炼钢管理 | `/mmsm/mmsmRsltLadleUse/list` |
|
|
30
|
-
| sale | 销售管理 | `/sale/saleOrder/list` |
|
|
31
|
-
| hrms | 人力资源 | `/hrms/hrmsEmployee/list` |
|
|
32
|
-
| base | 基础数据 | `/base/cmUserGroup/list` |
|
|
33
|
-
|
|
34
|
-
### 标准操作集
|
|
35
|
-
|
|
36
|
-
| 操作 | 方法 | URL 后缀 | 说明 |
|
|
37
|
-
| -------- | ---- | ----------------- | ----------------------------------------------------- |
|
|
38
|
-
| 分页列表 | POST | `/list` | 基类 `super({ url: { list } })` 自动调用 |
|
|
39
|
-
| 单条查询 | GET | `/getById?id=xxx` | `getAction(API_CONFIG.getById, { id })` |
|
|
40
|
-
| 新增 | POST | `/save` | `postAction(API_CONFIG.save, formData)` |
|
|
41
|
-
| 编辑 | POST | `/update` | `postAction(API_CONFIG.update, formData)` |
|
|
42
|
-
| 删除 | POST | `/remove` | 基类 `super({ url: { remove } })` + `this.remove(id)` |
|
|
43
|
-
| 导出 | GET | `/export` | `getAction(API_CONFIG.export, params)` |
|
|
44
|
-
|
|
45
|
-
### 业务操作命名规范
|
|
46
|
-
|
|
47
|
-
非标准 CRUD 操作按以下约定命名,URL 后缀使用**动词原形**(camelCase):
|
|
48
|
-
|
|
49
|
-
| 操作 | 方法 | URL 后缀 | 请求说明 |
|
|
50
|
-
| --------- | ---- | --------------- | ------------------------------------- |
|
|
51
|
-
| 提交审批 | POST | `/submit` | `{ id }` 或 `{ ids: [] }` |
|
|
52
|
-
| 审批通过 | POST | `/approve` | `{ id, opinion? }` |
|
|
53
|
-
| 审批驳回 | POST | `/reject` | `{ id, opinion }` |
|
|
54
|
-
| 撤回 | POST | `/withdraw` | `{ id }` 撤回已提交的单据 |
|
|
55
|
-
| 启用/禁用 | POST | `/changeStatus` | `{ id, status }` |
|
|
56
|
-
| 转化 | POST | `/convert` | `{ id }` 临时→正式(如临时客户→正式) |
|
|
57
|
-
| 下发 | POST | `/release` | `{ id }` 计划/工单下发执行 |
|
|
58
|
-
| 关闭 | POST | `/close` | `{ id }` 关闭订单/计划 |
|
|
59
|
-
| 作废 | POST | `/cancel` | `{ id }` 作废单据 |
|
|
60
|
-
| 批量操作 | POST | `/batchXxx` | 如 `/batchSubmit`、`/batchRemove` |
|
|
61
|
-
| 子表查询 | POST | `/queryXxxList` | 如 `/queryDetailList`,主从表场景 |
|
|
62
|
-
|
|
63
|
-
> **命名原则**:`/[服务缩写]/[资源名]/[动作]`,动作用英文动词原形,不用中文拼音,不加 `do` / `handle` 前缀。
|
|
64
|
-
|
|
65
|
-
### 统一响应结构(基于真实后端契约)
|
|
66
|
-
|
|
67
|
-
> ⚠️ **重要**:本项目后端响应外壳为 `{ code, message, data }`(**非 `result`**),成功码为 **`2000`**(**非 200**)。
|
|
68
|
-
|
|
69
|
-
#### 1. 分页查询响应
|
|
70
|
-
|
|
71
|
-
```json
|
|
72
|
-
{
|
|
73
|
-
"code": 2000,
|
|
74
|
-
"message": "操作成功",
|
|
75
|
-
"data": {
|
|
76
|
-
"records": [
|
|
77
|
-
{
|
|
78
|
-
/* Entity 字段 */
|
|
79
|
-
}
|
|
80
|
-
],
|
|
81
|
-
"total": 100,
|
|
82
|
-
"current": 1,
|
|
83
|
-
"size": 20,
|
|
84
|
-
"pages": 5,
|
|
85
|
-
"countId": null,
|
|
86
|
-
"maxLimit": null,
|
|
87
|
-
"orders": [],
|
|
88
|
-
"searchCount": true
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
| data 字段 | 类型 | 说明 |
|
|
94
|
-
| ------------- | ------- | ---------------------------------------- |
|
|
95
|
-
| `records` | array | 当前页数据列表 |
|
|
96
|
-
| `total` | number | 总记录数 |
|
|
97
|
-
| `current` | number | 当前页码 |
|
|
98
|
-
| `size` | number | 每页条数 |
|
|
99
|
-
| `pages` | number | 总页数 |
|
|
100
|
-
| `countId` | any | MyBatis-Plus 分页计数 ID(前端忽略) |
|
|
101
|
-
| `maxLimit` | any | 最大单页限制(前端忽略) |
|
|
102
|
-
| `orders` | array | 排序条件回传(前端忽略,除非需回显排序) |
|
|
103
|
-
| `searchCount` | boolean | 是否执行总数查询(前端忽略) |
|
|
104
|
-
|
|
105
|
-
> 前端 `BaseTable` / `AbstractPageQueryHook` 已自动适配:取 `data.records` 渲染、`data.total` 设分页、其他字段透传或忽略。无需在 data.ts 中处理。
|
|
106
|
-
|
|
107
|
-
#### 2. 单条 / 非分页查询响应
|
|
108
|
-
|
|
109
|
-
```json
|
|
110
|
-
{
|
|
111
|
-
"code": 2000,
|
|
112
|
-
"message": "操作成功",
|
|
113
|
-
"data": {
|
|
114
|
-
/* Entity 单对象 */
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
或返回数组(无需分页时):
|
|
120
|
-
|
|
121
|
-
```json
|
|
122
|
-
{
|
|
123
|
-
"code": 2000,
|
|
124
|
-
"message": "操作成功",
|
|
125
|
-
"data": [
|
|
126
|
-
{
|
|
127
|
-
/* Entity */
|
|
128
|
-
}
|
|
129
|
-
]
|
|
130
|
-
}
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
#### 3. 字典查询响应
|
|
134
|
-
|
|
135
|
-
```json
|
|
136
|
-
{
|
|
137
|
-
"code": 2000,
|
|
138
|
-
"message": "操作成功",
|
|
139
|
-
"data": [
|
|
140
|
-
{ "value": "01", "label": "已审批", "extra": null },
|
|
141
|
-
{ "value": "02", "label": "驳回", "extra": null }
|
|
142
|
-
]
|
|
143
|
-
}
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
#### 4. 增删改响应
|
|
147
|
-
|
|
148
|
-
```json
|
|
149
|
-
{ "code": 2000, "message": "操作成功", "data": true }
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
或返回主键:
|
|
153
|
-
|
|
154
|
-
```json
|
|
155
|
-
{ "code": 2000, "message": "操作成功", "data": "1234567890123456789" }
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
#### 5. 失败响应
|
|
159
|
-
|
|
160
|
-
```json
|
|
161
|
-
{ "code": 4001, "message": "参数缺失:customerName 不能为空", "data": null }
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
| code 范围 | 含义 |
|
|
165
|
-
| ------------- | --------------------------------- |
|
|
166
|
-
| `2000` | 成功 |
|
|
167
|
-
| `4xxx` | 客户端错误(参数/权限/校验) |
|
|
168
|
-
| `5xxx` | 服务端错误 |
|
|
169
|
-
| `401` / `403` | 网关层未登录 / 无权限(统一拦截) |
|
|
170
|
-
|
|
171
|
-
> 业务代码**不需要**关心 `code` 判断,`request.ts` 拦截器统一处理:非 2000 自动 `Promise.reject` + Toast 提示。业务代码 `.then()` 拿到的就是 `data` 字段内容。
|
|
172
|
-
|
|
173
|
-
### 字段命名
|
|
174
|
-
|
|
175
|
-
| 端 | 规范 | 说明 |
|
|
176
|
-
| ---- | ------------ | ------------------------------ |
|
|
177
|
-
| 前端 | `camelCase` | 所有请求/响应字段名 |
|
|
178
|
-
| 后端 | `snake_case` | 数据库字段,Jackson 自动转驼峰 |
|
|
179
|
-
|
|
180
|
-
---
|
|
181
|
-
|
|
182
|
-
## 执行步骤
|
|
183
|
-
|
|
184
|
-
### Step 1:接收输入
|
|
185
|
-
|
|
186
|
-
从 Phase 1 《页面清单》获取:
|
|
187
|
-
|
|
188
|
-
- 业务服务缩写(如 `pm`)
|
|
189
|
-
- 资源名(camelCase,如 `omptMillPlanOrder`)
|
|
190
|
-
- 各页面的查询字段、表格列、表单字段
|
|
191
|
-
|
|
192
|
-
### Step 2:为每个页面生成 api.md
|
|
193
|
-
|
|
194
|
-
文件放在**页面目录下**(和 index.vue 同级),字段名与 data.ts 完全一致。
|
|
195
|
-
|
|
196
|
-
### Step 3:同步生成 API_CONFIG
|
|
197
|
-
|
|
198
|
-
api.md 中的接口 URL 直接对应 data.ts 中的 `API_CONFIG`:
|
|
199
|
-
|
|
200
|
-
```typescript
|
|
201
|
-
export const API_CONFIG = {
|
|
202
|
-
list: "/pm/omptMillPlanOrder/list",
|
|
203
|
-
remove: "/pm/omptMillPlanOrder/remove",
|
|
204
|
-
getById: "/pm/omptMillPlanOrder/getById",
|
|
205
|
-
save: "/pm/omptMillPlanOrder/save",
|
|
206
|
-
update: "/pm/omptMillPlanOrder/update",
|
|
207
|
-
export: "/pm/omptMillPlanOrder/export",
|
|
208
|
-
// 按需增加业务操作
|
|
209
|
-
release: "/pm/omptMillPlanOrder/release",
|
|
210
|
-
} as const;
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
---
|
|
214
|
-
|
|
215
|
-
## api.md 模板
|
|
216
|
-
|
|
217
|
-
每个页面目录下生成:
|
|
218
|
-
|
|
219
|
-
````markdown
|
|
220
|
-
# 接口约定 - [页面中文名]
|
|
221
|
-
|
|
222
|
-
> 页面路径:`src/views/[域]/[模块]/[子模块]/[目录]/`
|
|
223
|
-
> 服务缩写:[pm / mmwr / sale / ...]
|
|
224
|
-
> 资源名:[camelCase 实体名]
|
|
225
|
-
> 状态:🟡 待后端确认
|
|
226
|
-
|
|
227
|
-
---
|
|
228
|
-
|
|
229
|
-
## API_CONFIG
|
|
230
|
-
|
|
231
|
-
```typescript
|
|
232
|
-
export const API_CONFIG = {
|
|
233
|
-
list: "/[服务缩写]/[资源名]/list",
|
|
234
|
-
remove: "/[服务缩写]/[资源名]/remove",
|
|
235
|
-
getById: "/[服务缩写]/[资源名]/getById",
|
|
236
|
-
save: "/[服务缩写]/[资源名]/save",
|
|
237
|
-
update: "/[服务缩写]/[资源名]/update",
|
|
238
|
-
export: "/[服务缩写]/[资源名]/export",
|
|
239
|
-
} as const;
|
|
240
|
-
```
|
|
241
|
-
|
|
242
|
-
---
|
|
243
|
-
|
|
244
|
-
## 实体定义
|
|
245
|
-
|
|
246
|
-
> 字段名与 data.ts 中 queryDef/columnsDef 使用的字段名**完全一致**
|
|
247
|
-
|
|
248
|
-
| 字段名 | 类型 | 说明 | 必填 | 字典(logicValue) | 备注 |
|
|
249
|
-
| ------------- | ------ | -------- | ---- | ---------------- | -------------------- |
|
|
250
|
-
| id | string | 主键 | 自动 | - | 后端生成 |
|
|
251
|
-
| [field1] | string | [说明] | ✅ | - | |
|
|
252
|
-
| [statusField] | string | [状态] | ✅ | [dictCode] | 前端 logicValue 对应 |
|
|
253
|
-
| [dateField] | string | [日期] | ❌ | - | YYYY-MM-DD |
|
|
254
|
-
| createTime | string | 创建时间 | 自动 | - | YYYY-MM-DD HH:mm:ss |
|
|
255
|
-
| updateTime | string | 更新时间 | 自动 | - | |
|
|
256
|
-
| createBy | string | 创建人 | 自动 | - | |
|
|
257
|
-
|
|
258
|
-
---
|
|
259
|
-
|
|
260
|
-
## 接口清单
|
|
261
|
-
|
|
262
|
-
### 1. 分页查询
|
|
263
|
-
|
|
264
|
-
```
|
|
265
|
-
POST /[服务缩写]/[资源名]/list
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
| 字段 | 类型 | 必填 | 说明 |
|
|
269
|
-
| ------------- | ------ | ---- | ----------------------------------- |
|
|
270
|
-
| current | number | ✅ | 页码(基类自动传) |
|
|
271
|
-
| size | number | ✅ | 每页条数(基类自动传) |
|
|
272
|
-
| [queryField1] | string | ❌ | [说明] |
|
|
273
|
-
| [queryField2] | string | ❌ | [说明],对应 logicValue: [dictCode] |
|
|
274
|
-
| [startDate] | string | ❌ | 开始日期 YYYY-MM-DD |
|
|
275
|
-
| [endDate] | string | ❌ | 结束日期 YYYY-MM-DD |
|
|
276
|
-
|
|
277
|
-
**响应 data.records:** 同实体定义;外壳 `{ code: 2000, message, data: { records, total, current, size, pages, countId, maxLimit, orders, searchCount } }`
|
|
278
|
-
|
|
279
|
-
### 2. 详情查询
|
|
280
|
-
|
|
281
|
-
```
|
|
282
|
-
GET /[服务缩写]/[资源名]/getById?id=xxx
|
|
283
|
-
```
|
|
284
|
-
|
|
285
|
-
**响应 data:** 单个 Entity;外壳 `{ code: 2000, message, data: {...} }`
|
|
286
|
-
|
|
287
|
-
### 3. 新增
|
|
288
|
-
|
|
289
|
-
```
|
|
290
|
-
POST /[服务缩写]/[资源名]/save
|
|
291
|
-
```
|
|
292
|
-
|
|
293
|
-
**请求:** 实体定义中必填字段(不含 id、createTime 等自动字段)
|
|
294
|
-
|
|
295
|
-
### 4. 编辑
|
|
296
|
-
|
|
297
|
-
```
|
|
298
|
-
POST /[服务缩写]/[资源名]/update
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
**请求:** 同新增 + `id`(必填)
|
|
302
|
-
|
|
303
|
-
### 5. 删除
|
|
304
|
-
|
|
305
|
-
```
|
|
306
|
-
POST /[服务缩写]/[资源名]/remove
|
|
307
|
-
```
|
|
308
|
-
|
|
309
|
-
**请求:** `{ "ids": ["xxx"] }` 或 `{ "id": "xxx" }`
|
|
310
|
-
|
|
311
|
-
### 6. 导出(如需要)
|
|
312
|
-
|
|
313
|
-
```
|
|
314
|
-
GET /[服务缩写]/[资源名]/export?[查询参数]
|
|
315
|
-
```
|
|
316
|
-
|
|
317
|
-
---
|
|
318
|
-
|
|
319
|
-
## 数据字典
|
|
320
|
-
|
|
321
|
-
| dictCode(logicValue) | 用途 | 出现位置 |
|
|
322
|
-
| -------------------- | ------ | ---------------------------- |
|
|
323
|
-
| [dictCode] | [说明] | queryDef / columnsDef / form |
|
|
324
|
-
|
|
325
|
-
---
|
|
326
|
-
|
|
327
|
-
## 联调注意
|
|
328
|
-
|
|
329
|
-
1. **响应外壳**:`{ code, message, data }`,成功 `code: 2000`(非 200,非 result)
|
|
330
|
-
2. 前端字段全部 camelCase,后端 JSON 序列化输出 camelCase
|
|
331
|
-
3. 时间字段统一 `YYYY-MM-DD HH:mm:ss`
|
|
332
|
-
4. 大数字 ID 后端转字符串(雪花 ID 超过 JS Number 精度)
|
|
333
|
-
5. 分页参数前端传 `current` / `size`(基类自动处理),后端响应 `data.records` / `data.total`
|
|
334
|
-
6. 枚举字段前端传 value,后端可返回 `[field]Label` 辅助展示,或前端自行通过 `logicValue` 字典翻译
|
|
335
|
-
7. 业务代码 `.then(res => res)` 拿到的就是 `data` 字段(拦截器已剥外壳)
|
|
336
|
-
````
|
|
337
|
-
|
|
338
|
-
---
|
|
339
|
-
|
|
340
|
-
## 状态标记
|
|
341
|
-
|
|
342
|
-
- 🟡 待后端确认 — 刚生成
|
|
343
|
-
- 🟢 已确认 — 双方对齐,可编码
|
|
344
|
-
- 🔴 有变更 — 需双方同步
|
|
1
|
+
---
|
|
2
|
+
name: api-contract
|
|
3
|
+
description: "Use when: designing API contracts between frontend and backend based on prototype page inventory, defining request/response field structures, establishing naming conventions, and generating an api.md file per page for team alignment before coding. Triggers on: api contract, interface design, 接口约定, 前后端对齐, 字段定义, 接口设计, api.md."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Skill: 接口约定(api-contract)
|
|
7
|
+
|
|
8
|
+
基于《页面清单》为每个页面生成 `api.md` 文件,放在**页面目录下**(和 index.vue 同级)。
|
|
9
|
+
|
|
10
|
+
**双重作用:**
|
|
11
|
+
|
|
12
|
+
1. **前端** — data.ts 中 `API_CONFIG` 的 URL 和字段名直接基于 api.md
|
|
13
|
+
2. **后端** — 拿到 api.md 直接出接口(Controller + Service + Entity),字段名一致,联调零成本
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## 全局规范
|
|
18
|
+
|
|
19
|
+
### URL 命名
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
/[服务缩写]/[资源名CamelCase]/[操作]
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
| 服务缩写 | 含义 | 示例 |
|
|
26
|
+
| -------- | -------- | ------------------------------------ |
|
|
27
|
+
| pm | 生产管理 | `/pm/omptMillPlanOrder/list` |
|
|
28
|
+
| mmwr | 精整作业 | `/mmwr/mmwrTechFinish/queryTechList` |
|
|
29
|
+
| mmsm | 炼钢管理 | `/mmsm/mmsmRsltLadleUse/list` |
|
|
30
|
+
| sale | 销售管理 | `/sale/saleOrder/list` |
|
|
31
|
+
| hrms | 人力资源 | `/hrms/hrmsEmployee/list` |
|
|
32
|
+
| base | 基础数据 | `/base/cmUserGroup/list` |
|
|
33
|
+
|
|
34
|
+
### 标准操作集
|
|
35
|
+
|
|
36
|
+
| 操作 | 方法 | URL 后缀 | 说明 |
|
|
37
|
+
| -------- | ---- | ----------------- | ----------------------------------------------------- |
|
|
38
|
+
| 分页列表 | POST | `/list` | 基类 `super({ url: { list } })` 自动调用 |
|
|
39
|
+
| 单条查询 | GET | `/getById?id=xxx` | `getAction(API_CONFIG.getById, { id })` |
|
|
40
|
+
| 新增 | POST | `/save` | `postAction(API_CONFIG.save, formData)` |
|
|
41
|
+
| 编辑 | POST | `/update` | `postAction(API_CONFIG.update, formData)` |
|
|
42
|
+
| 删除 | POST | `/remove` | 基类 `super({ url: { remove } })` + `this.remove(id)` |
|
|
43
|
+
| 导出 | GET | `/export` | `getAction(API_CONFIG.export, params)` |
|
|
44
|
+
|
|
45
|
+
### 业务操作命名规范
|
|
46
|
+
|
|
47
|
+
非标准 CRUD 操作按以下约定命名,URL 后缀使用**动词原形**(camelCase):
|
|
48
|
+
|
|
49
|
+
| 操作 | 方法 | URL 后缀 | 请求说明 |
|
|
50
|
+
| --------- | ---- | --------------- | ------------------------------------- |
|
|
51
|
+
| 提交审批 | POST | `/submit` | `{ id }` 或 `{ ids: [] }` |
|
|
52
|
+
| 审批通过 | POST | `/approve` | `{ id, opinion? }` |
|
|
53
|
+
| 审批驳回 | POST | `/reject` | `{ id, opinion }` |
|
|
54
|
+
| 撤回 | POST | `/withdraw` | `{ id }` 撤回已提交的单据 |
|
|
55
|
+
| 启用/禁用 | POST | `/changeStatus` | `{ id, status }` |
|
|
56
|
+
| 转化 | POST | `/convert` | `{ id }` 临时→正式(如临时客户→正式) |
|
|
57
|
+
| 下发 | POST | `/release` | `{ id }` 计划/工单下发执行 |
|
|
58
|
+
| 关闭 | POST | `/close` | `{ id }` 关闭订单/计划 |
|
|
59
|
+
| 作废 | POST | `/cancel` | `{ id }` 作废单据 |
|
|
60
|
+
| 批量操作 | POST | `/batchXxx` | 如 `/batchSubmit`、`/batchRemove` |
|
|
61
|
+
| 子表查询 | POST | `/queryXxxList` | 如 `/queryDetailList`,主从表场景 |
|
|
62
|
+
|
|
63
|
+
> **命名原则**:`/[服务缩写]/[资源名]/[动作]`,动作用英文动词原形,不用中文拼音,不加 `do` / `handle` 前缀。
|
|
64
|
+
|
|
65
|
+
### 统一响应结构(基于真实后端契约)
|
|
66
|
+
|
|
67
|
+
> ⚠️ **重要**:本项目后端响应外壳为 `{ code, message, data }`(**非 `result`**),成功码为 **`2000`**(**非 200**)。
|
|
68
|
+
|
|
69
|
+
#### 1. 分页查询响应
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"code": 2000,
|
|
74
|
+
"message": "操作成功",
|
|
75
|
+
"data": {
|
|
76
|
+
"records": [
|
|
77
|
+
{
|
|
78
|
+
/* Entity 字段 */
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
"total": 100,
|
|
82
|
+
"current": 1,
|
|
83
|
+
"size": 20,
|
|
84
|
+
"pages": 5,
|
|
85
|
+
"countId": null,
|
|
86
|
+
"maxLimit": null,
|
|
87
|
+
"orders": [],
|
|
88
|
+
"searchCount": true
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
| data 字段 | 类型 | 说明 |
|
|
94
|
+
| ------------- | ------- | ---------------------------------------- |
|
|
95
|
+
| `records` | array | 当前页数据列表 |
|
|
96
|
+
| `total` | number | 总记录数 |
|
|
97
|
+
| `current` | number | 当前页码 |
|
|
98
|
+
| `size` | number | 每页条数 |
|
|
99
|
+
| `pages` | number | 总页数 |
|
|
100
|
+
| `countId` | any | MyBatis-Plus 分页计数 ID(前端忽略) |
|
|
101
|
+
| `maxLimit` | any | 最大单页限制(前端忽略) |
|
|
102
|
+
| `orders` | array | 排序条件回传(前端忽略,除非需回显排序) |
|
|
103
|
+
| `searchCount` | boolean | 是否执行总数查询(前端忽略) |
|
|
104
|
+
|
|
105
|
+
> 前端 `BaseTable` / `AbstractPageQueryHook` 已自动适配:取 `data.records` 渲染、`data.total` 设分页、其他字段透传或忽略。无需在 data.ts 中处理。
|
|
106
|
+
|
|
107
|
+
#### 2. 单条 / 非分页查询响应
|
|
108
|
+
|
|
109
|
+
```json
|
|
110
|
+
{
|
|
111
|
+
"code": 2000,
|
|
112
|
+
"message": "操作成功",
|
|
113
|
+
"data": {
|
|
114
|
+
/* Entity 单对象 */
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
或返回数组(无需分页时):
|
|
120
|
+
|
|
121
|
+
```json
|
|
122
|
+
{
|
|
123
|
+
"code": 2000,
|
|
124
|
+
"message": "操作成功",
|
|
125
|
+
"data": [
|
|
126
|
+
{
|
|
127
|
+
/* Entity */
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
#### 3. 字典查询响应
|
|
134
|
+
|
|
135
|
+
```json
|
|
136
|
+
{
|
|
137
|
+
"code": 2000,
|
|
138
|
+
"message": "操作成功",
|
|
139
|
+
"data": [
|
|
140
|
+
{ "value": "01", "label": "已审批", "extra": null },
|
|
141
|
+
{ "value": "02", "label": "驳回", "extra": null }
|
|
142
|
+
]
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
#### 4. 增删改响应
|
|
147
|
+
|
|
148
|
+
```json
|
|
149
|
+
{ "code": 2000, "message": "操作成功", "data": true }
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
或返回主键:
|
|
153
|
+
|
|
154
|
+
```json
|
|
155
|
+
{ "code": 2000, "message": "操作成功", "data": "1234567890123456789" }
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
#### 5. 失败响应
|
|
159
|
+
|
|
160
|
+
```json
|
|
161
|
+
{ "code": 4001, "message": "参数缺失:customerName 不能为空", "data": null }
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
| code 范围 | 含义 |
|
|
165
|
+
| ------------- | --------------------------------- |
|
|
166
|
+
| `2000` | 成功 |
|
|
167
|
+
| `4xxx` | 客户端错误(参数/权限/校验) |
|
|
168
|
+
| `5xxx` | 服务端错误 |
|
|
169
|
+
| `401` / `403` | 网关层未登录 / 无权限(统一拦截) |
|
|
170
|
+
|
|
171
|
+
> 业务代码**不需要**关心 `code` 判断,`request.ts` 拦截器统一处理:非 2000 自动 `Promise.reject` + Toast 提示。业务代码 `.then()` 拿到的就是 `data` 字段内容。
|
|
172
|
+
|
|
173
|
+
### 字段命名
|
|
174
|
+
|
|
175
|
+
| 端 | 规范 | 说明 |
|
|
176
|
+
| ---- | ------------ | ------------------------------ |
|
|
177
|
+
| 前端 | `camelCase` | 所有请求/响应字段名 |
|
|
178
|
+
| 后端 | `snake_case` | 数据库字段,Jackson 自动转驼峰 |
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## 执行步骤
|
|
183
|
+
|
|
184
|
+
### Step 1:接收输入
|
|
185
|
+
|
|
186
|
+
从 Phase 1 《页面清单》获取:
|
|
187
|
+
|
|
188
|
+
- 业务服务缩写(如 `pm`)
|
|
189
|
+
- 资源名(camelCase,如 `omptMillPlanOrder`)
|
|
190
|
+
- 各页面的查询字段、表格列、表单字段
|
|
191
|
+
|
|
192
|
+
### Step 2:为每个页面生成 api.md
|
|
193
|
+
|
|
194
|
+
文件放在**页面目录下**(和 index.vue 同级),字段名与 data.ts 完全一致。
|
|
195
|
+
|
|
196
|
+
### Step 3:同步生成 API_CONFIG
|
|
197
|
+
|
|
198
|
+
api.md 中的接口 URL 直接对应 data.ts 中的 `API_CONFIG`:
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
export const API_CONFIG = {
|
|
202
|
+
list: "/pm/omptMillPlanOrder/list",
|
|
203
|
+
remove: "/pm/omptMillPlanOrder/remove",
|
|
204
|
+
getById: "/pm/omptMillPlanOrder/getById",
|
|
205
|
+
save: "/pm/omptMillPlanOrder/save",
|
|
206
|
+
update: "/pm/omptMillPlanOrder/update",
|
|
207
|
+
export: "/pm/omptMillPlanOrder/export",
|
|
208
|
+
// 按需增加业务操作
|
|
209
|
+
release: "/pm/omptMillPlanOrder/release",
|
|
210
|
+
} as const;
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## api.md 模板
|
|
216
|
+
|
|
217
|
+
每个页面目录下生成:
|
|
218
|
+
|
|
219
|
+
````markdown
|
|
220
|
+
# 接口约定 - [页面中文名]
|
|
221
|
+
|
|
222
|
+
> 页面路径:`src/views/[域]/[模块]/[子模块]/[目录]/`
|
|
223
|
+
> 服务缩写:[pm / mmwr / sale / ...]
|
|
224
|
+
> 资源名:[camelCase 实体名]
|
|
225
|
+
> 状态:🟡 待后端确认
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
## API_CONFIG
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
export const API_CONFIG = {
|
|
233
|
+
list: "/[服务缩写]/[资源名]/list",
|
|
234
|
+
remove: "/[服务缩写]/[资源名]/remove",
|
|
235
|
+
getById: "/[服务缩写]/[资源名]/getById",
|
|
236
|
+
save: "/[服务缩写]/[资源名]/save",
|
|
237
|
+
update: "/[服务缩写]/[资源名]/update",
|
|
238
|
+
export: "/[服务缩写]/[资源名]/export",
|
|
239
|
+
} as const;
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## 实体定义
|
|
245
|
+
|
|
246
|
+
> 字段名与 data.ts 中 queryDef/columnsDef 使用的字段名**完全一致**
|
|
247
|
+
|
|
248
|
+
| 字段名 | 类型 | 说明 | 必填 | 字典(logicValue) | 备注 |
|
|
249
|
+
| ------------- | ------ | -------- | ---- | ---------------- | -------------------- |
|
|
250
|
+
| id | string | 主键 | 自动 | - | 后端生成 |
|
|
251
|
+
| [field1] | string | [说明] | ✅ | - | |
|
|
252
|
+
| [statusField] | string | [状态] | ✅ | [dictCode] | 前端 logicValue 对应 |
|
|
253
|
+
| [dateField] | string | [日期] | ❌ | - | YYYY-MM-DD |
|
|
254
|
+
| createTime | string | 创建时间 | 自动 | - | YYYY-MM-DD HH:mm:ss |
|
|
255
|
+
| updateTime | string | 更新时间 | 自动 | - | |
|
|
256
|
+
| createBy | string | 创建人 | 自动 | - | |
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## 接口清单
|
|
261
|
+
|
|
262
|
+
### 1. 分页查询
|
|
263
|
+
|
|
264
|
+
```
|
|
265
|
+
POST /[服务缩写]/[资源名]/list
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
| 字段 | 类型 | 必填 | 说明 |
|
|
269
|
+
| ------------- | ------ | ---- | ----------------------------------- |
|
|
270
|
+
| current | number | ✅ | 页码(基类自动传) |
|
|
271
|
+
| size | number | ✅ | 每页条数(基类自动传) |
|
|
272
|
+
| [queryField1] | string | ❌ | [说明] |
|
|
273
|
+
| [queryField2] | string | ❌ | [说明],对应 logicValue: [dictCode] |
|
|
274
|
+
| [startDate] | string | ❌ | 开始日期 YYYY-MM-DD |
|
|
275
|
+
| [endDate] | string | ❌ | 结束日期 YYYY-MM-DD |
|
|
276
|
+
|
|
277
|
+
**响应 data.records:** 同实体定义;外壳 `{ code: 2000, message, data: { records, total, current, size, pages, countId, maxLimit, orders, searchCount } }`
|
|
278
|
+
|
|
279
|
+
### 2. 详情查询
|
|
280
|
+
|
|
281
|
+
```
|
|
282
|
+
GET /[服务缩写]/[资源名]/getById?id=xxx
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
**响应 data:** 单个 Entity;外壳 `{ code: 2000, message, data: {...} }`
|
|
286
|
+
|
|
287
|
+
### 3. 新增
|
|
288
|
+
|
|
289
|
+
```
|
|
290
|
+
POST /[服务缩写]/[资源名]/save
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
**请求:** 实体定义中必填字段(不含 id、createTime 等自动字段)
|
|
294
|
+
|
|
295
|
+
### 4. 编辑
|
|
296
|
+
|
|
297
|
+
```
|
|
298
|
+
POST /[服务缩写]/[资源名]/update
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
**请求:** 同新增 + `id`(必填)
|
|
302
|
+
|
|
303
|
+
### 5. 删除
|
|
304
|
+
|
|
305
|
+
```
|
|
306
|
+
POST /[服务缩写]/[资源名]/remove
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
**请求:** `{ "ids": ["xxx"] }` 或 `{ "id": "xxx" }`
|
|
310
|
+
|
|
311
|
+
### 6. 导出(如需要)
|
|
312
|
+
|
|
313
|
+
```
|
|
314
|
+
GET /[服务缩写]/[资源名]/export?[查询参数]
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
---
|
|
318
|
+
|
|
319
|
+
## 数据字典
|
|
320
|
+
|
|
321
|
+
| dictCode(logicValue) | 用途 | 出现位置 |
|
|
322
|
+
| -------------------- | ------ | ---------------------------- |
|
|
323
|
+
| [dictCode] | [说明] | queryDef / columnsDef / form |
|
|
324
|
+
|
|
325
|
+
---
|
|
326
|
+
|
|
327
|
+
## 联调注意
|
|
328
|
+
|
|
329
|
+
1. **响应外壳**:`{ code, message, data }`,成功 `code: 2000`(非 200,非 result)
|
|
330
|
+
2. 前端字段全部 camelCase,后端 JSON 序列化输出 camelCase
|
|
331
|
+
3. 时间字段统一 `YYYY-MM-DD HH:mm:ss`
|
|
332
|
+
4. 大数字 ID 后端转字符串(雪花 ID 超过 JS Number 精度)
|
|
333
|
+
5. 分页参数前端传 `current` / `size`(基类自动处理),后端响应 `data.records` / `data.total`
|
|
334
|
+
6. 枚举字段前端传 value,后端可返回 `[field]Label` 辅助展示,或前端自行通过 `logicValue` 字典翻译
|
|
335
|
+
7. 业务代码 `.then(res => res)` 拿到的就是 `data` 字段(拦截器已剥外壳)
|
|
336
|
+
````
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
## 状态标记
|
|
341
|
+
|
|
342
|
+
- 🟡 待后端确认 — 刚生成
|
|
343
|
+
- 🟢 已确认 — 双方对齐,可编码
|
|
344
|
+
- 🔴 有变更 — 需双方同步
|