Parcourir la source

通告添加评论功能

lizhenhao il y a 2 ans
Parent
commit
a4224d202e

+ 22 - 0
jeeplus-module/jeeplus-test/src/main/java/com/jeeplus/test/cw/common/CommonUtils.java

@@ -6,6 +6,7 @@ import com.jeeplus.sys.service.dto.UserDTO;
 import com.jeeplus.sys.utils.UserUtils;
 import com.jeeplus.sys.utils.UserUtils;
 
 
 import java.util.ArrayList;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.List;
 import java.util.List;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
@@ -53,4 +54,25 @@ public class CommonUtils {
         }
         }
         return false;
         return false;
     }
     }
+
+    /**
+     * 计算时间差
+     * 注:参数小于或等于当前时间
+     */
+    public static String timeDef(Date time) {
+        Long def = new Date().getTime() - time.getTime();
+        // 计算天数
+        long day = def / (1000 * 60 * 60 * 24);
+        if (day != 0) {
+            return day + "天前";
+        }
+        // 计算小时
+        long house = def / (1000 * 60 * 60);
+        if (house != 0) {
+            return house + "小时前";
+        }
+        // 计算分钟
+        long min = def / (1000 * 60);
+        return min + "分钟前";
+    }
 }
 }

+ 22 - 0
jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/controller/NotifyController.java

@@ -10,12 +10,14 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Lists;
 import com.jeeplus.common.utils.ResponseUtil;
 import com.jeeplus.common.utils.ResponseUtil;
 import com.jeeplus.core.query.QueryWrapperGenerator;
 import com.jeeplus.core.query.QueryWrapperGenerator;
+import com.jeeplus.notify.domain.PluginNotifyComments;
 import com.jeeplus.notify.service.NotifyService;
 import com.jeeplus.notify.service.NotifyService;
 import com.jeeplus.notify.service.dto.NotifyDTO;
 import com.jeeplus.notify.service.dto.NotifyDTO;
 import com.jeeplus.notify.service.dto.NotifyRecordDTO;
 import com.jeeplus.notify.service.dto.NotifyRecordDTO;
 import com.jeeplus.sys.constant.CommonConstants;
 import com.jeeplus.sys.constant.CommonConstants;
 import com.jeeplus.sys.utils.UserUtils;
 import com.jeeplus.sys.utils.UserUtils;
 import com.jeeplus.test.cw.workClientInfo.service.dto.CwWorkClientBaseDTO;
 import com.jeeplus.test.cw.workClientInfo.service.dto.CwWorkClientBaseDTO;
+import com.jeeplus.test.knowledge.domain.KnowledgeShareComment;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
 import org.springframework.http.ResponseEntity;
@@ -101,4 +103,24 @@ public class NotifyController {
         return ResponseEntity.ok ( "删除通知成功" );
         return ResponseEntity.ok ( "删除通知成功" );
     }
     }
 
 
+    /**
+     * 评论
+     */
+    @PostMapping("/addComment")
+    @ApiOperation(value = "添加评论")
+    public ResponseEntity<String> addComment(@RequestBody PluginNotifyComments comment) {
+        String s = notifyService.addComment(comment);
+        return ResponseEntity.ok(s);
+    }
+
+    /**
+     * 删除评论
+     */
+    @GetMapping("/delComment")
+    @ApiOperation(value = "删除评论")
+    public ResponseEntity<String> delComment(String id) {
+        String s = notifyService.delComment(id);
+        return ResponseEntity.ok(s);
+    }
+
 }
 }

+ 36 - 0
jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/domain/PluginNotifyComments.java

@@ -0,0 +1,36 @@
+package com.jeeplus.notify.domain;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.jeeplus.core.domain.BaseEntity;
+import lombok.Data;
+
+/**
+ * 知识分享评论记录表
+ * @TableName plugin_notify_comments
+ */
+@TableName(value ="plugin_notify_comments")
+@Data
+public class PluginNotifyComments extends BaseEntity {
+
+    /**
+     * 公告id
+     */
+    private String notifyId;
+
+    /**
+     * 评论人id
+     */
+    private String userId;
+
+    /**
+     * 评论
+     */
+    private String comments;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+}

