sangwenwei vor 6 Monaten
Ursprung
Commit
1f69c99d6f
24 geänderte Dateien mit 1399 neuen und 0 gelöschten Zeilen
  1. 38 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/editor/domain/EditorFiles.java
  2. 18 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/editor/mapper/EditorFilesMapper.java
  3. 32 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/editor/mapper/xml/EditorFilesMapper.xml
  4. 107 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/editor/service/EditorFilesService.java
  5. 35 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/editor/service/dto/EditorFilesDTO.java
  6. 17 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/editor/service/mapstruct/EditorFilesWrapper.java
  7. 96 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/controller/KnowledgeShareInfoController.java
  8. 78 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/controller/TypeController.java
  9. 33 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/domain/KnowledgeShareComment.java
  10. 37 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/domain/KnowledgeShareDetail.java
  11. 37 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/domain/KnowledgeShareType.java
  12. 45 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/domain/KnowledgeShareVisit.java
  13. 8 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/mapper/KnowledgeShareCommentMapper.java
  14. 21 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/mapper/KnowledgeShareDetailMapper.java
  15. 22 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/mapper/KnowledgeShareTypeMapper.java
  16. 12 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/mapper/KnowledgeShareVisitMapper.java
  17. 49 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/mapper/xml/KnowledgeShareDetailMapper.xml
  18. 52 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/mapper/xml/KnowledgeShareTypeMapper.xml
  19. 16 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/mapper/xml/KnowledgeShareVisitMapper.xml
  20. 355 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/service/KnowledgeShareInfoService.java
  21. 74 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/service/KnowledgeTypeService.java
  22. 93 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/service/dto/KnowledgeShareInfoDto.java
  23. 67 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/service/dto/KnowledgeShareListDto.java
  24. 57 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/service/dto/KnowledgeShareTypeDto.java

+ 38 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/editor/domain/EditorFiles.java

@@ -0,0 +1,38 @@
+package com.jeeplus.pubmodules.editor.domain;
+
+
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.jeeplus.core.domain.BaseEntity;
+import lombok.Data;
+
+/**
+ * 富文本图片表
+ * @TableName editor_files
+ */
+@Data
+@TableName("editor_files")
+public class EditorFiles extends BaseEntity {
+
+    /**
+     * 备注信息
+     */
+    private String remarks;
+
+    /**
+     * 来源id
+     */
+    private String sourceId;
+
+    /**
+     * 临时地址
+     */
+    private String temporaryUrl;
+
+    /**
+     * 图片路径
+     */
+    private String url;
+
+    private static final long serialVersionUID = 1L;
+}

+ 18 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/editor/mapper/EditorFilesMapper.java

@@ -0,0 +1,18 @@
+package com.jeeplus.pubmodules.editor.mapper;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.jeeplus.pubmodules.editor.domain.EditorFiles;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * @Entity com.jeeplus.test.editor.domain.EditorFiles
+ */
+@Mapper
+public interface EditorFilesMapper extends BaseMapper<EditorFiles> {
+
+}
+
+
+
+

+ 32 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/editor/mapper/xml/EditorFilesMapper.xml

@@ -0,0 +1,32 @@
+<?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.pubmodules.editor.mapper.EditorFilesMapper">
+
+    <resultMap id="BaseResultMap" type="com.jeeplus.pubmodules.editor.service.dto.EditorFilesDTO">
+            <id property="id" column="id" jdbcType="VARCHAR"/>
+            <result property="createBy.id" column="create_by" jdbcType="VARCHAR"/>
+            <result property="createTime" column="create_date" jdbcType="TIMESTAMP"/>
+            <result property="updateBy.id" column="update_by" jdbcType="VARCHAR"/>
+            <result property="updateTime" column="update_date" jdbcType="TIMESTAMP"/>
+            <result property="delFlag" column="del_flag" jdbcType="INTEGER"/>
+            <result property="remarks" column="remarks" jdbcType="VARCHAR"/>
+            <result property="sourceId" column="source_id" jdbcType="VARCHAR"/>
+            <result property="temporaryUrl" column="temporary_url" jdbcType="VARCHAR"/>
+            <result property="url" column="url" jdbcType="VARCHAR"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        ef.id,
+        ef.create_by,
+        ef.create_time,
+        ef.update_by,
+        ef.update_time,
+        ef.del_flag,
+        ef.remarks,
+        ef.source_id,
+        ef.temporary_url,
+        ef.url
+    </sql>
+</mapper>

+ 107 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/editor/service/EditorFilesService.java

