Commit 08a4de37c2f8fffbb9d656b54c58ab95eded18ba

Authored by xingyu
2 parents 68bdaa78 624b5716

Merge remote-tracking branch 'origin/master' into feature/springdoc

# Conflicts:
#	README.md
Showing 90 changed files with 4026 additions and 134 deletions
README.md
@@ -41,7 +41,20 @@ @@ -41,7 +41,20 @@
41 | `ruoyi-vue-pro` | Spring Boot 多模块 | **[Gitee](https://gitee.com/zhijiantianya/ruoyi-vue-pro)**     [Github](https://github.com/YunaiV/ruoyi-vue-pro) | 41 | `ruoyi-vue-pro` | Spring Boot 多模块 | **[Gitee](https://gitee.com/zhijiantianya/ruoyi-vue-pro)**     [Github](https://github.com/YunaiV/ruoyi-vue-pro) |
42 | `yudao-cloud` | Spring Cloud 微服务 | **[Gitee](https://gitee.com/zhijiantianya/yudao-cloud)**     [Github](https://github.com/YunaiV/yudao-cloud) | 42 | `yudao-cloud` | Spring Cloud 微服务 | **[Gitee](https://gitee.com/zhijiantianya/yudao-cloud)**     [Github](https://github.com/YunaiV/yudao-cloud) |
43 | `Spring-Boot-Labs` | Spring Boot & Cloud 入门 | **[Gitee](https://gitee.com/zhijiantianya/SpringBoot-Labs)**     [Github](https://github.com/YunaiV/SpringBoot-Labs) | 43 | `Spring-Boot-Labs` | Spring Boot & Cloud 入门 | **[Gitee](https://gitee.com/zhijiantianya/SpringBoot-Labs)**     [Github](https://github.com/YunaiV/SpringBoot-Labs) |
44 -| `ruoyi-vue-pro-mini` | 精简版:移除工作流、支付等模块 | **[Gitee](https://gitee.com/zhijiantianya/ruoyi-vue-pro/tree/mini)** | 44 +
  45 +## 🐰 分支说明
  46 +
  47 +| | JDK 8 完整版 | JDK 8 精简版 | JDK 17 完整版 |
  48 +|-------|-----------------------------------------------------------|--------------------------------------------------------------------|-----------------------------------------------------------------------------|
  49 +| 分支 | [`master`](https://gitee.com/zhijiantianya/ruoyi-vue-pro) | [`mini`](https://gitee.com/zhijiantianya/ruoyi-vue-pro/tree/mini/) | [`boot-dev`](https://gitee.com/zhijiantianya/ruoyi-vue-pro/tree/boot3-dev/) |
  50 +| 说明 | 包括所有功能 | 只保留核心功能 | 适配 Spring Boot 3.X |
  51 +| 系统功能 | √ | √ | √ |
  52 +| 基础设施 | √ | √ | √ |
  53 +| 会员中心 | √ | √ | √ |
  54 +| 工作流程 | √ | x | 适配中 |
  55 +| 数据报表 | √ | x | 适配中 |
  56 +| 商城系统 | √ | x | √ |
  57 +| 微信公众号 | √ | x | √ |
45 58
46 ## 😎 开源协议 59 ## 😎 开源协议
47 60
@@ -55,6 +68,14 @@ @@ -55,6 +68,14 @@
55 68
56 ③ 代码整洁、架构整洁,遵循《阿里巴巴 Java 开发手册》规范,代码注释详细,57000 行 Java 代码,22000 行代码注释。 69 ③ 代码整洁、架构整洁,遵循《阿里巴巴 Java 开发手册》规范,代码注释详细,57000 行 Java 代码,22000 行代码注释。
57 70
  71 +## 🤝 项目外包
  72 +
  73 +我们也是接外包滴,如果你有项目想要外包,可以微信联系【**Aix9975**】。
  74 +
  75 +团队包含专业的项目经理、架构师、前端工程师、后端工程师、测试工程师、运维工程师,可以提供全流程的外包服务。
  76 +
  77 +项目可以是商城、SCRM 系统、OA 系统、物流系统、ERP 系统、CMS 系统、HIS 系统、支付系统、IM 聊天、微信公众号、微信小程序等等。
  78 +
58 ## 🐼 内置功能 79 ## 🐼 内置功能
59 80
60 系统内置多种多种业务功能,可以用于快速你的业务系统: 81 系统内置多种多种业务功能,可以用于快速你的业务系统:
@@ -92,6 +113,7 @@ @@ -92,6 +113,7 @@
92 | | 字典管理 | 对系统中经常使用的一些较为固定的数据进行维护 | 113 | | 字典管理 | 对系统中经常使用的一些较为固定的数据进行维护 |
93 | 🚀 | 短信管理 | 短信渠道、短息模板、短信日志,对接阿里云、腾讯云等主流短信平台 | 114 | 🚀 | 短信管理 | 短信渠道、短息模板、短信日志,对接阿里云、腾讯云等主流短信平台 |
94 | 🚀 | 邮件管理 | 邮箱账号、邮件模版、邮件发送日志,支持所有邮件平台 | 115 | 🚀 | 邮件管理 | 邮箱账号、邮件模版、邮件发送日志,支持所有邮件平台 |
  116 +| 🚀 | 站内信 | 系统内的消息通知,提供站内信模版、站内信消息 |
95 | 🚀 | 操作日志 | 系统正常操作日志记录和查询,集成 Swagger 生成日志内容 | 117 | 🚀 | 操作日志 | 系统正常操作日志记录和查询,集成 Swagger 生成日志内容 |
96 | ⭐️ | 登录日志 | 系统登录日志记录查询,包含登录异常 | 118 | ⭐️ | 登录日志 | 系统登录日志记录查询,包含登录异常 |
97 | 🚀 | 错误码管理 | 系统所有错误码的管理,可在线修改错误提示,无需重启服务 | 119 | 🚀 | 错误码管理 | 系统所有错误码的管理,可在线修改错误提示,无需重启服务 |
@@ -30,7 +30,7 @@ @@ -30,7 +30,7 @@
30 <url>https://github.com/YunaiV/ruoyi-vue-pro</url> 30 <url>https://github.com/YunaiV/ruoyi-vue-pro</url>
31 31
32 <properties> 32 <properties>
33 - <revision>1.6.6-snapshot</revision> 33 + <revision>1.7.0-snapshot</revision>
34 <!-- Maven 相关 --> 34 <!-- Maven 相关 -->
35 <java.version>1.8</java.version> 35 <java.version>1.8</java.version>
36 <maven.compiler.source>${java.version}</maven.compiler.source> 36 <maven.compiler.source>${java.version}</maven.compiler.source>
sql/mysql/ruoyi-vue-pro.sql
@@ -546,7 +546,7 @@ CREATE TABLE `infra_api_error_log` ( @@ -546,7 +546,7 @@ CREATE TABLE `infra_api_error_log` (
546 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', 546 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
547 `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', 547 `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
548 PRIMARY KEY (`id`) USING BTREE 548 PRIMARY KEY (`id`) USING BTREE
549 -) ENGINE = InnoDB AUTO_INCREMENT = 949 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统异常日志'; 549 +) ENGINE = InnoDB AUTO_INCREMENT = 965 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统异常日志';
550 550
551 -- ---------------------------- 551 -- ----------------------------
552 -- Records of infra_api_error_log 552 -- Records of infra_api_error_log
@@ -584,7 +584,7 @@ CREATE TABLE `infra_codegen_column` ( @@ -584,7 +584,7 @@ CREATE TABLE `infra_codegen_column` (
584 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', 584 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
585 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', 585 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
586 PRIMARY KEY (`id`) USING BTREE 586 PRIMARY KEY (`id`) USING BTREE
587 -) ENGINE = InnoDB AUTO_INCREMENT = 1582 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '代码生成表字段定义'; 587 +) ENGINE = InnoDB AUTO_INCREMENT = 1612 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '代码生成表字段定义';
588 588
589 -- ---------------------------- 589 -- ----------------------------
590 -- Records of infra_codegen_column 590 -- Records of infra_codegen_column
@@ -616,7 +616,7 @@ CREATE TABLE `infra_codegen_table` ( @@ -616,7 +616,7 @@ CREATE TABLE `infra_codegen_table` (
616 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', 616 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
617 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', 617 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
618 PRIMARY KEY (`id`) USING BTREE 618 PRIMARY KEY (`id`) USING BTREE
619 -) ENGINE = InnoDB AUTO_INCREMENT = 122 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '代码生成表定义'; 619 +) ENGINE = InnoDB AUTO_INCREMENT = 124 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '代码生成表定义';
620 620
621 -- ---------------------------- 621 -- ----------------------------
622 -- Records of infra_codegen_table 622 -- Records of infra_codegen_table
@@ -1191,7 +1191,7 @@ CREATE TABLE `system_dict_data` ( @@ -1191,7 +1191,7 @@ CREATE TABLE `system_dict_data` (
1191 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', 1191 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
1192 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', 1192 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
1193 PRIMARY KEY (`id`) USING BTREE 1193 PRIMARY KEY (`id`) USING BTREE
1194 -) ENGINE = InnoDB AUTO_INCREMENT = 1227 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '字典数据表'; 1194 +) ENGINE = InnoDB AUTO_INCREMENT = 1229 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '字典数据表';
1195 1195
1196 -- ---------------------------- 1196 -- ----------------------------
1197 -- Records of system_dict_data 1197 -- Records of system_dict_data
@@ -1395,6 +1395,8 @@ INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `st @@ -1395,6 +1395,8 @@ INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `st
1395 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1224, 10, '发送成功', '10', 'system_mail_send_status', 0, 'success', '', '邮件发送状态 - 发送成功', '1', '2023-01-26 09:54:28', '1', '2023-01-26 16:36:22', b'0'); 1395 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1224, 10, '发送成功', '10', 'system_mail_send_status', 0, 'success', '', '邮件发送状态 - 发送成功', '1', '2023-01-26 09:54:28', '1', '2023-01-26 16:36:22', b'0');
1396 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1225, 20, '发送失败', '20', 'system_mail_send_status', 0, 'danger', '', '邮件发送状态 - 发送失败', '1', '2023-01-26 09:54:50', '1', '2023-01-26 16:36:26', b'0'); 1396 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1225, 20, '发送失败', '20', 'system_mail_send_status', 0, 'danger', '', '邮件发送状态 - 发送失败', '1', '2023-01-26 09:54:50', '1', '2023-01-26 16:36:26', b'0');
1397 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1226, 30, '不发送', '30', 'system_mail_send_status', 0, 'info', '', '邮件发送状态 - 不发送', '1', '2023-01-26 09:55:06', '1', '2023-01-26 16:36:36', b'0'); 1397 INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1226, 30, '不发送', '30', 'system_mail_send_status', 0, 'info', '', '邮件发送状态 - 不发送', '1', '2023-01-26 09:55:06', '1', '2023-01-26 16:36:36', b'0');
  1398 +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1227, 1, '通知公告', '1', 'system_notify_template_type', 0, 'primary', '', '站内信模版的类型 - 通知公告', '1', '2023-01-28 10:35:59', '1', '2023-01-28 10:35:59', b'0');
  1399 +INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1228, 2, '系统消息', '2', 'system_notify_template_type', 0, 'success', '', '站内信模版的类型 - 系统消息', '1', '2023-01-28 10:36:20', '1', '2023-01-28 10:36:25', b'0');
1398 COMMIT; 1400 COMMIT;
1399 1401
1400 -- ---------------------------- 1402 -- ----------------------------
@@ -1415,7 +1417,7 @@ CREATE TABLE `system_dict_type` ( @@ -1415,7 +1417,7 @@ CREATE TABLE `system_dict_type` (
1415 `deleted_time` datetime NULL DEFAULT NULL COMMENT '删除时间', 1417 `deleted_time` datetime NULL DEFAULT NULL COMMENT '删除时间',
1416 PRIMARY KEY (`id`) USING BTREE, 1418 PRIMARY KEY (`id`) USING BTREE,
1417 UNIQUE INDEX `dict_type`(`type` ASC) USING BTREE 1419 UNIQUE INDEX `dict_type`(`type` ASC) USING BTREE
1418 -) ENGINE = InnoDB AUTO_INCREMENT = 167 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '字典类型表'; 1420 +) ENGINE = InnoDB AUTO_INCREMENT = 168 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '字典类型表';
1419 1421
1420 -- ---------------------------- 1422 -- ----------------------------
1421 -- Records of system_dict_type 1423 -- Records of system_dict_type
@@ -1479,6 +1481,7 @@ INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creat @@ -1479,6 +1481,7 @@ INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creat
1479 INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (164, '公众号自动回复的请求关键字匹配模式', 'mp_auto_reply_request_match', 0, '公众号自动回复的请求关键字匹配模式', '1', '2023-01-16 23:29:56', '1', '2023-01-16 23:29:56', b'0', '1970-01-01 00:00:00'); 1481 INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (164, '公众号自动回复的请求关键字匹配模式', 'mp_auto_reply_request_match', 0, '公众号自动回复的请求关键字匹配模式', '1', '2023-01-16 23:29:56', '1', '2023-01-16 23:29:56', b'0', '1970-01-01 00:00:00');
1480 INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (165, '公众号的消息类型', 'mp_message_type', 0, '公众号的消息类型', '1', '2023-01-17 22:17:09', '1', '2023-01-17 22:17:09', b'0', '1970-01-01 00:00:00'); 1482 INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (165, '公众号的消息类型', 'mp_message_type', 0, '公众号的消息类型', '1', '2023-01-17 22:17:09', '1', '2023-01-17 22:17:09', b'0', '1970-01-01 00:00:00');
1481 INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (166, '邮件发送状态', 'system_mail_send_status', 0, '邮件发送状态', '1', '2023-01-26 09:53:13', '1', '2023-01-26 09:53:13', b'0', '1970-01-01 00:00:00'); 1483 INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (166, '邮件发送状态', 'system_mail_send_status', 0, '邮件发送状态', '1', '2023-01-26 09:53:13', '1', '2023-01-26 09:53:13', b'0', '1970-01-01 00:00:00');
  1484 +INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (167, '站内信模版的类型', 'system_notify_template_type', 0, '站内信模版的类型', '1', '2023-01-28 10:35:10', '1', '2023-01-28 10:35:10', b'0', '1970-01-01 00:00:00');
1482 COMMIT; 1485 COMMIT;
1483 1486
1484 -- ---------------------------- 1487 -- ----------------------------
@@ -1527,7 +1530,7 @@ CREATE TABLE `system_login_log` ( @@ -1527,7 +1530,7 @@ CREATE TABLE `system_login_log` (
1527 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', 1530 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
1528 `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', 1531 `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
1529 PRIMARY KEY (`id`) USING BTREE 1532 PRIMARY KEY (`id`) USING BTREE
1530 -) ENGINE = InnoDB AUTO_INCREMENT = 1980 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统访问记录'; 1533 +) ENGINE = InnoDB AUTO_INCREMENT = 1985 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统访问记录';
1531 1534
1532 -- ---------------------------- 1535 -- ----------------------------
1533 -- Records of system_login_log 1536 -- Records of system_login_log
@@ -1620,7 +1623,7 @@ CREATE TABLE `system_mail_template` ( @@ -1620,7 +1623,7 @@ CREATE TABLE `system_mail_template` (
1620 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', 1623 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
1621 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', 1624 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
1622 PRIMARY KEY (`id`) USING BTREE 1625 PRIMARY KEY (`id`) USING BTREE
1623 -) ENGINE = InnoDB AUTO_INCREMENT = 15 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '邮件模版表'; 1626 +) ENGINE = InnoDB AUTO_INCREMENT = 16 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '邮件模版表';
1624 1627
1625 -- ---------------------------- 1628 -- ----------------------------
1626 -- Records of system_mail_template 1629 -- Records of system_mail_template
@@ -1654,7 +1657,7 @@ CREATE TABLE `system_menu` ( @@ -1654,7 +1657,7 @@ CREATE TABLE `system_menu` (
1654 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', 1657 `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
1655 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', 1658 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
1656 PRIMARY KEY (`id`) USING BTREE 1659 PRIMARY KEY (`id`) USING BTREE
1657 -) ENGINE = InnoDB AUTO_INCREMENT = 2144 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '菜单权限表'; 1660 +) ENGINE = InnoDB AUTO_INCREMENT = 2153 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '菜单权限表';
1658 1661
1659 -- ---------------------------- 1662 -- ----------------------------
1660 -- Records of system_menu 1663 -- Records of system_menu
@@ -1877,7 +1880,7 @@ INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_i @@ -1877,7 +1880,7 @@ INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_i
1877 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1250, '敏感词更新', 'system:sensitive-word:update', 3, 3, 1247, '', '', '', 0, b'1', b'1', '', '2022-04-07 16:55:03', '', '2022-04-20 17:03:10', b'0'); 1880 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1250, '敏感词更新', 'system:sensitive-word:update', 3, 3, 1247, '', '', '', 0, b'1', b'1', '', '2022-04-07 16:55:03', '', '2022-04-20 17:03:10', b'0');
1878 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1251, '敏感词删除', 'system:sensitive-word:delete', 3, 4, 1247, '', '', '', 0, b'1', b'1', '', '2022-04-07 16:55:03', '', '2022-04-20 17:03:10', b'0'); 1881 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1251, '敏感词删除', 'system:sensitive-word:delete', 3, 4, 1247, '', '', '', 0, b'1', b'1', '', '2022-04-07 16:55:03', '', '2022-04-20 17:03:10', b'0');
1879 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1252, '敏感词导出', 'system:sensitive-word:export', 3, 5, 1247, '', '', '', 0, b'1', b'1', '', '2022-04-07 16:55:03', '', '2022-04-20 17:03:10', b'0'); 1882 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1252, '敏感词导出', 'system:sensitive-word:export', 3, 5, 1247, '', '', '', 0, b'1', b'1', '', '2022-04-07 16:55:03', '', '2022-04-20 17:03:10', b'0');
1880 -INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1254, '作者动态', '', 1, 0, 0, 'https://www.iocoder.cn', 'people', NULL, 0, b'1', b'1', '1', '2022-04-23 01:03:15', '1', '2023-01-25 20:05:55', b'0'); 1883 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1254, '作者动态', '', 1, 0, 0, 'https://www.iocoder.cn', 'people', NULL, 0, b'1', b'1', '1', '2022-04-23 01:03:15', '1', '2023-01-28 12:33:52', b'0');
1881 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1255, '数据源配置', '', 2, 1, 2, 'data-source-config', 'rate', 'infra/dataSourceConfig/index', 0, b'1', b'1', '', '2022-04-27 14:37:32', '1', '2022-04-27 22:42:06', b'0'); 1884 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1255, '数据源配置', '', 2, 1, 2, 'data-source-config', 'rate', 'infra/dataSourceConfig/index', 0, b'1', b'1', '', '2022-04-27 14:37:32', '1', '2022-04-27 22:42:06', b'0');
1882 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1256, '数据源配置查询', 'infra:data-source-config:query', 3, 1, 1255, '', '', '', 0, b'1', b'1', '', '2022-04-27 14:37:32', '', '2022-04-27 14:37:32', b'0'); 1885 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1256, '数据源配置查询', 'infra:data-source-config:query', 3, 1, 1255, '', '', '', 0, b'1', b'1', '', '2022-04-27 14:37:32', '', '2022-04-27 14:37:32', b'0');
1883 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1257, '数据源配置创建', 'infra:data-source-config:create', 3, 2, 1255, '', '', '', 0, b'1', b'1', '', '2022-04-27 14:37:32', '', '2022-04-27 14:37:32', b'0'); 1886 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1257, '数据源配置创建', 'infra:data-source-config:create', 3, 2, 1255, '', '', '', 0, b'1', b'1', '', '2022-04-27 14:37:32', '', '2022-04-27 14:37:32', b'0');
@@ -2023,6 +2026,15 @@ INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_i @@ -2023,6 +2026,15 @@ INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_i
2023 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2141, '邮件记录', '', 2, 0, 2130, 'mail-log', 'log', 'system/mail/log/index', 0, b'1', b'1', '', '2023-01-26 02:16:50', '1', '2023-01-26 16:38:27', b'0'); 2026 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2141, '邮件记录', '', 2, 0, 2130, 'mail-log', 'log', 'system/mail/log/index', 0, b'1', b'1', '', '2023-01-26 02:16:50', '1', '2023-01-26 16:38:27', b'0');
2024 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2142, '日志查询', 'system:mail-log:query', 3, 1, 2141, '', '', '', 0, b'1', b'1', '', '2023-01-26 02:16:50', '', '2023-01-26 02:16:50', b'0'); 2027 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2142, '日志查询', 'system:mail-log:query', 3, 1, 2141, '', '', '', 0, b'1', b'1', '', '2023-01-26 02:16:50', '', '2023-01-26 02:16:50', b'0');
2025 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2143, '发送测试邮件', 'system:mail-template:send-mail', 3, 5, 2136, '', '', '', 0, b'1', b'1', '1', '2023-01-26 23:29:15', '1', '2023-01-26 23:29:15', b'0'); 2028 INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2143, '发送测试邮件', 'system:mail-template:send-mail', 3, 5, 2136, '', '', '', 0, b'1', b'1', '1', '2023-01-26 23:29:15', '1', '2023-01-26 23:29:15', b'0');
  2029 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2144, '站内信管理', '', 1, 11, 1, 'notify', 'message', NULL, 0, b'1', b'1', '1', '2023-01-28 10:25:18', '1', '2023-01-28 10:25:46', b'0');
  2030 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2145, '模板管理', '', 2, 0, 2144, 'notify-template', 'education', 'system/notify/template/index', 0, b'1', b'1', '', '2023-01-28 02:26:42', '1', '2023-01-28 10:27:47', b'0');
  2031 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2146, '站内信模板查询', 'system:notify-template:query', 3, 1, 2145, '', '', '', 0, b'1', b'1', '', '2023-01-28 02:26:42', '', '2023-01-28 02:26:42', b'0');
  2032 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2147, '站内信模板创建', 'system:notify-template:create', 3, 2, 2145, '', '', '', 0, b'1', b'1', '', '2023-01-28 02:26:42', '', '2023-01-28 02:26:42', b'0');
  2033 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2148, '站内信模板更新', 'system:notify-template:update', 3, 3, 2145, '', '', '', 0, b'1', b'1', '', '2023-01-28 02:26:42', '', '2023-01-28 02:26:42', b'0');
  2034 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2149, '站内信模板删除', 'system:notify-template:delete', 3, 4, 2145, '', '', '', 0, b'1', b'1', '', '2023-01-28 02:26:42', '', '2023-01-28 02:26:42', b'0');
  2035 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2150, '发送测试站内信', 'system:notify-template:send-notify', 3, 5, 2145, '', '', '', 0, b'1', b'1', '1', '2023-01-28 10:54:43', '1', '2023-01-28 10:54:43', b'0');
  2036 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2151, '消息记录', '', 2, 0, 2144, 'notify-message', 'edit', 'system/notify/message/index', 0, b'1', b'1', '', '2023-01-28 04:28:22', '1', '2023-01-28 20:59:53', b'0');
  2037 +INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `status`, `visible`, `keep_alive`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2152, '站内信消息查询', 'system:notify-message:query', 3, 1, 2151, '', '', '', 0, b'1', b'1', '', '2023-01-28 04:28:22', '', '2023-01-28 04:28:22', b'0');