+ 17 - 0
jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/mapper/PluginNotifyCommentsMapper.java

@@ -0,0 +1,17 @@
+package com.jeeplus.notify.mapper;
+
+import com.jeeplus.notify.domain.PluginNotifyComments;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * @Entity com.jeeplus.notify.domain.PluginNotifyComments
+ */
+@Mapper
+public interface PluginNotifyCommentsMapper extends BaseMapper<PluginNotifyComments> {
+
+}
+
+
+
+

+ 21 - 0
jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/mapper/xml/NotifyMapper.xml

@@ -26,6 +26,7 @@
         <collection property="workAttachmentDtoList" ofType="com.jeeplus.test.workContract.service.dto.WorkAttachmentDto" column="id" select="getFileList"></collection>
         <collection property="workAttachmentDtoList" ofType="com.jeeplus.test.workContract.service.dto.WorkAttachmentDto" column="id" select="getFileList"></collection>
         <collection property="pluginNotifyOfficesDTOList" ofType="com.jeeplus.notify.service.dto.PluginNotifyOfficesDTO" column="id" select="getOfficeList"></collection>
         <collection property="pluginNotifyOfficesDTOList" ofType="com.jeeplus.notify.service.dto.PluginNotifyOfficesDTO" column="id" select="getOfficeList"></collection>
         <collection property="pluginNotifyUserDTOList" ofType="com.jeeplus.notify.service.dto.PluginNotifyUserDTO" column="id" select="getUserList"></collection>
         <collection property="pluginNotifyUserDTOList" ofType="com.jeeplus.notify.service.dto.PluginNotifyUserDTO" column="id" select="getUserList"></collection>
+    <collection property="comments" ofType="com.jeeplus.notify.service.dto.PluginNotifyCommentsDTO" column="id" select="getComments"></collection>
     </resultMap>
     </resultMap>
     <resultMap id="AttachmentMap" type="com.jeeplus.test.workContract.service.dto.WorkAttachmentDto">
     <resultMap id="AttachmentMap" type="com.jeeplus.test.workContract.service.dto.WorkAttachmentDto">
         <id property="id" column="id" jdbcType="VARCHAR"/>
         <id property="id" column="id" jdbcType="VARCHAR"/>
@@ -105,6 +106,26 @@
         pno.office_id,
         pno.office_id,
         pno.notify_id
         pno.notify_id
     </sql>
     </sql>
+    <sql id="Comments_Column_List">
+        pnc.id,
+        pnc.create_by as create_id,
+        pnc.create_date,
+        pnc.update_by,
+        pnc.update_date,
+        pnc.notify_id,
+        pnc.user_id,
+        pnc.comments,
+        pnc.del_flag
+    </sql>
+    <select id="getComments" resultType="com.jeeplus.notify.service.dto.PluginNotifyCommentsDTO">
+        select
+        <include refid="Comments_Column_List"></include>,
+        su.name as user_name
+        from plugin_notify_comments pnc
+        left join sys_user su on su.id = pnc.user_id and su.del_flag = '0'
+        where pnc.del_flag = '0' and pnc.notify_id = #{id}
+        order by pnc.create_date desc
+    </select>
     <select id="getOfficeList" resultType="com.jeeplus.notify.service.dto.PluginNotifyOfficesDTO">
     <select id="getOfficeList" resultType="com.jeeplus.notify.service.dto.PluginNotifyOfficesDTO">
         select
         select
         <include refid="Offices_Column_List"></include>,
         <include refid="Offices_Column_List"></include>,

+ 30 - 0
jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/mapper/xml/PluginNotifyCommentsMapper.xml