@@ -0,0 +1,107 @@
+package com.jeeplus.pubmodules.editor.service;
+
+
+import com.aliyun.oss.OSSClient;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+import com.jeeplus.pubmodules.editor.domain.EditorFiles;
+import com.jeeplus.pubmodules.editor.mapper.EditorFilesMapper;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicReference;
+
+@Service
+@Transactional
+public class EditorFilesService extends ServiceImpl<EditorFilesMapper, EditorFiles> {
+
+
+
+    @Resource
+    private EditorFilesMapper editorFilesMapper;
+
+    /**
+     * 将富文本内容中的临时图片地址替换为新的
+     * @param content 富文本内容
+     * @param sourceId 数据id
+     * @return
+     */
+    public String getNewContent(String content,String sourceId){
+        List<EditorFiles> list = this.list(new QueryWrapper<EditorFiles>().lambda().eq(EditorFiles::getSourceId, sourceId));
+        AtomicReference<String> replace = new AtomicReference<>(content.replace("amp;", ""));
+        list.stream().forEach(item->{
+            boolean contains = replace.get().contains(item.getTemporaryUrl());
+            if(contains){
+                String fileTemporaryLookUrl = this.getFileTemporaryLookUrl(item.getUrl());
+                String r = replace.get().replace(item.getTemporaryUrl(),fileTemporaryLookUrl);
+                replace.set(r);
+                EditorFiles editorFiles = new EditorFiles();
+                editorFiles.setTemporaryUrl(fileTemporaryLookUrl);
+                editorFiles.setSourceId(sourceId);
+                this.update(editorFiles,new QueryWrapper<EditorFiles>().lambda().eq(EditorFiles::getSourceId,sourceId).eq(EditorFiles::getTemporaryUrl,item.getTemporaryUrl()));
+            }
+        });
+        return replace.get();
+    }
+
+    /**
+     * 富文本图片新增
+     * @param temporaryUrl
+     * @param url
+     * @param sourceId
+     * @return
+     */
+    public void saveUrl(String temporaryUrl,String url,String sourceId){
+        EditorFiles editorFiles = new EditorFiles();
+        editorFiles.setSourceId(sourceId);
+        editorFiles.setTemporaryUrl(temporaryUrl);
+        editorFiles.setUrl(url);
+        this.save(editorFiles);
+    }
+
+
+    @Value("${config.accessory.aliyun.aliyunUrl}")
+    private String aliyunUrl;
+    @Value("${config.accessory.aliyun.aliyunDownloadUrl}")
+    private String aliyunDownloadUrl;
+    @Value("${config.accessory.aliyun.endpoint}")
+    private String endpoint;
+    @Value("${config.accessory.aliyun.accessKeyId}")
+    private String accessKeyId;
+    @Value("${config.accessory.aliyun.accessKeySecret}")
+    private String accessKeySecret;
+    @Value("${config.accessory.aliyun.bucketName}")
+    private String bucketName;
+    /**
+     * 阿里云获取临时文件查看url
+     * @param url
+     */
+    public String getFileTemporaryLookUrl(String url){
+        url = url.replace("amp;","");
+        String cons = "";
+        if (url.contains(aliyunUrl)){
+            cons = aliyunUrl;
+        }else if (url.contains("http://gangwan-app.oss-cn-hangzhou.aliyuncs.com")){
+            cons = "http://gangwan-app.oss-cn-hangzhou.aliyuncs.com";
+        }else {
+            cons = aliyunDownloadUrl;
+        }
+        String key = "";
+        String[] split = url.split(cons + "/");
+        if(split.length>1){
+            key = split[1];
+        }else{
+            key = url;
+        }
+        // 指定过期时间为24小时。
+        Date expiration = new Date(new Date().getTime() + 1000 * 60 * 60 * 24 );
+        //初始化OSSClient
+        OSSClient ossClient = new OSSClient(endpoint,accessKeyId,accessKeySecret);
+        return ossClient.generatePresignedUrl(bucketName, key, expiration).toString();
+    }
+}

+ 35 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/editor/service/dto/EditorFilesDTO.java

@@ -0,0 +1,35 @@
+package com.jeeplus.pubmodules.editor.service.dto;
+
+
+import com.jeeplus.core.service.dto.BaseDTO;
+import lombok.Data;
+
+/**
+ * 富文本图片表
+ * @TableName editor_files
+ */
+@Data
+public class EditorFilesDTO extends BaseDTO {
+
+    /**
+     * 备注信息
+     */
+    private String remarks;
+
+    /**
+     * 来源id
+     */
+    private String sourceId;
+
+    /**
+     * 临时地址
+     */
+    private String temporaryUrl;
+
+    /**
+     * 图片路径
+     */
+    private String url;
+
+    private static final long serialVersionUID = 1L;
+}

+ 17 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/editor/service/mapstruct/EditorFilesWrapper.java

@@ -0,0 +1,17 @@
+package com.jeeplus.pubmodules.editor.service.mapstruct;
+
+
+
+import com.jeeplus.core.mapstruct.EntityWrapper;
+import com.jeeplus.pubmodules.editor.domain.EditorFiles;
+import com.jeeplus.pubmodules.editor.service.dto.EditorFilesDTO;
+import org.mapstruct.Mapper;
+import org.mapstruct.ReportingPolicy;
+import org.mapstruct.factory.Mappers;
+
+@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE, uses = {})
+public interface EditorFilesWrapper extends EntityWrapper<EditorFilesDTO, EditorFiles> {
+
+    EditorFilesWrapper INSTANCE = Mappers.getMapper(EditorFilesWrapper.class);
+
+}

+ 96 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/controller/KnowledgeShareInfoController.java

@@ -0,0 +1,96 @@
+package com.jeeplus.pubmodules.knowledge.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.jeeplus.pubmodules.knowledge.domain.KnowledgeShareComment;
+import com.jeeplus.pubmodules.knowledge.domain.KnowledgeShareDetail;
+import com.jeeplus.pubmodules.knowledge.service.KnowledgeShareInfoService;
+import com.jeeplus.pubmodules.knowledge.service.dto.KnowledgeShareInfoDto;
+import com.jeeplus.pubmodules.knowledge.service.dto.KnowledgeShareListDto;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@RestController
+@Api("/知识分享")
+@RequestMapping(value = "/knowledgeShare/info")
+public class KnowledgeShareInfoController {
+
+    @Resource
+    private KnowledgeShareInfoService service;
+
+    /**
+     * 列表
+     */
+    @GetMapping("list")
+    @ApiOperation(value = "列表")
+    public ResponseEntity<IPage<KnowledgeShareListDto>> list(Page<KnowledgeShareListDto> page, KnowledgeShareDetail detail) {
+        IPage<KnowledgeShareListDto> iPage = service.list(page, detail);
+        return ResponseEntity.ok(iPage);
+    }
+
+    /**
+     * 新增/修改
+     */
+    @PostMapping("save")
+    @ApiOperation(value = "新增/修改")
+    public ResponseEntity<String> save(@RequestBody KnowledgeShareInfoDto dto) {
+        String s = service.save(dto);
+        return ResponseEntity.ok(s);
+    }
+
+    /**
+     * 查看
+     */
+    @GetMapping("/findById")
+    @ApiOperation(value = "查看")
+    public ResponseEntity<KnowledgeShareInfoDto> findById(String id, String method,Integer size) {
+        KnowledgeShareInfoDto dto = service.findById(id, method,size);
+        return ResponseEntity.ok(dto);
+    }
+
+    /**
+     * 删除知识分享
+     */
+    @GetMapping("/removeById")
+    @ApiOperation(value = "删除")
+    public ResponseEntity<String> removeById(String id) {
+        String s = service.removeById(id);
+        return ResponseEntity.ok(s);
+    }
+
+    /**
+     * 评论
+     */
+    @PostMapping("/addComment")
+    @ApiOperation(value = "添加评论")
+    public ResponseEntity<String> addComment(@RequestBody KnowledgeShareComment comment) {
+        String s = service.addComment(comment);
+        return ResponseEntity.ok(s);
+    }
+
+    /**
+     * 删除评论
+     */
+    @GetMapping("/delComment")
+    @ApiOperation(value = "删除评论")
+    public ResponseEntity<String> delComment(String id) {
+        String s = service.delComment(id);
+        return ResponseEntity.ok(s);
+    }
+
+    /**
+     * 查询评论
+     */
+    @GetMapping("/getComments")
+    @ApiOperation(value = "查询评论")
+    public ResponseEntity<KnowledgeShareInfoDto> getComments(String id){
+        KnowledgeShareInfoDto list=service.getComments(id);
+        return ResponseEntity.ok(list);
+    }
+
+}

