Compare commits
2 Commits
f690f30552
...
cfb7451e62
| Author | SHA1 | Date | |
|---|---|---|---|
| cfb7451e62 | |||
| 723443ea1e |
@@ -9,9 +9,9 @@
|
||||
| 口径 | 数量 | 说明 |
|
||||
|---|---:|---|
|
||||
| framework 定制视图总数 | 46 | README 总览口径;backlog 表格当前可解析出 45 行,需后续校正缺的 1 行。 |
|
||||
| 已逐功能验收 / 可算 Done | 约 5 | 用户管理、功能模板下载、实体分类-枚举组、已办任务、消息查看/已读。功能模板下载/已办/消息查看各覆盖 2 个 templateId,但按 engineclass 各计 1 组。 |
|
||||
| 已逐功能验收 / 可算 Done | 约 6 | 用户管理、功能模板下载、实体分类-枚举组、已办任务、消息查看/已读、短消息。功能模板下载/已办/消息查看各覆盖 2 个 templateId,但按 engineclass 各计 1 组。 |
|
||||
| 代码已提交但待最终副作用验收 | 约 3 | 待办任务:列表、查看详细、处理抽屉已验;未点同意/拒绝。用户选择框全家已切标准 amis picker,并已覆盖单选查询、单选表单、多选弹窗层级与多选展示烟测;流程选择框已接线/页面烟测;两者都未覆盖所有真实业务保存和权限差异验收。 |
|
||||
| 仍需修或逐功能验收 | 约 42 | 含上面的 3 个待验组;大多是通用页已产出,但 engineclass Java delta 未迁移。 |
|
||||
| 仍需修或逐功能验收 | 约 41 | 含上面的 3 个待验组;大多是通用页已产出,但 engineclass Java delta 未迁移。 |
|
||||
| 剩余工程单元 | 约 28+ | 多视图可复用同一套组件/端点,如脚本编辑器、消息详情、工作流按钮。 |
|
||||
|
||||
## Done(已完成 / 已验收)
|
||||
@@ -28,14 +28,15 @@
|
||||
| 2026-06-17 | 功能模板下载模板管理/设置:去右表单添加按钮、标题改「编辑模板附件」 | Done | `b5fe995`, `3276774` | 转换器测试;重转重导后生效 |
|
||||
| 2026-06-17 | 实体分类-枚举组:确认 EIP4 树端点 PK 唯一 + 去重,全量建树覆盖老 UUID 防重逻辑 | Done | 文档/核验项 | 无需移植 |
|
||||
| 2026-06-17 | 用户管理 Delta 端到端案例 | Done | 见 `用户管理-Delta移植-实现过程与踩坑-2026-06-17.md` | 已逐字段 dogfood |
|
||||
| 2026-06-18 | 消息查看/已读:收到的消息查看弹窗、打开即已读、已发送消息只读详情 | Done | 本次提交 | `NoticeControllerTest`; 浏览器验收 `83971d1a`:本地记录 `94d3645c-2487-47f6-bbf5-ebdff3434f6e` 置未读后列表显示“否”,打开详情后 DB 与列表均回“是”;浏览器验收 `b7635622`:已发送消息只读详情正常,无“消息详情加载失败” |
|
||||
| 2026-06-18 | 消息查看/已读:收到的消息查看弹窗、打开即已读、已发送消息只读详情 | Done | `eip4-platform f690f30` | `NoticeControllerTest`; 浏览器验收 `83971d1a`:本地记录 `94d3645c-2487-47f6-bbf5-ebdff3434f6e` 置未读后列表显示“否”,打开详情后 DB 与列表均回“是”;浏览器验收 `b7635622`:已发送消息只读详情正常,无“消息详情加载失败” |
|
||||
| 2026-06-18 | 短消息 `MessageManageView`:发送消息弹窗、标准用户多选 picker、写 `sys_message/sys_messageuser`、发送后刷新已发列表 | Done | `eip4-platform 723443e` | `NoticeControllerTest`; `TemplateToAmisConverterTest#engineclass_MessageSendView_注入查看按钮,#engineclass_MessageManageView_注入发送消息弹窗`; live 浏览器验收 `ae79a47b`:打开「发送消息」→ 接收人标准 amis 表格 picker(搜索/分页/checkbox)→ 发送成功 → 不点搜索即在已发列表第一行出现 `codex短消息live刷新-*` |
|
||||
|
||||
## In Progress / Needs Verification
|
||||
|
||||
| 范围 | 状态 | 缺口 | 下一步 |
|
||||
|---|---|---|---|
|
||||
| 流程/审批:待办任务 `TaskComponentNew` | Needs side-effect verification | 浏览器已验 `4ebfc9ee`、`0f7531e2`:列表有数据、发起人显名、查看详细抽屉、处理抽屉、遮罩层级均正常;未点最终同意/拒绝,未验处理后刷新 | 准备专门测试流程实例,或经用户确认可消耗真实待办后,再验“同意/拒绝/退回后列表刷新” |
|
||||
| 用户选择框全家 | Implemented / Needs business verification | 最新口径:`eip4-platform 0d6fab4` 已把用户单选 `SelectDialog`、多选 `MultiSelectDialog` 统一转换为标准 amis `picker`(单选不加 `multiple`,多选仅加 `multiple: true` + `overflowConfig.maxTagCount=1`,数据源 `/api/picker/<dialogid>/list`);`eip4-web b0537f8` 兼容过滤器会把存量 `user-transfer-picker` schema 归一成同一标准 picker,本轮补丁进一步移除旧自定义 renderer 注册,只保留 schema filter。自动化:`npm run test -- registerUserTransferPicker registerMessageAction`、`npm run build`、`mvn -q -pl platform-converter -Dtest=TemplateToAmisConverterTest test`、`mvn -q -pl platform-metadata -Dtest=NoticeControllerTest test`。浏览器烟测:`54042d08` 查询单选「操作人」为标准 PickerControl;`919477da`「流程代理授权」代理人为标准单选 picker,和日期/下拉同高对齐;`5078945c`「用户组-分配用户」为标准多选 picker,默认值/label 正常,图标可打开二级 amis 表格弹窗,含搜索/分页/checkbox,多选确认后输入框仍 32px 且显示 `+ N ...`,未再撑开表单。 | 继续在短消息、设置定时任务、岗位设置等真实引用页验保存值、ALL 互斥、受控/全部权限差异和考勤排除挂靠 |
|
||||
| 用户选择框全家 | Implemented / Needs business verification | 最新口径:`eip4-platform 0d6fab4` 已把用户单选 `SelectDialog`、多选 `MultiSelectDialog` 统一转换为标准 amis `picker`(单选不加 `multiple`,多选仅加 `multiple: true` + `overflowConfig.maxTagCount=1`,数据源 `/api/picker/<dialogid>/list`);`eip4-web b0537f8` 兼容过滤器会把存量 `user-transfer-picker` schema 归一成同一标准 picker,本轮补丁进一步移除旧自定义 renderer 注册,只保留 schema filter。自动化:`npm run test -- registerUserTransferPicker registerMessageAction`、`npm run build`、`mvn -q -pl platform-converter -Dtest=TemplateToAmisConverterTest test`、`mvn -q -pl platform-metadata -Dtest=NoticeControllerTest test`。浏览器烟测:`54042d08` 查询单选「操作人」为标准 PickerControl;`919477da`「流程代理授权」代理人为标准单选 picker,和日期/下拉同高对齐;`5078945c`「用户组-分配用户」为标准多选 picker,默认值/label 正常,图标可打开二级 amis 表格弹窗,含搜索/分页/checkbox,多选确认后输入框仍 32px 且显示 `+ N ...`,未再撑开表单;短消息 `ae79a47b` 已覆盖多选 picker 选人并保存。 | 继续在设置定时任务、岗位设置等真实引用页验保存值、ALL 互斥、受控/全部权限差异和考勤排除挂靠 |
|
||||
| 流程选择框 | Implemented / Needs business verification | `ProcessSelectController` 已提供 `/api/process-select/options|search`;转换器已把 `b3070157` 接到 amis `transfer-picker`;`919477da` 流程代理授权已重转重导并从 PARTIAL 转 SUCCESS;浏览器 smoke 可打开弹窗,显示「流程名称/已选流程」和流程名 | 继续验流程代理授权保存闭环:代理类型=指定流程时必填、保存后 `wf_agent_process` 写入/读取一致 |
|
||||
| 菜单真入口 | Needs verification | 前端已去硬编码假入口;需确认所有需要的真菜单在 `sys_menu` 中可达 | 用 `/api/menu` 和页面侧栏核对 |
|
||||
| 功能模板下载门控 | Pending | backlog 写了 `VIEW_TEMPLATEID` 非空才显示附件编辑;当前只做了去按钮/改标题 | 决定是否补门控,若补则在 `EngineclassDelta` mutator 中按行/上下文控制 |
|
||||
@@ -48,7 +49,6 @@
|
||||
| P1 | 我的发起任务 | `0db4af06` | 查看详细、撤回;撤回需 Flowable 桥和已流转校验 | 机制① + 流程端点 |
|
||||
| P1 | 流程监控 | `9f3b5a8b` | 处理、高级处理、结束流程;高级处理涉及 Groovy 权限/审计 | 机制① + 流程端点,需权限守卫 |
|
||||
| P1 | 审批表单删除 | `91ccbba3` | 查看只读表单、删除历史流程实例 | 复用只读审批抽屉 + 流程删除端点 |
|
||||
| P1 | 短消息 | `ae79a47b` | 发送消息弹窗;收件人使用已接线的标准 amis 用户 picker | MessageService REST + 发送弹窗 |
|
||||
|
||||
## P2(中等 delta,可批量复用)
|
||||
|
||||
|
||||
@@ -84,6 +84,10 @@ public final class EngineclassDelta {
|
||||
EngineclassDelta::receivedMessageDetailButton);
|
||||
register("com.dsasp.client.tools.message.MessageSendView",
|
||||
EngineclassDelta::sentMessageDetailButton);
|
||||
registerMutator("com.dsasp.client.tools.message.MessageSendView",
|
||||
EngineclassDelta::messageSentViewDelta);
|
||||
registerMutator("com.dsasp.client.tools.message.MessageManageView",
|
||||
EngineclassDelta::messageManageDelta);
|
||||
}
|
||||
|
||||
private EngineclassDelta() {
|
||||
@@ -349,6 +353,164 @@ public final class EngineclassDelta {
|
||||
return btn;
|
||||
}
|
||||
|
||||
/** 已发送消息列表:给 CRUD 稳定 id,供短消息发送弹窗成功后精准刷新。 */
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void messageSentViewDelta(Map<String, Object> schema, ConversionResult result) {
|
||||
Object bodyObj = schema.get("body");
|
||||
if (!(bodyObj instanceof Map<?, ?> body) || !"crud".equals(body.get("type"))) {
|
||||
return;
|
||||
}
|
||||
((Map<String, Object>) bodyObj).putIfAbsent("id", "short-message-sent-crud");
|
||||
if (result != null) {
|
||||
result.note("engineclass[MessageSendView] 设置已发送消息 CRUD 刷新锚点");
|
||||
}
|
||||
}
|
||||
|
||||
/** 短消息 MessageManageView:在 group tabs 上方加「发送消息」弹窗表单。 */
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void messageManageDelta(Map<String, Object> schema, ConversionResult result) {
|
||||
Object bodyObj = schema.get("body");
|
||||
if (!(bodyObj instanceof Map<?, ?> tabs) || !"tabs".equals(tabs.get("type"))) {
|
||||
return;
|
||||
}
|
||||
if (hasSendMessageButton(schema)) {
|
||||
return;
|
||||
}
|
||||
((Map<String, Object>) bodyObj).putIfAbsent("id", "message-tabs");
|
||||
markShortMessageTabServices((Map<String, Object>) bodyObj);
|
||||
|
||||
Map<String, Object> toolbar = new LinkedHashMap<>();
|
||||
toolbar.put("type", "button-toolbar");
|
||||
toolbar.put("className", "m-b-sm");
|
||||
toolbar.put("buttons", List.of(sendMessageButton()));
|
||||
|
||||
List<Object> body = new ArrayList<>();
|
||||
body.add(toolbar);
|
||||
body.add(bodyObj);
|
||||
schema.put("body", body);
|
||||
if (result != null) {
|
||||
result.note("engineclass[MessageManageView] 注入「发送消息」弹窗表单");
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void markShortMessageTabServices(Map<String, Object> tabs) {
|
||||
Object tabListObj = tabs.get("tabs");
|
||||
if (!(tabListObj instanceof List<?> tabList)) {
|
||||
return;
|
||||
}
|
||||
for (Object tabObj : tabList) {
|
||||
if (!(tabObj instanceof Map<?, ?> tab)) {
|
||||
continue;
|
||||
}
|
||||
Object bodyObj = tab.get("body");
|
||||
if (!(bodyObj instanceof Map<?, ?> body) || !"service".equals(body.get("type"))) {
|
||||
continue;
|
||||
}
|
||||
String title = tab.get("title") == null ? "" : String.valueOf(tab.get("title"));
|
||||
if ("已发消息".equals(title)) {
|
||||
((Map<String, Object>) bodyObj).putIfAbsent("id", "short-message-sent-service");
|
||||
} else if ("已收消息".equals(title)) {
|
||||
((Map<String, Object>) bodyObj).putIfAbsent("id", "short-message-received-service");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static boolean hasSendMessageButton(Map<String, Object> schema) {
|
||||
Object bodyObj = schema.get("body");
|
||||
if (!(bodyObj instanceof List<?> list) || list.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
Object first = list.get(0);
|
||||
if (!(first instanceof Map<?, ?> toolbar)) {
|
||||
return false;
|
||||
}
|
||||
Object buttonsObj = toolbar.get("buttons");
|
||||
if (!(buttonsObj instanceof List<?> buttons)) {
|
||||
return false;
|
||||
}
|
||||
return buttons.stream()
|
||||
.filter(Map.class::isInstance)
|
||||
.map(Map.class::cast)
|
||||
.anyMatch(btn -> "发送消息".equals(btn.get("label")));
|
||||
}
|
||||
|
||||
private static Map<String, Object> sendMessageButton() {
|
||||
Map<String, Object> btn = new LinkedHashMap<>();
|
||||
btn.put("type", "button");
|
||||
btn.put("label", "发送消息");
|
||||
btn.put("level", "primary");
|
||||
btn.put("icon", "fa fa-paper-plane");
|
||||
btn.put("actionType", "dialog");
|
||||
btn.put("dialog", sendMessageDialog());
|
||||
return btn;
|
||||
}
|
||||
|
||||
private static Map<String, Object> sendMessageDialog() {
|
||||
Map<String, Object> form = new LinkedHashMap<>();
|
||||
form.put("type", "form");
|
||||
form.put("mode", "horizontal");
|
||||
form.put("api", "POST:/api/notice/send");
|
||||
form.put("reload", "short-message-sent-crud");
|
||||
form.put("horizontal", mapOf("left", 2, "right", 10));
|
||||
form.put("body", List.of(
|
||||
mapOf("type", "input-text", "name", "TITLE", "label", "标题",
|
||||
"required", true, "maxLength", 200),
|
||||
sendMessageReceiverPicker(),
|
||||
mapOf("type", "hidden", "name", "ISREPLY", "value", true),
|
||||
mapOf("type", "textarea", "name", "CONTENT", "label", "内容",
|
||||
"required", true, "minRows", 6, "maxLength", 2000)
|
||||
));
|
||||
|
||||
Map<String, Object> submit = new LinkedHashMap<>();
|
||||
submit.put("type", "button");
|
||||
submit.put("label", "发送");
|
||||
submit.put("level", "primary");
|
||||
submit.put("actionType", "submit");
|
||||
submit.put("close", true);
|
||||
|
||||
Map<String, Object> cancel = mapOf("type", "button", "label", "取消", "actionType", "close");
|
||||
|
||||
Map<String, Object> dialog = new LinkedHashMap<>();
|
||||
dialog.put("type", "dialog");
|
||||
dialog.put("title", "发送消息");
|
||||
dialog.put("size", "md");
|
||||
dialog.put("body", form);
|
||||
dialog.put("actions", List.of(cancel, submit));
|
||||
return dialog;
|
||||
}
|
||||
|
||||
private static Map<String, Object> sendMessageReceiverPicker() {
|
||||
Map<String, Object> searchBox = mapOf(
|
||||
"type", "search-box",
|
||||
"name", "q",
|
||||
"placeholder", "输入关键字搜索");
|
||||
Map<String, Object> pickerSchema = new LinkedHashMap<>();
|
||||
pickerSchema.put("mode", "table");
|
||||
pickerSchema.put("headerToolbar", List.of(searchBox));
|
||||
pickerSchema.put("footerToolbar", List.of("pagination"));
|
||||
|
||||
Map<String, Object> picker = new LinkedHashMap<>();
|
||||
picker.put("type", "picker");
|
||||
picker.put("name", "TOUSERS");
|
||||
picker.put("label", "接收人");
|
||||
picker.put("required", true);
|
||||
picker.put("multiple", true);
|
||||
picker.put("clearable", true);
|
||||
picker.put("placeholder", "请点击右侧的图标");
|
||||
picker.put("source", "/api/picker/090981ba-0c10-4d84-92dc-80e226594480/list");
|
||||
picker.put("labelField", "_label");
|
||||
picker.put("valueField", "_id");
|
||||
picker.put("modalMode", "dialog");
|
||||
picker.put("modalSize", "lg");
|
||||
picker.put("overflowConfig", mapOf(
|
||||
"maxTagCount", 1,
|
||||
"displayPosition", List.of("select")));
|
||||
picker.put("pickerSchema", pickerSchema);
|
||||
return picker;
|
||||
}
|
||||
|
||||
// ── 用户管理 · 设置主岗位 ──────────────────────────────────────────────
|
||||
/**
|
||||
* 「设置主岗位」按钮:选 1 用户 → 弹窗 form。initApi 拉该用户岗位(SYS_POSITIONUSER_SEARCH by USERID),
|
||||
|
||||
@@ -1104,6 +1104,7 @@ class TemplateToAmisConverterTest {
|
||||
ConversionResult r = converter.convertGraded(xml, null,
|
||||
"com.dsasp.client.tools.message.MessageSendView", "已发送消息", new ArrayList<>(), noPage);
|
||||
List<Object> toolbar = (List<Object>) body(r.getSchema()).get("headerToolbar");
|
||||
assertEquals("short-message-sent-crud", body(r.getSchema()).get("id"));
|
||||
Map<String, Object> detail = toolbar.stream()
|
||||
.filter(o -> o instanceof Map && "查看".equals(((Map<String, Object>) o).get("label")))
|
||||
.map(o -> (Map<String, Object>) o).findFirst().orElse(null);
|
||||
@@ -1117,6 +1118,51 @@ class TemplateToAmisConverterTest {
|
||||
assertEquals("${selectedItems[0].PM_DEMO_ID}", args.get("messageId"));
|
||||
}
|
||||
|
||||
/** engineclass=MessageManageView → 短消息页在已发/已收 tabs 上方注入发送消息弹窗。 */
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
void engineclass_MessageManageView_注入发送消息弹窗() {
|
||||
String xml = "<group>"
|
||||
+ "<template name='已发消息' tempid='b7635622-309a-4348-9657-a9ae6866992f'/>"
|
||||
+ "<template name='已收消息' tempid='83971d1a-490c-48a1-b9e1-e57fa26acda3'/>"
|
||||
+ "</group>";
|
||||
ConversionResult r = converter.convertGraded(xml, null,
|
||||
"com.dsasp.client.tools.message.MessageManageView", "短消息", new ArrayList<>(), noPage);
|
||||
|
||||
List<Object> pageBody = (List<Object>) r.getSchema().get("body");
|
||||
Map<String, Object> toolbar = (Map<String, Object>) pageBody.get(0);
|
||||
Map<String, Object> tabs = (Map<String, Object>) pageBody.get(1);
|
||||
List<Object> buttons = (List<Object>) toolbar.get("buttons");
|
||||
Map<String, Object> send = (Map<String, Object>) buttons.get(0);
|
||||
List<Object> tabItems = (List<Object>) tabs.get("tabs");
|
||||
Map<String, Object> sentTab = (Map<String, Object>) tabItems.get(0);
|
||||
Map<String, Object> sentService = (Map<String, Object>) sentTab.get("body");
|
||||
|
||||
assertEquals("button-toolbar", toolbar.get("type"));
|
||||
assertEquals("tabs", tabs.get("type"));
|
||||
assertEquals("message-tabs", tabs.get("id"));
|
||||
assertEquals("short-message-sent-service", sentService.get("id"));
|
||||
assertEquals("发送消息", send.get("label"));
|
||||
assertEquals("dialog", send.get("actionType"));
|
||||
|
||||
Map<String, Object> dialog = (Map<String, Object>) send.get("dialog");
|
||||
Map<String, Object> form = (Map<String, Object>) dialog.get("body");
|
||||
List<Object> fields = (List<Object>) form.get("body");
|
||||
Map<String, Object> receivers = (Map<String, Object>) fields.get(1);
|
||||
List<Object> actions = (List<Object>) dialog.get("actions");
|
||||
Map<String, Object> submit = (Map<String, Object>) actions.get(1);
|
||||
|
||||
assertEquals("发送消息", dialog.get("title"));
|
||||
assertEquals("POST:/api/notice/send", form.get("api"));
|
||||
assertEquals("short-message-sent-crud", form.get("reload"));
|
||||
assertEquals("picker", receivers.get("type"));
|
||||
assertEquals("TOUSERS", receivers.get("name"));
|
||||
assertEquals(true, receivers.get("multiple"));
|
||||
assertEquals("/api/picker/090981ba-0c10-4d84-92dc-80e226594480/list", receivers.get("source"));
|
||||
assertEquals("submit", submit.get("actionType"));
|
||||
assertFalse(submit.containsKey("api"));
|
||||
}
|
||||
|
||||
/**
|
||||
* engineclass=FuncDownloadComponent(功能模板下载模板管理/设置,type=3 树页)→ 整页改写器(机制① MUTATORS):
|
||||
* 移除右表单「添加」按钮(空 toolbar 整条移除)+ 右表单标题改「编辑模板附件」。复刻 refreshRightLayout。
|
||||
|
||||
@@ -1,17 +1,23 @@
|
||||
package com.eip4.platform.metadata.web;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.dao.EmptyResultDataAccessException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.jdbc.core.JdbcOperations;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
@@ -50,6 +56,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
* <li>{@code GET /api/notice/unread-count} — 轻量未读数计数(顶栏轮询用)</li>
|
||||
* <li>{@code GET /api/notice/{id}/detail} — 已发送/可访问消息详情</li>
|
||||
* <li>{@code POST /api/notice/received/{id}/open} — 收到消息打开详情并置已读</li>
|
||||
* <li>{@code POST /api/notice/send} — 发送短消息(写 sys_message + sys_messageuser)</li>
|
||||
* <li>{@code POST /api/notice/{id}/read} — 单条置已读</li>
|
||||
* <li>{@code POST /api/notice/read-all} — 当前用户全部已读</li>
|
||||
* </ul>
|
||||
@@ -196,6 +203,69 @@ public class NoticeController {
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- 发送短消息
|
||||
|
||||
/**
|
||||
* 发送短消息。
|
||||
*
|
||||
* <p>复刻旧 {@code MessageSendForm -> SYS_MESSAGE_ADD} 的核心写库语义:写一条
|
||||
* {@code SYS_MESSAGE(TYPE=2)},并按 {@code TOUSERS} 为每个收件人写 {@code SYS_MESSAGEUSER}。
|
||||
* 收件人输入兼容标准 amis picker 的多种形态:逗号串、字符串数组、行对象数组(取
|
||||
* {@code _id/value/SYS_USER_ID/VIEW_SYS_USER_ID})。
|
||||
*/
|
||||
@Operation(summary = "发送短消息",
|
||||
description = "写 SYS_MESSAGE(TYPE=2) + SYS_MESSAGEUSER;TOUSERS 支持 picker 多选值")
|
||||
@PostMapping("/api/notice/send")
|
||||
@Transactional
|
||||
public ResponseEntity<Map<String, Object>> send(@RequestBody Map<String, Object> body) {
|
||||
String userId = requireCurrentUserId();
|
||||
String title = string(body == null ? null : body.get("TITLE"));
|
||||
String content = string(body == null ? null : body.get("CONTENT"));
|
||||
List<String> receivers = parseReceiverIds(body == null ? null : body.get("TOUSERS"));
|
||||
|
||||
if (title.isBlank()) {
|
||||
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "标题为必输项");
|
||||
}
|
||||
if (receivers.isEmpty()) {
|
||||
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "接收人为必输项");
|
||||
}
|
||||
if (content.isBlank()) {
|
||||
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "内容不能为空");
|
||||
}
|
||||
|
||||
Properties ctx = UserSession.get();
|
||||
String orgId = blankToNull(ctx == null ? null : ctx.getProperty(LoggedInUser.CURRENTORG));
|
||||
String departId = blankToNull(ctx == null ? null : ctx.getProperty(LoggedInUser.CURRENTDEPART));
|
||||
long now = System.currentTimeMillis();
|
||||
String messageId = UUID.randomUUID().toString();
|
||||
int isReply = body != null && isTruthy(body.get("ISREPLY")) ? 1 : 0;
|
||||
|
||||
jdbcTemplate.update(
|
||||
"INSERT INTO eip3.sys_message(sys_message_id,title,content,isdel,isreply,type,"
|
||||
+ "createtime,createby,updatetime,updateby,orgid,departid,isactive,version,params)"
|
||||
+ " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
|
||||
messageId, title, content, 0, isReply, 2,
|
||||
now, userId, now, userId, orgId, departId, 1, 0, null);
|
||||
|
||||
for (String receiverId : receivers) {
|
||||
jdbcTemplate.update(
|
||||
"INSERT INTO eip3.sys_messageuser(sys_messageuser_id,sys_message_id,sys_user_id,"
|
||||
+ "isread,isdel,createtime,createby,updatetime,updateby,orgid,departid,isactive,version)"
|
||||
+ " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)",
|
||||
UUID.randomUUID().toString(), messageId, receiverId,
|
||||
0, 0, now, userId, now, userId, orgId, departId, 1, 0);
|
||||
}
|
||||
|
||||
Map<String, Object> data = new LinkedHashMap<>();
|
||||
data.put("id", messageId);
|
||||
data.put("receiverCount", receivers.size());
|
||||
Map<String, Object> resp = new LinkedHashMap<>();
|
||||
resp.put("status", 0);
|
||||
resp.put("msg", "发送成功");
|
||||
resp.put("data", data);
|
||||
return ResponseEntity.ok(resp);
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- 未读数计数
|
||||
|
||||
/**
|
||||
@@ -390,4 +460,51 @@ public class NoticeController {
|
||||
String s = String.valueOf(value).trim();
|
||||
return "1".equals(s) || "true".equalsIgnoreCase(s) || "yes".equalsIgnoreCase(s);
|
||||
}
|
||||
|
||||
private static String blankToNull(String value) {
|
||||
String s = string(value);
|
||||
return s.isBlank() ? null : s;
|
||||
}
|
||||
|
||||
private static List<String> parseReceiverIds(Object raw) {
|
||||
Set<String> out = new LinkedHashSet<>();
|
||||
collectReceiverIds(raw, out);
|
||||
return new ArrayList<>(out);
|
||||
}
|
||||
|
||||
private static void collectReceiverIds(Object raw, Set<String> out) {
|
||||
if (raw == null) {
|
||||
return;
|
||||
}
|
||||
if (raw instanceof Iterable<?> values) {
|
||||
for (Object value : values) {
|
||||
collectReceiverIds(value, out);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (raw instanceof Map<?, ?> map) {
|
||||
Object id = firstNonNull(map, "_id", "value", "id", "SYS_USER_ID", "VIEW_SYS_USER_ID");
|
||||
collectReceiverIds(id, out);
|
||||
return;
|
||||
}
|
||||
String text = string(raw);
|
||||
if (text.isBlank()) {
|
||||
return;
|
||||
}
|
||||
for (String part : text.split(",")) {
|
||||
String id = part.trim();
|
||||
if (!id.isBlank()) {
|
||||
out.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Object firstNonNull(Map<?, ?> map, String... keys) {
|
||||
for (String key : keys) {
|
||||
if (map.containsKey(key) && map.get(key) != null) {
|
||||
return map.get(key);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,11 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.anyLong;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.contains;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.mockStatic;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -272,6 +275,51 @@ class NoticeControllerTest {
|
||||
assertThrows(ResponseStatusException.class, () -> controller.markAllRead());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- 发送短消息
|
||||
|
||||
@Test
|
||||
@DisplayName("15. 发送短消息 → 写 sys_message 和去重后的 sys_messageuser")
|
||||
void sendMessage() {
|
||||
mockUser("sender-001");
|
||||
Map<String, Object> body = new LinkedHashMap<>();
|
||||
body.put("TITLE", "短消息标题");
|
||||
body.put("CONTENT", "短消息内容");
|
||||
body.put("ISREPLY", true);
|
||||
body.put("TOUSERS", List.of(Map.of("_id", "user-001"), "user-002,user-001"));
|
||||
|
||||
ResponseEntity<Map<String, Object>> resp = controller.send(body);
|
||||
|
||||
assertEquals(200, resp.getStatusCode().value());
|
||||
Map<String, Object> data = (Map<String, Object>) resp.getBody().get("data");
|
||||
assertEquals(2, data.get("receiverCount"));
|
||||
assertNotNull(data.get("id"));
|
||||
verify(jdbc).update(contains("INSERT INTO eip3.sys_message("),
|
||||
anyString(), eq("短消息标题"), eq("短消息内容"), eq(0), eq(1), eq(2),
|
||||
anyLong(), eq("sender-001"), anyLong(), eq("sender-001"),
|
||||
isNull(), isNull(), eq(1), eq(0), isNull());
|
||||
verify(jdbc).update(contains("INSERT INTO eip3.sys_messageuser"),
|
||||
anyString(), anyString(), eq("user-001"), eq(0), eq(0),
|
||||
anyLong(), eq("sender-001"), anyLong(), eq("sender-001"),
|
||||
isNull(), isNull(), eq(1), eq(0));
|
||||
verify(jdbc).update(contains("INSERT INTO eip3.sys_messageuser"),
|
||||
anyString(), anyString(), eq("user-002"), eq(0), eq(0),
|
||||
anyLong(), eq("sender-001"), anyLong(), eq("sender-001"),
|
||||
isNull(), isNull(), eq(1), eq(0));
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("16. 发送短消息缺接收人 → 400")
|
||||
void sendMessageMissingReceiver() {
|
||||
mockUser("sender-002");
|
||||
Map<String, Object> body = new LinkedHashMap<>();
|
||||
body.put("TITLE", "短消息标题");
|
||||
body.put("CONTENT", "短消息内容");
|
||||
|
||||
ResponseStatusException ex = assertThrows(ResponseStatusException.class, () -> controller.send(body));
|
||||
|
||||
assertEquals(HttpStatus.BAD_REQUEST, ex.getStatusCode());
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- 测试数据构建
|
||||
|
||||
private Map<String, Object> fakeMsg(String id, String title, String summary,
|
||||
|
||||
Reference in New Issue
Block a user