2026 COMMIT; 2038 COMMIT;
2027 2039
2028 -- ---------------------------- 2040 -- ----------------------------
@@ -2054,6 +2066,72 @@ INSERT INTO `system_notice` (`id`, `title`, `content`, `type`, `status`, `creato @@ -2054,6 +2066,72 @@ INSERT INTO `system_notice` (`id`, `title`, `content`, `type`, `status`, `creato
2054 COMMIT; 2066 COMMIT;
2055 2067
2056 -- ---------------------------- 2068 -- ----------------------------
  2069 +-- Table structure for system_notify_message
  2070 +-- ----------------------------
  2071 +DROP TABLE IF EXISTS `system_notify_message`;
  2072 +CREATE TABLE `system_notify_message` (
  2073 + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '用户ID',
  2074 + `user_id` bigint NOT NULL COMMENT '用户id',
  2075 + `user_type` tinyint NOT NULL COMMENT '用户类型',
  2076 + `template_id` bigint NOT NULL COMMENT '模版编号',
  2077 + `template_code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '模板编码',
  2078 + `template_nickname` varchar(63) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '模版发送人名称',
  2079 + `template_content` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '模版内容',
  2080 + `template_type` int NOT NULL COMMENT '模版类型',
  2081 + `template_params` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '模版参数',
  2082 + `read_status` bit(1) NOT NULL COMMENT '是否已读',
  2083 + `read_time` datetime NULL DEFAULT NULL COMMENT '阅读时间',
  2084 + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
  2085 + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  2086 + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
  2087 + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  2088 + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  2089 + `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
  2090 + PRIMARY KEY (`id`) USING BTREE
  2091 +) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '站内信消息表';
  2092 +
  2093 +-- ----------------------------
  2094 +-- Records of system_notify_message
  2095 +-- ----------------------------
  2096 +BEGIN;
  2097 +INSERT INTO `system_notify_message` (`id`, `user_id`, `user_type`, `template_id`, `template_code`, `template_nickname`, `template_content`, `template_type`, `template_params`, `read_status`, `read_time`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (2, 1, 2, 1, 'test', '123', '我是 1,我开始 2 了', 1, '{\"name\":\"1\",\"what\":\"2\"}', b'0', '2023-01-28 21:06:10', '1', '2023-01-28 11:44:08', '1', '2023-01-29 02:51:50', b'0', 1);
  2098 +INSERT INTO `system_notify_message` (`id`, `user_id`, `user_type`, `template_id`, `template_code`, `template_nickname`, `template_content`, `template_type`, `template_params`, `read_status`, `read_time`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (3, 1, 2, 1, 'test', '123', '我是 1,我开始 2 了', 1, '{\"name\":\"1\",\"what\":\"2\"}', b'0', '2023-01-29 10:34:13', '1', '2023-01-28 11:45:04', '1', '2023-01-29 02:51:52', b'0', 1);
  2099 +INSERT INTO `system_notify_message` (`id`, `user_id`, `user_type`, `template_id`, `template_code`, `template_nickname`, `template_content`, `template_type`, `template_params`, `read_status`, `read_time`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (4, 103, 2, 2, 'register', '系统消息', '你好,欢迎 哈哈 加入大家庭!', 2, '{\"name\":\"哈哈\"}', b'0', NULL, '1', '2023-01-28 21:02:20', '1', '2023-01-28 21:02:20', b'0', 1);
  2100 +INSERT INTO `system_notify_message` (`id`, `user_id`, `user_type`, `template_id`, `template_code`, `template_nickname`, `template_content`, `template_type`, `template_params`, `read_status`, `read_time`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (5, 1, 2, 1, 'test', '123', '我是 芋艿,我开始 写代码 了', 1, '{\"name\":\"芋艿\",\"what\":\"写代码\"}', b'0', '2023-01-29 10:41:45', '1', '2023-01-28 22:21:42', '1', '2023-01-29 02:51:54', b'0', 1);
  2101 +INSERT INTO `system_notify_message` (`id`, `user_id`, `user_type`, `template_id`, `template_code`, `template_nickname`, `template_content`, `template_type`, `template_params`, `read_status`, `read_time`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (6, 1, 2, 1, 'test', '123', '我是 芋艿,我开始 写代码 了', 1, '{\"name\":\"芋艿\",\"what\":\"写代码\"}', b'1', '2023-01-29 10:52:06', '1', '2023-01-28 22:22:07', '1', '2023-01-29 10:52:06', b'0', 1);
  2102 +INSERT INTO `system_notify_message` (`id`, `user_id`, `user_type`, `template_id`, `template_code`, `template_nickname`, `template_content`, `template_type`, `template_params`, `read_status`, `read_time`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (7, 1, 2, 1, 'test', '123', '我是 2,我开始 3 了', 1, '{\"name\":\"2\",\"what\":\"3\"}', b'1', '2023-01-29 10:52:06', '1', '2023-01-28 23:45:21', '1', '2023-01-29 10:52:06', b'0', 1);
  2103 +INSERT INTO `system_notify_message` (`id`, `user_id`, `user_type`, `template_id`, `template_code`, `template_nickname`, `template_content`, `template_type`, `template_params`, `read_status`, `read_time`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (8, 1, 2, 2, 'register', '系统消息', '你好,欢迎 123 加入大家庭!', 2, '{\"name\":\"123\"}', b'1', '2023-01-29 10:52:06', '1', '2023-01-28 23:50:21', '1', '2023-01-29 10:52:06', b'0', 1);
  2104 +COMMIT;
  2105 +
  2106 +-- ----------------------------
  2107 +-- Table structure for system_notify_template
  2108 +-- ----------------------------
  2109 +DROP TABLE IF EXISTS `system_notify_template`;
  2110 +CREATE TABLE `system_notify_template` (
  2111 + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  2112 + `name` varchar(63) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '模板名称',
  2113 + `code` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '模版编码',
  2114 + `nickname` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '发送人名称',
  2115 + `content` varchar(1024) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '模版内容',
  2116 + `type` tinyint NOT NULL COMMENT '类型',
  2117 + `params` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '参数数组',
  2118 + `status` tinyint NOT NULL COMMENT '状态',
  2119 + `remark` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT NULL COMMENT '备注',
  2120 + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
  2121 + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  2122 + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
  2123 + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  2124 + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
  2125 + PRIMARY KEY (`id`) USING BTREE
  2126 +) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '站内信模板表';
  2127 +
  2128 +-- ----------------------------
  2129 +-- Records of system_notify_template
  2130 +-- ----------------------------
  2131 +BEGIN;
  2132 +COMMIT;
  2133 +
  2134 +-- ----------------------------
2057 -- Table structure for system_oauth2_access_token 2135 -- Table structure for system_oauth2_access_token
2058 -- ---------------------------- 2136 -- ----------------------------
2059 DROP TABLE IF EXISTS `system_oauth2_access_token`; 2137 DROP TABLE IF EXISTS `system_oauth2_access_token`;
@@ -2073,7 +2151,7 @@ CREATE TABLE `system_oauth2_access_token` ( @@ -2073,7 +2151,7 @@ CREATE TABLE `system_oauth2_access_token` (
2073 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', 2151 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
2074 `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', 2152 `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
2075 PRIMARY KEY (`id`) USING BTREE 2153 PRIMARY KEY (`id`) USING BTREE
2076 -) ENGINE = InnoDB AUTO_INCREMENT = 1214 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'OAuth2 访问令牌'; 2154 +) ENGINE = InnoDB AUTO_INCREMENT = 1249 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'OAuth2 访问令牌';
2077 2155
2078 -- ---------------------------- 2156 -- ----------------------------
2079 -- Records of system_oauth2_access_token 2157 -- Records of system_oauth2_access_token
@@ -2195,7 +2273,7 @@ CREATE TABLE `system_oauth2_refresh_token` ( @@ -2195,7 +2273,7 @@ CREATE TABLE `system_oauth2_refresh_token` (
2195 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', 2273 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
2196 `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', 2274 `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
2197 PRIMARY KEY (`id`) USING BTREE 2275 PRIMARY KEY (`id`) USING BTREE
2198 -) ENGINE = InnoDB AUTO_INCREMENT = 588 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'OAuth2 刷新令牌'; 2276 +) ENGINE = InnoDB AUTO_INCREMENT = 593 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'OAuth2 刷新令牌';
2199 2277
2200 -- ---------------------------- 2278 -- ----------------------------
2201 -- Records of system_oauth2_refresh_token 2279 -- Records of system_oauth2_refresh_token
@@ -2235,7 +2313,7 @@ CREATE TABLE `system_operate_log` ( @@ -2235,7 +2313,7 @@ CREATE TABLE `system_operate_log` (
2235 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', 2313 `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
2236 `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', 2314 `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
2237 PRIMARY KEY (`id`) USING BTREE 2315 PRIMARY KEY (`id`) USING BTREE
2238 -) ENGINE = InnoDB AUTO_INCREMENT = 4177 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '操作日志记录'; 2316 +) ENGINE = InnoDB AUTO_INCREMENT = 4245 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '操作日志记录';
2239 2317
2240 -- ---------------------------- 2318 -- ----------------------------
2241 -- Records of system_operate_log 2319 -- Records of system_operate_log
@@ -3353,7 +3431,7 @@ CREATE TABLE `system_users` ( @@ -3353,7 +3431,7 @@ CREATE TABLE `system_users` (
3353 -- Records of system_users 3431 -- Records of system_users
3354 -- ---------------------------- 3432 -- ----------------------------
3355 BEGIN; 3433 BEGIN;
3356 -INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1, 'admin', '$2a$10$mRMIYLDtRHlf6.9ipiqH1.Z.bh/R9dO9d5iHiGYPigi6r5KOoR2Wm', '芋道源码', '管理员', 103, '[1]', 'aoteman@126.com', '15612345678', 1, 'http://test.yudao.iocoder.cn/e1fdd7271685ec143a0900681606406621717a666ad0b2798b096df41422b32f.png', 0, '0:0:0:0:0:0:0:1', '2023-01-27 14:31:00', 'admin', '2021-01-05 17:03:47', NULL, '2023-01-27 14:31:00', b'0', 1); 3434 +INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1, 'admin', '$2a$10$mRMIYLDtRHlf6.9ipiqH1.Z.bh/R9dO9d5iHiGYPigi6r5KOoR2Wm', '芋道源码', '管理员', 103, '[1]', 'aoteman@126.com', '15612345678', 1, 'http://test.yudao.iocoder.cn/e1fdd7271685ec143a0900681606406621717a666ad0b2798b096df41422b32f.png', 0, '127.0.0.1', '2023-01-29 10:05:18', 'admin', '2021-01-05 17:03:47', NULL, '2023-01-29 10:05:18', b'0', 1);
3357 INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (100, 'yudao', '$2a$10$11U48RhyJ5pSBYWSn12AD./ld671.ycSzJHbyrtpeoMeYiw31eo8a', '芋道', '不要吓我', 104, '[1]', 'yudao@iocoder.cn', '15601691300', 1, '', 1, '127.0.0.1', '2022-07-09 23:03:33', '', '2021-01-07 09:07:17', NULL, '2022-07-09 23:03:33', b'0', 1); 3435 INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (100, 'yudao', '$2a$10$11U48RhyJ5pSBYWSn12AD./ld671.ycSzJHbyrtpeoMeYiw31eo8a', '芋道', '不要吓我', 104, '[1]', 'yudao@iocoder.cn', '15601691300', 1, '', 1, '127.0.0.1', '2022-07-09 23:03:33', '', '2021-01-07 09:07:17', NULL, '2022-07-09 23:03:33', b'0', 1);
3358 INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (103, 'yuanma', '$2a$10$YMpimV4T6BtDhIaA8jSW.u8UTGBeGhc/qwXP4oxoMr4mOw9.qttt6', '源码', NULL, 106, NULL, 'yuanma@iocoder.cn', '15601701300', 0, '', 0, '127.0.0.1', '2022-07-08 01:26:27', '', '2021-01-13 23:50:35', NULL, '2022-07-08 01:26:27', b'0', 1); 3436 INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (103, 'yuanma', '$2a$10$YMpimV4T6BtDhIaA8jSW.u8UTGBeGhc/qwXP4oxoMr4mOw9.qttt6', '源码', NULL, 106, NULL, 'yuanma@iocoder.cn', '15601701300', 0, '', 0, '127.0.0.1', '2022-07-08 01:26:27', '', '2021-01-13 23:50:35', NULL, '2022-07-08 01:26:27', b'0', 1);
3359 INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (104, 'test', '$2a$10$GP8zvqHB//TekuzYZSBYAuBQJiNq1.fxQVDYJ.uBCOnWCtDVKE4H6', '测试号', NULL, 107, '[1,2]', '111@qq.com', '15601691200', 1, '', 0, '127.0.0.1', '2022-05-28 15:43:17', '', '2021-01-21 02:13:53', NULL, '2022-07-09 09:00:33', b'0', 1); 3437 INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (104, 'test', '$2a$10$GP8zvqHB//TekuzYZSBYAuBQJiNq1.fxQVDYJ.uBCOnWCtDVKE4H6', '测试号', NULL, 107, '[1,2]', '111@qq.com', '15601691200', 1, '', 0, '127.0.0.1', '2022-05-28 15:43:17', '', '2021-01-21 02:13:53', NULL, '2022-07-09 09:00:33', b'0', 1);
yudao-dependencies/pom.xml
@@ -14,7 +14,7 @@ @@ -14,7 +14,7 @@
14 <url>https://github.com/YunaiV/ruoyi-vue-pro</url> 14 <url>https://github.com/YunaiV/ruoyi-vue-pro</url>
15 15
16 <properties> 16 <properties>
17 - <revision>1.6.6-snapshot</revision> 17 + <revision>1.7.0-snapshot</revision>
18 <!-- 统一依赖管理 --> 18 <!-- 统一依赖管理 -->
19 <spring.boot.version>2.7.7</spring.boot.version> 19 <spring.boot.version>2.7.7</spring.boot.version>
20 <!-- Web 相关 --> 20 <!-- Web 相关 -->
yudao-framework/yudao-spring-boot-starter-banner/src/main/java/cn/iocoder/yudao/framework/banner/core/BannerApplicationRunner.java
@@ -40,6 +40,10 @@ public class BannerApplicationRunner implements ApplicationRunner { @@ -40,6 +40,10 @@ public class BannerApplicationRunner implements ApplicationRunner {
40 if (isNotPresent("cn.iocoder.yudao.framework.flowable.config.YudaoFlowableConfiguration")) { 40 if (isNotPresent("cn.iocoder.yudao.framework.flowable.config.YudaoFlowableConfiguration")) {
41 System.out.println("[工作流模块 yudao-module-bpm - 已禁用][参考 https://doc.iocoder.cn/bpm/ 开启]"); 41 System.out.println("[工作流模块 yudao-module-bpm - 已禁用][参考 https://doc.iocoder.cn/bpm/ 开启]");
42 } 42 }
  43 + // 微信公众号
  44 + if (isNotPresent("cn.iocoder.yudao.module.mp.framework.mp.config.MpConfiguration")) {
  45 + System.out.println("[微信公众号 yudao-module-mp - 已禁用][参考 https://doc.iocoder.cn/mp/build/ 开启]");
  46 + }
43 }); 47 });
44 } 48 }
45 49
yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/LambdaQueryWrapperX.java
1 package cn.iocoder.yudao.framework.mybatis.core.query; 1 package cn.iocoder.yudao.framework.mybatis.core.query;
2 2
  3 +import cn.hutool.core.lang.Assert;
3 import cn.hutool.core.util.ArrayUtil; 4 import cn.hutool.core.util.ArrayUtil;
4 import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils; 5 import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils;
  6 +import cn.iocoder.yudao.framework.mybatis.core.enums.SqlConstants;
5 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 7 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
6 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; 8 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
7 import com.baomidou.mybatisplus.core.toolkit.support.SFunction; 9 import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/QueryWrapperX.java
@@ -146,19 +146,19 @@ public class QueryWrapperX&lt;T&gt; extends QueryWrapper&lt;T&gt; { @@ -146,19 +146,19 @@ public class QueryWrapperX&lt;T&gt; extends QueryWrapper&lt;T&gt; {
146 * 146 *
147 * @return this 147 * @return this
148 */ 148 */
149 - public QueryWrapperX<T> limit1() { 149 + public QueryWrapperX<T> limitN(int n) {
150 Assert.notNull(SqlConstants.DB_TYPE, "获取不到数据库的类型"); 150 Assert.notNull(SqlConstants.DB_TYPE, "获取不到数据库的类型");
151 switch (SqlConstants.DB_TYPE) { 151 switch (SqlConstants.DB_TYPE) {
152 case ORACLE: 152 case ORACLE:
153 case ORACLE_12C: 153 case ORACLE_12C:
154 - super.eq("ROWNUM", 1); 154 + super.eq("ROWNUM", n);
155 break; 155 break;
156 case SQL_SERVER: 156 case SQL_SERVER:
157 case SQL_SERVER2005: 157 case SQL_SERVER2005:
158 - super.select("TOP 1 *"); // 由于 SQL Server 是通过 SELECT TOP 1 实现限制一条,所以只好使用 * 查询剩余字段 158 + super.select("TOP " + n + " *"); // 由于 SQL Server 是通过 SELECT TOP 1 实现限制一条,所以只好使用 * 查询剩余字段
159 break; 159 break;
160 default: 160 default:
161 - super.last("LIMIT 1"); 161 + super.last("LIMIT " + n);
162 } 162 }
163 return this; 163 return this;
164 } 164 }
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/notify/NotifyMessageSendApi.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.api.notify;
  2 +
  3 +import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
  4 +
  5 +import javax.validation.Valid;
  6 +
  7 +/**
  8 + * 站内信发送 API 接口
  9 + *
  10 + * @author xrcoder
  11 + */
  12 +public interface NotifyMessageSendApi {
  13 +
  14 + /**
  15 + * 发送单条站内信给 Admin 用户
  16 + *
  17 + * @param reqDTO 发送请求
  18 + * @return 发送消息 ID
  19 + */
  20 + Long sendSingleMessageToAdmin(@Valid NotifySendSingleToUserReqDTO reqDTO);
  21 +
  22 + /**
  23 + * 发送单条站内信给 Member 用户
  24 + *
  25 + * @param reqDTO 发送请求
  26 + * @return 发送消息 ID
  27 + */
  28 + Long sendSingleMessageToMember(@Valid NotifySendSingleToUserReqDTO reqDTO);
  29 +
  30 +}
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/notify/dto/NotifySendSingleToUserReqDTO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.api.notify.dto;
  2 +
  3 +import lombok.Data;
  4 +
  5 +import javax.validation.constraints.NotEmpty;
  6 +import javax.validation.constraints.NotNull;
  7 +import java.util.Map;
  8 +
  9 +/**
  10 + * 站内信发送给 Admin 或者 Member 用户
  11 + *
  12 + * @author xrcoder
  13 + */
  14 +@Data
  15 +public class NotifySendSingleToUserReqDTO {
  16 +
  17 + /**
  18 + * 用户编号
  19 + */
  20 + @NotNull(message = "用户编号不能为空")
  21 + private Long userId;
  22 +
  23 + /**
  24 + * 站内信模板编号
  25 + */
  26 + @NotEmpty(message = "站内信模板编号不能为空")
  27 + private String templateCode;
  28 +
  29 + /**
  30 + * 站内信模板参数
  31 + */
  32 + private Map<String, Object> templateParams;
  33 +}
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
@@ -153,4 +153,13 @@ public interface ErrorCodeConstants { @@ -153,4 +153,13 @@ public interface ErrorCodeConstants {
153 ErrorCode MAIL_SEND_TEMPLATE_PARAM_MISS = new ErrorCode(1002025000, "模板参数({})缺失"); 153 ErrorCode MAIL_SEND_TEMPLATE_PARAM_MISS = new ErrorCode(1002025000, "模板参数({})缺失");
154 ErrorCode MAIL_SEND_MAIL_NOT_EXISTS = new ErrorCode(1002025000, "邮箱不存在"); 154 ErrorCode MAIL_SEND_MAIL_NOT_EXISTS = new ErrorCode(1002025000, "邮箱不存在");
155 155
  156 + // ========== 站内信模版 1002026000 ==========
  157 + ErrorCode NOTIFY_TEMPLATE_NOT_EXISTS = new ErrorCode(1002026000, "站内信模版不存在");
  158 + ErrorCode NOTIFY_TEMPLATE_CODE_DUPLICATE = new ErrorCode(1002026001, "已经存在编码为【{}】的站内信模板");
  159 +
  160 + // ========== 站内信模版 1002027000 ==========
  161 +
  162 + // ========== 站内信发送 1002028000 ==========
  163 + ErrorCode NOTIFY_SEND_TEMPLATE_PARAM_MISS = new ErrorCode(1002025000, "模板参数({})缺失");
  164 +
156 } 165 }
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/notify/NotifyMessageSendApiImpl.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.api.notify;
  2 +
  3 +import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
  4 +import cn.iocoder.yudao.module.system.service.notify.NotifyMessageService;
  5 +import cn.iocoder.yudao.module.system.service.notify.NotifySendService;
  6 +import org.springframework.stereotype.Service;
  7 +
  8 +import javax.annotation.Resource;
  9 +
  10 +/**
  11 + * 站内信发送 API 实现类
  12 + *
  13 + * @author xrcoder
  14 + */
  15 +@Service
  16 +public class NotifyMessageSendApiImpl implements NotifyMessageSendApi {
  17 +
  18 + @Resource
  19 + private NotifySendService notifySendService;
  20 +
  21 + @Override
  22 + public Long sendSingleMessageToAdmin(NotifySendSingleToUserReqDTO reqDTO) {
  23 + return notifySendService.sendSingleNotifyToAdmin(reqDTO.getUserId(),
  24 + reqDTO.getTemplateCode(), reqDTO.getTemplateParams());
  25 + }
  26 +
  27 + @Override
  28 + public Long sendSingleMessageToMember(NotifySendSingleToUserReqDTO reqDTO) {
  29 + return notifySendService.sendSingleNotifyToMember(reqDTO.getUserId(),
  30 + reqDTO.getTemplateCode(), reqDTO.getTemplateParams());
  31 + }
  32 +
  33 +}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyMessageController.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.controller.admin.notify;
  2 +
  3 +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
  4 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  5 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  6 +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageMyPageReqVO;
  7 +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
  8 +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageRespVO;
  9 +import cn.iocoder.yudao.module.system.convert.notify.NotifyMessageConvert;
  10 +import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
  11 +import cn.iocoder.yudao.module.system.service.notify.NotifyMessageService;
  12 +import io.swagger.annotations.Api;
  13 +import io.swagger.annotations.ApiImplicitParam;
  14 +import io.swagger.annotations.ApiOperation;
  15 +import org.springframework.security.access.prepost.PreAuthorize;
  16 +import org.springframework.validation.annotation.Validated;
  17 +import org.springframework.web.bind.annotation.*;
  18 +
  19 +import javax.annotation.Resource;
  20 +import javax.validation.Valid;
  21 +import java.util.List;
  22 +
  23 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  24 +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
  25 +
  26 +@Api(tags = "管理后台 - 我的站内信")
  27 +@RestController
  28 +@RequestMapping("/system/notify-message")
  29 +@Validated
  30 +public class NotifyMessageController {
  31 +
  32 + @Resource
  33 + private NotifyMessageService notifyMessageService;
  34 +
  35 + // ========== 管理所有的站内信 ==========
  36 +
  37 + @GetMapping("/get")
  38 + @ApiOperation("获得站内信")
  39 + @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
  40 + @PreAuthorize("@ss.hasPermission('system:notify-message:query')")
  41 + public CommonResult<NotifyMessageRespVO> getNotifyMessage(@RequestParam("id") Long id) {
  42 + NotifyMessageDO notifyMessage = notifyMessageService.getNotifyMessage(id);
  43 + return success(NotifyMessageConvert.INSTANCE.convert(notifyMessage));
  44 + }
  45 +
  46 + @GetMapping("/page")
  47 + @ApiOperation("获得站内信分页")
  48 + @PreAuthorize("@ss.hasPermission('system:notify-message:query')")
  49 + public CommonResult<PageResult<NotifyMessageRespVO>> getNotifyMessagePage(@Valid NotifyMessagePageReqVO pageVO) {
  50 + PageResult<NotifyMessageDO> pageResult = notifyMessageService.getNotifyMessagePage(pageVO);
  51 + return success(NotifyMessageConvert.INSTANCE.convertPage(pageResult));
  52 + }
  53 +
  54 + // ========== 查看自己的站内信 ==========
  55 +
  56 + @GetMapping("/my-page")
  57 + @ApiOperation("获得我的站内信分页")
  58 + public CommonResult<PageResult<NotifyMessageRespVO>> getMyMyNotifyMessagePage(@Valid NotifyMessageMyPageReqVO pageVO) {
  59 + PageResult<NotifyMessageDO> pageResult = notifyMessageService.getMyMyNotifyMessagePage(pageVO,
  60 + getLoginUserId(), UserTypeEnum.ADMIN.getValue());
  61 + return success(NotifyMessageConvert.INSTANCE.convertPage(pageResult));
  62 + }
  63 +
  64 + @PutMapping("/update-read")
  65 + @ApiOperation("标记站内信为已读")
  66 + @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
  67 + public CommonResult<Boolean> updateNotifyMessageRead(@RequestParam("ids") List<Long> ids) {
  68 + notifyMessageService.updateNotifyMessageRead(ids, getLoginUserId(), UserTypeEnum.ADMIN.getValue());
  69 + return success(Boolean.TRUE);
  70 + }
  71 +
  72 + @PutMapping("/update-all-read")
  73 + @ApiOperation("标记所有站内信为已读")
  74 + public CommonResult<Boolean> updateAllNotifyMessageRead() {
  75 + notifyMessageService.updateAllNotifyMessageRead(getLoginUserId(), UserTypeEnum.ADMIN.getValue());
  76 + return success(Boolean.TRUE);
  77 + }
  78 +
  79 + @GetMapping("/get-unread-list")
  80 + @ApiOperation("获取当前用户的最新站内信列表,默认 10 条")
  81 + @ApiImplicitParam(name = "size", value = "10", defaultValue = "10", dataTypeClass = Integer.class)
  82 + public CommonResult<List<NotifyMessageRespVO>> getUnreadNotifyMessageList(
  83 + @RequestParam(name = "size", defaultValue = "10") Integer size) {
  84 + List<NotifyMessageDO> list = notifyMessageService.getUnreadNotifyMessageList(
  85 + getLoginUserId(), UserTypeEnum.ADMIN.getValue(), size);
  86 + return success(NotifyMessageConvert.INSTANCE.convertList(list));
  87 + }
  88 +
  89 + @GetMapping("/get-unread-count")
  90 + @ApiOperation("获得当前用户的未读站内信数量")
  91 + public CommonResult<Long> getUnreadNotifyMessageCount() {
  92 + return success(notifyMessageService.getUnreadNotifyMessageCount(getLoginUserId(), UserTypeEnum.ADMIN.getValue()));
  93 + }
  94 +
  95 +}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyTemplateController.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.controller.admin.notify;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  4 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  5 +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.*;
  6 +import cn.iocoder.yudao.module.system.convert.notify.NotifyTemplateConvert;
  7 +import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
  8 +import cn.iocoder.yudao.module.system.service.notify.NotifySendService;
  9 +import cn.iocoder.yudao.module.system.service.notify.NotifyTemplateService;
  10 +import io.swagger.annotations.Api;
  11 +import io.swagger.annotations.ApiImplicitParam;
  12 +import io.swagger.annotations.ApiOperation;
  13 +import org.springframework.security.access.prepost.PreAuthorize;
  14 +import org.springframework.validation.annotation.Validated;
  15 +import org.springframework.web.bind.annotation.*;
  16 +
  17 +import javax.annotation.Resource;
  18 +import javax.validation.Valid;
  19 +
  20 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  21 +
  22 +@Api(tags = "管理后台 - 站内信模版")
  23 +@RestController
  24 +@RequestMapping("/system/notify-template")
  25 +@Validated
  26 +public class NotifyTemplateController {
  27 +
  28 + @Resource
  29 + private NotifyTemplateService notifyTemplateService;
  30 +
  31 + @Resource
  32 + private NotifySendService notifySendService;
  33 +
  34 + @PostMapping("/create")
  35 + @ApiOperation("创建站内信模版")
  36 + @PreAuthorize("@ss.hasPermission('system:notify-template:create')")
  37 + public CommonResult<Long> createNotifyTemplate(@Valid @RequestBody NotifyTemplateCreateReqVO createReqVO) {
  38 + return success(notifyTemplateService.createNotifyTemplate(createReqVO));
  39 + }
  40 +
  41 + @PutMapping("/update")
  42 + @ApiOperation("更新站内信模版")
  43 + @PreAuthorize("@ss.hasPermission('system:notify-template:update')")
  44 + public CommonResult<Boolean> updateNotifyTemplate(@Valid @RequestBody NotifyTemplateUpdateReqVO updateReqVO) {
  45 + notifyTemplateService.updateNotifyTemplate(updateReqVO);
  46 + return success(true);
  47 + }
  48 +
  49 + @DeleteMapping("/delete")
  50 + @ApiOperation("删除站内信模版")
  51 + @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
  52 + @PreAuthorize("@ss.hasPermission('system:notify-template:delete')")
  53 + public CommonResult<Boolean> deleteNotifyTemplate(@RequestParam("id") Long id) {
  54 + notifyTemplateService.deleteNotifyTemplate(id);
  55 + return success(true);
  56 + }
  57 +
  58 + @GetMapping("/get")
  59 + @ApiOperation("获得站内信模版")
  60 + @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
  61 + @PreAuthorize("@ss.hasPermission('system:notify-template:query')")
  62 + public CommonResult<NotifyTemplateRespVO> getNotifyTemplate(@RequestParam("id") Long id) {
  63 + NotifyTemplateDO notifyTemplate = notifyTemplateService.getNotifyTemplate(id);
  64 + return success(NotifyTemplateConvert.INSTANCE.convert(notifyTemplate));
  65 + }
  66 +
  67 + @GetMapping("/page")
  68 + @ApiOperation("获得站内信模版分页")
  69 + @PreAuthorize("@ss.hasPermission('system:notify-template:query')")
  70 + public CommonResult<PageResult<NotifyTemplateRespVO>> getNotifyTemplatePage(@Valid NotifyTemplatePageReqVO pageVO) {
  71 + PageResult<NotifyTemplateDO> pageResult = notifyTemplateService.getNotifyTemplatePage(pageVO);
  72 + return success(NotifyTemplateConvert.INSTANCE.convertPage(pageResult));
  73 + }
  74 +
  75 + @PostMapping("/send-notify")
  76 + @ApiOperation("发送站内信")
  77 + @PreAuthorize("@ss.hasPermission('system:notify-template:send-notify')")
  78 + public CommonResult<Long> sendNotify(@Valid @RequestBody NotifyTemplateSendReqVO sendReqVO) {
  79 + return success(notifySendService.sendSingleNotifyToAdmin(sendReqVO.getUserId(),
  80 + sendReqVO.getTemplateCode(), sendReqVO.getTemplateParams()));
  81 + }
  82 +
  83 +}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageBaseVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.controller.admin.notify.vo.message;
  2 +
  3 +import io.swagger.annotations.ApiModelProperty;
  4 +import lombok.Data;
  5 +import org.springframework.format.annotation.DateTimeFormat;
  6 +
  7 +import javax.validation.constraints.NotNull;
  8 +import java.time.LocalDateTime;
  9 +import java.util.Date;
  10 +import java.util.Map;
  11 +
  12 +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
  13 +
  14 +/**
  15 + * 站内信消息 Base VO,提供给添加、修改、详细的子 VO 使用
  16 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
  17 + */
  18 +@Data
  19 +public class NotifyMessageBaseVO {
  20 +
  21 + @ApiModelProperty(value = "用户编号", required = true, example = "25025")
  22 + @NotNull(message = "用户编号不能为空")
  23 + private Long userId;
  24 +
  25 + @ApiModelProperty(value = "用户类型", required = true, example = "1", notes = "参见 UserTypeEnum 枚举")
  26 + @NotNull(message = "用户类型不能为空")
  27 + private Byte userType;
  28 +
  29 + @ApiModelProperty(value = "模版编号", required = true, example = "13013")
  30 + @NotNull(message = "模版编号不能为空")
  31 + private Long templateId;
  32 +
  33 + @ApiModelProperty(value = "模板编码", required = true, example = "test_01")
  34 + @NotNull(message = "模板编码不能为空")
  35 + private String templateCode;
  36 +
  37 + @ApiModelProperty(value = "模版发送人名称", required = true, example = "芋艿")
  38 + @NotNull(message = "模版发送人名称不能为空")
  39 + private String templateNickname;
  40 +
  41 + @ApiModelProperty(value = "模版内容", required = true, example = "测试内容")
  42 + @NotNull(message = "模版内容不能为空")
  43 + private String templateContent;
  44 +
  45 + @ApiModelProperty(value = "模版类型", required = true, example = "2")
  46 + @NotNull(message = "模版类型不能为空")
  47 + private Integer templateType;
  48 +
  49 + @ApiModelProperty(value = "模版参数", required = true)
  50 + @NotNull(message = "模版参数不能为空")
  51 + private Map<String, Object> templateParams;
  52 +
  53 + @ApiModelProperty(value = "是否已读", required = true, example = "true")
  54 + @NotNull(message = "是否已读不能为空")
  55 + private Boolean readStatus;
  56 +
  57 + @ApiModelProperty(value = "阅读时间")
  58 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  59 + private LocalDateTime readTime;
  60 +
  61 +}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageMyPageReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.controller.admin.notify.vo.message;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  4 +import io.swagger.annotations.ApiModel;
  5 +import io.swagger.annotations.ApiModelProperty;
  6 +import lombok.Data;
  7 +import lombok.EqualsAndHashCode;
  8 +import lombok.ToString;
  9 +import org.springframework.format.annotation.DateTimeFormat;
  10 +
  11 +import java.time.LocalDateTime;
  12 +
  13 +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
  14 +
  15 +@ApiModel("管理后台 - 站内信分页 Request VO")
  16 +@Data
  17 +@EqualsAndHashCode(callSuper = true)
  18 +@ToString(callSuper = true)
  19 +public class NotifyMessageMyPageReqVO extends PageParam {
  20 +
  21 + @ApiModelProperty(value = "是否已读", example = "true")
  22 + private Boolean readStatus;
  23 +
  24 + @ApiModelProperty(value = "创建时间")
  25 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  26 + private LocalDateTime[] createTime;
  27 +
  28 +}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessagePageReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.controller.admin.notify.vo.message;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  4 +import io.swagger.annotations.ApiModel;
  5 +import io.swagger.annotations.ApiModelProperty;
  6 +import lombok.Data;
  7 +import lombok.EqualsAndHashCode;
  8 +import lombok.ToString;
  9 +import org.springframework.format.annotation.DateTimeFormat;
  10 +
  11 +import java.time.LocalDateTime;
  12 +import java.util.Date;
  13 +
  14 +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
  15 +
  16 +@ApiModel("管理后台 - 站内信分页 Request VO")
  17 +@Data
  18 +@EqualsAndHashCode(callSuper = true)
  19 +@ToString(callSuper = true)
  20 +public class NotifyMessagePageReqVO extends PageParam {
  21 +
  22 + @ApiModelProperty(value = "用户编号", example = "25025")
  23 + private Long userId;
  24 +
  25 + @ApiModelProperty(value = "用户类型", example = "1")
  26 + private Integer userType;
  27 +
  28 + @ApiModelProperty(value = "模板编码", example = "test_01")
  29 + private String templateCode;
  30 +
  31 + @ApiModelProperty(value = "模版类型", example = "2")
  32 + private Integer templateType;
  33 +
  34 + @ApiModelProperty(value = "创建时间")
  35 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  36 + private LocalDateTime[] createTime;
  37 +
  38 +}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageRespVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.controller.admin.notify.vo.message;
  2 +
  3 +import lombok.*;
  4 +import java.util.*;
  5 +import io.swagger.annotations.*;
  6 +
  7 +@ApiModel("管理后台 - 站内信 Response VO")
  8 +@Data
  9 +@EqualsAndHashCode(callSuper = true)
  10 +@ToString(callSuper = true)
  11 +public class NotifyMessageRespVO extends NotifyMessageBaseVO {
  12 +
  13 + @ApiModelProperty(value = "ID", required = true, example = "1024")
  14 + private Long id;
  15 +
  16 + @ApiModelProperty(value = "创建时间", required = true)
  17 + private Date createTime;
  18 +
  19 +}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateBaseVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.controller.admin.notify.vo.template;
  2 +
  3 +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
  4 +import cn.iocoder.yudao.framework.common.validation.InEnum;
  5 +import io.swagger.annotations.ApiModelProperty;
  6 +import lombok.Data;
  7 +
  8 +import javax.validation.constraints.NotEmpty;
  9 +import javax.validation.constraints.NotNull;
  10 +
  11 +/**
  12 +* 站内信模版 Base VO,提供给添加、修改、详细的子 VO 使用
  13 +* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
  14 +*/
  15 +@Data
  16 +public class NotifyTemplateBaseVO {
  17 +
  18 + @ApiModelProperty(value = "模版名称", required = true, example = "测试模版")
  19 + @NotEmpty(message = "模版名称不能为空")
  20 + private String name;
  21 +
  22 + @ApiModelProperty(value = "模版编码", required = true, example = "SEND_TEST")
  23 + @NotNull(message = "模版编码不能为空")
  24 + private String code;
  25 +
  26 + @ApiModelProperty(value = "模版类型", required = true, example = "1", notes = "对应 system_notify_template_type 字典")
  27 + @NotNull(message = "模版类型不能为空")
  28 + private Integer type;
  29 +
  30 + @ApiModelProperty(value = "发送人名称", required = true, example = "土豆")
  31 + @NotEmpty(message = "发送人名称不能为空")
  32 + private String nickname;
  33 +
  34 + @ApiModelProperty(value = "模版内容", required = true, example = "我是模版内容")
  35 + @NotEmpty(message = "模版内容不能为空")
  36 + private String content;
  37 +
  38 + @ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 CommonStatusEnum 枚举")
  39 + @NotNull(message = "状态不能为空")
  40 + @InEnum(value = CommonStatusEnum.class, message = "状态必须是 {value}")
  41 + private Integer status;
  42 +
  43 + @ApiModelProperty(value = "备注", example = "我是备注")
  44 + private String remark;
  45 +
  46 +}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateCreateReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.controller.admin.notify.vo.template;
  2 +
  3 +import lombok.*;
  4 +import io.swagger.annotations.*;
  5 +
  6 +@ApiModel("管理后台 - 站内信模版创建 Request VO")
  7 +@Data
  8 +@EqualsAndHashCode(callSuper = true)
  9 +@ToString(callSuper = true)
  10 +public class NotifyTemplateCreateReqVO extends NotifyTemplateBaseVO {
  11 +}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplatePageReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.controller.admin.notify.vo.template;
  2 +
  3 +import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
  4 +import lombok.*;
  5 +
  6 +import java.time.LocalDateTime;
  7 +import java.util.*;
  8 +import io.swagger.annotations.*;
  9 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  10 +import org.springframework.format.annotation.DateTimeFormat;
  11 +
  12 +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
  13 +
  14 +@ApiModel("管理后台 - 站内信模版分页 Request VO")
  15 +@Data
  16 +@EqualsAndHashCode(callSuper = true)
  17 +@ToString(callSuper = true)
  18 +public class NotifyTemplatePageReqVO extends PageParam {
  19 +
  20 + @ApiModelProperty(value = "模版编码", example = "test_01")
  21 + private String code;
  22 +
  23 + @ApiModelProperty(value = "模版名称", example = "我是名称")
  24 + private String name;
  25 +
  26 + @ApiModelProperty(value = "状态", example = "1", notes = "参见 CommonStatusEnum 枚举类")
  27 + private Integer status;
  28 +
  29 + @ApiModelProperty(value = "创建时间")
  30 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  31 + private LocalDateTime[] createTime;
  32 +
  33 +}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateRespVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.controller.admin.notify.vo.template;
  2 +
  3 +import lombok.*;
  4 +import java.util.*;
  5 +import io.swagger.annotations.*;
  6 +
  7 +@ApiModel("管理后台 - 站内信模版 Response VO")
  8 +@Data
  9 +@EqualsAndHashCode(callSuper = true)
  10 +@ToString(callSuper = true)
  11 +public class NotifyTemplateRespVO extends NotifyTemplateBaseVO {
  12 +
  13 + @ApiModelProperty(value = "ID", required = true, example = "1024")
  14 + private Long id;
  15 +
  16 + @ApiModelProperty(value = "参数数组", example = "name,code")
  17 + private List<String> params;
  18 +
  19 + @ApiModelProperty(value = "创建时间", required = true)
  20 + private Date createTime;
  21 +
  22 +}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateSendReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.controller.admin.notify.vo.template;
  2 +
  3 +import io.swagger.annotations.ApiModel;
  4 +import io.swagger.annotations.ApiModelProperty;
  5 +import lombok.Data;
  6 +
  7 +import javax.validation.constraints.NotEmpty;
  8 +import javax.validation.constraints.NotNull;
  9 +import java.util.Map;
  10 +
  11 +@ApiModel("管理后台 - 站内信模板的发送 Request VO")
  12 +@Data
  13 +public class NotifyTemplateSendReqVO {
  14 +
  15 + @ApiModelProperty(value = "用户id", required = true, example = "01")
  16 + @NotNull(message = "用户id不能为空")
  17 + private Long userId;
  18 +
  19 + @ApiModelProperty(value = "模板编码", required = true, example = "01")
  20 + @NotEmpty(message = "模板编码不能为空")
  21 + private String templateCode;
  22 +
  23 + @ApiModelProperty(value = "模板参数")
  24 + private Map<String, Object> templateParams;
  25 +}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateUpdateReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.controller.admin.notify.vo.template;
  2 +
  3 +import lombok.*;
  4 +import io.swagger.annotations.*;
  5 +import javax.validation.constraints.*;
  6 +
  7 +@ApiModel("管理后台 - 站内信模版更新 Request VO")
  8 +@Data
  9 +@EqualsAndHashCode(callSuper = true)
  10 +@ToString(callSuper = true)
  11 +public class NotifyTemplateUpdateReqVO extends NotifyTemplateBaseVO {
  12 +
  13 + @ApiModelProperty(value = "ID", required = true, example = "1024")
  14 + @NotNull(message = "ID 不能为空")
  15 + private Long id;
  16 +
  17 +}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyMessageConvert.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.convert.notify;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageRespVO;
  5 +import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
  6 +import org.mapstruct.Mapper;
  7 +import org.mapstruct.factory.Mappers;
  8 +
  9 +import java.util.List;
  10 +
  11 +/**
  12 + * 站内信 Convert
  13 + *
  14 + * @author xrcoder
  15 + */
  16 +@Mapper
  17 +public interface NotifyMessageConvert {
  18 +
  19 + NotifyMessageConvert INSTANCE = Mappers.getMapper(NotifyMessageConvert.class);
  20 +
  21 + NotifyMessageRespVO convert(NotifyMessageDO bean);
  22 +
  23 + List<NotifyMessageRespVO> convertList(List<NotifyMessageDO> list);
  24 +
  25 + PageResult<NotifyMessageRespVO> convertPage(PageResult<NotifyMessageDO> page);
  26 +
  27 +
  28 +}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyTemplateConvert.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.convert.notify;
  2 +
  3 +import java.util.*;
  4 +
  5 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  6 +
  7 +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateCreateReqVO;
  8 +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateRespVO;
  9 +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateUpdateReqVO;
  10 +import org.mapstruct.Mapper;
  11 +import org.mapstruct.factory.Mappers;
  12 +import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
  13 +
  14 +/**
  15 + * 站内信模版 Convert
  16 + *
  17 + * @author xrcoder
  18 + */
  19 +@Mapper
  20 +public interface NotifyTemplateConvert {
  21 +
  22 + NotifyTemplateConvert INSTANCE = Mappers.getMapper(NotifyTemplateConvert.class);
  23 +
  24 + NotifyTemplateDO convert(NotifyTemplateCreateReqVO bean);
  25 +
  26 + NotifyTemplateDO convert(NotifyTemplateUpdateReqVO bean);
  27 +
  28 + NotifyTemplateRespVO convert(NotifyTemplateDO bean);
  29 +
  30 + List<NotifyTemplateRespVO> convertList(List<NotifyTemplateDO> list);
  31 +
  32 + PageResult<NotifyTemplateRespVO> convertPage(PageResult<NotifyTemplateDO> page);
  33 +
  34 +}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyMessageDO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.dal.dataobject.notify;
  2 +
  3 +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
  4 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  5 +import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO;
  6 +import com.baomidou.mybatisplus.annotation.KeySequence;
  7 +import com.baomidou.mybatisplus.annotation.TableField;
  8 +import com.baomidou.mybatisplus.annotation.TableId;
  9 +import com.baomidou.mybatisplus.annotation.TableName;
  10 +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
  11 +import lombok.*;
  12 +
  13 +import java.time.LocalDateTime;
  14 +import java.util.Date;
  15 +import java.util.Map;
  16 +
  17 +/**
  18 + * 站内信 DO
  19 + *
  20 + * @author xrcoder
  21 + */
  22 +@TableName(value = "system_notify_message", autoResultMap = true)
  23 +@KeySequence("system_notify_message_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
  24 +@Data
  25 +@EqualsAndHashCode(callSuper = true)
  26 +@ToString(callSuper = true)
  27 +@Builder
  28 +@NoArgsConstructor
  29 +@AllArgsConstructor
  30 +public class NotifyMessageDO extends BaseDO {
  31 +
  32 + /**
  33 + * 站内信编号,自增
  34 + */
  35 + @TableId
  36 + private Long id;
  37 + /**
  38 + * 用户编号
  39 + *
  40 + * 关联 MemberUserDO 的 id 字段、或者 AdminUserDO 的 id 字段
  41 + */
  42 + private Long userId;
  43 + /**
  44 + * 用户类型
  45 + *
  46 + * 枚举 {@link UserTypeEnum}
  47 + */
  48 + private Integer userType;
  49 +
  50 + // ========= 模板相关字段 =========
  51 +
  52 + /**
  53 + * 模版编号
  54 + *
  55 + * 关联 {@link NotifyTemplateDO#getId()}
  56 + */
  57 + private Long templateId;
  58 + /**
  59 + * 模版编码
  60 + *
  61 + * 关联 {@link NotifyTemplateDO#getCode()}
  62 + */
  63 + private String templateCode;
  64 + /**
  65 + * 模版类型
  66 + *
  67 + * 冗余 {@link NotifyTemplateDO#getType()}
  68 + */
  69 + private Integer templateType;
  70 + /**
  71 + * 模版发送人名称
  72 + *
  73 + * 冗余 {@link NotifyTemplateDO#getNickname()}
  74 + */
  75 + private String templateNickname;
  76 + /**
  77 + * 模版内容
  78 + *
  79 + * 基于 {@link NotifyTemplateDO#getContent()} 格式化后的内容
  80 + */
  81 + private String templateContent;
  82 + /**
  83 + * 模版参数
  84 + *
  85 + * 基于 {@link NotifyTemplateDO#getParams()} 输入后的参数
  86 + */
  87 + @TableField(typeHandler = JacksonTypeHandler.class)
  88 + private Map<String, Object> templateParams;
  89 +
  90 + // ========= 读取相关字段 =========
  91 +
  92 + /**
  93 + * 是否已读
  94 + */
  95 + private Boolean readStatus;
  96 + /**
  97 + * 阅读时间
  98 + */
  99 + private LocalDateTime readTime;
  100 +
  101 +}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyTemplateDO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.dal.dataobject.notify;
  2 +
  3 +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
  4 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  5 +import com.baomidou.mybatisplus.annotation.KeySequence;
  6 +import com.baomidou.mybatisplus.annotation.TableField;
  7 +import com.baomidou.mybatisplus.annotation.TableId;
  8 +import com.baomidou.mybatisplus.annotation.TableName;
  9 +import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
  10 +import lombok.*;
  11 +
  12 +import java.util.List;
  13 +
  14 +/**
  15 + * 站内信模版 DO
  16 + *
  17 + * @author xrcoder
  18 + */
  19 +@TableName(value = "system_notify_template", autoResultMap = true)
  20 +@KeySequence("system_notify_template_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
  21 +@Data
  22 +@EqualsAndHashCode(callSuper = true)
  23 +@ToString(callSuper = true)
  24 +@Builder
  25 +@NoArgsConstructor
  26 +@AllArgsConstructor
  27 +public class NotifyTemplateDO extends BaseDO {
  28 +
  29 + /**
  30 + * ID
  31 + */
  32 + @TableId
  33 + private Long id;
  34 + /**
  35 + * 模版名称
  36 + */
  37 + private String name;
  38 + /**
  39 + * 模版编码
  40 + */
  41 + private String code;
  42 + /**
  43 + * 模版类型
  44 + *
  45 + * 对应 system_notify_template_type 字典
  46 + */
  47 + private Integer type;
  48 + /**
  49 + * 发送人名称
  50 + */
  51 + private String nickname;
  52 + /**
  53 + * 模版内容
  54 + */
  55 + private String content;
  56 + /**
  57 + * 参数数组
  58 + */
  59 + @TableField(typeHandler = JacksonTypeHandler.class)
  60 + private List<String> params;
  61 + /**
  62 + * 状态
  63 + *
  64 + * 枚举 {@link CommonStatusEnum}
  65 + */
  66 + private Integer status;
  67 + /**
  68 + * 备注
  69 + */
  70 + private String remark;
  71 +
  72 +}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.dal.mysql.notify;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
  5 +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
  6 +import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
  7 +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageMyPageReqVO;
  8 +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
  9 +import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
  10 +import org.apache.ibatis.annotations.Mapper;
  11 +
  12 +import java.time.LocalDateTime;
  13 +import java.util.Collection;
  14 +import java.util.List;
  15 +
  16 +@Mapper
  17 +public interface NotifyMessageMapper extends BaseMapperX<NotifyMessageDO> {
  18 +
  19 + default PageResult<NotifyMessageDO> selectPage(NotifyMessagePageReqVO reqVO) {
  20 + return selectPage(reqVO, new LambdaQueryWrapperX<NotifyMessageDO>()
  21 + .eqIfPresent(NotifyMessageDO::getUserId, reqVO.getUserId())
  22 + .eqIfPresent(NotifyMessageDO::getUserType, reqVO.getUserType())
  23 + .likeIfPresent(NotifyMessageDO::getTemplateCode, reqVO.getTemplateCode())
  24 + .eqIfPresent(NotifyMessageDO::getTemplateType, reqVO.getTemplateType())
  25 + .betweenIfPresent(NotifyMessageDO::getCreateTime, reqVO.getCreateTime())
  26 + .orderByDesc(NotifyMessageDO::getId));
  27 + }
  28 +
  29 + default PageResult<NotifyMessageDO> selectPage(NotifyMessageMyPageReqVO reqVO, Long userId, Integer userType) {
  30 + return selectPage(reqVO, new LambdaQueryWrapperX<NotifyMessageDO>()
  31 + .eqIfPresent(NotifyMessageDO::getReadStatus, reqVO.getReadStatus())
  32 + .betweenIfPresent(NotifyMessageDO::getCreateTime, reqVO.getCreateTime())
  33 + .eq(NotifyMessageDO::getUserId, userId)
  34 + .eq(NotifyMessageDO::getUserType, userType)
  35 + .orderByDesc(NotifyMessageDO::getId));
  36 + }
  37 +
  38 + default int updateListRead(Collection<Long> ids, Long userId, Integer userType) {
  39 + return update(new NotifyMessageDO().setReadStatus(true).setReadTime(LocalDateTime.now()),
  40 + new LambdaQueryWrapperX<NotifyMessageDO>()
  41 + .in(NotifyMessageDO::getId, ids)
  42 + .eq(NotifyMessageDO::getUserId, userId)
  43 + .eq(NotifyMessageDO::getUserType, userType)
  44 + .eq(NotifyMessageDO::getReadStatus, false));
  45 + }
  46 +
  47 + default int updateListRead(Long userId, Integer userType) {
  48 + return update(new NotifyMessageDO().setReadStatus(true).setReadTime(LocalDateTime.now()),
  49 + new LambdaQueryWrapperX<NotifyMessageDO>()
  50 + .eq(NotifyMessageDO::getUserId, userId)
  51 + .eq(NotifyMessageDO::getUserType, userType)
  52 + .eq(NotifyMessageDO::getReadStatus, false));
  53 + }
  54 +
  55 + default List<NotifyMessageDO> selectUnreadListByUserIdAndUserType(Long userId, Integer userType, Integer size) {
  56 + return selectList(new QueryWrapperX<NotifyMessageDO>() // 由于要使用 limitN 语句,所以只能用 QueryWrapperX
  57 + .eq("user_id", userId)
  58 + .eq("user_type", userType)
  59 + .eq("read_status", false)
  60 + .orderByDesc("id").limitN(size));
  61 + }
  62 +
  63 + default Long selectUnreadCountByUserIdAndUserType(Long userId, Integer userType) {
  64 + return selectCount(new LambdaQueryWrapperX<NotifyMessageDO>()
  65 + .eq(NotifyMessageDO::getReadStatus, false)
  66 + .eq(NotifyMessageDO::getUserId, userId)
  67 + .eq(NotifyMessageDO::getUserType, userType));
  68 + }
  69 +
  70 +}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyTemplateMapper.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.dal.mysql.notify;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
  5 +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
  6 +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplatePageReqVO;
  7 +import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
  8 +import org.apache.ibatis.annotations.Mapper;
  9 +
  10 +@Mapper
  11 +public interface NotifyTemplateMapper extends BaseMapperX<NotifyTemplateDO> {
  12 +
  13 + default NotifyTemplateDO selectByCode(String code) {
  14 + return selectOne(NotifyTemplateDO::getCode, code);
  15 + }
  16 +
  17 + default PageResult<NotifyTemplateDO> selectPage(NotifyTemplatePageReqVO reqVO) {
  18 + return selectPage(reqVO, new LambdaQueryWrapperX<NotifyTemplateDO>()
  19 + .likeIfPresent(NotifyTemplateDO::getCode, reqVO.getCode())
  20 + .likeIfPresent(NotifyTemplateDO::getName, reqVO.getName())
  21 + .eqIfPresent(NotifyTemplateDO::getStatus, reqVO.getStatus())
  22 + .betweenIfPresent(NotifyTemplateDO::getCreateTime, reqVO.getCreateTime())
  23 + .orderByDesc(NotifyTemplateDO::getId));
  24 + }
  25 +
  26 +}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/sms/SmsCodeMapper.java
@@ -22,7 +22,7 @@ public interface SmsCodeMapper extends BaseMapperX&lt;SmsCodeDO&gt; { @@ -22,7 +22,7 @@ public interface SmsCodeMapper extends BaseMapperX&lt;SmsCodeDO&gt; {
22 .eqIfPresent("scene", scene) 22 .eqIfPresent("scene", scene)
23 .eqIfPresent("code", code) 23 .eqIfPresent("code", code)
24 .orderByDesc("id") 24 .orderByDesc("id")
25 - .limit1()); 25 + .limitN(1));
26 } 26 }
27 27
28 } 28 }
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/consumer/notify/NotifyTemplateRefreshConsumer.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.mq.consumer.notify;
  2 +
  3 +import cn.iocoder.yudao.framework.mq.core.pubsub.AbstractChannelMessageListener;
  4 +import cn.iocoder.yudao.module.system.mq.message.notify.NotifyTemplateRefreshMessage;
  5 +import cn.iocoder.yudao.module.system.service.notify.NotifyTemplateService;
  6 +import lombok.extern.slf4j.Slf4j;
  7 +import org.springframework.stereotype.Component;
  8 +
  9 +import javax.annotation.Resource;
  10 +
  11 +/**
  12 + * 针对 {@link NotifyTemplateRefreshMessage} 的消费者
  13 + *
  14 + * @author xrcoder
  15 + */
  16 +@Component
  17 +@Slf4j
  18 +public class NotifyTemplateRefreshConsumer extends AbstractChannelMessageListener<NotifyTemplateRefreshMessage> {
  19 +
  20 + @Resource
  21 + private NotifyTemplateService notifyTemplateService;
  22 +
  23 + @Override
  24 + public void onMessage(NotifyTemplateRefreshMessage message) {
  25 + log.info("[onMessage][收到 NotifyTemplate 刷新消息]");
  26 + notifyTemplateService.initLocalCache();
  27 + }
  28 +
  29 +}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/message/notify/NotifyTemplateRefreshMessage.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.mq.message.notify;
  2 +
  3 +import cn.iocoder.yudao.framework.mq.core.pubsub.AbstractChannelMessage;
  4 +import lombok.Data;
  5 +import lombok.EqualsAndHashCode;
  6 +
  7 +/**
  8 + * 站内信模板的数据刷新 Message
  9 + *
  10 + * @author xrcoder
  11 + */
  12 +@Data
  13 +@EqualsAndHashCode(callSuper = true)
  14 +public class NotifyTemplateRefreshMessage extends AbstractChannelMessage {
  15 +
  16 + @Override
  17 + public String getChannel() {
  18 + return "system.notify-template.refresh";
  19 + }
  20 +
  21 +}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/producer/notify/NotifyProducer.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.mq.producer.notify;
  2 +
  3 +import cn.iocoder.yudao.framework.mq.core.RedisMQTemplate;
  4 +import cn.iocoder.yudao.module.system.mq.message.notify.NotifyTemplateRefreshMessage;
  5 +import lombok.extern.slf4j.Slf4j;
  6 +import org.springframework.stereotype.Component;
  7 +
  8 +import javax.annotation.Resource;
  9 +
  10 +/**
  11 + * Notify 站内信相关消息的 Producer
  12 + *
  13 + * @author xrcoder
  14 + * @since 2022-08-06
  15 + */
  16 +@Slf4j
  17 +@Component
  18 +public class NotifyProducer {
  19 +
  20 + @Resource
  21 + private RedisMQTemplate redisMQTemplate;
  22 +
  23 +
  24 + /**
  25 + * 发送 {@link NotifyTemplateRefreshMessage} 消息
  26 + */
  27 + public void sendNotifyTemplateRefreshMessage() {
  28 + NotifyTemplateRefreshMessage message = new NotifyTemplateRefreshMessage();
  29 + redisMQTemplate.send(message);
  30 + }
  31 +
  32 +
  33 +}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailLogService.java
@@ -45,7 +45,7 @@ public interface MailLogService { @@ -45,7 +45,7 @@ public interface MailLogService {
45 * @param isSend 是否发送成功 45 * @param isSend 是否发送成功
46 * @return 日志编号 46 * @return 日志编号
47 */ 47 */
48 - Long createMailLog(Long userId,Integer userType, String toMail, 48 + Long createMailLog(Long userId, Integer userType, String toMail,
49 MailAccountDO account, MailTemplateDO template , 49 MailAccountDO account, MailTemplateDO template ,
50 String templateContent, Map<String, Object> templateParams, Boolean isSend); 50 String templateContent, Map<String, Object> templateParams, Boolean isSend);
51 51
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/mail/MailSendServiceImpl.java
@@ -88,8 +88,7 @@ public class MailSendServiceImpl implements MailSendService { @@ -88,8 +88,7 @@ public class MailSendServiceImpl implements MailSendService {
88 88
89 // 校验邮箱是否存在 89 // 校验邮箱是否存在
90 mail = checkMail(mail); 90 mail = checkMail(mail);
91 - // 构建有序的模板参数。为什么放在这个位置,是提前保证模板参数的正确性,而不是到了插入发送日志  
92 - List<KeyValue<String, Object>> newTemplateParams = buildTemplateParams(template, templateParams); 91 + checkTemplateParams(template, templateParams);
93 92
94 // 创建发送日志。如果模板被禁用,则不发送短信,只记录日志 93 // 创建发送日志。如果模板被禁用,则不发送短信,只记录日志
95 Boolean isSend = CommonStatusEnum.ENABLE.getStatus().equals(template.getStatus()); 94 Boolean isSend = CommonStatusEnum.ENABLE.getStatus().equals(template.getStatus());
@@ -152,21 +151,19 @@ public class MailSendServiceImpl implements MailSendService { @@ -152,21 +151,19 @@ public class MailSendServiceImpl implements MailSendService {
152 } 151 }
153 152
154 /** 153 /**
155 - * 将参数模板,处理成有序的 KeyValue 数组 154 + * 校验邮件参数是否确实
156 * 155 *
157 * @param template 邮箱模板 156 * @param template 邮箱模板
158 - * @param templateParams 原始参数  
159 - * @return 处理后的参数 157 + * @param templateParams 参数列表
160 */ 158 */
161 @VisibleForTesting 159 @VisibleForTesting
162 - public List<KeyValue<String, Object>> buildTemplateParams(MailTemplateDO template, Map<String, Object> templateParams) {  
163 - return template.getParams().stream().map(key -> { 160 + public void checkTemplateParams(MailTemplateDO template, Map<String, Object> templateParams) {
  161 + template.getParams().forEach(key -> {
164 Object value = templateParams.get(key); 162 Object value = templateParams.get(key);
165 if (value == null) { 163 if (value == null) {
166 throw exception(MAIL_SEND_TEMPLATE_PARAM_MISS, key); 164 throw exception(MAIL_SEND_TEMPLATE_PARAM_MISS, key);
167 } 165 }
168 - return new KeyValue<>(key, value);  
169 - }).collect(Collectors.toList()); 166 + });
170 } 167 }
171 168
172 } 169 }
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageService.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.service.notify;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageMyPageReqVO;
  5 +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
  6 +import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
  7 +import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
  8 +
  9 +import java.util.Collection;
  10 +import java.util.List;
  11 +import java.util.Map;
  12 +
  13 +/**
  14 + * 站内信 Service 接口
  15 + *
  16 + * @author xrcoder
  17 + */
  18 +public interface NotifyMessageService {
  19 +
  20 + /**
  21 + * 创建站内信
  22 + *
  23 + * @param userId 用户编号
  24 + * @param userType 用户类型
  25 + * @param template 模版信息
  26 + * @param templateContent 模版内容
  27 + * @param templateParams 模版参数
  28 + * @return 站内信编号
  29 + */
  30 + Long createNotifyMessage(Long userId, Integer userType,
  31 + NotifyTemplateDO template, String templateContent, Map<String, Object> templateParams);
  32 +
  33 + /**
  34 + * 获得站内信分页
  35 + *
  36 + * @param pageReqVO 分页查询
  37 + * @return 站内信分页
  38 + */
  39 + PageResult<NotifyMessageDO> getNotifyMessagePage(NotifyMessagePageReqVO pageReqVO);
  40 +
  41 + /**
  42 + * 获得【我的】站内信分页
  43 + *
  44 + * @param pageReqVO 分页查询
  45 + * @param userId 用户编号
  46 + * @param userType 用户类型
  47 + * @return 站内信分页
  48 + */
  49 + PageResult<NotifyMessageDO> getMyMyNotifyMessagePage(NotifyMessageMyPageReqVO pageReqVO, Long userId, Integer userType);
  50 +
  51 + /**
  52 + * 获得站内信
  53 + *
  54 + * @param id 编号
  55 + * @return 站内信
  56 + */
  57 + NotifyMessageDO getNotifyMessage(Long id);
  58 +
  59 + /**
  60 + * 获得【我的】未读站内信列表
  61 + *
  62 + * @param userId 用户编号
  63 + * @param userType 用户类型
  64 + * @param size 数量
  65 + * @return 站内信列表
  66 + */
  67 + List<NotifyMessageDO> getUnreadNotifyMessageList(Long userId, Integer userType, Integer size);
  68 +
  69 + /**
  70 + * 统计用户未读站内信条数
  71 + *
  72 + * @param userId 用户编号
  73 + * @param userType 用户类型
  74 + * @return 返回未读站内信条数
  75 + */
  76 + Long getUnreadNotifyMessageCount(Long userId, Integer userType);
  77 +
  78 + /**
  79 + * 标记站内信为已读
  80 + *
  81 + * @param ids 站内信编号集合
  82 + * @param userId 用户编号
  83 + * @param userType 用户类型
  84 + * @return 更新到的条数
  85 + */
  86 + int updateNotifyMessageRead(Collection<Long> ids, Long userId, Integer userType);
  87 +
  88 + /**
  89 + * 标记所有站内信为已读
  90 + *
  91 + * @param userId 用户编号
  92 + * @param userType 用户类型
  93 + * @return 更新到的条数
  94 + */
  95 + int updateAllNotifyMessageRead(Long userId, Integer userType);
  96 +
  97 +}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.service.notify;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageMyPageReqVO;
  5 +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
  6 +import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
  7 +import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
  8 +import cn.iocoder.yudao.module.system.dal.mysql.notify.NotifyMessageMapper;
  9 +import org.springframework.stereotype.Service;
  10 +import org.springframework.validation.annotation.Validated;
  11 +
  12 +import javax.annotation.Resource;
  13 +import java.util.Collection;
  14 +import java.util.List;
  15 +import java.util.Map;
  16 +
  17 +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
  18 +
  19 +/**
  20 + * 站内信 Service 实现类
  21 + *
  22 + * @author xrcoder
  23 + */
  24 +@Service
  25 +@Validated
  26 +public class NotifyMessageServiceImpl implements NotifyMessageService {
  27 +
  28 + @Resource
  29 + private NotifyMessageMapper notifyMessageMapper;
  30 +
  31 + @Override
  32 + public Long createNotifyMessage(Long userId, Integer userType,
  33 + NotifyTemplateDO template, String templateContent, Map<String, Object> templateParams) {
  34 + NotifyMessageDO message = new NotifyMessageDO().setUserId(userId).setUserType(userType)
  35 + .setTemplateId(template.getId()).setTemplateCode(template.getCode())
  36 + .setTemplateType(template.getType()).setTemplateNickname(template.getNickname())
  37 + .setTemplateContent(templateContent).setTemplateParams(templateParams).setReadStatus(false);
  38 + notifyMessageMapper.insert(message);
  39 + return message.getId();
  40 + }
  41 +
  42 + @Override
  43 + public PageResult<NotifyMessageDO> getNotifyMessagePage(NotifyMessagePageReqVO pageReqVO) {
  44 + return notifyMessageMapper.selectPage(pageReqVO);
  45 + }
  46 +
  47 + @Override
  48 + public PageResult<NotifyMessageDO> getMyMyNotifyMessagePage(NotifyMessageMyPageReqVO pageReqVO, Long userId, Integer userType) {
  49 + return notifyMessageMapper.selectPage(pageReqVO, userId, userType);
  50 + }
  51 +
  52 + @Override
  53 + public NotifyMessageDO getNotifyMessage(Long id) {
  54 + return notifyMessageMapper.selectById(id);
  55 + }
  56 +
  57 + @Override
  58 + public List<NotifyMessageDO> getUnreadNotifyMessageList(Long userId, Integer userType, Integer size) {
  59 + return notifyMessageMapper.selectUnreadListByUserIdAndUserType(userId, userType, size);
  60 + }
  61 +
  62 + @Override
  63 + public Long getUnreadNotifyMessageCount(Long userId, Integer userType) {
  64 + return notifyMessageMapper.selectUnreadCountByUserIdAndUserType(userId, userType);
  65 + }
  66 +
  67 + @Override
  68 + public int updateNotifyMessageRead(Collection<Long> ids, Long userId, Integer userType) {
  69 + return notifyMessageMapper.updateListRead(ids, userId, userType);
  70 + }
  71 +
  72 + @Override
  73 + public int updateAllNotifyMessageRead(Long userId, Integer userType) {
  74 + return notifyMessageMapper.updateListRead(userId, userType);
  75 + }
  76 +
  77 +}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifySendService.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.service.notify;
  2 +
  3 +import java.util.List;
  4 +import java.util.Map;
  5 +
  6 +/**
  7 + * 站内信发送 Service 接口
  8 + *
  9 + * @author xrcoder
  10 + */
  11 +public interface NotifySendService {
  12 +
  13 + /**
  14 + * 发送单条站内信给管理后台的用户
  15 + *
  16 + * 在 mobile 为空时,使用 userId 加载对应管理员的手机号
  17 + *
  18 + * @param userId 用户编号
  19 + * @param templateCode 短信模板编号
  20 + * @param templateParams 短信模板参数
  21 + * @return 发送日志编号
  22 + */
  23 + Long sendSingleNotifyToAdmin(Long userId,
  24 + String templateCode, Map<String, Object> templateParams);
  25 + /**
  26 + * 发送单条站内信给用户 APP 的用户
  27 + *
  28 + * 在 mobile 为空时,使用 userId 加载对应会员的手机号
  29 + *
  30 + * @param userId 用户编号
  31 + * @param templateCode 站内信模板编号
  32 + * @param templateParams 站内信模板参数
  33 + * @return 发送日志编号
  34 + */
  35 + Long sendSingleNotifyToMember(Long userId,
  36 + String templateCode, Map<String, Object> templateParams);
  37 +
  38 + /**
  39 + * 发送单条站内信给用户
  40 + *
  41 + * @param userId 用户编号
  42 + * @param userType 用户类型
  43 + * @param templateCode 站内信模板编号
  44 + * @param templateParams 站内信模板参数
  45 + * @return 发送日志编号
  46 + */
  47 + Long sendSingleNotify( Long userId, Integer userType,
  48 + String templateCode, Map<String, Object> templateParams);
  49 +
  50 + default void sendBatchNotify(List<String> mobiles, List<Long> userIds, Integer userType,
  51 + String templateCode, Map<String, Object> templateParams) {
  52 + throw new UnsupportedOperationException("暂时不支持该操作,感兴趣可以实现该功能哟!");
  53 + }
  54 +
  55 +}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifySendServiceImpl.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.service.notify;
  2 +
  3 +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
  4 +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
  5 +import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
  6 +import com.google.common.annotations.VisibleForTesting;
  7 +import lombok.extern.slf4j.Slf4j;
  8 +import org.springframework.stereotype.Service;
  9 +import org.springframework.validation.annotation.Validated;
  10 +
  11 +import javax.annotation.Resource;
  12 +import java.util.Map;
  13 +import java.util.Objects;
  14 +
  15 +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
  16 +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
  17 +
  18 +/**
  19 + * 站内信发送 Service 实现类
  20 + *
  21 + * @author xrcoder
  22 + */
  23 +@Service
  24 +@Validated
  25 +@Slf4j
  26 +public class NotifySendServiceImpl implements NotifySendService {
  27 +
  28 + @Resource
  29 + private NotifyTemplateService notifyTemplateService;
  30 +
  31 + @Resource
  32 + private NotifyMessageService notifyMessageService;
  33 +
  34 + @Override
  35 + public Long sendSingleNotifyToAdmin(Long userId, String templateCode, Map<String, Object> templateParams) {
  36 + return sendSingleNotify(userId, UserTypeEnum.ADMIN.getValue(), templateCode, templateParams);
  37 + }
  38 +
  39 + @Override
  40 + public Long sendSingleNotifyToMember(Long userId, String templateCode, Map<String, Object> templateParams) {
  41 + return sendSingleNotify(userId, UserTypeEnum.MEMBER.getValue(), templateCode, templateParams);
  42 + }
  43 +
  44 + @Override
  45 + public Long sendSingleNotify(Long userId, Integer userType, String templateCode, Map<String, Object> templateParams) {
  46 + // 校验模版
  47 + NotifyTemplateDO template = checkNotifyTemplateValid(templateCode);
  48 + if (Objects.equals(template.getStatus(), CommonStatusEnum.DISABLE.getStatus())) {
  49 + log.info("[sendSingleNotify][模版({})已经关闭,无法给用户({}/{})发送]", templateCode, userId, userType);
  50 + return null;
  51 + }
  52 + // 校验参数
  53 + checkTemplateParams(template, templateParams);
  54 +
  55 + // 发送站内信
  56 + String content = notifyTemplateService.formatNotifyTemplateContent(template.getContent(), templateParams);
  57 + return notifyMessageService.createNotifyMessage(userId, userType, template, content, templateParams);
  58 + }
  59 +
  60 + @VisibleForTesting
  61 + public NotifyTemplateDO checkNotifyTemplateValid(String templateCode) {
  62 + // 获得站内信模板。考虑到效率,从缓存中获取
  63 + NotifyTemplateDO template = notifyTemplateService.getNotifyTemplateByCodeFromCache(templateCode);
  64 + // 站内信模板不存在
  65 + if (template == null) {
  66 + throw exception(NOTICE_NOT_FOUND);
  67 + }
  68 + return template;
  69 + }
  70 +
  71 + /**
  72 + * 校验站内信模版参数是否确实
  73 + *
  74 + * @param template 邮箱模板
  75 + * @param templateParams 参数列表
  76 + */
  77 + @VisibleForTesting
  78 + public void checkTemplateParams(NotifyTemplateDO template, Map<String, Object> templateParams) {
  79 + template.getParams().forEach(key -> {
  80 + Object value = templateParams.get(key);
  81 + if (value == null) {
  82 + throw exception(NOTIFY_SEND_TEMPLATE_PARAM_MISS, key);
  83 + }
  84 + });
  85 + }
  86 +}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateService.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.service.notify;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateCreateReqVO;
  5 +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplatePageReqVO;
  6 +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateUpdateReqVO;
  7 +import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
  8 +
  9 +import javax.validation.Valid;
  10 +import java.util.Map;
  11 +
  12 +/**
  13 + * 站内信模版 Service 接口
  14 + *
  15 + * @author xrcoder
  16 + */
  17 +public interface NotifyTemplateService {
  18 +
  19 + /**
  20 + * 初始化站内信模板的本地缓存
  21 + */
  22 + void initLocalCache();
  23 +
  24 + /**
  25 + * 获得站内信模板,从缓存中
  26 + *
  27 + * @param code 模板编码
  28 + * @return 站内信模板
  29 + */
  30 + NotifyTemplateDO getNotifyTemplateByCodeFromCache(String code);
  31 +
  32 + /**
  33 + * 创建站内信模版
  34 + *
  35 + * @param createReqVO 创建信息
  36 + * @return 编号
  37 + */
  38 + Long createNotifyTemplate(@Valid NotifyTemplateCreateReqVO createReqVO);
  39 +
  40 + /**
  41 + * 更新站内信模版
  42 + *
  43 + * @param updateReqVO 更新信息
  44 + */
  45 + void updateNotifyTemplate(@Valid NotifyTemplateUpdateReqVO updateReqVO);
  46 +
  47 + /**
  48 + * 删除站内信模版
  49 + *
  50 + * @param id 编号
  51 + */
  52 + void deleteNotifyTemplate(Long id);
  53 +
  54 + /**
  55 + * 获得站内信模版
  56 + *
  57 + * @param id 编号
  58 + * @return 站内信模版
  59 + */
  60 + NotifyTemplateDO getNotifyTemplate(Long id);
  61 +
  62 + /**
  63 + * 获得站内信模版分页
  64 + *
  65 + * @param pageReqVO 分页查询
  66 + * @return 站内信模版分页
  67 + */
  68 + PageResult<NotifyTemplateDO> getNotifyTemplatePage(NotifyTemplatePageReqVO pageReqVO);
  69 +
  70 + /**
  71 + * 格式化站内信内容
  72 + *
  73 + * @param content 站内信模板的内容
  74 + * @param params 站内信内容的参数
  75 + * @return 格式化后的内容
  76 + */
  77 + String formatNotifyTemplateContent(String content, Map<String, Object> params);
  78 +
  79 +}
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImpl.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.service.notify;
  2 +
  3 +import cn.hutool.core.util.ReUtil;
  4 +import cn.hutool.core.util.StrUtil;
  5 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  6 +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
  7 +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateCreateReqVO;
  8 +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplatePageReqVO;
  9 +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateUpdateReqVO;
  10 +import cn.iocoder.yudao.module.system.convert.notify.NotifyTemplateConvert;
  11 +import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
  12 +import cn.iocoder.yudao.module.system.dal.mysql.notify.NotifyTemplateMapper;
  13 +import cn.iocoder.yudao.module.system.mq.producer.notify.NotifyProducer;
  14 +import com.google.common.annotations.VisibleForTesting;
  15 +import lombok.extern.slf4j.Slf4j;
  16 +import org.springframework.stereotype.Service;
  17 +import org.springframework.validation.annotation.Validated;
  18 +
  19 +import javax.annotation.PostConstruct;
  20 +import javax.annotation.Resource;
  21 +import java.util.List;
  22 +import java.util.Map;
  23 +import java.util.regex.Pattern;
  24 +
  25 +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
  26 +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
  27 +
  28 +/**
  29 + * 站内信模版 Service 实现类
  30 + *
  31 + * @author xrcoder
  32 + */
  33 +@Service
  34 +@Validated
  35 +@Slf4j
  36 +public class NotifyTemplateServiceImpl implements NotifyTemplateService {
  37 +
  38 + /**
  39 + * 正则表达式,匹配 {} 中的变量
  40 + */
  41 + private static final Pattern PATTERN_PARAMS = Pattern.compile("\\{(.*?)}");
  42 +
  43 + @Resource
  44 + private NotifyTemplateMapper notifyTemplateMapper;
  45 +
  46 + @Resource
  47 + private NotifyProducer notifyProducer;
  48 +
  49 + /**
  50 + * 站内信模板缓存
  51 + * key:站内信模板编码 {@link NotifyTemplateDO#getCode()}
  52 + * <p>
  53 + * 这里声明 volatile 修饰的原因是,每次刷新时,直接修改指向
  54 + */
  55 + private volatile Map<String, NotifyTemplateDO> notifyTemplateCache;
  56 +
  57 + /**
  58 + * 初始化站内信模板的本地缓存
  59 + */
  60 + @Override
  61 + @PostConstruct
  62 + public void initLocalCache() {
  63 + // 第一步:查询数据
  64 + List<NotifyTemplateDO> templates = notifyTemplateMapper.selectList();
  65 + log.info("[initLocalCache][缓存站内信模版,数量为:{}]", templates.size());
  66 +
  67 + // 第二步:构建缓存
  68 + notifyTemplateCache = CollectionUtils.convertMap(templates, NotifyTemplateDO::getCode);
  69 + }
  70 +
  71 + @Override
  72 + public NotifyTemplateDO getNotifyTemplateByCodeFromCache(String code) {
  73 + return notifyTemplateCache.get(code);
  74 + }
  75 +
  76 + @Override
  77 + public Long createNotifyTemplate(NotifyTemplateCreateReqVO createReqVO) {
  78 + // 校验站内信编码是否重复
  79 + checkNotifyTemplateCodeDuplicate(null, createReqVO.getCode());
  80 +
  81 + // 插入
  82 + NotifyTemplateDO notifyTemplate = NotifyTemplateConvert.INSTANCE.convert(createReqVO);
  83 + notifyTemplate.setParams(parseTemplateContentParams(notifyTemplate.getContent()));
  84 + notifyTemplateMapper.insert(notifyTemplate);
  85 +
  86 + // 发送刷新消息
  87 + notifyProducer.sendNotifyTemplateRefreshMessage();
  88 + return notifyTemplate.getId();
  89 + }
  90 +
  91 + @Override
  92 + public void updateNotifyTemplate(NotifyTemplateUpdateReqVO updateReqVO) {
  93 + // 校验存在
  94 + validateNotifyTemplateExists(updateReqVO.getId());
  95 + // 校验站内信编码是否重复
  96 + checkNotifyTemplateCodeDuplicate(updateReqVO.getId(), updateReqVO.getCode());
  97 +
  98 + // 更新
  99 + NotifyTemplateDO updateObj = NotifyTemplateConvert.INSTANCE.convert(updateReqVO);
  100 + updateObj.setParams(parseTemplateContentParams(updateObj.getContent()));
  101 + notifyTemplateMapper.updateById(updateObj);
  102 +
  103 + // 发送刷新消息
  104 + notifyProducer.sendNotifyTemplateRefreshMessage();
  105 + }
  106 +
  107 + @VisibleForTesting
  108 + public List<String> parseTemplateContentParams(String content) {
  109 + return ReUtil.findAllGroup1(PATTERN_PARAMS, content);
  110 + }
  111 +
  112 + @Override
  113 + public void deleteNotifyTemplate(Long id) {
  114 + // 校验存在
  115 + validateNotifyTemplateExists(id);
  116 + // 删除
  117 + notifyTemplateMapper.deleteById(id);
  118 + // 发送刷新消息
  119 + notifyProducer.sendNotifyTemplateRefreshMessage();
  120 + }
  121 +
  122 + private void validateNotifyTemplateExists(Long id) {
  123 + if (notifyTemplateMapper.selectById(id) == null) {
  124 + throw exception(NOTIFY_TEMPLATE_NOT_EXISTS);
  125 + }
  126 + }
  127 +
  128 + @Override
  129 + public NotifyTemplateDO getNotifyTemplate(Long id) {
  130 + return notifyTemplateMapper.selectById(id);
  131 + }
  132 +
  133 + @Override
  134 + public PageResult<NotifyTemplateDO> getNotifyTemplatePage(NotifyTemplatePageReqVO pageReqVO) {
  135 + return notifyTemplateMapper.selectPage(pageReqVO);
  136 + }
  137 +
  138 + @VisibleForTesting
  139 + public void checkNotifyTemplateCodeDuplicate(Long id, String code) {
  140 + NotifyTemplateDO template = notifyTemplateMapper.selectByCode(code);
  141 + if (template == null) {
  142 + return;
  143 + }
  144 + // 如果 id 为空,说明不用比较是否为相同 id 的字典类型
  145 + if (id == null) {
  146 + throw exception(NOTIFY_TEMPLATE_CODE_DUPLICATE, code);
  147 + }
  148 + if (!template.getId().equals(id)) {
  149 + throw exception(NOTIFY_TEMPLATE_CODE_DUPLICATE, code);
  150 + }
  151 + }
  152 +
  153 + /**
  154 + * 格式化站内信内容
  155 + *
  156 + * @param content 站内信模板的内容
  157 + * @param params 站内信内容的参数
  158 + * @return 格式化后的内容
  159 + */
  160 + @Override
  161 + public String formatNotifyTemplateContent(String content, Map<String, Object> params) {
  162 + return StrUtil.format(content, params);
  163 + }
  164 +}
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/mail/MailSendServiceImplTest.java
@@ -145,7 +145,7 @@ class MailSendServiceImplTest extends BaseMockitoUnitTest { @@ -145,7 +145,7 @@ class MailSendServiceImplTest extends BaseMockitoUnitTest {
145 } 145 }
146 146
147 @Test 147 @Test
148 - public void testBuildTemplateParams_paramMiss() { 148 + public void testCheckTemplateParams_paramMiss() {
149 // 准备参数 149 // 准备参数
150 MailTemplateDO template = randomPojo(MailTemplateDO.class, 150 MailTemplateDO template = randomPojo(MailTemplateDO.class,
151 o -> o.setParams(Lists.newArrayList("code"))); 151 o -> o.setParams(Lists.newArrayList("code")));
@@ -153,7 +153,7 @@ class MailSendServiceImplTest extends BaseMockitoUnitTest { @@ -153,7 +153,7 @@ class MailSendServiceImplTest extends BaseMockitoUnitTest {
153 // mock 方法 153 // mock 方法
154 154
155 // 调用,并断言异常 155 // 调用,并断言异常
156 - assertServiceException(() -> mailSendService.buildTemplateParams(template, templateParams), 156 + assertServiceException(() -> mailSendService.checkTemplateParams(template, templateParams),
157 MAIL_SEND_TEMPLATE_PARAM_MISS, "code"); 157 MAIL_SEND_TEMPLATE_PARAM_MISS, "code");
158 } 158 }
159 159
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImplTest.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.service.notify;
  2 +
  3 +import cn.hutool.core.map.MapUtil;
  4 +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
  5 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  6 +import cn.iocoder.yudao.framework.mybatis.core.enums.SqlConstants;
  7 +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
  8 +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageMyPageReqVO;
  9 +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
  10 +import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
  11 +import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
  12 +import cn.iocoder.yudao.module.system.dal.mysql.notify.NotifyMessageMapper;
  13 +import com.baomidou.mybatisplus.annotation.DbType;
  14 +import org.junit.jupiter.api.Test;
  15 +import org.springframework.context.annotation.Import;
  16 +
  17 +import javax.annotation.Resource;
  18 +import java.util.Arrays;
  19 +import java.util.Collection;
  20 +import java.util.List;
  21 +import java.util.Map;
  22 +
  23 +import static cn.hutool.core.util.RandomUtil.randomEle;
  24 +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime;
  25 +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime;
  26 +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
  27 +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
  28 +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
  29 +import static org.junit.jupiter.api.Assertions.*;
  30 +
  31 +/**
  32 +* {@link NotifyMessageServiceImpl} 的单元测试类
  33 +*
  34 +* @author 芋道源码
  35 +*/
  36 +@Import(NotifyMessageServiceImpl.class)
  37 +public class NotifyMessageServiceImplTest extends BaseDbUnitTest {
  38 +
  39 + @Resource
  40 + private NotifyMessageServiceImpl notifyMessageService;
  41 +
  42 + @Resource
  43 + private NotifyMessageMapper notifyMessageMapper;
  44 +
  45 + @Test
  46 + public void testCreateNotifyMessage_success() {
  47 + // 准备参数
  48 + Long userId = randomLongId();
  49 + Integer userType = randomEle(UserTypeEnum.values()).getValue();
  50 + NotifyTemplateDO template = randomPojo(NotifyTemplateDO.class);
  51 + String templateContent = randomString();
  52 + Map<String, Object> templateParams = randomTemplateParams();
  53 + // mock 方法
  54 +
  55 + // 调用
  56 + Long messageId = notifyMessageService.createNotifyMessage(userId, userType,
  57 + template, templateContent, templateParams);
  58 + // 断言
  59 + NotifyMessageDO message = notifyMessageMapper.selectById(messageId);
  60 + assertNotNull(message);
  61 + assertEquals(userId, message.getUserId());
  62 + assertEquals(userType, message.getUserType());
  63 + assertEquals(template.getId(), message.getTemplateId());
  64 + assertEquals(template.getCode(), message.getTemplateCode());
  65 + assertEquals(template.getType(), message.getTemplateType());
  66 + assertEquals(template.getNickname(), message.getTemplateNickname());
  67 + assertEquals(templateContent, message.getTemplateContent());
  68 + assertEquals(templateParams, message.getTemplateParams());
  69 + assertEquals(false, message.getReadStatus());
  70 + assertNull(message.getReadTime());
  71 + }
  72 +
  73 + @Test
  74 + public void testGetNotifyMessagePage() {
  75 + // mock 数据
  76 + NotifyMessageDO dbNotifyMessage = randomPojo(NotifyMessageDO.class, o -> { // 等会查询到
  77 + o.setUserId(1L);
  78 + o.setUserType(UserTypeEnum.ADMIN.getValue());
  79 + o.setTemplateCode("test_01");
  80 + o.setTemplateType(10);
  81 + o.setCreateTime(buildTime(2022, 1, 2));
  82 + o.setTemplateParams(randomTemplateParams());
  83 + });
  84 + notifyMessageMapper.insert(dbNotifyMessage);
  85 + // 测试 userId 不匹配
  86 + notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserId(2L)));
  87 + // 测试 userType 不匹配
  88 + notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserType(UserTypeEnum.MEMBER.getValue())));
  89 + // 测试 templateCode 不匹配
  90 + notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setTemplateCode("test_11")));
  91 + // 测试 templateType 不匹配
  92 + notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setTemplateType(20)));
  93 + // 测试 createTime 不匹配
  94 + notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setCreateTime(buildTime(2022, 2, 1))));
  95 + // 准备参数
  96 + NotifyMessagePageReqVO reqVO = new NotifyMessagePageReqVO();
  97 + reqVO.setUserId(1L);
  98 + reqVO.setUserType(UserTypeEnum.ADMIN.getValue());
  99 + reqVO.setTemplateCode("est_01");
  100 + reqVO.setTemplateType(10);
  101 + reqVO.setCreateTime(buildBetweenTime(2022, 1, 1, 2022, 1, 10));
  102 +
  103 + // 调用
  104 + PageResult<NotifyMessageDO> pageResult = notifyMessageService.getNotifyMessagePage(reqVO);
  105 + // 断言
  106 + assertEquals(1, pageResult.getTotal());
  107 + assertEquals(1, pageResult.getList().size());
  108 + assertPojoEquals(dbNotifyMessage, pageResult.getList().get(0));
  109 + }
  110 +
  111 + @Test
  112 + public void testGetMyNotifyMessagePage() {
  113 + // mock 数据
  114 + NotifyMessageDO dbNotifyMessage = randomPojo(NotifyMessageDO.class, o -> { // 等会查询到
  115 + o.setUserId(1L);
  116 + o.setUserType(UserTypeEnum.ADMIN.getValue());
  117 + o.setReadStatus(true);
  118 + o.setCreateTime(buildTime(2022, 1, 2));
  119 + o.setTemplateParams(randomTemplateParams());
  120 + });
  121 + notifyMessageMapper.insert(dbNotifyMessage);
  122 + // 测试 userId 不匹配
  123 + notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserId(2L)));
  124 + // 测试 userType 不匹配
  125 + notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserType(UserTypeEnum.MEMBER.getValue())));
  126 + // 测试 readStatus 不匹配
  127 + notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setReadStatus(false)));
  128 + // 测试 createTime 不匹配
  129 + notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setCreateTime(buildTime(2022, 2, 1))));
  130 + // 准备参数
  131 + Long userId = 1L;
  132 + Integer userType = UserTypeEnum.ADMIN.getValue();
  133 + NotifyMessageMyPageReqVO reqVO = new NotifyMessageMyPageReqVO();
  134 + reqVO.setReadStatus(true);
  135 + reqVO.setCreateTime(buildBetweenTime(2022, 1, 1, 2022, 1, 10));
  136 +
  137 + // 调用
  138 + PageResult<NotifyMessageDO> pageResult = notifyMessageService.getMyMyNotifyMessagePage(reqVO, userId, userType);
  139 + // 断言
  140 + assertEquals(1, pageResult.getTotal());
  141 + assertEquals(1, pageResult.getList().size());
  142 + assertPojoEquals(dbNotifyMessage, pageResult.getList().get(0));
  143 + }
  144 +
  145 + @Test
  146 + public void testGetUnreadNotifyMessageList() {
  147 + SqlConstants.init(DbType.MYSQL);
  148 + // mock 数据
  149 + NotifyMessageDO dbNotifyMessage = randomPojo(NotifyMessageDO.class, o -> { // 等会查询到
  150 + o.setUserId(1L);
  151 + o.setUserType(UserTypeEnum.ADMIN.getValue());
  152 + o.setReadStatus(false);
  153 + o.setTemplateParams(randomTemplateParams());
  154 + });
  155 + notifyMessageMapper.insert(dbNotifyMessage);
  156 + // 测试 userId 不匹配
  157 + notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserId(2L)));
  158 + // 测试 userType 不匹配
  159 + notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserType(UserTypeEnum.MEMBER.getValue())));
  160 + // 测试 readStatus 不匹配
  161 + notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setReadStatus(true)));
  162 + // 准备参数
  163 + Long userId = 1L;
  164 + Integer userType = UserTypeEnum.ADMIN.getValue();
  165 + Integer size = 10;
  166 +
  167 + // 调用
  168 + List<NotifyMessageDO> list = notifyMessageService.getUnreadNotifyMessageList(userId, userType, size);
  169 + // 断言
  170 + assertEquals(1, list.size());
  171 + assertPojoEquals(dbNotifyMessage, list.get(0));
  172 + }
  173 +
  174 + @Test
  175 + public void testGetUnreadNotifyMessageCount() {
  176 + SqlConstants.init(DbType.MYSQL);
  177 + // mock 数据
  178 + NotifyMessageDO dbNotifyMessage = randomPojo(NotifyMessageDO.class, o -> { // 等会查询到
  179 + o.setUserId(1L);
  180 + o.setUserType(UserTypeEnum.ADMIN.getValue());
  181 + o.setReadStatus(false);
  182 + o.setTemplateParams(randomTemplateParams());
  183 + });
  184 + notifyMessageMapper.insert(dbNotifyMessage);
  185 + // 测试 userId 不匹配
  186 + notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserId(2L)));
  187 + // 测试 userType 不匹配
  188 + notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserType(UserTypeEnum.MEMBER.getValue())));
  189 + // 测试 readStatus 不匹配
  190 + notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setReadStatus(true)));
  191 + // 准备参数
  192 + Long userId = 1L;
  193 + Integer userType = UserTypeEnum.ADMIN.getValue();
  194 +
  195 + // 调用,并断言
  196 + assertEquals(1, notifyMessageService.getUnreadNotifyMessageCount(userId, userType));
  197 + }
  198 +
  199 + @Test
  200 + public void testUpdateNotifyMessageRead() {
  201 + // mock 数据
  202 + NotifyMessageDO dbNotifyMessage = randomPojo(NotifyMessageDO.class, o -> { // 等会查询到
  203 + o.setUserId(1L);
  204 + o.setUserType(UserTypeEnum.ADMIN.getValue());
  205 + o.setReadStatus(false);
  206 + o.setReadTime(null);
  207 + o.setTemplateParams(randomTemplateParams());
  208 + });
  209 + notifyMessageMapper.insert(dbNotifyMessage);
  210 + // 测试 userId 不匹配
  211 + notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserId(2L)));
  212 + // 测试 userType 不匹配
  213 + notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserType(UserTypeEnum.MEMBER.getValue())));
  214 + // 测试 readStatus 不匹配
  215 + notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setReadStatus(true)));
  216 + // 准备参数
  217 + Collection<Long> ids = Arrays.asList(dbNotifyMessage.getId(), dbNotifyMessage.getId() + 1,
  218 + dbNotifyMessage.getId() + 2, dbNotifyMessage.getId() + 3);
  219 + Long userId = 1L;
  220 + Integer userType = UserTypeEnum.ADMIN.getValue();
  221 +
  222 + // 调用
  223 + int updateCount = notifyMessageService.updateNotifyMessageRead(ids, userId, userType);
  224 + // 断言
  225 + assertEquals(1, updateCount);
  226 + NotifyMessageDO notifyMessage = notifyMessageMapper.selectById(dbNotifyMessage.getId());
  227 + assertTrue(notifyMessage.getReadStatus());
  228 + assertNotNull(notifyMessage.getReadTime());
  229 + }
  230 +
  231 + @Test
  232 + public void testUpdateAllNotifyMessageRead() {
  233 + // mock 数据
  234 + NotifyMessageDO dbNotifyMessage = randomPojo(NotifyMessageDO.class, o -> { // 等会查询到
  235 + o.setUserId(1L);
  236 + o.setUserType(UserTypeEnum.ADMIN.getValue());
  237 + o.setReadStatus(false);
  238 + o.setReadTime(null);
  239 + o.setTemplateParams(randomTemplateParams());
  240 + });
  241 + notifyMessageMapper.insert(dbNotifyMessage);
  242 + // 测试 userId 不匹配
  243 + notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserId(2L)));
  244 + // 测试 userType 不匹配
  245 + notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setUserType(UserTypeEnum.MEMBER.getValue())));
  246 + // 测试 readStatus 不匹配
  247 + notifyMessageMapper.insert(cloneIgnoreId(dbNotifyMessage, o -> o.setReadStatus(true)));
  248 + // 准备参数
  249 + Long userId = 1L;
  250 + Integer userType = UserTypeEnum.ADMIN.getValue();
  251 +
  252 + // 调用
  253 + int updateCount = notifyMessageService.updateAllNotifyMessageRead(userId, userType);
  254 + // 断言
  255 + assertEquals(1, updateCount);
  256 + NotifyMessageDO notifyMessage = notifyMessageMapper.selectById(dbNotifyMessage.getId());
  257 + assertTrue(notifyMessage.getReadStatus());
  258 + assertNotNull(notifyMessage.getReadTime());
  259 + }
  260 +
  261 + private static Map<String, Object> randomTemplateParams() {
  262 + return MapUtil.<String, Object>builder().put(randomString(), randomString())
  263 + .put(randomString(), randomString()).build();
  264 + }
  265 +
  266 +}
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifySendServiceImplTest.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.service.notify;
  2 +
  3 +import cn.hutool.core.map.MapUtil;
  4 +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
  5 +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
  6 +import cn.iocoder.yudao.framework.test.core.ut.BaseMockitoUnitTest;
  7 +import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailAccountDO;
  8 +import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO;
  9 +import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
  10 +import org.assertj.core.util.Lists;
  11 +import org.junit.jupiter.api.Test;
  12 +import org.mockito.InjectMocks;
  13 +import org.mockito.Mock;
  14 +
  15 +import java.util.HashMap;
  16 +import java.util.Map;
  17 +
  18 +import static cn.hutool.core.util.RandomUtil.randomEle;
  19 +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
  20 +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
  21 +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
  22 +import static org.junit.jupiter.api.Assertions.assertEquals;
  23 +import static org.junit.jupiter.api.Assertions.assertNull;
  24 +import static org.mockito.ArgumentMatchers.eq;
  25 +import static org.mockito.Mockito.*;
  26 +
  27 +class NotifySendServiceImplTest extends BaseMockitoUnitTest {
  28 +
  29 + @InjectMocks
  30 + private NotifySendServiceImpl notifySendService;
  31 +
  32 + @Mock
  33 + private NotifyTemplateService notifyTemplateService;
  34 + @Mock
  35 + private NotifyMessageService notifyMessageService;
  36 +
  37 + /**
  38 + * 发送成功,当短信模板开启时
  39 + */
  40 + @Test
  41 + public void testSendSingleNotify_successWhenMailTemplateEnable() {
  42 + // 准备参数
  43 + Long userId = randomLongId();
  44 + Integer userType = randomEle(UserTypeEnum.values()).getValue();
  45 + String templateCode = randomString();
  46 + Map<String, Object> templateParams = MapUtil.<String, Object>builder().put("code", "1234")
  47 + .put("op", "login").build();
  48 + // mock NotifyTemplateService 的方法
  49 + NotifyTemplateDO template = randomPojo(NotifyTemplateDO.class, o -> {
  50 + o.setStatus(CommonStatusEnum.ENABLE.getStatus());
  51 + o.setContent("验证码为{code}, 操作为{op}");
  52 + o.setParams(Lists.newArrayList("code", "op"));
  53 + });
  54 + when(notifyTemplateService.getNotifyTemplateByCodeFromCache(eq(templateCode))).thenReturn(template);
  55 + String content = randomString();
  56 + when(notifyTemplateService.formatNotifyTemplateContent(eq(template.getContent()), eq(templateParams)))
  57 + .thenReturn(content);
  58 + // mock NotifyMessageService 的方法
  59 + Long messageId = randomLongId();
  60 + when(notifyMessageService.createNotifyMessage(eq(userId), eq(userType),
  61 + eq(template), eq(content), eq(templateParams))).thenReturn(messageId);
  62 +
  63 + // 调用
  64 + Long resultMessageId = notifySendService.sendSingleNotify(userId, userType, templateCode, templateParams);
  65 + // 断言
  66 + assertEquals(messageId, resultMessageId);
  67 + }
  68 +
  69 + /**
  70 + * 发送成功,当短信模板关闭时
  71 + */
  72 + @Test
  73 + public void testSendSingleMail_successWhenSmsTemplateDisable() {
  74 + // 准备参数
  75 + Long userId = randomLongId();
  76 + Integer userType = randomEle(UserTypeEnum.values()).getValue();
  77 + String templateCode = randomString();
  78 + Map<String, Object> templateParams = MapUtil.<String, Object>builder().put("code", "1234")
  79 + .put("op", "login").build();
  80 + // mock NotifyTemplateService 的方法
  81 + NotifyTemplateDO template = randomPojo(NotifyTemplateDO.class, o -> {
  82 + o.setStatus(CommonStatusEnum.DISABLE.getStatus());
  83 + o.setContent("验证码为{code}, 操作为{op}");
  84 + o.setParams(Lists.newArrayList("code", "op"));
  85 + });
  86 + when(notifyTemplateService.getNotifyTemplateByCodeFromCache(eq(templateCode))).thenReturn(template);
  87 +
  88 + // 调用
  89 + Long resultMessageId = notifySendService.sendSingleNotify(userId, userType, templateCode, templateParams);
  90 + // 断言
  91 + assertNull(resultMessageId);
  92 + verify(notifyTemplateService, never()).formatNotifyTemplateContent(anyString(), anyMap());
  93 + verify(notifyMessageService, never()).createNotifyMessage(anyLong(), anyInt(), any(), anyString(), anyMap());
  94 + }
  95 +
  96 + @Test
  97 + public void testCheckMailTemplateValid_notExists() {
  98 + // 准备参数
  99 + String templateCode = randomString();
  100 + // mock 方法
  101 +
  102 + // 调用,并断言异常
  103 + assertServiceException(() -> notifySendService.checkNotifyTemplateValid(templateCode),
  104 + NOTICE_NOT_FOUND);
  105 + }
  106 +
  107 + @Test
  108 + public void testCheckTemplateParams_paramMiss() {
  109 + // 准备参数
  110 + NotifyTemplateDO template = randomPojo(NotifyTemplateDO.class,
  111 + o -> o.setParams(Lists.newArrayList("code")));
  112 + Map<String, Object> templateParams = new HashMap<>();
  113 + // mock 方法
  114 +
  115 + // 调用,并断言异常
  116 + assertServiceException(() -> notifySendService.checkTemplateParams(template, templateParams),
  117 + NOTIFY_SEND_TEMPLATE_PARAM_MISS, "code");
  118 + }
  119 +
  120 +
  121 +}
yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImplTest.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.service.notify;
  2 +
  3 +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
  4 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  5 +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
  6 +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateCreateReqVO;
  7 +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplatePageReqVO;
  8 +import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateUpdateReqVO;
  9 +import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
  10 +import cn.iocoder.yudao.module.system.dal.mysql.notify.NotifyTemplateMapper;
  11 +import cn.iocoder.yudao.module.system.mq.producer.notify.NotifyProducer;
  12 +import org.junit.jupiter.api.Test;
  13 +import org.springframework.boot.test.mock.mockito.MockBean;
  14 +import org.springframework.context.annotation.Import;
  15 +
  16 +import javax.annotation.Resource;
  17 +
  18 +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime;
  19 +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime;
  20 +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
  21 +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
  22 +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
  23 +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
  24 +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.NOTIFY_TEMPLATE_NOT_EXISTS;
  25 +import static org.junit.jupiter.api.Assertions.*;
  26 +import static org.mockito.Mockito.verify;
  27 +
  28 +/**
  29 +* {@link NotifyTemplateServiceImpl} 的单元测试类
  30 +*
  31 +* @author 芋道源码
  32 +*/
  33 +@Import(NotifyTemplateServiceImpl.class)
  34 +public class NotifyTemplateServiceImplTest extends BaseDbUnitTest {
  35 +
  36 + @Resource
  37 + private NotifyTemplateServiceImpl notifyTemplateService;
  38 +
  39 + @Resource
  40 + private NotifyTemplateMapper notifyTemplateMapper;
  41 +
  42 + @MockBean
  43 + private NotifyProducer notifyProducer;
  44 +
  45 + @Test
  46 + public void testCreateNotifyTemplate_success() {
  47 + // 准备参数
  48 + NotifyTemplateCreateReqVO reqVO = randomPojo(NotifyTemplateCreateReqVO.class,
  49 + o -> o.setStatus(randomCommonStatus()));
  50 +
  51 + // 调用
  52 + Long notifyTemplateId = notifyTemplateService.createNotifyTemplate(reqVO);
  53 + // 断言
  54 + assertNotNull(notifyTemplateId);
  55 + // 校验记录的属性是否正确
  56 + NotifyTemplateDO notifyTemplate = notifyTemplateMapper.selectById(notifyTemplateId);
  57 + assertPojoEquals(reqVO, notifyTemplate);
  58 + verify(notifyProducer).sendNotifyTemplateRefreshMessage();
  59 + }
  60 +
  61 + @Test
  62 + public void testUpdateNotifyTemplate_success() {
  63 + // mock 数据
  64 + NotifyTemplateDO dbNotifyTemplate = randomPojo(NotifyTemplateDO.class);
  65 + notifyTemplateMapper.insert(dbNotifyTemplate);// @Sql: 先插入出一条存在的数据
  66 + // 准备参数
  67 + NotifyTemplateUpdateReqVO reqVO = randomPojo(NotifyTemplateUpdateReqVO.class, o -> {
  68 + o.setId(dbNotifyTemplate.getId()); // 设置更新的 ID
  69 + o.setStatus(randomCommonStatus());
  70 + });
  71 +
  72 + // 调用
  73 + notifyTemplateService.updateNotifyTemplate(reqVO);
  74 + // 校验是否更新正确
  75 + NotifyTemplateDO notifyTemplate = notifyTemplateMapper.selectById(reqVO.getId()); // 获取最新的
  76 + assertPojoEquals(reqVO, notifyTemplate);
  77 + verify(notifyProducer).sendNotifyTemplateRefreshMessage();
  78 + }
  79 +
  80 + @Test
  81 + public void testUpdateNotifyTemplate_notExists() {
  82 + // 准备参数
  83 + NotifyTemplateUpdateReqVO reqVO = randomPojo(NotifyTemplateUpdateReqVO.class);
  84 +
  85 + // 调用, 并断言异常
  86 + assertServiceException(() -> notifyTemplateService.updateNotifyTemplate(reqVO), NOTIFY_TEMPLATE_NOT_EXISTS);
  87 + }
  88 +
  89 + @Test
  90 + public void testDeleteNotifyTemplate_success() {
  91 + // mock 数据
  92 + NotifyTemplateDO dbNotifyTemplate = randomPojo(NotifyTemplateDO.class);
  93 + notifyTemplateMapper.insert(dbNotifyTemplate);// @Sql: 先插入出一条存在的数据
  94 + // 准备参数
  95 + Long id = dbNotifyTemplate.getId();
  96 +
  97 + // 调用
  98 + notifyTemplateService.deleteNotifyTemplate(id);
  99 + // 校验数据不存在了
  100 + assertNull(notifyTemplateMapper.selectById(id));
  101 + verify(notifyProducer).sendNotifyTemplateRefreshMessage();
  102 + }
  103 +
  104 + @Test
  105 + public void testDeleteNotifyTemplate_notExists() {
  106 + // 准备参数
  107 + Long id = randomLongId();
  108 +
  109 + // 调用, 并断言异常
  110 + assertServiceException(() -> notifyTemplateService.deleteNotifyTemplate(id), NOTIFY_TEMPLATE_NOT_EXISTS);
  111 + }
  112 +
  113 + @Test
  114 + public void testGetNotifyTemplatePage() {
  115 + // mock 数据
  116 + NotifyTemplateDO dbNotifyTemplate = randomPojo(NotifyTemplateDO.class, o -> { // 等会查询到
  117 + o.setName("芋头");
  118 + o.setCode("test_01");
  119 + o.setStatus(CommonStatusEnum.ENABLE.getStatus());
  120 + o.setCreateTime(buildTime(2022, 2, 3));
  121 + });
  122 + notifyTemplateMapper.insert(dbNotifyTemplate);
  123 + // 测试 name 不匹配
  124 + notifyTemplateMapper.insert(cloneIgnoreId(dbNotifyTemplate, o -> o.setName("投")));
  125 + // 测试 code 不匹配
  126 + notifyTemplateMapper.insert(cloneIgnoreId(dbNotifyTemplate, o -> o.setCode("test_02")));
  127 + // 测试 status 不匹配
  128 + notifyTemplateMapper.insert(cloneIgnoreId(dbNotifyTemplate, o -> o.setStatus(CommonStatusEnum.DISABLE.getStatus())));
  129 + // 测试 createTime 不匹配
  130 + notifyTemplateMapper.insert(cloneIgnoreId(dbNotifyTemplate, o -> o.setCreateTime(buildTime(2022, 1, 5))));
  131 + // 准备参数
  132 + NotifyTemplatePageReqVO reqVO = new NotifyTemplatePageReqVO();
  133 + reqVO.setName("芋");
  134 + reqVO.setCode("est_01");
  135 + reqVO.setStatus(CommonStatusEnum.ENABLE.getStatus());
  136 + reqVO.setCreateTime(buildBetweenTime(2022, 2, 1, 2022, 2, 5));
  137 +
  138 + // 调用
  139 + PageResult<NotifyTemplateDO> pageResult = notifyTemplateService.getNotifyTemplatePage(reqVO);
  140 + // 断言
  141 + assertEquals(1, pageResult.getTotal());
  142 + assertEquals(1, pageResult.getList().size());
  143 + assertPojoEquals(dbNotifyTemplate, pageResult.getList().get(0));
  144 + }
  145 +
  146 +}
