chenguangyu 1 рік тому
батько
коміт
8d87c9819f

+ 7 - 1
cx-knowledge-base/cx-knowledge-base-common/pom.xml

@@ -63,6 +63,12 @@
             <artifactId>easyexcel</artifactId>
             <version>3.3.2</version>
         </dependency>
+        <dependency>
+            <groupId>com.rongwei</groupId>
+            <artifactId>bs-common</artifactId>
+            <version>1.0-SNAPSHOT</version>
+            <scope>compile</scope>
+        </dependency>
 
     </dependencies>
-</project>
+</project>

+ 27 - 0
cx-knowledge-base/cx-knowledge-base-common/src/main/java/com/rongwei/bscommon/sys/dao/KnowledgebaseCommentsDao.java

@@ -0,0 +1,27 @@
+package com.rongwei.bscommon.sys.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.rongwei.bsentity.domain.KnowledgebaseCommentsDo;
+import com.rongwei.bsentity.enums.KnowledgeInfo;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.springframework.stereotype.Repository;
+
+/**
+ * @author chenguangyu
+ * @version 1.0
+ * @email chenguangyu@irongwei.com
+ * @date 2024/01/11 11:12
+ */
+@Repository
+public interface KnowledgebaseCommentsDao extends BaseMapper<KnowledgebaseCommentsDo> {
+
+    @Select("SELECT CODE FROM sys_user WHERE DELETED = 0 AND ID = #{id}")
+    String QueryJobNumber(@Param("id") String commenterid);
+
+
+    @Select("SELECT AUTHORID,TITLE FROM kb_knowledge_ledger WHERE DELETED = 0 AND ID = #{id}")
+    KnowledgeInfo knowledgeInfo(@Param("id") String commenterid);
+
+
+}

+ 19 - 0
cx-knowledge-base/cx-knowledge-base-common/src/main/java/com/rongwei/bscommon/sys/service/KnowledgebaseCommentsService.java

@@ -0,0 +1,19 @@
+package com.rongwei.bscommon.sys.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.rongwei.bsentity.domain.KnowledgebaseCommentsDo;
+import com.rongwei.rwcommon.base.R;
+import org.springframework.stereotype.Service;
+
+
+import java.util.Map;
+/**
+ *
+ * @author cgy
+ * @since 2024-01-11
+ */
+@Service
+public interface KnowledgebaseCommentsService extends IService<KnowledgebaseCommentsDo> {
+
+    R KnowledgebaseCommentsSave(Map<String,Object> objectMap);
+}

+ 70 - 0
cx-knowledge-base/cx-knowledge-base-common/src/main/java/com/rongwei/bscommon/sys/service/impl/KnowledgebaseCommentsServiceImpl.java

@@ -0,0 +1,70 @@
+package com.rongwei.bscommon.sys.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.rongwei.bscommon.sys.dao.KnowledgebaseCommentsDao;
+import com.rongwei.bscommon.sys.service.KnowledgebaseCommentsService;
+import com.rongwei.bsentity.domain.KnowledgebaseCommentsDo;
+import com.rongwei.bsentity.enums.KnowledgeInfo;
+import com.rongwei.rwcommon.base.R;
+import com.rongwei.rwcommon.utils.SecurityUtil;
+import com.rongwei.safecommon.utils.CXCommonUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author ChenGuangYu
+ * @version 1.0
+ * @email chenguangyu@irongwei.com
+ * @date 2024/1/11 09:16
+ */
+@Service
+public class KnowledgebaseCommentsServiceImpl extends ServiceImpl<KnowledgebaseCommentsDao, KnowledgebaseCommentsDo> implements KnowledgebaseCommentsService {
+
+    @Autowired
+    private KnowledgebaseCommentsDao knowledgebaseCommentsDao;
+
+    @Autowired
+    private KnowledgebaseCommentsService knowledgebaseCommentsService;
+
+    public static final String NOTIFICATION_TITLE = "您收到一条【%s】新点评";
+
+
+    @Override
+    public R KnowledgebaseCommentsSave(Map<String, Object> objectMap) {
+
+
+        String commentid = (String) objectMap.get("COMMENTID");//评论数据 id
+        String commentcontent = (String) objectMap.get("COMMENTCONTENT");//评论内容
+        String commenterid = (String) objectMap.get("COMMENTERID");//评论人id
+        String commenteremployeeid = knowledgebaseCommentsDao.QueryJobNumber(commenterid);//获取评论人工号
+
+        KnowledgeInfo knowledgeInfo = knowledgebaseCommentsDao.knowledgeInfo(commentid);
+        String authorid = knowledgeInfo.getAuthorid();//获取作者
+        String title = knowledgeInfo.getTitle();//获取数据标题
+        String authornotification = (String) objectMap.get("AUTHORNOTIFICATION");//作者通知状态
+
+        KnowledgebaseCommentsDo knowCommentInfo = new KnowledgebaseCommentsDo();
+        knowCommentInfo.setId(SecurityUtil.getUUID());
+        knowCommentInfo.setCommentid(commentid);
+        knowCommentInfo.setCommentauthor(authorid);
+        knowCommentInfo.setCommentcontent(commentcontent);
+        knowCommentInfo.setCommenterid(commenterid);
+        knowCommentInfo.setCommenteremployeeid(commenteremployeeid);
+        Date currentDate = new Date();
+        knowCommentInfo.setCreatedate(currentDate);
+        knowCommentInfo.setCreateuserid(commenterid);
+        knowledgebaseCommentsService.save(knowCommentInfo);
+        if ("y".equals(authornotification)) {//系统消息通知作者
+            List<String> personnelIdList = new ArrayList<>();
+            personnelIdList.add(authorid);
+            CXCommonUtils.sendNotify(String.format(NOTIFICATION_TITLE,title),commentcontent,
+                    "", personnelIdList, "", "knowledgebase");
+        }
+        return R.ok();
+    }
+}

