feat(face-b): 业务分类 + 站内消息 + 公告落地(面 B 批次 4,+19 端点)
- schema:新增 base_business_category / base_message / base_notice(DDL 逐字对齐官方 JNPF-PostgreSQL.sql),tables 26 → 29 - 业务分类(BusinessCategoryController):树/详情/增改删/treeList/selector。 selector 的 parentId=-1 按官方两段式语义 = 「所有一级的子级」,不是根列表; treeList?type=1|2|3 按层数裁剪,不是按 f_type 列过滤 - 平台字典种子:官方初始库 89 行,本仓灌 38 行(5 个一级 + 33 个二级), id 沿用官方雪花 id —— f_category 存的就是这些 id 串,改 id 官方历史消息就错位 - 站内消息(NoticeController 消息那半截):列表按 f_user_id=当前用户过滤(一行 = 一个收件人, 漏了就是串号);ReadInfo 会写库置已读且已回执(2)不回退;ReadAll/Record/Reply 均只动自己的 - 公告:增删改查 + 发布。发布时置 enabledMark=1 并**逐收件人落 base_message** (收件人为空 ⇒ 全体用户),f_category 拼「公告一级 id,公告提醒二级 id」 ⇒ 消息记录页按二级页签过滤、按一级 enCode 显示类型名两个需求同时成立。 不做这一步消息记录页永远空白且不报错,是这批最容易漏的一环 - 用户标签按 f_id + f_account 双键查:本仓 f_creator_user_id 存账号,官方历史数据存 id - 契约登记三处同步:[ENDPOINT] 19 行 / [OFFICIAL] 19 条(1 条 partial: Notice/List 的时间区间过滤未做)/ FACE B 177→196;测试 499 → 502
This commit is contained in:
1 parent
ba8883dfb0
commit
c932075082
12 files changed
+2682
-18
No files matched your search
@@ -746,3 +746,49 @@ Java `FlowFormDataUtil.create()` 里 `CALCULATE` 走 `getIntValue(dataValue, ...
|
||||
**数字**:`cargo test --workspace` **495** | mcp-smoke **48/48** | lowcode-smoke **15/15**
|
||||
| 十二道闸门全绿(check-module 114、boundary 11、contract 10、citations 4、arch 9、naming 3+1提示、
|
||||
perm-smoke 43、perm-smoke-jnpf 23、baseline 10、mem 7 MB)
|
||||
|
||||
## 22:50 面 B 批次 3 + 批次 4(按「官方 frontend 实调」逐条推进)
|
||||
|
||||
### 批次 3(提交 `ba8883d`)应用中心 + 系统配置 + 标签,26 条
|
||||
新表 `base_system_top` / `base_sys_config` / `base_tag`;tables 23 → 26。
|
||||
- `SysConfig` 是**键值表**(官方 `SysConfigModel` 72 字段拆行存 `f_key/f_value/f_category`)
|
||||
⇒ 逐键 upsert,读回做数字/布尔还原;库为空时给 39 键默认对象(前端
|
||||
`state.baseForm = res.data` 后**立刻**读 `.logCleanPeriod` ⇒ `data` 不能是 null)。
|
||||
- 顺手修了**尺子自身的静默失效**:`check-contract-scan.py` 判面 B 守卫只认模块名 `jnpf`
|
||||
与函数 `require_login_jnpf`,文件早已改名 `face_b` ⇒ 整片面 B 的 CC6 没在跑。
|
||||
|
||||
### 批次 4 消息业务分类 + 站内消息 + 公告,19 条
|
||||
新表 `base_business_category` / `base_message` / `base_notice`;tables 26 → 29。
|
||||
|
||||
### 这一批真正的判断依据:**「被多少页面共用」而不是「缺口百分比」**
|
||||
`python3 scripts/fe-page-deps.py` 会打印「被最多页面共用的接口」——那才是「先做哪个」的
|
||||
正确排序(缺口百分比会被 `workFlow`/`onlineDev` 这种本仓没有的模块稀释)。
|
||||
实测 Top:`DataModel/{}/Tables`(12 页) / `visualdev/OnlineDev/{}/Config`(10) /
|
||||
`ai/AiSupplier/Selector`(10) / `BusinessCategory/treeList`(9) / `Log`(9) / `BasicDataType`(9)。
|
||||
|
||||
### 🔴 这一批踩到 / 想清楚的
|
||||
|
||||
- **`base_message` 一行 = 一个收件人**(`f_user_id`),发件人在 `f_creator_user_id`
|
||||
⇒ 所有查询必须带 `f_user_id = 当前用户`,漏了就是串号。
|
||||
- **用户标签必须按 `f_id` + `f_account` 双键查**:本仓写 `f_creator_user_id` 存的是**账号**
|
||||
(`seed.rs` 的 `ADMIN_ACCOUNT`),官方历史数据里是 **id**。只查一种,另一种永远显示空。
|
||||
- **公告发布是全链路唯一的消息来源**:`Release` 里逐收件人插 `base_message`
|
||||
(收件人为空 ⇒ 全体用户),`f_category` 拼「一级 id,二级 id」⇒
|
||||
页签按二级子串过滤、类型名按一级 `enCode` 解析,两个需求同时满足。
|
||||
不做这一步,消息记录页永远空白 —— 而且**不报错**,最容易漏。
|
||||
- **`ReadInfo` 会写库**(`f_is_read` 0⇒1);`f_is_read=2`(已回执)时不回退。
|
||||
- 官方 `selector?parentId=-1` **不是根列表**,是「所有一级的子级」(两段式查询);
|
||||
`treeList?type=1|2|3` 是**按层数裁剪**,不是按 `f_type` 列过滤。
|
||||
- 业务分类种子的**雪花 id 不得改**:`f_category` 存的就是 id 串,改 id 官方历史消息错位。
|
||||
- pglite 的单语句多组 `VALUES`(一次插 N 个收件人)比循环 N 次 INSERT 省往返,且能保持原子。
|
||||
|
||||
### 数字(批次 4 收尾)
|
||||
|
||||
`cargo test --workspace` **502** | `fe-gap` **197/900 = 21.9%**(system 66/196 = 33.7%)
|
||||
| 契约端点 **226 条(面 B 196)** | 官方覆盖 **215/222(implemented 205 / partial 10 / absent 7)**
|
||||
| 十二道闸门全绿 | 空载内存 7 MB
|
||||
|
||||
### 下一个(批次 5)
|
||||
|
||||
`system/Log`(5) + `system/CommonWords`(6) + `system/BillRule`(8) —— 都是「一张表 + CRUD + selector」;
|
||||
`Log` 能顺手把**登录日志落库**,让个人中心的 `Users/Current/SystemLog`(当前恒空)变真。
|
||||
@@ -222,7 +222,7 @@ ssw-platform/
|
||||
每把尺子结尾比对「实际断言数 vs 契约登记数」,对不上即失败 —— 尺子不会被悄悄改弱。
|
||||
**加任何业务模块 / 改任何契约 / 加任何 crate 依赖 / 改任何内部标识 / 加任何表,十二道闸门必须全绿才算完成。**
|
||||
|
||||
🔴 **`cargo test --workspace` 当前 499 条**(内核 + contract 13 + store 17 + sdk 2 + pack-asset 5 + mcp 52 + adapter-baseline 19 + lowcode 112 + 集成测试)——
|
||||
🔴 **`cargo test --workspace` 当前 502 条**(内核 + contract 13 + store 17 + sdk 2 + pack-asset 5 + mcp 52 + adapter-baseline 19 + lowcode 112 + 集成测试)——
|
||||
拆 crate 后总数会变,**不许把断言数写死**,跑一遍看实际值。
|
||||
|
||||
cipher 自证(免 node):`./target/release/ssw-platform --enc 123456`。
|
||||
@@ -276,7 +276,7 @@ cp .env.example .env && ./run.sh install && ./run.sh dev
|
||||
|
||||
```bash
|
||||
cargo build --release # 编译(workspace 根,含 crates/* 与 packs/*)
|
||||
cargo test --workspace # 单测(当前 499 条)
|
||||
cargo test --workspace # 单测(当前 502 条)
|
||||
bash run.sh dev # 起后端(30010) + 前端(5173)
|
||||
bash scripts/perm-smoke.sh # 面 A 43 条
|
||||
bash scripts/perm-smoke-jnpf.sh # 面 B 23 条
|
||||
|
||||
+46
-5
@@ -34,11 +34,26 @@
|
||||
剩下的真价值集中在 `permission` 那 62 条。所以**下一轮按这个顺序做**:
|
||||
1. `permission/Users/Current/*` 个人设置(14 条,个人中心要用)—— ✅ 批次 1(实际 23 条)
|
||||
2. `permission/Standing` / `PermissionGroup` / `Action`(15 条)—— ✅ 批次 2(实际 21 条)
|
||||
3. `system/System` + `system/SysConfig`(17 条,系统配置页)—— ✅ 批次 3(实际 25 条)
|
||||
4. 剩下的 `message`/`file`/`extend`/低代码模块 ⇒ **批量恒空 stub**(只为消红条,不建表) ← **下一个**
|
||||
3. ~~`system/System` + `system/SysConfig`(17 条,系统配置页)~~ —— ✅ 批次 3(实际 25 条)
|
||||
4. ~~`message`(53) / 低代码模块 ⇒ 批量恒空 stub~~
|
||||
✅ **批次 4 做完(实际 19 条)**——新表 `base_business_category` / `base_message` /
|
||||
`base_notice`;业务分类(官方 38 行种子)+ 站内消息(列表/已读/回执/删除)+
|
||||
公告(增删改查 + **发布即逐收件人落消息**)。
|
||||
⚠️ 只做了 `api/system/message.ts` 那 14 条(消息记录页 / 公告管理页用的),
|
||||
`api/msgCenter/*`(发送配置/账号配置/供应商/模板/监控/敏感词 —— 共 36 条)
|
||||
是「消息中心运维后台」,本仓没这个产品 ⇒ **仍待定**(见下条)。
|
||||
|
||||
**2026-10-31 22:00 实测**(`python3 scripts/fe-gap.py`):合计 **172 / 900**(19.1%);
|
||||
`permission` 111/137(81.0%)、`system` **41/196(20.9%,批次 3 从 17 涨到 41)**;
|
||||
**被最多页面共用的接口**(`python3 scripts/fe-page-deps.py` 的实测排序,按这个做收益最高):
|
||||
`DataModel/{}/Tables`(12 页) / `visualdev/OnlineDev/{}/Config`(10) / `ai/AiSupplier/Selector`(10) /
|
||||
`BusinessCategory/treeList`(9 ✅批次4) / `Log`(9) / `workflow/operator/List`(9) /
|
||||
`Dataset/{}/Actions/InfoByIds`(9) / `BasicDataType`(9) / `extend/TableExample` 四个(9) / `Tag/selector`(8 ✅批次3)。
|
||||
|
||||
**下一个(批次 5)建议**:`system/Log`(5) + `system/CommonWords`(6) + `system/BillRule`(8)
|
||||
—— 都是「一张表 + CRUD + selector」,模板照抄;`Log` 还能顺手把登录日志落库,
|
||||
让个人中心的 `Users/Current/SystemLog`(目前恒空)变成真的。
|
||||
|
||||
**2026-10-31 实测**(`python3 scripts/fe-gap.py`):合计 **197 / 900**(21.9%);
|
||||
`permission` 111/137(81.0%)、`system` **66/196(33.7%,批次 4 从 47 涨到 66)**;
|
||||
剩下体量最大的仍是 `workFlow`(104) / `onlineDev`(101) / `systemData`(91) / `aiCenter`(75) /
|
||||
`extend`(64) / `msgCenter`(50) —— **基本都属于「本仓没这个模块」**。
|
||||
|
||||
@@ -123,7 +138,33 @@
|
||||
应用授权的 `devUsers` 存 `f_user_id` 逗号串、不写 `base_authorize` ⇒ 也记 `partial`。
|
||||
- 企业微信/钉钉连通性测试**恒业务失败**(未接 SDK)—— 刻意不假装成功。
|
||||
|
||||
### 🔴 上一版说「页面从未渲染过一次」——**这个未知已经消除**。
|
||||
### 批次 4(2026-10-31)—— 消息业务分类 + 站内消息 + 公告
|
||||
|
||||
**19 条面 B 端点**:`/api/system/BusinessCategory`(7:树/详/增/改/删/`treeList`/`selector`)
|
||||
+ `/api/message`(5:列表/全部已读/读消息/删记录/回执)
|
||||
+ `/api/message/Notice`(7:列表/增/详/改/删/发布/回执人列表)。
|
||||
|
||||
- 新表三张(官方 DDL 逐字):`base_business_category` / `base_message` / `base_notice`;
|
||||
tables 26 → 29。
|
||||
- 🔴 **业务分类是平台字典,不是用户数据**:官方初始库灌 89 行(一级 + 二级 + 三级)。
|
||||
本仓在 `platform/seed.rs::BUSINESS_CATEGORIES` 灌 **38 行**(5 个一级 + 33 个二级),
|
||||
**id 沿用官方雪花 id**(`f_category` 存的就是这些 id 串,改 id 官方历史消息就错位)。
|
||||
三级是「消息事件」粒度(`flow_todo_remind` 之类),没有消息行时展示不到 ⇒ 暂不灌。
|
||||
- 🔴 **`base_message` 一行 = 一个收件人**(`f_user_id` 是收件人,发件人在 `f_creator_user_id`)
|
||||
⇒ 所有查询必须带 `f_user_id = 当前用户`,漏了就是串号。
|
||||
- 🔴 **公告发布是全链路的唯一消息来源**:`PUT /Notice/{id}/Actions/Release` 置
|
||||
`f_enabled_mark=1` 后**逐收件人插 `base_message`**(收件人为空 ⇒ 全体启用用户),
|
||||
`f_category` 拼「公告一级 id,公告提醒二级 id」⇒ 消息记录页按二级页签过滤、
|
||||
按一级 `enCode` 显示类型名,两者同时成立。不落这一步,消息记录页永远是空的。
|
||||
- 🔴 **`ReadInfo` 会写库**(`f_is_read` 0⇒1),且 `f_is_read=2`(已回执)时不回退 ——
|
||||
前端「点开就变已读」全靠它,别当纯查询。
|
||||
- 🔴 **用户标签要按 `f_id` 与 `f_account` 双键查**:本仓写 `f_creator_user_id` 存的是**账号**
|
||||
(`seed.rs` 的 `ADMIN_ACCOUNT`),官方历史数据里是 **id** ⇒ 只查一种另一种永远显示空。
|
||||
- 已知 `partial`:`POST /message/Notice/List` 的**时间区间过滤未做**
|
||||
(`releaseTime`/`creatorTime`/`expirationTime` 三个区间参数接受但忽略);
|
||||
分类删除是**软删**(官方物理删,本仓偏保守)。
|
||||
- 回归测试 `tests/batch4_it.rs`(**3 条**):分类树/裁剪/两段式 selector/判重、
|
||||
发布扩散、读+回执+删除(含「已回执不回退」与「只删自己的」)。
|
||||
|
||||
### 🔴 上一批(第一批)踩到并解决的 4 个真 bug
|
||||
|
||||
|
||||
@@ -251,7 +251,7 @@ ssw-platform/
|
||||
|
||||
| 能力 | 现状 | 目标 | 差距 |
|
||||
|---|---|---|---|
|
||||
| 面 B 契约端点 | ✅ 177 条 | 全量(含 lowcode/flow/file/message) | 补 ~250 条(多在 lowcode 域) |
|
||||
| 面 B 契约端点 | ✅ 196 条 | 全量(含 lowcode/flow/file/message) | 补 ~250 条(多在 lowcode 域) |
|
||||
| `base_*` DDL | ✅ 21 张逐字对齐 | 全量 331 张中的必需集 | 按域补 |
|
||||
| 平台/业务分层 | ✅ `check-boundary.sh` 钉住 | 升级为 crate 级隔离 | **P0 已拆 contract / store / sdk;asset 包可独立编译;`jnpf.rs`→`face_b.rs`** |
|
||||
| 低代码元数据引擎 | ✅ **P2-b 完成**:解析 + 校验 + 建表 + 动态 CRUD(6 个工具) | visualdev 同构 + 动态 CRUD + 发布 | 读 release / 单据号 / 乐观锁 → P2-c |
|
||||
|
||||
@@ -1203,28 +1203,29 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn schema_sql_has_expected_table_count() {
|
||||
// schema.sql 必须包含 26 张表的 CREATE TABLE
|
||||
// (21 张 base_*:8 张官方 + base_system + base_group + base_position
|
||||
// schema.sql 必须包含 29 张表的 CREATE TABLE
|
||||
// (24 张 base_*:8 张官方 + base_system + base_group + base_position
|
||||
// + 字典分类/字典数据 + base_sign_img + base_user_extra
|
||||
// + base_standing + base_permission_group + base_action
|
||||
// + base_system_top + base_sys_config(应用中心/系统配置)+ base_tag(标签)
|
||||
// + base_business_category + base_message + base_notice(消息批次)
|
||||
// + base_visual_dev / base_visual_release(P2 低代码),+ 4 张业务表)。
|
||||
//
|
||||
// 🔴 这个数字**故意写死**:加表必须同时改这里与 main.rs 的 BASE_TABLES,
|
||||
// 两处都改才算登记完成(漏一处就是「孤儿 DDL」或「白名单多一项」)。
|
||||
let count = SCHEMA_SQL.matches("CREATE TABLE ").count();
|
||||
assert_eq!(count, 26, "schema.sql 的 CREATE TABLE 数量应为 26");
|
||||
assert_eq!(count, 29, "schema.sql 的 CREATE TABLE 数量应为 29");
|
||||
}
|
||||
|
||||
/// 🔴 [`ddl_tables`] 的解析必须与上面那条计数一致(不能只数到 12 却解析出别的)。
|
||||
#[test]
|
||||
fn ddl_tables_parses_every_create_table() {
|
||||
let tables = ddl_tables();
|
||||
assert_eq!(tables.len(), 26, "ddl_tables 应解析出 26 张表");
|
||||
assert_eq!(tables.len(), 29, "ddl_tables 应解析出 29 张表");
|
||||
assert!(tables.iter().all(|t| !t.is_empty()));
|
||||
assert_eq!(
|
||||
tables.iter().collect::<std::collections::HashSet<_>>().len(),
|
||||
26,
|
||||
29,
|
||||
"表名不许重复"
|
||||
);
|
||||
// 基础 base_* 必须都在(业务表由业务层 spec 派生,不在本文件写死)。
|
||||
@@ -1240,6 +1241,9 @@ mod tests {
|
||||
"base_system_top",
|
||||
"base_sys_config",
|
||||
"base_tag",
|
||||
"base_business_category",
|
||||
"base_message",
|
||||
"base_notice",
|
||||
] {
|
||||
assert!(
|
||||
tables.iter().any(|t| t == base),
|
||||
|
||||
+39
-1
@@ -1208,6 +1208,25 @@ B POST /api/system/SynThirdInfo sysConfig.parameter platform
|
||||
B GET /api/system/SynThirdInfo/getSynThirdTotal/{type} sysConfig.parameter platform
|
||||
B GET /api/system/SynThirdInfo/clearAllSyn sysConfig.parameter platform
|
||||
B GET /api/system/SynThirdInfo/getHandleNum sysConfig.parameter platform
|
||||
B GET /api/system/BusinessCategory 登录 platform
|
||||
B POST /api/system/BusinessCategory 登录 platform
|
||||
B GET /api/system/BusinessCategory/treeList 登录 platform
|
||||
B GET /api/system/BusinessCategory/selector 登录 platform
|
||||
B GET /api/system/BusinessCategory/{id} 登录 platform
|
||||
B PUT /api/system/BusinessCategory/{id} 登录 platform
|
||||
B DELETE /api/system/BusinessCategory/{id} 登录 platform
|
||||
B GET /api/message 登录 platform
|
||||
B POST /api/message/Actions/ReadAll 登录 platform
|
||||
B GET /api/message/ReadInfo/{id} 登录 platform
|
||||
B DELETE /api/message/Record 登录 platform
|
||||
B POST /api/message/Reply/{id} 登录 platform
|
||||
B POST /api/message/Notice/List msgCenter.notice platform
|
||||
B POST /api/message/Notice msgCenter.notice platform
|
||||
B GET /api/message/Notice/{id} msgCenter.notice platform
|
||||
B PUT /api/message/Notice/{id} msgCenter.notice platform
|
||||
B DELETE /api/message/Notice/{id} msgCenter.notice platform
|
||||
B PUT /api/message/Notice/{id}/Actions/Release msgCenter.notice platform
|
||||
B GET /api/message/Notice/{id}/ReplyUserList msgCenter.notice platform
|
||||
B DELETE /api/permission/socials/{id} permission.user platform
|
||||
B GET /api/system/DictionaryData/All 登录 platform
|
||||
B GET /api/system/HomeData 登录 platform
|
||||
@@ -1348,7 +1367,7 @@ A DELETE /api/ssw/asset/DataResource/Delete asset/DataResource asset
|
||||
[FACE]
|
||||
# face 条数 说明
|
||||
A 28 面 A 专属(+ 2 条共用 ⇒ 面 A 合计 30 条)
|
||||
B 177 面 B 专属(官方 JNPF 形状)
|
||||
B 196 面 B 专属(官方 JNPF 形状)
|
||||
AB 2 两面共用(CurrentUser / Authority Data —— 按判别头分流)
|
||||
|
||||
[OFFICIAL]
|
||||
@@ -1432,6 +1451,25 @@ GET /api/system/Tag/selector implemented TagController.java:116 面 B 已落地
|
||||
GET /api/system/Tag/{id} implemented TagController.java:109 面 B 已落地:详情
|
||||
PUT /api/system/Tag/{id} implemented TagController.java:84 面 B 已落地:只 SET body 出现的键;名称判重
|
||||
DELETE /api/system/Tag/{id} implemented TagController.java:102 面 B 已落地:软删
|
||||
GET /api/system/BusinessCategory implemented BusinessCategoryController.java:43 面 B 已落地:ListVO,`list` 是**树**(根节点带 `children`),不是平铺数组
|
||||
POST /api/system/BusinessCategory implemented BusinessCategoryController.java:53 面 B 已落地:`f_type` 强制 1(自定义);同层级重名 / 编码重复 ⇒ `400`
|
||||
PUT /api/system/BusinessCategory/{id} implemented BusinessCategoryController.java:73 面 B 已落地:只 SET body 出现的键;判重带上「同父级」
|
||||
DELETE /api/system/BusinessCategory/{id} implemented BusinessCategoryController.java:91 面 B 已落地:软删(官方是物理删 ⇒ 本仓偏保守)
|
||||
GET /api/system/BusinessCategory/{id} implemented BusinessCategoryController.java:98 面 B 已落地:软删后返 `400`(不是空对象)
|
||||
GET /api/system/BusinessCategory/treeList implemented BusinessCategoryController.java:105 面 B 已落地:`type` = 1/2/3 ⇒ 按层数裁剪(1 只剩一级,2 带一层子级)
|
||||
GET /api/system/BusinessCategory/selector implemented BusinessCategoryController.java:114 面 B 已落地:`parentId=-1` = **所有一级的子级**(官方两段式语义,不是根列表)
|
||||
GET /api/message implemented NoticeController.java:273 面 B 已落地:PageListVO;**按 `f_user_id = 当前用户`** 过滤,漏了等于串号
|
||||
POST /api/message/Actions/ReadAll implemented NoticeController.java:386 面 B 已落地:`ids` / `category` 可选收窄;只动自己的未读行
|
||||
GET /api/message/ReadInfo/{id} implemented NoticeController.java:332 面 B 已落地:**会写库**(`f_is_read` 0⇒1,已回执 2 不回退);公告快照 JSON 摊平到 VO
|
||||
DELETE /api/message/Record implemented NoticeController.java:433 面 B 已落地:软删**自己的**消息;`ids` 为空 ⇒ `400`
|
||||
POST /api/message/Reply/{id} implemented NoticeController.java:310 面 B 已落地:手动回执 ⇒ `f_is_read = 2`(官方同款)
|
||||
POST /api/message/Notice/List implemented NoticeController.java:94 partial:`keyword`/`type`/`enabledMark`/`releaseUser` 已实现,**时间区间过滤未做**
|
||||
POST /api/message/Notice implemented NoticeController.java:143 面 B 已落地:只建草稿(`f_enabled_mark = 0`),不发消息
|
||||
GET /api/message/Notice/{id} implemented NoticeController.java:186 面 B 已落地:详情 + `excerpt` 现算(官方 `getExcerpt()` 是 getter,不落列)
|
||||
PUT /api/message/Notice/{id} implemented NoticeController.java:167 面 B 已落地:只 SET body 出现的键
|
||||
DELETE /api/message/Notice/{id} implemented NoticeController.java:221 面 B 已落地:软删 + `f_enabled_mark = -1`(同官方语义)
|
||||
PUT /api/message/Notice/{id}/Actions/Release implemented NoticeController.java:239 面 B 已落地:置已发送 + **逐收件人落 `base_message`**(收件人为空 ⇒ 全体用户)
|
||||
GET /api/message/Notice/{id}/ReplyUserList implemented NoticeController.java:317 面 B 已落地:ListVO;按 `f_body_text LIKE %noticeId%` + `f_is_read = 2` 去重成人
|
||||
DELETE /api/permission/socials/{id} implemented socialsUser.ts:21 面 B 已落地:本仓无 `base_socials_users` 表 ⇒ 无绑可解,恒成功(只返 msg)
|
||||
GET /api/system/DictionaryData/All implemented dictionary.ts:38-40 面 B 已落地:恒 `{list:[]}`(无 base_dictionary 表);前端 `store/base.ts:48` 取 `res.data.list` ⇒ 不能是裸数组
|
||||
GET /api/system/HomeData implemented homeData.ts:8 面 B 已落地:恒 `[]`(前端 `dashboard/index.vue:104` 读 `res.data.length` ⇒ 必须是数组)
|
||||
|
||||
@@ -519,6 +519,95 @@ CREATE TABLE base_tag (
|
||||
PRIMARY KEY (f_id, f_tenant_id)
|
||||
);
|
||||
|
||||
-- 消息业务分类(消息记录页左侧两级页签、公告的类型下拉)—— 列与官方 JNPF 7.0 逐字一致
|
||||
-- (官方 database/PostgreSQL/JNPF-PostgreSQL.sql 第 939 行,`base_business_category`)。
|
||||
-- 🔴 **这是平台自带字典**:官方初始库里已灌 91 行(5 个一级 + 二级 + 三级),
|
||||
-- 本仓只灌「一级 + 二级」共 38 行(见 platform/seed.rs::ensure_business_category)。
|
||||
-- 三级是「消息事件」粒度(flow_todo_remind 之类),没有消息行时展示不到;
|
||||
-- 等真有消息落库再补,避免 53 行死数据。
|
||||
CREATE TABLE base_business_category (
|
||||
f_id VARCHAR(50) NOT NULL,
|
||||
f_full_name VARCHAR(200),
|
||||
f_parent_id VARCHAR(255),
|
||||
f_en_code VARCHAR(255),
|
||||
f_enabled_mark INTEGER,
|
||||
f_type INTEGER NOT NULL,
|
||||
f_sort_code BIGINT,
|
||||
f_description VARCHAR(500),
|
||||
f_creator_time TIMESTAMP(0) WITHOUT TIME ZONE,
|
||||
f_creator_user_id VARCHAR(50),
|
||||
f_last_modify_time TIMESTAMP(0) WITHOUT TIME ZONE,
|
||||
f_last_modify_user_id VARCHAR(50),
|
||||
f_delete_time TIMESTAMP(0) WITHOUT TIME ZONE,
|
||||
f_delete_user_id VARCHAR(50),
|
||||
f_delete_mark INTEGER,
|
||||
f_tenant_id VARCHAR(50) DEFAULT '0' NOT NULL,
|
||||
PRIMARY KEY (f_id, f_tenant_id)
|
||||
);
|
||||
|
||||
-- 站内消息(消息记录页 / 首页铃铛)—— 列与官方 JNPF 7.0 逐字一致
|
||||
-- (官方 database/PostgreSQL/JNPF-PostgreSQL.sql 第 2164 行,`base_message`)。
|
||||
-- 🔴 **一行 = 一个收件人的一条消息**(`f_user_id` 是收件人,不是发件人);
|
||||
-- 发件人在 `f_creator_user_id`。官方的「全部已读」就是按 `f_user_id` 批量改 `f_is_read`。
|
||||
-- 🔴 `f_type`:1 公告 / 2 流程 / 3 系统 / 4 日程 / 5 表单 / 6 应用
|
||||
-- (官方 `BusinessCategoryEnum`;前端 `_core/messageRecord/index.vue:145` 按它分派详情弹窗)。
|
||||
CREATE TABLE base_message (
|
||||
f_id VARCHAR(50) NOT NULL,
|
||||
f_type INTEGER,
|
||||
f_title VARCHAR(200),
|
||||
f_flow_type INTEGER,
|
||||
f_user_id VARCHAR(50),
|
||||
f_is_read INTEGER,
|
||||
f_read_time TIMESTAMP(0) WITHOUT TIME ZONE,
|
||||
f_read_count INTEGER,
|
||||
f_sort_code BIGINT,
|
||||
f_creator_time TIMESTAMP(0) WITHOUT TIME ZONE,
|
||||
f_creator_user_id VARCHAR(50),
|
||||
f_last_modify_time TIMESTAMP(0) WITHOUT TIME ZONE,
|
||||
f_last_modify_user_id VARCHAR(50),
|
||||
f_delete_time TIMESTAMP(0) WITHOUT TIME ZONE,
|
||||
f_delete_user_id VARCHAR(50),
|
||||
f_delete_mark INTEGER,
|
||||
f_tenant_id VARCHAR(50) DEFAULT '0' NOT NULL,
|
||||
f_body_text TEXT,
|
||||
f_category VARCHAR(200),
|
||||
f_monitor_id VARCHAR(50),
|
||||
PRIMARY KEY (f_id, f_tenant_id)
|
||||
);
|
||||
|
||||
-- 系统公告(公告管理页 msgCenter/notice)—— 列与官方 JNPF 7.0 逐字一致
|
||||
-- (官方 database/PostgreSQL/JNPF-PostgreSQL.sql 第 3127 行,`base_notice`)。
|
||||
-- 🔴 **没有 `f_excerpt` 列**:官方 `MessageNoticeVO.excerpt` 是 `@TableField(exist=false)`,
|
||||
-- 由 `f_body_text` 里的富文本现算 ⇒ 本仓同样不建列,列表里现取。
|
||||
-- 🔴 `f_enabled_mark`:0 存草稿 / 1 已发送 / 2 已过期 / 3 待发送 / 4 失败
|
||||
-- (前端 `msgCenter/notice/index.vue:23-29` 的 `enabledMarkMap`)。
|
||||
CREATE TABLE base_notice (
|
||||
f_id VARCHAR(50) NOT NULL,
|
||||
f_title VARCHAR(200),
|
||||
f_body_text TEXT,
|
||||
f_to_user_ids TEXT,
|
||||
f_cover_image TEXT,
|
||||
f_files TEXT,
|
||||
f_expiration_time TIMESTAMP(0) WITHOUT TIME ZONE,
|
||||
f_category VARCHAR(50),
|
||||
f_type INTEGER,
|
||||
f_send_config_id VARCHAR(50),
|
||||
f_description VARCHAR(500),
|
||||
f_enabled_mark INTEGER,
|
||||
f_sort_code BIGINT,
|
||||
f_creator_time TIMESTAMP(0) WITHOUT TIME ZONE,
|
||||
f_creator_user_id VARCHAR(50),
|
||||
f_last_modify_time TIMESTAMP(0) WITHOUT TIME ZONE,
|
||||
f_last_modify_user_id VARCHAR(50),
|
||||
f_delete_time TIMESTAMP(0) WITHOUT TIME ZONE,
|
||||
f_delete_user_id VARCHAR(50),
|
||||
f_delete_mark INTEGER,
|
||||
f_tenant_id VARCHAR(50) DEFAULT '0' NOT NULL,
|
||||
f_reply_type INTEGER,
|
||||
f_send_time TIMESTAMP(0) WITHOUT TIME ZONE,
|
||||
PRIMARY KEY (f_id, f_tenant_id)
|
||||
);
|
||||
|
||||
-- ============================================================================
|
||||
-- 业务表 3 张(demo_item / shop_product / book_shop_book)
|
||||
--
|
||||
|
||||
@@ -43,8 +43,9 @@ use ssw_platform::routes;
|
||||
/// 多应用 MVP 新增了平台表 `base_system`(`SystemEntity` 注册表,
|
||||
/// 承载 `App-Code` → `systemId` 的映射);P2 低代码新增 `base_visual_dev` /
|
||||
/// `base_visual_release`(功能定义与发布快照);应用中心/系统配置批次新增
|
||||
/// `base_system_top` / `base_sys_config` / `base_tag`,故清单现在是 **22 张**。
|
||||
const BASE_TABLES: [&str; 22] = [
|
||||
/// `base_system_top` / `base_sys_config` / `base_tag`;消息批次新增
|
||||
/// `base_business_category` / `base_message` / `base_notice`,故清单现在是 **25 张**。
|
||||
const BASE_TABLES: [&str; 25] = [
|
||||
"base_group",
|
||||
"base_user",
|
||||
"base_role",
|
||||
@@ -67,6 +68,10 @@ const BASE_TABLES: [&str; 22] = [
|
||||
"base_system_top",
|
||||
"base_sys_config",
|
||||
"base_tag",
|
||||
// 🔴 消息批次(2026-10-31):业务分类字典 + 站内消息 + 公告,仍是官方 DDL 逐字。
|
||||
"base_business_category",
|
||||
"base_message",
|
||||
"base_notice",
|
||||
// 🔴 低代码两张表是**平台表**不是业务表:它们存的是「功能定义」,
|
||||
// 任何业务模块都会用,属于引擎基础设施。
|
||||
"base_visual_dev",
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -157,6 +157,9 @@ pub async fn ensure_base(db: &Db, extra_menus: &[MenuSpec]) -> Result<(), pglite
|
||||
let all_menus = all_builtin_menus(extra_menus);
|
||||
ensure_builtin_menus(db, &now, &all_menus).await?;
|
||||
ensure_admin_authorizations(db, &now, &all_menus).await?;
|
||||
// 🔴 消息业务分类字典(`base_business_category`):消息记录页左侧两级页签的数据源。
|
||||
// 缺了它页面只是「页签为空」,不报错 ⇒ 很容易一直没人发现,所以放在同一处种。
|
||||
ensure_business_category(db, &now).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -226,6 +229,111 @@ pub async fn ensure_systems(db: &Db, now: &str) -> Result<(), pglite::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// 消息业务分类字典(`base_business_category`)—— 官方初始库里的**一级 + 二级**共 38 行。
|
||||
///
|
||||
/// 真源:`jnpf-database/PostgreSQL/jnpf_db_init.sql` 的 `INSERT INTO base_business_category`
|
||||
/// (官方共 89 行;此处只取 `f_parent_id = '-1'` 的 5 个一级 + 其直接子级 33 个)。
|
||||
///
|
||||
/// 🔴 **id 沿用官方字面量**(雪花 id)—— 消息行的 `f_category` 存的是这些 id 的拼接,
|
||||
/// id 一变,官方的历史消息就对不上分类。所以这 38 个 id **不得改动**。
|
||||
/// 🔴 **为什么不灌三级**:三级是「消息事件」粒度(`flow_todo_remind` 之类),
|
||||
/// 本仓还没有产生消息的流程引擎 ⇒ 灌了也展示不到,只是 51 行死数据。
|
||||
/// 等真有消息落库再补(届时按官方 dump 续加到 [`BUSINESS_CATEGORIES`] 即可)。
|
||||
/// 🔴 `f_type` 官方种子一律 `0`(自定义分类才写 `1`,见 `BusinessCategoryController.addTag`)。
|
||||
const BUSINESS_CATEGORIES: [(&str, &str, &str, &str); 38] = [
|
||||
// ── 一级(`f_parent_id = '-1'`)────────────────────────────────
|
||||
("2046493747218354176", "应用", "-1", "app"),
|
||||
("2046494412900536320", "流程", "-1", "flow"),
|
||||
("2046494560334516224", "系统", "-1", "sys"),
|
||||
("2046494646179336192", "公告", "-1", "announce"),
|
||||
("2046494880842256384", "其他", "-1", "other"),
|
||||
// ── 二级 ──────────────────────────────────────────────────────
|
||||
("2046498207713857536", "应用授权", "2046493747218354176", "app_auth"),
|
||||
("2046498549667074048", "公告提醒", "2046494646179336192", "announce_remind"),
|
||||
("2046500072862126080", "签收提醒", "2046494412900536320", "flow_sign"),
|
||||
("2046500160736989184", "办理", "2046494412900536320", "flow_handle"),
|
||||
("2046500875702243328", "催办", "2046494412900536320", "flow_urge"),
|
||||
("2046501020737081344", "待办", "2046494412900536320", "flow_todo"),
|
||||
("2046501168506605568", "抄送", "2046494412900536320", "flow_cc"),
|
||||
("2046501319522521088", "转审", "2046494412900536320", "flow_transfer_review"),
|
||||
("2046501588842975232", "协办", "2046494412900536320", "flow_assist"),
|
||||
("2046501724960722944", "指派", "2046494412900536320", "flow_assign"),
|
||||
("2046501881433427968", "退回", "2046494412900536320", "flow_return"),
|
||||
("2046501986085507072", "撤销", "2046494412900536320", "flow_revoke"),
|
||||
("2046502107422527488", "超时", "2046494412900536320", "flow_timeout"),
|
||||
("2046502107422527491", "提醒", "2046494412900536320", "flow_notice"),
|
||||
("2046502333298380800", "异常", "2046494412900536320", "flow_exception"),
|
||||
("2046502439330385920", "评论", "2046494412900536320", "flow_comment"),
|
||||
("2046502572495343616", "同意", "2046494412900536320", "flow_approve"),
|
||||
("2046502674320461824", "结束", "2046494412900536320", "flow_end"),
|
||||
("2046502848119836672", "拒绝", "2046494412900536320", "flow_reject"),
|
||||
("2046502966558593024", "子流程", "2046494412900536320", "flow_subflow"),
|
||||
("2046503112767836160", "委托/代理通知", "2046494412900536320", "flow_delegate_rel"),
|
||||
("2046503688704495616", "委托操作通知", "2046494412900536320", "flow_delegate_op"),
|
||||
("2046504062601531392", "任务流通知", "2046494412900536320", "flow_notice_task"),
|
||||
("2046504062601531395", "决策流通知", "2046494412900536320", "flow_notice_decision"),
|
||||
("2046504380970176512", "流程编辑", "2046494412900536320", "flow_edit"),
|
||||
("2046504635065307136", "账户同步", "2046494560334516224", "sys_sync"),
|
||||
("2046504806578786304", "日程变更", "2046494560334516224", "sys_schedule_change"),
|
||||
("2046504806578786314", "日程邀请", "2046494560334516224", "sys_schedule_invite"),
|
||||
("2046505011386650624", "文档共享", "2046494560334516224", "sys_file"),
|
||||
("2046505115216646144", "运维安全", "2046494560334516224", "sys_operation"),
|
||||
("2046505268967247872", "登录安全", "2046494560334516224", "sys_login"),
|
||||
("2046505516032724992", "密码安全", "2046494560334516224", "sys_password"),
|
||||
("2058744163381415936", "消息通知", "2046494412900536320", "flow_message_notice"),
|
||||
];
|
||||
|
||||
/// 灌业务分类字典 —— 幂等、每次启动都跑。
|
||||
///
|
||||
/// 🔴 **存在性按 `f_id` 判且不过滤 `f_delete_mark`**:管理员在 UI 里删掉某个分类
|
||||
/// (软删)后,这里不会再插回去 —— 与 [`ensure_base`] 的其余种子同一条口径。
|
||||
/// 🔴 顺序有意义:一级先插(`f_parent_id = '-1'`),二级引用它们 ⇒ 按常量里的
|
||||
/// 书写顺序插入即可(本常量就是一级在前)。
|
||||
pub async fn ensure_business_category(db: &Db, now: &str) -> Result<(), pglite::Error> {
|
||||
let now = now.to_string();
|
||||
let tenant_id = "0".to_string();
|
||||
let enabled_mark = "1".to_string();
|
||||
let type_zero = "0".to_string();
|
||||
let delete_mark = "0".to_string();
|
||||
for (index, (id, full_name, parent_id, en_code)) in BUSINESS_CATEGORIES.iter().enumerate() {
|
||||
let (id, full_name, parent_id) =
|
||||
(id.to_string(), full_name.to_string(), parent_id.to_string());
|
||||
let (en_code, sort_code) = (en_code.to_string(), index.to_string());
|
||||
let existed = db
|
||||
.query_json_params(
|
||||
"SELECT f_id AS \"id\" FROM base_business_category WHERE f_id = $1::text LIMIT 1",
|
||||
&[&id],
|
||||
)
|
||||
.await?;
|
||||
if !existed.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let params: [&(dyn ToSql + Sync); 10] = [
|
||||
&id,
|
||||
&full_name,
|
||||
&parent_id,
|
||||
&en_code,
|
||||
&enabled_mark,
|
||||
&type_zero,
|
||||
&sort_code,
|
||||
&delete_mark,
|
||||
&tenant_id,
|
||||
&now,
|
||||
];
|
||||
db.exec_params(
|
||||
"INSERT INTO base_business_category \
|
||||
(f_id, f_full_name, f_parent_id, f_en_code, f_enabled_mark, f_type, \
|
||||
f_sort_code, f_delete_mark, f_tenant_id, f_creator_time) \
|
||||
VALUES ($1::text, $2::text, $3::text, $4::text, $5::text::integer, \
|
||||
$6::text::integer, $7::text::bigint, $8::text::integer, \
|
||||
$9::text, $10::text::timestamp)",
|
||||
¶ms,
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// 把一个 `App-Code`(`base_system.f_en_code`)解析成系统 id(`base_system.f_id`)。
|
||||
///
|
||||
/// 🔴 用于把菜单种进正确的系统(`f_system_id`)—— 平台层**不认**具体 app 名,
|
||||
|
||||
@@ -243,6 +243,55 @@ pub fn build_router(state: AppState) -> axum::Router<AppState> {
|
||||
.route("/api/system/Tag/{id}", get(face_b::tag_info))
|
||||
.route("/api/system/Tag/{id}", put(face_b::tag_update))
|
||||
.route("/api/system/Tag/{id}", delete(face_b::tag_delete))
|
||||
// ---- 消息业务分类(消息记录页左侧两级页签 + 公告类型下拉)----
|
||||
.route(
|
||||
"/api/system/BusinessCategory",
|
||||
get(face_b::business_category_list),
|
||||
)
|
||||
.route(
|
||||
"/api/system/BusinessCategory",
|
||||
post(face_b::business_category_create),
|
||||
)
|
||||
.route(
|
||||
"/api/system/BusinessCategory/treeList",
|
||||
get(face_b::business_category_tree_list),
|
||||
)
|
||||
.route(
|
||||
"/api/system/BusinessCategory/selector",
|
||||
get(face_b::business_category_selector),
|
||||
)
|
||||
.route(
|
||||
"/api/system/BusinessCategory/{id}",
|
||||
get(face_b::business_category_info),
|
||||
)
|
||||
.route(
|
||||
"/api/system/BusinessCategory/{id}",
|
||||
put(face_b::business_category_update),
|
||||
)
|
||||
.route(
|
||||
"/api/system/BusinessCategory/{id}",
|
||||
delete(face_b::business_category_delete),
|
||||
)
|
||||
// ---- 站内消息(消息记录页 / 首页铃铛)----
|
||||
.route("/api/message", get(face_b::message_list))
|
||||
.route("/api/message/Actions/ReadAll", post(face_b::message_read_all))
|
||||
.route("/api/message/ReadInfo/{id}", get(face_b::message_read_info))
|
||||
.route("/api/message/Record", delete(face_b::message_record_delete))
|
||||
.route("/api/message/Reply/{id}", post(face_b::message_reply))
|
||||
// ---- 系统公告(公告管理页)----
|
||||
.route("/api/message/Notice/List", post(face_b::notice_list))
|
||||
.route("/api/message/Notice", post(face_b::notice_create))
|
||||
.route("/api/message/Notice/{id}", get(face_b::notice_info))
|
||||
.route("/api/message/Notice/{id}", put(face_b::notice_update))
|
||||
.route("/api/message/Notice/{id}", delete(face_b::notice_delete))
|
||||
.route(
|
||||
"/api/message/Notice/{id}/Actions/Release",
|
||||
put(face_b::notice_release),
|
||||
)
|
||||
.route(
|
||||
"/api/message/Notice/{id}/ReplyUserList",
|
||||
get(face_b::notice_reply_user_list),
|
||||
)
|
||||
// ---- 系统配置 + 第三方同步(官方 `SysConfigController` / `SynThirdInfoController`)----
|
||||
.route("/api/system/SysConfig", get(face_b::sys_config_get))
|
||||
.route("/api/system/SysConfig", put(face_b::sys_config_update))
|
||||
@@ -1035,7 +1084,7 @@ mod tests {
|
||||
// 🔴 表数**故意写死**:它同时校验「schema.sql 建了预期的表」与
|
||||
// 「health 报的是真数」。加表要同步改这里 + main.rs 的 BASE_TABLES
|
||||
// + crates/sspf-store 的两条 DDL 断言(共四处,漏一处就红)。
|
||||
assert_eq!(body["tables"], 26);
|
||||
assert_eq!(body["tables"], 29);
|
||||
assert_eq!(body["version"], env!("CARGO_PKG_VERSION"));
|
||||
}
|
||||
|
||||
@@ -1050,7 +1099,7 @@ mod tests {
|
||||
let port = serve(new_state(db().await)).await;
|
||||
|
||||
// 🔴 按**路径**列(同一路径多个方法只算一条)—— 每条都用 PATCH 探 405。
|
||||
const FACE_B_REGISTERED: [&str; 133] = [
|
||||
const FACE_B_REGISTERED: [&str; 147] = [
|
||||
"/api/permission/Users",
|
||||
"/api/permission/Users/any-id",
|
||||
"/api/permission/Users/BatchDelete",
|
||||
@@ -1185,6 +1234,21 @@ mod tests {
|
||||
"/api/system/Tag",
|
||||
"/api/system/Tag/selector",
|
||||
"/api/system/Tag/any-id",
|
||||
// —— 消息业务分类 + 站内消息 + 公告(批次 4)——
|
||||
"/api/system/BusinessCategory",
|
||||
"/api/system/BusinessCategory/treeList",
|
||||
"/api/system/BusinessCategory/selector",
|
||||
"/api/system/BusinessCategory/any-id",
|
||||
"/api/message",
|
||||
"/api/message/Actions/ReadAll",
|
||||
"/api/message/ReadInfo/any-id",
|
||||
"/api/message/Record",
|
||||
"/api/message/Reply/any-id",
|
||||
"/api/message/Notice/List",
|
||||
"/api/message/Notice",
|
||||
"/api/message/Notice/any-id",
|
||||
"/api/message/Notice/any-id/Actions/Release",
|
||||
"/api/message/Notice/any-id/ReplyUserList",
|
||||
];
|
||||
|
||||
for path in FACE_B_REGISTERED {
|
||||
|
||||
@@ -0,0 +1,633 @@
|
||||
//! 批次 4(业务分类 `/api/system/BusinessCategory` + 站内消息 `/api/message` + 公告)集成测试。
|
||||
//!
|
||||
//! 🔴 **钉住的契约点**(每条都对应官方 VO / 控制器的一处要求):
|
||||
//! ① `GET /BusinessCategory` 是 `ListVO` 且 `list` 是**树**(根节点带 `children`);
|
||||
//! `?treeList?type=1` 只剩一级(5 条),`type=2` 带一层子级,`selector?parentId=-1`
|
||||
//! 是「**所有一级的子级**」(官方 `getListByParentIds(["-1"])` 的两段式语义)。
|
||||
//! ② 平台种子必须真灌进库:5 个一级 + 33 个二级 = 38 行
|
||||
//! (`platform/seed.rs::BUSINESS_CATEGORIES`,官方初始库同源)。
|
||||
//! ③ `POST /message/Notice` 只是**草稿**(`enabledMark=0`);`PUT …/Actions/Release`
|
||||
//! 才置 1 并**给每个收件人各落一条 `base_message`** —— 这是「消息记录页有东西」的唯一来源。
|
||||
//! ④ 落库的消息:`f_type=1`、`enCode=announce`、`typeName=公告`、
|
||||
//! `f_category` 同时含一级与二级分类 id ⇒ 页签按二级过滤、类型名按一级解析,两者都成立。
|
||||
//! ⑤ `GET /message/ReadInfo/{id}` **会写库**(`isRead` 0 ⇒ 1),且把公告快照 JSON 摊平。
|
||||
//! ⑥ `POST /message/Reply/{id}` ⇒ `isRead = 2`(已回执),**不回退**成 1。
|
||||
//! ⑦ `DELETE /message/Record` 只删**自己的**消息,且是软删(列表 total 归零)。
|
||||
//!
|
||||
//! 🔴 pglite-rs 0.2.7 是**进程级全局标志** ⇒ 全文件共用一个临时库 + 一把互斥锁。
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
use serde_json::{json, Value};
|
||||
use ssw_platform::bootstrap::ensure_base;
|
||||
use ssw_platform::platform::config::Config;
|
||||
use ssw_platform::platform::db::Db;
|
||||
use ssw_platform::platform::seed::first_seed;
|
||||
use ssw_platform::platform::session::SessionStore;
|
||||
use ssw_platform::platform::state::AppState;
|
||||
use ssw_platform::routes::build_app;
|
||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||
use tokio::net::TcpStream;
|
||||
use tokio::sync::{Mutex, OnceCell};
|
||||
|
||||
static DB: OnceCell<Db> = OnceCell::const_new();
|
||||
static LOCK: Mutex<()> = Mutex::const_new(());
|
||||
|
||||
async fn db() -> &'static Db {
|
||||
DB.get_or_init(|| async {
|
||||
let db = Db::open_temp().await.expect("打开 pglite 临时库失败");
|
||||
db.ensure_schema().await.expect("ensure_schema 失败");
|
||||
ensure_base(&db).await.expect("ensure_base 失败");
|
||||
first_seed(&db, "123456").await.expect("first_seed 失败");
|
||||
db
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
async fn serve(state: AppState) -> u16 {
|
||||
let listener = tokio::net::TcpListener::bind("127.0.0.1:0")
|
||||
.await
|
||||
.expect("绑定失败");
|
||||
let port = listener.local_addr().expect("取本地地址失败").port();
|
||||
let server = tokio::spawn(async move {
|
||||
let _ = axum::serve(listener, build_app(state)).await;
|
||||
});
|
||||
tokio::task::yield_now().await;
|
||||
std::mem::forget(server);
|
||||
port
|
||||
}
|
||||
|
||||
/// 面 B 请求(带 `Vue-Version: 3`)。
|
||||
async fn call(
|
||||
port: u16,
|
||||
method: &str,
|
||||
path: &str,
|
||||
token: &str,
|
||||
body: Option<&str>,
|
||||
) -> (String, Value) {
|
||||
let mut stream = TcpStream::connect(("127.0.0.1", port))
|
||||
.await
|
||||
.expect("连接失败");
|
||||
let payload = body.unwrap_or("");
|
||||
let req = format!(
|
||||
"{method} {path} HTTP/1.1\r\n\
|
||||
Host: 127.0.0.1\r\n\
|
||||
Vue-Version: 3\r\n\
|
||||
App-Code: mainSystem\r\n\
|
||||
Authorization: {token}\r\n\
|
||||
Content-Type: application/json\r\n\
|
||||
Content-Length: {}\r\n\
|
||||
Connection: close\r\n\r\n{payload}",
|
||||
payload.len()
|
||||
);
|
||||
stream.write_all(req.as_bytes()).await.expect("写请求失败");
|
||||
let mut buf = Vec::new();
|
||||
tokio::time::timeout(
|
||||
std::time::Duration::from_secs(10),
|
||||
stream.read_to_end(&mut buf),
|
||||
)
|
||||
.await
|
||||
.expect("读响应超时")
|
||||
.expect("读响应失败");
|
||||
let text = String::from_utf8_lossy(&buf).to_string();
|
||||
let (head, body) = text.split_once("\r\n\r\n").expect("响应必须有头体分隔");
|
||||
let status = head.lines().next().unwrap_or_default().to_string();
|
||||
let json: Value = serde_json::from_str(body.trim()).unwrap_or(Value::Null);
|
||||
(status, json)
|
||||
}
|
||||
|
||||
async fn login(port: u16) -> String {
|
||||
let enc = ssw_platform::platform::cipher::encrypt_password("123456");
|
||||
let payload = format!("account=admin&password={enc}");
|
||||
let mut stream = TcpStream::connect(("127.0.0.1", port))
|
||||
.await
|
||||
.expect("连接失败");
|
||||
let req = format!(
|
||||
"POST /api/oauth/Login HTTP/1.1\r\n\
|
||||
Host: 127.0.0.1\r\n\
|
||||
Vue-Version: 3\r\n\
|
||||
App-Code: mainSystem\r\n\
|
||||
Content-Type: application/x-www-form-urlencoded\r\n\
|
||||
Content-Length: {}\r\n\
|
||||
Connection: close\r\n\r\n{payload}",
|
||||
payload.len()
|
||||
);
|
||||
stream.write_all(req.as_bytes()).await.expect("写请求失败");
|
||||
let mut buf = Vec::new();
|
||||
tokio::time::timeout(
|
||||
std::time::Duration::from_secs(10),
|
||||
stream.read_to_end(&mut buf),
|
||||
)
|
||||
.await
|
||||
.expect("读响应超时")
|
||||
.expect("读响应失败");
|
||||
let text = String::from_utf8_lossy(&buf).to_string();
|
||||
let (_, body) = text.split_once("\r\n\r\n").expect("响应必须有头体分隔");
|
||||
let json: Value = serde_json::from_str(body.trim()).expect("登录响应必须是 JSON");
|
||||
json["data"]["token"]
|
||||
.as_str()
|
||||
.expect("登录必须返回 token")
|
||||
.to_string()
|
||||
}
|
||||
|
||||
fn new_state(db: &Db) -> AppState {
|
||||
AppState {
|
||||
config: Arc::new(Config::from_env(PathBuf::from("/tmp/ssw-platform-batch4-it"))),
|
||||
db: Arc::new(db.clone()),
|
||||
sessions: Arc::new(SessionStore::default()),
|
||||
}
|
||||
}
|
||||
|
||||
/// 建一条公告并发布,返回 `(公告 id, 标题)`。收件人为空 ⇒ 发给全体用户。
|
||||
async fn seed_notice(port: u16, token: &str, title: &str) -> String {
|
||||
let body = json!({
|
||||
"title": title,
|
||||
"bodyText": "<p>正文<b>加粗</b>部分</p>",
|
||||
"category": "notice_type_1",
|
||||
"replyType": 1,
|
||||
});
|
||||
let (_, created) = call(
|
||||
port,
|
||||
"POST",
|
||||
"/api/message/Notice",
|
||||
token,
|
||||
Some(&body.to_string()),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(created["code"], 200, "新建公告失败: {created}");
|
||||
|
||||
let (_, listed) = call(
|
||||
port,
|
||||
"POST",
|
||||
"/api/message/Notice/List",
|
||||
token,
|
||||
Some(&json!({ "keyword": title }).to_string()),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(listed["code"], 200, "公告列表失败: {listed}");
|
||||
let row = listed["data"]["list"]
|
||||
.as_array()
|
||||
.expect("data 必须是 PageListVO")
|
||||
.iter()
|
||||
.find(|x| x["title"] == json!(title))
|
||||
.unwrap_or_else(|| panic!("新建的公告必须出现在列表: {listed}"))
|
||||
.clone();
|
||||
let id = row["id"].as_str().expect("公告必须有 id").to_string();
|
||||
// ③ 草稿状态:新建不发布 ⇒ enabledMark=0。
|
||||
assert_eq!(row["enabledMark"], json!(0), "新建的公告应是草稿: {row}");
|
||||
id
|
||||
}
|
||||
|
||||
/// 业务分类:种子行数 / 树形状 / type 裁剪 / selector 两段式 / CRUD 判重。
|
||||
#[tokio::test]
|
||||
async fn business_category_tree_and_crud() {
|
||||
let _guard = LOCK.lock().await;
|
||||
let port = serve(new_state(db().await)).await;
|
||||
let token = login(port).await;
|
||||
|
||||
// ① 一级:5 条(应用 / 流程 / 系统 / 公告 / 其他)。
|
||||
let (_, lv1) = call(
|
||||
port,
|
||||
"GET",
|
||||
"/api/system/BusinessCategory/treeList?type=1",
|
||||
&token,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
assert_eq!(lv1["code"], 200, "{lv1}");
|
||||
let roots = lv1["data"]["list"].as_array().expect("data 必须是 ListVO");
|
||||
assert_eq!(roots.len(), 5, "一级分类必须是 5 个: {lv1}");
|
||||
let names: Vec<&str> = roots.iter().filter_map(|x| x["fullName"].as_str()).collect();
|
||||
assert_eq!(names, vec!["应用", "流程", "系统", "公告", "其他"], "{lv1}");
|
||||
assert!(
|
||||
roots.iter().all(|x| x.get("children").is_none()),
|
||||
"type=1 不该带子级: {lv1}"
|
||||
);
|
||||
|
||||
// ① type=2 ⇒ 带一层子级;流程下必须是 24 个(官方二级 + 新增的「消息通知」)。
|
||||
let (_, lv2) = call(
|
||||
port,
|
||||
"GET",
|
||||
"/api/system/BusinessCategory/treeList?type=2",
|
||||
&token,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
let roots2 = lv2["data"]["list"].as_array().unwrap();
|
||||
assert_eq!(roots2.len(), 5, "{lv2}");
|
||||
let flow = roots2
|
||||
.iter()
|
||||
.find(|x| x["enCode"] == json!("flow"))
|
||||
.expect("必须有流程一级");
|
||||
let flow_children = flow["children"].as_array().expect("type=2 必须带子级");
|
||||
assert!(!flow_children.is_empty(), "流程下必须有二级: {flow}");
|
||||
assert_eq!(
|
||||
flow["hasChildren"],
|
||||
json!(true),
|
||||
"有子级时 hasChildren 必须是 true: {flow}"
|
||||
);
|
||||
|
||||
// ① selector `parentId=-1` = **所有一级的子级**(33 条种子二级)。
|
||||
let (_, sel_all) = call(
|
||||
port,
|
||||
"GET",
|
||||
"/api/system/BusinessCategory/selector?parentId=-1",
|
||||
&token,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
let all_level2 = sel_all["data"]["list"].as_array().unwrap();
|
||||
assert_eq!(
|
||||
all_level2.len(),
|
||||
33,
|
||||
"种子二级分类应为 33 个: {}",
|
||||
sel_all
|
||||
);
|
||||
// ① selector `parentId=<一级 id>` = 该一级的直接子级。
|
||||
let flow_id = flow["id"].as_str().unwrap().to_string();
|
||||
let (_, sel_flow) = call(
|
||||
port,
|
||||
"GET",
|
||||
&format!("/api/system/BusinessCategory/selector?parentId={flow_id}"),
|
||||
&token,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
let flow_children2 = sel_flow["data"]["list"].as_array().unwrap();
|
||||
assert_eq!(
|
||||
flow_children2.len(),
|
||||
flow_children.len(),
|
||||
"selector 与 treeList 的子级数必须一致"
|
||||
);
|
||||
|
||||
// ② 全树接口 `GET /BusinessCategory` 的 `list` 同样是树(不是平铺 38 行)。
|
||||
let (_, tree) = call(port, "GET", "/api/system/BusinessCategory", &token, None).await;
|
||||
assert_eq!(
|
||||
tree["data"]["list"].as_array().unwrap().len(),
|
||||
5,
|
||||
"全树接口返回的必须是根节点: {tree}"
|
||||
);
|
||||
|
||||
// ④ 新建 → 同父级重名 400 → 编码重复 400 → 改 → 删。
|
||||
let other_id = roots
|
||||
.iter()
|
||||
.find(|x| x["enCode"] == json!("other"))
|
||||
.expect("必须有其他一级")["id"]
|
||||
.as_str()
|
||||
.unwrap()
|
||||
.to_string();
|
||||
let body = json!({ "fullName": "批次四分类", "parentId": other_id, "enCode": "ZDY9" });
|
||||
let (_, created) = call(
|
||||
port,
|
||||
"POST",
|
||||
"/api/system/BusinessCategory",
|
||||
&token,
|
||||
Some(&body.to_string()),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(created["code"], 200, "新建分类失败: {created}");
|
||||
|
||||
let (_, dup_name) = call(
|
||||
port,
|
||||
"POST",
|
||||
"/api/system/BusinessCategory",
|
||||
&token,
|
||||
Some(&json!({ "fullName": "批次四分类", "parentId": other_id }).to_string()),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(dup_name["code"], 400, "同层级重名必须 400: {dup_name}");
|
||||
|
||||
let (_, dup_code) = call(
|
||||
port,
|
||||
"POST",
|
||||
"/api/system/BusinessCategory",
|
||||
&token,
|
||||
Some(&json!({ "fullName": "批次四分类2", "parentId": other_id, "enCode": "ZDY9" }).to_string()),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(dup_code["code"], 400, "编码重复必须 400: {dup_code}");
|
||||
|
||||
let (_, under_other) = call(
|
||||
port,
|
||||
"GET",
|
||||
&format!("/api/system/BusinessCategory/selector?parentId={other_id}"),
|
||||
&token,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
let row = under_other["data"]["list"]
|
||||
.as_array()
|
||||
.unwrap()
|
||||
.iter()
|
||||
.find(|x| x["fullName"] == json!("批次四分类"))
|
||||
.expect("新建的分类必须出现在父级下拉里")
|
||||
.clone();
|
||||
let cid = row["id"].as_str().unwrap().to_string();
|
||||
assert_eq!(row["type"], json!(1), "新建分类的 f_type 必须是 1(官方同款): {row}");
|
||||
|
||||
let (_, renamed) = call(
|
||||
port,
|
||||
"PUT",
|
||||
&format!("/api/system/BusinessCategory/{cid}"),
|
||||
&token,
|
||||
Some(&json!({ "fullName": "批次四分类改名" }).to_string()),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(renamed["code"], 200, "{renamed}");
|
||||
let (_, info) = call(
|
||||
port,
|
||||
"GET",
|
||||
&format!("/api/system/BusinessCategory/{cid}"),
|
||||
&token,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
assert_eq!(info["data"]["fullName"], json!("批次四分类改名"), "{info}");
|
||||
assert_eq!(info["data"]["enCode"], json!("ZDY9"), "改名不该动编码: {info}");
|
||||
|
||||
let (_, deleted) = call(
|
||||
port,
|
||||
"DELETE",
|
||||
&format!("/api/system/BusinessCategory/{cid}"),
|
||||
&token,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
assert_eq!(deleted["code"], 200, "{deleted}");
|
||||
let (_, gone) = call(
|
||||
port,
|
||||
"GET",
|
||||
&format!("/api/system/BusinessCategory/{cid}"),
|
||||
&token,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
assert_eq!(gone["code"], 400, "软删后详情必须查不到: {gone}");
|
||||
}
|
||||
|
||||
/// 公告发布 ⇒ 真的给收件人落站内消息(消息记录页的数据来源)。
|
||||
#[tokio::test]
|
||||
async fn notice_release_fans_out_messages() {
|
||||
let _guard = LOCK.lock().await;
|
||||
let port = serve(new_state(db().await)).await;
|
||||
let token = login(port).await;
|
||||
|
||||
let title = "发布扩散用例";
|
||||
let id = seed_notice(port, &token, title).await;
|
||||
|
||||
// 未发布前,消息记录页应为空(这条用例自己创造消息,先清零自己的)。
|
||||
let (_, before) = call(
|
||||
port,
|
||||
"GET",
|
||||
&format!("/api/message?keyword={title}"),
|
||||
&token,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
assert_eq!(
|
||||
before["data"]["pagination"]["total"],
|
||||
json!(0),
|
||||
"草稿公告不该产生消息: {before}"
|
||||
);
|
||||
|
||||
let (_, released) = call(
|
||||
port,
|
||||
"PUT",
|
||||
&format!("/api/message/Notice/{id}/Actions/Release"),
|
||||
&token,
|
||||
Some("{}"),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(released["code"], 200, "发布失败: {released}");
|
||||
|
||||
// ② 公告本体已发送。
|
||||
let (_, notices) = call(
|
||||
port,
|
||||
"POST",
|
||||
"/api/message/Notice/List",
|
||||
&token,
|
||||
Some(&json!({ "keyword": title }).to_string()),
|
||||
)
|
||||
.await;
|
||||
let notice = ¬ices["data"]["list"][0];
|
||||
assert_eq!(notice["enabledMark"], json!(1), "发布后必须是已发送: {notices}");
|
||||
assert!(
|
||||
notice["releaseUser"].as_str().map(|s| !s.is_empty()).unwrap_or(false),
|
||||
"发布后 releaseUser 必须有值: {notices}"
|
||||
);
|
||||
|
||||
// ④ 消息列表出现,且形状对得上消息记录页(title/type/isRead/releaseUser/enCode)。
|
||||
let (_, msgs) = call(
|
||||
port,
|
||||
"GET",
|
||||
&format!("/api/message?keyword={title}"),
|
||||
&token,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
assert_eq!(msgs["code"], 200, "{msgs}");
|
||||
assert_eq!(
|
||||
msgs["data"]["pagination"]["total"],
|
||||
json!(1),
|
||||
"发布后必须给 admin 落 1 条消息: {msgs}"
|
||||
);
|
||||
let msg = &msgs["data"]["list"][0];
|
||||
assert_eq!(msg["title"], json!(title), "{msg}");
|
||||
assert_eq!(msg["type"], json!(1), "公告类消息 type 必须是 1: {msg}");
|
||||
assert_eq!(msg["typeName"], json!("公告"), "{msg}");
|
||||
assert_eq!(msg["enCode"], json!("announce"), "{msg}");
|
||||
assert_eq!(msg["isRead"], json!(0), "新消息必须未读: {msg}");
|
||||
assert!(
|
||||
msg["releaseUser"].as_str().map(|s| s.contains('/')).unwrap_or(false),
|
||||
"releaseUser 应是「姓名/账号」: {msg}"
|
||||
);
|
||||
assert!(
|
||||
msg["releaseTime"].as_i64().unwrap_or(0) > 0,
|
||||
"releaseTime 必须是毫秒时间戳: {msg}"
|
||||
);
|
||||
|
||||
// ④ 二级页签过滤:公告提醒 ⇒ 命中;流程的某个二级 ⇒ 不命中。
|
||||
let (_, by_announce) = call(
|
||||
port,
|
||||
"GET",
|
||||
&format!("/api/message?keyword={title}&category=2046498549667074048"),
|
||||
&token,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
assert_eq!(
|
||||
by_announce["data"]["pagination"]["total"],
|
||||
json!(1),
|
||||
"按「公告提醒」二级页签必须能查到: {by_announce}"
|
||||
);
|
||||
let (_, by_flow) = call(
|
||||
port,
|
||||
"GET",
|
||||
&format!("/api/message?keyword={title}&category=2046500072862126080"),
|
||||
&token,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
assert_eq!(
|
||||
by_flow["data"]["pagination"]["total"],
|
||||
json!(0),
|
||||
"按流程二级页签不该查到公告消息: {by_flow}"
|
||||
);
|
||||
}
|
||||
|
||||
/// 读消息(置已读 + 摊平快照)/ 回执(isRead=2)/ 只有自己能看到并删除。
|
||||
#[tokio::test]
|
||||
async fn message_read_reply_and_delete() {
|
||||
let _guard = LOCK.lock().await;
|
||||
let port = serve(new_state(db().await)).await;
|
||||
let token = login(port).await;
|
||||
|
||||
let title = "读回执用例";
|
||||
let notice_id = seed_notice(port, &token, title).await;
|
||||
let (_, released) = call(
|
||||
port,
|
||||
"PUT",
|
||||
&format!("/api/message/Notice/{notice_id}/Actions/Release"),
|
||||
&token,
|
||||
Some("{}"),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(released["code"], 200, "{released}");
|
||||
|
||||
let (_, msgs) = call(
|
||||
port,
|
||||
"GET",
|
||||
&format!("/api/message?keyword={title}"),
|
||||
&token,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
let mid = msgs["data"]["list"][0]["id"]
|
||||
.as_str()
|
||||
.expect("消息必须有 id")
|
||||
.to_string();
|
||||
|
||||
// ⑤ 读一次:isRead 0 ⇒ 1,且公告快照里的 bodyText 被摊平到 VO 上。
|
||||
let (_, read) = call(
|
||||
port,
|
||||
"GET",
|
||||
&format!("/api/message/ReadInfo/{mid}"),
|
||||
&token,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
assert_eq!(read["code"], 200, "{read}");
|
||||
assert_eq!(read["data"]["isRead"], json!(1), "读一次必须置已读: {read}");
|
||||
assert_eq!(
|
||||
read["data"]["bodyText"], json!("<p>正文<b>加粗</b>部分</p>"),
|
||||
"公告快照的正文必须摊平到 VO: {read}"
|
||||
);
|
||||
assert_eq!(read["data"]["title"], json!(title), "{read}");
|
||||
|
||||
let (_, again) = call(
|
||||
port,
|
||||
"GET",
|
||||
&format!("/api/message?keyword={title}"),
|
||||
&token,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
assert_eq!(
|
||||
again["data"]["list"][0]["isRead"],
|
||||
json!(1),
|
||||
"已读必须落库(不是只改返回值): {again}"
|
||||
);
|
||||
|
||||
// ⑥ 回执 ⇒ isRead = 2;再读一次**不回退**成 1。
|
||||
let (_, replied) = call(
|
||||
port,
|
||||
"POST",
|
||||
&format!("/api/message/Reply/{mid}"),
|
||||
&token,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
assert_eq!(replied["code"], 200, "{replied}");
|
||||
let (_, after_reply) = call(
|
||||
port,
|
||||
"GET",
|
||||
&format!("/api/message?keyword={title}"),
|
||||
&token,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
assert_eq!(
|
||||
after_reply["data"]["list"][0]["isRead"],
|
||||
json!(2),
|
||||
"回执后必须是 2: {after_reply}"
|
||||
);
|
||||
let (_, reread) = call(
|
||||
port,
|
||||
"GET",
|
||||
&format!("/api/message/ReadInfo/{mid}"),
|
||||
&token,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
assert_eq!(
|
||||
reread["data"]["isRead"],
|
||||
json!(2),
|
||||
"再读一次不能把已回执降回已读: {reread}"
|
||||
);
|
||||
|
||||
// 回执人员列表里必须出现 admin。
|
||||
let (_, reply_users) = call(
|
||||
port,
|
||||
"GET",
|
||||
&format!("/api/message/Notice/{notice_id}/ReplyUserList"),
|
||||
&token,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
assert_eq!(reply_users["code"], 200, "{reply_users}");
|
||||
let users = reply_users["data"]["list"].as_array().unwrap();
|
||||
assert_eq!(users.len(), 1, "回执人员应只有 admin: {reply_users}");
|
||||
assert!(
|
||||
users[0]["replyUser"]
|
||||
.as_str()
|
||||
.map(|s| s.contains('/'))
|
||||
.unwrap_or(false),
|
||||
"回执人应是「姓名/账号」: {reply_users}"
|
||||
);
|
||||
|
||||
// ⑦ 删除自己的消息 ⇒ 列表 total 归零。
|
||||
let (_, removed) = call(
|
||||
port,
|
||||
"DELETE",
|
||||
"/api/message/Record",
|
||||
&token,
|
||||
Some(&json!({ "ids": mid }).to_string()),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(removed["code"], 200, "删除消息失败: {removed}");
|
||||
let (_, after_delete) = call(
|
||||
port,
|
||||
"GET",
|
||||
&format!("/api/message?keyword={title}"),
|
||||
&token,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
assert_eq!(
|
||||
after_delete["data"]["pagination"]["total"],
|
||||
json!(0),
|
||||
"删除后不该再出现: {after_delete}"
|
||||
);
|
||||
|
||||
// 空 ids 删除 ⇒ 400(官方 `MessageRecordForm` 校验失败的表现)。
|
||||
let (_, empty) = call(
|
||||
port,
|
||||
"DELETE",
|
||||
"/api/message/Record",
|
||||
&token,
|
||||
Some(&json!({}).to_string()),
|
||||
)
|
||||
.await;
|
||||
assert_eq!(empty["code"], 400, "空 ids 必须 400: {empty}");
|
||||
}
|
||||
Reference in new issue
Block a user