@@ -0,0 +1,30 @@
+<?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.jeeplus.notify.mapper.PluginNotifyCommentsMapper">
+
+    <resultMap id="BaseResultMap" type="com.jeeplus.notify.service.dto.PluginNotifyCommentsDTO">
+            <id property="id" column="id" jdbcType="VARCHAR"/>
+            <result property="createBy.id" column="create_by" jdbcType="VARCHAR"/>
+            <result property="createDate" column="create_date" jdbcType="TIMESTAMP"/>
+            <result property="updateBy.id" column="update_by" jdbcType="VARCHAR"/>
+            <result property="updateDate" column="update_date" jdbcType="TIMESTAMP"/>
+            <result property="notifyId" column="notify_id" jdbcType="VARCHAR"/>
+            <result property="userId" column="user_id" jdbcType="VARCHAR"/>
+            <result property="comments" column="comments" jdbcType="VARCHAR"/>
+            <result property="delFlag" column="del_flag" jdbcType="INTEGER"/>
+    </resultMap>
+
+    <sql id="Comments_Column_List">
+        pnc.id,
+        pnc.create_by,
+        pnc.create_date,
+        pnc.update_by,
+        pnc.update_date,
+        pnc.notify_id,
+        pnc.user_id,
+        pnc.comments,
+        pnc.del_flag
+    </sql>
+</mapper>

+ 24 - 4
jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/service/NotifyService.java

@@ -10,11 +10,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.jeeplus.notify.domain.Notify;
-import com.jeeplus.notify.domain.NotifyRecord;
-import com.jeeplus.notify.domain.PluginNotifyOffices;
-import com.jeeplus.notify.domain.PluginNotifyUser;
+import com.jeeplus.notify.domain.*;
 import com.jeeplus.notify.mapper.NotifyMapper;
 import com.jeeplus.notify.mapper.NotifyMapper;
+import com.jeeplus.notify.mapper.PluginNotifyCommentsMapper;
 import com.jeeplus.notify.mapper.PluginNotifyOfficesMapper;
 import com.jeeplus.notify.mapper.PluginNotifyOfficesMapper;
 import com.jeeplus.notify.mapper.PluginNotifyUserMapper;
 import com.jeeplus.notify.mapper.PluginNotifyUserMapper;
 import com.jeeplus.notify.service.dto.NotifyDTO;
 import com.jeeplus.notify.service.dto.NotifyDTO;
@@ -24,14 +22,17 @@ import com.jeeplus.notify.service.mapstruct.NotifyWrapper;
 import com.jeeplus.sys.constant.CommonConstants;
 import com.jeeplus.sys.constant.CommonConstants;
 import com.jeeplus.sys.domain.User;
 import com.jeeplus.sys.domain.User;
 import com.jeeplus.sys.mapper.UserMapper;
 import com.jeeplus.sys.mapper.UserMapper;
+import com.jeeplus.sys.service.dto.UserDTO;
 import com.jeeplus.sys.utils.StringUtils;
 import com.jeeplus.sys.utils.StringUtils;
 import com.jeeplus.sys.utils.UserUtils;
 import com.jeeplus.sys.utils.UserUtils;
+import com.jeeplus.test.cw.common.CommonUtils;
 import com.jeeplus.test.cw.workClientInfo.domain.CwWorkClientBase;
 import com.jeeplus.test.cw.workClientInfo.domain.CwWorkClientBase;
 import com.jeeplus.test.cw.workClientInfo.service.dto.CwWorkClientBaseDTO;
 import com.jeeplus.test.cw.workClientInfo.service.dto.CwWorkClientBaseDTO;
 import com.jeeplus.test.cw.workClientInfo.service.mapstruct.CwWorkClientBaseWrapper;
 import com.jeeplus.test.cw.workClientInfo.service.mapstruct.CwWorkClientBaseWrapper;
 import com.jeeplus.test.editor.domain.EditorFiles;
 import com.jeeplus.test.editor.domain.EditorFiles;
 import com.jeeplus.test.editor.service.EditorFilesService;
 import com.jeeplus.test.editor.service.EditorFilesService;
 import com.jeeplus.test.editor.service.dto.EditorFilesDTO;
 import com.jeeplus.test.editor.service.dto.EditorFilesDTO;
+import com.jeeplus.test.knowledge.domain.KnowledgeShareComment;
 import com.jeeplus.test.oss.service.OssService;
 import com.jeeplus.test.oss.service.OssService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.ResponseEntity;
 import org.springframework.http.ResponseEntity;