+ 125 - 0
cx-knowledge-base/cx-knowledge-base-entity/src/main/java/com/rongwei/bsentity/domain/KnowledgebaseCommentsDo.java

@@ -0,0 +1,125 @@
+package com.rongwei.bsentity.domain;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.rongwei.rwcommon.base.BaseDo;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+import java.util.Date;
+
+/**
+ * @author CGY
+ * @version 知识库评论
+ * @email chenguangyu@irongwei.com
+ * @date 2024/1/09 11:48
+ * @TableName kb_knowledgebase_comments
+ */
+@Data
+@TableName(value = "kb_knowledgebase_comments")
+public class KnowledgebaseCommentsDo extends BaseDo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键ID
+     */
+    @TableId("ID")
+    private String id;
+
+    /**
+     * 租户ID
+     */
+    @TableField("TENANTID")
+    private String tenantid;
+
+    /**
+     * 扩展json格式配置
+     */
+    @TableField("ROPTION")
+    private String roption;
+
+    /**
+     * 是否删除Y/N
+     */
+    @TableField("DELETED")
+    private String deleted;
+
+    /**
+     * 备注
+     */
+    @TableField("REMARK")
+    private String remark;
+
+    /**
+     * 创建时间
+     */
+    @TableField("CREATEDATE")
+    private Date createdate;
+
+    /**
+     * 创建用户ID
+     */
+    @TableField("CREATEUSERID")
+    private String createuserid;
+
+    /**
+     * 修改日期
+     */
+    @TableField("MODIFYDATE")
+    private Date modifydate;
+
+    /**
+     * 修改用户ID
+     */
+    @TableField("MODIFYUSERID")
+    private String modifyuserid;
+
+    /**
+     * 创建人
+     */
+    @TableField("CREATEUSERNAME")
+    private String createusername;
+
+    /**
+     * 修改人
+     */
+    @TableField("MODIFYUSERNAME")
+    private String modifyusername;
+
+    /**
+     * 评论表名
+     */
+    @TableField("COMMENT")
+    private String comment;
+    /**
+     * 评论数据 ID
+     */
+    @TableField("COMMENTID")
+    private String commentid;
+
+    /**
+     * 评论数据中作者字段
+     */
+    @TableField("COMMENTAUTHOR")
+    private String commentauthor;
+
+    /**
+     * 评论内容
+     */
+    @TableField("COMMENTCONTENT")
+    private String commentcontent;
+
+    /**
+     * 评论人ID
+     */
+    @TableField("COMMENTERID")
+    private String commenterid;
+
+    /**
+     * 评论人工号
+     */
+    @TableField("COMMENTEREMPLOYEEID")
+    private String commenteremployeeid;
+}

+ 30 - 0
cx-knowledge-base/cx-knowledge-base-entity/src/main/java/com/rongwei/bsentity/enums/KnowledgeInfo.java

@@ -0,0 +1,30 @@
+package com.rongwei.bsentity.enums;
+/**
+ * @author ChenGuangYu
+ * @version 1.0
+ * @email chenguangyu@irongwei.com
+ * @date 2024/1/11 15:08
+ */
+public class KnowledgeInfo {
+    private String authorid;
+
+    private String title;
+
+    // getter and setter
+    public String getAuthorid() {
+        return authorid;
+    }
+
+    public void setAuthorid(String authorid) {
+        this.authorid = authorid;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+}

+ 46 - 0
cx-knowledge-base/cx-knowledge-base-server/src/main/java/com/rongwei/bsserver/sys/controller/KnowledgeViewController.java

@@ -0,0 +1,46 @@
+package com.rongwei.bsserver.sys.controller;
+
+import com.rongwei.bscommon.sys.service.KnowledgebaseCommentsService;
+import com.rongwei.rwcommon.base.R;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+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;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author ChenGuangYu
+ * @version 1.0
+ * @email chenguangyu@irongwei.com
+ * @date 2024/1/9 11:24
+ * @description 知识库查看前端接口
+ */
+@RestController
+@RequestMapping("/KnowledgeView")
+public class KnowledgeViewController {
+    @Autowired
+    private KnowledgebaseCommentsService knowledgebaseCommentsService;
+    private final Logger log = LoggerFactory.getLogger(this.getClass().getName());
+
+    /**
+     * 知识库查看 详情页评论
+     */
+    @PostMapping("/commentSave")
+    public R purOrderWarehouse(@RequestBody Map<String,Object> objectMap){
+        try{
+            knowledgebaseCommentsService.KnowledgebaseCommentsSave(objectMap);
+        }catch (Exception e){
+            e.printStackTrace();
+            log.error("评论保存异常",e);
+            return R.error("评论保存异常");
+        }
+        return R.ok();
+    }
+
+
+}