yudao-module-system/yudao-module-system-biz/src/test/resources/sql/clean.sql
@@ -28,3 +28,5 @@ DELETE FROM &quot;system_oauth2_code&quot;; @@ -28,3 +28,5 @@ DELETE FROM &quot;system_oauth2_code&quot;;
28 DELETE FROM "system_mail_account"; 28 DELETE FROM "system_mail_account";
29 DELETE FROM "system_mail_template"; 29 DELETE FROM "system_mail_template";
30 DELETE FROM "system_mail_log"; 30 DELETE FROM "system_mail_log";
  31 +DELETE FROM "system_notify_template";
  32 +DELETE FROM "system_notify_message";
yudao-module-system/yudao-module-system-biz/src/test/resources/sql/create_tables.sql
@@ -626,3 +626,43 @@ CREATE TABLE IF NOT EXISTS &quot;system_mail_log&quot; ( @@ -626,3 +626,43 @@ CREATE TABLE IF NOT EXISTS &quot;system_mail_log&quot; (
626 "deleted" bit NOT NULL DEFAULT FALSE, 626 "deleted" bit NOT NULL DEFAULT FALSE,
627 PRIMARY KEY ("id") 627 PRIMARY KEY ("id")
628 ) COMMENT '邮件日志表'; 628 ) COMMENT '邮件日志表';
  629 +
  630 +-- 将该建表 SQL 语句,添加到 yudao-module-system-biz 模块的 test/resources/sql/create_tables.sql 文件里
  631 +CREATE TABLE IF NOT EXISTS "system_notify_template" (
  632 + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  633 + "name" varchar NOT NULL,
  634 + "code" varchar NOT NULL,
  635 + "nickname" varchar NOT NULL,
  636 + "content" varchar NOT NULL,
  637 + "type" varchar NOT NULL,
  638 + "params" varchar,
  639 + "status" varchar NOT NULL,
  640 + "remark" varchar,
  641 + "creator" varchar DEFAULT '',
  642 + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  643 + "updater" varchar DEFAULT '',
  644 + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  645 + "deleted" bit NOT NULL DEFAULT FALSE,
  646 + PRIMARY KEY ("id")
  647 +) COMMENT '站内信模板表';
  648 +
  649 +CREATE TABLE IF NOT EXISTS "system_notify_message" (
  650 + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY,
  651 + "user_id" bigint NOT NULL,
  652 + "user_type" varchar NOT NULL,
  653 + "template_id" bigint NOT NULL,
  654 + "template_code" varchar NOT NULL,
  655 + "template_nickname" varchar NOT NULL,
  656 + "template_content" varchar NOT NULL,
  657 + "template_type" int NOT NULL,
  658 + "template_params" varchar NOT NULL,
  659 + "read_status" bit NOT NULL,
  660 + "read_time" varchar,
  661 + "creator" varchar DEFAULT '',
  662 + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  663 + "updater" varchar DEFAULT '',
  664 + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  665 + "deleted" bit NOT NULL DEFAULT FALSE,
  666 + "tenant_id" bigint not null default '0',
  667 + PRIMARY KEY ("id")
  668 +) COMMENT '站内信消息表';