@@ -42,6 +43,7 @@ import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.Date;
 import java.util.List;
 import java.util.List;
+import java.util.UUID;
 import java.util.stream.Collectors;
 import java.util.stream.Collectors;
 
 
 /**
 /**
@@ -72,6 +74,9 @@ public class NotifyService extends ServiceImpl <NotifyMapper, Notify> {
     @Resource
     @Resource
     private UserMapper userMapper;
     private UserMapper userMapper;
 
 
+    @Resource
+    private PluginNotifyCommentsMapper commentsMapper;
+
     /**
     /**
      * 根据id获取通知
      * 根据id获取通知
      */
      */
@@ -119,6 +124,11 @@ public class NotifyService extends ServiceImpl <NotifyMapper, Notify> {
                 });
                 });
                 notifyDTO.setEditorFilesDTOList(editorFilesDTOList);
                 notifyDTO.setEditorFilesDTOList(editorFilesDTOList);
             }
             }
+            if (CollectionUtil.isNotEmpty(notifyDTO.getComments())){
+                notifyDTO.getComments().stream().forEach(item -> {
+                    item.setDeff(CommonUtils.timeDef(item.getCreateDate()));
+                });
+            }
             return notifyDTO;
             return notifyDTO;
         } else {
         } else {
             return new NotifyDTO();
             return new NotifyDTO();
@@ -253,4 +263,14 @@ public class NotifyService extends ServiceImpl <NotifyMapper, Notify> {
                 .eq ( NotifyRecord::getUserId, UserUtils.getCurrentUserDTO ( ).getId ( ) ).ne ( NotifyRecord::getReadFlag, CommonConstants.YES )
                 .eq ( NotifyRecord::getUserId, UserUtils.getCurrentUserDTO ( ).getId ( ) ).ne ( NotifyRecord::getReadFlag, CommonConstants.YES )
                 .set ( NotifyRecord::getReadDate, new Date ( ) ).set ( NotifyRecord::getReadFlag, CommonConstants.YES ).update ( );
                 .set ( NotifyRecord::getReadDate, new Date ( ) ).set ( NotifyRecord::getReadFlag, CommonConstants.YES ).update ( );
     }
     }
+
+    public String addComment(PluginNotifyComments comment) {
+        commentsMapper.insert(comment);
+        return "操作完成";
+    }
+
+    public String delComment(String id) {
+        commentsMapper.deleteById(id);
+        return "操作完成";
+    }
 }
 }

+ 4 - 0
jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/service/dto/NotifyDTO.java

@@ -126,6 +126,10 @@ public class NotifyDTO extends BaseDTO {
 
 
     private List<NotifyRecordDTO> notifyRecordDTOList = Lists.newArrayList();
     private List<NotifyRecordDTO> notifyRecordDTOList = Lists.newArrayList();
 
 
+    /**
+     * 评论
+     */
+    private List<PluginNotifyCommentsDTO> comments;
 
 
     /**
     /**
      * 获取通知发送记录用户ID
      * 获取通知发送记录用户ID

+ 48 - 0
jeeplus-plugins/jeeplus-notify/src/main/java/com/jeeplus/notify/service/dto/PluginNotifyCommentsDTO.java

@@ -0,0 +1,48 @@
+package com.jeeplus.notify.service.dto;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.jeeplus.core.domain.BaseEntity;
+import com.jeeplus.core.service.dto.BaseDTO;
+import lombok.Data;
+
+/**
+ * 知识分享评论记录表
+ * @TableName plugin_notify_comments
+ */
+@Data
+public class PluginNotifyCommentsDTO extends BaseDTO {
+
+    /**
+     * 公告id
+     */
+    private String notifyId;
+
+    /**
+     * 评论人id
+     */
+    private String userId;
+
+    /**
+     * 评论人
+     */
+    private String userName;
+
+    /**
+     * 评论
+     */
+    private String comments;
+
+    /**
+     * 评论距离当前时间
+     */
+    private String Deff;
+
+    /**
+     * 创建人id
+     */
+    private String createId;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+}