+ 78 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/controller/TypeController.java

@@ -0,0 +1,78 @@
+package com.jeeplus.pubmodules.knowledge.controller;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.jeeplus.pubmodules.knowledge.domain.KnowledgeShareType;
+import com.jeeplus.pubmodules.knowledge.mapper.KnowledgeShareTypeMapper;
+import com.jeeplus.pubmodules.knowledge.service.KnowledgeTypeService;
+import com.jeeplus.pubmodules.knowledge.service.dto.KnowledgeShareTypeDto;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+
+@RestController
+@Api("/知识分享类型")
+@RequestMapping(value = "/knowledgeShare/type")
+public class TypeController {
+
+    @Resource
+    private KnowledgeTypeService service;
+
+    @Resource
+    private KnowledgeShareTypeMapper mapper;
+
+    /**
+     * 列表查询
+     * @param type
+     * @return
+     */
+    @ApiOperation(value = "列表")
+    @GetMapping("/list")
+    public ResponseEntity<IPage<KnowledgeShareTypeDto>> list(Page<KnowledgeShareTypeDto> page, KnowledgeShareType type) {
+        return ResponseEntity.ok(service.list(page, type));
+    }
+
+    /**
+     * 新增/修改
+     * @param type
+     * @return
+     */
+    @ApiOperation(value = "新增/修改")
+    @PostMapping("/save")
+    public ResponseEntity<String> save(@RequestBody KnowledgeShareType type) {
+        Boolean b = service.save(type);
+        if (b) {
+            return ResponseEntity.ok("操作成功");
+        } else {
+            return ResponseEntity.badRequest().body("该类型已存在,请重新输入");
+        }
+    }
+
+    /**
+     * 根据id查询
+     * @param id
+     * @return
+     */
+    @ApiOperation(value = "根据id查询")
+    @GetMapping("/findById")
+    public ResponseEntity<KnowledgeShareType> findById(String id) {
+        KnowledgeShareType knowledgeShareType = mapper.selectById(id);
+        return ResponseEntity.ok(knowledgeShareType);
+    }
+
+    /**
+     * 根据id删除
+     * @param id
+     * @return
+     */
+    @ApiOperation(value = "根据id删除")
+    @GetMapping("/remove")
+    public ResponseEntity<String> remove(String id) {
+        mapper.deleteById(id);
+        return ResponseEntity.ok("操作完成");
+    }
+
+}

+ 33 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/domain/KnowledgeShareComment.java

@@ -0,0 +1,33 @@
+package com.jeeplus.pubmodules.knowledge.domain;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.jeeplus.core.domain.BaseEntity;
+import lombok.Data;
+
+@Data
+@TableName(value = "knowledge_share_comment")
+public class KnowledgeShareComment extends BaseEntity {
+
+    /**
+     * 知识分享详情id
+     */
+    private String detailId;
+
+    /**
+     * 评论人id
+     */
+    private String userId;
+
+    /**
+     * 内容
+     */
+    private String content;
+
+    /**
+     * 时间差
+     */
+    @TableField(exist = false)
+    private String deff;
+
+}

+ 37 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/domain/KnowledgeShareDetail.java

@@ -0,0 +1,37 @@
+package com.jeeplus.pubmodules.knowledge.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.jeeplus.core.domain.BaseEntity;
+import lombok.Data;
+
+@Data
+@TableName(value = "knowledge_share_detail")
+public class KnowledgeShareDetail extends BaseEntity {
+
+    /**
+     * 知识分享类型id
+     */
+    private String typeId;
+
+    /**
+     * 主题
+     */
+    private String title;
+
+    /**
+     * 内容
+     */
+    private String detail;
+
+    /**
+     * 部门id
+     */
+    private String officeId;
+
+
+    /*8
+    公司id
+     */
+    private String companyId;
+
+}

+ 37 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/domain/KnowledgeShareType.java

@@ -0,0 +1,37 @@
+package com.jeeplus.pubmodules.knowledge.domain;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.jeeplus.core.domain.BaseEntity;
+import lombok.Data;
+
+@Data
+@TableName("knowledge_share_type")
+public class KnowledgeShareType extends BaseEntity {
+
+    /**
+     * 分享类型key值
+     */
+    private String klgsKey;
+
+    /**
+     * 分享类型
+     */
+    private String klgsType;
+
+    /**
+     * 排序
+     */
+    private Integer klgsSort;
+
+    /**
+     * 部门id
+     */
+    private String officeId;
+
+
+    /*8
+    公司id
+     */
+    private String companyId;
+
+}

+ 45 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/domain/KnowledgeShareVisit.java