yudao-server/src/main/java/cn/iocoder/yudao/server/controller/DefaultController.java
@@ -21,4 +21,10 @@ public class DefaultController { @@ -21,4 +21,10 @@ public class DefaultController {
21 "[工作流模块 yudao-module-bpm - 已禁用][参考 https://doc.iocoder.cn/bpm/ 开启]"); 21 "[工作流模块 yudao-module-bpm - 已禁用][参考 https://doc.iocoder.cn/bpm/ 开启]");
22 } 22 }
23 23
  24 + @RequestMapping("/admin-api/mp/**")
  25 + public CommonResult<Boolean> mp404() {
  26 + return CommonResult.error(NOT_IMPLEMENTED.getCode(),
  27 + "[微信公众号 yudao-module-mp - 已禁用][参考 https://doc.iocoder.cn/mp/build/ 开启]");
  28 + }
  29 +
24 } 30 }
yudao-server/src/main/resources/application.yaml
@@ -133,6 +133,7 @@ yudao: @@ -133,6 +133,7 @@ yudao:
133 - cn.iocoder.yudao.module.member.enums.ErrorCodeConstants 133 - cn.iocoder.yudao.module.member.enums.ErrorCodeConstants
134 - cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants 134 - cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants
135 - cn.iocoder.yudao.module.system.enums.ErrorCodeConstants 135 - cn.iocoder.yudao.module.system.enums.ErrorCodeConstants
  136 + - cn.iocoder.yudao.module.mp.enums.ErrorCodeConstants
136 tenant: # 多租户相关配置项 137 tenant: # 多租户相关配置项
137 enable: true 138 enable: true
138 ignore-urls: 139 ignore-urls:
@@ -159,6 +160,7 @@ yudao: @@ -159,6 +160,7 @@ yudao:
159 - system_mail_account 160 - system_mail_account
160 - system_mail_template 161 - system_mail_template
161 - system_mail_log 162 - system_mail_log
  163 + - system_notify_template
