Jelajahi Sumber

Merge remote-tracking branch 'origin/master'

yonghuifan 1 tahun lalu
induk
melakukan
6faeaf12ef
61 mengubah file dengan 1820 tambahan dan 204 penghapusan
  1. 17 3
      src/main/java/com/dragon/tj/portal/common/constants/BusinessConstants.java
  2. 23 0
      src/main/java/com/dragon/tj/portal/common/constants/DateTimeFormatterConstant.java
  3. 15 0
      src/main/java/com/dragon/tj/portal/common/convert/notice/NoticeInfoVOConvert.java
  4. 25 0
      src/main/java/com/dragon/tj/portal/common/convert/notice/NoticeReqConvert.java
  5. 3 18
      src/main/java/com/dragon/tj/portal/common/dto/message/MessageInfoItem.java
  6. 5 0
      src/main/java/com/dragon/tj/portal/common/dto/message/MessageInfoReq.java
  7. 68 0
      src/main/java/com/dragon/tj/portal/common/dto/notice/NoticeInfoItem.java
  8. 62 0
      src/main/java/com/dragon/tj/portal/common/dto/notice/NoticeInfoReq.java
  9. 22 0
      src/main/java/com/dragon/tj/portal/common/dto/notice/NoticeInfoSend.java
  10. 0 4
      src/main/java/com/dragon/tj/portal/common/dto/testDTO.java
  11. 24 0
      src/main/java/com/dragon/tj/portal/common/enums/message/MessageEnum.java
  12. 2 0
      src/main/java/com/dragon/tj/portal/common/enums/message/MessageInfoErrorEnums.java
  13. 24 0
      src/main/java/com/dragon/tj/portal/common/enums/message/MessageLevelEnum.java
  14. 24 0
      src/main/java/com/dragon/tj/portal/common/enums/message/MsgRecordTypeEnum.java
  15. 7 2
      src/main/java/com/dragon/tj/portal/common/enums/message/ScopeEnums.java
  16. 0 4
      src/main/java/com/dragon/tj/portal/common/util/TestUtil.java
  17. 0 4
      src/main/java/com/dragon/tj/portal/common/vo/TestVO.java
  18. 57 0
      src/main/java/com/dragon/tj/portal/common/vo/message/MessagePageParam.java
  19. 78 0
      src/main/java/com/dragon/tj/portal/common/vo/notice/NoticeInfoParam.java
  20. 78 0
      src/main/java/com/dragon/tj/portal/common/vo/notice/NoticeInfoVO.java
  21. 56 0
      src/main/java/com/dragon/tj/portal/common/vo/notice/NoticePageParam.java
  22. 34 13
      src/main/java/com/dragon/tj/portal/component/message/KafkaInitialConfiguration.java
  23. 44 2
      src/main/java/com/dragon/tj/portal/component/message/MessageConsumer.java
  24. 2 12
      src/main/java/com/dragon/tj/portal/component/message/SseController.java
  25. 67 0
      src/main/java/com/dragon/tj/portal/controller/MessageCenterController.java
  26. 27 1
      src/main/java/com/dragon/tj/portal/controller/MessageInfoController.java
  27. 21 0
      src/main/java/com/dragon/tj/portal/controller/MsgRecordController.java
  28. 80 0
      src/main/java/com/dragon/tj/portal/controller/NoticeInfoController.java
  29. 0 42
      src/main/java/com/dragon/tj/portal/controller/TestController.java
  30. 15 0
      src/main/java/com/dragon/tj/portal/entity/MessageInfo.java
  31. 13 2
      src/main/java/com/dragon/tj/portal/entity/MessageInfoScope.java
  32. 65 0
      src/main/java/com/dragon/tj/portal/entity/MsgRecord.java
  33. 106 0
      src/main/java/com/dragon/tj/portal/entity/NoticeInfo.java
  34. 56 0
      src/main/java/com/dragon/tj/portal/entity/NoticeInfoScope.java
  35. 0 31
      src/main/java/com/dragon/tj/portal/entity/Test.java
  36. 5 0
      src/main/java/com/dragon/tj/portal/mapper/MessageInfoMapper.java
  37. 4 4
      src/main/java/com/dragon/tj/portal/mapper/MsgRecordMapper.java
  38. 24 0
      src/main/java/com/dragon/tj/portal/mapper/NoticeInfoMapper.java
  39. 18 0
      src/main/java/com/dragon/tj/portal/mapper/NoticeInfoScopeMapper.java
  40. 11 0
      src/main/java/com/dragon/tj/portal/service/AppInfoService.java
  41. 17 0
      src/main/java/com/dragon/tj/portal/service/InstallInfoService.java
  42. 9 0
      src/main/java/com/dragon/tj/portal/service/MessageInfoService.java
  43. 16 0
      src/main/java/com/dragon/tj/portal/service/MsgRecordService.java
  44. 16 0
      src/main/java/com/dragon/tj/portal/service/NoticeInfoScopeService.java
  45. 36 0
      src/main/java/com/dragon/tj/portal/service/NoticeInfoService.java
  46. 0 16
      src/main/java/com/dragon/tj/portal/service/TestService.java
  47. 38 0
      src/main/java/com/dragon/tj/portal/service/impl/AppInfoServiceImpl.java
  48. 38 0
      src/main/java/com/dragon/tj/portal/service/impl/InstallInfoServiceImpl.java
  49. 74 18
      src/main/java/com/dragon/tj/portal/service/impl/MessageInfoServiceImpl.java
  50. 20 0
      src/main/java/com/dragon/tj/portal/service/impl/MsgRecordServiceImpl.java
  51. 20 0
      src/main/java/com/dragon/tj/portal/service/impl/NoticeInfoScopeServiceImpl.java
  52. 240 0
      src/main/java/com/dragon/tj/portal/service/impl/NoticeInfoServiceImpl.java
  53. 0 20
      src/main/java/com/dragon/tj/portal/service/impl/TestServiceImpl.java
  54. 8 1
      src/main/resources/application-dev.properties
  55. 12 1
      src/main/resources/application-local.properties
  56. 24 0
      src/main/resources/mapper/MessageInfoMapper.xml
  57. 21 0
      src/main/resources/mapper/MsgRecordMapper.xml
  58. 29 0
      src/main/resources/mapper/NoticeInfoMapper.xml
  59. 19 0
      src/main/resources/mapper/NoticeInfoScopeMapper.xml
  60. 0 5
      src/main/resources/mapper/TestMapper.xml
  61. 1 1
      src/test/java/com/dragon/tj/portal/generate/CodeGeneration.java

+ 17 - 3
src/main/java/com/dragon/tj/portal/common/constants/BusinessConstants.java

@@ -11,13 +11,27 @@ public interface BusinessConstants {
     /**
      * 1 通知公告
      */
-    public static Integer DICT_ITEM_ID_1 = 1;
+    public static final Integer DICT_ITEM_ID_1 = 1;
     /**
      * 2 信息交流
      */
-    public static Integer DICT_ITEM_ID_2 = 2;
+    public static final Integer DICT_ITEM_ID_2 = 2;
     /**
      * 3 标准规范
      */
-    public static Integer DICT_ITEM_ID_3 = 3;
+    public static final Integer DICT_ITEM_ID_3 = 3;
+
+
+    /**
+     * 4 任务类
+     */
+    public static final Integer DICT_ITEM_ID_4 = 4;
+    /**
+     * 5 通知类
+     */
+    public static final Integer DICT_ITEM_ID_5 = 5;
+    /**
+     * 6 超期提醒类
+     */
+    public static final Integer DICT_ITEM_ID_6 = 6;
 }

+ 23 - 0
src/main/java/com/dragon/tj/portal/common/constants/DateTimeFormatterConstant.java

@@ -0,0 +1,23 @@
+package com.dragon.tj.portal.common.constants;
+
+import java.time.format.DateTimeFormatter;
+
+public class DateTimeFormatterConstant {
+
+	public static final String OF_PATTERN_0 = "yyyy-MM-dd HH:mm:ss";
+
+	public static final String OF_PATTERN_1 = "yyyyMMddHHmmss";
+
+	public static final String OF_PATTERN_2 = "yyyyMMdd";
+
+	public static final String OF_PATTERN_4 = "yyMMddHHmmss";
+
+
+	public static final DateTimeFormatter FORMATTER0 = DateTimeFormatter.ofPattern(OF_PATTERN_0);
+
+	public static final DateTimeFormatter FORMATTER1 = DateTimeFormatter.ofPattern(OF_PATTERN_1);
+
+	public static final DateTimeFormatter FORMATTER2 = DateTimeFormatter.ofPattern(OF_PATTERN_2);
+
+	public static final DateTimeFormatter FORMATTER4 = DateTimeFormatter.ofPattern(OF_PATTERN_4);
+}

+ 15 - 0
src/main/java/com/dragon/tj/portal/common/convert/notice/NoticeInfoVOConvert.java

@@ -0,0 +1,15 @@
+package com.dragon.tj.portal.common.convert.notice;
+
+import com.dragon.tj.portal.common.vo.notice.NoticeInfoParam;
+import com.dragon.tj.portal.common.vo.notice.NoticeInfoVO;
+import com.dragon.tj.portal.entity.NoticeInfo;
+import org.mapstruct.Mapper;
+import org.mapstruct.MappingConstants;
+
+@Mapper(componentModel = MappingConstants.ComponentModel.SPRING)
+public interface NoticeInfoVOConvert {
+
+    NoticeInfoVO toVo(NoticeInfo noticeInfo);
+
+    NoticeInfo paramTo(NoticeInfoParam noticeInfoParam);
+}

+ 25 - 0
src/main/java/com/dragon/tj/portal/common/convert/notice/NoticeReqConvert.java

@@ -0,0 +1,25 @@
+package com.dragon.tj.portal.common.convert.notice;
+
+
+import com.dragon.tj.portal.common.dto.message.MessageInfoItem;
+import com.dragon.tj.portal.common.dto.message.MessageInfoReq;
+import com.dragon.tj.portal.common.dto.notice.NoticeInfoReq;
+import com.dragon.tj.portal.entity.NoticeInfo;
+import org.mapstruct.Mapper;
+import org.mapstruct.MappingConstants;
+
+@Mapper(componentModel = MappingConstants.ComponentModel.SPRING)
+public interface NoticeReqConvert {
+
+    /**
+     * User转换UserDTO
+     *
+     * @return {@link } Mappings是对字段名不一致的字段进行映射
+     * <p>
+     * Mapping可以处理变量名不一致映射关系以及指定日期格式等等
+     */
+    MessageInfoItem reqToItem(NoticeInfoReq messageInfoReq);
+
+    NoticeInfo reqToInfo(NoticeInfoReq noticeInfoReq);
+
+}