@@ -0,0 +1,45 @@
+package com.jeeplus.pubmodules.knowledge.domain;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.jeeplus.core.domain.BaseEntity;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+@TableName(value = "knowledge_share_visit")
+public class KnowledgeShareVisit extends BaseEntity {
+
+    /**
+     * 知识分享详情id
+     */
+    private String detailId;
+
+    /**
+     * 访问人id
+     */
+    private String userId;
+
+    /**
+     * 初次访问时间
+     */
+    private Date firstTime;
+
+    /**
+     * 最近访问时间
+     */
+    private Date lastTime;
+
+    /**
+     * 访问次数
+     */
+    private Integer num;
+
+    /**
+     * 访问人
+     */
+    @TableField(exist = false)
+    private String userName;
+
+}

+ 8 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/mapper/KnowledgeShareCommentMapper.java

@@ -0,0 +1,8 @@
+package com.jeeplus.pubmodules.knowledge.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.jeeplus.pubmodules.knowledge.domain.KnowledgeShareComment;
+
+
+public interface KnowledgeShareCommentMapper extends BaseMapper<KnowledgeShareComment> {
+}

+ 21 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/mapper/KnowledgeShareDetailMapper.java

@@ -0,0 +1,21 @@
+package com.jeeplus.pubmodules.knowledge.mapper;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Constants;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.jeeplus.pubmodules.knowledge.domain.KnowledgeShareDetail;
+import com.jeeplus.pubmodules.knowledge.service.dto.KnowledgeShareListDto;
+import com.jeeplus.sys.service.dto.WorkAttachmentInfoDTO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+
+public interface KnowledgeShareDetailMapper extends BaseMapper<KnowledgeShareDetail> {
+
+    IPage<KnowledgeShareListDto> findList(Page<KnowledgeShareListDto> page, @Param(Constants.WRAPPER) QueryWrapper queryWrapper, @Param("detail") KnowledgeShareDetail detail);
+
+    List<WorkAttachmentInfoDTO> findDtos(@Param("id")String id);
+}

+ 22 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/mapper/KnowledgeShareTypeMapper.java

@@ -0,0 +1,22 @@
+package com.jeeplus.pubmodules.knowledge.mapper;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Constants;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+
+
+import com.jeeplus.pubmodules.knowledge.domain.KnowledgeShareType;
+import com.jeeplus.pubmodules.knowledge.service.dto.KnowledgeShareTypeDto;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+public interface KnowledgeShareTypeMapper extends BaseMapper<KnowledgeShareType> {
+
+    IPage<KnowledgeShareTypeDto> findList(Page<KnowledgeShareTypeDto> page, @Param(Constants.WRAPPER) QueryWrapper queryWrapper, @Param("type") String type);
+
+    List<KnowledgeShareType> checkList(@Param("type")KnowledgeShareType type);
+
+}

+ 12 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/mapper/KnowledgeShareVisitMapper.java

@@ -0,0 +1,12 @@
+package com.jeeplus.pubmodules.knowledge.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.jeeplus.pubmodules.knowledge.domain.KnowledgeShareVisit;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+
+public interface KnowledgeShareVisitMapper extends BaseMapper<KnowledgeShareVisit> {
+    List<KnowledgeShareVisit> selectByDetailId(@Param("size") Integer size, @Param("id") String id);
+}

+ 49 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/mapper/xml/KnowledgeShareDetailMapper.xml

