소스 검색

feat(notice): notice-base

huey 1 년 전
부모
커밋
904c38dfa6

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

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

+ 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.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>
+ * 信息表 前端控制器
+ * </p>
+ *
+ * @author huey
+ * @since 2023-06-15
+ */
+@RestController
+@RequestMapping("/noticeInfo")
+public class NoticeInfoController {
+
+    @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);
+    }
+
+    /**
+     * 详情
+     */
+    @GetMapping("detail")
+    public R detail(Long id) {
+        MessageInfoVO messageInfoVO = messageInfoService.detail(id);
+        return R.ok(messageInfoVO);
+    }
+
+    /**
+     * 修改
+     */
+    @SysLog("信息更新")
+    @PostMapping("update")
+    public R update(@Validated @RequestBody MessageInfoParam messageInfoParam) {
+        return R.ok(messageInfoService.update(messageInfoParam));
+    }
+
+    /**
+     * 阅读
+     */
+    @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));
+    }
+}
+

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

@@ -32,7 +32,7 @@ public class NoticeInfo implements Serializable {
     private Long id;
 
     /**
-     * 信息类型 1 通知公告 2信息交流 3 标准规范 
+     * 消息类型 4 任务类 5 通知类 6 超期提醒类
      */
     private Integer messageType;
 

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

@@ -1,8 +1,13 @@
 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>
@@ -15,4 +20,5 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface NoticeInfoMapper extends BaseMapper<NoticeInfo> {
 
+    IPage<MessageInfo> queryPage(Page page,@Param("req") MessagePageParam req);
 }

+ 18 - 1
src/main/java/com/dragon/tj/portal/service/NoticeInfoService.java

@@ -1,9 +1,16 @@
 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 com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
 
 /**
  * <p>
@@ -16,4 +23,14 @@ import com.baomidou.mybatisplus.extension.service.IService;
 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);
 }

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

@@ -2,17 +2,27 @@ 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.MessageInfoParam;
+import com.dragon.tj.portal.common.vo.message.MessageInfoVO;
+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.KafkaInitialConfiguration;
 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;
@@ -61,6 +71,9 @@ public class NoticeInfoServiceImpl extends ServiceImpl<NoticeInfoMapper, NoticeI
     @Autowired
     private NoticeReqConvert noticeReqConvert;
 
+    @Autowired
+    private NoticeInfoVOConvert noticeInfoVOConvert;
+
 
     @Override
     public R send(NoticeInfoReq noticeInfoReq) {
@@ -72,6 +85,47 @@ public class NoticeInfoServiceImpl extends ServiceImpl<NoticeInfoMapper, NoticeI
         return R.ok(b);
     }
 
+    @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
@@ -117,6 +171,10 @@ public class NoticeInfoServiceImpl extends ServiceImpl<NoticeInfoMapper, NoticeI
     }
 
     private void validate(NoticeInfoReq noticeInfoReq) {
+
+
+        //TODO 校验一下topic
+
         String id = noticeInfoReq.getId();
         Long t = noticeInfoReq.getT();
         String scopeId = noticeInfoReq.getScopeId();

+ 23 - 22
src/main/resources/mapper/NoticeInfoMapper.xml

@@ -2,27 +2,28 @@
 <!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">
 
-    <!-- 通用查询映射结果 -->
-    <resultMap id="BaseResultMap" type="com.dragon.tj.portal.entity.NoticeInfo">
-        <id column="id" property="id" />
-        <result column="message_type" property="messageType" />
-        <result column="read_status" property="readStatus" />
-        <result column="title" property="title" />
-        <result column="content" property="content" />
-        <result column="attachment_path" property="attachmentPath" />
-        <result column="create_by" property="createBy" />
-        <result column="create_user" property="createUser" />
-        <result column="update_by" property="updateBy" />
-        <result column="update_user" property="updateUser" />
-        <result column="create_time" property="createTime" />
-        <result column="update_time" property="updateTime" />
-        <result column="del_flag" property="delFlag" />
-        <result column="version" property="version" />
-    </resultMap>
-
-    <!-- 通用查询结果列 -->
-    <sql id="Base_Column_List">
-        id, message_type, read_status, title, content, attachment_path, create_by, create_user, update_by, update_user, create_time, update_time, del_flag, version
-    </sql>
 
+    <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>