+ 3 - 18
src/main/java/com/dragon/tj/portal/common/dto/message/MessageInfoItem.java

@@ -21,9 +21,10 @@ public class MessageInfoItem {
     private Integer messageType;
 
     /**
-     * 范围ids
+     *消息级别
      */
-    private Set<String> scopeIds;
+    private Integer messageLevel;
+
 
     /**
      * 阅读状态 默认0未读 1已读
@@ -35,22 +36,6 @@ public class MessageInfoItem {
      */
     private String title;
 
-    /**
-     * 信息内容
-     */
-    private String content;
-
-    /**
-     * 附件地址
-     */
-    private String attachmentPath;
-
-
-    /**
-     * 版本号
-     */
-    private Integer version;
-
     /**
      *
      *--------------非req参数

+ 5 - 0
src/main/java/com/dragon/tj/portal/common/dto/message/MessageInfoReq.java

@@ -71,4 +71,9 @@ public class MessageInfoReq {
      */
     private String appId = "appId";
 
+    /**
+     *消息级别
+     */
+    private Integer messageLevel;
+
 }

+ 68 - 0
src/main/java/com/dragon/tj/portal/common/dto/notice/NoticeInfoItem.java

@@ -0,0 +1,68 @@
+package com.dragon.tj.portal.common.dto.notice;
+
+
+import lombok.Getter;
+import lombok.Setter;
+import org.hibernate.validator.constraints.Range;
+
+import java.util.Set;
+
+/**
+ * @author huey China.
+ * @Description :
+ * @Date Created in 2023/6/15 15:59
+ */
+@Getter
+@Setter
+public class NoticeInfoItem {
+
+
+    @Range(min = 1, max = 3, message = "请填入1~3,1 通知公告 2信息交流 3 标准规范 ")
+    private Integer messageType;
+
+    /**
+     * 范围ids
+     */
+    private Set<String> scopeIds;
+
+    /**
+     * 阅读状态 默认0未读 1已读
+     */
+    private Integer readStatus;
+
+    /**
+     * 信息标题
+     */
+    private String title;
+
+    /**
+     * 信息内容
+     */
+    private String content;
+
+    /**
+     * 附件地址
+     */
+    private String attachmentPath;
+
+
+    /**
+     * 版本号
+     */
+    private Integer version;
+
+    /**
+     *
+     *--------------非req参数
+     */
+    /**
+     * TODO appId
+     */
+    private String appId = "appId";
+
+    /**
+     * 客户端id
+     */
+    private String clientId;
+
+}

+ 62 - 0
src/main/java/com/dragon/tj/portal/common/dto/notice/NoticeInfoReq.java

@@ -0,0 +1,62 @@
+package com.dragon.tj.portal.common.dto.notice;
+
+
+import lombok.Getter;
+import lombok.Setter;
+import org.hibernate.validator.constraints.Range;
+
+import javax.validation.constraints.NotNull;
+import java.util.Set;
+
+/**
+ * @author huey China.
+ * @Description :
+ * @Date Created in 2023/6/15 15:59
+ */
+@Getter
+@Setter
+public class NoticeInfoReq {
+
+
+    /**
+    *范围id 为appCode
+    */
+    private String scopeId;
+
+    @Range(min = 4, max = 6, message = "请填入4~6,4 任务类 5 通知类 6 超期提醒类")
+    private Integer messageType;
+
+
+    /**
+     *消息级别
+     */
+    private Integer messageLevel;
+
+    /**
+     * 信息标题
+     */
+    private String title;
+
+    /**
+     * 信息内容
+     */
+    private String content;
+
+    /**
+     * 附件地址
+     */
+    private String attachmentPath;
+
+    @NotNull(message = "毫秒时间戳 不能为空")
+    private Long t;
+
+    private String id;
+
+    /**
+     * md5 (登录人标识+t)
+     */
+//    @NotBlank(message = "调用者身份验证标识 不能为空")
+    private String k;
+
+
+}

+ 22 - 0
src/main/java/com/dragon/tj/portal/common/dto/notice/NoticeInfoSend.java

@@ -0,0 +1,22 @@
+package com.dragon.tj.portal.common.dto.notice;
+
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Set;
+
+/**
+ * @author huey China.
+ * @Description :
+ * @Date Created in 2023/6/15 15:59
+ */
+@Getter
+@Setter
+public class NoticeInfoSend {
+
+    private NoticeInfoReq noticeInfoReq;
+
+    private Set<String> clientIds;
+
+}

+ 0 - 4
src/main/java/com/dragon/tj/portal/common/dto/testDTO.java

@@ -1,4 +0,0 @@
-package com.dragon.tj.portal.common.dto;
-
-public class testDTO {
-}

+ 24 - 0
src/main/java/com/dragon/tj/portal/common/enums/message/MessageEnum.java

@@ -0,0 +1,24 @@
+package com.dragon.tj.portal.common.enums.message;
+
+/**
+ * @author huey China.
+ * @Description : 消息读状态
+ * @Date Created in 2023/6/28 15:48
+ */
+public enum MessageEnum {
+
+    NO(0, "未读"),
+    YES(1, "已读");
+
+    private final Integer value;
+    private final String name;
+
+    MessageEnum(Integer value, String name) {
+        this.value = value;
+        this.name = name;
+    }
+
+    public Integer value() {
+        return this.value;
+    }
+}

+ 2 - 0
src/main/java/com/dragon/tj/portal/common/enums/message/MessageInfoErrorEnums.java