162 - infra_codegen_column 164 - infra_codegen_column
163 - infra_codegen_table 165 - infra_codegen_table
164 - infra_test_demo 166 - infra_test_demo
yudao-ui-admin-vue3/package.json
1 { 1 {
2 "name": "yudao-ui-admin-vue3", 2 "name": "yudao-ui-admin-vue3",
3 - "version": "1.6.6-snapshot.1925", 3 + "version": "1.7.0-snapshot.1925",
4 "description": "基于vue3、vite4、element-plus、typesScript", 4 "description": "基于vue3、vite4、element-plus、typesScript",
5 "author": "xingyu", 5 "author": "xingyu",
6 "private": false, 6 "private": false,
yudao-ui-admin-vue3/src/api/system/mail/template/index.ts
@@ -21,7 +21,7 @@ export interface MailTemplatePageReqVO extends PageParam { @@ -21,7 +21,7 @@ export interface MailTemplatePageReqVO extends PageParam {
21 createTime?: Date[] 21 createTime?: Date[]
22 } 22 }
23 23
24 -export interface MailSmsReqVO { 24 +export interface MailSendReqVO {
25 mail: string 25 mail: string
26 templateCode: string 26 templateCode: string
27 templateParams: Map<String, Object> 27 templateParams: Map<String, Object>
@@ -53,6 +53,6 @@ export const deleteMailTemplateApi = async (id: number) =&gt; { @@ -53,6 +53,6 @@ export const deleteMailTemplateApi = async (id: number) =&gt; {
53 } 53 }
54 54
55 // 发送邮件 55 // 发送邮件
56 -export const sendMailApi = (data: MailSmsReqVO) => { 56 +export const sendMailApi = (data: MailSendReqVO) => {
57 return request.post({ url: '/system/mail-template/send-mail', data }) 57 return request.post({ url: '/system/mail-template/send-mail', data })
58 } 58 }
yudao-ui-admin-vue3/src/api/system/notify/message/index.ts 0 → 100644
  1 +import request from '@/config/axios'
  2 +import qs from 'qs'
  3 +
  4 +export interface NotifyMessageVO {
  5 + id: number
  6 + userId: number
  7 + userType: number
  8 + templateId: number
  9 + templateCode: string
  10 + templateNickname: string
  11 + templateContent: string
  12 + templateType: number
  13 + templateParams: string
  14 + readStatus: boolean
  15 + readTime: Date
  16 +}
  17 +
  18 +export interface NotifyMessagePageReqVO extends PageParam {
  19 + userId?: number
  20 + userType?: number
  21 + templateCode?: string
  22 + templateType?: number
  23 + createTime?: Date[]
  24 +}
  25 +
  26 +export interface NotifyMessageMyPageReqVO extends PageParam {
  27 + readStatus?: boolean
  28 + createTime?: Date[]
  29 +}
  30 +
  31 +// 查询站内信消息列表
  32 +export const getNotifyMessagePageApi = async (params: NotifyMessagePageReqVO) => {
  33 + return await request.get({ url: '/system/notify-message/page', params })
  34 +}
  35 +
  36 +// 查询站内信消息详情
  37 +export const getNotifyMessageApi = async (id: number) => {
  38 + return await request.get({ url: '/system/notify-message/get?id=' + id })
  39 +}
  40 +
  41 +// 获得我的站内信分页
  42 +export const getMyNotifyMessagePage = async (params: NotifyMessageMyPageReqVO) => {
  43 + return await request.get({ url: '/system/notify-message/my-page', params })
  44 +}
  45 +
  46 +// 批量标记已读
  47 +export const updateNotifyMessageRead = async (ids) => {
  48 + return await request.put({
  49 + url: '/system/notify-message/update-read?' + qs.stringify({ ids: ids }, { indices: false })
  50 + })
  51 +}
  52 +
  53 +// 标记所有站内信为已读
  54 +export const updateAllNotifyMessageRead = async () => {
  55 + return await request.put({ url: '/system/notify-message/update-all-read' })
  56 +}
  57 +
  58 +// 获取当前用户的最新站内信列表
  59 +export const getUnreadNotifyMessageListApi = async () => {
  60 + return await request.get({ url: '/system/notify-message/get-unread-list' })
  61 +}
  62 +
  63 +// 获得当前用户的未读站内信数量
  64 +export const getUnreadNotifyMessageCountApi = async () => {
  65 + return await request.get({ url: '/system/notify-message/get-unread-count' })
  66 +}
yudao-ui-admin-vue3/src/api/system/notify/template/index.ts 0 → 100644
  1 +import request from '@/config/axios'
  2 +
  3 +export interface NotifyTemplateVO {
  4 + id: number
  5 + name: string
  6 + code: string
  7 + content: string
  8 + type: number
  9 + params: string
  10 + status: number
  11 + remark: string
  12 +}
  13 +
  14 +export interface NotifyTemplatePageReqVO extends PageParam {
  15 + name?: string
  16 + code?: string
  17 + status?: number
  18 + createTime?: Date[]
  19 +}
  20 +
  21 +export interface NotifySendReqVO {
  22 + userId: number
  23 + templateCode: string
  24 + templateParams: Map<String, Object>
  25 +}
  26 +
  27 +// 查询站内信模板列表
  28 +export const getNotifyTemplatePageApi = async (params: NotifyTemplatePageReqVO) => {
  29 + return await request.get({ url: '/system/notify-template/page', params })
  30 +}
  31 +
  32 +// 查询站内信模板详情
  33 +export const getNotifyTemplateApi = async (id: number) => {
  34 + return await request.get({ url: '/system/notify-template/get?id=' + id })
  35 +}
  36 +
  37 +// 新增站内信模板
  38 +export const createNotifyTemplateApi = async (data: NotifyTemplateVO) => {
  39 + return await request.post({ url: '/system/notify-template/create', data })
  40 +}
  41 +
  42 +// 修改站内信模板
  43 +export const updateNotifyTemplateApi = async (data: NotifyTemplateVO) => {
  44 + return await request.put({ url: '/system/notify-template/update', data })
  45 +}
  46 +
  47 +// 删除站内信模板
  48 +export const deleteNotifyTemplateApi = async (id: number) => {
  49 + return await request.delete({ url: '/system/notify-template/delete?id=' + id })
  50 +}
  51 +
  52 +// 发送站内信
  53 +export const sendNotifyApi = (data: NotifySendReqVO) => {
  54 + return request.post({ url: '/system/notify-template/send-notify', data })
  55 +}
yudao-ui-admin-vue3/src/hooks/web/useXTable.ts
@@ -7,7 +7,7 @@ export interface tableMethod { @@ -7,7 +7,7 @@ export interface tableMethod {
7 deleteBatch: () => void // 批量删除 7 deleteBatch: () => void // 批量删除
8 exportList: (fileName?: string) => void // 导出列表 8 exportList: (fileName?: string) => void // 导出列表
9 getCurrentColumn: () => void // 获取当前列 9 getCurrentColumn: () => void // 获取当前列
10 - getRadioRecord: () => void // 获取当前选中列,redio 10 + getRadioRecord: () => void // 获取当前选中列,radio
11 getCheckboxRecords: () => void //获取当前选中列, checkbox 11 getCheckboxRecords: () => void //获取当前选中列, checkbox
12 } 12 }
13 13
yudao-ui-admin-vue3/src/layout/components/Message/src/Message.vue
1 <script setup lang="ts"> 1 <script setup lang="ts">
  2 +import dayjs from 'dayjs'
  3 +import * as NotifyMessageApi from '@/api/system/notify/message'
  4 +
  5 +const { push } = useRouter()
2 const activeName = ref('notice') 6 const activeName = ref('notice')
  7 +const unreadCount = ref(0) // 未读消息数量
  8 +const list = ref([]) // 消息列表
  9 +
  10 +// 获得消息列表
  11 +const getList = async () => {
  12 + list.value = await NotifyMessageApi.getUnreadNotifyMessageListApi()
  13 + // 强制设置 unreadCount 为 0,避免小红点因为轮询太慢,不消除
  14 + unreadCount.value = 0
  15 +}
  16 +
  17 +// 获得未读消息数
  18 +const getUnreadCount = async () => {
  19 + NotifyMessageApi.getUnreadNotifyMessageCountApi().then((data) => {
  20 + unreadCount.value = data
  21 + })
  22 +}
  23 +
  24 +// 跳转我的站内信
  25 +const goMyList = () => {
  26 + push({
  27 + name: 'MyNotifyMessage'
  28 + })
  29 +}
3 30
4 -const noticeList = ref([  
5 - { id: 1, title: '版本升级1', date: '2022-12-12 10:00:00' },  
6 - { id: 2, title: '版本升级2', date: '2022-12-12 10:00:00' },  
7 - { id: 3, title: '版本升级3', date: '2022-12-12 10:00:00' },  
8 - { id: 4, title: '版本升级4', date: '2022-12-12 10:00:00' },  
9 - { id: 5, title: '版本升级5', date: '2022-12-12 10:00:00' }  
10 -])  
11 -const messageList = ref([  
12 - { id: 1, title: '加班1', date: '2022-12-12 10:00:00' },  
13 - { id: 2, title: '加班2', date: '2022-12-12 10:00:00' },  
14 - { id: 3, title: '加班3', date: '2022-12-12 10:00:00' },  
15 - { id: 4, title: '加班4', date: '2022-12-12 10:00:00' },  
16 - { id: 5, title: '加班5', date: '2022-12-12 10:00:00' }  
17 -])  
18 -const needList = ref([  
19 - { id: 1, title: '审批1', date: '2022-12-12 10:00:00' },  
20 - { id: 2, title: '审批2', date: '2022-12-12 10:00:00' },  
21 - { id: 3, title: '审批3', date: '2022-12-12 10:00:00' },  
22 - { id: 4, title: '审批4', date: '2022-12-12 10:00:00' },  
23 - { id: 5, title: '审批5', date: '2022-12-12 10:00:00' }  
24 -]) 31 +// ========== 初始化 =========
  32 +onMounted(() => {
  33 + // 首次加载小红点
  34 + getUnreadCount()
  35 + // 轮询刷新小红点
  36 + setInterval(() => {
  37 + getUnreadCount()
  38 + }, 1000 * 60 * 2)
  39 +})
25 </script> 40 </script>
26 <template> 41 <template>
27 <div class="message"> 42 <div class="message">
28 - <ElPopover placement="bottom" :width="310" trigger="click"> 43 + <ElPopover placement="bottom" :width="400" trigger="click">
29 <template #reference> 44 <template #reference>
30 - <ElBadge :value="noticeList.length" class="item">  
31 - <Icon icon="ep:bell" :size="18" class="cursor-pointer" /> 45 + <ElBadge :is-dot="unreadCount > 0" class="item">
  46 + <Icon icon="ep:bell" :size="18" class="cursor-pointer" @click="getList" />
32 </ElBadge> 47 </ElBadge>
33 </template> 48 </template>
34 <ElTabs v-model="activeName"> 49 <ElTabs v-model="activeName">
35 - <ElTabPane label="通知(5)" name="notice">  
36 - <div class="message-list">  
37 - <template v-for="item in noticeList" :key="item.id">  
38 - <div class="message-item">  
39 - <img src="@/assets/imgs/avatar.gif" alt="" class="message-icon" />  
40 - <div class="message-content">  
41 - <span class="message-title">{{ item.title }}</span>  
42 - <span class="message-date">{{ item.date }}</span>  
43 - </div>  
44 - </div>  
45 - </template>  
46 - </div>  
47 - </ElTabPane>  
48 - <ElTabPane label="消息(0)" name="message">  
49 - <div class="message-list">  
50 - <template v-for="item in messageList" :key="item.id">  
51 - <div class="message-item">  
52 - <img src="@/assets/imgs/avatar.gif" alt="" class="message-icon" />  
53 - <div class="message-content">  
54 - <span class="message-title">{{ item.title }}</span>  
55 - <span class="message-date">{{ item.date }}</span>  
56 - </div>  
57 - </div>  
58 - </template>  
59 - </div>  
60 - </ElTabPane>  
61 - <ElTabPane label="代办(0)" name="need"> 50 + <ElTabPane label="我的站内信" name="notice">
62 <div class="message-list"> 51 <div class="message-list">
63 - <template v-for="item in needList" :key="item.id"> 52 + <template v-for="item in list" :key="item.id">
64 <div class="message-item"> 53 <div class="message-item">
65 <img src="@/assets/imgs/avatar.gif" alt="" class="message-icon" /> 54 <img src="@/assets/imgs/avatar.gif" alt="" class="message-icon" />
66 <div class="message-content"> 55 <div class="message-content">
67 - <span class="message-title">{{ item.title }}</span>  
68 - <span class="message-date">{{ item.date }}</span> 56 + <span class="message-title">
  57 + {{ item.templateNickname }}:{{ item.templateContent }}
  58 + </span>
  59 + <span class="message-date">
  60 + {{ dayjs(item.createTime).format('YYYY-MM-DD HH:mm:ss') }}
  61 + </span>
69 </div> 62 </div>
70 </div> 63 </div>
71 </template> 64 </template>
72 </div> 65 </div>
73 </ElTabPane> 66 </ElTabPane>
74 </ElTabs> 67 </ElTabs>
  68 + <!-- 更多 -->
  69 + <div style="text-align: right; margin-top: 10px">
  70 + <XButton type="primary" preIcon="ep:view" title="查看全部" @click="goMyList" />
  71 + </div>
75 </ElPopover> 72 </ElPopover>
76 </div> 73 </div>
77 </template> 74 </template>
yudao-ui-admin-vue3/src/layout/components/UserInfo/src/UserInfo.vue
@@ -41,7 +41,7 @@ const loginOut = () =&gt; { @@ -41,7 +41,7 @@ const loginOut = () =&gt; {
41 .catch(() => {}) 41 .catch(() => {})
42 } 42 }
43 const toProfile = async () => { 43 const toProfile = async () => {
44 - push('/userinfo/profile') 44 + push('/user/profile')
45 } 45 }
46 const toDocument = () => { 46 const toDocument = () => {
47 window.open('https://doc.iocoder.cn/') 47 window.open('https://doc.iocoder.cn/')
yudao-ui-admin-vue3/src/router/modules/remaining.ts
@@ -71,7 +71,7 @@ const remainingRouter: AppRouteRecordRaw[] = [ @@ -71,7 +71,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
71 ] 71 ]
72 }, 72 },
73 { 73 {
74 - path: '/userinfo', 74 + path: '/user',
75 component: Layout, 75 component: Layout,
76 name: 'UserInfo', 76 name: 'UserInfo',
77 meta: { 77 meta: {
@@ -89,6 +89,18 @@ const remainingRouter: AppRouteRecordRaw[] = [ @@ -89,6 +89,18 @@ const remainingRouter: AppRouteRecordRaw[] = [
89 icon: 'ep:user', 89 icon: 'ep:user',
90 title: t('common.profile') 90 title: t('common.profile')
91 } 91 }
  92 + },
  93 + {
  94 + path: 'notify-message',
  95 + component: () => import('@/views/system/notify/my/index.vue'),
  96 + name: 'MyNotifyMessage',
  97 + meta: {
  98 + canTo: true,
  99 + hidden: true,
  100 + noTagsView: false,
  101 + icon: 'ep:message',
  102 + title: '我的站内信'
  103 + }
92 } 104 }
93 ] 105 ]
94 }, 106 },
yudao-ui-admin-vue3/src/utils/dict.ts
@@ -91,6 +91,7 @@ export enum DICT_TYPE { @@ -91,6 +91,7 @@ export enum DICT_TYPE {
91 SYSTEM_ERROR_CODE_TYPE = 'system_error_code_type', 91 SYSTEM_ERROR_CODE_TYPE = 'system_error_code_type',
92 SYSTEM_OAUTH2_GRANT_TYPE = 'system_oauth2_grant_type', 92 SYSTEM_OAUTH2_GRANT_TYPE = 'system_oauth2_grant_type',
93 SYSTEM_MAIL_SEND_STATUS = 'system_mail_send_status', 93 SYSTEM_MAIL_SEND_STATUS = 'system_mail_send_status',
  94 + SYSTEM_NOTIFY_TEMPLATE_TYPE = 'system_notify_template_type',
94 95
95 // ========== INFRA 模块 ========== 96 // ========== INFRA 模块 ==========
96 INFRA_BOOLEAN_STRING = 'infra_boolean_string', 97 INFRA_BOOLEAN_STRING = 'infra_boolean_string',
yudao-ui-admin-vue3/src/views/system/mail/template/index.vue
@@ -252,7 +252,7 @@ const handleSendMail = (row: any) =&gt; { @@ -252,7 +252,7 @@ const handleSendMail = (row: any) =&gt; {
252 } 252 }
253 253
254 const sendTest = async () => { 254 const sendTest = async () => {
255 - const data: MailTemplateApi.MailSmsReqVO = { 255 + const data: MailTemplateApi.MailSendReqVO = {
256 mail: sendForm.value.mail, 256 mail: sendForm.value.mail,
257 templateCode: sendForm.value.templateCode, 257 templateCode: sendForm.value.templateCode,
258 templateParams: sendForm.value.templateParams as unknown as Map<string, Object> 258 templateParams: sendForm.value.templateParams as unknown as Map<string, Object>
yudao-ui-admin-vue3/src/views/system/notify/message/index.vue 0 → 100644
  1 +<template>
  2 + <ContentWrap>
  3 + <!-- 列表 -->
  4 + <XTable @register="registerTable">
  5 + <template #actionbtns_default="{ row }">
  6 + <!-- 操作:详情 -->
  7 + <XTextButton
  8 + preIcon="ep:view"
  9 + :title="t('action.detail')"
  10 + v-hasPermi="['system:notify-message:query']"
  11 + @click="handleDetail(row.id)"
  12 + />
  13 + </template>
  14 + </XTable>
  15 + </ContentWrap>
  16 + <!-- 弹窗 -->
  17 + <XModal id="messageModel" :loading="modelLoading" v-model="modelVisible" :title="modelTitle">
  18 + <!-- 表单:详情 -->
  19 + <Descriptions
  20 + v-if="actionType === 'detail'"
  21 + :schema="allSchemas.detailSchema"
  22 + :data="detailData"
  23 + />
  24 + <template #footer>
  25 + <!-- 按钮:关闭 -->
  26 + <XButton :loading="actionLoading" :title="t('dialog.close')" @click="modelVisible = false" />
  27 + </template>
  28 + </XModal>
  29 +</template>
  30 +<script setup lang="ts" name="NotifyMessage">
  31 +// 业务相关的 import
  32 +import { allSchemas } from './message.data'
  33 +import * as NotifyMessageApi from '@/api/system/notify/message'
  34 +
  35 +const { t } = useI18n() // 国际化
  36 +
  37 +// 列表相关的变量
  38 +const [registerTable] = useXTable({
  39 + allSchemas: allSchemas,
  40 + getListApi: NotifyMessageApi.getNotifyMessagePageApi
  41 +})
  42 +
  43 +// 弹窗相关的变量
  44 +const modelVisible = ref(false) // 是否显示弹出层
  45 +const modelTitle = ref('edit') // 弹出层标题
  46 +const modelLoading = ref(false) // 弹出层loading
  47 +const actionType = ref('') // 操作按钮的类型
  48 +const actionLoading = ref(false) // 按钮 Loading
  49 +const detailData = ref() // 详情 Ref
  50 +
  51 +// 设置标题
  52 +const setDialogTile = (type: string) => {
  53 + modelLoading.value = true
  54 + modelTitle.value = t('action.' + type)
  55 + actionType.value = type
  56 + modelVisible.value = true
  57 +}
  58 +
  59 +// 详情操作
  60 +const handleDetail = async (rowId: number) => {
  61 + setDialogTile('detail')
  62 + const res = await NotifyMessageApi.getNotifyMessageApi(rowId)
  63 + detailData.value = res
  64 + modelLoading.value = false
  65 +}
  66 +</script>
yudao-ui-admin-vue3/src/views/system/notify/message/message.data.ts 0 → 100644
  1 +import type { VxeCrudSchema } from '@/hooks/web/useVxeCrudSchemas'
  2 +
  3 +// CrudSchema
  4 +const crudSchemas = reactive<VxeCrudSchema>({
  5 + primaryKey: 'id', // 默认的主键ID
  6 + primaryTitle: '编号', // 默认显示的值
  7 + primaryType: 'seq', // 默认为seq,序号模式
  8 + action: true,
  9 + actionWidth: '200', // 3个按钮默认200,如有删减对应增减即可
  10 + columns: [
  11 + {
  12 + title: '用户编号',
  13 + field: 'userId',
  14 + isSearch: true
  15 + },
  16 + {
  17 + title: '用户类型',
  18 + field: 'userType',
  19 + dictType: DICT_TYPE.USER_TYPE,
  20 + dictClass: 'string',
  21 + isSearch: true,
  22 + table: {
  23 + width: 80
  24 + }
  25 + },
  26 + {
  27 + title: '模版编号',
  28 + field: 'templateId'
  29 + },
  30 + {
  31 + title: '模板编码',
  32 + field: 'templateCode',
  33 + isSearch: true,
  34 + table: {
  35 + width: 80
  36 + }
  37 + },
  38 + {
  39 + title: '发送人名称',
  40 + field: 'templateNickname',
  41 + table: {
  42 + width: 120
  43 + }
  44 + },
  45 + {
  46 + title: '模版内容',
  47 + field: 'templateContent',
  48 + table: {
  49 + width: 200
  50 + }
  51 + },
  52 + {
  53 + title: '模版类型',
  54 + field: 'templateType',
  55 + dictType: DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE,
  56 + dictClass: 'number',
  57 + isSearch: true,
  58 + table: {
  59 + width: 80
  60 + }
  61 + },
  62 + {
  63 + title: '模版参数',
  64 + field: 'templateParams',
  65 + isTable: false
  66 + },
  67 + {
  68 + title: '是否已读',
  69 + field: 'readStatus',
  70 + dictType: DICT_TYPE.INFRA_BOOLEAN_STRING,
  71 + dictClass: 'boolean',
  72 + table: {
  73 + width: 80
  74 + }
  75 + },
  76 + {
  77 + title: '阅读时间',
  78 + field: 'readTime',
  79 + formatter: 'formatDate',
  80 + table: {
  81 + width: 180
  82 + }
  83 + },
  84 + {
  85 + title: '创建时间',
  86 + field: 'createTime',
  87 + isForm: false,
  88 + formatter: 'formatDate',
  89 + search: {
  90 + show: true,
  91 + itemRender: {
  92 + name: 'XDataTimePicker'
  93 + }
  94 + },
  95 + table: {
  96 + width: 180
  97 + }
  98 + }
  99 + ]
  100 +})
  101 +export const { allSchemas } = useVxeCrudSchemas(crudSchemas)
yudao-ui-admin-vue3/src/views/system/notify/my/index.vue 0 → 100644
  1 +<template>
  2 + <ContentWrap>
  3 + <!-- 列表 -->
  4 + <XTable @register="registerTable">
  5 + <template #toolbar_buttons>
  6 + <!-- 操作:标记已读 -->
  7 + <XButton type="primary" preIcon="ep:zoom-in" title="标记已读" @click="handleUpdateList" />
  8 + <!-- 操作:全部已读 -->
  9 + <XButton type="primary" preIcon="ep:zoom-in" title="全部已读" @click="handleUpdateAll" />
  10 + </template>
  11 + <template #actionbtns_default="{ row }">
  12 + <!-- 操作:已读 -->
  13 + <XTextButton
  14 + preIcon="ep:view"
  15 + title="已读"
  16 + v-hasPermi="['system:notify-message:query']"
  17 + v-if="!row.readStatus"
  18 + @click="handleUpdate([row.id])"
  19 + />
  20 + </template>
  21 + </XTable>
  22 + </ContentWrap>
  23 +</template>
  24 +<script setup lang="ts" name="MyNotifyMessage">
  25 +// 业务相关的 import
  26 +import { allSchemas } from './my.data'
  27 +import * as NotifyMessageApi from '@/api/system/notify/message'
  28 +
  29 +const message = useMessage() // 消息
  30 +
  31 +// 列表相关的变量
  32 +const [registerTable, { reload, getCheckboxRecords }] = useXTable({
  33 + allSchemas: allSchemas,
  34 + getListApi: NotifyMessageApi.getMyNotifyMessagePage
  35 +})
  36 +
  37 +const handleUpdateList = async () => {
  38 + const list = getCheckboxRecords()
  39 + if (list.length === 0) {
  40 + return
  41 + }
  42 + await handleUpdate(list.map((v) => v.id))
  43 +}
  44 +
  45 +// 标记指定 id 已读
  46 +const handleUpdate = async (ids) => {
  47 + await NotifyMessageApi.updateNotifyMessageRead(ids)
  48 + message.success('标记已读成功!')
  49 + reload()
  50 +}
  51 +
  52 +// 标记全部已读
  53 +const handleUpdateAll = async () => {
  54 + await NotifyMessageApi.updateAllNotifyMessageRead()
  55 + message.success('全部已读成功!')
  56 + reload()
  57 +}
  58 +</script>
yudao-ui-admin-vue3/src/views/system/notify/my/my.data.ts 0 → 100644
  1 +import type { VxeCrudSchema } from '@/hooks/web/useVxeCrudSchemas'
  2 +
  3 +// CrudSchema
  4 +const crudSchemas = reactive<VxeCrudSchema>({
  5 + primaryKey: 'id',
  6 + primaryTitle: ' ',
  7 + primaryType: 'checkbox',
  8 + action: true,
  9 + actionWidth: '200', // 3个按钮默认200,如有删减对应增减即可
  10 + columns: [
  11 + {
  12 + title: '发送人名称',
  13 + field: 'templateNickname',
  14 + table: {
  15 + width: 120
  16 + }
  17 + },
  18 + {
  19 + title: '发送时间',
  20 + field: 'createTime',
  21 + isForm: false,
  22 + formatter: 'formatDate',
  23 + search: {
  24 + show: true,
  25 + itemRender: {
  26 + name: 'XDataTimePicker'
  27 + }
  28 + },
  29 + table: {
  30 + width: 180
  31 + }
  32 + },
  33 + {
  34 + title: '类型',
  35 + field: 'templateType',
  36 + dictType: DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE,
  37 + dictClass: 'number',
  38 + table: {
  39 + width: 80
  40 + }
  41 + },
  42 + {
  43 + title: '内容',
  44 + field: 'templateContent'
  45 + },
  46 + {
  47 + title: '是否已读',
  48 + field: 'readStatus',
  49 + dictType: DICT_TYPE.INFRA_BOOLEAN_STRING,
  50 + dictClass: 'boolean',
  51 + table: {
  52 + width: 80
  53 + },
  54 + isSearch: true
  55 + }
  56 + ]
  57 +})
  58 +export const { allSchemas } = useVxeCrudSchemas(crudSchemas)
yudao-ui-admin-vue3/src/views/system/notify/template/index.vue 0 → 100644
  1 +<template>
  2 + <ContentWrap>
  3 + <!-- 列表 -->
  4 + <XTable @register="registerTable">
  5 + <template #toolbar_buttons>
  6 + <!-- 操作:新增 -->
  7 + <XButton
  8 + type="primary"
  9 + preIcon="ep:zoom-in"
  10 + :title="t('action.add')"
  11 + v-hasPermi="['system:notify-template:create']"
  12 + @click="handleCreate()"
  13 + />
  14 + </template>
  15 + <template #actionbtns_default="{ row }">
  16 + <!-- 操作:测试站内信 -->
  17 + <XTextButton
  18 + preIcon="ep:cpu"
  19 + :title="t('action.test')"
  20 + v-hasPermi="['system:notify-template:send-notify']"
  21 + @click="handleSendNotify(row)"
  22 + />
  23 + <!-- 操作:修改 -->
  24 + <XTextButton
  25 + preIcon="ep:edit"
  26 + :title="t('action.edit')"
  27 + v-hasPermi="['system:notify-template:update']"
  28 + @click="handleUpdate(row.id)"
  29 + />
  30 + <!-- 操作:详情 -->
  31 + <XTextButton
  32 + preIcon="ep:view"
  33 + :title="t('action.detail')"
  34 + v-hasPermi="['system:notify-template:query']"
  35 + @click="handleDetail(row.id)"
  36 + />
  37 + <!-- 操作:删除 -->
  38 + <XTextButton
  39 + preIcon="ep:delete"
  40 + :title="t('action.del')"
  41 + v-hasPermi="['system:notify-template:delete']"
  42 + @click="deleteData(row.id)"
  43 + />
  44 + </template>
  45 + </XTable>
  46 + </ContentWrap>
  47 +
  48 + <!-- 添加/修改的弹窗 -->
  49 + <XModal id="templateModel" :loading="modelLoading" v-model="modelVisible" :title="modelTitle">
  50 + <!-- 表单:添加/修改 -->
  51 + <Form
  52 + ref="formRef"
  53 + v-if="['create', 'update'].includes(actionType)"
  54 + :schema="allSchemas.formSchema"
  55 + :rules="rules"
  56 + />
  57 + <!-- 表单:详情 -->
  58 + <Descriptions
  59 + v-if="actionType === 'detail'"
  60 + :schema="allSchemas.detailSchema"
  61 + :data="detailData"
  62 + />
  63 + <template #footer>
  64 + <!-- 按钮:保存 -->
  65 + <XButton
  66 + v-if="['create', 'update'].includes(actionType)"
  67 + type="primary"
  68 + :title="t('action.save')"
  69 + :loading="actionLoading"
  70 + @click="submitForm()"
  71 + />
  72 + <!-- 按钮:关闭 -->
  73 + <XButton :loading="actionLoading" :title="t('dialog.close')" @click="modelVisible = false" />
  74 + </template>
  75 + </XModal>
  76 +
  77 + <!-- 测试站内信的弹窗 -->
  78 + <XModal id="sendTest" v-model="sendVisible" title="测试">
  79 + <el-form :model="sendForm" :rules="sendRules" label-width="200px" label-position="top">
  80 + <el-form-item label="模板内容" prop="content">
  81 + <el-input type="textarea" v-model="sendForm.content" readonly />
  82 + </el-form-item>
  83 + <el-form-item label="接收人" prop="userId">
  84 + <el-select v-model="sendForm.userId" placeholder="请选择接收人">
  85 + <el-option
  86 + v-for="item in userOption"
  87 + :key="item.id"
  88 + :label="item.nickname"
  89 + :value="item.id"
  90 + />
  91 + </el-select>
  92 + </el-form-item>
  93 + <el-form-item
  94 + v-for="param in sendForm.params"
  95 + :key="param"
  96 + :label="'参数 {' + param + '}'"
  97 + :prop="'templateParams.' + param"
  98 + >
  99 + <el-input
  100 + v-model="sendForm.templateParams[param]"
  101 + :placeholder="'请输入 ' + param + ' 参数'"
  102 + />
  103 + </el-form-item>
  104 + </el-form>
  105 + <!-- 操作按钮 -->
  106 + <template #footer>
  107 + <XButton
  108 + type="primary"
  109 + :title="t('action.test')"
  110 + :loading="actionLoading"
  111 + @click="sendTest()"
  112 + />
  113 + <XButton :title="t('dialog.close')" @click="sendVisible = false" />
  114 + </template>
  115 + </XModal>
  116 +</template>
  117 +<script setup lang="ts" name="NotifyTemplate">
  118 +import { FormExpose } from '@/components/Form'
  119 +// 业务相关的 import
  120 +import { rules, allSchemas } from './template.data'
  121 +import * as NotifyTemplateApi from '@/api/system/notify/template'
  122 +import { getListSimpleUsersApi, UserVO } from '@/api/system/user'
  123 +
  124 +const { t } = useI18n() // 国际化
  125 +const message = useMessage() // 消息弹窗
  126 +
  127 +// 列表相关的变量
  128 +const [registerTable, { reload, deleteData }] = useXTable({
  129 + allSchemas: allSchemas,
  130 + getListApi: NotifyTemplateApi.getNotifyTemplatePageApi,
  131 + deleteApi: NotifyTemplateApi.deleteNotifyTemplateApi
  132 +})
  133 +
  134 +// 弹窗相关的变量
  135 +const modelVisible = ref(false) // 是否显示弹出层
  136 +const modelTitle = ref('edit') // 弹出层标题
  137 +const modelLoading = ref(false) // 弹出层loading
  138 +const actionType = ref('') // 操作按钮的类型
  139 +const actionLoading = ref(false) // 按钮 Loading
  140 +const formRef = ref<FormExpose>() // 表单 Ref
  141 +const detailData = ref() // 详情 Ref
  142 +
  143 +// 设置标题
  144 +const setDialogTile = (type: string) => {
  145 + modelLoading.value = true
  146 + modelTitle.value = t('action.' + type)
  147 + actionType.value = type
  148 + modelVisible.value = true
  149 +}
  150 +
  151 +// 新增操作
  152 +const handleCreate = () => {
  153 + setDialogTile('create')
  154 + modelLoading.value = false
  155 +}
  156 +
  157 +// 修改操作
  158 +const handleUpdate = async (rowId: number) => {
  159 + setDialogTile('update')
  160 + // 设置数据
  161 + const res = await NotifyTemplateApi.getNotifyTemplateApi(rowId)
  162 + unref(formRef)?.setValues(res)
  163 + modelLoading.value = false
  164 +}
  165 +
  166 +// 详情操作
  167 +const handleDetail = async (rowId: number) => {
  168 + setDialogTile('detail')
  169 + const res = await NotifyTemplateApi.getNotifyTemplateApi(rowId)
  170 + detailData.value = res
  171 + modelLoading.value = false
  172 +}
  173 +
  174 +// 提交按钮
  175 +const submitForm = async () => {
  176 + const elForm = unref(formRef)?.getElFormRef()
  177 + if (!elForm) return
  178 + elForm.validate(async (valid) => {
  179 + if (valid) {
  180 + actionLoading.value = true
  181 + // 提交请求
  182 + try {
  183 + const data = unref(formRef)?.formModel as NotifyTemplateApi.NotifyTemplateVO
  184 + if (actionType.value === 'create') {
  185 + await NotifyTemplateApi.createNotifyTemplateApi(data)
  186 + message.success(t('common.createSuccess'))
  187 + } else {
  188 + await NotifyTemplateApi.updateNotifyTemplateApi(data)
  189 + message.success(t('common.updateSuccess'))
  190 + }
  191 + modelVisible.value = false
  192 + } finally {
  193 + actionLoading.value = false
  194 + // 刷新列表
  195 + await reload()
  196 + }
  197 + }
  198 + })
  199 +}
  200 +
  201 +// ========== 测试相关 ==========
  202 +const sendForm = ref({
  203 + content: '',
  204 + params: {},
  205 + userId: undefined,
  206 + templateCode: '',
  207 + templateParams: {}
  208 +})
  209 +const sendRules = ref({
  210 + userId: [{ required: true, message: '用户编号不能为空', trigger: 'blur' }],
  211 + templateCode: [{ required: true, message: '模版编号不能为空', trigger: 'blur' }],
  212 + templateParams: {}
  213 +})
  214 +const sendVisible = ref(false)
  215 +const userOption = ref<UserVO[]>([])
  216 +
  217 +const handleSendNotify = (row: any) => {
  218 + sendForm.value.content = row.content
  219 + sendForm.value.params = row.params
  220 + sendForm.value.templateCode = row.code
  221 + sendForm.value.templateParams = row.params.reduce(function (obj, item) {
  222 + obj[item] = undefined
  223 + return obj
  224 + }, {})
  225 + sendRules.value.templateParams = row.params.reduce(function (obj, item) {
  226 + obj[item] = { required: true, message: '参数 ' + item + ' 不能为空', trigger: 'change' }
  227 + return obj
  228 + }, {})
  229 + sendVisible.value = true
  230 +}
  231 +
  232 +const sendTest = async () => {
  233 + const data: NotifyTemplateApi.NotifySendReqVO = {
  234 + userId: sendForm.value.userId,
  235 + templateCode: sendForm.value.templateCode,
  236 + templateParams: sendForm.value.templateParams as unknown as Map<string, Object>
  237 + }
  238 + const res = await NotifyTemplateApi.sendNotifyApi(data)
  239 + if (res) {
  240 + message.success('提交发送成功!发送结果,见发送日志编号:' + res)
  241 + }
  242 + sendVisible.value = false
  243 +}
  244 +
  245 +// ========== 初始化 ==========
  246 +onMounted(() => {
  247 + getListSimpleUsersApi().then((data) => {
  248 + userOption.value = data
  249 + })
  250 +})
  251 +</script>
yudao-ui-admin-vue3/src/views/system/notify/template/template.data.ts 0 → 100644
  1 +import type { VxeCrudSchema } from '@/hooks/web/useVxeCrudSchemas'
  2 +
  3 +// 表单校验
  4 +export const rules = reactive({
  5 + name: [required],
  6 + code: [required],
  7 + content: [required],
  8 + type: [required],
  9 + status: [required]
  10 +})
  11 +
  12 +// CrudSchema
  13 +const crudSchemas = reactive<VxeCrudSchema>({
  14 + primaryKey: 'id',
  15 + primaryTitle: '编号',
  16 + primaryType: null,
  17 + action: true,
  18 + actionWidth: '260', // 3个按钮默认200,如有删减对应增减即可
  19 + columns: [
  20 + {
  21 + title: '模版编码',
  22 + field: 'code',
  23 + isSearch: true
  24 + },
  25 + {
  26 + title: '模板名称',
  27 + field: 'name',
  28 + isSearch: true
  29 + },
  30 + {
  31 + title: '发件人名称',
  32 + field: 'nickname'
  33 + },
  34 + {
  35 + title: '类型',
  36 + field: 'type',
  37 + dictType: DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE,
  38 + dictClass: 'number'
  39 + },
  40 + {
  41 + title: '模版内容',
  42 + field: 'content',
  43 + table: {
  44 + width: 300
  45 + },
  46 + form: {
  47 + component: 'Input',
  48 + componentProps: {
  49 + type: 'textarea',
  50 + rows: 4
  51 + },
  52 + colProps: {
  53 + span: 24
  54 + }
  55 + }
  56 + },
  57 + {
  58 + title: '状态',
  59 + field: 'status',
  60 + dictType: DICT_TYPE.COMMON_STATUS,
  61 + dictClass: 'number',
  62 + isSearch: true
  63 + },
  64 + {
  65 + title: '备注',
  66 + field: 'remark'
  67 + },
  68 + {
  69 + title: '创建时间',
  70 + field: 'createTime',
  71 + isForm: false,
  72 + formatter: 'formatDate',
  73 + search: {
  74 + show: true,
  75 + itemRender: {
  76 + name: 'XDataTimePicker'
  77 + }
  78 + },
  79 + table: {
  80 + width: 180
  81 + }
  82 + }
  83 + ]
  84 +})
  85 +export const { allSchemas } = useVxeCrudSchemas(crudSchemas)
yudao-ui-admin/package.json
1 { 1 {
2 "name": "yudao-ui-admin", 2 "name": "yudao-ui-admin",
3 - "version": "1.6.6-snapshot", 3 + "version": "1.7.0-snapshot",
4 "description": "芋道管理系统", 4 "description": "芋道管理系统",
5 "author": "芋道", 5 "author": "芋道",
6 "license": "MIT", 6 "license": "MIT",
yudao-ui-admin/src/api/system/notify/message.js 0 → 100644
  1 +import request from '@/utils/request'
  2 +import qs from 'qs'
  3 +
  4 +// 获得我的站内信分页
  5 +export function getNotifyMessagePage(query) {
  6 + return request({
  7 + url: '/system/notify-message/page',
  8 + method: 'get',
  9 + params: query
  10 + })
  11 +}
  12 +
  13 +// 获得我的站内信分页
  14 +export function getMyNotifyMessagePage(query) {
  15 + return request({
  16 + url: '/system/notify-message/my-page',
  17 + method: 'get',
  18 + params: query
  19 + })
  20 +}
  21 +
  22 +// 批量标记已读
  23 +export function updateNotifyMessageRead(ids) {
  24 + return request({
  25 + url: '/system/notify-message/update-read?' + qs.stringify({ids: ids}, { indices: false }),
  26 + method: 'put'
  27 + })
  28 +}
  29 +
  30 +// 标记所有站内信为已读
  31 +export function updateAllNotifyMessageRead() {
  32 + return request({
  33 + url: '/system/notify-message/update-all-read',
  34 + method: 'put'
  35 + })
  36 +}
  37 +
  38 +// 获取当前用户的最新站内信列表
  39 +export function getUnreadNotifyMessageList() {
  40 + return request({
  41 + url: '/system/notify-message/get-unread-list',
  42 + method: 'get'
  43 + })
  44 +}
  45 +
  46 +// 获得当前用户的未读站内信数量
  47 +export function getUnreadNotifyMessageCount() {
  48 + return request({
  49 + url: '/system/notify-message/get-unread-count',
  50 + method: 'get'
  51 + })
  52 +}
yudao-ui-admin/src/api/system/notify/template.js 0 → 100644
  1 +import request from '@/utils/request'
  2 +
  3 +// 创建站内信模板
  4 +export function createNotifyTemplate(data) {
  5 + return request({
  6 + url: '/system/notify-template/create',
  7 + method: 'post',
  8 + data: data
  9 + })
  10 +}
  11 +
  12 +// 更新站内信模板
  13 +export function updateNotifyTemplate(data) {
  14 + return request({
  15 + url: '/system/notify-template/update',
  16 + method: 'put',
  17 + data: data
  18 + })
  19 +}
  20 +
  21 +// 删除站内信模板
  22 +export function deleteNotifyTemplate(id) {
  23 + return request({
  24 + url: '/system/notify-template/delete?id=' + id,
  25 + method: 'delete'
  26 + })
  27 +}
  28 +
  29 +// 获得站内信模板
  30 +export function getNotifyTemplate(id) {
  31 + return request({
  32 + url: '/system/notify-template/get?id=' + id,
  33 + method: 'get'
  34 + })
  35 +}
  36 +
  37 +// 获得站内信模板分页
  38 +export function getNotifyTemplatePage(query) {
  39 + return request({
  40 + url: '/system/notify-template/page',
  41 + method: 'get',
  42 + params: query
  43 + })
  44 +}
  45 +
  46 +// 创建站内信模板
  47 +export function sendNotify(data) {
  48 + return request({
  49 + url: '/system/notify-template/send-notify',
  50 + method: 'post',
  51 + data: data
  52 + })
  53 +}
  54 +
  55 +// 导出站内信模板 Excel
  56 +export function exportNotifyTemplateExcel(query) {
  57 + return request({
  58 + url: '/system/notify-template/export-excel',
  59 + method: 'get',
  60 + params: query,
  61 + responseType: 'blob'
  62 + })
  63 +}
  64 +
yudao-ui-admin/src/components/DocAlert/index.vue
1 <template> 1 <template>
2 - <el-alert v-if="enable()" :title="'【' + title + '】文档地址:' + url" type="success" show-icon /> 2 + <el-alert v-if="enable()" type="success" show-icon>
  3 + <template slot="title">
  4 + <div @click="goToUrl">{{ '【' + title + '】文档地址:' + url }}</div>
  5 + </template>
  6 + </el-alert>
3 </template> 7 </template>
4 8
5 <script> 9 <script>
@@ -14,6 +18,9 @@ export default { @@ -14,6 +18,9 @@ export default {
14 methods: { 18 methods: {
15 enable: function () { 19 enable: function () {
16 return getDocEnable(); 20 return getDocEnable();
  21 + },
  22 + goToUrl: function() {
  23 + window.open(this.url);
17 } 24 }
18 } 25 }
19 }; 26 };
yudao-ui-admin/src/components/RuoYi/Doc/index.vue
@@ -9,7 +9,7 @@ export default { @@ -9,7 +9,7 @@ export default {
9 name: 'YudaoDoc', 9 name: 'YudaoDoc',
10 data() { 10 data() {
11 return { 11 return {
12 - url: 'http://www.iocoder.cn/Yudao/build-debugger-environment/?yudao' 12 + url: 'https://doc.iocoder.cn/'
13 } 13 }
14 }, 14 },
15 methods: { 15 methods: {
yudao-ui-admin/src/layout/components/Message/index.vue 0 → 100644
  1 +<template>
  2 + <div>
  3 + <el-popover placement="bottom" width="600" trigger="click">
  4 + <!-- icon 展示 -->
  5 + <el-badge slot="reference" :is-dot="unreadCount > 0" type="danger">
  6 + <svg-icon icon-class="message" @click="getList"/>
  7 + </el-badge>
  8 +
  9 + <!-- 弹出列表 -->
  10 + <el-table v-loading="loading" :data="list">
  11 + <el-table-column width="120" property="templateNickname" label="发送人" />
  12 + <el-table-column width="180" property="createTime" label="发送时间">
  13 + <template slot-scope="scope">
  14 + <span>{{ parseTime(scope.row.createTime) }}</span>
  15 + </template>
  16 + </el-table-column>
  17 + <el-table-column label="类型" align="center" prop="templateType" width="100">
  18 + <template v-slot="scope">
  19 + <dict-tag :type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE" :value="scope.row.templateType" />
  20 + </template>
  21 + </el-table-column>
  22 + <el-table-column property="templateContent" label="内容" />
  23 + </el-table>
  24 +
  25 + <!-- 更多 -->
  26 + <div style="text-align: right; margin-top: 10px">
  27 + <el-button type="primary" size="mini" @click="goMyList">查看全部</el-button>
  28 + </div>
  29 + </el-popover>
  30 + </div>
  31 +</template>
  32 +
  33 +<script>
  34 +import {getUnreadNotifyMessageCount, getUnreadNotifyMessageList} from "@/api/system/notify/message";
  35 +
  36 +export default {
  37 + name: 'NotifyMessage',
  38 + data() {
  39 + return {
  40 + // 遮罩层
  41 + loading: false,
  42 + // 列表
  43 + list: [],
  44 + // 未读数量,
  45 + unreadCount: 0,
  46 + }
  47 + },
  48 + created() {
  49 + // 首次加载小红点
  50 + this.getUnreadCount()
  51 + // 轮询刷新小红点
  52 + setInterval(() => {
  53 + this.getUnreadCount()
  54 + },1000 * 60 * 2)
  55 + },
  56 + methods: {
  57 + getList: function() {
  58 + this.loading = true;
  59 + getUnreadNotifyMessageList().then(response => {
  60 + this.list = response.data;
  61 + this.loading = false;
  62 + // 强制设置 unreadCount 为 0,避免小红点因为轮询太慢,不消除
  63 + this.unreadCount = 0
  64 + });
  65 + },
  66 + getUnreadCount: function() {
  67 + getUnreadNotifyMessageCount().then(response => {
  68 + this.unreadCount = response.data;
  69 + })
  70 + },
  71 + goMyList: function() {
  72 + this.$router.push({
  73 + name: 'MyNotifyMessage'
  74 + });
  75 + }
  76 + }
  77 +}
  78 +</script>
  79 +<style>
  80 +.el-badge__content.is-fixed {
  81 + top: 10px; /* 保证徽章的位置 */
  82 +}
  83 +</style>
yudao-ui-admin/src/layout/components/Navbar.vue
@@ -9,6 +9,9 @@ @@ -9,6 +9,9 @@
9 <template v-if="device!=='mobile'"> 9 <template v-if="device!=='mobile'">
10 <search id="header-search" class="right-menu-item" /> 10 <search id="header-search" class="right-menu-item" />
11 11
  12 + <!-- 站内信 -->
  13 + <notify-message class="right-menu-item hover-effect" />
  14 +
12 <el-tooltip content="源码地址" effect="dark" placement="bottom"> 15 <el-tooltip content="源码地址" effect="dark" placement="bottom">
13 <ruo-yi-git id="ruoyi-git" class="right-menu-item hover-effect" /> 16 <ruo-yi-git id="ruoyi-git" class="right-menu-item hover-effect" />
14 </el-tooltip> 17 </el-tooltip>
@@ -57,6 +60,7 @@ import SizeSelect from &#39;@/components/SizeSelect&#39; @@ -57,6 +60,7 @@ import SizeSelect from &#39;@/components/SizeSelect&#39;
57 import Search from '@/components/HeaderSearch' 60 import Search from '@/components/HeaderSearch'
58 import RuoYiGit from '@/components/RuoYi/Git' 61 import RuoYiGit from '@/components/RuoYi/Git'
59 import RuoYiDoc from '@/components/RuoYi/Doc' 62 import RuoYiDoc from '@/components/RuoYi/Doc'
  63 +import NotifyMessage from '@/layout/components/Message'
60 import {getPath} from "@/utils/ruoyi"; 64 import {getPath} from "@/utils/ruoyi";
61 65
62 export default { 66 export default {
@@ -68,7 +72,8 @@ export default { @@ -68,7 +72,8 @@ export default {
68 SizeSelect, 72 SizeSelect,
69 Search, 73 Search,
70 RuoYiGit, 74 RuoYiGit,
71 - RuoYiDoc 75 + RuoYiDoc,
  76 + NotifyMessage
72 }, 77 },
73 computed: { 78 computed: {
74 ...mapGetters([ 79 ...mapGetters([
yudao-ui-admin/src/router/index.js
@@ -75,7 +75,8 @@ export const constantRoutes = [ @@ -75,7 +75,8 @@ export const constantRoutes = [
75 meta: {title: '首页', icon: 'dashboard', affix: true} 75 meta: {title: '首页', icon: 'dashboard', affix: true}
76 } 76 }
77 ] 77 ]
78 - }, { 78 + },
  79 + {
79 path: '/user', 80 path: '/user',
80 component: Layout, 81 component: Layout,
81 hidden: true, 82 hidden: true,
@@ -85,9 +86,14 @@ export const constantRoutes = [ @@ -85,9 +86,14 @@ export const constantRoutes = [
85 component: (resolve) => require(['@/views/system/user/profile/index'], resolve), 86 component: (resolve) => require(['@/views/system/user/profile/index'], resolve),
86 name: 'Profile', 87 name: 'Profile',
87 meta: {title: '个人中心', icon: 'user'} 88 meta: {title: '个人中心', icon: 'user'}
88 - }  
89 - ]  
90 - }, { 89 + }, {
  90 + path: 'notify-message',
  91 + component: (resolve) => require(['@/views/system/notify/my/index'], resolve),
  92 + name: 'MyNotifyMessage',
  93 + meta: { title: '我的站内信', icon: 'message' },
  94 + }]
  95 + },
  96 + {
91 path: '/dict', 97 path: '/dict',
92 component: Layout, 98 component: Layout,
93 hidden: true, 99 hidden: true,
@@ -98,18 +104,8 @@ export const constantRoutes = [ @@ -98,18 +104,8 @@ export const constantRoutes = [
98 meta: {title: '字典数据', icon: '', activeMenu: '/system/dict'} 104 meta: {title: '字典数据', icon: '', activeMenu: '/system/dict'}
99 } 105 }
100 ] 106 ]
101 - }, {  
102 - path: '/property',  
103 - component: Layout,  
104 - hidden: true,  
105 - children: [{  
106 - path: 'value/:propertyId(\\d+)',  
107 - component: (resolve) => require(['@/views/mall/product/property/value'], resolve),  
108 - name: 'PropertyValue',  
109 - meta: {title: '商品属性值', icon: '', activeMenu: '/product/property'}  
110 - }  
111 - ]  
112 - }, { 107 + },
  108 + {
113 path: '/job', 109 path: '/job',
114 component: Layout, 110 component: Layout,
115 hidden: true, 111 hidden: true,
@@ -131,24 +127,8 @@ export const constantRoutes = [ @@ -131,24 +127,8 @@ export const constantRoutes = [
131 meta: {title: '修改生成配置', activeMenu: '/infra/codegen'} 127 meta: {title: '修改生成配置', activeMenu: '/infra/codegen'}
132 } 128 }
133 ] 129 ]
134 - }, {  
135 - path: '/spu',  
136 - component: Layout,  
137 - hidden: true,  
138 - children: [{  
139 - path: 'edit/:spuId(\\d+)',  
140 - component: (resolve) => require(['@/views/mall/product/spu/save'], resolve),  
141 - name: 'SpuEdit',  
142 - meta: {title: '修改商品', activeMenu: '/product/spu'}  
143 - },  
144 - {  
145 - path: 'add',  
146 - component: (resolve) => require(['@/views/mall/product/spu/save'], resolve),  
147 - name: 'SpuAdd',  
148 - meta: {title: '添加商品', activeMenu: '/product/spu'}  
149 - }  
150 - ]  
151 - }, { 130 + },
  131 + {
152 path: '/bpm', 132 path: '/bpm',
153 component: Layout, 133 component: Layout,
154 hidden: true, 134 hidden: true,
@@ -165,7 +145,8 @@ export const constantRoutes = [ @@ -165,7 +145,8 @@ export const constantRoutes = [
165 meta: {title: '查看 OA 请假', icon: 'view', activeMenu: '/bpm/oa/leave'} 145 meta: {title: '查看 OA 请假', icon: 'view', activeMenu: '/bpm/oa/leave'}
166 } 146 }
167 ] 147 ]
168 - }, { 148 + },
  149 + {
169 path: '/bpm', 150 path: '/bpm',
170 component: Layout, 151 component: Layout,
171 hidden: true, 152 hidden: true,
@@ -198,6 +179,36 @@ export const constantRoutes = [ @@ -198,6 +179,36 @@ export const constantRoutes = [
198 ] 179 ]
199 }, 180 },
200 { 181 {
  182 + path: '/property',
  183 + component: Layout,
  184 + hidden: true,
  185 + children: [{
  186 + path: 'value/:propertyId(\\d+)',
  187 + component: (resolve) => require(['@/views/mall/product/property/value'], resolve),
  188 + name: 'PropertyValue',
  189 + meta: {title: '商品属性值', icon: '', activeMenu: '/product/property'}
  190 + }
  191 + ]
  192 + },
  193 + {
  194 + path: '/spu',
  195 + component: Layout,
  196 + hidden: true,
  197 + children: [{
  198 + path: 'edit/:spuId(\\d+)',
  199 + component: (resolve) => require(['@/views/mall/product/spu/save'], resolve),
  200 + name: 'SpuEdit',
  201 + meta: {title: '修改商品', activeMenu: '/product/spu'}
  202 + },
  203 + {
  204 + path: 'add',
  205 + component: (resolve) => require(['@/views/mall/product/spu/save'], resolve),
  206 + name: 'SpuAdd',
  207 + meta: {title: '添加商品', activeMenu: '/product/spu'}
  208 + }
  209 + ]
  210 + },
  211 + {
201 path: '/trade/order', 212 path: '/trade/order',
202 component: Layout, 213 component: Layout,
203 hidden: true, 214 hidden: true,
yudao-ui-admin/src/utils/dict.js
@@ -26,6 +26,7 @@ export const DICT_TYPE = { @@ -26,6 +26,7 @@ export const DICT_TYPE = {
26 SYSTEM_ERROR_CODE_TYPE: 'system_error_code_type', 26 SYSTEM_ERROR_CODE_TYPE: 'system_error_code_type',
27 SYSTEM_OAUTH2_GRANT_TYPE: 'system_oauth2_grant_type', 27 SYSTEM_OAUTH2_GRANT_TYPE: 'system_oauth2_grant_type',
28 SYSTEM_MAIL_SEND_STATUS: 'system_mail_send_status', 28 SYSTEM_MAIL_SEND_STATUS: 'system_mail_send_status',
  29 + SYSTEM_NOTIFY_TEMPLATE_TYPE: 'system_notify_template_type',
29 30
30 // ========== INFRA 模块 ========== 31 // ========== INFRA 模块 ==========
31 INFRA_BOOLEAN_STRING: 'infra_boolean_string', 32 INFRA_BOOLEAN_STRING: 'infra_boolean_string',
yudao-ui-admin/src/views/mp/account/index.vue
1 <template> 1 <template>
2 <div class="app-container"> 2 <div class="app-container">
  3 + <doc-alert title="公众号接入" url="https://doc.iocoder.cn/mp/account/" />
3 4
4 <!-- 搜索工作栏 --> 5 <!-- 搜索工作栏 -->
5 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> 6 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
yudao-ui-admin/src/views/mp/autoReply/index.vue
@@ -26,6 +26,8 @@ SOFTWARE. @@ -26,6 +26,8 @@ SOFTWARE.
26 --> 26 -->
27 <template> 27 <template>
28 <div class="app-container"> 28 <div class="app-container">
  29 + <doc-alert title="自动回复" url="https://doc.iocoder.cn/mp/auto-reply/" />
  30 +
29 <!-- 搜索工作栏 --> 31 <!-- 搜索工作栏 -->
30 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> 32 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
31 <el-form-item label="公众号" prop="accountId"> 33 <el-form-item label="公众号" prop="accountId">
yudao-ui-admin/src/views/mp/draft/index.vue
@@ -27,6 +27,8 @@ SOFTWARE. @@ -27,6 +27,8 @@ SOFTWARE.
27 --> 27 -->
28 <template> 28 <template>
29 <div class="app-container"> 29 <div class="app-container">
  30 + <doc-alert title="公众号图文" url="https://doc.iocoder.cn/mp/article/" />
  31 +
30 <!-- 搜索工作栏 --> 32 <!-- 搜索工作栏 -->
31 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> 33 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
32 <el-form-item label="公众号" prop="accountId"> 34 <el-form-item label="公众号" prop="accountId">
yudao-ui-admin/src/views/mp/freePublish/index.vue
@@ -25,6 +25,8 @@ SOFTWARE. @@ -25,6 +25,8 @@ SOFTWARE.
25 --> 25 -->
26 <template> 26 <template>
27 <div class="app-container"> 27 <div class="app-container">
  28 + <doc-alert title="公众号图文" url="https://doc.iocoder.cn/mp/article/" />
  29 +
28 <!-- 搜索工作栏 --> 30 <!-- 搜索工作栏 -->
29 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> 31 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
30 <el-form-item label="公众号" prop="accountId"> 32 <el-form-item label="公众号" prop="accountId">
yudao-ui-admin/src/views/mp/material/index.vue
@@ -27,6 +27,8 @@ SOFTWARE. @@ -27,6 +27,8 @@ SOFTWARE.
27 --> 27 -->
28 <template> 28 <template>
29 <div class="app-container"> 29 <div class="app-container">
  30 + <doc-alert title="公众号素材" url="https://doc.iocoder.cn/mp/material/" />
  31 +
30 <!-- 搜索工作栏 --> 32 <!-- 搜索工作栏 -->
31 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> 33 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
32 <el-form-item label="公众号" prop="accountId"> 34 <el-form-item label="公众号" prop="accountId">
yudao-ui-admin/src/views/mp/menu/index.vue
@@ -26,6 +26,8 @@ SOFTWARE. @@ -26,6 +26,8 @@ SOFTWARE.
26 --> 26 -->
27 <template> 27 <template>
28 <div class="app-container"> 28 <div class="app-container">
  29 + <doc-alert title="公众号菜单" url="https://doc.iocoder.cn/mp/menu/" />
  30 +
29 <!-- 搜索工作栏 --> 31 <!-- 搜索工作栏 -->
30 <el-form ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> 32 <el-form ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
31 <el-form-item label="公众号" prop="accountId"> 33 <el-form-item label="公众号" prop="accountId">
yudao-ui-admin/src/views/mp/message/index.vue
1 <template> 1 <template>
2 <div class="app-container"> 2 <div class="app-container">
  3 + <doc-alert title="公众号消息" url="https://doc.iocoder.cn/mp/message/" />
3 4
4 <!-- 搜索工作栏 --> 5 <!-- 搜索工作栏 -->
5 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> 6 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
yudao-ui-admin/src/views/mp/statistics/index.vue
1 <template> 1 <template>
2 <div class="app-container"> 2 <div class="app-container">
  3 + <doc-alert title="公众号统计" url="https://doc.iocoder.cn/mp/statistics/" />
  4 +
3 <!-- 搜索工作栏 --> 5 <!-- 搜索工作栏 -->
4 <el-form ref="queryForm" size="small" :inline="true" label-width="68px"> 6 <el-form ref="queryForm" size="small" :inline="true" label-width="68px">
5 <el-form-item label="公众号" prop="accountId"> 7 <el-form-item label="公众号" prop="accountId">
yudao-ui-admin/src/views/mp/tag/index.vue
1 <template> 1 <template>
2 <div class="app-container"> 2 <div class="app-container">
  3 + <doc-alert title="公众号标签" url="https://doc.iocoder.cn/mp/tag/" />
  4 +
3 <!-- 搜索工作栏 --> 5 <!-- 搜索工作栏 -->
4 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> 6 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
5 <el-form-item label="公众号" prop="accountId"> 7 <el-form-item label="公众号" prop="accountId">
yudao-ui-admin/src/views/mp/user/index.vue
1 <template> 1 <template>
2 <div class="app-container"> 2 <div class="app-container">
  3 + <doc-alert title="公众号粉丝" url="https://doc.iocoder.cn/mp/user/" />
3 4
4 <!-- 搜索工作栏 --> 5 <!-- 搜索工作栏 -->
5 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> 6 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
yudao-ui-admin/src/views/system/mail/log/index.vue
@@ -140,7 +140,7 @@ export default { @@ -140,7 +140,7 @@ export default {
140 // 邮件日志列表 140 // 邮件日志列表
141 list: [], 141 list: [],
142 // 弹出层标题 142 // 弹出层标题
143 - title: "", 143 + title: "邮件发送日志详细",
144 // 是否显示弹出层 144 // 是否显示弹出层
145 open: false, 145 open: false,
146 // 查询参数 146 // 查询参数
yudao-ui-admin/src/views/system/notify/message/index.vue 0 → 100644
  1 +<template>
  2 + <div class="app-container">
  3 + <doc-alert title="站内信配置" url="https://doc.iocoder.cn/notify/" />
  4 + <!-- 搜索工作栏 -->
  5 + <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  6 + <el-form-item label="用户编号" prop="userId">
  7 + <el-input v-model="queryParams.userId" placeholder="请输入用户编号" clearable @keyup.enter.native="handleQuery"/>
  8 + </el-form-item>
  9 + <el-form-item label="用户类型" prop="userType">
  10 + <el-select v-model="queryParams.userType" placeholder="请选择用户类型" clearable size="small">
  11 + <el-option v-for="dict in this.getDictDatas(DICT_TYPE.USER_TYPE)"
  12 + :key="dict.value" :label="dict.label" :value="dict.value"/>
  13 + </el-select>
  14 + </el-form-item>
  15 + <el-form-item label="模板编码" prop="templateCode">
  16 + <el-input v-model="queryParams.templateCode" placeholder="请输入模板编码" clearable @keyup.enter.native="handleQuery"/>
  17 + </el-form-item>
  18 + <el-form-item label="模版类型" prop="templateType">
  19 + <el-select v-model="queryParams.templateType" placeholder="请选择模版类型" clearable size="small">
  20 + <el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE)"
  21 + :key="dict.value" :label="dict.label" :value="dict.value"/>
  22 + </el-select>
  23 + </el-form-item>
  24 + <el-form-item label="创建时间" prop="createTime">
  25 + <el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange"
  26 + range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" />
  27 + </el-form-item>
  28 + <el-form-item>
  29 + <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
  30 + <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  31 + </el-form-item>
  32 + </el-form>
  33 +
  34 + <!-- 操作工具栏 -->
  35 + <el-row :gutter="10" class="mb8">
  36 + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  37 + </el-row>
  38 +
  39 + <!-- 列表 -->
  40 + <el-table v-loading="loading" :data="list">
  41 + <el-table-column label="编号" align="center" prop="id" />
  42 + <el-table-column label="用户编号" align="center" prop="userId" />
  43 + <el-table-column label="用户类型" align="center" prop="userType">
  44 + <template v-slot="scope">
  45 + <dict-tag :type="DICT_TYPE.USER_TYPE" :value="scope.row.userType" />
  46 + </template>
  47 + </el-table-column>
  48 + <el-table-column label="模板编码" align="center" prop="templateCode" />
  49 + <el-table-column label="发送人名称" align="center" prop="templateNickname" />
  50 + <el-table-column label="模版内容" align="center" prop="templateContent" />
  51 + <el-table-column label="模版类型" align="center" prop="templateType">
  52 + <template v-slot="scope">
  53 + <dict-tag :type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE" :value="scope.row.templateType" />
  54 + </template>
  55 + </el-table-column>
  56 + <el-table-column label="是否已读" align="center" prop="readStatus">
  57 + <template v-slot="scope">
  58 + <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.readStatus" />
  59 + </template>
  60 + </el-table-column>
  61 + <el-table-column label="阅读时间" align="center" prop="readTime" width="180">
  62 + <template v-slot="scope">
  63 + <span>{{ parseTime(scope.row.readTime) }}</span>
  64 + </template>
  65 + </el-table-column>
  66 + <el-table-column label="创建时间" align="center" prop="createTime" width="180">
  67 + <template v-slot="scope">
  68 + <span>{{ parseTime(scope.row.createTime) }}</span>
  69 + </template>
  70 + </el-table-column>
  71 + <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  72 + <template v-slot="scope">
  73 + <el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)"
  74 + v-hasPermi="['system:notify-message:query']">详细</el-button>
  75 + </template>
  76 + </el-table-column>
  77 + </el-table>
  78 + <!-- 分页组件 -->
  79 + <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
  80 + @pagination="getList"/>
  81 +
  82 + <!-- 站内信详细-->
  83 + <el-dialog :title="title" :visible.sync="open" width="700px" v-dialogDrag append-to-body>
  84 + <el-form ref="form" :model="form" label-width="160px">
  85 + <el-row>
  86 + <el-col :span="24">
  87 + <el-form-item label="日志主键:">{{ form.id }}</el-form-item>
  88 + <el-form-item label="发送时间:">{{ parseTime(form.createTime) }}</el-form-item>
  89 + <el-form-item label="用户编号:">{{ form.userId }}</el-form-item>
  90 + <el-form-item label="用户类型:">
  91 + <dict-tag :type="DICT_TYPE.USER_TYPE" :value="form.userType"/>
  92 + </el-form-item>
  93 + <el-form-item label="模板编号:">{{ form.templateId }}</el-form-item>
  94 + <el-form-item label="模板编码:">{{ form.templateCode }}</el-form-item>
  95 + <el-form-item label="模板类型:">
  96 + <dict-tag :type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE" :value="form.templateType" />
  97 + </el-form-item>
  98 + <el-form-item label="模版发送人名称:">{{ form.templateNickname }}</el-form-item>
  99 + <el-form-item label="邮件内容:">{{ form.templateContent }}</el-form-item>
  100 + <el-form-item label="模版参数:">{{ form.templateParams }}</el-form-item>
  101 + <el-form-item label="是否已读:">
  102 + <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="form.readStatus" />
  103 + </el-form-item>
  104 + <el-form-item label="阅读时间:">{{ parseTime(form.readTime) }}</el-form-item>
  105 + </el-col>
  106 + </el-row>
  107 + </el-form>
  108 + <div slot="footer" class="dialog-footer">
  109 + <el-button @click="open = false">关 闭</el-button>
  110 + </div>
  111 + </el-dialog>
  112 + </div>
  113 +</template>
  114 +
  115 +<script>
  116 +import { getNotifyMessagePage } from "@/api/system/notify/message";
  117 +
  118 +export default {
  119 + name: "NotifyMessage",
  120 + data() {
  121 + return {
  122 + // 遮罩层
  123 + loading: true,
  124 + // 显示搜索条件
  125 + showSearch: true,
  126 + // 总条数
  127 + total: 0,
  128 + // 站内信消息列表
  129 + list: [],
  130 + // 弹出层标题
  131 + title: "站内信详细",
  132 + // 是否显示弹出层
  133 + open: false,
  134 + // 查询参数
  135 + queryParams: {
  136 + pageNo: 1,
  137 + pageSize: 10,
  138 + userId: null,
  139 + userType: null,
  140 + templateCode: null,
  141 + templateType: null,
  142 + createTime: [],
  143 + },
  144 + // 表单参数
  145 + form: {},
  146 + };
  147 + },
  148 + created() {
  149 + this.getList();
  150 + },
  151 + methods: {
  152 + /** 查询列表 */
  153 + getList() {
  154 + this.loading = true;
  155 + // 执行查询
  156 + getNotifyMessagePage(this.queryParams).then(response => {
  157 + this.list = response.data.list;
  158 + this.total = response.data.total;
  159 + this.loading = false;
  160 + });
  161 + },
  162 + /** 搜索按钮操作 */
  163 + handleQuery() {
  164 + this.queryParams.pageNo = 1;
  165 + this.getList();
  166 + },
  167 + /** 重置按钮操作 */
  168 + resetQuery() {
  169 + this.resetForm("queryForm");
  170 + this.handleQuery();
  171 + },
  172 + /** 详细按钮操作 */
  173 + handleView(row) {
  174 + this.open = true;
  175 + this.form = row;
  176 + }
  177 + }
  178 +};
  179 +</script>
yudao-ui-admin/src/views/system/notify/my/index.vue 0 → 100644
  1 +<template>
  2 + <div class="app-container">
  3 + <doc-alert title="站内信配置" url="https://doc.iocoder.cn/notify/" />
  4 +
  5 + <!-- 搜索工作栏 -->
  6 + <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  7 + <el-form-item label="是否已读" prop="readStatus">
  8 + <el-select v-model="queryParams.readStatus" placeholder="请选择状态" clearable>
  9 + <el-option v-for="dict in this.getDictDatas(DICT_TYPE.INFRA_BOOLEAN_STRING)"
  10 + :key="dict.value" :label="dict.label" :value="dict.value"/>
  11 + </el-select>
  12 + </el-form-item>
  13 + <el-form-item label="发送时间" prop="createTime">
  14 + <el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange"
  15 + range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" />
  16 + </el-form-item>
  17 + <el-form-item>
  18 + <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
  19 + <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  20 + </el-form-item>
  21 + </el-form>
  22 +
  23 + <!-- 操作工具栏 -->
  24 + <el-row :gutter="10" class="mb8">
  25 + <el-col :span="1.5">
  26 + <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleUpdateList">标记已读</el-button>
  27 + </el-col>
  28 + <el-col :span="1.5">
  29 + <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleUpdateAll">全部已读</el-button>
  30 + </el-col>
  31 + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  32 + </el-row>
  33 +
  34 + <!-- 列表 -->
  35 + <el-table v-loading="loading" ref="tables" :data="list">
  36 + <el-table-column type="selection" width="55" />
  37 + <el-table-column label="发送人" align="center" prop="templateNickname" width="120" />
  38 + <el-table-column label="发送时间" align="center" prop="createTime" width="180">
  39 + <template slot-scope="scope">
  40 + <span>{{ parseTime(scope.row.createTime) }}</span>
  41 + </template>
  42 + </el-table-column>
  43 + <el-table-column label="类型" align="center" prop="templateType" width="80">
  44 + <template v-slot="scope">
  45 + <dict-tag :type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE" :value="scope.row.templateType" />
  46 + </template>
  47 + </el-table-column>
  48 + <el-table-column label="内容" align="center" prop="templateContent" />
  49 + <el-table-column label="是否已读" align="center" prop="readStatus" width="80">
  50 + <template slot-scope="scope">
  51 + <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.readStatus"/>
  52 + </template>
  53 + </el-table-column>
  54 + <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150">
  55 + <template slot-scope="scope">
  56 + <el-button v-show="!scope.row.readStatus" size="mini" type="text" icon="el-icon-check" @click="handleUpdateSingle(scope.row)">已读</el-button>
  57 + </template>
  58 + </el-table-column>
  59 + </el-table>
  60 + <!-- 分页组件 -->
  61 + <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
  62 + @pagination="getList"/>
  63 +
  64 + </div>
  65 +</template>
  66 +
  67 +<script>
  68 +import {getMyNotifyMessagePage, updateAllNotifyMessageRead, updateNotifyMessageRead} from "@/api/system/notify/message";
  69 +
  70 +export default {
  71 + name: "myNotify",
  72 + data() {
  73 + return {
  74 + // 遮罩层
  75 + loading: true,
  76 + // 显示搜索条件
  77 + showSearch: true,
  78 + // 总条数
  79 + total: 0,
  80 + // 我的站内信列表
  81 + list: [],
  82 + // 查询参数
  83 + queryParams: {
  84 + pageNo: 1,
  85 + pageSize: 10,
  86 + readStatus: null,
  87 + createTime: []
  88 + },
  89 + };
  90 + },
  91 + created() {
  92 + this.getList();
  93 + },
  94 + methods: {
  95 + /** 查询列表 */
  96 + getList() {
  97 + this.loading = true;
  98 + // 执行查询
  99 + getMyNotifyMessagePage(this.queryParams).then(response => {
  100 + this.list = response.data.list;
  101 + this.total = response.data.total;
  102 + this.loading = false;
  103 + });
  104 + },
  105 + /** 搜索按钮操作 */
  106 + handleQuery() {
  107 + this.queryParams.pageNo = 1;
  108 + this.getList();
  109 + },
  110 + /** 重置按钮操作 */
  111 + resetQuery() {
  112 + this.resetForm("queryForm");
  113 + this.handleQuery();
  114 + },
  115 + handleUpdateList() {
  116 + let list = this.$refs["tables"].selection;
  117 + if (list.length === 0) {
  118 + return;
  119 + }
  120 + this.handleUpdate(list.map(v => v.id))
  121 + },
  122 + handleUpdateSingle(row) {
  123 + this.handleUpdate([row.id])
  124 + },
  125 + handleUpdate(ids) {
  126 + updateNotifyMessageRead(ids).then(response => {
  127 + this.$modal.msgSuccess("标记已读成功!");
  128 + this.getList();
  129 + });
  130 + },
  131 + handleUpdateAll(){
  132 + updateAllNotifyMessageRead().then(response => {
  133 + this.$modal.msgSuccess("全部已读成功!");
  134 + this.getList();
  135 + });
  136 + }
  137 + }
  138 +}
  139 +</script>
yudao-ui-admin/src/views/system/notify/template/index.vue 0 → 100644
  1 +<template>
  2 + <div class="app-container">
  3 + <doc-alert title="站内信配置" url="https://doc.iocoder.cn/notify/" />
  4 +
  5 + <!-- 搜索工作栏 -->
  6 + <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
  7 + <el-form-item label="模板名称" prop="name">
  8 + <el-input v-model="queryParams.name" placeholder="请输入模板名称" clearable @keyup.enter.native="handleQuery"/>
  9 + </el-form-item>
  10 + <el-form-item label="模版编码" prop="code">
  11 + <el-input v-model="queryParams.code" placeholder="请输入模版编码" clearable @keyup.enter.native="handleQuery"/>
  12 + </el-form-item>
  13 + <el-form-item label="状态" prop="status">
  14 + <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small">
  15 + <el-option v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)"
  16 + :key="dict.value" :label="dict.label" :value="dict.value"/>
  17 + </el-select>
  18 + </el-form-item>
  19 + <el-form-item label="创建时间" prop="createTime">
  20 + <el-date-picker v-model="queryParams.createTime" style="width: 240px" value-format="yyyy-MM-dd HH:mm:ss" type="daterange"
  21 + range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" />
  22 + </el-form-item>
  23 + <el-form-item>
  24 + <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
  25 + <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  26 + </el-form-item>
  27 + </el-form>
  28 +
  29 + <!-- 操作工具栏 -->
  30 + <el-row :gutter="10" class="mb8">
  31 + <el-col :span="1.5">
  32 + <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
  33 + v-hasPermi="['system:notify-template:create']">新增</el-button>
  34 + </el-col>
  35 + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  36 + </el-row>
  37 +
  38 + <!-- 列表 -->
  39 + <el-table v-loading="loading" :data="list">
  40 + <el-table-column label="模板编码" align="center" prop="code" />
  41 + <el-table-column label="模板名称" align="center" prop="name" />
  42 + <el-table-column label="类型" align="center" prop="type">
  43 + <template v-slot="scope">
  44 + <dict-tag :type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE" :value="scope.row.type" />
  45 + </template>
  46 + </el-table-column>
  47 + <el-table-column label="发送人名称" align="center" prop="nickname" />
  48 + <el-table-column label="模板内容" align="center" prop="content" width="300" />
  49 + <el-table-column label="开启状态" align="center" prop="status">
  50 + <template slot-scope="scope">
  51 + <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status"/>
  52 + </template>
  53 + </el-table-column>
  54 + <el-table-column label="备注" align="center" prop="remark" />
  55 + <el-table-column label="创建时间" align="center" prop="createTime" width="180">
  56 + <template slot-scope="scope">
  57 + <span>{{ parseTime(scope.row.createTime) }}</span>
  58 + </template>
  59 + </el-table-column>
  60 + <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150">
  61 + <template slot-scope="scope">
  62 + <el-button size="mini" type="text" icon="el-icon-share" @click="handleSendNotify(scope.row)"
  63 + v-hasPermi="['system:notify-template:send-notify']">测试</el-button>
  64 + <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
  65 + v-hasPermi="['system:notify-template:update']">修改</el-button>
  66 + <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
  67 + v-hasPermi="['system:notify-template:delete']">删除</el-button>
  68 + </template>
  69 + </el-table-column>
  70 + </el-table>
  71 + <!-- 分页组件 -->
  72 + <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
  73 + @pagination="getList"/>
  74 +
  75 + <!-- 对话框(添加 / 修改) -->
  76 + <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  77 + <el-form ref="form" :model="form" :rules="rules" label-width="140px">
  78 + <el-form-item label="模版编码" prop="code">
  79 + <el-input v-model="form.code" placeholder="请输入模版编码" />
  80 + </el-form-item>
  81 + <el-form-item label="模板名称" prop="name">
  82 + <el-input v-model="form.name" placeholder="请输入模版名称" />
  83 + </el-form-item>
  84 + <el-form-item label="发件人名称" prop="nickname">
  85 + <el-input v-model="form.nickname" placeholder="请输入发件人名称" />
  86 + </el-form-item>
  87 + <el-form-item label="模板内容" prop="content">
  88 + <el-input type="textarea" v-model="form.content" placeholder="请输入模板内容" />
  89 + </el-form-item>
  90 + <el-form-item label="类型" prop="type">
  91 + <el-select v-model="form.type" placeholder="请选择类型">
  92 + <el-option v-for="dict in this.getDictDatas(DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE)"
  93 + :key="dict.value" :label="dict.label" :value="parseInt(dict.value)" />
  94 + </el-select>
  95 + </el-form-item>
  96 + <el-form-item label="开启状态" prop="status">
  97 + <el-radio-group v-model="form.status">
  98 + <el-radio v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)"
  99 + :key="dict.value" :label="parseInt(dict.value)">{{dict.label}}</el-radio>
  100 + </el-radio-group>
  101 + </el-form-item>
  102 + <el-form-item label="备注" prop="remark">
  103 + <el-input v-model="form.remark" placeholder="请输入备注" />
  104 + </el-form-item>
  105 + </el-form>
  106 + <div slot="footer" class="dialog-footer">
  107 + <el-button type="primary" @click="submitForm">确 定</el-button>
  108 + <el-button @click="cancel">取 消</el-button>
  109 + </div>
  110 + </el-dialog>
  111 +
  112 + <!-- 对话框(发送站内信) -->
  113 + <el-dialog title="发送站内信" :visible.sync="sendNotifyOpen" width="500px" append-to-body>
  114 + <el-form ref="sendNotifyForm" :model="sendNotifyForm" :rules="sendNotifyRules" label-width="140px">
  115 + <el-form-item label="模板内容" prop="content">
  116 + <el-input v-model="sendNotifyForm.content" type="textarea" placeholder="请输入模板内容" readonly />
  117 + </el-form-item>
  118 + <el-form-item label="接收人" prop="userId">
  119 + <el-select v-model="sendNotifyForm.userId" placeholder="请输入接收人" clearable style="width: 100%">
  120 + <el-option v-for="item in users" :key="parseInt(item.id)" :label="item.nickname" :value="parseInt(item.id)" />
  121 + </el-select>
  122 + </el-form-item>
  123 + <el-form-item v-for="param in sendNotifyForm.params" :key="param" :label="'参数 {' + param + '}'" :prop="'templateParams.' + param">
  124 + <el-input v-model="sendNotifyForm.templateParams[param]" :placeholder="'请输入 ' + param + ' 参数'" />
  125 + </el-form-item>
  126 + </el-form>
  127 + <div slot="footer" class="dialog-footer">
  128 + <el-button type="primary" @click="submitSendNotifyForm">确 定</el-button>
  129 + <el-button @click="cancelSendNotify">取 消</el-button>
  130 + </div>
  131 + </el-dialog>
  132 +
  133 + </div>
  134 +</template>
  135 +
  136 +<script>
  137 +import { createNotifyTemplate, updateNotifyTemplate, deleteNotifyTemplate, getNotifyTemplate, getNotifyTemplatePage,
  138 + sendNotify } from "@/api/system/notify/template";
  139 +import {listSimpleUsers} from "@/api/system/user";
  140 +import {CommonStatusEnum} from "@/utils/constants";
  141 +
  142 +export default {
  143 + name: "NotifyTemplate",
  144 + data() {
  145 + return {
  146 + // 遮罩层
  147 + loading: true,
  148 + // 显示搜索条件
  149 + showSearch: true,
  150 + // 总条数
  151 + total: 0,
  152 + // 短信模板列表
  153 + list: [],
  154 + // 弹出层标题
  155 + title: "",
  156 + // 是否显示弹出层
  157 + open: false,
  158 + // 查询参数
  159 + queryParams: {
  160 + pageNo: 1,
  161 + pageSize: 10,
  162 + status: null,
  163 + code: null,
  164 + title: null,
  165 + createTime: []
  166 + },
  167 + // 表单参数
  168 + form: {},
  169 + // 表单校验
  170 + rules: {
  171 + name: [{ required: true, message: "模板名称不能为空", trigger: "blur" }],
  172 + code: [{ required: true, message: "模版编码不能为空", trigger: "blur" }],
  173 + nickname: [{ required: true, message: "发件人名称不能为空", trigger: "blur" }],
  174 + content: [{ required: true, message: "模版内容不能为空", trigger: "blur" }],
  175 + type: [{ required: true, message: "类型不能为空", trigger: "change" }],
  176 + status: [{ required: true, message: "状态不能为空", trigger: "blur" }],
  177 + },
  178 + // 用户列表
  179 + users: [],
  180 + // 发送短信
  181 + sendNotifyOpen: false,
  182 + sendNotifyForm: {
  183 + params: [], // 模板的参数列表
  184 + },
  185 + sendNotifyRules: {
  186 + userId: [{ required: true, message: "接收人不能为空", trigger: "blur" }],
  187 + templateCode: [{ required: true, message: "模版编码不能为空", trigger: "blur" }],
  188 + templateParams: { }
  189 + }
  190 + };
  191 + },
  192 + created() {
  193 + this.getList();
  194 + // 获得用户列表
  195 + listSimpleUsers().then(response => {
  196 + this.users = response.data;
  197 + })
  198 + },
  199 + methods: {
  200 + /** 查询列表 */
  201 + getList() {
  202 + this.loading = true;
  203 + // 执行查询
  204 + getNotifyTemplatePage(this.queryParams).then(response => {
  205 + this.list = response.data.list;
  206 + this.total = response.data.total;
  207 + this.loading = false;
  208 + });
  209 + },
  210 + /** 取消按钮 */
  211 + cancel() {
  212 + this.open = false;
  213 + this.reset();
  214 + },
  215 + /** 表单重置 */
  216 + reset() {
  217 + this.form = {
  218 + id: undefined,
  219 + name: undefined,
  220 + code: undefined,
  221 + nickname: undefined,
  222 + content: undefined,
  223 + type: undefined,
  224 + params: undefined,
  225 + status: CommonStatusEnum.ENABLE,
  226 + remark: undefined,
  227 + };
  228 + this.resetForm("form");
  229 + },
  230 + /** 搜索按钮操作 */
  231 + handleQuery() {
  232 + this.queryParams.pageNo = 1;
  233 + this.getList();
  234 + },
  235 + /** 重置按钮操作 */
  236 + resetQuery() {
  237 + this.resetForm("queryForm");
  238 + this.handleQuery();
  239 + },
  240 + /** 新增按钮操作 */
  241 + handleAdd() {
  242 + this.reset();
  243 + this.open = true;
  244 + this.title = "添加站内信模板";
  245 + },
  246 + /** 修改按钮操作 */
  247 + handleUpdate(row) {
  248 + this.reset();
  249 + const id = row.id;
  250 + getNotifyTemplate(id).then(response => {
  251 + this.form = response.data;
  252 + this.open = true;
  253 + this.title = "修改站内信模板";
  254 + });
  255 + },
  256 + /** 提交按钮 */
  257 + submitForm() {
  258 + this.$refs["form"].validate(valid => {
  259 + if (!valid) {
  260 + return;
  261 + }
  262 + // 修改的提交
  263 + if (this.form.id != null) {
  264 + updateNotifyTemplate(this.form).then(response => {
  265 + this.$modal.msgSuccess("修改成功");
  266 + this.open = false;
  267 + this.getList();
  268 + });
  269 + return;
  270 + }
  271 + // 添加的提交
  272 + createNotifyTemplate(this.form).then(response => {
  273 + this.$modal.msgSuccess("新增成功");
  274 + this.open = false;
  275 + this.getList();
  276 + });
  277 + });
  278 + },
  279 + /** 删除按钮操作 */
  280 + handleDelete(row) {
  281 + const id = row.id;
  282 + this.$modal.confirm('是否确认删除站内信模板编号为"' + id + '"的数据项?').then(function() {
  283 + return deleteNotifyTemplate(id);
  284 + }).then(() => {
  285 + this.getList();
  286 + this.$modal.msgSuccess("删除成功");
  287 + }).catch(() => {});
  288 + },
  289 + /** 发送站内信按钮 */
  290 + handleSendNotify(row) {
  291 + this.resetSendNotify(row);
  292 + // 设置参数
  293 + this.sendNotifyForm.content = row.content;
  294 + this.sendNotifyForm.params = row.params;
  295 + this.sendNotifyForm.templateCode = row.code;
  296 + this.sendNotifyForm.templateParams = row.params.reduce(function(obj, item) {
  297 + obj[item] = undefined;
  298 + return obj;
  299 + }, {});
  300 + // 根据 row 重置 rules
  301 + this.sendNotifyRules.templateParams = row.params.reduce(function(obj, item) {
  302 + obj[item] = { required: true, message: '参数 ' + item + " 不能为空", trigger: "change" };
  303 + return obj;
  304 + }, {});
  305 + // 设置打开
  306 + this.sendNotifyOpen = true;
  307 + },
  308 + /** 重置发送站内信的表单 */
  309 + resetSendNotify() {
  310 + // 根据 row 重置表单
  311 + this.sendNotifyForm = {
  312 + content: undefined,
  313 + params: undefined,
  314 + userId: undefined,
  315 + templateCode: undefined,
  316 + templateParams: {}
  317 + };
  318 + this.resetForm("sendNotifyForm");
  319 + },
  320 + /** 取消发送站内信 */
  321 + cancelSendNotify() {
  322 + this.sendNotifyOpen = false;
  323 + this.resetSendNotify();
  324 + },
  325 + /** 提交按钮 */
  326 + submitSendNotifyForm() {
  327 + this.$refs["sendNotifyForm"].validate(valid => {
  328 + if (!valid) {
  329 + return;
  330 + }
  331 + // 添加的提交
  332 + sendNotify(this.sendNotifyForm).then(response => {
  333 + this.$modal.msgSuccess("提交发送成功!发送结果,见发送日志编号:" + response.data);
  334 + this.sendNotifyOpen = false;
  335 + });
  336 + });
  337 + },
  338 + }
  339 +};
  340 +</script>
yudao-ui-admin/src/views/system/oauth2/client/index.vue
1 <template> 1 <template>
2 <div class="app-container"> 2 <div class="app-container">
  3 + <doc-alert title="OAuth 2.0(SSO 单点登录)" url="https://doc.iocoder.cn/oauth2/" />
3 4
4 <!-- 搜索工作栏 --> 5 <!-- 搜索工作栏 -->
5 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> 6 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
yudao-ui-admin/src/views/system/oauth2/token/index.vue
1 <template> 1 <template>
2 <div class="app-container"> 2 <div class="app-container">
  3 + <doc-alert title="OAuth 2.0(SSO 单点登录)" url="https://doc.iocoder.cn/oauth2/" />
3 <doc-alert title="用户体系" url="https://doc.iocoder.cn/user-center/" /> 4 <doc-alert title="用户体系" url="https://doc.iocoder.cn/user-center/" />
  5 +
4 <!-- 搜索工作栏 --> 6 <!-- 搜索工作栏 -->
5 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px"> 7 <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
6 <el-form-item label="用户编号" prop="userId"> 8 <el-form-item label="用户编号" prop="userId">