From bb78a58029db52df14b3812300b07c144a5d0b48 Mon Sep 17 00:00:00 2001
From: xrcoder <53924337@qq.com>
Date: Sat, 6 Aug 2022 09:08:38 +0800
Subject: [PATCH 01/18] =?UTF-8?q?=E7=AB=99=E5=86=85=E4=BF=A1=E5=9F=BA?=
=?UTF-8?q?=E7=A1=80=E4=BB=A3=E7=A0=81=E6=95=B4=E7=90=86=EF=BC=8C=E6=8E=A5?=
=?UTF-8?q?=E5=8F=A3=E5=AE=9A=E4=B9=89=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../api/notify/NotifyMessageSendApi.java | 34 +++++++
.../dto/NotifySendSingleToUserReqDTO.java | 33 +++++++
.../system/enums/ErrorCodeConstants.java | 6 ++
.../enums/notify/NotifyReadStatusEnum.java | 22 +++++
.../api/notify/NotifyMessageSendApiImpl.java | 39 ++++++++
.../admin/notify/NotifyMessageController.java | 73 ++++++++++++++
.../notify/NotifyTemplateController.java | 99 +++++++++++++++++++
.../notify/UserNotifyMessageController.java | 83 ++++++++++++++++
.../vo/message/NotifyMessageBaseVO.java | 40 ++++++++
.../vo/message/NotifyMessageCreateReqVO.java | 15 +++
.../vo/message/NotifyMessagePageReqVO.java | 27 +++++
.../vo/message/NotifyMessageRespVO.java | 19 ++++
.../vo/message/NotifyMessageUpdateReqVO.java | 20 ++++
.../vo/template/NotifyTemplateBaseVO.java | 34 +++++++
.../template/NotifyTemplateCreateReqVO.java | 12 +++
.../vo/template/NotifyTemplateExcelVO.java | 42 ++++++++
.../template/NotifyTemplateExportReqVO.java | 28 ++++++
.../vo/template/NotifyTemplatePageReqVO.java | 30 ++++++
.../vo/template/NotifyTemplateRespVO.java | 19 ++++
.../template/NotifyTemplateUpdateReqVO.java | 17 ++++
.../convert/notify/NotifyMessageConvert.java | 34 +++++++
.../convert/notify/NotifyTemplateConvert.java | 37 +++++++
.../dataobject/notify/NotifyMessageDO.java | 59 +++++++++++
.../dataobject/notify/NotifyTemplateDO.java | 55 +++++++++++
.../dal/mysql/notify/NotifyMessageMapper.java | 25 +++++
.../mysql/notify/NotifyTemplateMapper.java | 39 ++++++++
.../service/notify/NotifyMessageService.java | 65 ++++++++++++
.../notify/NotifyMessageServiceImpl.java | 78 +++++++++++++++
.../service/notify/NotifyTemplateService.java | 74 ++++++++++++++
.../notify/NotifyTemplateServiceImpl.java | 86 ++++++++++++++++
30 files changed, 1244 insertions(+)
create mode 100644 yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/notify/NotifyMessageSendApi.java
create mode 100644 yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/notify/dto/NotifySendSingleToUserReqDTO.java
create mode 100644 yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/notify/NotifyReadStatusEnum.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/notify/NotifyMessageSendApiImpl.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyMessageController.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyTemplateController.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/UserNotifyMessageController.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageBaseVO.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageCreateReqVO.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessagePageReqVO.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageRespVO.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageUpdateReqVO.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateBaseVO.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateCreateReqVO.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateExcelVO.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateExportReqVO.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplatePageReqVO.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateRespVO.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateUpdateReqVO.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyMessageConvert.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyTemplateConvert.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyMessageDO.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyTemplateDO.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyTemplateMapper.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageService.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateService.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImpl.java
diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/notify/NotifyMessageSendApi.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/notify/NotifyMessageSendApi.java
new file mode 100644
index 000000000..b5885e7ef
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/notify/NotifyMessageSendApi.java
@@ -0,0 +1,34 @@
+package cn.iocoder.yudao.module.system.api.notify;
+
+import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
+
+import javax.validation.Valid;
+
+/**
+ * 站内信发送 API 接口
+ *
+ * @author xrcoder
+ */
+public interface NotifyMessageSendApi {
+
+ /**
+ * 发送单条站内信给 Admin 用户
+ *
+ * 在 mobile 为空时,使用 userId 加载对应 Admin 的手机号
+ *
+ * @param reqDTO 发送请求
+ * @return 发送消息ID
+ */
+ Long sendSingleMessageToAdmin(@Valid NotifySendSingleToUserReqDTO reqDTO);
+
+ /**
+ * 发送单条站内信给 Member 用户
+ *
+ * 在 mobile 为空时,使用 userId 加载对应 Member 的手机号
+ *
+ * @param reqDTO 发送请求
+ * @return 发送消息ID
+ */
+ Long sendSingleMessageToMember(@Valid NotifySendSingleToUserReqDTO reqDTO);
+
+}
diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/notify/dto/NotifySendSingleToUserReqDTO.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/notify/dto/NotifySendSingleToUserReqDTO.java
new file mode 100644
index 000000000..502d3eb30
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/notify/dto/NotifySendSingleToUserReqDTO.java
@@ -0,0 +1,33 @@
+package cn.iocoder.yudao.module.system.api.notify.dto;
+
+import lombok.Data;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import java.util.Map;
+
+/**
+ * 站内信发送给 Admin 或者 Member 用户
+ *
+ * @author xrcoder
+ */
+@Data
+public class NotifySendSingleToUserReqDTO {
+
+ /**
+ * 用户编号
+ */
+ @NotNull(message = "用户编号不能为空")
+ private Long userId;
+
+ /**
+ * 站内信模板编号
+ */
+ @NotEmpty(message = "站内信模板编号不能为空")
+ private String templateCode;
+
+ /**
+ * 站内信模板参数
+ */
+ private Map templateParams;
+}
diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
index 2f39519a3..321599f00 100644
--- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
+++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
@@ -142,4 +142,10 @@ public interface ErrorCodeConstants {
ErrorCode OAUTH2_CODE_NOT_EXISTS = new ErrorCode(1002022000, "code 不存在");
ErrorCode OAUTH2_CODE_EXPIRE = new ErrorCode(1002022000, "code 已过期");
+ // ========== 站内信模版 1002023000 ==========
+ ErrorCode NOTIFY_TEMPLATE_NOT_EXISTS = new ErrorCode(1002023000, "站内信模版不存在");
+
+ // ========== 站内信 1002024000 ==========
+ ErrorCode NOTIFY_MESSAGE_NOT_EXISTS = new ErrorCode(1002024000, "站内信不存在");
+
}
diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/notify/NotifyReadStatusEnum.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/notify/NotifyReadStatusEnum.java
new file mode 100644
index 000000000..f0af060da
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/notify/NotifyReadStatusEnum.java
@@ -0,0 +1,22 @@
+package cn.iocoder.yudao.module.system.enums.notify;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * 站内信阅读状态枚举类
+ *
+ * @author xrcoder
+ */
+@Getter
+@AllArgsConstructor
+public enum NotifyReadStatusEnum {
+
+ UNREAD(0),
+ READ(1);
+
+ /**
+ * 类型
+ */
+ private final Integer status;
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/notify/NotifyMessageSendApiImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/notify/NotifyMessageSendApiImpl.java
new file mode 100644
index 000000000..6861ff8c5
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/api/notify/NotifyMessageSendApiImpl.java
@@ -0,0 +1,39 @@
+package cn.iocoder.yudao.module.system.api.notify;
+
+import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO;
+import org.springframework.stereotype.Service;
+
+/**
+ * 站内信发送 API 接口
+ *
+ * @author xrcoder
+ */
+@Service
+public class NotifyMessageSendApiImpl implements NotifyMessageSendApi {
+
+ /**
+ * 发送单条站内信给 Admin 用户
+ *
+ * 在 mobile 为空时,使用 userId 加载对应 Admin 的手机号
+ *
+ * @param reqDTO 发送请求
+ * @return 发送消息ID
+ */
+ @Override
+ public Long sendSingleMessageToAdmin(NotifySendSingleToUserReqDTO reqDTO) {
+ return null;
+ }
+
+ /**
+ * 发送单条站内信给 Member 用户
+ *
+ * 在 mobile 为空时,使用 userId 加载对应 Member 的手机号
+ *
+ * @param reqDTO 发送请求
+ * @return 发送消息ID
+ */
+ @Override
+ public Long sendSingleMessageToMember(NotifySendSingleToUserReqDTO reqDTO) {
+ return null;
+ }
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyMessageController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyMessageController.java
new file mode 100644
index 000000000..0f5290377
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyMessageController.java
@@ -0,0 +1,73 @@
+package cn.iocoder.yudao.module.system.controller.admin.notify;
+
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageCreateReqVO;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageRespVO;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageUpdateReqVO;
+import cn.iocoder.yudao.module.system.convert.notify.NotifyMessageConvert;
+import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
+import cn.iocoder.yudao.module.system.service.notify.NotifyMessageService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.validation.Valid;
+
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
+@Api(tags = "管理后台 - 站内信")
+@RestController
+@RequestMapping("/system/notify-message")
+@Validated
+public class NotifyMessageController {
+
+ @Resource
+ private NotifyMessageService notifyMessageService;
+
+ @PostMapping("/create")
+ @ApiOperation("创建站内信")
+ @PreAuthorize("@ss.hasPermission('system:notify-message:create')")
+ public CommonResult createNotifyMessage(@Valid @RequestBody NotifyMessageCreateReqVO createReqVO) {
+ return success(notifyMessageService.createNotifyMessage(createReqVO));
+ }
+
+ @PutMapping("/update")
+ @ApiOperation("更新站内信")
+ @PreAuthorize("@ss.hasPermission('system:notify-message:update')")
+ public CommonResult updateNotifyMessage(@Valid @RequestBody NotifyMessageUpdateReqVO updateReqVO) {
+ notifyMessageService.updateNotifyMessage(updateReqVO);
+ return success(true);
+ }
+
+ @DeleteMapping("/delete")
+ @ApiOperation("删除站内信")
+ @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
+ @PreAuthorize("@ss.hasPermission('system:notify-message:delete')")
+ public CommonResult deleteNotifyMessage(@RequestParam("id") Long id) {
+ notifyMessageService.deleteNotifyMessage(id);
+ return success(true);
+ }
+
+ @GetMapping("/get")
+ @ApiOperation("获得站内信")
+ @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
+ @PreAuthorize("@ss.hasPermission('system:notify-message:query')")
+ public CommonResult getNotifyMessage(@RequestParam("id") Long id) {
+ NotifyMessageDO notifyMessage = notifyMessageService.getNotifyMessage(id);
+ return success(NotifyMessageConvert.INSTANCE.convert(notifyMessage));
+ }
+
+ @GetMapping("/page")
+ @ApiOperation("获得站内信分页")
+ @PreAuthorize("@ss.hasPermission('system:notify-message:query')")
+ public CommonResult> getNotifyMessagePage(@Valid NotifyMessagePageReqVO pageVO) {
+ PageResult pageResult = notifyMessageService.getNotifyMessagePage(pageVO);
+ return success(NotifyMessageConvert.INSTANCE.convertPage(pageResult));
+ }
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyTemplateController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyTemplateController.java
new file mode 100644
index 000000000..fe7f8a1a2
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyTemplateController.java
@@ -0,0 +1,99 @@
+package cn.iocoder.yudao.module.system.controller.admin.notify;
+
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
+import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.*;
+import cn.iocoder.yudao.module.system.convert.notify.NotifyTemplateConvert;
+import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
+import cn.iocoder.yudao.module.system.service.notify.NotifyTemplateService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.List;
+
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
+
+@Api(tags = "管理后台 - 站内信模版")
+@RestController
+@RequestMapping("/system/notify-template")
+@Validated
+public class NotifyTemplateController {
+
+ @Resource
+ private NotifyTemplateService notifyTemplateService;
+
+ @PostMapping("/create")
+ @ApiOperation("创建站内信模版")
+ @PreAuthorize("@ss.hasPermission('system:notify-template:create')")
+ public CommonResult createNotifyTemplate(@Valid @RequestBody NotifyTemplateCreateReqVO createReqVO) {
+ return success(notifyTemplateService.createNotifyTemplate(createReqVO));
+ }
+
+ @PutMapping("/update")
+ @ApiOperation("更新站内信模版")
+ @PreAuthorize("@ss.hasPermission('system:notify-template:update')")
+ public CommonResult updateNotifyTemplate(@Valid @RequestBody NotifyTemplateUpdateReqVO updateReqVO) {
+ notifyTemplateService.updateNotifyTemplate(updateReqVO);
+ return success(true);
+ }
+
+ @DeleteMapping("/delete")
+ @ApiOperation("删除站内信模版")
+ @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
+ @PreAuthorize("@ss.hasPermission('system:notify-template:delete')")
+ public CommonResult deleteNotifyTemplate(@RequestParam("id") Long id) {
+ notifyTemplateService.deleteNotifyTemplate(id);
+ return success(true);
+ }
+
+ @GetMapping("/get")
+ @ApiOperation("获得站内信模版")
+ @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
+ @PreAuthorize("@ss.hasPermission('system:notify-template:query')")
+ public CommonResult getNotifyTemplate(@RequestParam("id") Long id) {
+ NotifyTemplateDO notifyTemplate = notifyTemplateService.getNotifyTemplate(id);
+ return success(NotifyTemplateConvert.INSTANCE.convert(notifyTemplate));
+ }
+
+ @GetMapping("/list")
+ @ApiOperation("获得站内信模版列表")
+ @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
+ @PreAuthorize("@ss.hasPermission('system:notify-template:query')")
+ public CommonResult> getNotifyTemplateList(@RequestParam("ids") Collection ids) {
+ List list = notifyTemplateService.getNotifyTemplateList(ids);
+ return success(NotifyTemplateConvert.INSTANCE.convertList(list));
+ }
+
+ @GetMapping("/page")
+ @ApiOperation("获得站内信模版分页")
+ @PreAuthorize("@ss.hasPermission('system:notify-template:query')")
+ public CommonResult> getNotifyTemplatePage(@Valid NotifyTemplatePageReqVO pageVO) {
+ PageResult pageResult = notifyTemplateService.getNotifyTemplatePage(pageVO);
+ return success(NotifyTemplateConvert.INSTANCE.convertPage(pageResult));
+ }
+
+ @GetMapping("/export-excel")
+ @ApiOperation("导出站内信模版 Excel")
+ @PreAuthorize("@ss.hasPermission('system:notify-template:export')")
+ @OperateLog(type = EXPORT)
+ public void exportNotifyTemplateExcel(@Valid NotifyTemplateExportReqVO exportReqVO,
+ HttpServletResponse response) throws IOException {
+ List list = notifyTemplateService.getNotifyTemplateList(exportReqVO);
+ // 导出 Excel
+ List datas = NotifyTemplateConvert.INSTANCE.convertList02(list);
+ ExcelUtils.write(response, "站内信模版.xls", "数据", NotifyTemplateExcelVO.class, datas);
+ }
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/UserNotifyMessageController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/UserNotifyMessageController.java
new file mode 100644
index 000000000..c74291d58
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/UserNotifyMessageController.java
@@ -0,0 +1,83 @@
+package cn.iocoder.yudao.module.system.controller.admin.notify;
+
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageRespVO;
+import cn.iocoder.yudao.module.system.convert.notify.NotifyMessageConvert;
+import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
+import cn.iocoder.yudao.module.system.service.notify.NotifyMessageService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import javax.validation.Valid;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
+/**
+ * 管理后台 - 站内信-消息中心
+ *
+ * @author xrcoder
+ */
+@Api(tags = "管理后台 - 站内信-消息中心")
+@RestController
+@RequestMapping("/system/user/notify-message")
+@Validated
+public class UserNotifyMessageController {
+
+ @Resource
+ private NotifyMessageService notifyMessageService;
+
+
+ @GetMapping("/page")
+ @ApiOperation("获得站内信分页")
+ public CommonResult> getNotifyMessagePage(@Valid NotifyMessagePageReqVO pageVO) {
+ PageResult pageResult = notifyMessageService.getNotifyMessagePage(pageVO);
+ return success(NotifyMessageConvert.INSTANCE.convertPage(pageResult));
+ }
+
+ @GetMapping("/latest/list")
+ @ApiOperation("获得最新10站内信列表")
+ public CommonResult> getNotifyLatestMessageList() {
+ return success(Collections.emptyList());
+ }
+
+ @GetMapping("/unread/count")
+ @ApiOperation("获得未读站内信数量")
+ public CommonResult getUnreadNotifyMessageCount() {
+ return success(1L);
+ }
+
+ @GetMapping("/read")
+ @ApiOperation("获得站内信")
+ @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
+ public CommonResult readNotifyMessage(@RequestParam("id") Long id) {
+ NotifyMessageDO notifyMessage = notifyMessageService.getNotifyMessage(id);
+ // TODO 记录消息已读。
+ return success(NotifyMessageConvert.INSTANCE.convert(notifyMessage));
+ }
+
+ @GetMapping("/read/list")
+ @ApiOperation("批量标记已读")
+ @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
+ public CommonResult batchUpdateNotifyMessageReadStatus(@RequestParam("ids") Collection ids) {
+ return success(Boolean.TRUE);
+ }
+
+ @GetMapping("/read/all")
+ @ApiOperation("所有未读消息标记已读")
+ @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
+ public CommonResult batchUpdateAllNotifyMessageReadStatus(@RequestParam("ids") Collection ids) {
+ return success(Boolean.TRUE);
+ }
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageBaseVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageBaseVO.java
new file mode 100644
index 000000000..b19480e71
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageBaseVO.java
@@ -0,0 +1,40 @@
+package cn.iocoder.yudao.module.system.controller.admin.notify.vo.message;
+
+import lombok.*;
+import java.util.*;
+import io.swagger.annotations.*;
+import javax.validation.constraints.*;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+/**
+* 站内信 Base VO,提供给添加、修改、详细的子 VO 使用
+* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
+*/
+@Data
+public class NotifyMessageBaseVO {
+
+ @ApiModelProperty(value = "用户编号", required = true)
+ @NotNull(message = "用户编号不能为空")
+ private Long userId;
+
+ @ApiModelProperty(value = "用户类型", required = true)
+ @NotNull(message = "用户类型不能为空")
+ private Integer userType;
+
+ @ApiModelProperty(value = "标题")
+ private String title;
+
+ @ApiModelProperty(value = "内容", required = true)
+ @NotNull(message = "内容不能为空")
+ private String content;
+
+ @ApiModelProperty(value = "是否已读 0-未读 1-已读")
+ private Boolean readStatus;
+
+ @ApiModelProperty(value = "阅读时间")
+ @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+ private Date readTime;
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageCreateReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageCreateReqVO.java
new file mode 100644
index 000000000..61a0e5666
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageCreateReqVO.java
@@ -0,0 +1,15 @@
+package cn.iocoder.yudao.module.system.controller.admin.notify.vo.message;
+
+import lombok.*;
+import io.swagger.annotations.*;
+
+@ApiModel("管理后台 - 站内信创建 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class NotifyMessageCreateReqVO extends NotifyMessageBaseVO {
+
+ @ApiModelProperty(value = "站内信模版编号")
+ private Long templateId;
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessagePageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessagePageReqVO.java
new file mode 100644
index 000000000..8331d1b5f
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessagePageReqVO.java
@@ -0,0 +1,27 @@
+package cn.iocoder.yudao.module.system.controller.admin.notify.vo.message;
+
+import lombok.*;
+import java.util.*;
+import io.swagger.annotations.*;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@ApiModel("管理后台 - 站内信分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class NotifyMessagePageReqVO extends PageParam {
+
+ @ApiModelProperty(value = "标题")
+ private String title;
+
+ @ApiModelProperty(value = "是否已读 0-未读 1-已读")
+ private Boolean readStatus;
+
+ @ApiModelProperty(value = "创建时间")
+ @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+ private Date[] createTime;
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageRespVO.java
new file mode 100644
index 000000000..530b368c1
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageRespVO.java
@@ -0,0 +1,19 @@
+package cn.iocoder.yudao.module.system.controller.admin.notify.vo.message;
+
+import lombok.*;
+import java.util.*;
+import io.swagger.annotations.*;
+
+@ApiModel("管理后台 - 站内信 Response VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class NotifyMessageRespVO extends NotifyMessageBaseVO {
+
+ @ApiModelProperty(value = "ID", required = true)
+ private Long id;
+
+ @ApiModelProperty(value = "创建时间", required = true)
+ private Date createTime;
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageUpdateReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageUpdateReqVO.java
new file mode 100644
index 000000000..3576cca9f
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageUpdateReqVO.java
@@ -0,0 +1,20 @@
+package cn.iocoder.yudao.module.system.controller.admin.notify.vo.message;
+
+import lombok.*;
+import io.swagger.annotations.*;
+import javax.validation.constraints.*;
+
+@ApiModel("管理后台 - 站内信更新 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class NotifyMessageUpdateReqVO extends NotifyMessageBaseVO {
+
+ @ApiModelProperty(value = "ID", required = true)
+ @NotNull(message = "ID不能为空")
+ private Long id;
+
+ @ApiModelProperty(value = "站内信模版编号")
+ private Long templateId;
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateBaseVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateBaseVO.java
new file mode 100644
index 000000000..371239455
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateBaseVO.java
@@ -0,0 +1,34 @@
+package cn.iocoder.yudao.module.system.controller.admin.notify.vo.template;
+
+import lombok.*;
+import java.util.*;
+import io.swagger.annotations.*;
+import javax.validation.constraints.*;
+
+/**
+* 站内信模版 Base VO,提供给添加、修改、详细的子 VO 使用
+* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
+*/
+@Data
+public class NotifyTemplateBaseVO {
+
+ @ApiModelProperty(value = "模版编码", required = true)
+ @NotNull(message = "模版编码不能为空")
+ private String code;
+
+ @ApiModelProperty(value = "模版标题", required = true)
+ @NotNull(message = "模版标题不能为空")
+ private String title;
+
+ @ApiModelProperty(value = "模版内容", required = true)
+ @NotNull(message = "模版内容不能为空")
+ private String content;
+
+ @ApiModelProperty(value = "状态:1-启用 0-禁用", required = true)
+ @NotNull(message = "状态:1-启用 0-禁用不能为空")
+ private String status;
+
+ @ApiModelProperty(value = "备注")
+ private String remarks;
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateCreateReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateCreateReqVO.java
new file mode 100644
index 000000000..e39a2774a
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateCreateReqVO.java
@@ -0,0 +1,12 @@
+package cn.iocoder.yudao.module.system.controller.admin.notify.vo.template;
+
+import lombok.*;
+import io.swagger.annotations.*;
+
+@ApiModel("管理后台 - 站内信模版创建 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class NotifyTemplateCreateReqVO extends NotifyTemplateBaseVO {
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateExcelVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateExcelVO.java
new file mode 100644
index 000000000..e0402da8c
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateExcelVO.java
@@ -0,0 +1,42 @@
+package cn.iocoder.yudao.module.system.controller.admin.notify.vo.template;
+
+import lombok.*;
+import java.util.*;
+import io.swagger.annotations.*;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
+import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
+
+
+/**
+ * 站内信模版 Excel VO
+ *
+ * @author 芋道源码
+ */
+@Data
+public class NotifyTemplateExcelVO {
+
+ @ExcelProperty("ID")
+ private Long id;
+
+ @ExcelProperty("模版编码")
+ private String code;
+
+ @ExcelProperty("模版标题")
+ private String title;
+
+ @ExcelProperty("模版内容")
+ private String content;
+
+ @ExcelProperty(value = "状态:1-启用 0-禁用", converter = DictConvert.class)
+ @DictFormat("common_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中
+ private String status;
+
+ @ExcelProperty("备注")
+ private String remarks;
+
+ @ExcelProperty("创建时间")
+ private Date createTime;
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateExportReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateExportReqVO.java
new file mode 100644
index 000000000..a9f8877e2
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateExportReqVO.java
@@ -0,0 +1,28 @@
+package cn.iocoder.yudao.module.system.controller.admin.notify.vo.template;
+
+import lombok.*;
+import java.util.*;
+import io.swagger.annotations.*;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@ApiModel(value = "管理后台 - 站内信模版 Excel 导出 Request VO", description = "参数和 NotifyTemplatePageReqVO 是一致的")
+@Data
+public class NotifyTemplateExportReqVO {
+
+ @ApiModelProperty(value = "模版编码")
+ private String code;
+
+ @ApiModelProperty(value = "模版标题")
+ private String title;
+
+ @ApiModelProperty(value = "状态:1-启用 0-禁用")
+ private String status;
+
+ @ApiModelProperty(value = "创建时间")
+ @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+ private Date[] createTime;
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplatePageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplatePageReqVO.java
new file mode 100644
index 000000000..7a8145b67
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplatePageReqVO.java
@@ -0,0 +1,30 @@
+package cn.iocoder.yudao.module.system.controller.admin.notify.vo.template;
+
+import lombok.*;
+import java.util.*;
+import io.swagger.annotations.*;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@ApiModel("管理后台 - 站内信模版分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class NotifyTemplatePageReqVO extends PageParam {
+
+ @ApiModelProperty(value = "模版编码")
+ private String code;
+
+ @ApiModelProperty(value = "模版标题")
+ private String title;
+
+ @ApiModelProperty(value = "状态:1-启用 0-禁用")
+ private String status;
+
+ @ApiModelProperty(value = "创建时间")
+ @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+ private Date[] createTime;
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateRespVO.java
new file mode 100644
index 000000000..52dd3656e
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateRespVO.java
@@ -0,0 +1,19 @@
+package cn.iocoder.yudao.module.system.controller.admin.notify.vo.template;
+
+import lombok.*;
+import java.util.*;
+import io.swagger.annotations.*;
+
+@ApiModel("管理后台 - 站内信模版 Response VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class NotifyTemplateRespVO extends NotifyTemplateBaseVO {
+
+ @ApiModelProperty(value = "ID", required = true)
+ private Long id;
+
+ @ApiModelProperty(value = "创建时间", required = true)
+ private Date createTime;
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateUpdateReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateUpdateReqVO.java
new file mode 100644
index 000000000..267159447
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateUpdateReqVO.java
@@ -0,0 +1,17 @@
+package cn.iocoder.yudao.module.system.controller.admin.notify.vo.template;
+
+import lombok.*;
+import io.swagger.annotations.*;
+import javax.validation.constraints.*;
+
+@ApiModel("管理后台 - 站内信模版更新 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class NotifyTemplateUpdateReqVO extends NotifyTemplateBaseVO {
+
+ @ApiModelProperty(value = "ID", required = true)
+ @NotNull(message = "ID不能为空")
+ private Long id;
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyMessageConvert.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyMessageConvert.java
new file mode 100644
index 000000000..b5bce25d4
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyMessageConvert.java
@@ -0,0 +1,34 @@
+package cn.iocoder.yudao.module.system.convert.notify;
+
+import java.util.*;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageCreateReqVO;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageRespVO;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageUpdateReqVO;
+import org.mapstruct.Mapper;
+import org.mapstruct.factory.Mappers;
+import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
+
+/**
+ * 站内信 Convert
+ *
+ * @author xrcoder
+ */
+@Mapper
+public interface NotifyMessageConvert {
+
+ NotifyMessageConvert INSTANCE = Mappers.getMapper(NotifyMessageConvert.class);
+
+ NotifyMessageDO convert(NotifyMessageCreateReqVO bean);
+
+ NotifyMessageDO convert(NotifyMessageUpdateReqVO bean);
+
+ NotifyMessageRespVO convert(NotifyMessageDO bean);
+
+ List convertList(List list);
+
+ PageResult convertPage(PageResult page);
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyTemplateConvert.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyTemplateConvert.java
new file mode 100644
index 000000000..8d58067b9
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyTemplateConvert.java
@@ -0,0 +1,37 @@
+package cn.iocoder.yudao.module.system.convert.notify;
+
+import java.util.*;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateCreateReqVO;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateExcelVO;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateRespVO;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateUpdateReqVO;
+import org.mapstruct.Mapper;
+import org.mapstruct.factory.Mappers;
+import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
+
+/**
+ * 站内信模版 Convert
+ *
+ * @author xrcoder
+ */
+@Mapper
+public interface NotifyTemplateConvert {
+
+ NotifyTemplateConvert INSTANCE = Mappers.getMapper(NotifyTemplateConvert.class);
+
+ NotifyTemplateDO convert(NotifyTemplateCreateReqVO bean);
+
+ NotifyTemplateDO convert(NotifyTemplateUpdateReqVO bean);
+
+ NotifyTemplateRespVO convert(NotifyTemplateDO bean);
+
+ List convertList(List list);
+
+ PageResult convertPage(PageResult page);
+
+ List convertList02(List list);
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyMessageDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyMessageDO.java
new file mode 100644
index 000000000..c826c9d10
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyMessageDO.java
@@ -0,0 +1,59 @@
+package cn.iocoder.yudao.module.system.dal.dataobject.notify;
+
+import lombok.*;
+import java.util.*;
+import com.baomidou.mybatisplus.annotation.*;
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+
+/**
+ * 站内信 DO
+ *
+ * @author xrcoder
+ */
+@TableName("system_notify_message")
+@KeySequence("system_notify_message_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class NotifyMessageDO extends BaseDO {
+
+ /**
+ * ID
+ */
+ @TableId
+ private Long id;
+ /**
+ * 站内信模版编号
+ */
+ private Long templateId;
+ /**
+ * 用户编号
+ */
+ private Long userId;
+ /**
+ * 用户类型
+ */
+ private Integer userType;
+ /**
+ * 标题
+ */
+ private String title;
+ /**
+ * 内容
+ */
+ private String content;
+ /**
+ * 是否已读 0-未读 1-已读
+ *
+ * 枚举 {@link TODO system_notify_message_read_status 对应的类}
+ */
+ private Boolean readStatus;
+ /**
+ * 阅读时间
+ */
+ private Date readTime;
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyTemplateDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyTemplateDO.java
new file mode 100644
index 000000000..aa7cce11e
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyTemplateDO.java
@@ -0,0 +1,55 @@
+package cn.iocoder.yudao.module.system.dal.dataobject.notify;
+
+import lombok.*;
+import java.util.*;
+import com.baomidou.mybatisplus.annotation.*;
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+
+/**
+ * 站内信模版 DO
+ *
+ * @author xrcoder
+ */
+@TableName("system_notify_template")
+@KeySequence("system_notify_template_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class NotifyTemplateDO extends BaseDO {
+
+ /**
+ * ID
+ */
+ @TableId
+ private Long id;
+ /**
+ * 模版编码
+ */
+ private String code;
+ /**
+ * 模版标题
+ */
+ private String title;
+ /**
+ * 模版内容
+ */
+ private String content;
+ /**
+ * 参数数组
+ */
+ private String params;
+ /**
+ * 状态:1-启用 0-禁用
+ *
+ * 枚举 {@link TODO common_status 对应的类}
+ */
+ private String status;
+ /**
+ * 备注
+ */
+ private String remarks;
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java
new file mode 100644
index 000000000..2a7293d10
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java
@@ -0,0 +1,25 @@
+package cn.iocoder.yudao.module.system.dal.mysql.notify;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
+import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 站内信 Mapper
+ *
+ * @author xrcoder
+ */
+@Mapper
+public interface NotifyMessageMapper extends BaseMapperX {
+
+ default PageResult selectPage(NotifyMessagePageReqVO reqVO) {
+ return selectPage(reqVO, new LambdaQueryWrapperX()
+ .likeIfPresent(NotifyMessageDO::getTitle, reqVO.getTitle())
+ .eqIfPresent(NotifyMessageDO::getReadStatus, reqVO.getReadStatus())
+ .betweenIfPresent(NotifyMessageDO::getCreateTime, reqVO.getCreateTime())
+ .orderByDesc(NotifyMessageDO::getId));
+ }
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyTemplateMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyTemplateMapper.java
new file mode 100644
index 000000000..115055b09
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyTemplateMapper.java
@@ -0,0 +1,39 @@
+package cn.iocoder.yudao.module.system.dal.mysql.notify;
+
+import java.util.*;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateExportReqVO;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplatePageReqVO;
+import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 站内信模版 Mapper
+ *
+ * @author xrcoder
+ */
+@Mapper
+public interface NotifyTemplateMapper extends BaseMapperX {
+
+ default PageResult selectPage(NotifyTemplatePageReqVO reqVO) {
+ return selectPage(reqVO, new LambdaQueryWrapperX()
+ .eqIfPresent(NotifyTemplateDO::getCode, reqVO.getCode())
+ .eqIfPresent(NotifyTemplateDO::getTitle, reqVO.getTitle())
+ .eqIfPresent(NotifyTemplateDO::getStatus, reqVO.getStatus())
+ .betweenIfPresent(NotifyTemplateDO::getCreateTime, reqVO.getCreateTime())
+ .orderByDesc(NotifyTemplateDO::getId));
+ }
+
+ default List selectList(NotifyTemplateExportReqVO reqVO) {
+ return selectList(new LambdaQueryWrapperX()
+ .eqIfPresent(NotifyTemplateDO::getCode, reqVO.getCode())
+ .eqIfPresent(NotifyTemplateDO::getTitle, reqVO.getTitle())
+ .eqIfPresent(NotifyTemplateDO::getStatus, reqVO.getStatus())
+ .betweenIfPresent(NotifyTemplateDO::getCreateTime, reqVO.getCreateTime())
+ .orderByDesc(NotifyTemplateDO::getId));
+ }
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageService.java
new file mode 100644
index 000000000..42b4f05ea
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageService.java
@@ -0,0 +1,65 @@
+package cn.iocoder.yudao.module.system.service.notify;
+
+import java.util.*;
+import javax.validation.*;
+
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageCreateReqVO;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageUpdateReqVO;
+import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+
+/**
+ * 站内信 Service 接口
+ *
+ * @author xrcoder
+ */
+public interface NotifyMessageService {
+
+ /**
+ * 创建站内信
+ *
+ * @param createReqVO 创建信息
+ * @return 编号
+ */
+ Long createNotifyMessage(@Valid NotifyMessageCreateReqVO createReqVO);
+
+ /**
+ * 更新站内信
+ *
+ * @param updateReqVO 更新信息
+ */
+ void updateNotifyMessage(@Valid NotifyMessageUpdateReqVO updateReqVO);
+
+ /**
+ * 删除站内信
+ *
+ * @param id 编号
+ */
+ void deleteNotifyMessage(Long id);
+
+ /**
+ * 获得站内信
+ *
+ * @param id 编号
+ * @return 站内信
+ */
+ NotifyMessageDO getNotifyMessage(Long id);
+
+ /**
+ * 获得站内信列表
+ *
+ * @param ids 编号
+ * @return 站内信列表
+ */
+ List getNotifyMessageList(Collection ids);
+
+ /**
+ * 获得站内信分页
+ *
+ * @param pageReqVO 分页查询
+ * @return 站内信分页
+ */
+ PageResult getNotifyMessagePage(NotifyMessagePageReqVO pageReqVO);
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java
new file mode 100644
index 000000000..25a6f94a6
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java
@@ -0,0 +1,78 @@
+package cn.iocoder.yudao.module.system.service.notify;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageCreateReqVO;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageUpdateReqVO;
+import cn.iocoder.yudao.module.system.convert.notify.NotifyMessageConvert;
+import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
+import cn.iocoder.yudao.module.system.dal.mysql.notify.NotifyMessageMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+
+import javax.annotation.Resource;
+import java.util.Collection;
+import java.util.List;
+
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.NOTIFY_MESSAGE_NOT_EXISTS;
+
+/**
+ * 站内信 Service 实现类
+ *
+ * @author xrcoder
+ */
+@Service
+@Validated
+public class NotifyMessageServiceImpl implements NotifyMessageService {
+
+ @Resource
+ private NotifyMessageMapper notifyMessageMapper;
+
+ @Override
+ public Long createNotifyMessage(NotifyMessageCreateReqVO createReqVO) {
+ // 插入
+ NotifyMessageDO notifyMessage = NotifyMessageConvert.INSTANCE.convert(createReqVO);
+ notifyMessageMapper.insert(notifyMessage);
+ // 返回
+ return notifyMessage.getId();
+ }
+
+ @Override
+ public void updateNotifyMessage(NotifyMessageUpdateReqVO updateReqVO) {
+ // 校验存在
+ this.validateNotifyMessageExists(updateReqVO.getId());
+ // 更新
+ NotifyMessageDO updateObj = NotifyMessageConvert.INSTANCE.convert(updateReqVO);
+ notifyMessageMapper.updateById(updateObj);
+ }
+
+ @Override
+ public void deleteNotifyMessage(Long id) {
+ // 校验存在
+ this.validateNotifyMessageExists(id);
+ // 删除
+ notifyMessageMapper.deleteById(id);
+ }
+
+ private void validateNotifyMessageExists(Long id) {
+ if (notifyMessageMapper.selectById(id) == null) {
+ throw exception(NOTIFY_MESSAGE_NOT_EXISTS);
+ }
+ }
+
+ @Override
+ public NotifyMessageDO getNotifyMessage(Long id) {
+ return notifyMessageMapper.selectById(id);
+ }
+
+ @Override
+ public List getNotifyMessageList(Collection ids) {
+ return notifyMessageMapper.selectBatchIds(ids);
+ }
+
+ @Override
+ public PageResult getNotifyMessagePage(NotifyMessagePageReqVO pageReqVO) {
+ return notifyMessageMapper.selectPage(pageReqVO);
+ }
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateService.java
new file mode 100644
index 000000000..744d5585e
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateService.java
@@ -0,0 +1,74 @@
+package cn.iocoder.yudao.module.system.service.notify;
+
+import java.util.*;
+import javax.validation.*;
+
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateCreateReqVO;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateExportReqVO;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplatePageReqVO;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateUpdateReqVO;
+import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+
+/**
+ * 站内信模版 Service 接口
+ *
+ * @author xrcoder
+ */
+public interface NotifyTemplateService {
+
+ /**
+ * 创建站内信模版
+ *
+ * @param createReqVO 创建信息
+ * @return 编号
+ */
+ Long createNotifyTemplate(@Valid NotifyTemplateCreateReqVO createReqVO);
+
+ /**
+ * 更新站内信模版
+ *
+ * @param updateReqVO 更新信息
+ */
+ void updateNotifyTemplate(@Valid NotifyTemplateUpdateReqVO updateReqVO);
+
+ /**
+ * 删除站内信模版
+ *
+ * @param id 编号
+ */
+ void deleteNotifyTemplate(Long id);
+
+ /**
+ * 获得站内信模版
+ *
+ * @param id 编号
+ * @return 站内信模版
+ */
+ NotifyTemplateDO getNotifyTemplate(Long id);
+
+ /**
+ * 获得站内信模版列表
+ *
+ * @param ids 编号
+ * @return 站内信模版列表
+ */
+ List getNotifyTemplateList(Collection ids);
+
+ /**
+ * 获得站内信模版分页
+ *
+ * @param pageReqVO 分页查询
+ * @return 站内信模版分页
+ */
+ PageResult getNotifyTemplatePage(NotifyTemplatePageReqVO pageReqVO);
+
+ /**
+ * 获得站内信模版列表, 用于 Excel 导出
+ *
+ * @param exportReqVO 查询条件
+ * @return 站内信模版列表
+ */
+ List getNotifyTemplateList(NotifyTemplateExportReqVO exportReqVO);
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImpl.java
new file mode 100644
index 000000000..eb43af802
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImpl.java
@@ -0,0 +1,86 @@
+package cn.iocoder.yudao.module.system.service.notify;
+
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateCreateReqVO;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateExportReqVO;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplatePageReqVO;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateUpdateReqVO;
+import org.springframework.stereotype.Service;
+import javax.annotation.Resource;
+import org.springframework.validation.annotation.Validated;
+
+import java.util.*;
+
+import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+
+import cn.iocoder.yudao.module.system.convert.notify.NotifyTemplateConvert;
+import cn.iocoder.yudao.module.system.dal.mysql.notify.NotifyTemplateMapper;
+
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
+
+/**
+ * 站内信模版 Service 实现类
+ *
+ * @author xrcoder
+ */
+@Service
+@Validated
+public class NotifyTemplateServiceImpl implements NotifyTemplateService {
+
+ @Resource
+ private NotifyTemplateMapper notifyTemplateMapper;
+
+ @Override
+ public Long createNotifyTemplate(NotifyTemplateCreateReqVO createReqVO) {
+ // 插入
+ NotifyTemplateDO notifyTemplate = NotifyTemplateConvert.INSTANCE.convert(createReqVO);
+ notifyTemplateMapper.insert(notifyTemplate);
+ // 返回
+ return notifyTemplate.getId();
+ }
+
+ @Override
+ public void updateNotifyTemplate(NotifyTemplateUpdateReqVO updateReqVO) {
+ // 校验存在
+ this.validateNotifyTemplateExists(updateReqVO.getId());
+ // 更新
+ NotifyTemplateDO updateObj = NotifyTemplateConvert.INSTANCE.convert(updateReqVO);
+ notifyTemplateMapper.updateById(updateObj);
+ }
+
+ @Override
+ public void deleteNotifyTemplate(Long id) {
+ // 校验存在
+ this.validateNotifyTemplateExists(id);
+ // 删除
+ notifyTemplateMapper.deleteById(id);
+ }
+
+ private void validateNotifyTemplateExists(Long id) {
+ if (notifyTemplateMapper.selectById(id) == null) {
+ throw exception(NOTIFY_TEMPLATE_NOT_EXISTS);
+ }
+ }
+
+ @Override
+ public NotifyTemplateDO getNotifyTemplate(Long id) {
+ return notifyTemplateMapper.selectById(id);
+ }
+
+ @Override
+ public List getNotifyTemplateList(Collection ids) {
+ return notifyTemplateMapper.selectBatchIds(ids);
+ }
+
+ @Override
+ public PageResult getNotifyTemplatePage(NotifyTemplatePageReqVO pageReqVO) {
+ return notifyTemplateMapper.selectPage(pageReqVO);
+ }
+
+ @Override
+ public List getNotifyTemplateList(NotifyTemplateExportReqVO exportReqVO) {
+ return notifyTemplateMapper.selectList(exportReqVO);
+ }
+
+}
From d16f873521d24892f1148cfa9b43f01e94514e04 Mon Sep 17 00:00:00 2001
From: xrcoder <53924337@qq.com>
Date: Sat, 6 Aug 2022 10:03:09 +0800
Subject: [PATCH 02/18] =?UTF-8?q?=E7=AB=99=E5=86=85=E4=BF=A1=E6=A8=A1?=
=?UTF-8?q?=E6=9D=BF=E5=8A=9F=E8=83=BD=E5=AE=8C=E5=96=84=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../system/enums/ErrorCodeConstants.java | 1 +
.../vo/template/NotifyTemplateRespVO.java | 3 +
.../dataobject/notify/NotifyTemplateDO.java | 27 ++-
.../mysql/notify/NotifyTemplateMapper.java | 9 +
.../notify/NotifyTemplateRefreshConsumer.java | 29 ++++
.../notify/NotifyTemplateRefreshMessage.java | 21 +++
.../mq/producer/notify/NotifyProducer.java | 33 ++++
.../service/notify/NotifyTemplateService.java | 24 +++
.../notify/NotifyTemplateServiceImpl.java | 159 +++++++++++++++++-
9 files changed, 290 insertions(+), 16 deletions(-)
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/consumer/notify/NotifyTemplateRefreshConsumer.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/message/notify/NotifyTemplateRefreshMessage.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/producer/notify/NotifyProducer.java
diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
index 321599f00..078deb7f4 100644
--- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
+++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
@@ -144,6 +144,7 @@ public interface ErrorCodeConstants {
// ========== 站内信模版 1002023000 ==========
ErrorCode NOTIFY_TEMPLATE_NOT_EXISTS = new ErrorCode(1002023000, "站内信模版不存在");
+ ErrorCode NOTIFY_TEMPLATE_CODE_DUPLICATE = new ErrorCode(1002023001, "已经存在编码为【{}】的站内信模板");
// ========== 站内信 1002024000 ==========
ErrorCode NOTIFY_MESSAGE_NOT_EXISTS = new ErrorCode(1002024000, "站内信不存在");
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateRespVO.java
index 52dd3656e..f77126f6c 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateRespVO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateRespVO.java
@@ -13,6 +13,9 @@ public class NotifyTemplateRespVO extends NotifyTemplateBaseVO {
@ApiModelProperty(value = "ID", required = true)
private Long id;
+ @ApiModelProperty(value = "参数数组", example = "name,code")
+ private List params;
+
@ApiModelProperty(value = "创建时间", required = true)
private Date createTime;
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyTemplateDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyTemplateDO.java
index aa7cce11e..2066f0b23 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyTemplateDO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyTemplateDO.java
@@ -1,16 +1,22 @@
package cn.iocoder.yudao.module.system.dal.dataobject.notify;
-import lombok.*;
-import java.util.*;
-import com.baomidou.mybatisplus.annotation.*;
+import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import com.baomidou.mybatisplus.annotation.KeySequence;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
+import lombok.*;
+
+import java.util.List;
/**
* 站内信模版 DO
*
* @author xrcoder
*/
-@TableName("system_notify_template")
+@TableName(value = "system_notify_template", autoResultMap = true)
@KeySequence("system_notify_template_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@@ -25,28 +31,35 @@ public class NotifyTemplateDO extends BaseDO {
*/
@TableId
private Long id;
+
/**
* 模版编码
*/
private String code;
+
/**
* 模版标题
*/
private String title;
+
/**
* 模版内容
*/
private String content;
+
/**
* 参数数组
*/
- private String params;
+ @TableField(typeHandler = JacksonTypeHandler.class)
+ private List params;
+
/**
* 状态:1-启用 0-禁用
- *
- * 枚举 {@link TODO common_status 对应的类}
+ *
+ * 枚举 {@link CommonStatusEnum}
*/
private String status;
+
/**
* 备注
*/
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyTemplateMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyTemplateMapper.java
index 115055b09..c71a054b1 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyTemplateMapper.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyTemplateMapper.java
@@ -8,7 +8,9 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplatePageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
+import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO;
import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
/**
* 站内信模版 Mapper
@@ -18,6 +20,13 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface NotifyTemplateMapper extends BaseMapperX {
+ @Select("SELECT COUNT(*) FROM system_notify_template WHERE update_time > #{maxUpdateTime}")
+ Long selectCountByUpdateTimeGt(Date maxUpdateTime);
+
+ default NotifyTemplateDO selectByCode(String code) {
+ return selectOne(NotifyTemplateDO::getCode, code);
+ }
+
default PageResult selectPage(NotifyTemplatePageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX()
.eqIfPresent(NotifyTemplateDO::getCode, reqVO.getCode())
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/consumer/notify/NotifyTemplateRefreshConsumer.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/consumer/notify/NotifyTemplateRefreshConsumer.java
new file mode 100644
index 000000000..c2d8133b3
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/consumer/notify/NotifyTemplateRefreshConsumer.java
@@ -0,0 +1,29 @@
+package cn.iocoder.yudao.module.system.mq.consumer.notify;
+
+import cn.iocoder.yudao.framework.mq.core.pubsub.AbstractChannelMessageListener;
+import cn.iocoder.yudao.module.system.mq.message.notify.NotifyTemplateRefreshMessage;
+import cn.iocoder.yudao.module.system.service.notify.NotifyTemplateService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+
+/**
+ * 针对 {@link NotifyTemplateRefreshMessage} 的消费者
+ *
+ * @author xrcoder
+ */
+@Component
+@Slf4j
+public class NotifyTemplateRefreshConsumer extends AbstractChannelMessageListener {
+
+ @Resource
+ private NotifyTemplateService notifyTemplateService;
+
+ @Override
+ public void onMessage(NotifyTemplateRefreshMessage message) {
+ log.info("[onMessage][收到 NotifyTemplate 刷新消息]");
+ notifyTemplateService.initLocalCache();
+ }
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/message/notify/NotifyTemplateRefreshMessage.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/message/notify/NotifyTemplateRefreshMessage.java
new file mode 100644
index 000000000..3eddf0bc6
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/message/notify/NotifyTemplateRefreshMessage.java
@@ -0,0 +1,21 @@
+package cn.iocoder.yudao.module.system.mq.message.notify;
+
+import cn.iocoder.yudao.framework.mq.core.pubsub.AbstractChannelMessage;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 站内信模板的数据刷新 Message
+ *
+ * @author xrcoder
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class NotifyTemplateRefreshMessage extends AbstractChannelMessage {
+
+ @Override
+ public String getChannel() {
+ return "system.notify-template.refresh";
+ }
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/producer/notify/NotifyProducer.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/producer/notify/NotifyProducer.java
new file mode 100644
index 000000000..3affe2c2f
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/mq/producer/notify/NotifyProducer.java
@@ -0,0 +1,33 @@
+package cn.iocoder.yudao.module.system.mq.producer.notify;
+
+import cn.iocoder.yudao.framework.mq.core.RedisMQTemplate;
+import cn.iocoder.yudao.module.system.mq.message.notify.NotifyTemplateRefreshMessage;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+
+/**
+ * Notify 站内信相关消息的 Producer
+ *
+ * @author xrcoder
+ * @since 2022-08-06
+ */
+@Slf4j
+@Component
+public class NotifyProducer {
+
+ @Resource
+ private RedisMQTemplate redisMQTemplate;
+
+
+ /**
+ * 发送 {@link NotifyTemplateRefreshMessage} 消息
+ */
+ public void sendNotifyTemplateRefreshMessage() {
+ NotifyTemplateRefreshMessage message = new NotifyTemplateRefreshMessage();
+ redisMQTemplate.send(message);
+ }
+
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateService.java
index 744d5585e..f7a9318a1 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateService.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateService.java
@@ -9,6 +9,7 @@ import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.Notify
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateUpdateReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO;
/**
* 站内信模版 Service 接口
@@ -17,6 +18,29 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
*/
public interface NotifyTemplateService {
+ /**
+ * 初始化站内信模板的本地缓存
+ */
+ void initLocalCache();
+
+ /**
+ * 获得站内信模板,从缓存中
+ *
+ * @param code 模板编码
+ * @return 站内信模板
+ */
+ NotifyTemplateDO getNotifyTemplateByCodeFromCache(String code);
+
+
+ /**
+ * 格式化站内信内容
+ *
+ * @param content 站内信模板的内容
+ * @param params 站内信内容的参数
+ * @return 格式化后的内容
+ */
+ String formatNotifyTemplateContent(String content, Map params);
+
/**
* 创建站内信模版
*
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImpl.java
index eb43af802..65b71d92e 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImpl.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImpl.java
@@ -1,23 +1,34 @@
package cn.iocoder.yudao.module.system.service.notify;
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.ReUtil;
+import cn.hutool.core.util.StrUtil;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateCreateReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplatePageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateUpdateReqVO;
+import cn.iocoder.yudao.module.system.convert.notify.NotifyTemplateConvert;
+import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
+import cn.iocoder.yudao.module.system.dal.mysql.notify.NotifyTemplateMapper;
+import cn.iocoder.yudao.module.system.mq.producer.notify.NotifyProducer;
+import com.google.common.annotations.VisibleForTesting;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
-import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
-import java.util.*;
-
-import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
-import cn.iocoder.yudao.framework.common.pojo.PageResult;
-
-import cn.iocoder.yudao.module.system.convert.notify.NotifyTemplateConvert;
-import cn.iocoder.yudao.module.system.dal.mysql.notify.NotifyTemplateMapper;
+import javax.annotation.Resource;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Pattern;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
-import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
+import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.NOTIFY_TEMPLATE_CODE_DUPLICATE;
+import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.NOTIFY_TEMPLATE_NOT_EXISTS;
/**
* 站内信模版 Service 实现类
@@ -26,16 +37,123 @@ import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
*/
@Service
@Validated
+@Slf4j
public class NotifyTemplateServiceImpl implements NotifyTemplateService {
+ /**
+ * 定时执行 {@link #schedulePeriodicRefresh()} 的周期
+ * 因为已经通过 Redis Pub/Sub 机制,所以频率不需要高
+ */
+ private static final long SCHEDULER_PERIOD = 5 * 60 * 1000L;
+
+ /**
+ * 正则表达式,匹配 {} 中的变量
+ */
+ private static final Pattern PATTERN_PARAMS = Pattern.compile("\\{(.*?)}");
+
@Resource
private NotifyTemplateMapper notifyTemplateMapper;
+ @Resource
+ private NotifyProducer notifyProducer;
+
+ /**
+ * 站内信模板缓存
+ * key:站内信模板编码 {@link NotifyTemplateDO#getCode()}
+ *
+ * 这里声明 volatile 修饰的原因是,每次刷新时,直接修改指向
+ */
+ private volatile Map notifyTemplateCache;
+
+ /**
+ * 缓存站内信模板的最大更新时间,用于后续的增量轮询,判断是否有更新
+ */
+ private volatile Date maxUpdateTime;
+
+ /**
+ * 初始化站内信模板的本地缓存
+ */
+ @Override
+ public void initLocalCache() {
+ // 获取站内信模板列表,如果有更新
+ List notifyTemplateList = this.loadNotifyTemplateIfUpdate(maxUpdateTime);
+ if (CollUtil.isEmpty(notifyTemplateList)) {
+ return;
+ }
+
+ // 写入缓存
+ notifyTemplateCache = CollectionUtils.convertMap(notifyTemplateList, NotifyTemplateDO::getCode);
+ maxUpdateTime = CollectionUtils.getMaxValue(notifyTemplateList, NotifyTemplateDO::getUpdateTime);
+ log.info("[initLocalCache][初始化 NotifyTemplate 数量为 {}]", notifyTemplateList.size());
+
+ }
+
+ /**
+ * 如果站内信模板发生变化,从数据库中获取最新的全量站内信模板。
+ * 如果未发生变化,则返回空
+ *
+ * @param maxUpdateTime 当前站内信模板的最大更新时间
+ * @return 站内信模板列表
+ */
+ private List loadNotifyTemplateIfUpdate(Date maxUpdateTime) {
+ // 第一步,判断是否要更新。
+ if (maxUpdateTime == null) { // 如果更新时间为空,说明 DB 一定有新数据
+ log.info("[loadNotifyTemplateIfUpdate][首次加载全量站内信模板]");
+ } else { // 判断数据库中是否有更新的站内信模板
+ if (notifyTemplateMapper.selectCountByUpdateTimeGt(maxUpdateTime) == 0) {
+ return null;
+ }
+ log.info("[loadNotifyTemplateIfUpdate][增量加载全量站内信模板]");
+ }
+ // 第二步,如果有更新,则从数据库加载所有站内信模板
+ return notifyTemplateMapper.selectList();
+ }
+
+ @Scheduled(fixedDelay = SCHEDULER_PERIOD, initialDelay = SCHEDULER_PERIOD)
+ public void schedulePeriodicRefresh() {
+ initLocalCache();
+ }
+
+
+ /**
+ * 获得站内信模板,从缓存中
+ *
+ * @param code 模板编码
+ * @return 站内信模板
+ */
+ @Override
+ public NotifyTemplateDO getNotifyTemplateByCodeFromCache(String code) {
+ return notifyTemplateCache.get(code);
+ }
+
+ /**
+ * 格式化站内信内容
+ *
+ * @param content 站内信模板的内容
+ * @param params 站内信内容的参数
+ * @return 格式化后的内容
+ */
+ @Override
+ public String formatNotifyTemplateContent(String content, Map params) {
+ return StrUtil.format(content, params);
+ }
+
+ @VisibleForTesting
+ public List parseTemplateContentParams(String content) {
+ return ReUtil.findAllGroup1(PATTERN_PARAMS, content);
+ }
+
@Override
public Long createNotifyTemplate(NotifyTemplateCreateReqVO createReqVO) {
+ // 校验站内信编码是否重复
+ checkNotifyTemplateCodeDuplicate(null, createReqVO.getCode());
+
// 插入
NotifyTemplateDO notifyTemplate = NotifyTemplateConvert.INSTANCE.convert(createReqVO);
+ notifyTemplate.setParams(parseTemplateContentParams(notifyTemplate.getContent()));
notifyTemplateMapper.insert(notifyTemplate);
+ // 发送刷新消息
+ notifyProducer.sendNotifyTemplateRefreshMessage();
// 返回
return notifyTemplate.getId();
}
@@ -44,9 +162,16 @@ public class NotifyTemplateServiceImpl implements NotifyTemplateService {
public void updateNotifyTemplate(NotifyTemplateUpdateReqVO updateReqVO) {
// 校验存在
this.validateNotifyTemplateExists(updateReqVO.getId());
+ // 校验站内信编码是否重复
+ checkNotifyTemplateCodeDuplicate(updateReqVO.getId(), updateReqVO.getCode());
+
// 更新
NotifyTemplateDO updateObj = NotifyTemplateConvert.INSTANCE.convert(updateReqVO);
+ updateObj.setParams(parseTemplateContentParams(updateObj.getContent()));
+
notifyTemplateMapper.updateById(updateObj);
+ // 发送刷新消息
+ notifyProducer.sendNotifyTemplateRefreshMessage();
}
@Override
@@ -55,6 +180,8 @@ public class NotifyTemplateServiceImpl implements NotifyTemplateService {
this.validateNotifyTemplateExists(id);
// 删除
notifyTemplateMapper.deleteById(id);
+ // 发送刷新消息
+ notifyProducer.sendNotifyTemplateRefreshMessage();
}
private void validateNotifyTemplateExists(Long id) {
@@ -83,4 +210,18 @@ public class NotifyTemplateServiceImpl implements NotifyTemplateService {
return notifyTemplateMapper.selectList(exportReqVO);
}
+ @VisibleForTesting
+ public void checkNotifyTemplateCodeDuplicate(Long id, String code) {
+ NotifyTemplateDO template = notifyTemplateMapper.selectByCode(code);
+ if (template == null) {
+ return;
+ }
+ // 如果 id 为空,说明不用比较是否为相同 id 的字典类型
+ if (id == null) {
+ throw exception(NOTIFY_TEMPLATE_CODE_DUPLICATE, code);
+ }
+ if (!template.getId().equals(id)) {
+ throw exception(NOTIFY_TEMPLATE_CODE_DUPLICATE, code);
+ }
+ }
}
From af4290784e852ba0f673e848af75955f03eca7c4 Mon Sep 17 00:00:00 2001
From: xrcoder <53924337@qq.com>
Date: Sat, 6 Aug 2022 10:47:54 +0800
Subject: [PATCH 03/18] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7?=
=?UTF-8?q?=E6=9F=A5=E8=AF=A2=E7=AB=99=E5=86=85=E4=BF=A1=E5=88=86=E9=A1=B5?=
=?UTF-8?q?=E5=88=97=E8=A1=A8=E6=95=B0=E6=8D=AE=EF=BC=8C=E6=9C=AA=E8=AF=BB?=
=?UTF-8?q?=E7=AB=99=E5=86=85=E4=BF=A1=E6=95=B0=E9=87=8F=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../system/enums/ErrorCodeConstants.java | 1 +
.../notify/UserNotifyMessageController.java | 16 +++++-
.../vo/message/NotifyMessagePageReqVO.java | 6 +++
.../dal/mysql/notify/NotifyMessageMapper.java | 14 ++++-
.../service/notify/NotifyMessageService.java | 17 ++++--
.../notify/NotifyMessageServiceImpl.java | 52 ++++++++++++++++++-
6 files changed, 99 insertions(+), 7 deletions(-)
diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
index 078deb7f4..a126aee6e 100644
--- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
+++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
@@ -145,6 +145,7 @@ public interface ErrorCodeConstants {
// ========== 站内信模版 1002023000 ==========
ErrorCode NOTIFY_TEMPLATE_NOT_EXISTS = new ErrorCode(1002023000, "站内信模版不存在");
ErrorCode NOTIFY_TEMPLATE_CODE_DUPLICATE = new ErrorCode(1002023001, "已经存在编码为【{}】的站内信模板");
+ ErrorCode NOTIFY_TEMPLATE_PARAM_MISS = new ErrorCode(1002023002, "模板参数({})缺失");
// ========== 站内信 1002024000 ==========
ErrorCode NOTIFY_MESSAGE_NOT_EXISTS = new ErrorCode(1002024000, "站内信不存在");
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/UserNotifyMessageController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/UserNotifyMessageController.java
index c74291d58..eaae42e81 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/UserNotifyMessageController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/UserNotifyMessageController.java
@@ -1,5 +1,7 @@
package cn.iocoder.yudao.module.system.controller.admin.notify;
+import cn.hutool.core.collection.CollUtil;
+import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
@@ -23,6 +25,7 @@ import java.util.Collections;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
/**
* 管理后台 - 站内信-消息中心
@@ -42,6 +45,8 @@ public class UserNotifyMessageController {
@GetMapping("/page")
@ApiOperation("获得站内信分页")
public CommonResult> getNotifyMessagePage(@Valid NotifyMessagePageReqVO pageVO) {
+ pageVO.setUserId(getLoginUserId());
+ pageVO.setUserType(UserTypeEnum.ADMIN.getValue());
PageResult pageResult = notifyMessageService.getNotifyMessagePage(pageVO);
return success(NotifyMessageConvert.INSTANCE.convertPage(pageResult));
}
@@ -49,13 +54,22 @@ public class UserNotifyMessageController {
@GetMapping("/latest/list")
@ApiOperation("获得最新10站内信列表")
public CommonResult> getNotifyLatestMessageList() {
+ NotifyMessagePageReqVO reqVO = new NotifyMessagePageReqVO();
+ reqVO.setUserId(getLoginUserId());
+ reqVO.setUserType(UserTypeEnum.ADMIN.getValue());
+ reqVO.setPageNo(1);
+ reqVO.setPageSize(10);
+ PageResult pageResult = notifyMessageService.getNotifyMessagePage(reqVO);
+ if (CollUtil.isNotEmpty(pageResult.getList())) {
+ return success(NotifyMessageConvert.INSTANCE.convertList(pageResult.getList()));
+ }
return success(Collections.emptyList());
}
@GetMapping("/unread/count")
@ApiOperation("获得未读站内信数量")
public CommonResult getUnreadNotifyMessageCount() {
- return success(1L);
+ return success(notifyMessageService.getUnreadNotifyMessageCount(getLoginUserId(), UserTypeEnum.ADMIN.getValue()));
}
@GetMapping("/read")
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessagePageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessagePageReqVO.java
index 8331d1b5f..6db082d2c 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessagePageReqVO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessagePageReqVO.java
@@ -24,4 +24,10 @@ public class NotifyMessagePageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date[] createTime;
+
+ @ApiModelProperty(value = "用户编号", hidden = true)
+ private Long userId;
+
+ @ApiModelProperty(value = "用户类型", hidden = true)
+ private Integer userType;
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java
index 2a7293d10..899208b8b 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java
@@ -1,12 +1,15 @@
package cn.iocoder.yudao.module.system.dal.mysql.notify;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
+import cn.iocoder.yudao.module.system.enums.notify.NotifyReadStatusEnum;
import org.apache.ibatis.annotations.Mapper;
+import java.util.List;
+
/**
* 站内信 Mapper
*
@@ -20,6 +23,15 @@ public interface NotifyMessageMapper extends BaseMapperX {
.likeIfPresent(NotifyMessageDO::getTitle, reqVO.getTitle())
.eqIfPresent(NotifyMessageDO::getReadStatus, reqVO.getReadStatus())
.betweenIfPresent(NotifyMessageDO::getCreateTime, reqVO.getCreateTime())
+ .eqIfPresent(NotifyMessageDO::getUserId, reqVO.getUserId())
+ .eqIfPresent(NotifyMessageDO::getUserType, reqVO.getUserType())
.orderByDesc(NotifyMessageDO::getId));
}
+
+ default Long selectUnreadCountByUserIdAndUserType(Long userId, Integer userType) {
+ return selectCount(new LambdaQueryWrapperX()
+ .eq(NotifyMessageDO::getReadStatus, NotifyReadStatusEnum.UNREAD.getStatus())
+ .eq(NotifyMessageDO::getUserId, userId)
+ .eq(NotifyMessageDO::getUserType, userType));
+ }
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageService.java
index 42b4f05ea..847ab9a4b 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageService.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageService.java
@@ -1,13 +1,14 @@
package cn.iocoder.yudao.module.system.service.notify;
-import java.util.*;
-import javax.validation.*;
-
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageCreateReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageUpdateReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
-import cn.iocoder.yudao.framework.common.pojo.PageResult;
+
+import javax.validation.Valid;
+import java.util.Collection;
+import java.util.List;
/**
* 站内信 Service 接口
@@ -62,4 +63,12 @@ public interface NotifyMessageService {
*/
PageResult getNotifyMessagePage(NotifyMessagePageReqVO pageReqVO);
+ /**
+ * 统计用户未读站内信条数
+ *
+ * @param userId 用户ID
+ * @param userType 用户类型
+ * @return 返回未读站内信条数
+ */
+ Long getUnreadNotifyMessageCount(Long userId, Integer userType);
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java
index 25a6f94a6..c37ada4fd 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java
@@ -1,21 +1,26 @@
package cn.iocoder.yudao.module.system.service.notify;
+import cn.iocoder.yudao.framework.common.core.KeyValue;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageCreateReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageUpdateReqVO;
import cn.iocoder.yudao.module.system.convert.notify.NotifyMessageConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
+import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
import cn.iocoder.yudao.module.system.dal.mysql.notify.NotifyMessageMapper;
+import com.google.common.annotations.VisibleForTesting;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
-import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.NOTIFY_MESSAGE_NOT_EXISTS;
+import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
/**
* 站内信 Service 实现类
@@ -29,6 +34,39 @@ public class NotifyMessageServiceImpl implements NotifyMessageService {
@Resource
private NotifyMessageMapper notifyMessageMapper;
+ @Resource
+ private NotifyTemplateService notifyTemplateService;
+
+
+ @VisibleForTesting
+ public NotifyTemplateDO checkNotifyTemplateValid(String templateCode) {
+ // 获得站内信模板。考虑到效率,从缓存中获取
+ NotifyTemplateDO template = notifyTemplateService.getNotifyTemplateByCodeFromCache(templateCode);
+ // 站内信模板不存在
+ if (template == null) {
+ throw exception(NOTIFY_TEMPLATE_NOT_EXISTS);
+ }
+ return template;
+ }
+
+ /**
+ * 将参数模板,处理成有序的 KeyValue 数组
+ *
+ * @param template 站内信模板
+ * @param templateParams 原始参数
+ * @return 处理后的参数
+ */
+ @VisibleForTesting
+ public List> buildTemplateParams(NotifyTemplateDO template, Map templateParams) {
+ return template.getParams().stream().map(key -> {
+ Object value = templateParams.get(key);
+ if (value == null) {
+ throw exception(NOTIFY_TEMPLATE_PARAM_MISS, key);
+ }
+ return new KeyValue<>(key, value);
+ }).collect(Collectors.toList());
+ }
+
@Override
public Long createNotifyMessage(NotifyMessageCreateReqVO createReqVO) {
// 插入
@@ -75,4 +113,16 @@ public class NotifyMessageServiceImpl implements NotifyMessageService {
public PageResult getNotifyMessagePage(NotifyMessagePageReqVO pageReqVO) {
return notifyMessageMapper.selectPage(pageReqVO);
}
+
+ /**
+ * 统计用户未读站内信条数
+ *
+ * @param userId 用户ID
+ * @param userType 用户类型
+ * @return 返回未读站内信条数
+ */
+ @Override
+ public Long getUnreadNotifyMessageCount(Long userId, Integer userType) {
+ return notifyMessageMapper.selectUnreadCountByUserIdAndUserType(userId, userType);
+ }
}
From 7d6737479c0a5266f96241641a1be6d7d85412e9 Mon Sep 17 00:00:00 2001
From: xrcoder <53924337@qq.com>
Date: Sat, 6 Aug 2022 10:53:36 +0800
Subject: [PATCH 04/18] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=9E=9A=E4=B8=BE?=
=?UTF-8?q?=E7=B1=BB=E9=AA=8C=E8=AF=81=E3=80=82?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../admin/notify/vo/message/NotifyMessageBaseVO.java | 12 ++++++++----
.../notify/vo/template/NotifyTemplateBaseVO.java | 11 +++++++----
2 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageBaseVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageBaseVO.java
index b19480e71..ca77eaccb 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageBaseVO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageBaseVO.java
@@ -1,11 +1,14 @@
package cn.iocoder.yudao.module.system.controller.admin.notify.vo.message;
-import lombok.*;
-import java.util.*;
-import io.swagger.annotations.*;
-import javax.validation.constraints.*;
+import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
+import cn.iocoder.yudao.framework.common.validation.InEnum;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
+import javax.validation.constraints.NotNull;
+import java.util.Date;
+
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
@@ -21,6 +24,7 @@ public class NotifyMessageBaseVO {
@ApiModelProperty(value = "用户类型", required = true)
@NotNull(message = "用户类型不能为空")
+ @InEnum(value = UserTypeEnum.class, message = "用户类型必须是 {value}")
private Integer userType;
@ApiModelProperty(value = "标题")
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateBaseVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateBaseVO.java
index 371239455..bff746e14 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateBaseVO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateBaseVO.java
@@ -1,9 +1,11 @@
package cn.iocoder.yudao.module.system.controller.admin.notify.vo.template;
-import lombok.*;
-import java.util.*;
-import io.swagger.annotations.*;
-import javax.validation.constraints.*;
+import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
+import cn.iocoder.yudao.framework.common.validation.InEnum;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
/**
* 站内信模版 Base VO,提供给添加、修改、详细的子 VO 使用
@@ -26,6 +28,7 @@ public class NotifyTemplateBaseVO {
@ApiModelProperty(value = "状态:1-启用 0-禁用", required = true)
@NotNull(message = "状态:1-启用 0-禁用不能为空")
+ @InEnum(value = CommonStatusEnum.class, message = "状态必须是 {value}")
private String status;
@ApiModelProperty(value = "备注")
From 872107b319973655e11c716a2cf922348d3febb9 Mon Sep 17 00:00:00 2001
From: xrcoder <53924337@qq.com>
Date: Sat, 6 Aug 2022 11:30:12 +0800
Subject: [PATCH 05/18] =?UTF-8?q?=E5=AE=8C=E5=96=84=E7=AB=99=E5=86=85?=
=?UTF-8?q?=E4=BF=A1=E9=98=85=E8=AF=BB=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../system/enums/ErrorCodeConstants.java | 1 +
.../notify/UserNotifyMessageController.java | 9 ++-
.../vo/message/NotifyMessageBaseVO.java | 2 +-
.../vo/message/NotifyMessagePageReqVO.java | 2 +-
.../dataobject/notify/NotifyMessageDO.java | 4 +-
.../dal/mysql/notify/NotifyMessageMapper.java | 7 ++
.../service/notify/NotifyMessageService.java | 24 +++++++
.../notify/NotifyMessageServiceImpl.java | 71 +++++++++++++++++++
8 files changed, 113 insertions(+), 7 deletions(-)
diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
index a126aee6e..91dae4dfe 100644
--- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
+++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
@@ -149,5 +149,6 @@ public interface ErrorCodeConstants {
// ========== 站内信 1002024000 ==========
ErrorCode NOTIFY_MESSAGE_NOT_EXISTS = new ErrorCode(1002024000, "站内信不存在");
+ ErrorCode NOTIFY_MESSAGE_ID_PARAM_ERROR = new ErrorCode(1002024001, "站内信ID错误");
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/UserNotifyMessageController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/UserNotifyMessageController.java
index eaae42e81..4104acdc1 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/UserNotifyMessageController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/UserNotifyMessageController.java
@@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyM
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageRespVO;
import cn.iocoder.yudao.module.system.convert.notify.NotifyMessageConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
+import cn.iocoder.yudao.module.system.enums.notify.NotifyReadStatusEnum;
import cn.iocoder.yudao.module.system.service.notify.NotifyMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@@ -77,7 +78,8 @@ public class UserNotifyMessageController {
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
public CommonResult readNotifyMessage(@RequestParam("id") Long id) {
NotifyMessageDO notifyMessage = notifyMessageService.getNotifyMessage(id);
- // TODO 记录消息已读。
+ // 记录消息已读。
+ notifyMessageService.updateNotifyMessageReadStatus(id, NotifyReadStatusEnum.READ.getStatus());
return success(NotifyMessageConvert.INSTANCE.convert(notifyMessage));
}
@@ -85,13 +87,14 @@ public class UserNotifyMessageController {
@ApiOperation("批量标记已读")
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
public CommonResult batchUpdateNotifyMessageReadStatus(@RequestParam("ids") Collection ids) {
+ notifyMessageService.batchUpdateNotifyMessageReadStatus(ids, getLoginUserId());
return success(Boolean.TRUE);
}
@GetMapping("/read/all")
@ApiOperation("所有未读消息标记已读")
- @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
- public CommonResult batchUpdateAllNotifyMessageReadStatus(@RequestParam("ids") Collection ids) {
+ public CommonResult batchUpdateAllNotifyMessageReadStatus() {
+ notifyMessageService.batchUpdateAllNotifyMessageReadStatus(getLoginUserId(), UserTypeEnum.ADMIN.getValue());
return success(Boolean.TRUE);
}
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageBaseVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageBaseVO.java
index ca77eaccb..e7f7439c2 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageBaseVO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageBaseVO.java
@@ -35,7 +35,7 @@ public class NotifyMessageBaseVO {
private String content;
@ApiModelProperty(value = "是否已读 0-未读 1-已读")
- private Boolean readStatus;
+ private Integer readStatus;
@ApiModelProperty(value = "阅读时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessagePageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessagePageReqVO.java
index 6db082d2c..7f24c61c0 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessagePageReqVO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessagePageReqVO.java
@@ -18,7 +18,7 @@ public class NotifyMessagePageReqVO extends PageParam {
private String title;
@ApiModelProperty(value = "是否已读 0-未读 1-已读")
- private Boolean readStatus;
+ private Integer readStatus;
@ApiModelProperty(value = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyMessageDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyMessageDO.java
index c826c9d10..714ec4498 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyMessageDO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyMessageDO.java
@@ -48,9 +48,9 @@ public class NotifyMessageDO extends BaseDO {
/**
* 是否已读 0-未读 1-已读
*
- * 枚举 {@link TODO system_notify_message_read_status 对应的类}
+ * 枚举 {@link cn.iocoder.yudao.module.system.enums.notify.NotifyReadStatusEnum}
*/
- private Boolean readStatus;
+ private Integer readStatus;
/**
* 阅读时间
*/
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java
index 899208b8b..2c9137f11 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java
@@ -34,4 +34,11 @@ public interface NotifyMessageMapper extends BaseMapperX {
.eq(NotifyMessageDO::getUserId, userId)
.eq(NotifyMessageDO::getUserType, userType));
}
+
+ default List selectUnreadListByUserIdAndUserType(Long userId, Integer userType) {
+ return selectList(new LambdaQueryWrapperX()
+ .eq(NotifyMessageDO::getReadStatus, NotifyReadStatusEnum.UNREAD.getStatus())
+ .eq(NotifyMessageDO::getUserId, userId)
+ .eq(NotifyMessageDO::getUserType, userType));
+ }
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageService.java
index 847ab9a4b..f74a394b7 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageService.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageService.java
@@ -71,4 +71,28 @@ public interface NotifyMessageService {
* @return 返回未读站内信条数
*/
Long getUnreadNotifyMessageCount(Long userId, Integer userType);
+
+ /**
+ * 修改站内信阅读状态
+ *
+ * @param id 站内信编号
+ * @param status 状态
+ */
+ void updateNotifyMessageReadStatus(Long id, Integer status);
+
+ /**
+ * 批量修改站内信阅读状态
+ *
+ * @param ids 站内信编号集合
+ * @param userId 用户ID
+ */
+ void batchUpdateNotifyMessageReadStatus(Collection ids, Long userId);
+
+ /**
+ * 批量修改用户所有未读消息标记已读
+ *
+ * @param userId 用户ID
+ * @param userType 用户类型
+ */
+ void batchUpdateAllNotifyMessageReadStatus(Long userId, Integer userType);
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java
index c37ada4fd..4c385ee48 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java
@@ -1,7 +1,10 @@
package cn.iocoder.yudao.module.system.service.notify;
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.NumberUtil;
import cn.iocoder.yudao.framework.common.core.KeyValue;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageCreateReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageUpdateReqVO;
@@ -9,6 +12,7 @@ import cn.iocoder.yudao.module.system.convert.notify.NotifyMessageConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
import cn.iocoder.yudao.module.system.dal.mysql.notify.NotifyMessageMapper;
+import cn.iocoder.yudao.module.system.enums.notify.NotifyReadStatusEnum;
import com.google.common.annotations.VisibleForTesting;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@@ -125,4 +129,71 @@ public class NotifyMessageServiceImpl implements NotifyMessageService {
public Long getUnreadNotifyMessageCount(Long userId, Integer userType) {
return notifyMessageMapper.selectUnreadCountByUserIdAndUserType(userId, userType);
}
+
+ /**
+ * 修改站内信阅读状态
+ *
+ * @param id 站内信编号
+ * @param status 状态
+ */
+ @Override
+ public void updateNotifyMessageReadStatus(Long id, Integer status) {
+ // 校验消息是否存在
+ this.validateNotifyMessageExists(id);
+ // 更新状态
+ batchUpdateReadStatus(CollectionUtils.singleton(id));
+ }
+
+ /**
+ * 批量修改站内信阅读状态
+ *
+ * @param ids 站内信编号集合
+ * @param userId 用户ID
+ */
+ @Override
+ public void batchUpdateNotifyMessageReadStatus(Collection ids, Long userId) {
+ List list = getNotifyMessageList(ids);
+ if (CollUtil.isEmpty(list)) {
+ throw exception(NOTIFY_MESSAGE_NOT_EXISTS);
+ }
+ // 验证站内信是否是属于用户
+ for (NotifyMessageDO messageDO : list) {
+ checkNotifyMessageIdValid(messageDO, userId);
+ }
+ batchUpdateReadStatus(ids);
+ }
+
+ @VisibleForTesting
+ public void checkNotifyMessageIdValid(NotifyMessageDO notifyMessageDO, Long userId) {
+ if (!NumberUtil.equals(notifyMessageDO.getUserId(), userId)) {
+ throw exception(NOTIFY_MESSAGE_ID_PARAM_ERROR);
+ }
+ }
+
+ /**
+ * 批量修改用户所有未读消息标记已读
+ *
+ * @param userId 用户ID
+ * @param userType 用户类型
+ */
+ @Override
+ public void batchUpdateAllNotifyMessageReadStatus(Long userId, Integer userType) {
+ List list = notifyMessageMapper.selectUnreadListByUserIdAndUserType(userId, userType);
+ if (CollUtil.isNotEmpty(list)) {
+ batchUpdateReadStatus(CollectionUtils.convertList(list, NotifyMessageDO::getId));
+
+ }
+ }
+
+ private void batchUpdateReadStatus(Collection ids) {
+ if (CollUtil.isNotEmpty(ids)) {
+ for (Long id : ids) {
+ NotifyMessageDO updateObj = new NotifyMessageDO();
+ updateObj.setId(id);
+ updateObj.setReadStatus(NotifyReadStatusEnum.READ.getStatus());
+ notifyMessageMapper.updateById(updateObj);
+ }
+ }
+
+ }
}
From 131adad9c070e650fea9e644f1cca391987152e0 Mon Sep 17 00:00:00 2001
From: YunaiV
Date: Mon, 21 Nov 2022 11:52:55 +0800
Subject: [PATCH 06/18] =?UTF-8?q?review=20=E9=83=A8=E5=88=86=E7=AB=99?=
=?UTF-8?q?=E5=86=85=E4=BF=A1=E7=9A=84=E5=AE=9E=E7=8E=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../enums/notify/NotifyReadStatusEnum.java | 22 -------------------
.../notify/UserNotifyMessageController.java | 6 +----
.../dataobject/notify/NotifyMessageDO.java | 22 +++++++++++++------
.../dataobject/notify/NotifyTemplateDO.java | 12 +++-------
4 files changed, 19 insertions(+), 43 deletions(-)
delete mode 100644 yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/notify/NotifyReadStatusEnum.java
diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/notify/NotifyReadStatusEnum.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/notify/NotifyReadStatusEnum.java
deleted file mode 100644
index f0af060da..000000000
--- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/notify/NotifyReadStatusEnum.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package cn.iocoder.yudao.module.system.enums.notify;
-
-import lombok.AllArgsConstructor;
-import lombok.Getter;
-
-/**
- * 站内信阅读状态枚举类
- *
- * @author xrcoder
- */
-@Getter
-@AllArgsConstructor
-public enum NotifyReadStatusEnum {
-
- UNREAD(0),
- READ(1);
-
- /**
- * 类型
- */
- private final Integer status;
-}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/UserNotifyMessageController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/UserNotifyMessageController.java
index 4104acdc1..430c3ade8 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/UserNotifyMessageController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/UserNotifyMessageController.java
@@ -28,11 +28,7 @@ import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
-/**
- * 管理后台 - 站内信-消息中心
- *
- * @author xrcoder
- */
+// TODO 芋艿:合并到 合并到 NotifyTemplateController 中
@Api(tags = "管理后台 - 站内信-消息中心")
@RestController
@RequestMapping("/system/user/notify-message")
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyMessageDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyMessageDO.java
index 714ec4498..5a923998a 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyMessageDO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyMessageDO.java
@@ -1,9 +1,13 @@
package cn.iocoder.yudao.module.system.dal.dataobject.notify;
-import lombok.*;
-import java.util.*;
-import com.baomidou.mybatisplus.annotation.*;
+import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import com.baomidou.mybatisplus.annotation.KeySequence;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.*;
+
+import java.util.Date;
/**
* 站内信 DO
@@ -27,14 +31,20 @@ public class NotifyMessageDO extends BaseDO {
private Long id;
/**
* 站内信模版编号
+ *
+ * 关联 {@link NotifyTemplateDO#getId()}
*/
private Long templateId;
/**
* 用户编号
+ *
+ * 关联 MemberUserDO 的 id 字段、或者 AdminUserDO 的 id 字段
*/
private Long userId;
/**
* 用户类型
+ *
+ * 枚举 {@link UserTypeEnum}
*/
private Integer userType;
/**
@@ -46,11 +56,9 @@ public class NotifyMessageDO extends BaseDO {
*/
private String content;
/**
- * 是否已读 0-未读 1-已读
- *
- * 枚举 {@link cn.iocoder.yudao.module.system.enums.notify.NotifyReadStatusEnum}
+ * 是否已读
*/
- private Integer readStatus;
+ private Boolean readStatus;
/**
* 阅读时间
*/
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyTemplateDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyTemplateDO.java
index 2066f0b23..ab8b128ea 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyTemplateDO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyTemplateDO.java
@@ -31,38 +31,32 @@ public class NotifyTemplateDO extends BaseDO {
*/
@TableId
private Long id;
-
/**
* 模版编码
*/
private String code;
-
/**
* 模版标题
*/
private String title;
-
/**
* 模版内容
*/
private String content;
-
/**
* 参数数组
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private List params;
-
/**
- * 状态:1-启用 0-禁用
- *
+ * 状态
+ *
* 枚举 {@link CommonStatusEnum}
*/
private String status;
-
/**
* 备注
*/
- private String remarks;
+ private String remark;
}
From e8dd66c6f848963e4b4329e14ecac3c80a18d844 Mon Sep 17 00:00:00 2001
From: YunaiV
Date: Mon, 21 Nov 2022 13:01:16 +0800
Subject: [PATCH 07/18] =?UTF-8?q?review=20=E9=83=A8=E5=88=86=E7=AB=99?=
=?UTF-8?q?=E5=86=85=E4=BF=A1=E7=9A=84=E5=AE=9E=E7=8E=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../admin/notify/NotifyMessageController.java | 27 +------------------
.../notify/NotifyTemplateController.java | 15 ++++-------
.../notify/UserNotifyMessageController.java | 8 +++++-
.../vo/message/NotifyMessageCreateReqVO.java | 15 -----------
.../vo/message/NotifyMessagePageReqVO.java | 13 ++++++---
.../vo/message/NotifyMessageUpdateReqVO.java | 20 --------------
.../service/notify/NotifyMessageService.java | 25 -----------------
.../notify/NotifyMessageServiceImpl.java | 27 +------------------
.../service/notify/NotifyTemplateService.java | 12 +++++----
.../notify/NotifyTemplateServiceImpl.java | 1 -
10 files changed, 30 insertions(+), 133 deletions(-)
delete mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageCreateReqVO.java
delete mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageUpdateReqVO.java
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyMessageController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyMessageController.java
index 0f5290377..7c65e4961 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyMessageController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyMessageController.java
@@ -2,10 +2,8 @@ package cn.iocoder.yudao.module.system.controller.admin.notify;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageCreateReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageRespVO;
-import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageUpdateReqVO;
import cn.iocoder.yudao.module.system.convert.notify.NotifyMessageConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
import cn.iocoder.yudao.module.system.service.notify.NotifyMessageService;
@@ -30,30 +28,6 @@ public class NotifyMessageController {
@Resource
private NotifyMessageService notifyMessageService;
- @PostMapping("/create")
- @ApiOperation("创建站内信")
- @PreAuthorize("@ss.hasPermission('system:notify-message:create')")
- public CommonResult createNotifyMessage(@Valid @RequestBody NotifyMessageCreateReqVO createReqVO) {
- return success(notifyMessageService.createNotifyMessage(createReqVO));
- }
-
- @PutMapping("/update")
- @ApiOperation("更新站内信")
- @PreAuthorize("@ss.hasPermission('system:notify-message:update')")
- public CommonResult updateNotifyMessage(@Valid @RequestBody NotifyMessageUpdateReqVO updateReqVO) {
- notifyMessageService.updateNotifyMessage(updateReqVO);
- return success(true);
- }
-
- @DeleteMapping("/delete")
- @ApiOperation("删除站内信")
- @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class)
- @PreAuthorize("@ss.hasPermission('system:notify-message:delete')")
- public CommonResult deleteNotifyMessage(@RequestParam("id") Long id) {
- notifyMessageService.deleteNotifyMessage(id);
- return success(true);
- }
-
@GetMapping("/get")
@ApiOperation("获得站内信")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@@ -70,4 +44,5 @@ public class NotifyMessageController {
PageResult pageResult = notifyMessageService.getNotifyMessagePage(pageVO);
return success(NotifyMessageConvert.INSTANCE.convertPage(pageResult));
}
+
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyTemplateController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyTemplateController.java
index fe7f8a1a2..2be58771d 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyTemplateController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyTemplateController.java
@@ -19,12 +19,12 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
-import java.util.Collection;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
+// TODO 芋艿:VO 类上的 swagger 注解完善下,例如说 swagger,枚举等等
@Api(tags = "管理后台 - 站内信模版")
@RestController
@RequestMapping("/system/notify-template")
@@ -67,15 +67,6 @@ public class NotifyTemplateController {
return success(NotifyTemplateConvert.INSTANCE.convert(notifyTemplate));
}
- @GetMapping("/list")
- @ApiOperation("获得站内信模版列表")
- @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
- @PreAuthorize("@ss.hasPermission('system:notify-template:query')")
- public CommonResult> getNotifyTemplateList(@RequestParam("ids") Collection ids) {
- List list = notifyTemplateService.getNotifyTemplateList(ids);
- return success(NotifyTemplateConvert.INSTANCE.convertList(list));
- }
-
@GetMapping("/page")
@ApiOperation("获得站内信模版分页")
@PreAuthorize("@ss.hasPermission('system:notify-template:query')")
@@ -96,4 +87,8 @@ public class NotifyTemplateController {
ExcelUtils.write(response, "站内信模版.xls", "数据", NotifyTemplateExcelVO.class, datas);
}
+ // TODO @芋艿:参考 SmsTemplateController 的 sendNotify 写一个发送站内信的接口
+
+ // TODO @芋艿:参考 SmsSendServiceImpl,新建一个 NotifySendServiceImpl,用于提供出来给发送消息。注意,不要考虑异步发送,直接 insert 就可以了。也不用考虑发送后的回调
+
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/UserNotifyMessageController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/UserNotifyMessageController.java
index 430c3ade8..04bd09160 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/UserNotifyMessageController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/UserNotifyMessageController.java
@@ -38,7 +38,7 @@ public class UserNotifyMessageController {
@Resource
private NotifyMessageService notifyMessageService;
-
+ // TODO 芋艿:和 NotifyMessageController 的 page 合并
@GetMapping("/page")
@ApiOperation("获得站内信分页")
public CommonResult> getNotifyMessagePage(@Valid NotifyMessagePageReqVO pageVO) {
@@ -48,6 +48,7 @@ public class UserNotifyMessageController {
return success(NotifyMessageConvert.INSTANCE.convertPage(pageResult));
}
+ // TODO @芋艿:url 改成 get-recent-list;方法名也改下。默认传入 size = 10;
@GetMapping("/latest/list")
@ApiOperation("获得最新10站内信列表")
public CommonResult> getNotifyLatestMessageList() {
@@ -56,6 +57,7 @@ public class UserNotifyMessageController {
reqVO.setUserType(UserTypeEnum.ADMIN.getValue());
reqVO.setPageNo(1);
reqVO.setPageSize(10);
+ // TODO 芋艿:不要用分页写;
PageResult pageResult = notifyMessageService.getNotifyMessagePage(reqVO);
if (CollUtil.isNotEmpty(pageResult.getList())) {
return success(NotifyMessageConvert.INSTANCE.convertList(pageResult.getList()));
@@ -63,12 +65,14 @@ public class UserNotifyMessageController {
return success(Collections.emptyList());
}
+ // TODO @芋艿:get-unread-count
@GetMapping("/unread/count")
@ApiOperation("获得未读站内信数量")
public CommonResult getUnreadNotifyMessageCount() {
return success(notifyMessageService.getUnreadNotifyMessageCount(getLoginUserId(), UserTypeEnum.ADMIN.getValue()));
}
+ // TODO @芋艿:把 get 站内信,和更新站内信已经读分开。其中更新单条和多条,使用一个接口就好列
@GetMapping("/read")
@ApiOperation("获得站内信")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@@ -79,6 +83,7 @@ public class UserNotifyMessageController {
return success(NotifyMessageConvert.INSTANCE.convert(notifyMessage));
}
+ // TODO @芋艿:PutMapping;update-list-read
@GetMapping("/read/list")
@ApiOperation("批量标记已读")
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
@@ -87,6 +92,7 @@ public class UserNotifyMessageController {
return success(Boolean.TRUE);
}
+ // TODO @芋艿:PutMapping:update-all-read
@GetMapping("/read/all")
@ApiOperation("所有未读消息标记已读")
public CommonResult batchUpdateAllNotifyMessageReadStatus() {
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageCreateReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageCreateReqVO.java
deleted file mode 100644
index 61a0e5666..000000000
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageCreateReqVO.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package cn.iocoder.yudao.module.system.controller.admin.notify.vo.message;
-
-import lombok.*;
-import io.swagger.annotations.*;
-
-@ApiModel("管理后台 - 站内信创建 Request VO")
-@Data
-@EqualsAndHashCode(callSuper = true)
-@ToString(callSuper = true)
-public class NotifyMessageCreateReqVO extends NotifyMessageBaseVO {
-
- @ApiModelProperty(value = "站内信模版编号")
- private Long templateId;
-
-}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessagePageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessagePageReqVO.java
index 7f24c61c0..443f3729a 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessagePageReqVO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessagePageReqVO.java
@@ -1,11 +1,15 @@
package cn.iocoder.yudao.module.system.controller.admin.notify.vo.message;
-import lombok.*;
-import java.util.*;
-import io.swagger.annotations.*;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
+import java.util.Date;
+
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ApiModel("管理后台 - 站内信分页 Request VO")
@@ -18,12 +22,13 @@ public class NotifyMessagePageReqVO extends PageParam {
private String title;
@ApiModelProperty(value = "是否已读 0-未读 1-已读")
- private Integer readStatus;
+ private Boolean readStatus;
@ApiModelProperty(value = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date[] createTime;
+ // TODO 芋艿:去掉 userId 和 userType,不要在 VO 里
@ApiModelProperty(value = "用户编号", hidden = true)
private Long userId;
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageUpdateReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageUpdateReqVO.java
deleted file mode 100644
index 3576cca9f..000000000
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageUpdateReqVO.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package cn.iocoder.yudao.module.system.controller.admin.notify.vo.message;
-
-import lombok.*;
-import io.swagger.annotations.*;
-import javax.validation.constraints.*;
-
-@ApiModel("管理后台 - 站内信更新 Request VO")
-@Data
-@EqualsAndHashCode(callSuper = true)
-@ToString(callSuper = true)
-public class NotifyMessageUpdateReqVO extends NotifyMessageBaseVO {
-
- @ApiModelProperty(value = "ID", required = true)
- @NotNull(message = "ID不能为空")
- private Long id;
-
- @ApiModelProperty(value = "站内信模版编号")
- private Long templateId;
-
-}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageService.java
index f74a394b7..e6057bef0 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageService.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageService.java
@@ -1,12 +1,9 @@
package cn.iocoder.yudao.module.system.service.notify;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageCreateReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
-import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageUpdateReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
-import javax.validation.Valid;
import java.util.Collection;
import java.util.List;
@@ -17,28 +14,6 @@ import java.util.List;
*/
public interface NotifyMessageService {
- /**
- * 创建站内信
- *
- * @param createReqVO 创建信息
- * @return 编号
- */
- Long createNotifyMessage(@Valid NotifyMessageCreateReqVO createReqVO);
-
- /**
- * 更新站内信
- *
- * @param updateReqVO 更新信息
- */
- void updateNotifyMessage(@Valid NotifyMessageUpdateReqVO updateReqVO);
-
- /**
- * 删除站内信
- *
- * @param id 编号
- */
- void deleteNotifyMessage(Long id);
-
/**
* 获得站内信
*
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java
index 4c385ee48..8150ee453 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java
@@ -71,32 +71,6 @@ public class NotifyMessageServiceImpl implements NotifyMessageService {
}).collect(Collectors.toList());
}
- @Override
- public Long createNotifyMessage(NotifyMessageCreateReqVO createReqVO) {
- // 插入
- NotifyMessageDO notifyMessage = NotifyMessageConvert.INSTANCE.convert(createReqVO);
- notifyMessageMapper.insert(notifyMessage);
- // 返回
- return notifyMessage.getId();
- }
-
- @Override
- public void updateNotifyMessage(NotifyMessageUpdateReqVO updateReqVO) {
- // 校验存在
- this.validateNotifyMessageExists(updateReqVO.getId());
- // 更新
- NotifyMessageDO updateObj = NotifyMessageConvert.INSTANCE.convert(updateReqVO);
- notifyMessageMapper.updateById(updateObj);
- }
-
- @Override
- public void deleteNotifyMessage(Long id) {
- // 校验存在
- this.validateNotifyMessageExists(id);
- // 删除
- notifyMessageMapper.deleteById(id);
- }
-
private void validateNotifyMessageExists(Long id) {
if (notifyMessageMapper.selectById(id) == null) {
throw exception(NOTIFY_MESSAGE_NOT_EXISTS);
@@ -185,6 +159,7 @@ public class NotifyMessageServiceImpl implements NotifyMessageService {
}
}
+ // TODO 芋艿:批量更新,不要单条遍历哈。
private void batchUpdateReadStatus(Collection ids) {
if (CollUtil.isNotEmpty(ids)) {
for (Long id : ids) {
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateService.java
index f7a9318a1..cb2a5576c 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateService.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateService.java
@@ -1,21 +1,23 @@
package cn.iocoder.yudao.module.system.service.notify;
-import java.util.*;
-import javax.validation.*;
-
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateCreateReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplatePageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateUpdateReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
-import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsTemplateDO;
+
+import javax.validation.Valid;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
/**
* 站内信模版 Service 接口
*
* @author xrcoder
*/
+// TODO 芋艿:缺少单测,可以参考 SmsTemplateServiceTest 写下
public interface NotifyTemplateService {
/**
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImpl.java
index 65b71d92e..1342fe03b 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImpl.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImpl.java
@@ -114,7 +114,6 @@ public class NotifyTemplateServiceImpl implements NotifyTemplateService {
initLocalCache();
}
-
/**
* 获得站内信模板,从缓存中
*
From f77522980f9898594e54ac115e4b3fc903c837c4 Mon Sep 17 00:00:00 2001
From: luowenfeng <1092164058@qq.com>
Date: Wed, 23 Nov 2022 12:26:51 +0800
Subject: [PATCH 08/18] =?UTF-8?q?fix(=E7=AB=99=E5=86=85=E4=BF=A1=E5=8A=9F?=
=?UTF-8?q?=E8=83=BD=E8=B0=83=E6=95=B4):=20=E6=8E=A5=E5=8F=A3fix?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../admin/notify/NotifyMessageController.java | 45 ++++++++
.../notify/NotifyTemplateController.java | 16 ++-
.../notify/UserNotifyMessageController.java | 102 ------------------
.../vo/message/NotifyMessageBaseVO.java | 4 +-
.../vo/template/NotifyTemplateBaseVO.java | 2 +-
.../vo/template/NotifyTemplateExcelVO.java | 5 +-
.../template/NotifyTemplateExportReqVO.java | 2 +-
.../vo/template/NotifyTemplateSendReqVO.java | 24 +++++
.../convert/notify/NotifyMessageConvert.java | 6 --
.../dataobject/notify/NotifyTemplateDO.java | 2 +-
.../dal/mysql/notify/NotifyMessageMapper.java | 16 ++-
.../service/notify/NotifyMessageService.java | 10 +-
.../notify/NotifyMessageServiceImpl.java | 26 ++---
.../service/notify/NotifySendService.java | 51 +++++++++
.../service/notify/NotifySendServiceImpl.java | 77 +++++++++++++
15 files changed, 248 insertions(+), 140 deletions(-)
delete mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/UserNotifyMessageController.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateSendReqVO.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifySendService.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifySendServiceImpl.java
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyMessageController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyMessageController.java
index 7c65e4961..7e14b86c7 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyMessageController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyMessageController.java
@@ -1,5 +1,7 @@
package cn.iocoder.yudao.module.system.controller.admin.notify;
+import cn.hutool.core.collection.CollUtil;
+import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
@@ -17,7 +19,12 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
@Api(tags = "管理后台 - 站内信")
@RestController
@@ -41,8 +48,46 @@ public class NotifyMessageController {
@ApiOperation("获得站内信分页")
@PreAuthorize("@ss.hasPermission('system:notify-message:query')")
public CommonResult> getNotifyMessagePage(@Valid NotifyMessagePageReqVO pageVO) {
+ pageVO.setUserId(getLoginUserId());
+ pageVO.setUserType(UserTypeEnum.ADMIN.getValue());
PageResult pageResult = notifyMessageService.getNotifyMessagePage(pageVO);
return success(NotifyMessageConvert.INSTANCE.convertPage(pageResult));
}
+ @GetMapping("/get-recent-list")
+ @ApiOperation("获取当前用户最新站内信,默认10条")
+ @ApiImplicitParam(name = "size", value = "10", defaultValue = "10", dataTypeClass = Integer.class)
+ public CommonResult> getRecentList(@RequestParam(name = "size", defaultValue = "10") Integer size) {
+ NotifyMessagePageReqVO reqVO = new NotifyMessagePageReqVO();
+ reqVO.setUserId(getLoginUserId());
+ reqVO.setUserType(UserTypeEnum.ADMIN.getValue());
+
+ List pageResult = notifyMessageService.getNotifyMessageList(reqVO, size);
+ if (CollUtil.isNotEmpty(pageResult)) {
+ return success(NotifyMessageConvert.INSTANCE.convertList(pageResult));
+ }
+ return success(Collections.emptyList());
+ }
+
+ @GetMapping("/get-unread-count")
+ @ApiOperation("获得未读站内信数量")
+ public CommonResult getUnreadCount() {
+ return success(notifyMessageService.getUnreadNotifyMessageCount(getLoginUserId(), UserTypeEnum.ADMIN.getValue()));
+ }
+
+ @GetMapping("/update-list-read")
+ @ApiOperation("批量标记已读")
+ @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
+ public CommonResult batchUpdateNotifyMessageReadStatus(@RequestParam("ids") Collection ids) {
+ notifyMessageService.batchUpdateNotifyMessageReadStatus(ids, getLoginUserId());
+ return success(Boolean.TRUE);
+ }
+
+ @GetMapping("/update-all-read")
+ @ApiOperation("所有未读消息标记已读")
+ public CommonResult batchUpdateAllNotifyMessageReadStatus() {
+ notifyMessageService.batchUpdateAllNotifyMessageReadStatus(getLoginUserId(), UserTypeEnum.ADMIN.getValue());
+ return success(Boolean.TRUE);
+ }
+
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyTemplateController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyTemplateController.java
index 2be58771d..aa57a795e 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyTemplateController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyTemplateController.java
@@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.*;
import cn.iocoder.yudao.module.system.convert.notify.NotifyTemplateConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
+import cn.iocoder.yudao.module.system.service.notify.NotifySendService;
import cn.iocoder.yudao.module.system.service.notify.NotifyTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@@ -24,7 +25,6 @@ import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
-// TODO 芋艿:VO 类上的 swagger 注解完善下,例如说 swagger,枚举等等
@Api(tags = "管理后台 - 站内信模版")
@RestController
@RequestMapping("/system/notify-template")
@@ -34,6 +34,10 @@ public class NotifyTemplateController {
@Resource
private NotifyTemplateService notifyTemplateService;
+ @Resource
+ private NotifySendService notifySendService;
+
+
@PostMapping("/create")
@ApiOperation("创建站内信模版")
@PreAuthorize("@ss.hasPermission('system:notify-template:create')")
@@ -87,8 +91,10 @@ public class NotifyTemplateController {
ExcelUtils.write(response, "站内信模版.xls", "数据", NotifyTemplateExcelVO.class, datas);
}
- // TODO @芋艿:参考 SmsTemplateController 的 sendNotify 写一个发送站内信的接口
-
- // TODO @芋艿:参考 SmsSendServiceImpl,新建一个 NotifySendServiceImpl,用于提供出来给发送消息。注意,不要考虑异步发送,直接 insert 就可以了。也不用考虑发送后的回调
-
+ @PostMapping("/send-notify")
+ @ApiOperation("发送站内信")
+ public CommonResult sendNotify(@Valid @RequestBody NotifyTemplateSendReqVO sendReqVO) {
+ return success(notifySendService.sendSingleNotifyToAdmin(sendReqVO.getUserId(),
+ sendReqVO.getTemplateId(), sendReqVO.getTemplateParams()));
+ }
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/UserNotifyMessageController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/UserNotifyMessageController.java
deleted file mode 100644
index 04bd09160..000000000
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/UserNotifyMessageController.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package cn.iocoder.yudao.module.system.controller.admin.notify;
-
-import cn.hutool.core.collection.CollUtil;
-import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
-import cn.iocoder.yudao.framework.common.pojo.CommonResult;
-import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
-import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageRespVO;
-import cn.iocoder.yudao.module.system.convert.notify.NotifyMessageConvert;
-import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
-import cn.iocoder.yudao.module.system.enums.notify.NotifyReadStatusEnum;
-import cn.iocoder.yudao.module.system.service.notify.NotifyMessageService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import javax.validation.Valid;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-
-import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
-import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
-
-// TODO 芋艿:合并到 合并到 NotifyTemplateController 中
-@Api(tags = "管理后台 - 站内信-消息中心")
-@RestController
-@RequestMapping("/system/user/notify-message")
-@Validated
-public class UserNotifyMessageController {
-
- @Resource
- private NotifyMessageService notifyMessageService;
-
- // TODO 芋艿:和 NotifyMessageController 的 page 合并
- @GetMapping("/page")
- @ApiOperation("获得站内信分页")
- public CommonResult> getNotifyMessagePage(@Valid NotifyMessagePageReqVO pageVO) {
- pageVO.setUserId(getLoginUserId());
- pageVO.setUserType(UserTypeEnum.ADMIN.getValue());
- PageResult pageResult = notifyMessageService.getNotifyMessagePage(pageVO);
- return success(NotifyMessageConvert.INSTANCE.convertPage(pageResult));
- }
-
- // TODO @芋艿:url 改成 get-recent-list;方法名也改下。默认传入 size = 10;
- @GetMapping("/latest/list")
- @ApiOperation("获得最新10站内信列表")
- public CommonResult> getNotifyLatestMessageList() {
- NotifyMessagePageReqVO reqVO = new NotifyMessagePageReqVO();
- reqVO.setUserId(getLoginUserId());
- reqVO.setUserType(UserTypeEnum.ADMIN.getValue());
- reqVO.setPageNo(1);
- reqVO.setPageSize(10);
- // TODO 芋艿:不要用分页写;
- PageResult pageResult = notifyMessageService.getNotifyMessagePage(reqVO);
- if (CollUtil.isNotEmpty(pageResult.getList())) {
- return success(NotifyMessageConvert.INSTANCE.convertList(pageResult.getList()));
- }
- return success(Collections.emptyList());
- }
-
- // TODO @芋艿:get-unread-count
- @GetMapping("/unread/count")
- @ApiOperation("获得未读站内信数量")
- public CommonResult getUnreadNotifyMessageCount() {
- return success(notifyMessageService.getUnreadNotifyMessageCount(getLoginUserId(), UserTypeEnum.ADMIN.getValue()));
- }
-
- // TODO @芋艿:把 get 站内信,和更新站内信已经读分开。其中更新单条和多条,使用一个接口就好列
- @GetMapping("/read")
- @ApiOperation("获得站内信")
- @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
- public CommonResult readNotifyMessage(@RequestParam("id") Long id) {
- NotifyMessageDO notifyMessage = notifyMessageService.getNotifyMessage(id);
- // 记录消息已读。
- notifyMessageService.updateNotifyMessageReadStatus(id, NotifyReadStatusEnum.READ.getStatus());
- return success(NotifyMessageConvert.INSTANCE.convert(notifyMessage));
- }
-
- // TODO @芋艿:PutMapping;update-list-read
- @GetMapping("/read/list")
- @ApiOperation("批量标记已读")
- @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
- public CommonResult batchUpdateNotifyMessageReadStatus(@RequestParam("ids") Collection ids) {
- notifyMessageService.batchUpdateNotifyMessageReadStatus(ids, getLoginUserId());
- return success(Boolean.TRUE);
- }
-
- // TODO @芋艿:PutMapping:update-all-read
- @GetMapping("/read/all")
- @ApiOperation("所有未读消息标记已读")
- public CommonResult batchUpdateAllNotifyMessageReadStatus() {
- notifyMessageService.batchUpdateAllNotifyMessageReadStatus(getLoginUserId(), UserTypeEnum.ADMIN.getValue());
- return success(Boolean.TRUE);
- }
-}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageBaseVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageBaseVO.java
index e7f7439c2..62d8a3113 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageBaseVO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageBaseVO.java
@@ -34,8 +34,8 @@ public class NotifyMessageBaseVO {
@NotNull(message = "内容不能为空")
private String content;
- @ApiModelProperty(value = "是否已读 0-未读 1-已读")
- private Integer readStatus;
+ @ApiModelProperty(value = "是否已读 false-未读 true-已读")
+ private Boolean readStatus;
@ApiModelProperty(value = "阅读时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateBaseVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateBaseVO.java
index bff746e14..84aa4b686 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateBaseVO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateBaseVO.java
@@ -29,7 +29,7 @@ public class NotifyTemplateBaseVO {
@ApiModelProperty(value = "状态:1-启用 0-禁用", required = true)
@NotNull(message = "状态:1-启用 0-禁用不能为空")
@InEnum(value = CommonStatusEnum.class, message = "状态必须是 {value}")
- private String status;
+ private Integer status;
@ApiModelProperty(value = "备注")
private String remarks;
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateExcelVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateExcelVO.java
index e0402da8c..6790f1858 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateExcelVO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateExcelVO.java
@@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.system.controller.admin.notify.vo.template;
+import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
@@ -30,8 +31,8 @@ public class NotifyTemplateExcelVO {
private String content;
@ExcelProperty(value = "状态:1-启用 0-禁用", converter = DictConvert.class)
- @DictFormat("common_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中
- private String status;
+ @DictFormat(DictTypeConstants.COMMON_STATUS)
+ private Integer status;
@ExcelProperty("备注")
private String remarks;
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateExportReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateExportReqVO.java
index a9f8877e2..b3a997933 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateExportReqVO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateExportReqVO.java
@@ -19,7 +19,7 @@ public class NotifyTemplateExportReqVO {
private String title;
@ApiModelProperty(value = "状态:1-启用 0-禁用")
- private String status;
+ private Integer status;
@ApiModelProperty(value = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateSendReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateSendReqVO.java
new file mode 100644
index 000000000..abfcb2b36
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateSendReqVO.java
@@ -0,0 +1,24 @@
+package cn.iocoder.yudao.module.system.controller.admin.notify.vo.template;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.util.Map;
+
+@ApiModel("管理后台 - 站内信模板的发送 Request VO")
+@Data
+public class NotifyTemplateSendReqVO {
+
+ @ApiModelProperty(value = "用户id", required = true, example = "01")
+ @NotNull(message = "用户id不能为空")
+ private Long userId;
+
+ @ApiModelProperty(value = "模板Id", required = true, example = "01")
+ @NotNull(message = "模板Id不能为空")
+ private Long templateId;
+
+ @ApiModelProperty(value = "模板参数")
+ private Map templateParams;
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyMessageConvert.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyMessageConvert.java
index b5bce25d4..a111827fe 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyMessageConvert.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyMessageConvert.java
@@ -4,9 +4,7 @@ import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageCreateReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageRespVO;
-import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageUpdateReqVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
@@ -21,10 +19,6 @@ public interface NotifyMessageConvert {
NotifyMessageConvert INSTANCE = Mappers.getMapper(NotifyMessageConvert.class);
- NotifyMessageDO convert(NotifyMessageCreateReqVO bean);
-
- NotifyMessageDO convert(NotifyMessageUpdateReqVO bean);
-
NotifyMessageRespVO convert(NotifyMessageDO bean);
List convertList(List list);
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyTemplateDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyTemplateDO.java
index ab8b128ea..28fa83406 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyTemplateDO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyTemplateDO.java
@@ -53,7 +53,7 @@ public class NotifyTemplateDO extends BaseDO {
*
* 枚举 {@link CommonStatusEnum}
*/
- private String status;
+ private Integer status;
/**
* 备注
*/
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java
index 2c9137f11..9523264d1 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java
@@ -5,7 +5,6 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
-import cn.iocoder.yudao.module.system.enums.notify.NotifyReadStatusEnum;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@@ -28,16 +27,27 @@ public interface NotifyMessageMapper extends BaseMapperX {
.orderByDesc(NotifyMessageDO::getId));
}
+ default List selectList(NotifyMessagePageReqVO reqVO, Integer size) {
+ return selectList(new LambdaQueryWrapperX()
+ .likeIfPresent(NotifyMessageDO::getTitle, reqVO.getTitle())
+ .eqIfPresent(NotifyMessageDO::getReadStatus, reqVO.getReadStatus())
+ .betweenIfPresent(NotifyMessageDO::getCreateTime, reqVO.getCreateTime())
+ .eqIfPresent(NotifyMessageDO::getUserId, reqVO.getUserId())
+ .eqIfPresent(NotifyMessageDO::getUserType, reqVO.getUserType())
+ .orderByDesc(NotifyMessageDO::getId)
+ .last("limit " + size));
+ }
+
default Long selectUnreadCountByUserIdAndUserType(Long userId, Integer userType) {
return selectCount(new LambdaQueryWrapperX()
- .eq(NotifyMessageDO::getReadStatus, NotifyReadStatusEnum.UNREAD.getStatus())
+ .eq(NotifyMessageDO::getReadStatus, false)
.eq(NotifyMessageDO::getUserId, userId)
.eq(NotifyMessageDO::getUserType, userType));
}
default List selectUnreadListByUserIdAndUserType(Long userId, Integer userType) {
return selectList(new LambdaQueryWrapperX()
- .eq(NotifyMessageDO::getReadStatus, NotifyReadStatusEnum.UNREAD.getStatus())
+ .eq(NotifyMessageDO::getReadStatus, false)
.eq(NotifyMessageDO::getUserId, userId)
.eq(NotifyMessageDO::getUserType, userType));
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageService.java
index e6057bef0..10f397505 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageService.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageService.java
@@ -30,6 +30,14 @@ public interface NotifyMessageService {
*/
List getNotifyMessageList(Collection ids);
+ /**
+ * 获得站内信集合
+ *
+ * @param pageReqVO 分页查询
+ * @return 站内信分页
+ */
+ List getNotifyMessageList(NotifyMessagePageReqVO pageReqVO, Integer size);
+
/**
* 获得站内信分页
*
@@ -53,7 +61,7 @@ public interface NotifyMessageService {
* @param id 站内信编号
* @param status 状态
*/
- void updateNotifyMessageReadStatus(Long id, Integer status);
+ void updateNotifyMessageReadStatus(Long id, Boolean status);
/**
* 批量修改站内信阅读状态
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java
index 8150ee453..0597fd689 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java
@@ -5,14 +5,11 @@ import cn.hutool.core.util.NumberUtil;
import cn.iocoder.yudao.framework.common.core.KeyValue;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
-import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageCreateReqVO;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
-import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageUpdateReqVO;
-import cn.iocoder.yudao.module.system.convert.notify.NotifyMessageConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
import cn.iocoder.yudao.module.system.dal.mysql.notify.NotifyMessageMapper;
-import cn.iocoder.yudao.module.system.enums.notify.NotifyReadStatusEnum;
import com.google.common.annotations.VisibleForTesting;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@@ -87,6 +84,11 @@ public class NotifyMessageServiceImpl implements NotifyMessageService {
return notifyMessageMapper.selectBatchIds(ids);
}
+ @Override
+ public List getNotifyMessageList(NotifyMessagePageReqVO pageReqVO, Integer size) {
+ return notifyMessageMapper.selectList(pageReqVO, size);
+ }
+
@Override
public PageResult getNotifyMessagePage(NotifyMessagePageReqVO pageReqVO) {
return notifyMessageMapper.selectPage(pageReqVO);
@@ -111,7 +113,7 @@ public class NotifyMessageServiceImpl implements NotifyMessageService {
* @param status 状态
*/
@Override
- public void updateNotifyMessageReadStatus(Long id, Integer status) {
+ public void updateNotifyMessageReadStatus(Long id, Boolean status) {
// 校验消息是否存在
this.validateNotifyMessageExists(id);
// 更新状态
@@ -155,20 +157,12 @@ public class NotifyMessageServiceImpl implements NotifyMessageService {
List list = notifyMessageMapper.selectUnreadListByUserIdAndUserType(userId, userType);
if (CollUtil.isNotEmpty(list)) {
batchUpdateReadStatus(CollectionUtils.convertList(list, NotifyMessageDO::getId));
-
}
}
- // TODO 芋艿:批量更新,不要单条遍历哈。
private void batchUpdateReadStatus(Collection ids) {
- if (CollUtil.isNotEmpty(ids)) {
- for (Long id : ids) {
- NotifyMessageDO updateObj = new NotifyMessageDO();
- updateObj.setId(id);
- updateObj.setReadStatus(NotifyReadStatusEnum.READ.getStatus());
- notifyMessageMapper.updateById(updateObj);
- }
- }
-
+ NotifyMessageDO updateObj = new NotifyMessageDO();
+ updateObj.setReadStatus(false);
+ notifyMessageMapper.update(updateObj, new LambdaQueryWrapperX().in(NotifyMessageDO::getId, ids));
}
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifySendService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifySendService.java
new file mode 100644
index 000000000..bbf8c2dc5
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifySendService.java
@@ -0,0 +1,51 @@
+package cn.iocoder.yudao.module.system.service.notify;
+
+import java.util.List;
+import java.util.Map;
+
+public interface NotifySendService {
+
+
+ /**
+ * 发送单条站内信给管理后台的用户
+ *
+ * 在 mobile 为空时,使用 userId 加载对应管理员的手机号
+ *
+ * @param userId 用户编号
+ * @param templateId 短信模板编号
+ * @param templateParams 短信模板参数
+ * @return 发送日志编号
+ */
+ Long sendSingleNotifyToAdmin(Long userId,
+ Long templateId, Map templateParams);
+ /**
+ * 发送单条站内信给用户 APP 的用户
+ *
+ * 在 mobile 为空时,使用 userId 加载对应会员的手机号
+ *
+ * @param userId 用户编号
+ * @param templateId 站内信模板编号
+ * @param templateParams 站内信模板参数
+ * @return 发送日志编号
+ */
+ Long sendSingleNotifyToMember(Long userId,
+ Long templateId, Map templateParams);
+
+ /**
+ * 发送单条站内信给用户
+ *
+ * @param userId 用户编号
+ * @param userType 用户类型
+ * @param templateId 站内信模板编号
+ * @param templateParams 站内信模板参数
+ * @return 发送日志编号
+ */
+ Long sendSingleNotify( Long userId, Integer userType,
+ Long templateId, Map templateParams);
+
+ default void sendBatchNotify(List mobiles, List userIds, Integer userType,
+ String templateCode, Map templateParams) {
+ throw new UnsupportedOperationException("暂时不支持该操作,感兴趣可以实现该功能哟!");
+ }
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifySendServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifySendServiceImpl.java
new file mode 100644
index 000000000..63237e79b
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifySendServiceImpl.java
@@ -0,0 +1,77 @@
+package cn.iocoder.yudao.module.system.service.notify;
+
+import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
+import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
+import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
+import cn.iocoder.yudao.module.system.dal.mysql.notify.NotifyMessageMapper;
+import com.google.common.annotations.VisibleForTesting;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.Map;
+
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.NOTICE_NOT_FOUND;
+
+/**
+ * 站内信发送 Service 实现类
+ *
+ * @author xrcoder
+ */
+@Service
+@Validated
+@Slf4j
+public class NotifySendServiceImpl implements NotifySendService {
+
+ @Resource
+ private NotifyTemplateService notifyTemplateService;
+
+ @Resource
+ private NotifyMessageMapper notifyMessageMapper;
+
+ @Override
+ public Long sendSingleNotifyToAdmin(Long userId, Long templateId, Map templateParams) {
+
+ return sendSingleNotify(userId, UserTypeEnum.ADMIN.getValue(), templateId, templateParams);
+ }
+
+ @Override
+ public Long sendSingleNotifyToMember(Long userId, Long templateId, Map templateParams) {
+ return sendSingleNotify(userId, UserTypeEnum.MEMBER.getValue(), templateId, templateParams);
+ }
+
+ @Override
+ public Long sendSingleNotify(Long userId, Integer userType, Long templateId, Map templateParams) {
+ // 校验短信模板是否合法
+ NotifyTemplateDO template = this.checkNotifyTemplateValid(templateId);
+ String content = notifyTemplateService.formatNotifyTemplateContent(template.getContent(), templateParams);
+
+ // todo 模板状态未开启时的业务
+ NotifyMessageDO notifyMessageDO = new NotifyMessageDO();
+ notifyMessageDO.setContent(content);
+ notifyMessageDO.setTitle(template.getTitle());
+ notifyMessageDO.setReadStatus(false);
+ notifyMessageDO.setReadTime(new Date());
+ notifyMessageDO.setTemplateId(templateId);
+ notifyMessageDO.setUserId(userId);
+ notifyMessageDO.setUserType(userType);
+ notifyMessageMapper.insert(notifyMessageDO);
+ return notifyMessageDO.getId();
+ }
+
+ // 此注解的含义
+ @VisibleForTesting
+ public NotifyTemplateDO checkNotifyTemplateValid(Long templateId) {
+ // 获得短信模板。考虑到效率,从缓存中获取
+ NotifyTemplateDO template = notifyTemplateService.getNotifyTemplate(templateId);
+ // 短信模板不存在
+ if (template == null) {
+ throw exception(NOTICE_NOT_FOUND);
+ }
+ return template;
+ }
+
+}
From 826a564abd022c973190391d5729b1766100579f Mon Sep 17 00:00:00 2001
From: luowenfeng <1092164058@qq.com>
Date: Sat, 17 Dec 2022 16:41:14 +0800
Subject: [PATCH 09/18] =?UTF-8?q?=E7=AB=99=E5=86=85=E4=BF=A1=E5=BC=80?=
=?UTF-8?q?=E5=8F=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../admin/notify/NotifyLogController.java | 54 +++
.../admin/notify/NotifyMessageController.java | 16 +-
.../notify/NotifyTemplateController.java | 2 +-
.../admin/notify/vo/log/NotifyLogBaseVO.java | 44 +++
.../notify/vo/log/NotifyLogPageReqVO.java | 30 ++
.../vo/message/NotifyMessageBaseVO.java | 28 +-
.../vo/message/NotifyMessagePageReqVO.java | 7 -
.../vo/message/NotifyMessageRespVO.java | 3 -
.../vo/template/NotifyTemplateSendReqVO.java | 6 +-
.../convert/notify/NotifyLogConvert.java | 23 ++
.../convert/notify/NotifyMessageConvert.java | 8 +-
.../dataobject/notify/NotifyMessageDO.java | 18 +
.../dal/mysql/notify/NotifyMessageMapper.java | 22 +-
.../service/notify/NotifyLogService.java | 24 ++
.../service/notify/NotifyLogServiceImpl.java | 35 ++
.../service/notify/NotifyMessageService.java | 9 +-
.../notify/NotifyMessageServiceImpl.java | 15 +-
.../service/notify/NotifySendService.java | 12 +-
.../service/notify/NotifySendServiceImpl.java | 32 +-
.../notify/NotifyTemplateServiceImpl.java | 2 +-
.../src/api/system/notify/myNotify.js | 38 ++
.../src/api/system/notify/notifyLog.js | 11 +
.../src/api/system/notify/notifyTemplate.js | 64 ++++
yudao-ui-admin/src/utils/dict.js | 1 +
.../src/views/system/notify/myNotify.vue | 143 ++++++++
.../src/views/system/notify/notifyLog.vue | 120 +++++++
.../views/system/notify/notifyTemplate.vue | 339 ++++++++++++++++++
27 files changed, 1029 insertions(+), 77 deletions(-)
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyLogController.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/log/NotifyLogBaseVO.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/log/NotifyLogPageReqVO.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyLogConvert.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyLogService.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyLogServiceImpl.java
create mode 100644 yudao-ui-admin/src/api/system/notify/myNotify.js
create mode 100644 yudao-ui-admin/src/api/system/notify/notifyLog.js
create mode 100644 yudao-ui-admin/src/api/system/notify/notifyTemplate.js
create mode 100644 yudao-ui-admin/src/views/system/notify/myNotify.vue
create mode 100644 yudao-ui-admin/src/views/system/notify/notifyLog.vue
create mode 100644 yudao-ui-admin/src/views/system/notify/notifyTemplate.vue
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyLogController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyLogController.java
new file mode 100644
index 000000000..84152df7d
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyLogController.java
@@ -0,0 +1,54 @@
+package cn.iocoder.yudao.module.system.controller.admin.notify;
+
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.log.NotifyLogBaseVO;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.log.NotifyLogPageReqVO;
+import cn.iocoder.yudao.module.system.convert.notify.NotifyLogConvert;
+import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
+import cn.iocoder.yudao.module.system.service.notify.NotifyLogService;
+import cn.iocoder.yudao.module.system.service.user.AdminUserService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import javax.validation.Valid;
+
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
+/**
+ *
+ *
+ *
+ *
+ * @author LuoWenFeng
+ */
+@Api(tags = "管理后台 - 站内信发送日志")
+@RestController
+@RequestMapping("/system/notify-log")
+@Validated
+public class NotifyLogController {
+
+ @Resource
+ private NotifyLogService notifyLogService;
+
+ @Resource
+ private AdminUserService userService;
+
+ @GetMapping("/page")
+ @ApiOperation("获得发送站内信日志分页")
+ public CommonResult> getNotifyLogPage(@Valid NotifyLogPageReqVO pageVO) {
+ PageResult pageResult = notifyLogService.getNotifyMessageSendPage(pageVO);
+ PageResult result = NotifyLogConvert.INSTANCE.convertPage(pageResult);
+ result.getList().forEach(v -> {
+ v.setReceiveUserName(userService.getUser(v.getUserId()).getNickname());
+ });
+ return success(result);
+ }
+
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyMessageController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyMessageController.java
index 7e14b86c7..67b0d5d58 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyMessageController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyMessageController.java
@@ -18,15 +18,13 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
-
-import java.util.Collection;
import java.util.Collections;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
-@Api(tags = "管理后台 - 站内信")
+@Api(tags = "管理后台 - 我的站内信")
@RestController
@RequestMapping("/system/notify-message")
@Validated
@@ -48,8 +46,6 @@ public class NotifyMessageController {
@ApiOperation("获得站内信分页")
@PreAuthorize("@ss.hasPermission('system:notify-message:query')")
public CommonResult> getNotifyMessagePage(@Valid NotifyMessagePageReqVO pageVO) {
- pageVO.setUserId(getLoginUserId());
- pageVO.setUserType(UserTypeEnum.ADMIN.getValue());
PageResult pageResult = notifyMessageService.getNotifyMessagePage(pageVO);
return success(NotifyMessageConvert.INSTANCE.convertPage(pageResult));
}
@@ -59,9 +55,6 @@ public class NotifyMessageController {
@ApiImplicitParam(name = "size", value = "10", defaultValue = "10", dataTypeClass = Integer.class)
public CommonResult> getRecentList(@RequestParam(name = "size", defaultValue = "10") Integer size) {
NotifyMessagePageReqVO reqVO = new NotifyMessagePageReqVO();
- reqVO.setUserId(getLoginUserId());
- reqVO.setUserType(UserTypeEnum.ADMIN.getValue());
-
List pageResult = notifyMessageService.getNotifyMessageList(reqVO, size);
if (CollUtil.isNotEmpty(pageResult)) {
return success(NotifyMessageConvert.INSTANCE.convertList(pageResult));
@@ -75,19 +68,20 @@ public class NotifyMessageController {
return success(notifyMessageService.getUnreadNotifyMessageCount(getLoginUserId(), UserTypeEnum.ADMIN.getValue()));
}
- @GetMapping("/update-list-read")
+ @PutMapping("/update-list-read")
@ApiOperation("批量标记已读")
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
- public CommonResult batchUpdateNotifyMessageReadStatus(@RequestParam("ids") Collection ids) {
+ public CommonResult batchUpdateNotifyMessageReadStatus(@RequestBody List ids) {
notifyMessageService.batchUpdateNotifyMessageReadStatus(ids, getLoginUserId());
return success(Boolean.TRUE);
}
- @GetMapping("/update-all-read")
+ @PutMapping("/update-all-read")
@ApiOperation("所有未读消息标记已读")
public CommonResult batchUpdateAllNotifyMessageReadStatus() {
notifyMessageService.batchUpdateAllNotifyMessageReadStatus(getLoginUserId(), UserTypeEnum.ADMIN.getValue());
return success(Boolean.TRUE);
}
+
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyTemplateController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyTemplateController.java
index aa57a795e..b0aad865e 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyTemplateController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyTemplateController.java
@@ -95,6 +95,6 @@ public class NotifyTemplateController {
@ApiOperation("发送站内信")
public CommonResult sendNotify(@Valid @RequestBody NotifyTemplateSendReqVO sendReqVO) {
return success(notifySendService.sendSingleNotifyToAdmin(sendReqVO.getUserId(),
- sendReqVO.getTemplateId(), sendReqVO.getTemplateParams()));
+ sendReqVO.getTemplateCode(), sendReqVO.getTemplateParams()));
}
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/log/NotifyLogBaseVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/log/NotifyLogBaseVO.java
new file mode 100644
index 000000000..e24a7d49b
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/log/NotifyLogBaseVO.java
@@ -0,0 +1,44 @@
+package cn.iocoder.yudao.module.system.controller.admin.notify.vo.log;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+/**
+ * 站内信 Base VO,提供给添加、修改、详细的子 VO 使用
+ * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
+ */
+@Data
+public class NotifyLogBaseVO {
+
+ @ApiModelProperty(value = "模版编码")
+ private String templateCode;
+
+ @ApiModelProperty(value = "标题")
+ private String title;
+
+ @ApiModelProperty(value = "内容", required = true)
+ private String content;
+
+ @ApiModelProperty(value = "发送时间", required = true)
+ @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+ private Date sendTime;
+
+ @ApiModelProperty(value = "芋艿", required = true)
+ private String receiveUserName;
+
+ @ApiModelProperty(value = "1", required = true)
+ private Long userId;
+
+ @ApiModelProperty(value = "是否已读 false-未读 true-已读")
+ private Boolean readStatus;
+
+ @ApiModelProperty(value = "阅读时间")
+ @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+ private Date readTime;
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/log/NotifyLogPageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/log/NotifyLogPageReqVO.java
new file mode 100644
index 000000000..aefd60498
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/log/NotifyLogPageReqVO.java
@@ -0,0 +1,30 @@
+package cn.iocoder.yudao.module.system.controller.admin.notify.vo.log;
+
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.ToString;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@ApiModel("管理后台 - 站内信日志分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class NotifyLogPageReqVO extends PageParam {
+
+ @ApiModelProperty(value = "模版编码")
+ private String templateCode;
+
+ @ApiModelProperty(value = "标题")
+ private String title;
+
+ @ApiModelProperty(value = "创建时间")
+ @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+ private Date[] sendTime;
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageBaseVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageBaseVO.java
index 62d8a3113..f8d5d814a 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageBaseVO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageBaseVO.java
@@ -1,39 +1,33 @@
package cn.iocoder.yudao.module.system.controller.admin.notify.vo.message;
-import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
-import cn.iocoder.yudao.framework.common.validation.InEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
-import javax.validation.constraints.NotNull;
import java.util.Date;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
-* 站内信 Base VO,提供给添加、修改、详细的子 VO 使用
-* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
-*/
+ * 站内信 Base VO,提供给添加、修改、详细的子 VO 使用
+ * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
+ */
@Data
public class NotifyMessageBaseVO {
- @ApiModelProperty(value = "用户编号", required = true)
- @NotNull(message = "用户编号不能为空")
- private Long userId;
-
- @ApiModelProperty(value = "用户类型", required = true)
- @NotNull(message = "用户类型不能为空")
- @InEnum(value = UserTypeEnum.class, message = "用户类型必须是 {value}")
- private Integer userType;
-
@ApiModelProperty(value = "标题")
private String title;
- @ApiModelProperty(value = "内容", required = true)
- @NotNull(message = "内容不能为空")
+ @ApiModelProperty(value = "内容")
private String content;
+ @ApiModelProperty(value = "发送时间")
+ @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+ private Date sendTime;
+
+ @ApiModelProperty(value = "芋艿")
+ private String sendUserName;
+
@ApiModelProperty(value = "是否已读 false-未读 true-已读")
private Boolean readStatus;
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessagePageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessagePageReqVO.java
index 443f3729a..3d786796b 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessagePageReqVO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessagePageReqVO.java
@@ -28,11 +28,4 @@ public class NotifyMessagePageReqVO extends PageParam {
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date[] createTime;
- // TODO 芋艿:去掉 userId 和 userType,不要在 VO 里
-
- @ApiModelProperty(value = "用户编号", hidden = true)
- private Long userId;
-
- @ApiModelProperty(value = "用户类型", hidden = true)
- private Integer userType;
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageRespVO.java
index 530b368c1..306b7bd28 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageRespVO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageRespVO.java
@@ -13,7 +13,4 @@ public class NotifyMessageRespVO extends NotifyMessageBaseVO {
@ApiModelProperty(value = "ID", required = true)
private Long id;
- @ApiModelProperty(value = "创建时间", required = true)
- private Date createTime;
-
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateSendReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateSendReqVO.java
index abfcb2b36..7a04db5dc 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateSendReqVO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateSendReqVO.java
@@ -15,9 +15,9 @@ public class NotifyTemplateSendReqVO {
@NotNull(message = "用户id不能为空")
private Long userId;
- @ApiModelProperty(value = "模板Id", required = true, example = "01")
- @NotNull(message = "模板Id不能为空")
- private Long templateId;
+ @ApiModelProperty(value = "模板编码", required = true, example = "01")
+ @NotNull(message = "模板编码不能为空")
+ private String templateCode;
@ApiModelProperty(value = "模板参数")
private Map templateParams;
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyLogConvert.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyLogConvert.java
new file mode 100644
index 000000000..07e3dfb85
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyLogConvert.java
@@ -0,0 +1,23 @@
+package cn.iocoder.yudao.module.system.convert.notify;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.log.NotifyLogBaseVO;
+import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
+import org.mapstruct.Mapper;
+import org.mapstruct.factory.Mappers;
+
+/**
+ *
+ *
+ *
+ *
+ * @author LuoWenFeng
+ */
+@Mapper
+public interface NotifyLogConvert {
+
+ NotifyLogConvert INSTANCE = Mappers.getMapper(NotifyLogConvert.class);
+
+ PageResult convertPage(PageResult page);
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyMessageConvert.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyMessageConvert.java
index a111827fe..4a393d30c 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyMessageConvert.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyMessageConvert.java
@@ -1,13 +1,12 @@
package cn.iocoder.yudao.module.system.convert.notify;
-import java.util.*;
-
import cn.iocoder.yudao.framework.common.pojo.PageResult;
-
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageRespVO;
+import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
-import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
+
+import java.util.List;
/**
* 站内信 Convert
@@ -25,4 +24,5 @@ public interface NotifyMessageConvert {
PageResult convertPage(PageResult page);
+
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyMessageDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyMessageDO.java
index 5a923998a..b431795cf 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyMessageDO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyMessageDO.java
@@ -35,6 +35,12 @@ public class NotifyMessageDO extends BaseDO {
* 关联 {@link NotifyTemplateDO#getId()}
*/
private Long templateId;
+ /**
+ * 站内信模版编码
+ *
+ * 关联 {@link NotifyTemplateDO#getCode()}
+ */
+ private String templateCode;
/**
* 用户编号
*
@@ -55,6 +61,18 @@ public class NotifyMessageDO extends BaseDO {
* 内容
*/
private String content;
+ /**
+ * 发送时间
+ */
+ private Date sendTime;
+ /**
+ * 发送用户id
+ */
+ private Long sendUserId;
+ /**
+ * 发送用户名
+ */
+ private String sendUserName;
/**
* 是否已读
*/
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java
index 9523264d1..7b599e25e 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java
@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.dal.mysql.notify;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.log.NotifyLogPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
import org.apache.ibatis.annotations.Mapper;
@@ -17,23 +18,31 @@ import java.util.List;
@Mapper
public interface NotifyMessageMapper extends BaseMapperX {
- default PageResult selectPage(NotifyMessagePageReqVO reqVO) {
+ default PageResult selectPage(NotifyMessagePageReqVO reqVO, Long userId, Integer userType) {
return selectPage(reqVO, new LambdaQueryWrapperX()
.likeIfPresent(NotifyMessageDO::getTitle, reqVO.getTitle())
.eqIfPresent(NotifyMessageDO::getReadStatus, reqVO.getReadStatus())
.betweenIfPresent(NotifyMessageDO::getCreateTime, reqVO.getCreateTime())
- .eqIfPresent(NotifyMessageDO::getUserId, reqVO.getUserId())
- .eqIfPresent(NotifyMessageDO::getUserType, reqVO.getUserType())
+ .eq(NotifyMessageDO::getUserId, userId)
+ .eq(NotifyMessageDO::getUserType, userType)
.orderByDesc(NotifyMessageDO::getId));
}
- default List selectList(NotifyMessagePageReqVO reqVO, Integer size) {
+ default PageResult selectSendPage(NotifyLogPageReqVO reqVO, Long userId) {
+ return selectPage(reqVO, new LambdaQueryWrapperX()
+ .likeIfPresent(NotifyMessageDO::getTitle, reqVO.getTitle())
+ .betweenIfPresent(NotifyMessageDO::getSendTime, reqVO.getSendTime())
+ .eq(NotifyMessageDO::getSendUserId, userId)
+ .orderByDesc(NotifyMessageDO::getId));
+ }
+
+ default List selectList(NotifyMessagePageReqVO reqVO, Integer size, Long userId, Integer userType) {
return selectList(new LambdaQueryWrapperX()
.likeIfPresent(NotifyMessageDO::getTitle, reqVO.getTitle())
.eqIfPresent(NotifyMessageDO::getReadStatus, reqVO.getReadStatus())
.betweenIfPresent(NotifyMessageDO::getCreateTime, reqVO.getCreateTime())
- .eqIfPresent(NotifyMessageDO::getUserId, reqVO.getUserId())
- .eqIfPresent(NotifyMessageDO::getUserType, reqVO.getUserType())
+ .eqIfPresent(NotifyMessageDO::getUserId, userId)
+ .eqIfPresent(NotifyMessageDO::getUserType, userType)
.orderByDesc(NotifyMessageDO::getId)
.last("limit " + size));
}
@@ -51,4 +60,5 @@ public interface NotifyMessageMapper extends BaseMapperX {
.eq(NotifyMessageDO::getUserId, userId)
.eq(NotifyMessageDO::getUserType, userType));
}
+
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyLogService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyLogService.java
new file mode 100644
index 000000000..272648c9c
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyLogService.java
@@ -0,0 +1,24 @@
+package cn.iocoder.yudao.module.system.service.notify;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.log.NotifyLogPageReqVO;
+import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
+
+/**
+ *
+ * 站内信日志 Service 接口
+ *
+ *
+ * @author LuoWenFeng
+ */
+public interface NotifyLogService {
+
+
+ /**
+ * 获得站内信发送分页
+ *
+ * @param pageReqVO 分页查询
+ * @return 站内信分页
+ */
+ PageResult getNotifyMessageSendPage(NotifyLogPageReqVO pageReqVO);
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyLogServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyLogServiceImpl.java
new file mode 100644
index 000000000..be95d8a6d
--- /dev/null
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyLogServiceImpl.java
@@ -0,0 +1,35 @@
+package cn.iocoder.yudao.module.system.service.notify;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.log.NotifyLogPageReqVO;
+import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
+import cn.iocoder.yudao.module.system.dal.mysql.notify.NotifyMessageMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+
+import javax.annotation.Resource;
+
+import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
+
+/**
+ *
+ * 站内信日志 Service 实现类
+ *
+ *
+ *
+ * @author LuoWenFeng
+ */
+@Service
+@Validated
+public class NotifyLogServiceImpl implements NotifyLogService {
+
+ @Resource
+ private NotifyMessageMapper notifyMessageMapper;
+
+ @Override
+ public PageResult getNotifyMessageSendPage(NotifyLogPageReqVO pageReqVO) {
+ return notifyMessageMapper.selectSendPage(pageReqVO, getLoginUserId());
+ }
+
+
+}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageService.java
index 10f397505..bb8d7e923 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageService.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageService.java
@@ -49,7 +49,7 @@ public interface NotifyMessageService {
/**
* 统计用户未读站内信条数
*
- * @param userId 用户ID
+ * @param userId 用户ID
* @param userType 用户类型
* @return 返回未读站内信条数
*/
@@ -58,7 +58,7 @@ public interface NotifyMessageService {
/**
* 修改站内信阅读状态
*
- * @param id 站内信编号
+ * @param id 站内信编号
* @param status 状态
*/
void updateNotifyMessageReadStatus(Long id, Boolean status);
@@ -66,7 +66,7 @@ public interface NotifyMessageService {
/**
* 批量修改站内信阅读状态
*
- * @param ids 站内信编号集合
+ * @param ids 站内信编号集合
* @param userId 用户ID
*/
void batchUpdateNotifyMessageReadStatus(Collection ids, Long userId);
@@ -74,8 +74,9 @@ public interface NotifyMessageService {
/**
* 批量修改用户所有未读消息标记已读
*
- * @param userId 用户ID
+ * @param userId 用户ID
* @param userType 用户类型
*/
void batchUpdateAllNotifyMessageReadStatus(Long userId, Integer userType);
+
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java
index 0597fd689..fdfff486e 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java
@@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.system.service.notify;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.NumberUtil;
import cn.iocoder.yudao.framework.common.core.KeyValue;
+import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
@@ -16,11 +17,13 @@ import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.util.Collection;
+import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
/**
@@ -86,12 +89,12 @@ public class NotifyMessageServiceImpl implements NotifyMessageService {
@Override
public List getNotifyMessageList(NotifyMessagePageReqVO pageReqVO, Integer size) {
- return notifyMessageMapper.selectList(pageReqVO, size);
+ return notifyMessageMapper.selectList(pageReqVO, size, getLoginUserId(), UserTypeEnum.ADMIN.getValue());
}
@Override
public PageResult getNotifyMessagePage(NotifyMessagePageReqVO pageReqVO) {
- return notifyMessageMapper.selectPage(pageReqVO);
+ return notifyMessageMapper.selectPage(pageReqVO, getLoginUserId(), UserTypeEnum.ADMIN.getValue());
}
/**
@@ -160,9 +163,15 @@ public class NotifyMessageServiceImpl implements NotifyMessageService {
}
}
+
+ /**
+ * 批量修改阅读状态为已读
+ * @param ids
+ */
private void batchUpdateReadStatus(Collection ids) {
NotifyMessageDO updateObj = new NotifyMessageDO();
- updateObj.setReadStatus(false);
+ updateObj.setReadStatus(true);
+ updateObj.setReadTime(new Date());
notifyMessageMapper.update(updateObj, new LambdaQueryWrapperX().in(NotifyMessageDO::getId, ids));
}
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifySendService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifySendService.java
index bbf8c2dc5..68e9a78c4 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifySendService.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifySendService.java
@@ -12,36 +12,36 @@ public interface NotifySendService {
* 在 mobile 为空时,使用 userId 加载对应管理员的手机号
*
* @param userId 用户编号
- * @param templateId 短信模板编号
+ * @param templateCode 短信模板编号
* @param templateParams 短信模板参数
* @return 发送日志编号
*/
Long sendSingleNotifyToAdmin(Long userId,
- Long templateId, Map templateParams);
+ String templateCode, Map templateParams);
/**
* 发送单条站内信给用户 APP 的用户
*
* 在 mobile 为空时,使用 userId 加载对应会员的手机号
*
* @param userId 用户编号
- * @param templateId 站内信模板编号
+ * @param templateCode 站内信模板编号
* @param templateParams 站内信模板参数
* @return 发送日志编号
*/
Long sendSingleNotifyToMember(Long userId,
- Long templateId, Map templateParams);
+ String templateCode, Map templateParams);
/**
* 发送单条站内信给用户
*
* @param userId 用户编号
* @param userType 用户类型
- * @param templateId 站内信模板编号
+ * @param templateCode 站内信模板编号
* @param templateParams 站内信模板参数
* @return 发送日志编号
*/
Long sendSingleNotify( Long userId, Integer userType,
- Long templateId, Map templateParams);
+ String templateCode, Map templateParams);
default void sendBatchNotify(List mobiles, List userIds, Integer userType,
String templateCode, Map templateParams) {
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifySendServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifySendServiceImpl.java
index 63237e79b..984fc196b 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifySendServiceImpl.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifySendServiceImpl.java
@@ -3,7 +3,9 @@ package cn.iocoder.yudao.module.system.service.notify;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
+import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.dal.mysql.notify.NotifyMessageMapper;
+import cn.iocoder.yudao.module.system.service.user.AdminUserService;
import com.google.common.annotations.VisibleForTesting;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@@ -14,6 +16,7 @@ import java.util.Date;
import java.util.Map;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.NOTICE_NOT_FOUND;
/**
@@ -32,41 +35,48 @@ public class NotifySendServiceImpl implements NotifySendService {
@Resource
private NotifyMessageMapper notifyMessageMapper;
- @Override
- public Long sendSingleNotifyToAdmin(Long userId, Long templateId, Map templateParams) {
+ @Resource
+ private AdminUserService userService;
- return sendSingleNotify(userId, UserTypeEnum.ADMIN.getValue(), templateId, templateParams);
+ @Override
+ public Long sendSingleNotifyToAdmin(Long userId, String templateCode, Map templateParams) {
+
+ return sendSingleNotify(userId, UserTypeEnum.ADMIN.getValue(), templateCode, templateParams);
}
@Override
- public Long sendSingleNotifyToMember(Long userId, Long templateId, Map templateParams) {
- return sendSingleNotify(userId, UserTypeEnum.MEMBER.getValue(), templateId, templateParams);
+ public Long sendSingleNotifyToMember(Long userId, String templateCode, Map templateParams) {
+ return sendSingleNotify(userId, UserTypeEnum.MEMBER.getValue(), templateCode, templateParams);
}
@Override
- public Long sendSingleNotify(Long userId, Integer userType, Long templateId, Map templateParams) {
+ public Long sendSingleNotify(Long userId, Integer userType, String templateCode, Map templateParams) {
// 校验短信模板是否合法
- NotifyTemplateDO template = this.checkNotifyTemplateValid(templateId);
+ NotifyTemplateDO template = this.checkNotifyTemplateValid(templateCode);
String content = notifyTemplateService.formatNotifyTemplateContent(template.getContent(), templateParams);
+ AdminUserDO sendUser = userService.getUser(getLoginUserId());
// todo 模板状态未开启时的业务
NotifyMessageDO notifyMessageDO = new NotifyMessageDO();
notifyMessageDO.setContent(content);
notifyMessageDO.setTitle(template.getTitle());
notifyMessageDO.setReadStatus(false);
- notifyMessageDO.setReadTime(new Date());
- notifyMessageDO.setTemplateId(templateId);
+ notifyMessageDO.setTemplateId(template.getId());
+ notifyMessageDO.setTemplateCode(templateCode);
notifyMessageDO.setUserId(userId);
notifyMessageDO.setUserType(userType);
+ notifyMessageDO.setSendTime(new Date());
+ notifyMessageDO.setSendUserId(sendUser.getId());
+ notifyMessageDO.setSendUserName(sendUser.getUsername());
notifyMessageMapper.insert(notifyMessageDO);
return notifyMessageDO.getId();
}
// 此注解的含义
@VisibleForTesting
- public NotifyTemplateDO checkNotifyTemplateValid(Long templateId) {
+ public NotifyTemplateDO checkNotifyTemplateValid(String templateCode) {
// 获得短信模板。考虑到效率,从缓存中获取
- NotifyTemplateDO template = notifyTemplateService.getNotifyTemplate(templateId);
+ NotifyTemplateDO template = notifyTemplateService.getNotifyTemplateByCodeFromCache(templateCode);
// 短信模板不存在
if (template == null) {
throw exception(NOTICE_NOT_FOUND);
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImpl.java
index 1342fe03b..fe5058074 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImpl.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImpl.java
@@ -109,7 +109,7 @@ public class NotifyTemplateServiceImpl implements NotifyTemplateService {
return notifyTemplateMapper.selectList();
}
- @Scheduled(fixedDelay = SCHEDULER_PERIOD, initialDelay = SCHEDULER_PERIOD)
+ @Scheduled(fixedDelay = SCHEDULER_PERIOD)
public void schedulePeriodicRefresh() {
initLocalCache();
}
diff --git a/yudao-ui-admin/src/api/system/notify/myNotify.js b/yudao-ui-admin/src/api/system/notify/myNotify.js
new file mode 100644
index 000000000..cd37fd898
--- /dev/null
+++ b/yudao-ui-admin/src/api/system/notify/myNotify.js
@@ -0,0 +1,38 @@
+import request from '@/utils/request'
+
+
+// 获得我的站内信分页
+export function getNotifyMessagePage(query) {
+ return request({
+ url: '/system/notify-message/page',
+ method: 'get',
+ params: query
+ })
+}
+
+// 获得单条我的站内信
+export function getNotifyMessage(query) {
+ return request({
+ url: '/system/notify-message/get',
+ method: 'get',
+ params: query
+ })
+}
+
+// 批量标记已读
+export function updateNotifyMessageListRead(data) {
+ return request({
+ url: '/system/notify-message/update-list-read',
+ method: 'put',
+ data: data
+ })
+}
+
+// 所有未读消息标记已读
+export function updateNotifyMessageAllRead(data) {
+ return request({
+ url: '/system/notify-message/update-all-read',
+ method: 'put',
+ data: data
+ })
+}
diff --git a/yudao-ui-admin/src/api/system/notify/notifyLog.js b/yudao-ui-admin/src/api/system/notify/notifyLog.js
new file mode 100644
index 000000000..de9e9f1ad
--- /dev/null
+++ b/yudao-ui-admin/src/api/system/notify/notifyLog.js
@@ -0,0 +1,11 @@
+import request from '@/utils/request'
+
+
+// 获得我的站内信分页
+export function getNotifyLogPage(query) {
+ return request({
+ url: '/system/notify-log/page',
+ method: 'get',
+ params: query
+ })
+}
diff --git a/yudao-ui-admin/src/api/system/notify/notifyTemplate.js b/yudao-ui-admin/src/api/system/notify/notifyTemplate.js
new file mode 100644
index 000000000..59c036540
--- /dev/null
+++ b/yudao-ui-admin/src/api/system/notify/notifyTemplate.js
@@ -0,0 +1,64 @@
+import request from '@/utils/request'
+
+// 创建站内信模板
+export function createNotifyTemplate(data) {
+ return request({
+ url: '/system/notify-template/create',
+ method: 'post',
+ data: data
+ })
+}
+
+// 更新站内信模板
+export function updateNotifyTemplate(data) {
+ return request({
+ url: '/system/notify-template/update',
+ method: 'put',
+ data: data
+ })
+}
+
+// 删除站内信模板
+export function deleteNotifyTemplate(id) {
+ return request({
+ url: '/system/notify-template/delete?id=' + id,
+ method: 'delete'
+ })
+}
+
+// 获得站内信模板
+export function getNotifyTemplate(id) {
+ return request({
+ url: '/system/notify-template/get?id=' + id,
+ method: 'get'
+ })
+}
+
+// 获得站内信模板分页
+export function getNotifyTemplatePage(query) {
+ return request({
+ url: '/system/notify-template/page',
+ method: 'get',
+ params: query
+ })
+}
+
+// 创建站内信模板
+export function sendNotify(data) {
+ return request({
+ url: '/system/notify-template/send-notify',
+ method: 'post',
+ data: data
+ })
+}
+
+// 导出站内信模板 Excel
+export function exportNotifyTemplateExcel(query) {
+ return request({
+ url: '/system/notify-template/export-excel',
+ method: 'get',
+ params: query,
+ responseType: 'blob'
+ })
+}
+
diff --git a/yudao-ui-admin/src/utils/dict.js b/yudao-ui-admin/src/utils/dict.js
index 1ddde889a..4ed01e9a9 100644
--- a/yudao-ui-admin/src/utils/dict.js
+++ b/yudao-ui-admin/src/utils/dict.js
@@ -24,6 +24,7 @@ export const DICT_TYPE = {
SYSTEM_SMS_RECEIVE_STATUS: 'system_sms_receive_status',
SYSTEM_ERROR_CODE_TYPE: 'system_error_code_type',
SYSTEM_OAUTH2_GRANT_TYPE: 'system_oauth2_grant_type',
+ SYSTEM_NOTIFY_READ_STATUS: "system_notify_read_status",
// ========== INFRA 模块 ==========
INFRA_BOOLEAN_STRING: 'infra_boolean_string',
diff --git a/yudao-ui-admin/src/views/system/notify/myNotify.vue b/yudao-ui-admin/src/views/system/notify/myNotify.vue
new file mode 100644
index 000000000..1c8a1b58a
--- /dev/null
+++ b/yudao-ui-admin/src/views/system/notify/myNotify.vue
@@ -0,0 +1,143 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 搜索
+ 重置
+
+
+
+
+
+
+ 标记已读
+
+
+ 全部已读
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ parseTime(scope.row.sendTime) }}
+
+
+
+
+
+
+
+
+
+ 已读
+
+
+
+
+
+
+
+
+
+
diff --git a/yudao-ui-admin/src/views/system/notify/notifyLog.vue b/yudao-ui-admin/src/views/system/notify/notifyLog.vue
new file mode 100644
index 000000000..7e9eb5610
--- /dev/null
+++ b/yudao-ui-admin/src/views/system/notify/notifyLog.vue
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 搜索
+ 重置
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ parseTime(scope.row.sendTime) }}
+
+
+
+
+ {{ parseTime(scope.row.readTime) }}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/yudao-ui-admin/src/views/system/notify/notifyTemplate.vue b/yudao-ui-admin/src/views/system/notify/notifyTemplate.vue
new file mode 100644
index 000000000..9fa396839
--- /dev/null
+++ b/yudao-ui-admin/src/views/system/notify/notifyTemplate.vue
@@ -0,0 +1,339 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 搜索
+ 重置
+
+
+
+
+
+
+ 新增
+
+
+ 导出
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ parseTime(scope.row.createTime) }}
+
+
+
+
+ 发送
+ 修改
+ 删除
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{dict.label}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From ed2d19541164df791de1fbf15c45ed677726855e Mon Sep 17 00:00:00 2001
From: luowenfeng <1092164058@qq.com>
Date: Sat, 17 Dec 2022 16:42:40 +0800
Subject: [PATCH 10/18] =?UTF-8?q?=E7=AB=99=E5=86=85=E4=BF=A1=E5=BC=80?=
=?UTF-8?q?=E5=8F=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../module/system/dal/mysql/notify/NotifyMessageMapper.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java
index 7b599e25e..470419244 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java
@@ -32,6 +32,7 @@ public interface NotifyMessageMapper extends BaseMapperX {
return selectPage(reqVO, new LambdaQueryWrapperX()
.likeIfPresent(NotifyMessageDO::getTitle, reqVO.getTitle())
.betweenIfPresent(NotifyMessageDO::getSendTime, reqVO.getSendTime())
+ .eqIfPresent(NotifyMessageDO::getTemplateCode, reqVO.getTemplateCode())
.eq(NotifyMessageDO::getSendUserId, userId)
.orderByDesc(NotifyMessageDO::getId));
}
From 5cac636f325250e5d7d5ff033761b6fc54a4afed Mon Sep 17 00:00:00 2001
From: luowenfeng <1092164058@qq.com>
Date: Sat, 17 Dec 2022 17:30:05 +0800
Subject: [PATCH 11/18] =?UTF-8?q?feature(=E7=AB=99=E5=86=85=E4=BF=A1?=
=?UTF-8?q?=E5=BC=80=E5=8F=91):=20=E6=B7=BB=E5=8A=A0=E8=84=9A=E6=9C=AC?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
sql/mysql/ruoyi-vue-pro.sql | 83 ++++++++++++++++++++++++++++++++++++-
1 file changed, 82 insertions(+), 1 deletion(-)
diff --git a/sql/mysql/ruoyi-vue-pro.sql b/sql/mysql/ruoyi-vue-pro.sql
index 683206e6f..dc3661448 100644
--- a/sql/mysql/ruoyi-vue-pro.sql
+++ b/sql/mysql/ruoyi-vue-pro.sql
@@ -1330,6 +1330,9 @@ INSERT INTO `system_dict_data` (`id`, `sort`, `label`, `value`, `dict_type`, `st
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 (1158, 3, 'implicit', 'implicit', 'system_oauth2_grant_type', 0, 'success', '', '简化模式', '1', '2022-05-12 00:23:40', '1', '2022-05-11 16:26:05', b'0');
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 (1159, 4, 'client_credentials', 'client_credentials', 'system_oauth2_grant_type', 0, 'default', '', '客户端模式', '1', '2022-05-12 00:23:51', '1', '2022-05-11 16:26:08', b'0');
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 (1160, 5, 'refresh_token', 'refresh_token', 'system_oauth2_grant_type', 0, 'info', '', '刷新模式', '1', '2022-05-12 00:24:02', '1', '2022-05-11 16:26:11', b'0');
+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 (1162, 0, '已读', 'true', 'system_notify_read_status', 0, 'success', '', NULL, '1', '2022-12-16 17:48:28', '1', '2022-12-17 03:32:09', b'0');
+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 (1163, 1, '未读', 'false', 'system_notify_read_status', 0, 'info', '', NULL, '1', '2022-12-16 17:48:43', '1', '2022-12-17 03:32:11', b'0');
+
COMMIT;
-- ----------------------------
@@ -1395,6 +1398,8 @@ INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creat
INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (145, '角色类型', 'system_role_type', 0, '角色类型', '1', '2022-02-16 13:01:46', '1', '2022-02-16 13:01:46', b'0');
INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (146, '文件存储器', 'infra_file_storage', 0, '文件存储器', '1', '2022-03-15 00:24:38', '1', '2022-03-15 00:24:38', b'0');
INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (147, 'OAuth 2.0 授权类型', 'system_oauth2_grant_type', 0, 'OAuth 2.0 授权类型(模式)', '1', '2022-05-12 00:20:52', '1', '2022-05-11 16:25:49', b'0');
+INSERT INTO `system_dict_type` (`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (149, '站内信读取状态', 'system_notify_read_status', 0, '站内信读取状态', '1', '2022-12-16 17:47:35', '1', '2022-12-17 03:25:08', b'0');
+
COMMIT;
-- ----------------------------
@@ -1712,6 +1717,21 @@ INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_i
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 (1267, '客户端删除', 'system:oauth2-client:delete', 3, 4, 1263, '', '', '', 0, b'1', b'1', '', '2022-05-10 16:26:33', '1', '2022-05-11 00:31:33', b'0');
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 (1281, '可视化报表', '', 1, 12, 0, '/visualization', 'chart', NULL, 0, b'1', b'1', '1', '2022-07-10 20:22:15', '1', '2022-07-10 20:33:30', b'0');
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 (1282, '积木报表', '', 2, 1, 1281, 'jimu-report', 'example', 'visualization/jmreport/index', 0, b'1', b'1', '1', '2022-07-10 20:26:36', '1', '2022-07-28 21:17:34', b'0');
+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 (2030, '站内信', '', 1, 14, 1, 'notify', 'build', '', 0, b'1', b'1', '1', '2022-12-16 11:27:45', '1', '2022-12-16 11:44:11', b'0');
+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 (2031, '站内信模板', '', 2, 1, 2030, 'notify-template', 'build', 'system/notify/notifyTemplate', 0, b'1', b'1', '1', '2022-12-16 11:35:14', '1', '2022-12-16 11:44:43', b'0');
+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 (2032, '我的站内信', '', 2, 2, 2030, 'my-notify', 'checkbox', 'system/notify/myNotify', 0, b'1', b'1', '1', '2022-12-16 11:35:58', '1', '2022-12-16 11:44:48', b'0');
+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 (2033, '查询', 'system:notify-template:query', 3, 1, 2031, '', '', '', 0, b'1', b'1', '1', '2022-12-16 11:36:57', '1', '2022-12-16 11:36:57', b'0');
+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 (2034, '创建', 'system:notify-template:create', 3, 2, 2031, '', '', '', 0, b'1', b'1', '1', '2022-12-16 11:43:16', '1', '2022-12-16 12:06:48', b'0');
+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 (2035, '更新', 'system:notify-template:update', 3, 3, 2031, '', '', '', 0, b'1', b'1', '1', '2022-12-16 12:06:41', '1', '2022-12-16 12:06:41', b'0');
+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 (2036, '删除', 'system:notify-template:delete', 3, 4, 2031, '', '', '', 0, b'1', b'1', '1', '2022-12-16 12:07:03', '1', '2022-12-16 12:07:03', b'0');
+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 (2037, '导出', 'system:notify-template:export', 3, 5, 2031, '', '', '', 0, b'1', b'1', '1', '2022-12-16 12:07:20', '1', '2022-12-16 12:07:20', b'0');
+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 (2038, '发送', 'system:notify-template:send-notify', 3, 6, 2031, '', '', '', 0, b'1', b'1', '1', '2022-12-16 15:21:16', '1', '2022-12-16 15:21:16', b'0');
+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 (2039, '日志', '', 2, 3, 2030, 'notify-log', 'post', 'system/notify/notifyLog', 0, b'1', b'1', '1', '2022-12-16 17:29:00', '1', '2022-12-17 16:07:58', b'0');
+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 (2040, '查询', 'system:notify-log:query', 3, 1, 2039, '', '', '', 0, b'1', b'1', '1', '2022-12-16 17:29:23', '1', '2022-12-16 17:29:23', b'0');
+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 (2041, '撤销', 'system:notify-log:cancel', 3, 2, 2039, '', '', '', 0, b'1', b'1', '1', '2022-12-16 17:30:13', '1', '2022-12-16 17:30:13', b'0');
+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 (2042, '查询', 'system:my-notify:query', 3, 1, 2032, '', '', '', 0, b'1', b'1', '1', '2022-12-16 17:31:31', '1', '2022-12-16 17:31:31', b'0');
+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 (2043, '读取', 'system:my-notify:query', 3, 2, 2032, '', '', '', 0, b'1', b'1', '1', '2022-12-16 17:32:03', '1', '2022-12-16 09:32:20', b'1');
+
COMMIT;
-- ----------------------------
@@ -2661,4 +2681,65 @@ SET FOREIGN_KEY_CHECKS = 1;
-- 积木报表菜单
INSERT INTO `system_menu` VALUES (1281, '可视化报表', '', 1, 12, 0, '/visualization', 'chart', NULL, 0, b'1', b'1', '1', '2022-07-10 20:22:15', '1', '2022-07-10 20:33:30', b'0');
-INSERT INTO `system_menu` VALUES (1282, '积木报表', '', 2, 1, 1281, 'jm-report', '#', 'visualization/jm/index', 0, b'1', b'1', '1', '2022-07-10 20:26:36', '1', '2022-07-10 20:33:26', b'0');
\ No newline at end of file
+INSERT INTO `system_menu` VALUES (1282, '积木报表', '', 2, 1, 1281, 'jm-report', '#', 'visualization/jm/index', 0, b'1', b'1', '1', '2022-07-10 20:26:36', '1', '2022-07-10 20:33:26', b'0');
+
+-- ----------------------------
+-- Table structure for system_notify_message
+-- ----------------------------
+DROP TABLE IF EXISTS `system_notify_message`;
+
+CREATE TABLE `system_notify_message` (
+ `id` bigint NOT NULL AUTO_INCREMENT COMMENT '用户ID',
+ `template_id` int DEFAULT NULL COMMENT '模板id',
+ `template_code` varchar(64) DEFAULT NULL COMMENT '模板编码',
+ `title` varchar(100) DEFAULT NULL COMMENT '模板标题',
+ `content` varchar(255) DEFAULT NULL COMMENT '模板内容',
+ `send_time` datetime DEFAULT NULL COMMENT '发送时间',
+ `send_user_id` int DEFAULT NULL COMMENT '发送用户id',
+ `send_user_name` varchar(30) DEFAULT NULL COMMENT '发送用户名',
+ `user_id` bigint DEFAULT NULL COMMENT '用户id',
+ `user_type` bit(2) DEFAULT NULL COMMENT '用户类型',
+ `read_status` bit(1) DEFAULT NULL COMMENT '阅读状态 0未读 1已读',
+ `read_time` datetime DEFAULT NULL COMMENT '阅读时间',
+ `create_time` datetime DEFAULT NULL COMMENT '创建时间',
+ `update_time` datetime DEFAULT NULL COMMENT '更新时间',
+ `creator` varchar(64) DEFAULT NULL COMMENT '创建者',
+ `updater` varchar(64) DEFAULT NULL COMMENT '更新者',
+ `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
+ `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB COMMENT = '站内信消息表';
+
+-- ----------------------------
+-- Records of system_notify_message
+-- ----------------------------
+BEGIN;
+COMMIT;
+
+-- ----------------------------
+-- Table structure for system_notify_template
+-- ----------------------------
+DROP TABLE IF EXISTS `system_notify_template`;
+
+CREATE TABLE `system_notify_template` (
+ `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
+ `code` varchar(64) DEFAULT NULL COMMENT '模版编码',
+ `title` varchar(255) DEFAULT NULL COMMENT '模版标题',
+ `content` varchar(255) DEFAULT NULL COMMENT '模版内容',
+ `params` varchar(255) DEFAULT NULL COMMENT '参数数组',
+ `status` bit(1) DEFAULT NULL COMMENT '状态',
+ `remark` varchar(60) DEFAULT NULL COMMENT '备注',
+ `create_time` datetime DEFAULT NULL COMMENT '创建时间',
+ `update_time` datetime DEFAULT NULL COMMENT '更新时间',
+ `creator` varchar(64) DEFAULT NULL COMMENT '创建者',
+ `updater` varchar(64) DEFAULT NULL COMMENT '更新者',
+ `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
+ `tenant_id` int DEFAULT NULL COMMENT '租户id',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB COMMENT = '站内信模板表';
+
+-- ----------------------------
+-- Records of system_notify_template
+-- ----------------------------
+BEGIN;
+COMMIT;
\ No newline at end of file
From 491921d5aefd36470ef38682a0bfe2385d7823d6 Mon Sep 17 00:00:00 2001
From: YunaiV
Date: Fri, 23 Dec 2022 18:41:41 +0800
Subject: [PATCH 12/18] =?UTF-8?q?code=20review=20=E7=AB=99=E5=86=85?=
=?UTF-8?q?=E4=BF=A1=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../system/dal/dataobject/notify/NotifyMessageDO.java | 2 ++
.../module/system/service/notify/NotifyLogService.java | 4 ++--
.../system/service/notify/NotifyMessageServiceImpl.java | 6 ++++--
.../module/system/service/notify/NotifySendServiceImpl.java | 5 +++--
.../system/service/notify/NotifyTemplateServiceImpl.java | 1 -
5 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyMessageDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyMessageDO.java
index b431795cf..fe80784a8 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyMessageDO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyMessageDO.java
@@ -61,10 +61,12 @@ public class NotifyMessageDO extends BaseDO {
* 内容
*/
private String content;
+ // TODO @luowenfeng:是不是创建时间,直接作为发送时间;
/**
* 发送时间
*/
private Date sendTime;
+ // TODO @luowenfeng:是不是不用发送 id 和名字😑?
/**
* 发送用户id
*/
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyLogService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyLogService.java
index 272648c9c..290b8f2b9 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyLogService.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyLogService.java
@@ -5,14 +5,13 @@ import cn.iocoder.yudao.module.system.controller.admin.notify.vo.log.NotifyLogPa
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
/**
- *
* 站内信日志 Service 接口
- *
*
* @author LuoWenFeng
*/
public interface NotifyLogService {
+ // TODO @LuoWenFeng:NotifyLogService=》NotifyMessageService
/**
* 获得站内信发送分页
@@ -21,4 +20,5 @@ public interface NotifyLogService {
* @return 站内信分页
*/
PageResult getNotifyMessageSendPage(NotifyLogPageReqVO pageReqVO);
+
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java
index fdfff486e..f8ddad0cf 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImpl.java
@@ -163,15 +163,17 @@ public class NotifyMessageServiceImpl implements NotifyMessageService {
}
}
-
/**
* 批量修改阅读状态为已读
- * @param ids
+ *
+ * @param ids 站内变编号数组
*/
private void batchUpdateReadStatus(Collection ids) {
NotifyMessageDO updateObj = new NotifyMessageDO();
updateObj.setReadStatus(true);
updateObj.setReadTime(new Date());
+ // TODO @luowenfeng:涉及到 mybatis 的操作,都要隐藏到 mapper 中;
notifyMessageMapper.update(updateObj, new LambdaQueryWrapperX().in(NotifyMessageDO::getId, ids));
}
+
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifySendServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifySendServiceImpl.java
index 984fc196b..e72bd6c86 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifySendServiceImpl.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifySendServiceImpl.java
@@ -19,6 +19,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.NOTICE_NOT_FOUND;
+// TODO @luowenfeng:可以直接合并到 NotifyMessageService 中;之前 sms 台复杂,所以没合并。
/**
* 站内信发送 Service 实现类
*
@@ -40,7 +41,6 @@ public class NotifySendServiceImpl implements NotifySendService {
@Override
public Long sendSingleNotifyToAdmin(Long userId, String templateCode, Map templateParams) {
-
return sendSingleNotify(userId, UserTypeEnum.ADMIN.getValue(), templateCode, templateParams);
}
@@ -54,9 +54,10 @@ public class NotifySendServiceImpl implements NotifySendService {
// 校验短信模板是否合法
NotifyTemplateDO template = this.checkNotifyTemplateValid(templateCode);
String content = notifyTemplateService.formatNotifyTemplateContent(template.getContent(), templateParams);
+ // 获得用户
AdminUserDO sendUser = userService.getUser(getLoginUserId());
- // todo 模板状态未开启时的业务
+ // todo 模板状态未开启时的业务;如果未开启,就直接 return 好了;
NotifyMessageDO notifyMessageDO = new NotifyMessageDO();
notifyMessageDO.setContent(content);
notifyMessageDO.setTitle(template.getTitle());
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImpl.java
index fe5058074..7bfa9027c 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImpl.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImpl.java
@@ -85,7 +85,6 @@ public class NotifyTemplateServiceImpl implements NotifyTemplateService {
notifyTemplateCache = CollectionUtils.convertMap(notifyTemplateList, NotifyTemplateDO::getCode);
maxUpdateTime = CollectionUtils.getMaxValue(notifyTemplateList, NotifyTemplateDO::getUpdateTime);
log.info("[initLocalCache][初始化 NotifyTemplate 数量为 {}]", notifyTemplateList.size());
-
}
/**
From ae3ee95cdd5b9e46199f48deb5b50296af39bfca Mon Sep 17 00:00:00 2001
From: YunaiV
Date: Sat, 28 Jan 2023 20:10:19 +0800
Subject: [PATCH 13/18] =?UTF-8?q?=E7=AB=99=E5=86=85=E4=BF=A1=E6=A8=A1?=
=?UTF-8?q?=E5=9D=97=EF=BC=9A=E6=95=B4=E4=BD=93=E5=8A=9F=E8=83=BD=E5=AE=9E?=
=?UTF-8?q?=E7=8E=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../core/query/LambdaQueryWrapperX.java | 2 +
.../mybatis/core/query/QueryWrapperX.java | 8 +-
.../system/enums/ErrorCodeConstants.java | 14 +-
.../admin/notify/NotifyLogController.java | 54 ----
.../admin/notify/NotifyMessageController.java | 58 ++--
.../notify/NotifyTemplateController.java | 21 +-
.../admin/notify/vo/log/NotifyLogBaseVO.java | 44 ---
.../vo/message/NotifyMessageBaseVO.java | 47 +++-
.../NotifyMessageMyPageReqVO.java} | 18 +-
.../vo/message/NotifyMessagePageReqVO.java | 17 +-
.../vo/message/NotifyMessageRespVO.java | 5 +-
.../vo/template/NotifyTemplateBaseVO.java | 29 +-
.../template/NotifyTemplateCreateReqVO.java | 1 -
.../vo/template/NotifyTemplateExcelVO.java | 43 ---
.../template/NotifyTemplateExportReqVO.java | 28 --
.../vo/template/NotifyTemplatePageReqVO.java | 15 +-
.../vo/template/NotifyTemplateRespVO.java | 2 +-
.../vo/template/NotifyTemplateSendReqVO.java | 3 +-
.../template/NotifyTemplateUpdateReqVO.java | 4 +-
.../convert/notify/NotifyLogConvert.java | 23 --
.../convert/notify/NotifyTemplateConvert.java | 3 -
.../dataobject/notify/NotifyMessageDO.java | 68 +++--
.../dataobject/notify/NotifyTemplateDO.java | 14 +-
.../dal/mysql/notify/NotifyMessageMapper.java | 69 ++---
.../mysql/notify/NotifyTemplateMapper.java | 28 +-
.../system/dal/mysql/sms/SmsCodeMapper.java | 2 +-
.../system/service/mail/MailLogService.java | 2 +-
.../service/mail/MailSendServiceImpl.java | 15 +-
.../service/notify/NotifyLogService.java | 24 --
.../service/notify/NotifyLogServiceImpl.java | 35 ---
.../service/notify/NotifyMessageService.java | 85 +++---
.../notify/NotifyMessageServiceImpl.java | 146 ++--------
.../service/notify/NotifySendService.java | 6 +-
.../service/notify/NotifySendServiceImpl.java | 66 +++--
.../service/notify/NotifyTemplateService.java | 31 +-
.../notify/NotifyTemplateServiceImpl.java | 119 ++------
.../service/mail/MailSendServiceImplTest.java | 4 +-
.../notify/NotifyMessageServiceImplTest.java | 266 ++++++++++++++++++
.../notify/NotifySendServiceImplTest.java | 121 ++++++++
.../notify/NotifyTemplateServiceImplTest.java | 146 ++++++++++
.../src/test/resources/sql/clean.sql | 2 +
.../src/test/resources/sql/create_tables.sql | 40 +++
.../src/main/resources/application.yaml | 2 +
.../src/api/system/notify/message.js | 51 ++++
.../src/api/system/notify/myNotify.js | 38 ---
.../src/api/system/notify/notifyLog.js | 11 -
.../notify/{notifyTemplate.js => template.js} | 0
.../src/components/RuoYi/Doc/index.vue | 2 +-
.../src/layout/components/Message/index.vue | 83 ++++++
.../src/layout/components/Navbar.vue | 7 +-
yudao-ui-admin/src/router/index.js | 81 +++---
yudao-ui-admin/src/utils/dict.js | 2 +-
.../src/views/system/mail/log/index.vue | 2 +-
.../src/views/system/notify/message/index.vue | 179 ++++++++++++
.../notify/{myNotify.vue => my/index.vue} | 64 ++---
.../src/views/system/notify/notifyLog.vue | 120 --------
.../index.vue} | 81 +++---
57 files changed, 1400 insertions(+), 1051 deletions(-)
delete mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyLogController.java
delete mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/log/NotifyLogBaseVO.java
rename yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/{log/NotifyLogPageReqVO.java => message/NotifyMessageMyPageReqVO.java} (67%)
delete mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateExcelVO.java
delete mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateExportReqVO.java
delete mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyLogConvert.java
delete mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyLogService.java
delete mode 100644 yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/notify/NotifyLogServiceImpl.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifyMessageServiceImplTest.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifySendServiceImplTest.java
create mode 100644 yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/notify/NotifyTemplateServiceImplTest.java
create mode 100644 yudao-ui-admin/src/api/system/notify/message.js
delete mode 100644 yudao-ui-admin/src/api/system/notify/myNotify.js
delete mode 100644 yudao-ui-admin/src/api/system/notify/notifyLog.js
rename yudao-ui-admin/src/api/system/notify/{notifyTemplate.js => template.js} (100%)
create mode 100644 yudao-ui-admin/src/layout/components/Message/index.vue
create mode 100644 yudao-ui-admin/src/views/system/notify/message/index.vue
rename yudao-ui-admin/src/views/system/notify/{myNotify.vue => my/index.vue} (67%)
delete mode 100644 yudao-ui-admin/src/views/system/notify/notifyLog.vue
rename yudao-ui-admin/src/views/system/notify/{notifyTemplate.vue => template/index.vue} (82%)
diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/LambdaQueryWrapperX.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/LambdaQueryWrapperX.java
index 9fd1d16f8..d0bc6c9e8 100644
--- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/LambdaQueryWrapperX.java
+++ b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/LambdaQueryWrapperX.java
@@ -1,7 +1,9 @@
package cn.iocoder.yudao.framework.mybatis.core.query;
+import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ArrayUtil;
import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils;
+import cn.iocoder.yudao.framework.mybatis.core.enums.SqlConstants;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/QueryWrapperX.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/QueryWrapperX.java
index a44300833..9661b7363 100644
--- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/QueryWrapperX.java
+++ b/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 extends QueryWrapper {
*
* @return this
*/
- public QueryWrapperX limit1() {
+ public QueryWrapperX limitN(int n) {
Assert.notNull(SqlConstants.DB_TYPE, "获取不到数据库的类型");
switch (SqlConstants.DB_TYPE) {
case ORACLE:
case ORACLE_12C:
- super.eq("ROWNUM", 1);
+ super.eq("ROWNUM", n);
break;
case SQL_SERVER:
case SQL_SERVER2005:
- super.select("TOP 1 *"); // 由于 SQL Server 是通过 SELECT TOP 1 实现限制一条,所以只好使用 * 查询剩余字段
+ super.select("TOP " + n + " *"); // 由于 SQL Server 是通过 SELECT TOP 1 实现限制一条,所以只好使用 * 查询剩余字段
break;
default:
- super.last("LIMIT 1");
+ super.last("LIMIT " + n);
}
return this;
}
diff --git a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
index 82266ac44..b108ca775 100644
--- a/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
+++ b/yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
@@ -153,13 +153,13 @@ public interface ErrorCodeConstants {
ErrorCode MAIL_SEND_TEMPLATE_PARAM_MISS = new ErrorCode(1002025000, "模板参数({})缺失");
ErrorCode MAIL_SEND_MAIL_NOT_EXISTS = new ErrorCode(1002025000, "邮箱不存在");
- // ========== 站内信模版 1002023000 ==========
- ErrorCode NOTIFY_TEMPLATE_NOT_EXISTS = new ErrorCode(1002023000, "站内信模版不存在");
- ErrorCode NOTIFY_TEMPLATE_CODE_DUPLICATE = new ErrorCode(1002023001, "已经存在编码为【{}】的站内信模板");
- ErrorCode NOTIFY_TEMPLATE_PARAM_MISS = new ErrorCode(1002023002, "模板参数({})缺失");
+ // ========== 站内信模版 1002026000 ==========
+ ErrorCode NOTIFY_TEMPLATE_NOT_EXISTS = new ErrorCode(1002026000, "站内信模版不存在");
+ ErrorCode NOTIFY_TEMPLATE_CODE_DUPLICATE = new ErrorCode(1002026001, "已经存在编码为【{}】的站内信模板");
- // ========== 站内信 1002024000 ==========
- ErrorCode NOTIFY_MESSAGE_NOT_EXISTS = new ErrorCode(1002024000, "站内信不存在");
- ErrorCode NOTIFY_MESSAGE_ID_PARAM_ERROR = new ErrorCode(1002024001, "站内信ID错误");
+ // ========== 站内信模版 1002027000 ==========
+
+ // ========== 站内信发送 1002028000 ==========
+ ErrorCode NOTIFY_SEND_TEMPLATE_PARAM_MISS = new ErrorCode(1002025000, "模板参数({})缺失");
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyLogController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyLogController.java
deleted file mode 100644
index 84152df7d..000000000
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyLogController.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package cn.iocoder.yudao.module.system.controller.admin.notify;
-
-import cn.iocoder.yudao.framework.common.pojo.CommonResult;
-import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.module.system.controller.admin.notify.vo.log.NotifyLogBaseVO;
-import cn.iocoder.yudao.module.system.controller.admin.notify.vo.log.NotifyLogPageReqVO;
-import cn.iocoder.yudao.module.system.convert.notify.NotifyLogConvert;
-import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
-import cn.iocoder.yudao.module.system.service.notify.NotifyLogService;
-import cn.iocoder.yudao.module.system.service.user.AdminUserService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import javax.annotation.Resource;
-import javax.validation.Valid;
-
-import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
-
-/**
- *
- *
- *
- *
- * @author LuoWenFeng
- */
-@Api(tags = "管理后台 - 站内信发送日志")
-@RestController
-@RequestMapping("/system/notify-log")
-@Validated
-public class NotifyLogController {
-
- @Resource
- private NotifyLogService notifyLogService;
-
- @Resource
- private AdminUserService userService;
-
- @GetMapping("/page")
- @ApiOperation("获得发送站内信日志分页")
- public CommonResult> getNotifyLogPage(@Valid NotifyLogPageReqVO pageVO) {
- PageResult pageResult = notifyLogService.getNotifyMessageSendPage(pageVO);
- PageResult result = NotifyLogConvert.INSTANCE.convertPage(pageResult);
- result.getList().forEach(v -> {
- v.setReceiveUserName(userService.getUser(v.getUserId()).getNickname());
- });
- return success(result);
- }
-
-
-}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyMessageController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyMessageController.java
index 67b0d5d58..51d236110 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyMessageController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyMessageController.java
@@ -1,9 +1,9 @@
package cn.iocoder.yudao.module.system.controller.admin.notify;
-import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageMyPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageRespVO;
import cn.iocoder.yudao.module.system.convert.notify.NotifyMessageConvert;
@@ -18,7 +18,6 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
-import java.util.Collections;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@@ -33,6 +32,8 @@ public class NotifyMessageController {
@Resource
private NotifyMessageService notifyMessageService;
+ // ========== 管理所有的站内信 ==========
+
@GetMapping("/get")
@ApiOperation("获得站内信")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
@@ -50,38 +51,45 @@ public class NotifyMessageController {
return success(NotifyMessageConvert.INSTANCE.convertPage(pageResult));
}
- @GetMapping("/get-recent-list")
- @ApiOperation("获取当前用户最新站内信,默认10条")
- @ApiImplicitParam(name = "size", value = "10", defaultValue = "10", dataTypeClass = Integer.class)
- public CommonResult> getRecentList(@RequestParam(name = "size", defaultValue = "10") Integer size) {
- NotifyMessagePageReqVO reqVO = new NotifyMessagePageReqVO();
- List pageResult = notifyMessageService.getNotifyMessageList(reqVO, size);
- if (CollUtil.isNotEmpty(pageResult)) {
- return success(NotifyMessageConvert.INSTANCE.convertList(pageResult));
- }
- return success(Collections.emptyList());
+ // ========== 查看自己的站内信 ==========
+
+ @GetMapping("/my-page")
+ @ApiOperation("获得我的站内信分页")
+ public CommonResult> getMyMyNotifyMessagePage(@Valid NotifyMessageMyPageReqVO pageVO) {
+ PageResult pageResult = notifyMessageService.getMyMyNotifyMessagePage(pageVO,
+ getLoginUserId(), UserTypeEnum.ADMIN.getValue());
+ return success(NotifyMessageConvert.INSTANCE.convertPage(pageResult));
}
- @GetMapping("/get-unread-count")
- @ApiOperation("获得未读站内信数量")
- public CommonResult getUnreadCount() {
- return success(notifyMessageService.getUnreadNotifyMessageCount(getLoginUserId(), UserTypeEnum.ADMIN.getValue()));
- }
-
- @PutMapping("/update-list-read")
- @ApiOperation("批量标记已读")
+ @PutMapping("/update-read")
+ @ApiOperation("标记站内信为已读")
@ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class)
- public CommonResult batchUpdateNotifyMessageReadStatus(@RequestBody List ids) {
- notifyMessageService.batchUpdateNotifyMessageReadStatus(ids, getLoginUserId());
+ public CommonResult updateNotifyMessageRead(@RequestParam("ids") List ids) {
+ notifyMessageService.updateNotifyMessageRead(ids, getLoginUserId(), UserTypeEnum.ADMIN.getValue());
return success(Boolean.TRUE);
}
@PutMapping("/update-all-read")
- @ApiOperation("所有未读消息标记已读")
- public CommonResult batchUpdateAllNotifyMessageReadStatus() {
- notifyMessageService.batchUpdateAllNotifyMessageReadStatus(getLoginUserId(), UserTypeEnum.ADMIN.getValue());
+ @ApiOperation("标记所有站内信为已读")
+ public CommonResult updateAllNotifyMessageRead() {
+ notifyMessageService.updateAllNotifyMessageRead(getLoginUserId(), UserTypeEnum.ADMIN.getValue());
return success(Boolean.TRUE);
}
+ @GetMapping("/get-unread-list")
+ @ApiOperation("获取当前用户的最新站内信列表,默认 10 条")
+ @ApiImplicitParam(name = "size", value = "10", defaultValue = "10", dataTypeClass = Integer.class)
+ public CommonResult> getUnreadNotifyMessageList(
+ @RequestParam(name = "size", defaultValue = "10") Integer size) {
+ List list = notifyMessageService.getUnreadNotifyMessageList(
+ getLoginUserId(), UserTypeEnum.ADMIN.getValue(), size);
+ return success(NotifyMessageConvert.INSTANCE.convertList(list));
+ }
+
+ @GetMapping("/get-unread-count")
+ @ApiOperation("获得当前用户的未读站内信数量")
+ public CommonResult getUnreadNotifyMessageCount() {
+ return success(notifyMessageService.getUnreadNotifyMessageCount(getLoginUserId(), UserTypeEnum.ADMIN.getValue()));
+ }
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyTemplateController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyTemplateController.java
index b0aad865e..c90145dcd 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyTemplateController.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/NotifyTemplateController.java
@@ -2,8 +2,6 @@ package cn.iocoder.yudao.module.system.controller.admin.notify;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
-import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.*;
import cn.iocoder.yudao.module.system.convert.notify.NotifyTemplateConvert;
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyTemplateDO;
@@ -17,13 +15,9 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
-import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
-import java.io.IOException;
-import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
-import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
@Api(tags = "管理后台 - 站内信模版")
@RestController
@@ -37,7 +31,6 @@ public class NotifyTemplateController {
@Resource
private NotifySendService notifySendService;
-
@PostMapping("/create")
@ApiOperation("创建站内信模版")
@PreAuthorize("@ss.hasPermission('system:notify-template:create')")
@@ -79,22 +72,12 @@ public class NotifyTemplateController {
return success(NotifyTemplateConvert.INSTANCE.convertPage(pageResult));
}
- @GetMapping("/export-excel")
- @ApiOperation("导出站内信模版 Excel")
- @PreAuthorize("@ss.hasPermission('system:notify-template:export')")
- @OperateLog(type = EXPORT)
- public void exportNotifyTemplateExcel(@Valid NotifyTemplateExportReqVO exportReqVO,
- HttpServletResponse response) throws IOException {
- List list = notifyTemplateService.getNotifyTemplateList(exportReqVO);
- // 导出 Excel
- List datas = NotifyTemplateConvert.INSTANCE.convertList02(list);
- ExcelUtils.write(response, "站内信模版.xls", "数据", NotifyTemplateExcelVO.class, datas);
- }
-
@PostMapping("/send-notify")
@ApiOperation("发送站内信")
+ @PreAuthorize("@ss.hasPermission('system:notify-template:send-notify')")
public CommonResult sendNotify(@Valid @RequestBody NotifyTemplateSendReqVO sendReqVO) {
return success(notifySendService.sendSingleNotifyToAdmin(sendReqVO.getUserId(),
sendReqVO.getTemplateCode(), sendReqVO.getTemplateParams()));
}
+
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/log/NotifyLogBaseVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/log/NotifyLogBaseVO.java
deleted file mode 100644
index e24a7d49b..000000000
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/log/NotifyLogBaseVO.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package cn.iocoder.yudao.module.system.controller.admin.notify.vo.log;
-
-import io.swagger.annotations.ApiModelProperty;
-import lombok.Data;
-import org.springframework.format.annotation.DateTimeFormat;
-
-import java.util.Date;
-
-import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
-
-/**
- * 站内信 Base VO,提供给添加、修改、详细的子 VO 使用
- * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
- */
-@Data
-public class NotifyLogBaseVO {
-
- @ApiModelProperty(value = "模版编码")
- private String templateCode;
-
- @ApiModelProperty(value = "标题")
- private String title;
-
- @ApiModelProperty(value = "内容", required = true)
- private String content;
-
- @ApiModelProperty(value = "发送时间", required = true)
- @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
- private Date sendTime;
-
- @ApiModelProperty(value = "芋艿", required = true)
- private String receiveUserName;
-
- @ApiModelProperty(value = "1", required = true)
- private Long userId;
-
- @ApiModelProperty(value = "是否已读 false-未读 true-已读")
- private Boolean readStatus;
-
- @ApiModelProperty(value = "阅读时间")
- @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
- private Date readTime;
-
-}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageBaseVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageBaseVO.java
index f8d5d814a..161fb9331 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageBaseVO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageBaseVO.java
@@ -4,35 +4,58 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
+import javax.validation.constraints.NotNull;
+import java.time.LocalDateTime;
import java.util.Date;
+import java.util.Map;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
/**
- * 站内信 Base VO,提供给添加、修改、详细的子 VO 使用
+ * 站内信消息 Base VO,提供给添加、修改、详细的子 VO 使用
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
*/
@Data
public class NotifyMessageBaseVO {
- @ApiModelProperty(value = "标题")
- private String title;
+ @ApiModelProperty(value = "用户编号", required = true, example = "25025")
+ @NotNull(message = "用户编号不能为空")
+ private Long userId;
- @ApiModelProperty(value = "内容")
- private String content;
+ @ApiModelProperty(value = "用户类型", required = true, example = "1", notes = "参见 UserTypeEnum 枚举")
+ @NotNull(message = "用户类型不能为空")
+ private Byte userType;
- @ApiModelProperty(value = "发送时间")
- @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
- private Date sendTime;
+ @ApiModelProperty(value = "模版编号", required = true, example = "13013")
+ @NotNull(message = "模版编号不能为空")
+ private Long templateId;
- @ApiModelProperty(value = "芋艿")
- private String sendUserName;
+ @ApiModelProperty(value = "模板编码", required = true, example = "test_01")
+ @NotNull(message = "模板编码不能为空")
+ private String templateCode;
- @ApiModelProperty(value = "是否已读 false-未读 true-已读")
+ @ApiModelProperty(value = "模版发送人名称", required = true, example = "芋艿")
+ @NotNull(message = "模版发送人名称不能为空")
+ private String templateNickname;
+
+ @ApiModelProperty(value = "模版内容", required = true, example = "测试内容")
+ @NotNull(message = "模版内容不能为空")
+ private String templateContent;
+
+ @ApiModelProperty(value = "模版类型", required = true, example = "2")
+ @NotNull(message = "模版类型不能为空")
+ private Integer templateType;
+
+ @ApiModelProperty(value = "模版参数", required = true)
+ @NotNull(message = "模版参数不能为空")
+ private Map templateParams;
+
+ @ApiModelProperty(value = "是否已读", required = true, example = "true")
+ @NotNull(message = "是否已读不能为空")
private Boolean readStatus;
@ApiModelProperty(value = "阅读时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
- private Date readTime;
+ private LocalDateTime readTime;
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/log/NotifyLogPageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageMyPageReqVO.java
similarity index 67%
rename from yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/log/NotifyLogPageReqVO.java
rename to yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageMyPageReqVO.java
index aefd60498..8d3eac162 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/log/NotifyLogPageReqVO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageMyPageReqVO.java
@@ -1,4 +1,4 @@
-package cn.iocoder.yudao.module.system.controller.admin.notify.vo.log;
+package cn.iocoder.yudao.module.system.controller.admin.notify.vo.message;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.annotations.ApiModel;
@@ -8,23 +8,21 @@ import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
-import java.util.Date;
+import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
-@ApiModel("管理后台 - 站内信日志分页 Request VO")
+@ApiModel("管理后台 - 站内信分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
-public class NotifyLogPageReqVO extends PageParam {
+public class NotifyMessageMyPageReqVO extends PageParam {
- @ApiModelProperty(value = "模版编码")
- private String templateCode;
-
- @ApiModelProperty(value = "标题")
- private String title;
+ @ApiModelProperty(value = "是否已读", example = "true")
+ private Boolean readStatus;
@ApiModelProperty(value = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
- private Date[] sendTime;
+ private LocalDateTime[] createTime;
+
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessagePageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessagePageReqVO.java
index 3d786796b..f705527c4 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessagePageReqVO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessagePageReqVO.java
@@ -8,6 +8,7 @@ import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
+import java.time.LocalDateTime;
import java.util.Date;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@@ -18,14 +19,20 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@ToString(callSuper = true)
public class NotifyMessagePageReqVO extends PageParam {
- @ApiModelProperty(value = "标题")
- private String title;
+ @ApiModelProperty(value = "用户编号", example = "25025")
+ private Long userId;
- @ApiModelProperty(value = "是否已读 0-未读 1-已读")
- private Boolean readStatus;
+ @ApiModelProperty(value = "用户类型", example = "1")
+ private Integer userType;
+
+ @ApiModelProperty(value = "模板编码", example = "test_01")
+ private String templateCode;
+
+ @ApiModelProperty(value = "模版类型", example = "2")
+ private Integer templateType;
@ApiModelProperty(value = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
- private Date[] createTime;
+ private LocalDateTime[] createTime;
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageRespVO.java
index 306b7bd28..26be638a4 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageRespVO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/message/NotifyMessageRespVO.java
@@ -10,7 +10,10 @@ import io.swagger.annotations.*;
@ToString(callSuper = true)
public class NotifyMessageRespVO extends NotifyMessageBaseVO {
- @ApiModelProperty(value = "ID", required = true)
+ @ApiModelProperty(value = "ID", required = true, example = "1024")
private Long id;
+ @ApiModelProperty(value = "创建时间", required = true)
+ private Date createTime;
+
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateBaseVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateBaseVO.java
index 84aa4b686..118f55baf 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateBaseVO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateBaseVO.java
@@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.validation.InEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
+import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
@@ -14,24 +15,32 @@ import javax.validation.constraints.NotNull;
@Data
public class NotifyTemplateBaseVO {
- @ApiModelProperty(value = "模版编码", required = true)
+ @ApiModelProperty(value = "模版名称", required = true, example = "测试模版")
+ @NotEmpty(message = "模版名称不能为空")
+ private String name;
+
+ @ApiModelProperty(value = "模版编码", required = true, example = "SEND_TEST")
@NotNull(message = "模版编码不能为空")
private String code;
- @ApiModelProperty(value = "模版标题", required = true)
- @NotNull(message = "模版标题不能为空")
- private String title;
+ @ApiModelProperty(value = "模版类型", required = true, example = "1", notes = "对应 system_notify_template_type 字典")
+ @NotNull(message = "模版类型不能为空")
+ private Integer type;
- @ApiModelProperty(value = "模版内容", required = true)
- @NotNull(message = "模版内容不能为空")
+ @ApiModelProperty(value = "发送人名称", required = true, example = "土豆")
+ @NotEmpty(message = "发送人名称不能为空")
+ private String nickname;
+
+ @ApiModelProperty(value = "模版内容", required = true, example = "我是模版内容")
+ @NotEmpty(message = "模版内容不能为空")
private String content;
- @ApiModelProperty(value = "状态:1-启用 0-禁用", required = true)
- @NotNull(message = "状态:1-启用 0-禁用不能为空")
+ @ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 CommonStatusEnum 枚举")
+ @NotNull(message = "状态不能为空")
@InEnum(value = CommonStatusEnum.class, message = "状态必须是 {value}")
private Integer status;
- @ApiModelProperty(value = "备注")
- private String remarks;
+ @ApiModelProperty(value = "备注", example = "我是备注")
+ private String remark;
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateCreateReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateCreateReqVO.java
index e39a2774a..aa41b4e28 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateCreateReqVO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateCreateReqVO.java
@@ -8,5 +8,4 @@ import io.swagger.annotations.*;
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class NotifyTemplateCreateReqVO extends NotifyTemplateBaseVO {
-
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateExcelVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateExcelVO.java
deleted file mode 100644
index 6790f1858..000000000
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateExcelVO.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package cn.iocoder.yudao.module.system.controller.admin.notify.vo.template;
-
-import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
-import lombok.*;
-import java.util.*;
-import io.swagger.annotations.*;
-
-import com.alibaba.excel.annotation.ExcelProperty;
-import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
-import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
-
-
-/**
- * 站内信模版 Excel VO
- *
- * @author 芋道源码
- */
-@Data
-public class NotifyTemplateExcelVO {
-
- @ExcelProperty("ID")
- private Long id;
-
- @ExcelProperty("模版编码")
- private String code;
-
- @ExcelProperty("模版标题")
- private String title;
-
- @ExcelProperty("模版内容")
- private String content;
-
- @ExcelProperty(value = "状态:1-启用 0-禁用", converter = DictConvert.class)
- @DictFormat(DictTypeConstants.COMMON_STATUS)
- private Integer status;
-
- @ExcelProperty("备注")
- private String remarks;
-
- @ExcelProperty("创建时间")
- private Date createTime;
-
-}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateExportReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateExportReqVO.java
deleted file mode 100644
index b3a997933..000000000
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateExportReqVO.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package cn.iocoder.yudao.module.system.controller.admin.notify.vo.template;
-
-import lombok.*;
-import java.util.*;
-import io.swagger.annotations.*;
-import cn.iocoder.yudao.framework.common.pojo.PageParam;
-import org.springframework.format.annotation.DateTimeFormat;
-
-import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
-
-@ApiModel(value = "管理后台 - 站内信模版 Excel 导出 Request VO", description = "参数和 NotifyTemplatePageReqVO 是一致的")
-@Data
-public class NotifyTemplateExportReqVO {
-
- @ApiModelProperty(value = "模版编码")
- private String code;
-
- @ApiModelProperty(value = "模版标题")
- private String title;
-
- @ApiModelProperty(value = "状态:1-启用 0-禁用")
- private Integer status;
-
- @ApiModelProperty(value = "创建时间")
- @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
- private Date[] createTime;
-
-}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplatePageReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplatePageReqVO.java
index 7a8145b67..849ce1275 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplatePageReqVO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplatePageReqVO.java
@@ -1,6 +1,9 @@
package cn.iocoder.yudao.module.system.controller.admin.notify.vo.template;
+import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
import lombok.*;
+
+import java.time.LocalDateTime;
import java.util.*;
import io.swagger.annotations.*;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
@@ -14,17 +17,17 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@ToString(callSuper = true)
public class NotifyTemplatePageReqVO extends PageParam {
- @ApiModelProperty(value = "模版编码")
+ @ApiModelProperty(value = "模版编码", example = "test_01")
private String code;
- @ApiModelProperty(value = "模版标题")
- private String title;
+ @ApiModelProperty(value = "模版名称", example = "我是名称")
+ private String name;
- @ApiModelProperty(value = "状态:1-启用 0-禁用")
- private String status;
+ @ApiModelProperty(value = "状态", example = "1", notes = "参见 CommonStatusEnum 枚举类")
+ private Integer status;
@ApiModelProperty(value = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
- private Date[] createTime;
+ private LocalDateTime[] createTime;
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateRespVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateRespVO.java
index f77126f6c..4df5b7b64 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateRespVO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateRespVO.java
@@ -10,7 +10,7 @@ import io.swagger.annotations.*;
@ToString(callSuper = true)
public class NotifyTemplateRespVO extends NotifyTemplateBaseVO {
- @ApiModelProperty(value = "ID", required = true)
+ @ApiModelProperty(value = "ID", required = true, example = "1024")
private Long id;
@ApiModelProperty(value = "参数数组", example = "name,code")
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateSendReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateSendReqVO.java
index 7a04db5dc..e078fd845 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateSendReqVO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateSendReqVO.java
@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
+import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Map;
@@ -16,7 +17,7 @@ public class NotifyTemplateSendReqVO {
private Long userId;
@ApiModelProperty(value = "模板编码", required = true, example = "01")
- @NotNull(message = "模板编码不能为空")
+ @NotEmpty(message = "模板编码不能为空")
private String templateCode;
@ApiModelProperty(value = "模板参数")
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateUpdateReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateUpdateReqVO.java
index 267159447..6e75ccf89 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateUpdateReqVO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/notify/vo/template/NotifyTemplateUpdateReqVO.java
@@ -10,8 +10,8 @@ import javax.validation.constraints.*;
@ToString(callSuper = true)
public class NotifyTemplateUpdateReqVO extends NotifyTemplateBaseVO {
- @ApiModelProperty(value = "ID", required = true)
- @NotNull(message = "ID不能为空")
+ @ApiModelProperty(value = "ID", required = true, example = "1024")
+ @NotNull(message = "ID 不能为空")
private Long id;
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyLogConvert.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyLogConvert.java
deleted file mode 100644
index 07e3dfb85..000000000
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyLogConvert.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package cn.iocoder.yudao.module.system.convert.notify;
-
-import cn.iocoder.yudao.framework.common.pojo.PageResult;
-import cn.iocoder.yudao.module.system.controller.admin.notify.vo.log.NotifyLogBaseVO;
-import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
-import org.mapstruct.Mapper;
-import org.mapstruct.factory.Mappers;
-
-/**
- *
- *
- *
- *
- * @author LuoWenFeng
- */
-@Mapper
-public interface NotifyLogConvert {
-
- NotifyLogConvert INSTANCE = Mappers.getMapper(NotifyLogConvert.class);
-
- PageResult convertPage(PageResult page);
-
-}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyTemplateConvert.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyTemplateConvert.java
index 8d58067b9..bc8c14d5b 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyTemplateConvert.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/notify/NotifyTemplateConvert.java
@@ -5,7 +5,6 @@ import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateCreateReqVO;
-import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateExcelVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateRespVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.template.NotifyTemplateUpdateReqVO;
import org.mapstruct.Mapper;
@@ -32,6 +31,4 @@ public interface NotifyTemplateConvert {
PageResult convertPage(PageResult page);
- List convertList02(List list);
-
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyMessageDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyMessageDO.java
index fe80784a8..e73badf26 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyMessageDO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyMessageDO.java
@@ -2,19 +2,24 @@ package cn.iocoder.yudao.module.system.dal.dataobject.notify;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import cn.iocoder.yudao.module.system.dal.dataobject.mail.MailTemplateDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
+import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import lombok.*;
+import java.time.LocalDateTime;
import java.util.Date;
+import java.util.Map;
/**
* 站内信 DO
*
* @author xrcoder
*/
-@TableName("system_notify_message")
+@TableName(value = "system_notify_message", autoResultMap = true)
@KeySequence("system_notify_message_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@@ -25,22 +30,10 @@ import java.util.Date;
public class NotifyMessageDO extends BaseDO {
/**
- * ID
+ * 站内信编号,自增
*/
@TableId
private Long id;
- /**
- * 站内信模版编号
- *
- * 关联 {@link NotifyTemplateDO#getId()}
- */
- private Long templateId;
- /**
- * 站内信模版编码
- *
- * 关联 {@link NotifyTemplateDO#getCode()}
- */
- private String templateCode;
/**
* 用户编号
*
@@ -53,28 +46,49 @@ public class NotifyMessageDO extends BaseDO {
* 枚举 {@link UserTypeEnum}
*/
private Integer userType;
+
+ // ========= 模板相关字段 =========
+
/**
- * 标题
+ * 模版编号
+ *
+ * 关联 {@link NotifyTemplateDO#getId()}
*/
- private String title;
+ private Long templateId;
/**
- * 内容
+ * 模版编码
+ *
+ * 关联 {@link NotifyTemplateDO#getCode()}
*/
- private String content;
- // TODO @luowenfeng:是不是创建时间,直接作为发送时间;
+ private String templateCode;
/**
- * 发送时间
+ * 模版类型
+ *
+ * 冗余 {@link NotifyTemplateDO#getType()}
*/
- private Date sendTime;
- // TODO @luowenfeng:是不是不用发送 id 和名字😑?
+ private Integer templateType;
/**
- * 发送用户id
+ * 模版发送人名称
+ *
+ * 冗余 {@link NotifyTemplateDO#getNickname()}
*/
- private Long sendUserId;
+ private String templateNickname;
/**
- * 发送用户名
+ * 模版内容
+ *
+ * 基于 {@link NotifyTemplateDO#getContent()} 格式化后的内容
*/
- private String sendUserName;
+ private String templateContent;
+ /**
+ * 模版参数
+ *
+ * 基于 {@link NotifyTemplateDO#getParams()} 输入后的参数
+ */
+ @TableField(typeHandler = JacksonTypeHandler.class)
+ private Map templateParams;
+
+ // ========= 读取相关字段 =========
+
/**
* 是否已读
*/
@@ -82,6 +96,6 @@ public class NotifyMessageDO extends BaseDO {
/**
* 阅读时间
*/
- private Date readTime;
+ private LocalDateTime readTime;
}
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyTemplateDO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyTemplateDO.java
index 28fa83406..1bce809a1 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyTemplateDO.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/notify/NotifyTemplateDO.java
@@ -31,14 +31,24 @@ public class NotifyTemplateDO extends BaseDO {
*/
@TableId
private Long id;
+ /**
+ * 模版名称
+ */
+ private String name;
/**
* 模版编码
*/
private String code;
/**
- * 模版标题
+ * 模版类型
+ *
+ * 对应 system_notify_template_type 字典
*/
- private String title;
+ private Integer type;
+ /**
+ * 发送人名称
+ */
+ private String nickname;
/**
* 模版内容
*/
diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java
index 470419244..52e2c641e 100644
--- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java
+++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/notify/NotifyMessageMapper.java
@@ -3,49 +3,61 @@ package cn.iocoder.yudao.module.system.dal.mysql.notify;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
-import cn.iocoder.yudao.module.system.controller.admin.notify.vo.log.NotifyLogPageReqVO;
+import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
+import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessageMyPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.notify.vo.message.NotifyMessagePageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.notify.NotifyMessageDO;
import org.apache.ibatis.annotations.Mapper;
+import java.time.LocalDateTime;
+import java.util.Collection;
import java.util.List;
-/**
- * 站内信 Mapper
- *
- * @author xrcoder
- */
@Mapper
public interface NotifyMessageMapper extends BaseMapperX {
- default PageResult selectPage(NotifyMessagePageReqVO reqVO, Long userId, Integer userType) {
+ default PageResult