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}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+