@@ -29,6 +29,8 @@ public interface MessageInfoErrorEnums extends FrameResultError {
         MESSAGE_DEPT_EMPTY(201002, "当前信息类型部门名称不能为空!"),
         MESSAGE_READ_ALREADY(201002, "当前信息已读"),
 
+        NOTICE_LIMIT_EMPTY(201002, "当前消息范围不能为空!"),
+
 
         ;
 

+ 24 - 0
src/main/java/com/dragon/tj/portal/common/enums/message/MessageLevelEnum.java

@@ -0,0 +1,24 @@
+package com.dragon.tj.portal.common.enums.message;
+
+/**
+ * @author huey China.
+ * @Description : 消息读状态
+ * @Date Created in 2023/6/28 15:48
+ */
+public enum MessageLevelEnum {
+
+    HOT(1, "紧急"),
+    DEFAULT(0, "正常");
+
+    private final Integer value;
+    private final String name;
+
+    MessageLevelEnum(Integer value, String name) {
+        this.value = value;
+        this.name = name;
+    }
+
+    public Integer value() {
+        return this.value;
+    }
+}

+ 24 - 0
src/main/java/com/dragon/tj/portal/common/enums/message/MsgRecordTypeEnum.java

@@ -0,0 +1,24 @@
+package com.dragon.tj.portal.common.enums.message;
+
+/**
+* @author huey China.
+* @Description : 1 信息 2 消息通知
+* @Date Created in
+*/
+public enum MsgRecordTypeEnum {
+
+    MESSAGE(1, "信息"),
+    NOTICE(2, "消息通知");
+
+    private final Integer value;
+    private final String name;
+
+    MsgRecordTypeEnum(Integer value, String name) {
+        this.value = value;
+        this.name = name;
+    }
+
+    public Integer value() {
+        return this.value;
+    }
+}

+ 7 - 2
src/main/java/com/dragon/tj/portal/common/enums/message/ScopeEnums.java

@@ -10,7 +10,9 @@ import com.dragon.tj.portal.common.constants.BusinessConstants;
 public enum ScopeEnums {
 
     SCOPE_DEPT(1, "部门"),
-    SCOPE_MEMBER(2, "人员");
+    SCOPE_MEMBER(2, "人员"),
+
+    SCOPE_APP(3, "应用");
 
     private final Integer value;
     private final String name;
@@ -26,9 +28,12 @@ public enum ScopeEnums {
 
     public static ScopeEnums ofMessageType(Integer messageType) {
         if (messageType.equals(BusinessConstants.DICT_ITEM_ID_2)) {
+            return SCOPE_DEPT;
+        } else if (messageType.equals(BusinessConstants.DICT_ITEM_ID_1)
+                || messageType.equals(BusinessConstants.DICT_ITEM_ID_3)) {
             return SCOPE_MEMBER;
         } else {
-            return SCOPE_MEMBER;
+            return SCOPE_APP;
         }
     }
 }

+ 0 - 4
src/main/java/com/dragon/tj/portal/common/util/TestUtil.java

@@ -1,4 +0,0 @@
-package com.dragon.tj.portal.common.util;
-
-public class TestUtil {
-}

+ 0 - 4
src/main/java/com/dragon/tj/portal/common/vo/TestVO.java

@@ -1,4 +0,0 @@
-package com.dragon.tj.portal.common.vo;
-
-public class TestVO {
-}

+ 57 - 0
src/main/java/com/dragon/tj/portal/common/vo/message/MessagePageParam.java

@@ -0,0 +1,57 @@
+package com.dragon.tj.portal.common.vo.message;
+
+import com.dragon.tj.portal.common.constants.DateTimeFormatterConstant;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.hibernate.validator.constraints.Range;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.time.LocalDateTime;
+
+/**
+ * @author huey China.
+ * @Description : vo
+ * @Date Created in 2023/6/28 15:19
+ */
+@ToString
+@Getter
+@Setter
+public class MessagePageParam {
+
+    /**
+     * 信息类型 1 通知公告 2信息交流 3 标准规范
+     */
+    private Integer messageType;
+
+
+    /**
+     * 信息标题
+     */
+    private String title;
+
+    /**
+     * 信息内容
+     */
+    private String content;
+
+    /**
+     * 部门名称
+     */
+    private String deptCode;
+
+    /**
+     * 发布时间
+     */
+    @DateTimeFormat(pattern = DateTimeFormatterConstant.OF_PATTERN_0)
+    private LocalDateTime publishTimeStart;
+    @DateTimeFormat(pattern = DateTimeFormatterConstant.OF_PATTERN_0)
+    private LocalDateTime publishTimeEnd;
+
+    /**
+    *
+    *已读状态
+    */
+    private Integer readStatus;
+
+}

+ 78 - 0
src/main/java/com/dragon/tj/portal/common/vo/notice/NoticeInfoParam.java

@@ -0,0 +1,78 @@
+package com.dragon.tj.portal.common.vo.notice;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+import java.time.LocalDateTime;
+
+/**
+ * @author huey China.
+ * @Description : vo
+ * @Date Created in 2023/6/28 15:19
+ */
+@ToString
+@Getter
+@Setter
+public class NoticeInfoParam {
+
+
+    /**
+     * 主键
+     */
+
+    private Long id;
+
+    /**
+     * 消息类型 4 任务类 5 通知类 6 超期提醒类
+     */
+    private Integer messageType;
+
+    /**
+     * 阅读状态 默认0未读 1已读
+     */
+    private Integer readStatus;
+
+    /**
+     * 信息标题
+     */
+    private String title;
+
+    /**
+     * 信息内容
+     */
+    private String content;
+
+    /**
+     * 附件地址
+     */
+    private String attachmentPath;
+
+    /**
+     * 创建人
+     */
+    private String createBy;
+    private String createUser;
+
+    /**
+     * 修改人
+     */
+    private String updateBy;
+    private String updateUser;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 更新时间
+     */
+    private LocalDateTime updateTime;
+
+
+    /**
+     * 版本号
+     */
+    private Integer version;
+}

+ 78 - 0
src/main/java/com/dragon/tj/portal/common/vo/notice/NoticeInfoVO.java

@@ -0,0 +1,78 @@
+package com.dragon.tj.portal.common.vo.notice;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+import java.time.LocalDateTime;
+
+/**
+ * @author huey China.
+ * @Description : vo
+ * @Date Created in 2023/6/28 15:19
+ */
+@ToString
+@Getter
+@Setter
+public class NoticeInfoVO {
+
+
+    /**
+     * 主键
+     */
+
+    private Long id;
+
+    /**
+     * 消息类型 4 任务类 5 通知类 6 超期提醒类
+     */
+    private Integer messageType;
+
+    /**
+     * 阅读状态 默认0未读 1已读
+     */
+    private Integer readStatus;
+
+    /**
+     * 信息标题
+     */
+    private String title;
+
+    /**
+     * 信息内容
+     */
+    private String content;
+
+    /**
+     * 附件地址
+     */
+    private String attachmentPath;
+
+    /**
+     * 创建人
+     */
+    private String createBy;
+    private String createUser;
+
+    /**
+     * 修改人
+     */
+    private String updateBy;
+    private String updateUser;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 更新时间
+     */
+    private LocalDateTime updateTime;
+
+
+    /**
+     * 版本号
+     */
+    private Integer version;
+}

+ 56 - 0
src/main/java/com/dragon/tj/portal/common/vo/notice/NoticePageParam.java

@@ -0,0 +1,56 @@
+package com.dragon.tj.portal.common.vo.notice;
+
+import com.dragon.tj.portal.common.constants.DateTimeFormatterConstant;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.time.LocalDateTime;
+
+/**
+ * @author huey China.
+ * @Description : vo
+ * @Date Created in 2023/6/28 15:19
+ */
+@ToString
+@Getter
+@Setter
+public class NoticePageParam {
+
+    /**
+     * 消息类型 4 任务类 5 通知类 6 超期提醒类
+     */
+    private Integer messageType;
+
+
+    /**
+     * 信息标题
+     */
+    private String title;
+
+    /**
+     * 信息内容
+     */
+    private String content;
+
+    /**
+     * 部门名称
+     */
+    private String deptCode;
+
+    /**
+     * 发布时间
+     */
+    @DateTimeFormat(pattern = DateTimeFormatterConstant.OF_PATTERN_0)
+    private LocalDateTime publishTimeStart;
+    @DateTimeFormat(pattern = DateTimeFormatterConstant.OF_PATTERN_0)
+    private LocalDateTime publishTimeEnd;
+
+    /**
+    *
+    *已读状态
+    */
+    private Integer readStatus;
+
+}

+ 34 - 13
src/main/java/com/dragon/tj/portal/component/message/KafkaInitialConfiguration.java

@@ -1,8 +1,15 @@
 package com.dragon.tj.portal.component.message;
 
+import cn.hutool.core.collection.CollUtil;
+import com.dragon.tj.portal.service.AppInfoService;
 import org.apache.kafka.clients.admin.NewTopic;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.kafka.config.TopicBuilder;
+import org.springframework.kafka.core.KafkaAdmin;
+
+import java.util.List;
 
 /**
  * @author huey China.
@@ -12,23 +19,37 @@ import org.springframework.context.annotation.Configuration;
 @Configuration
 public class KafkaInitialConfiguration {
 
-    public static String sseTopic = "sseTopic";
+    /**
+     * 信息管理
+     */
+    public static final String sseTopic = "sseTopic";
 
     /**
-     * 创建一个名为 sseTopic 的Topic并设置分区数为8,分区副本数为2
+     * @author huey China.
+     * @Description : 注入信息及不同系统级别的topic
+     * @Date Created in 2023/7/11 16:03
      */
     @Bean
-    public NewTopic initialTopic() {
-
-        return new NewTopic(sseTopic, 1, (short) 1);
-
+    public KafkaAdmin.NewTopics messageTopics() {
+//        List<String> allAppSysCodes = appInfoService.getAllAppSysCodes();
+        NewTopic base = TopicBuilder.name(sseTopic).partitions(1).replicas(1).build();
+
+        NewTopic[] newTopics = null;
+
+//        if (CollUtil.isNotEmpty(allAppSysCodes)) {
+//            newTopics = new NewTopic[allAppSysCodes.size() + 1];
+//            for (int i = 0; i < allAppSysCodes.size(); i++) {
+//                String sysCode = allAppSysCodes.get(i);
+//                newTopics[i] = TopicBuilder.name(sseTopic + "-" + sysCode).partitions(1).replicas(1).build();
+//            }
+//            newTopics[allAppSysCodes.size()] = base;
+//        } else {
+//            newTopics = new NewTopic[]{base};
+//        }
+        newTopics = new NewTopic[]{base};
+        //信息相关
+        KafkaAdmin.NewTopics infoBase = new KafkaAdmin.NewTopics(newTopics);
+        return infoBase;
     }
 
-    // 如果要修改分区数,只需修改配置值重启项目即可
-    // 修改分区数并不会导致数据的丢失,但是分区数只能增大不能减小
-    @Bean
-    public NewTopic updateTopic() {
-        return new NewTopic(sseTopic, 1, (short) 1);
-
-    }
 }

+ 44 - 2
src/main/java/com/dragon/tj/portal/component/message/MessageConsumer.java

@@ -4,9 +4,12 @@ import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.dragon.tj.portal.common.convert.mesage.MessageReqConvert;
+import com.dragon.tj.portal.common.convert.notice.NoticeReqConvert;
 import com.dragon.tj.portal.common.dto.message.MessageInfoItem;
 import com.dragon.tj.portal.common.dto.message.MessageInfoReq;
 import com.dragon.tj.portal.common.dto.message.MessageInfoSend;
+import com.dragon.tj.portal.common.dto.notice.NoticeInfoReq;
+import com.dragon.tj.portal.common.dto.notice.NoticeInfoSend;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
@@ -33,14 +36,16 @@ public class MessageConsumer {
     @Autowired
     private MessageReqConvert messageReqConvert;
 
+    @Autowired
+    private NoticeReqConvert noticeReqConvert;
+
     /**
      * get client published message from kafka,process it according to the serverId
      *
      * @param msg
      * @param ack
      */
-//    @KafkaListener(topics = {"sseTopic"}, clientIdPrefix = "${spring.application.name}", id = "openapi-be-sse-connection-", idIsGroup = false, groupId = "openapi-be-sse-connection-" + "#{T(java.util.UUID).randomUUID()}")
-    @KafkaListener(topics = {"sseTopic"})
+    @KafkaListener(topics = KafkaInitialConfiguration.sseTopic)
     public void sseConnectionProcess(String msg, Acknowledgment ack) {
         log.info("get kafka msg from topic:{}, msg:{}", KafkaInitialConfiguration.sseTopic, msg);
         if (StrUtil.isEmpty(msg)) {
@@ -78,4 +83,41 @@ public class MessageConsumer {
         ack.acknowledge();
     }
 
+    @KafkaListener(topics = "#{'${kafka.topics}'.split(',')}")
+    public void sseConnectionProcess2(String msg, Acknowledgment ack) {
+        log.info("get kafka2 msg from topic:{}, msg:{}", KafkaInitialConfiguration.sseTopic, msg);
+        if (StrUtil.isEmpty(msg)) {
+            log.error("kafka msg is empty, no process");
+            return;
+        }
+        NoticeInfoSend reqDTO;
+        try {
+            reqDTO = JSONObject.parseObject(msg, NoticeInfoSend.class);
+        } catch (Exception e) {
+            log.error("parsing string to obj failed, msg={}, e={}", msg, e);
+            return;
+        }
+        Set<String> clientIds = reqDTO.getClientIds();
+        NoticeInfoReq noticeInfoReq = reqDTO.getNoticeInfoReq();
+
+        for (String clientId : clientIds) {
+            OpenApiSseEmitter emitter = sseEmitters.get(clientId);
+            if (emitter == null) {
+                log.error("can't find the sseEmitter obj from sseEmitters, no process {}", clientId);
+                continue;
+            }
+            try {
+                MessageInfoItem messageInfoItem = noticeReqConvert.reqToItem(noticeInfoReq);
+                messageInfoItem.setClientId(clientId);
+
+                String sendMsg = JSON.toJSONString(messageInfoItem);
+                // 发送消息给客户端
+                log.info("send sse msg={} to clientId={}", sendMsg, clientId);
+                emitter.send(sendMsg, MediaType.APPLICATION_JSON);
+            } catch (IOException e) {
+                emitter.completeWithError(e);
+            }
+        }
+        ack.acknowledge();
+    }
 }

+ 2 - 12
src/main/java/com/dragon/tj/portal/component/message/SseController.java

@@ -2,7 +2,7 @@ package com.dragon.tj.portal.component.message;
 
 import com.alibaba.fastjson.JSON;
 import com.dragon.tj.portal.auth.model.LoginUser;
-import com.dragon.tj.portal.auth.service.TokenService;
+import com.dragon.tj.portal.auth.util.SecurityUtils;
 import com.dragon.tj.portal.common.base.R;
 import com.dragon.tj.portal.common.dto.message.MessageInfoReq;
 import com.dragon.tj.portal.service.MessageInfoService;
@@ -13,7 +13,6 @@ import org.springframework.web.bind.annotation.*;
 import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
 
 import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.util.Map;
 
@@ -32,9 +31,6 @@ public class SseController {
     @Autowired
     private MessageInfoService messageInfoService;
 
-    @Autowired
-    private TokenService tokenService;
-
     @GetMapping("/subscribe/{clientId}")
     public SseEmitter subscribe(@PathVariable String clientId, HttpServletResponse response) {
 
@@ -51,13 +47,7 @@ public class SseController {
         return emitter;
     }
 
-    @PostMapping("/publish")
-    public R publish(@Validated @RequestBody MessageInfoReq messageInfoReq, HttpServletRequest request) {
-        log.info("sseController req param is {}", JSON.toJSONString(messageInfoReq));
-        LoginUser loginUser = tokenService.getLoginUser(request);
-        log.info("sseController current people is {}", JSON.toJSONString(loginUser));
-        return messageInfoService.push(messageInfoReq,loginUser);
-    }
+
 
 
 }

+ 67 - 0
src/main/java/com/dragon/tj/portal/controller/MessageCenterController.java

@@ -0,0 +1,67 @@
+package com.dragon.tj.portal.controller;
+
+
+import com.alibaba.fastjson.JSON;
+import com.dragon.tj.portal.auth.model.LoginUser;
+import com.dragon.tj.portal.auth.util.SecurityUtils;
+import com.dragon.tj.portal.common.base.R;
+import com.dragon.tj.portal.common.dto.message.MessageInfoReq;
+import com.dragon.tj.portal.common.dto.notice.NoticeInfoReq;
+import com.dragon.tj.portal.component.message.MessageProducer;
+import com.dragon.tj.portal.service.MessageInfoService;
+import com.dragon.tj.portal.service.NoticeInfoService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ * 消息对接
+ * </p>
+ *
+ * @author huey
+ * @since 2023-06-15
+ */
+@Slf4j
+@RestController
+@RequestMapping("/api/message")
+public class MessageCenterController {
+
+    @Autowired
+    private MessageInfoService messageInfoService;
+
+    @Autowired
+    private NoticeInfoService noticeInfoService;
+
+    /**
+     * @author huey China.
+     * @Description : 信息发送
+     * @Date Created in 2023/7/11 15:14
+     */
+    @PostMapping("/publish")
+    public R publish(@Validated @RequestBody MessageInfoReq messageInfoReq) {
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        log.info("api/message/publish-req-is {}-{}", JSON.toJSONString(loginUser), JSON.toJSONString(messageInfoReq));
+        return messageInfoService.push(messageInfoReq, loginUser);
+    }
+
+    /**
+     * @author huey China.
+     * @Description : 消息提醒发送
+     * @Date Created in 2023/7/11 16:12
+     */
+    @PostMapping("/send")
+    public R send(@Validated @RequestBody NoticeInfoReq noticeInfoReq) {
+        log.info("api/message/send-req-is {}", JSON.toJSONString(noticeInfoReq));
+        return noticeInfoService.send(noticeInfoReq);
+    }
+
+    //topic 颁发 appcode 及
+
+
+}
+

+ 27 - 1
src/main/java/com/dragon/tj/portal/controller/MessageInfoController.java

@@ -1,15 +1,20 @@
 package com.dragon.tj.portal.controller;
 
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.dragon.tj.portal.common.base.R;
 import com.dragon.tj.portal.common.vo.message.MessageInfoParam;
 import com.dragon.tj.portal.common.vo.message.MessageInfoVO;
+import com.dragon.tj.portal.common.vo.message.MessagePageParam;
 import com.dragon.tj.portal.component.log.annotation.SysLog;
 import com.dragon.tj.portal.service.MessageInfoService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
+import java.util.List;
+
 /**
  * <p>
  * 信息表 前端控制器
@@ -25,6 +30,19 @@ public class MessageInfoController {
     @Autowired
     private MessageInfoService messageInfoService;
 
+    /**
+     * 分页查询
+     *
+     * @param page
+     * @param req
+     * @return
+     */
+    @GetMapping("/page")
+    public R page(Page page, MessagePageParam req) {
+        IPage iPage = messageInfoService.queryPage(page, req);
+        return R.ok(iPage);
+    }
+
     /**
      * 详情
      */
@@ -44,11 +62,19 @@ public class MessageInfoController {
     }
 
     /**
-     * 
+     * 阅
      */
     @GetMapping("read")
     public R read(Long id) {
         return R.ok(messageInfoService.read(id));
     }
+
+    /**
+     * 批阅
+     */
+    @GetMapping("reads")
+    public R reads(List<Long> ids) {
+        return R.ok(messageInfoService.reads(ids));
+    }
 }
 

+ 21 - 0
src/main/java/com/dragon/tj/portal/controller/MsgRecordController.java

@@ -0,0 +1,21 @@
+package com.dragon.tj.portal.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ * 消息信息原始记录表 前端控制器
+ * </p>
+ *
+ * @author huey
+ * @since 2023-07-11
+ */
+@RestController
+@RequestMapping("/msgRecord")
+public class MsgRecordController {
+
+}
+

+ 80 - 0
src/main/java/com/dragon/tj/portal/controller/NoticeInfoController.java

@@ -0,0 +1,80 @@
+package com.dragon.tj.portal.controller;
+
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.dragon.tj.portal.common.base.R;
+import com.dragon.tj.portal.common.vo.message.MessagePageParam;
+import com.dragon.tj.portal.common.vo.notice.NoticeInfoParam;
+import com.dragon.tj.portal.common.vo.notice.NoticeInfoVO;
+import com.dragon.tj.portal.component.log.annotation.SysLog;
+import com.dragon.tj.portal.service.NoticeInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 信息表 前端控制器
+ * </p>
+ *
+ * @author huey
+ * @since 2023-06-15
+ */
+@RestController
+@RequestMapping("/noticeInfo")
+public class NoticeInfoController {
+
+    @Autowired
+    private NoticeInfoService noticeInfoService;
+
+    /**
+     * 分页查询
+     *
+     * @param page
+     * @param req
+     * @return
+     */
+    @GetMapping("/page")
+    public R page(Page page, MessagePageParam req) {
+        IPage iPage = noticeInfoService.queryPage(page, req);
+        return R.ok(iPage);
+    }
+
+    /**
+     * 详情
+     */
+    @GetMapping("detail")
+    public R detail(Long id) {
+        NoticeInfoVO messageInfoVO = noticeInfoService.detail(id);
+        return R.ok(messageInfoVO);
+    }
+
+    /**
+     * 修改
+     */
+    @SysLog("信息更新")
+    @PostMapping("update")
+    public R update(@Validated @RequestBody NoticeInfoParam messageInfoParam) {
+        return R.ok(noticeInfoService.update(messageInfoParam));
+    }
+
+    /**
+     * 阅读
+     */
+    @GetMapping("read")
+    public R read(Long id) {
+        return R.ok(noticeInfoService.read(id));
+    }
+
+    /**
+     * 批阅
+     */
+    @GetMapping("reads")
+    public R reads(List<Long> ids) {
+        return R.ok(noticeInfoService.reads(ids));
+    }
+}
+

+ 0 - 42
src/main/java/com/dragon/tj/portal/controller/TestController.java

@@ -1,42 +0,0 @@
-package com.dragon.tj.portal.controller;
-
-
-import com.dragon.tj.portal.component.log.dto.SysLogDTO;
-import com.dragon.tj.portal.common.base.R;
-import com.dragon.tj.portal.component.log.annotation.SysLog;
-import com.dragon.tj.portal.component.redis.StringCacheUtil;
-import com.dragon.tj.portal.entity.Test;
-import com.dragon.tj.portal.service.TestService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-/**
- * <p>
- * 前端控制器
- * </p>
- *
- * @author huey
- * @since 2023-06-11
- */
-@RestController
-@RequestMapping("/test")
-public class TestController {
-
-    @Autowired
-    private TestService testService;
-
-    @Autowired
-    private StringCacheUtil stringCacheUtil;
-
-    @RequestMapping("/test1")
-    @SysLog("huey测试日志记录")
-    public R test1(@Validated @RequestBody SysLogDTO sysLogDTO) {
-        Test byId = testService.getById(1);
-        stringCacheUtil.set("huey", "huey-test");
-        return R.ok(byId.getContent());
-    }
-}
-

+ 15 - 0
src/main/java/com/dragon/tj/portal/entity/MessageInfo.java

@@ -1,6 +1,7 @@
 package com.dragon.tj.portal.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import java.io.Serializable;
@@ -36,6 +37,10 @@ public class MessageInfo implements Serializable {
      */
     private Integer messageType;
 
+    /**
+    *消息级别
+    */
+    private Integer messageLevel;
     /**
      * 阅读状态 默认0未读 1已读
      */
@@ -86,7 +91,17 @@ public class MessageInfo implements Serializable {
     /**
      * 版本号
      */
+
     private Integer version;
 
+    @TableField(exist = false)
+    private String memberId;
+
+    @TableField(exist = false)
+    private Integer scopeType;
+
+    @TableField(exist = false)
+    private String scopeId;
+
 
 }

+ 13 - 2
src/main/java/com/dragon/tj/portal/entity/MessageInfoScope.java

@@ -3,11 +3,12 @@ package com.dragon.tj.portal.entity;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import java.io.Serializable;
 import lombok.Getter;
 import lombok.Setter;
 import lombok.experimental.Accessors;
 
+import java.io.Serializable;
+
 /**
  * <p>
  * 信息范围表
@@ -30,13 +31,23 @@ public class MessageInfoScope implements Serializable {
     @TableId(value = "id", type = IdType.AUTO)
     private Long id;
 
+    /**
+     * 信息id
+     */
+    private Long messageInfoId;
+
+    /**
+     * 人员id
+     */
+    private String memberId;
+
     /**
      * 范围类型 1部门 2 人员
      */
     private Integer scopeType;
 
     /**
-     * 范围id 
+     * 部门id
      */
     private String scopeId;
 

+ 65 - 0
src/main/java/com/dragon/tj/portal/entity/MsgRecord.java

@@ -0,0 +1,65 @@
+package com.dragon.tj.portal.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 消息信息原始记录表
+ * </p>
+ *
+ * @author huey
+ * @since 2023-07-11
+ */
+@Getter
+@Setter
+@Accessors(chain = true)
+@TableName("msg_record")
+public class MsgRecord implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 1 信息 2 消息通知
+     */
+    private Integer type;
+
+    /**
+     * 信息内容
+     */
+    private String reqContent;
+
+    /**
+     * 创建人
+     */
+    private String createBy;
+
+    /**
+     * 创建人姓名
+     */
+    private String createUser;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 删除状态 默认0 有效 1无效
+     */
+    private Integer delFlag;
+
+
+}

+ 106 - 0
src/main/java/com/dragon/tj/portal/entity/NoticeInfo.java

@@ -0,0 +1,106 @@
+package com.dragon.tj.portal.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 消息表
+ * </p>
+ *
+ * @author huey
+ * @since 2023-07-11
+ */
+@Getter
+@Setter
+@Accessors(chain = true)
+@TableName("notice_info")
+public class NoticeInfo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 消息类型 4 任务类 5 通知类 6 超期提醒类
+     */
+    private Integer messageType;
+
+    /**
+    *
+    *消息级别
+    */
+    private Integer messageLevel;
+
+    /**
+     * 阅读状态 默认0未读 1已读
+     */
+    private Integer readStatus;
+
+    /**
+     * 信息标题
+     */
+    private String title;
+
+    /**
+     * 信息内容
+     */
+    private String content;
+
+    /**
+     * 附件地址
+     */
+    private String attachmentPath;
+
+    /**
+     * 创建人
+     */
+    private String createBy;
+
+    /**
+     * 创建人姓名
+     */
+    private String createUser;
+
+    /**
+     * 修改人
+     */
+    private String updateBy;
+
+    /**
+     * 修改人姓名
+     */
+    private String updateUser;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 更新时间
+     */
+    private LocalDateTime updateTime;
+
+    /**
+     * 删除状态 默认0 有效 1无效
+     */
+    private Integer delFlag;
+
+    /**
+     * 版本号
+     */
+    private Integer version;
+
+
+}

+ 56 - 0
src/main/java/com/dragon/tj/portal/entity/NoticeInfoScope.java

@@ -0,0 +1,56 @@
+package com.dragon.tj.portal.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 消息通知范围表
+ * </p>
+ *
+ * @author huey
+ * @since 2023-07-11
+ */
+@Getter
+@Setter
+@Accessors(chain = true)
+@TableName("notice_info_scope")
+public class NoticeInfoScope implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    private Long noticeInfoId;
+
+    /**
+     * 人员id
+     */
+    private String memberId;
+
+    /**
+     * 范围类型 1部门 2 人员
+     */
+    private Integer scopeType;
+
+    /**
+     * 部门id 
+     */
+    private String scopeId;
+
+    /**
+     * 范围级别
+     */
+    private Integer scopeLevel;
+
+
+}

+ 0 - 31
src/main/java/com/dragon/tj/portal/entity/Test.java

@@ -1,31 +0,0 @@
-package com.dragon.tj.portal.entity;
-
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
-import java.io.Serializable;
-import lombok.Getter;
-import lombok.Setter;
-import lombok.experimental.Accessors;
-
-/**
- * <p>
- * 
- * </p>
- *
- * @author huey
- * @since 2023-06-11
- */
-@Getter
-@Setter
-@Accessors(chain = true)
-public class Test implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    @TableId(value = "id", type = IdType.AUTO)
-    private Integer id;
-
-    private String content;
-
-
-}

+ 5 - 0
src/main/java/com/dragon/tj/portal/mapper/MessageInfoMapper.java

@@ -1,8 +1,12 @@
 package com.dragon.tj.portal.mapper;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.dragon.tj.portal.common.vo.message.MessagePageParam;
 import com.dragon.tj.portal.entity.MessageInfo;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * <p>
@@ -15,4 +19,5 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface MessageInfoMapper extends BaseMapper<MessageInfo> {
 
+    IPage<MessageInfo> queryPage(Page page,@Param("req") MessagePageParam req);
 }

+ 4 - 4
src/main/java/com/dragon/tj/portal/mapper/TestMapper.java → src/main/java/com/dragon/tj/portal/mapper/MsgRecordMapper.java

@@ -1,18 +1,18 @@
 package com.dragon.tj.portal.mapper;
 
-import com.dragon.tj.portal.entity.Test;
+import com.dragon.tj.portal.entity.MsgRecord;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Mapper;
 
 /**
  * <p>
- *  Mapper 接口
+ * 消息信息原始记录表 Mapper 接口
  * </p>
  *
  * @author huey
- * @since 2023-06-11
+ * @since 2023-07-11
  */
 @Mapper
-public interface TestMapper extends BaseMapper<Test> {
+public interface MsgRecordMapper extends BaseMapper<MsgRecord> {
 
 }

+ 24 - 0
src/main/java/com/dragon/tj/portal/mapper/NoticeInfoMapper.java

@@ -0,0 +1,24 @@
+package com.dragon.tj.portal.mapper;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.dragon.tj.portal.common.vo.message.MessagePageParam;
+import com.dragon.tj.portal.entity.MessageInfo;
+import com.dragon.tj.portal.entity.NoticeInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * <p>
+ * 消息表 Mapper 接口
+ * </p>
+ *
+ * @author huey
+ * @since 2023-07-11
+ */
+@Mapper
+public interface NoticeInfoMapper extends BaseMapper<NoticeInfo> {
+
+    IPage<MessageInfo> queryPage(Page page,@Param("req") MessagePageParam req);
+}

+ 18 - 0
src/main/java/com/dragon/tj/portal/mapper/NoticeInfoScopeMapper.java

@@ -0,0 +1,18 @@
+package com.dragon.tj.portal.mapper;
+
+import com.dragon.tj.portal.entity.NoticeInfoScope;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ * 消息通知范围表 Mapper 接口
+ * </p>
+ *
+ * @author huey
+ * @since 2023-07-11
+ */
+@Mapper
+public interface NoticeInfoScopeMapper extends BaseMapper<NoticeInfoScope> {
+
+}

+ 11 - 0
src/main/java/com/dragon/tj/portal/service/AppInfoService.java

@@ -0,0 +1,11 @@
+package com.dragon.tj.portal.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.dragon.tj.portal.entity.AppInfo;
+
+import java.util.List;
+
+public interface AppInfoService extends IService<AppInfo> {
+
+    List<String> getAllAppSysCodes();
+}

+ 17 - 0
src/main/java/com/dragon/tj/portal/service/InstallInfoService.java

@@ -0,0 +1,17 @@
+package com.dragon.tj.portal.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.dragon.tj.portal.entity.InstallInfo;
+
+import java.util.Set;
+
+public interface InstallInfoService extends IService<InstallInfo> {
+
+    /**
+    * @author huey China.
+    * @Description : 获取appid下所有有效用户id标识
+    * @Date Created in 2023/7/12 16:21
+     * @return
+    */
+    Set<String> findUsersByAppId(String appId);
+}

+ 9 - 0
src/main/java/com/dragon/tj/portal/service/MessageInfoService.java

@@ -1,13 +1,18 @@
 package com.dragon.tj.portal.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.dragon.tj.portal.auth.model.LoginUser;
 import com.dragon.tj.portal.common.base.R;
 import com.dragon.tj.portal.common.dto.message.MessageInfoReq;
 import com.dragon.tj.portal.common.vo.message.MessageInfoParam;
 import com.dragon.tj.portal.common.vo.message.MessageInfoVO;
+import com.dragon.tj.portal.common.vo.message.MessagePageParam;
 import com.dragon.tj.portal.entity.MessageInfo;
 import com.baomidou.mybatisplus.extension.service.IService;
 
+import java.util.List;
+
 /**
  * <p>
  * 信息表 服务类
@@ -25,4 +30,8 @@ public interface MessageInfoService extends IService<MessageInfo> {
     boolean update(MessageInfoParam messageInfoParam);
 
     boolean read(Long id);
+
+    boolean reads(List<Long> ids);
+
+    IPage queryPage(Page page, MessagePageParam req);
 }

+ 16 - 0
src/main/java/com/dragon/tj/portal/service/MsgRecordService.java

@@ -0,0 +1,16 @@
+package com.dragon.tj.portal.service;
+
+import com.dragon.tj.portal.entity.MsgRecord;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ * 消息信息原始记录表 服务类
+ * </p>
+ *
+ * @author huey
+ * @since 2023-07-11
+ */
+public interface MsgRecordService extends IService<MsgRecord> {
+
+}

+ 16 - 0
src/main/java/com/dragon/tj/portal/service/NoticeInfoScopeService.java

@@ -0,0 +1,16 @@
+package com.dragon.tj.portal.service;
+
+import com.dragon.tj.portal.entity.NoticeInfoScope;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ * 消息通知范围表 服务类
+ * </p>
+ *
+ * @author huey
+ * @since 2023-07-11
+ */
+public interface NoticeInfoScopeService extends IService<NoticeInfoScope> {
+
+}

+ 36 - 0
src/main/java/com/dragon/tj/portal/service/NoticeInfoService.java

@@ -0,0 +1,36 @@
+package com.dragon.tj.portal.service;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.dragon.tj.portal.common.base.R;
+import com.dragon.tj.portal.common.dto.notice.NoticeInfoReq;
+import com.dragon.tj.portal.common.vo.message.MessagePageParam;
+import com.dragon.tj.portal.common.vo.notice.NoticeInfoParam;
+import com.dragon.tj.portal.common.vo.notice.NoticeInfoVO;
+import com.dragon.tj.portal.entity.NoticeInfo;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 消息表 服务类
+ * </p>
+ *
+ * @author huey
+ * @since 2023-07-11
+ */
+public interface NoticeInfoService extends IService<NoticeInfo> {
+
+    R send(NoticeInfoReq messageInfoReq);
+
+    NoticeInfoVO detail(Long id);
+
+    boolean update(NoticeInfoParam noticeInfoParam);
+
+    boolean read(Long id);
+
+    boolean reads(List<Long> ids);
+
+    IPage queryPage(Page page, MessagePageParam req);
+}

+ 0 - 16
src/main/java/com/dragon/tj/portal/service/TestService.java

@@ -1,16 +0,0 @@
-package com.dragon.tj.portal.service;
-
-import com.dragon.tj.portal.entity.Test;
-import com.baomidou.mybatisplus.extension.service.IService;
-
-/**
- * <p>
- *  服务类
- * </p>
- *
- * @author huey
- * @since 2023-06-11
- */
-public interface TestService extends IService<Test> {
-
-}

+ 38 - 0
src/main/java/com/dragon/tj/portal/service/impl/AppInfoServiceImpl.java

@@ -0,0 +1,38 @@
+package com.dragon.tj.portal.service.impl;
+
+
+import cn.hutool.core.collection.CollUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.dragon.tj.portal.common.enums.DelFlagEnum;
+import com.dragon.tj.portal.entity.AppInfo;
+import com.dragon.tj.portal.mapper.app.AppInfoMapper;
+import com.dragon.tj.portal.service.AppInfoService;
+import com.google.common.collect.Lists;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+@Service
+public class AppInfoServiceImpl extends ServiceImpl<AppInfoMapper, AppInfo> implements AppInfoService {
+
+
+    @Override
+    public List<String> getAllAppSysCodes() {
+        LambdaQueryWrapper<AppInfo> wrapper = Wrappers.lambdaQuery();
+        wrapper.eq(AppInfo::getDelFlag, DelFlagEnum.NO.value());
+        List<AppInfo> list = this.list(wrapper);
+        if (CollUtil.isEmpty(list)) {
+            return Lists.newArrayList();
+        } else {
+            Set<String> sysCodes = list.stream().filter(e -> StringUtils.isNotEmpty(e.getSystemNumber())).map(AppInfo::getSystemNumber).collect(Collectors.toSet());
+            return Lists.newArrayList(sysCodes);
+        }
+    }
+}
+
+

+ 38 - 0
src/main/java/com/dragon/tj/portal/service/impl/InstallInfoServiceImpl.java

@@ -0,0 +1,38 @@
+package com.dragon.tj.portal.service.impl;
+
+
+import cn.hutool.core.collection.CollUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.dragon.tj.portal.entity.InstallInfo;
+import com.dragon.tj.portal.mapper.app.InstallInfoMapper;
+import com.dragon.tj.portal.service.InstallInfoService;
+import com.google.common.collect.Sets;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+@Service
+public class InstallInfoServiceImpl extends ServiceImpl<InstallInfoMapper, InstallInfo> implements InstallInfoService {
+
+
+    @Override
+    public Set<String> findUsersByAppId(String appId) {
+        LambdaQueryWrapper<InstallInfo> wrapper = Wrappers.lambdaQuery();
+        wrapper.eq(InstallInfo::getAppId, appId);
+        List<InstallInfo> list = this.list(wrapper);
+        if (CollUtil.isNotEmpty(list)) {
+            Set<String> idCardSet = list.stream().filter(e -> StringUtils.isNotEmpty(e.getUserIdcard())).map(InstallInfo::getUserIdcard).collect(Collectors.toSet());
+            if (CollUtil.isNotEmpty(idCardSet)) {
+                return idCardSet;
+            }
+        }
+        return Sets.newHashSet();
+    }
+}
+
+

+ 74 - 18
src/main/java/com/dragon/tj/portal/service/impl/MessageInfoServiceImpl.java

@@ -2,33 +2,44 @@ package com.dragon.tj.portal.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
 import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.dragon.tj.portal.auth.model.LoginUser;
 import com.dragon.tj.portal.auth.web.service.SysDeptService;
 import com.dragon.tj.portal.common.base.R;
 import com.dragon.tj.portal.common.constants.BusinessConstants;
-import com.dragon.tj.portal.common.convert.mesage.MessageReqConvert;
 import com.dragon.tj.portal.common.convert.mesage.MessageInfoVOConvert;
+import com.dragon.tj.portal.common.convert.mesage.MessageReqConvert;
 import com.dragon.tj.portal.common.dto.message.MessageInfoReq;
 import com.dragon.tj.portal.common.dto.message.MessageInfoSend;
 import com.dragon.tj.portal.common.enums.message.MessageInfoErrorEnums;
-import com.dragon.tj.portal.common.enums.message.ScopeEnums;
+import com.dragon.tj.portal.common.enums.message.MsgRecordTypeEnum;
 import com.dragon.tj.portal.common.enums.message.ReadStatusEnum;
+import com.dragon.tj.portal.common.enums.message.ScopeEnums;
 import com.dragon.tj.portal.common.vo.message.MessageInfoParam;
 import com.dragon.tj.portal.common.vo.message.MessageInfoVO;
+import com.dragon.tj.portal.common.vo.message.MessagePageParam;
 import com.dragon.tj.portal.component.exception.message.MessageInfoException;
 import com.dragon.tj.portal.component.message.KafkaInitialConfiguration;
 import com.dragon.tj.portal.component.message.MessageProducer;
 import com.dragon.tj.portal.entity.MessageInfo;
 import com.dragon.tj.portal.entity.MessageInfoScope;
+import com.dragon.tj.portal.entity.MsgRecord;
 import com.dragon.tj.portal.mapper.MessageInfoMapper;
 import com.dragon.tj.portal.service.MessageInfoScopeService;
 import com.dragon.tj.portal.service.MessageInfoService;
+import com.dragon.tj.portal.service.MsgRecordService;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Sets;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.codec.digest.DigestUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
+import java.time.LocalDateTime;
 import java.util.List;
 import java.util.Set;
 
@@ -40,6 +51,7 @@ import java.util.Set;
  * @author huey
  * @since 2023-06-15
  */
+@Slf4j
 @Service
 public class MessageInfoServiceImpl extends ServiceImpl<MessageInfoMapper, MessageInfo> implements MessageInfoService {
 
@@ -58,6 +70,12 @@ public class MessageInfoServiceImpl extends ServiceImpl<MessageInfoMapper, Messa
     @Autowired
     private MessageInfoVOConvert messageInfoVOConvert;
 
+    @Autowired
+    private MsgRecordService msgRecordService;
+
+    @Value("${message-secret:false}")
+    private boolean messageSecret;
+
     @Override
     public R push(MessageInfoReq messageInfoReq, LoginUser loginUser) {
         return R.ok(this.doMessage(messageInfoReq, loginUser));
@@ -86,6 +104,24 @@ public class MessageInfoServiceImpl extends ServiceImpl<MessageInfoMapper, Messa
         return this.updateById(messageInfo);
     }
 
+    @Override
+    public boolean reads(List<Long> ids) {
+        List<MessageInfo> list = Lists.newArrayList();
+        ids.forEach(e -> {
+            MessageInfo messageInfo = new MessageInfo();
+            messageInfo.setReadStatus(ReadStatusEnum.YES.value());
+            messageInfo.setId(e);
+
+        });
+        return this.updateBatchById(list);
+    }
+
+    @Override
+    public IPage queryPage(Page page, MessagePageParam req) {
+        IPage<MessageInfo> queryPage = baseMapper.queryPage(page, req);
+        return queryPage;
+    }
+
 
     /**
      * @author huey China.
@@ -103,24 +139,27 @@ public class MessageInfoServiceImpl extends ServiceImpl<MessageInfoMapper, Messa
         if (CollUtil.isNotEmpty(messageClientIds)) {
             MessageInfoSend messageInfoSend = this.doSaveMessageInfo(messageInfoReq, messageClientIds, loginUser);
             isSend = producer.send(KafkaInitialConfiguration.sseTopic, JSON.toJSONString(messageInfoSend));
+            if (isSend) {
+                MsgRecord msgRecord = new MsgRecord();
+                msgRecord.setCreateBy("admin");
+                msgRecord.setCreateTime(LocalDateTime.now());
+                msgRecord.setReqContent(JSON.toJSONString(messageInfoSend));
+                msgRecord.setType(MsgRecordTypeEnum.MESSAGE.value());
+                msgRecordService.save(msgRecord);
+            }
         }
         return isSend;
     }
 
-    private MessageInfoSend doSaveMessageInfo(MessageInfoReq messageInfoReq, Set<String> messageClientIds, LoginUser loginUser) {
+    @Transactional(rollbackFor = Exception.class)
+    public MessageInfoSend doSaveMessageInfo(MessageInfoReq messageInfoReq, Set<String> messageClientIds, LoginUser loginUser) {
+        log.info("doSaveMessageInfo-start-{}-{}", loginUser.getIdCard(), messageClientIds);
         Integer messageType = messageInfoReq.getMessageType();
         ScopeEnums scopeEnums = ScopeEnums.ofMessageType(messageType);
         List<MessageInfoScope> insertList = Lists.newArrayList();
         MessageInfoSend messageInfoSend = new MessageInfoSend();
         messageInfoSend.setMessageInfoReq(messageInfoReq);
         messageInfoSend.setClientIds(messageClientIds);
-        messageClientIds.forEach(e -> {
-            MessageInfoScope messageInfoScope = new MessageInfoScope();
-            messageInfoScope.setScopeId(e);
-            messageInfoScope.setScopeType(scopeEnums.value());
-            //messageInfoScope.setScopeLevel("");
-            insertList.add(messageInfoScope);
-        });
 
         MessageInfo messageInfo = messageReqConvert.reqToInfo(messageInfoReq);
         messageInfo.setCreateBy(loginUser.getIdCard());
@@ -129,6 +168,15 @@ public class MessageInfoServiceImpl extends ServiceImpl<MessageInfoMapper, Messa
         boolean isSaveBatchSuccess = false;
         try {
             isSaveBatchSuccess = this.save(messageInfo);
+            messageClientIds.forEach(e -> {
+                MessageInfoScope messageInfoScope = new MessageInfoScope();
+                messageInfoScope.setMessageInfoId(messageInfo.getId());
+                messageInfoScope.setScopeId(loginUser.getOrgCode());
+                messageInfoScope.setMemberId(e);
+                messageInfoScope.setScopeType(scopeEnums.value());
+                //messageInfoScope.setScopeLevel("");
+                insertList.add(messageInfoScope);
+            });
             isSaveBatchSuccess = messageInfoScopeService.saveBatch(insertList);
         } catch (Exception e) {
             log.warn("消息中心 saveBatch 存储失败 {}");
@@ -145,6 +193,7 @@ public class MessageInfoServiceImpl extends ServiceImpl<MessageInfoMapper, Messa
                 log.warn("消息中心 存储失败 {}");
             }
         }
+        log.info("doSaveMessageInfo-end-{}-{}", loginUser.getIdCard(), messageClientIds);
         return messageInfoSend;
     }
 
@@ -179,20 +228,27 @@ public class MessageInfoServiceImpl extends ServiceImpl<MessageInfoMapper, Messa
      */
     private boolean doMessage(MessageInfoReq messageInfoReq, LoginUser loginUser) {
 
-        this.validate(messageInfoReq);
-        return this.transferIds(messageInfoReq, loginUser);
+        if (this.validate(messageInfoReq, loginUser.getIdCard())) {
+            return this.transferIds(messageInfoReq, loginUser);
+        }
+        return false;
     }
 
     /**
      * @author huey China.
-     * @Description : md5 验证消息唯一
+     * @Description : md5 验证消息有效
      * @Date Created in 2023/6/16 16:15
      */
-    private void validate(MessageInfoReq messageInfoReq) {
-//        String correctHash = DigestUtils.md5Hex("currentId" + messageInfoReq.getT());
-//        if (!correctHash.equalsIgnoreCase(messageInfoReq.getK())) {
-//            return;
-//        }
+    private boolean validate(MessageInfoReq messageInfoReq, String idCard) {
+        log.info("validate-start-{}", idCard);
+        if (messageSecret) {
+            String correctHash = DigestUtils.md5Hex(idCard + messageInfoReq.getT());
+            if (!correctHash.equalsIgnoreCase(messageInfoReq.getK())) {
+                return false;
+            }
+        }
+        log.info("validate-end-{}", idCard);
+        return true;
     }
 
 }

+ 20 - 0
src/main/java/com/dragon/tj/portal/service/impl/MsgRecordServiceImpl.java

@@ -0,0 +1,20 @@
+package com.dragon.tj.portal.service.impl;
+
+import com.dragon.tj.portal.entity.MsgRecord;
+import com.dragon.tj.portal.mapper.MsgRecordMapper;
+import com.dragon.tj.portal.service.MsgRecordService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 消息信息原始记录表 服务实现类
+ * </p>
+ *
+ * @author huey
+ * @since 2023-07-11
+ */
+@Service
+public class MsgRecordServiceImpl extends ServiceImpl<MsgRecordMapper, MsgRecord> implements MsgRecordService {
+
+}

+ 20 - 0
src/main/java/com/dragon/tj/portal/service/impl/NoticeInfoScopeServiceImpl.java

@@ -0,0 +1,20 @@
+package com.dragon.tj.portal.service.impl;
+
+import com.dragon.tj.portal.entity.NoticeInfoScope;
+import com.dragon.tj.portal.mapper.NoticeInfoScopeMapper;
+import com.dragon.tj.portal.service.NoticeInfoScopeService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 消息通知范围表 服务实现类
+ * </p>
+ *
+ * @author huey
+ * @since 2023-07-11
+ */
+@Service
+public class NoticeInfoScopeServiceImpl extends ServiceImpl<NoticeInfoScopeMapper, NoticeInfoScope> implements NoticeInfoScopeService {
+
+}

+ 240 - 0
src/main/java/com/dragon/tj/portal/service/impl/NoticeInfoServiceImpl.java

@@ -0,0 +1,240 @@
+package com.dragon.tj.portal.service.impl;
+
+import cn.hutool.core.collection.CollUtil;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.dragon.tj.portal.common.base.R;
+import com.dragon.tj.portal.common.convert.notice.NoticeInfoVOConvert;
+import com.dragon.tj.portal.common.convert.notice.NoticeReqConvert;
+import com.dragon.tj.portal.common.dto.notice.NoticeInfoReq;
+import com.dragon.tj.portal.common.dto.notice.NoticeInfoSend;
+import com.dragon.tj.portal.common.enums.message.MessageInfoErrorEnums;
+import com.dragon.tj.portal.common.enums.message.MsgRecordTypeEnum;
+import com.dragon.tj.portal.common.enums.message.ReadStatusEnum;
+import com.dragon.tj.portal.common.enums.message.ScopeEnums;
+import com.dragon.tj.portal.common.vo.message.MessagePageParam;
+import com.dragon.tj.portal.common.vo.notice.NoticeInfoParam;
+import com.dragon.tj.portal.common.vo.notice.NoticeInfoVO;
+import com.dragon.tj.portal.component.exception.message.MessageInfoException;
+import com.dragon.tj.portal.component.message.MessageProducer;
+import com.dragon.tj.portal.entity.MessageInfo;
+import com.dragon.tj.portal.entity.MsgRecord;
+import com.dragon.tj.portal.entity.NoticeInfo;
+import com.dragon.tj.portal.entity.NoticeInfoScope;
+import com.dragon.tj.portal.mapper.NoticeInfoMapper;
+import com.dragon.tj.portal.service.InstallInfoService;
+import com.dragon.tj.portal.service.MsgRecordService;
+import com.dragon.tj.portal.service.NoticeInfoScopeService;
+import com.dragon.tj.portal.service.NoticeInfoService;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.time.LocalDateTime;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * <p>
+ * 消息表 服务实现类
+ * </p>
+ *
+ * @author huey
+ * @since 2023-07-11
+ */
+@Slf4j
+@Service
+public class NoticeInfoServiceImpl extends ServiceImpl<NoticeInfoMapper, NoticeInfo> implements NoticeInfoService {
+
+    @Autowired
+    private MessageProducer producer;
+
+    @Autowired
+    private MsgRecordService msgRecordService;
+
+    @Autowired
+    private InstallInfoService installInfoService;
+
+    @Autowired
+    private NoticeInfoScopeService noticeInfoScopeService;
+
+    @Autowired
+    private NoticeReqConvert noticeReqConvert;
+
+    @Autowired
+    private NoticeInfoVOConvert noticeInfoVOConvert;
+
+    @Value("${notice-secret:true}")
+    private boolean noticeSecret;
+
+
+    @Override
+    public R send(NoticeInfoReq noticeInfoReq) {
+        if (this.validate(noticeInfoReq)) {
+            return R.ok(this.transferIds(noticeInfoReq));
+        }
+        //封装消息
+        //保存及推送mq
+        return R.failed(false);
+    }
+
+    @Override
+    public NoticeInfoVO detail(Long id) {
+        NoticeInfo noticeInfo = this.getById(id);
+        return noticeInfoVOConvert.toVo(noticeInfo);
+    }
+
+    @Override
+    public boolean update(NoticeInfoParam noticeInfoParam) {
+        NoticeInfo messageInfo = noticeInfoVOConvert.paramTo(noticeInfoParam);
+        return this.updateById(messageInfo);
+    }
+
+    @Override
+    public boolean read(Long id) {
+        NoticeInfo noticeInfo = this.getById(id);
+        Integer readStatus = noticeInfo.getReadStatus();
+        if (ReadStatusEnum.YES.value().equals(readStatus)) {
+            throw new MessageInfoException(MessageInfoErrorEnums.Code.MESSAGE_READ_ALREADY);
+        }
+        noticeInfo.setReadStatus(ReadStatusEnum.YES.value());
+        return this.updateById(noticeInfo);
+    }
+
+    @Override
+    public boolean reads(List<Long> ids) {
+        List<NoticeInfo> list = Lists.newArrayList();
+        ids.forEach(e -> {
+            MessageInfo messageInfo = new MessageInfo();
+            messageInfo.setReadStatus(ReadStatusEnum.YES.value());
+            messageInfo.setId(e);
+
+        });
+        return this.updateBatchById(list);
+    }
+
+    @Override
+    public IPage queryPage(Page page, MessagePageParam req) {
+        IPage<MessageInfo> queryPage = baseMapper.queryPage(page, req);
+        return queryPage;
+    }
+
+    private boolean transferIds(NoticeInfoReq noticeInfoReq) {
+        // 120101510000 120000450200
+        //120222197001010001 120222197001010002
+        boolean isSend = false;
+        Integer messageType = noticeInfoReq.getMessageType();
+        String scopeId = noticeInfoReq.getScopeId();
+        Set<String> messageClientIds = this.getMessageClientIds(messageType, scopeId);
+        log.info("transferIds-scopeId-{}-{}", scopeId, messageClientIds);
+        if (CollUtil.isNotEmpty(messageClientIds)) {
+            NoticeInfoSend noticeInfoSend = this.doSaveNoticeInfo(noticeInfoReq, messageClientIds);
+            isSend = producer.send("sseTopic-a1", JSON.toJSONString(noticeInfoSend));
+            if (isSend) {
+                MsgRecord msgRecord = new MsgRecord();
+                msgRecord.setCreateBy("admin");
+                msgRecord.setCreateTime(LocalDateTime.now());
+                msgRecord.setReqContent(JSON.toJSONString(noticeInfoSend));
+                msgRecord.setType(MsgRecordTypeEnum.MESSAGE.value());
+                msgRecordService.save(msgRecord);
+            }
+        }
+        return isSend;
+    }
+
+
+    /**
+     * @author huey China.
+     * @Description :
+     * @Date Created in 2023/7/12 16:09
+     */
+    private Set<String> getMessageClientIds(Integer messageType, String scopeId) {
+        //登录人标识
+        Set<String> messageClientIds = Sets.newHashSet();
+        if (StringUtils.isEmpty(scopeId)) {
+            throw new MessageInfoException(MessageInfoErrorEnums.Code.NOTICE_LIMIT_EMPTY);
+        }
+        //查询有当前应用的人
+        Set<String> allUserIds = installInfoService.findUsersByAppId(scopeId);
+        if (CollUtil.isNotEmpty(allUserIds)) {
+            messageClientIds.addAll(allUserIds);
+        }
+
+        return messageClientIds;
+    }
+
+    private boolean validate(NoticeInfoReq noticeInfoReq) {
+
+        String id = noticeInfoReq.getId();
+        Long t = noticeInfoReq.getT();
+        String scopeId = noticeInfoReq.getScopeId();
+        log.info("noticeInfoReq-validate-start-{}", noticeInfoReq.getId());
+        if (noticeSecret) {
+            String correctHash = DigestUtils.md5Hex(id + t);
+            if (!correctHash.equalsIgnoreCase(noticeInfoReq.getK())) {
+                return false;
+            }
+        }
+
+        log.info("noticeInfoReq-validate-end-{}-{}", scopeId, id);
+        return true;
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    public NoticeInfoSend doSaveNoticeInfo(NoticeInfoReq noticeInfoReq, Set<String> messageClientIds) {
+        log.info("doSaveNoticeInfo-start-{}-{}", noticeInfoReq.getId(), messageClientIds);
+        Integer messageType = noticeInfoReq.getMessageType();
+        ScopeEnums scopeEnums = ScopeEnums.ofMessageType(messageType);
+        List<NoticeInfoScope> insertList = Lists.newArrayList();
+        NoticeInfoSend noticeInfoSend = new NoticeInfoSend();
+        noticeInfoSend.setNoticeInfoReq(noticeInfoReq);
+        noticeInfoSend.setClientIds(messageClientIds);
+
+        NoticeInfo noticeInfo = noticeReqConvert.reqToInfo(noticeInfoReq);
+        noticeInfo.setCreateBy(noticeInfoReq.getId());
+        // 存储
+        boolean isSaveBatchSuccess = false;
+        try {
+            isSaveBatchSuccess = this.save(noticeInfo);
+            messageClientIds.forEach(e -> {
+                NoticeInfoScope noticeInfoScope = new NoticeInfoScope();
+                noticeInfoScope.setNoticeInfoId(noticeInfo.getId());
+                noticeInfoScope.setScopeId(noticeInfoReq.getScopeId());
+                noticeInfoScope.setMemberId(e);
+                noticeInfoScope.setScopeType(scopeEnums.value());
+                //messageInfoScope.setScopeLevel("");
+                insertList.add(noticeInfoScope);
+            });
+            isSaveBatchSuccess = noticeInfoScopeService.saveBatch(insertList);
+        } catch (Exception e) {
+            log.warn("消息中心 saveBatch 存储失败 {}");
+        }
+
+        // 批量存储失败,则逐个存储
+        if (!isSaveBatchSuccess) {
+            try {
+                this.save(noticeInfo);
+                insertList.forEach(e -> {
+                    noticeInfoScopeService.save(e);
+                });
+            } catch (Exception e) {
+                log.warn("消息中心 存储失败 {}");
+            }
+        }
+        log.info("doSaveNoticeInfo-end-{}-{}", noticeInfoReq.getId(), messageClientIds);
+        return noticeInfoSend;
+    }
+
+    public static void main(String[] args) {
+        String correctHash = DigestUtils.md5Hex("1" + "333");
+        System.out.println(correctHash);
+    }
+}

+ 0 - 20
src/main/java/com/dragon/tj/portal/service/impl/TestServiceImpl.java

@@ -1,20 +0,0 @@
-package com.dragon.tj.portal.service.impl;
-
-import com.dragon.tj.portal.entity.Test;
-import com.dragon.tj.portal.mapper.TestMapper;
-import com.dragon.tj.portal.service.TestService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.springframework.stereotype.Service;
-
-/**
- * <p>
- *  服务实现类
- * </p>
- *
- * @author huey
- * @since 2023-06-11
- */
-@Service
-public class TestServiceImpl extends ServiceImpl<TestMapper, Test> implements TestService {
-
-}

+ 8 - 1
src/main/resources/application-dev.properties

@@ -7,6 +7,8 @@ mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
 #log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
 
 ###########kafka#############
+#指定哪些appId能发topic,动态变更后,不能自动订阅需重启服务
+kafka.topics=sseTopic-a1,sseTopic-a2
 spring.kafka.bootstrap-servers=149.28.158.127:9092
 spring.kafka.producer.retries=2
 spring.kafka.producer.acks=1
@@ -43,4 +45,9 @@ logging.level.org.apache.kafka=warn
 
 server.port=8082
 
-dragon.file.path=D:/crayon/file/
+dragon.file.path=D:/crayon/file/
+
+
+########notice##########
+message-secret=false
+notice-secret=true

+ 12 - 1
src/main/resources/application-local.properties

@@ -5,6 +5,8 @@ spring.datasource.password=123456
 mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
 #log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl
 ###########kafka#############
+#指定哪些appId能发topic,动态变更后,不能自动订阅需重启服务
+kafka.topics=sseTopic-a1,sseTopic-a2
 spring.kafka.bootstrap-servers=149.28.158.127:9092
 spring.kafka.producer.retries=2
 spring.kafka.producer.acks=1
@@ -30,9 +32,18 @@ cas.target.url=http://localhost:8081/#/?token=
 cas.filter.url=/sso/login
 cas.failure.url=http://localhost:8081/#/401
 
+########## dcuc api ################
+client.dcuc.user.url=http://localhost:8086/dcuc/user/api/
+client.dcuc.auth.url=http://localhost:8086/dcuc/auth/api/
+
+########## path api ################
+dragon.file.path=D:/crayon/file
+
 logging.level.org.springframework.security=trace
 logging.level.org.jasig.cas=trace
 logging.level.org.apache.kafka=warn
 
 server.port=8080
-
+########notice##########
+message-secret=false
+notice-secret=true

+ 24 - 0
src/main/resources/mapper/MessageInfoMapper.xml

@@ -22,5 +22,29 @@
     <sql id="Base_Column_List">
         id, message_type, read_status, title, content, attachment_path, create_by, update_by, create_time, update_time, del_flag, version
     </sql>
+    <select id="queryPage" resultType="com.dragon.tj.portal.entity.MessageInfo">
+        SELECT b.id,member_id,scope_type,scope_id,message_type,read_status,title,content,attachment_path from message_info_scope a
+        LEFT JOIN message_info b on a.message_info_id = b.id
+        where b.del_flag = 0
+        <if test="req.messageType != null">
+            and b.message_type = #{req.messageType}
+        </if>
+        <if test="req.title != null">
+            and b.title = #{req.title}
+        </if>
+        <if test="req.content != null">
+            and b.content = #{req.content}
+        </if>
+        <if test="req.deptCode != null">
+            and a.scope_id = #{req.deptCode}
+        </if>
+        <if test="req.readStatus != null">
+            and a.read_status = #{req.readStatus}
+        </if>
+        <if test="req.publishTimeStart != null and req.publishTimeEnd != null ">
+            and b.create_time >= #{req.publishTimeStart} and b.create_time &lt;= #{req.publishTimeEnd}
+        </if>
+
+    </select>
 
 </mapper>

+ 21 - 0
src/main/resources/mapper/MsgRecordMapper.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.dragon.tj.portal.mapper.MsgRecordMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.dragon.tj.portal.entity.MsgRecord">
+        <id column="id" property="id" />
+        <result column="type" property="type" />
+        <result column="req_content" property="reqContent" />
+        <result column="create_by" property="createBy" />
+        <result column="create_user" property="createUser" />
+        <result column="create_time" property="createTime" />
+        <result column="del_flag" property="delFlag" />
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id, type, req_content, create_by, create_user, create_time, del_flag
+    </sql>
+
+</mapper>

+ 29 - 0
src/main/resources/mapper/NoticeInfoMapper.xml

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.dragon.tj.portal.mapper.NoticeInfoMapper">
+
+
+    <select id="queryPage" resultType="com.dragon.tj.portal.entity.NoticeInfo">
+        SELECT b.id,member_id,scope_type,scope_id,message_type,read_status,title,content,attachment_path from notice_info_scope a
+        LEFT JOIN notice_info b on a.notice_info_id = b.id
+        where b.del_flag = 0
+        <if test="req.messageType != null">
+            and b.message_type = #{req.messageType}
+        </if>
+        <if test="req.title != null">
+            and b.title = #{req.title}
+        </if>
+        <if test="req.content != null">
+            and b.content = #{req.content}
+        </if>
+        <if test="req.deptCode != null">
+            and a.scope_id = #{req.deptCode}
+        </if>
+        <if test="req.readStatus != null">
+            and a.read_status = #{req.readStatus}
+        </if>
+        <if test="req.publishTimeStart != null and req.publishTimeEnd != null ">
+            and b.create_time >= #{req.publishTimeStart} and b.create_time &lt;= #{req.publishTimeEnd}
+        </if>
+    </select>
+</mapper>

+ 19 - 0
src/main/resources/mapper/NoticeInfoScopeMapper.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.dragon.tj.portal.mapper.NoticeInfoScopeMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.dragon.tj.portal.entity.NoticeInfoScope">
+        <id column="id" property="id" />
+        <result column="member_id" property="memberId" />
+        <result column="scope_type" property="scopeType" />
+        <result column="scope_id" property="scopeId" />
+        <result column="scope_level" property="scopeLevel" />
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id, member_id, scope_type, scope_id, scope_level
+    </sql>
+
+</mapper>

+ 0 - 5
src/main/resources/mapper/TestMapper.xml

@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.dragon.tj.portal.mapper.TestMapper">
-
-</mapper>

+ 1 - 1
src/test/java/com/dragon/tj/portal/generate/CodeGeneration.java

@@ -85,6 +85,6 @@ public class CodeGeneration {
 
     public static void main(String[] args) {
 //        Generation("52.76.81.218:3306","portal","portal01!","portal","sys_log","sys_dict_item","sys_dict");
-//        Generation(null,null,null,"portal","message_info","message_info_history","message_info_scope");
+//        Generation(null,null,null,"portal","msg_record","notice_info","notice_info_scope");
     }
 }