@@ -0,0 +1,49 @@
+<?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.pubmodules.knowledge.mapper.KnowledgeShareDetailMapper">
+
+	<select id="findList" resultType="com.jeeplus.pubmodules.knowledge.service.dto.KnowledgeShareListDto">
+		SELECT
+			a.id,
+			a.create_by_id,
+			b.`name` AS createName,
+			a.create_time,
+			a.update_by_id,
+			a.update_time,
+			a.del_flag,
+			a.type_id,
+			a.title,
+			a.detail,
+			(SELECT count(0) FROM knowledge_share_visit b WHERE a.id = b.detail_id AND b.del_flag = 0) AS visit_num,
+			(SELECT count(0) FROM knowledge_share_comment c WHERE a.id = c.detail_id AND c.del_flag = 0) AS comment_num
+		FROM knowledge_share_detail a
+		LEFT JOIN sys_user b ON a.create_by_id = b.id
+		${ew.customSqlSegment}
+		and a.del_flag = 0
+		<if test="detail.typeId != null and detail.typeId != ''">
+			AND a.type_id = #{detail.typeId}
+		</if>
+		<if test="detail.title != null and detail.title != ''">
+			AND a.title LIKE CONCAT ('%', #{detail.title}, '%')
+		</if>
+		<if test="detail.createById != null and detail.createById != ''">
+			AND b.id = #{detail.createById}
+		</if>
+		ORDER BY a.update_time DESC
+	</select>
+
+	<select id="findDtos" resultType="com.jeeplus.sys.service.dto.WorkAttachmentInfoDTO">
+		SELECT
+			id,
+			url,
+			attachment_name AS `name`,
+			create_by_id AS `by`,
+			create_time
+		FROM
+			work_attachment
+		WHERE
+			del_flag = 0
+			AND attachment_id = #{id}
+	</select>
+
+</mapper>

+ 52 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/mapper/xml/KnowledgeShareTypeMapper.xml

@@ -0,0 +1,52 @@
+<?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.pubmodules.knowledge.mapper.KnowledgeShareTypeMapper">
+
+	<select id="findList" resultType="com.jeeplus.pubmodules.knowledge.service.dto.KnowledgeShareTypeDto">
+		SELECT
+			a.id,
+			a.create_by_id,
+			b.`name` AS createName,
+			a.create_time,
+			a.update_by_id,
+			a.update_time,
+			a.del_flag,
+			a.klgs_key,
+			a.klgs_type,
+			a.klgs_sort
+		FROM
+			knowledge_share_type a
+			LEFT JOIN sys_user b ON a.create_by_id = b.id
+
+		${ew.customSqlSegment}
+		and a.del_flag = 0
+		<if test="type != null and type != ''">
+			AND a.klgs_type LIKE CONCAT ('%', #{type}, '%')
+		</if>
+		ORDER BY
+			a.klgs_sort
+	</select>
+
+	<select id="checkList" resultType="com.jeeplus.pubmodules.knowledge.domain.KnowledgeShareType">
+		SELECT
+			id,
+			create_by_id,
+			create_time,
+			update_by_id,
+			update_time,
+			del_flag,
+			klgs_key,
+			klgs_type,
+			klgs_sort
+		FROM
+			knowledge_share_type
+		WHERE
+			del_flag =0
+			AND klgs_key = #{type.klgsKey}
+			AND klgs_type = #{type.klgsType}
+			<if test="type.id != null and type.id != ''">
+				AND id != #{type.id}
+			</if>
+	</select>
+
+</mapper>

+ 16 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/mapper/xml/KnowledgeShareVisitMapper.xml

@@ -0,0 +1,16 @@
+<?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.pubmodules.knowledge.mapper.KnowledgeShareVisitMapper">
+    <select id="selectByDetailId" resultType="com.jeeplus.pubmodules.knowledge.domain.KnowledgeShareVisit">
+        select
+            sv.user_id,
+            sv.first_time,
+            sv.last_time,
+            sv.num,
+            su.name as userName
+        from knowledge_share_visit sv
+        left join sys_user su on sv.user_id=su.id
+        where sv.detail_id=#{id} and sv.del_flag=0
+        order By sv.last_time DESC limit #{size}
+    </select>
+</mapper>

+ 355 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/service/KnowledgeShareInfoService.java

@@ -0,0 +1,355 @@
+package com.jeeplus.pubmodules.knowledge.service;
+
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.extra.spring.SpringUtil;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.jeeplus.common.TokenProvider;
+import com.jeeplus.core.domain.BaseEntity;
+import com.jeeplus.pubmodules.editor.domain.EditorFiles;
+import com.jeeplus.pubmodules.editor.service.EditorFilesService;
+import com.jeeplus.pubmodules.editor.service.dto.EditorFilesDTO;
+import com.jeeplus.pubmodules.knowledge.domain.KnowledgeShareComment;
+import com.jeeplus.pubmodules.knowledge.domain.KnowledgeShareDetail;
+import com.jeeplus.pubmodules.knowledge.domain.KnowledgeShareVisit;
+import com.jeeplus.pubmodules.knowledge.mapper.KnowledgeShareCommentMapper;
+import com.jeeplus.pubmodules.knowledge.mapper.KnowledgeShareDetailMapper;
+import com.jeeplus.pubmodules.knowledge.mapper.KnowledgeShareTypeMapper;
+import com.jeeplus.pubmodules.knowledge.mapper.KnowledgeShareVisitMapper;
+import com.jeeplus.pubmodules.knowledge.service.dto.KnowledgeShareInfoDto;
+import com.jeeplus.pubmodules.knowledge.service.dto.KnowledgeShareListDto;
+import com.jeeplus.pubmodules.knowledge.service.dto.KnowledgeShareTypeDto;
+import com.jeeplus.sys.domain.WorkAttachmentInfo;
+import com.jeeplus.sys.feign.IUserApi;
+import com.jeeplus.sys.feign.IWorkAttachmentApi;
+import com.jeeplus.sys.service.dto.UserDTO;
+import com.jeeplus.sys.service.dto.WorkAttachmentInfoDTO;
+
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicInteger;
+
+@Service
+public class KnowledgeShareInfoService {
+
+    @Resource
+    private KnowledgeShareDetailMapper detailMapper;
+
+    @Resource
+    private KnowledgeShareVisitMapper visitMapper;
+
+    @Resource
+    private KnowledgeShareCommentMapper commentMapper;
+
+    @Resource
+    private KnowledgeShareTypeMapper typeMapper;
+
+    @Resource
+    private EditorFilesService editorFilesService;
+
+    public IPage<KnowledgeShareListDto> list(Page<KnowledgeShareListDto> page, KnowledgeShareDetail detail) {
+        UserDTO userDTO = SpringUtil.getBean(IUserApi.class).getByToken(TokenProvider.getCurrentToken());
+        QueryWrapper<KnowledgeShareTypeDto> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("a.company_id",userDTO.getCompanyDTO().getId());
+        return detailMapper.findList(page,queryWrapper, detail);
+    }
+
+    public String save(KnowledgeShareInfoDto dto) {
+        if (StringUtils.isNotEmpty(dto.getId())) {
+            return update(dto);
+        } else {
+            return add(dto);
+        }
+    }
+
+    public String add(KnowledgeShareInfoDto dto) {
+        // 获取当前登录人信息
+        UserDTO userDTO = SpringUtil.getBean(IUserApi.class).getByToken(TokenProvider.getCurrentToken());
+        // 生成id
+        String id = UUID.randomUUID().toString().replace("-", "");
+        // 保存知识分享详情信息
+        KnowledgeShareDetail detail = new KnowledgeShareDetail();
+        BeanUtils.copyProperties(dto, detail);
+        detail.setId(id);
+        detail.setCreateById(userDTO.getId());
+        detail.setCreateTime(new Date());
+        detail.setUpdateById(userDTO.getId());
+        detail.setUpdateTime(new Date());
+        detail.setDelFlag(0);
+        detail.setOfficeId(userDTO.getOfficeDTO().getId());
+        detail.setCompanyId(userDTO.getCompanyDTO().getId());
+        detailMapper.insert(detail);
+        // 保存富文本中的文件
+        editorFilesService.remove(new QueryWrapper<EditorFiles>().lambda().eq(EditorFiles::getSourceId,id));
+        if (CollectionUtil.isNotEmpty(dto.getEditorFilesDTOList())) {
+            dto.getEditorFilesDTOList().stream().forEach(item->{
+                editorFilesService.saveUrl(item.getTemporaryUrl(),item.getUrl(),id);
+            });
+        }
+        // 保存附件信息
+        if (ObjectUtil.isNotEmpty(dto.getFiles())) {
+            AtomicInteger sort = new AtomicInteger(1);
+            dto.getFiles().stream().forEach(item->{
+                //保存附件信息
+                WorkAttachmentInfo workAttachmentDto = new WorkAttachmentInfo();
+                workAttachmentDto.setName(item.getName());
+                workAttachmentDto.setSize(item.getSize());
+                workAttachmentDto.setUrl(item.getUrl());
+                Map<String,String> map = new HashMap<>();
+                String workAttachmentDtoInfo = JSON.toJSONString(workAttachmentDto);
+                String userDTOInfo = JSON.toJSONString(userDTO);
+                String attachmentId = id;
+                String attachmentFlag = "knowledgeShare";
+                String sortInfo = Integer.toString(sort.get());
+                map.put("workAttachmentDtoInfo",workAttachmentDtoInfo);
+                map.put("userDTOInfo",userDTOInfo);
+                map.put("attachmentId",attachmentId);
+                map.put("attachmentFlag",attachmentFlag);
+                map.put("sortInfo",sortInfo);
+                String fileId = SpringUtil.getBean ( IWorkAttachmentApi.class ).saveFile(map);
+                sort.getAndIncrement();
+            });
+        }
+        return "操作完成";
+    }
+
+    public String update(KnowledgeShareInfoDto dto) {
+        // 获取当前登录人信息
+        UserDTO userDTO = SpringUtil.getBean(IUserApi.class).getByToken(TokenProvider.getCurrentToken());
+
+        // 保存知识分享详情信息
+        KnowledgeShareDetail detail = new KnowledgeShareDetail();
+        BeanUtils.copyProperties(dto, detail);
+        detail.setUpdateById(userDTO.getId());
+        detail.setUpdateTime(new Date());
+        detailMapper.updateById(detail);
+        // 保存富文本中的文件
+        editorFilesService.remove(new QueryWrapper<EditorFiles>().lambda().eq(EditorFiles::getSourceId,dto.getId()));
+        if (CollectionUtil.isNotEmpty(dto.getEditorFilesDTOList())) {
+            dto.getEditorFilesDTOList().stream().forEach(item->{
+                editorFilesService.saveUrl(item.getTemporaryUrl(),item.getUrl(),dto.getId());
+            });
+        }
+        // 保存附件信息
+        if (ObjectUtil.isNotEmpty(dto.getFiles())) {
+            SpringUtil.getBean ( IWorkAttachmentApi.class ).deleteByAttachmentId(dto.getId());
+            AtomicInteger sort = new AtomicInteger(1);
+            dto.getFiles().stream().forEach(item->{
+                //保存附件信息
+                WorkAttachmentInfo workAttachmentDto = new WorkAttachmentInfo();
+                workAttachmentDto.setName(item.getName());
+                workAttachmentDto.setSize(item.getSize());
+                workAttachmentDto.setUrl(item.getUrl());
+                Map<String,String> map = new HashMap<>();
+                String workAttachmentDtoInfo = JSON.toJSONString(workAttachmentDto);
+                String userDTOInfo = JSON.toJSONString(userDTO);
+                String attachmentId = dto.getId();
+                String attachmentFlag = "knowledgeShare";
+                String sortInfo = Integer.toString(sort.get());
+                map.put("workAttachmentDtoInfo",workAttachmentDtoInfo);
+                map.put("userDTOInfo",userDTOInfo);
+                map.put("attachmentId",attachmentId);
+                map.put("attachmentFlag",attachmentFlag);
+                map.put("sortInfo",sortInfo);
+                String fileId = SpringUtil.getBean ( IWorkAttachmentApi.class ).saveFile(map);
+                sort.getAndIncrement();
+            });
+        }
+        return "操作完成";
+    }
+
+    public KnowledgeShareInfoDto findById(String id, String method, Integer size) {
+        KnowledgeShareInfoDto dto = new KnowledgeShareInfoDto();
+        // 获取当前登录人信息
+        UserDTO userDTO = SpringUtil.getBean(IUserApi.class).getByToken(TokenProvider.getCurrentToken());
+        if ("view".equals(method)) {
+            // 保存访问信息
+            saveVisit(id, userDTO);
+        }
+        // 查询数据
+        KnowledgeShareDetail detail = detailMapper.selectById(id);
+        BeanUtils.copyProperties(detail, dto);
+        dto.setTypeName(typeMapper.selectById(detail.getTypeId()).getKlgsType());
+
+        // 富文本图片查询
+        if (ObjectUtil.isNotEmpty(detail)) {
+            if(StringUtils.isNotBlank(detail.getDetail())){
+                String newContent = editorFilesService.getNewContent(detail.getDetail(), id);
+                dto.setDetail(newContent);
+                KnowledgeShareDetail k = new KnowledgeShareDetail();
+                k.setId(id);
+                k.setDetail(newContent);
+                detailMapper.update(k, new QueryWrapper<KnowledgeShareDetail>().lambda().eq(KnowledgeShareDetail::getId, id));
+                List<EditorFiles> list = editorFilesService.list(new QueryWrapper<EditorFiles>().lambda().eq(EditorFiles::getSourceId, id));
+                List<EditorFilesDTO> editorFilesDTOList = new ArrayList<>();
+                list.stream().forEach(item->{
+                    EditorFilesDTO editorFilesDTO = new EditorFilesDTO();
+                    editorFilesDTO.setSourceId(item.getSourceId());
+                    editorFilesDTO.setTemporaryUrl(item.getTemporaryUrl());
+                    editorFilesDTO.setUrl(item.getUrl());
+                    editorFilesDTOList.add(editorFilesDTO);
+                });
+                dto.setEditorFilesDTOList(editorFilesDTOList);
+            }
+        }
+
+        // 查询访问记录
+        LambdaQueryWrapper<KnowledgeShareVisit> visitWrapper = new LambdaQueryWrapper<>();
+        visitWrapper.eq(KnowledgeShareVisit::getDetailId, id).eq(BaseEntity::getDelFlag, 0);
+        List<KnowledgeShareVisit> visits = visitMapper.selectByDetailId(size,id);
+        if (CollectionUtils.isNotEmpty(visits)) {
+            visits.stream().forEach(i -> {
+                UserDTO visitUser = SpringUtil.getBean(IUserApi.class).getById(i.getUserId());
+                i.setUserId(visitUser.getName());
+            });
+        }
+        dto.setVisits(visits);
+        //查询访问人数
+        Integer integer = visitMapper.selectCount(visitWrapper);
+        dto.setVisitNum(integer);
+
+        // 查询回复记录
+        LambdaQueryWrapper<KnowledgeShareComment> commentWrapper = new LambdaQueryWrapper<>();
+        commentWrapper.eq(KnowledgeShareComment::getDetailId, id).eq(BaseEntity::getDelFlag, 0).orderByDesc(BaseEntity::getCreateTime);
+        List<KnowledgeShareComment> comments = commentMapper.selectList(commentWrapper);
+        if (CollectionUtils.isNotEmpty(comments)) {
+            comments.stream().forEach(i -> {
+                UserDTO commentUser = SpringUtil.getBean(IUserApi.class).getById(i.getUserId());
+                i.setUserId(commentUser.getName());
+                i.setDeff(timeDef(i.getCreateTime()));
+            });
+        }
+        dto.setComments(comments);
+        // 查询附件信息
+        List<WorkAttachmentInfoDTO> files = detailMapper.findDtos(id);
+        if (CollectionUtils.isNotEmpty(files)) {
+            for (WorkAttachmentInfoDTO i : files) {
+                i.setCreateBy(SpringUtil.getBean ( IUserApi.class ).getById(i.getBy()));
+            }
+            dto.setFiles(files);
+        }
+        return dto;
+    }
+
+    public String removeById(String id) {
+        // 删除知识分享主表
+        detailMapper.deleteById(id);
+        // 删除知识分享浏览记录表
+        LambdaQueryWrapper<KnowledgeShareVisit> visitWrapper = new LambdaQueryWrapper<>();
+        visitWrapper.eq(KnowledgeShareVisit::getDetailId, id).eq(BaseEntity::getDelFlag, 0);
+        visitMapper.delete(visitWrapper);
+        // 删除知识分享评论表
+        LambdaQueryWrapper<KnowledgeShareComment> commentWrapper = new LambdaQueryWrapper<>();
+        commentWrapper.eq(KnowledgeShareComment::getDetailId, id).eq(BaseEntity::getDelFlag, 0);
+        commentMapper.delete(commentWrapper);
+        // 删除附件信息表
+        SpringUtil.getBean ( IWorkAttachmentApi.class ).deleteByAttachmentId(id);
+        return "操作完成";
+    }
+
+    public String addComment(KnowledgeShareComment comment) {
+        // 获取当前登录人
+        UserDTO userDTO = SpringUtil.getBean(IUserApi.class).getByToken(TokenProvider.getCurrentToken());
+        // 生成id
+        String id = UUID.randomUUID().toString().replace("-", "");
+        comment.setId(id);
+        comment.setCreateById(userDTO.getId());
+        comment.setCreateTime(new Date());
+        comment.setUpdateById(userDTO.getId());
+        comment.setUpdateTime(new Date());
+        comment.setDelFlag(0);
+        comment.setUserId(userDTO.getId());
+        commentMapper.insert(comment);
+        return "操作完成";
+    }
+
+    public String delComment(String id) {
+        commentMapper.deleteById(id);
+        return "操作完成";
+    }
+
+    /**
+     * 保存访问记录
+     */
+    public Boolean saveVisit(String id, UserDTO userDTO) {
+        LambdaQueryWrapper<KnowledgeShareVisit> wrapper = new LambdaQueryWrapper<>();
+        wrapper.eq(BaseEntity::getDelFlag, 0).eq(KnowledgeShareVisit::getDetailId, id).eq(KnowledgeShareVisit::getUserId, userDTO.getId());
+        KnowledgeShareVisit visit = visitMapper.selectOne(wrapper);
+        if (visit != null) {
+            // 访问记录存在,则增加访问次数和更改最近访问时间
+            visit.setNum(visit.getNum() + 1);
+            visit.setLastTime(new Date());
+            visitMapper.updateById(visit);
+        } else {
+            // 访问记录不存在,则新增访问记录
+            visit = new KnowledgeShareVisit();
+            // 生成id
+            String visitId = UUID.randomUUID().toString().replace("-", "");
+            visit.setId(visitId);
+            visit.setCreateById(userDTO.getId());
+            visit.setCreateTime(new Date());
+            visit.setUpdateById(userDTO.getId());
+            visit.setUpdateTime(new Date());
+            visit.setDelFlag(0);
+            visit.setDetailId(id);
+            visit.setUserId(userDTO.getId());
+            visit.setFirstTime(new Date());
+            visit.setLastTime(new Date());
+            visit.setNum(1);
+            visitMapper.insert(visit);
+        }
+        return true;
+    }
+
+    /**
+     * 计算时间差
+     */
+    public 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 + "分钟前";
+    }
+
+    /**
+     * 查询评论
+     * @param id
+     * @return
+     */
+    public KnowledgeShareInfoDto getComments(String id) {
+        KnowledgeShareInfoDto knowledgeShareInfoDto = new KnowledgeShareInfoDto();
+        // 查询回复记录
+        LambdaQueryWrapper<KnowledgeShareComment> commentWrapper = new LambdaQueryWrapper<>();
+        commentWrapper.eq(KnowledgeShareComment::getDetailId, id).eq(BaseEntity::getDelFlag, 0).orderByDesc(BaseEntity::getCreateTime);
+        List<KnowledgeShareComment> comments = commentMapper.selectList(commentWrapper);
+        if (CollectionUtils.isNotEmpty(comments)) {
+            comments.stream().forEach(i -> {
+                UserDTO commentUser = SpringUtil.getBean(IUserApi.class).getById(i.getUserId());
+                i.setUserId(commentUser.getName());
+                i.setDeff(timeDef(i.getCreateTime()));
+            });
+        }
+        knowledgeShareInfoDto.setComments(comments);
+        return knowledgeShareInfoDto;
+    }
+}

+ 74 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/service/KnowledgeTypeService.java

@@ -0,0 +1,74 @@
+package com.jeeplus.pubmodules.knowledge.service;
+
+import cn.hutool.extra.spring.SpringUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.jeeplus.pubmodules.knowledge.domain.KnowledgeShareType;
+import com.jeeplus.pubmodules.knowledge.mapper.KnowledgeShareTypeMapper;
+import com.jeeplus.pubmodules.knowledge.service.dto.KnowledgeShareTypeDto;
+import com.jeeplus.common.TokenProvider;
+import com.jeeplus.sys.feign.IUserApi;
+import com.jeeplus.sys.service.dto.UserDTO;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+@Service
+public class KnowledgeTypeService {
+
+    @Resource
+    private KnowledgeShareTypeMapper mapper;
+
+    public IPage<KnowledgeShareTypeDto> list(Page<KnowledgeShareTypeDto> page, KnowledgeShareType type) {
+        UserDTO userDTO = SpringUtil.getBean(IUserApi.class).getByToken(TokenProvider.getCurrentToken());
+        QueryWrapper<KnowledgeShareTypeDto> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq("a.company_id",userDTO.getCompanyDTO().getId());
+        return mapper.findList(page,queryWrapper, type.getKlgsType());
+    }
+
+    public Boolean save(KnowledgeShareType type) {
+        List<KnowledgeShareType> list = mapper.checkList(type);
+        if (CollectionUtils.isNotEmpty(list)) {
+            return false;
+        }
+        if (StringUtils.isNotEmpty(type.getId())) {
+            return update(type);
+        } else {
+            return add(type);
+        }
+    }
+
+    public Boolean update(KnowledgeShareType type) {
+        // 获取当前登录人
+        UserDTO userDTO = SpringUtil.getBean(IUserApi.class).getByToken(TokenProvider.getCurrentToken());
+        type.setUpdateById(userDTO.getId());
+        type.setUpdateTime(new Date());
+        mapper.updateById(type);
+        return true;
+    }
+
+    public Boolean add(KnowledgeShareType type) {
+        // 获取当前登录人
+        UserDTO userDTO = SpringUtil.getBean(IUserApi.class).getByToken(TokenProvider.getCurrentToken());
+        // 生成id
+        String id = UUID.randomUUID().toString().replace("-", "");
+        type.setId(id);
+        type.setCreateById(userDTO.getId());
+        type.setCreateTime(new Date());
+        type.setUpdateById(userDTO.getId());
+        type.setUpdateTime(new Date());
+        type.setDelFlag(0);
+        type.setOfficeId(userDTO.getOfficeDTO().getId());
+        type.setCompanyId(userDTO.getCompanyDTO().getId());
+        mapper.insert(type);
+        return true;
+    }
+
+}

+ 93 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/service/dto/KnowledgeShareInfoDto.java

@@ -0,0 +1,93 @@
+package com.jeeplus.pubmodules.knowledge.service.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import com.jeeplus.pubmodules.editor.service.dto.EditorFilesDTO;
+import com.jeeplus.pubmodules.knowledge.domain.KnowledgeShareComment;
+import com.jeeplus.pubmodules.knowledge.domain.KnowledgeShareVisit;
+import com.jeeplus.sys.service.dto.WorkAttachmentInfoDTO;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+@Data
+public class KnowledgeShareInfoDto {
+
+    /**
+     * 主键
+     */
+    private String id;
+
+    /**
+     * 创建人
+     */
+    private String createBy;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date createDate;
+
+    /**
+     * 更新人
+     */
+    private String updateBy;
+
+    /**
+     * 更新时间
+     */
+    private Date updateDate;
+
+    /**
+     * 删除状态
+     */
+    private Integer delFlag;
+
+    /**
+     * 知识分享类型id
+     */
+    private String typeId;
+
+    /**
+     * 知识分享类型名称
+     */
+    private String typeName;
+
+    /**
+     * 主题
+     */
+    private String title;
+
+    /**
+     * 内容
+     */
+    private String detail;
+
+    /**
+     * 访问记录
+     */
+    private List<KnowledgeShareVisit> visits;
+
+    /**
+     * 评论记录
+     */
+    private List<KnowledgeShareComment> comments;
+
+    /**
+     * 附件列表
+     */
+    private List<WorkAttachmentInfoDTO> files;
+
+    /**
+     * 富文本图片集合
+     */
+    private List<EditorFilesDTO> editorFilesDTOList;
+
+    /**
+     * 阅读量
+     */
+    private Integer visitNum;
+
+}

+ 67 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/service/dto/KnowledgeShareListDto.java

@@ -0,0 +1,67 @@
+package com.jeeplus.pubmodules.knowledge.service.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class KnowledgeShareListDto {
+
+    /**
+     * 主键
+     */
+    private String id;
+
+    /**
+     * 创建人
+     */
+    private String createName;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:dd")
+    private Date createTime;
+
+    /**
+     * 更新人
+     */
+    private String updateById;
+
+    /**
+     * 更新时间
+     */
+    private Date updateTime;
+
+    /**
+     * 删除状态
+     */
+    private Integer delFlag;
+
+    /**
+     * 知识分享类型id
+     */
+    private String typeId;
+
+    /**
+     * 主题
+     */
+    private String title;
+
+    /**
+     * 内容
+     */
+    private String detail;
+
+    /**
+     * 阅读量
+     */
+    private Integer visitNum;
+
+    /**
+     * 回复量
+     */
+    private Integer commentNum;
+
+}

+ 57 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/knowledge/service/dto/KnowledgeShareTypeDto.java

@@ -0,0 +1,57 @@
+package com.jeeplus.pubmodules.knowledge.service.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class KnowledgeShareTypeDto {
+
+    /**
+     * 主键
+     */
+    private String id;
+
+    /**
+     * 创建人
+     */
+    private String createName;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date createTime;
+
+    /**
+     * 更新人
+     */
+    private String updateById;
+
+    /**
+     * 更新时间
+     */
+    private Date updateTime;
+
+    /**
+     * 删除状态
+     */
+    private Integer delFlag;
+
+    /**
+     * 分享类型key值
+     */
+    private String klgsKey;
+
+    /**
+     * 分享类型
+     */
+    private String klgsType;
+
+    /**
+     * 排序
+     */
+    private Integer klgsSort;
+
+}