Browse Source

文档,模板功能提交,创建表SQL提交

cxd 8 months ago
parent
commit
14336e59a7

+ 1 - 1
gqy-admin/src/main/java/com/gqy/web/controller/document/DcDocumentController.java

@@ -153,7 +153,7 @@ public class DcDocumentController extends BaseController
         if (id == null || "".equals(id)) {
         if (id == null || "".equals(id)) {
             return AjaxResultCQY.error("文档ID不能为空");
             return AjaxResultCQY.error("文档ID不能为空");
         }
         }
-        Document document = documentService.info(Long.valueOf(id));
+        Map<String, Object>  document = documentService.info(Long.valueOf(id));
         if (document == null) {
         if (document == null) {
             return AjaxResultCQY.error("文档不存在或无权限访问");
             return AjaxResultCQY.error("文档不存在或无权限访问");
         }
         }

+ 17 - 4
gqy-admin/src/main/java/com/gqy/web/controller/document/DcTemplateController.java

@@ -3,19 +3,18 @@ package com.gqy.web.controller.document;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.github.pagehelper.PageInfo;
 import com.gqy.common.core.controller.BaseController;
 import com.gqy.common.core.controller.BaseController;
+import com.gqy.common.core.domain.AjaxResult;
 import com.gqy.common.core.domain.AjaxResultCQY;
 import com.gqy.common.core.domain.AjaxResultCQY;
 import com.gqy.common.utils.StringUtils;
 import com.gqy.common.utils.StringUtils;
 import com.gqy.document.domain.DcTemplate;
 import com.gqy.document.domain.DcTemplate;
 import com.gqy.document.domain.vo.PageResult;
 import com.gqy.document.domain.vo.PageResult;
 import com.gqy.document.service.IDcTemplateService;
 import com.gqy.document.service.IDcTemplateService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import java.util.List;
 import java.util.List;
+import java.util.Map;
 
 
 
 
 @RestController
 @RestController
@@ -64,4 +63,18 @@ public class DcTemplateController extends BaseController {
         return AjaxResultCQY.success("查询成功", PageResult);
         return AjaxResultCQY.success("查询成功", PageResult);
     }
     }
 
 
+    /**
+     * 获取模板详细信息
+     *
+     * @param id 模板ID
+     * @return 模板详细信息,包括基本信息和分类信息
+     */
+    @PostMapping("/info")
+    public AjaxResultCQY info(@RequestBody Map map) {
+        Integer id = (Integer) map.get("id");
+        return  templateService.getInfo(id.longValue());
+    }
+
+
+
 }
 }

+ 1 - 0
gqy-system/src/main/java/com/gqy/document/domain/DcTemplate.java

@@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
 import java.util.Date;
 import java.util.Date;
 
 
 public class DcTemplate {
 public class DcTemplate {
+
     private Integer id;
     private Integer id;
     private String code;
     private String code;
     private String name;
     private String name;

+ 1 - 0
gqy-system/src/main/java/com/gqy/document/domain/Document.java

@@ -5,6 +5,7 @@ import com.gqy.common.annotation.Excel;
 import com.gqy.common.core.domain.BaseEntity;
 import com.gqy.common.core.domain.BaseEntity;
 
 
 import java.util.Date;
 import java.util.Date;
+import java.util.List;
 
 
 /**
 /**
  * 【请填写功能名称】对象 dc_document
  * 【请填写功能名称】对象 dc_document

+ 26 - 0
gqy-system/src/main/java/com/gqy/document/mapper/DcTemplateMapper.java

@@ -1,6 +1,8 @@
 package com.gqy.document.mapper;
 package com.gqy.document.mapper;
 
 
 import com.gqy.document.domain.DcTemplate;
 import com.gqy.document.domain.DcTemplate;
+import com.gqy.document.domain.DcTemplateCategory;
+import com.gqy.document.domain.TemplateCategory;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
 
 
 import java.util.List;
 import java.util.List;
@@ -9,5 +11,29 @@ import java.util.List;
  * 模板查询接口
  * 模板查询接口
  */
  */
 public interface DcTemplateMapper {
 public interface DcTemplateMapper {
+    /**
+     * 列表搜索
+     * @param name
+     * @param category_id
+     * @param status
+     * @return
+     */
     public List<DcTemplate> selectTemplateList(@Param("name") String name, @Param("category_id") Integer category_id,@Param("status") Integer status);
     public List<DcTemplate> selectTemplateList(@Param("name") String name, @Param("category_id") Integer category_id,@Param("status") Integer status);
+
+    /**
+     * 根据ID查询模板信息
+     *
+     * @param id 模板ID
+     * @return 模板信息
+     */
+    DcTemplate selectTemplateById(Long id);
+
+    /**
+     * 根据分类ID查询分类信息
+     *
+     * @param categoryId 分类ID
+     * @return 分类信息
+     */
+    DcTemplateCategory selectTemplateCategoryById(Long categoryId);
+
 }
 }

+ 17 - 0
gqy-system/src/main/java/com/gqy/document/mapper/DocumentMapper.java

@@ -45,4 +45,21 @@ public interface DocumentMapper
      * @return 文档信息
      * @return 文档信息
      */
      */
     public Document info(Long id);
     public Document info(Long id);
+
+    /**
+     * 获取文档关联的产品ID列表
+     *
+     * @param documentId 文档ID
+     * @return 关联的产品ID列表
+     */
+    List<Long> selectProductDocumentsByDocId(Long documentId);
+
+    /**
+     * 获取文档关联的项目ID列表
+     *
+     * @param documentId 文档ID
+     * @return 关联的项目ID列表
+     */
+    List<Long> selectProjectDocumentsByDocId(Long documentId);
+
 }
 }

+ 10 - 0
gqy-system/src/main/java/com/gqy/document/service/IDcTemplateService.java

@@ -1,5 +1,7 @@
 package com.gqy.document.service;
 package com.gqy.document.service;
 
 
+import com.gqy.common.core.domain.AjaxResult;
+import com.gqy.common.core.domain.AjaxResultCQY;
 import com.gqy.document.domain.DcTemplate;
 import com.gqy.document.domain.DcTemplate;
 
 
 import java.util.List;
 import java.util.List;
@@ -10,4 +12,12 @@ public interface IDcTemplateService {
      */
      */
     public List<DcTemplate> selectTemplateList(String name, Integer category_id, Integer status);
     public List<DcTemplate> selectTemplateList(String name, Integer category_id, Integer status);
 
 
+    /**
+     * 获取模板详细信息
+     *
+     * @param id 模板ID
+     * @return 模板详细信息
+     */
+    AjaxResultCQY getInfo(Long id);
+
 }
 }

+ 2 - 1
gqy-system/src/main/java/com/gqy/document/service/IDocumentService.java

@@ -10,6 +10,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import java.util.List;
 import java.util.List;
+import java.util.Map;
 
 
 /**
 /**
  * 文档管理 数据层
  * 文档管理 数据层
@@ -45,6 +46,6 @@ public interface IDocumentService
      * @param id 文档ID
      * @param id 文档ID
      * @return 文档信息
      * @return 文档信息
      */
      */
-    public Document info(Long id);
+    public Map<String, Object>  info(Long id);
 
 
 }
 }

+ 22 - 14
gqy-system/src/main/java/com/gqy/document/service/impl/DcDocumentServiceImpl.java

@@ -199,20 +199,28 @@ public class DcDocumentServiceImpl implements IDocumentService
      * @param id 文档ID
      * @param id 文档ID
      * @return 文档信息
      * @return 文档信息
      */
      */
-    public Document info(Long id) {
-        Document document = documentMapper.info(id);
-        if (document != null) {
-            Long loginUserId = SecurityUtils.getUserId();
-            boolean isAdmin = SecurityUtils.isAdmin(loginUserId);
-
-            // 非管理员只能查看自己的非模板文档
-            if (!isAdmin &&
-                    (document.getIs_template() == 1 ||
-                            !document.getUser_id().equals(loginUserId))) {
-                return null;
-            }
-        }
-        return document;
+    public Map<String, Object>  info(Long id) {
+        Document doc = documentMapper.info(id);
+        Map<String, Object> result = new HashMap<>();
+        result.put("id", doc.getId());
+        result.put("title", doc.getTitle());
+        result.put("data", doc.getData());
+      //  result.put("user_id", doc.getUserId());
+
+        // 获取关联产品
+        result.put("linkProduct", documentMapper.selectProductDocumentsByDocId(id));
+        result.put("links", "");
+
+        // 获取关联项目
+        result.put("linkProject", documentMapper.selectProjectDocumentsByDocId(id));
+        result.put("projects", "");
+
+        result.put("category_id", doc.getCategory_id());
+        result.put("createTime", doc.getCreateTime());
+        result.put("status", doc.getStatus());
+        result.put("is_template", doc.getIs_template());
+
+        return result;
     }
     }
 
 
 
 

+ 57 - 0
gqy-system/src/main/java/com/gqy/document/service/impl/DcTemplateServiceImpl.java

@@ -1,12 +1,18 @@
 package com.gqy.document.service.impl;
 package com.gqy.document.service.impl;
 
 
+import com.gqy.common.core.domain.AjaxResult;
+import com.gqy.common.core.domain.AjaxResultCQY;
 import com.gqy.document.domain.DcTemplate;
 import com.gqy.document.domain.DcTemplate;
+import com.gqy.document.domain.DcTemplateCategory;
+import com.gqy.document.domain.TemplateCategory;
 import com.gqy.document.mapper.DcTemplateMapper;
 import com.gqy.document.mapper.DcTemplateMapper;
 import com.gqy.document.service.IDcTemplateService;
 import com.gqy.document.service.IDcTemplateService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
+import java.util.HashMap;
 import java.util.List;
 import java.util.List;
+import java.util.Map;
 
 
 /**
 /**
  * 模板服务实现
  * 模板服务实现
@@ -21,4 +27,55 @@ public class DcTemplateServiceImpl implements IDcTemplateService {
     public List<DcTemplate> selectTemplateList(String name, Integer category_id, Integer status) {
     public List<DcTemplate> selectTemplateList(String name, Integer category_id, Integer status) {
         return dcTemplateMapper.selectTemplateList(name, category_id, status);
         return dcTemplateMapper.selectTemplateList(name, category_id, status);
     }
     }
+
+
+
+    /**
+     * 获取模板详细信息
+     * 包括模板基本信息和关联的分类信息
+     *
+     * @param id 模板ID
+     * @return 返回组装后的模板信息,格式如下:
+     */
+    public AjaxResultCQY getInfo(Long id) {
+        // 1. 查询模板基本信息
+        DcTemplate template = dcTemplateMapper.selectTemplateById(id);
+        if (template == null) {
+            return AjaxResultCQY.error("模板不存在");
+        }
+        // 2. 查询关联的分类信息
+        DcTemplateCategory category = null;
+        if (template.getCategory_id() != null) {
+            category = dcTemplateMapper.selectTemplateCategoryById(Long.valueOf(template.getCategory_id()));
+        }
+        // 3. 构建返回数据结构
+        Map<String, Object> result = new HashMap<>();
+        // 3.1 设置模板基本信息
+        result.put("id", template.getId());
+        result.put("code", template.getCode());
+        result.put("name", template.getName());
+        result.put("lay_id", template.getLay_id());
+        result.put("intro", template.getIntro());
+        result.put("type", template.getType());
+        result.put("category_id", template.getCategory_id());
+        result.put("content", template.getContent());
+        result.put("attrs", template.getAttrs());  // JSON格式的属性配置
+        result.put("createTime", template.getCreate_time());
+        result.put("status", template.getStatus());
+
+        // 3.2 设置分类信息(如果存在)
+        if (category != null) {
+            Map<String, Object> categoryMap = new HashMap<>();
+            categoryMap.put("id", category.getId());
+            categoryMap.put("intro", category.getIntro());
+            categoryMap.put("name", category.getName());
+            categoryMap.put("createTime", category.getCreate_time());
+            categoryMap.put("status", category.getStatus());
+            categoryMap.put("parent_id", category.getParent_id());
+            result.put("category", categoryMap);
+        }
+
+        // 4. 返回成功结果
+        return AjaxResultCQY.success(result);
+    }
 }
 }

+ 19 - 0
gqy-system/src/main/resources/mapper/document/DcDocumentMapper.xml

@@ -165,4 +165,23 @@
     </select>
     </select>
     <!-- ================  info  -->
     <!-- ================  info  -->
 
 
+
+    <!-- 获取文档关联的产品ID列表 -->
+    <select id="selectProductDocumentsByDocId" parameterType="Long" resultType="Long">
+        select product_id
+        from dc_product_document
+        where document_id = #{documentId}
+          and status != 4
+    </select>
+
+    <!-- 获取文档关联的项目ID列表 -->
+    <select id="selectProjectDocumentsByDocId" parameterType="Long" resultType="Long">
+        select project_id
+        from dc_project_document
+        where doc_id = #{documentId}
+          and status != 4
+    </select>
+
+
+
 </mapper>
 </mapper>

+ 25 - 0
gqy-system/src/main/resources/mapper/document/DcTemplateMapper.xml

@@ -68,4 +68,29 @@
         </where>
         </where>
         order by t.create_time desc
         order by t.create_time desc
     </select>
     </select>
+
+    <!--    info -->
+    <select id="selectTemplateById" parameterType="Long" resultMap="TemplateResult">
+        select id, code, name, intro, lay_id, type, content, attrs,
+               category_id, admin_id, create_time, status
+        from dc_template
+        where id = #{id}
+    </select>
+    <resultMap id="TemplateCategoryResult" type="TemplateCategory">
+        <id property="id" column="id"/>
+        <result property="name" column="name"/>
+        <result property="intro" column="intro"/>
+        <result property="parent_id" column="parent_id"/>
+        <result property="create_time" column="create_time"/>
+        <result property="status" column="status"/>
+    </resultMap>
+    <select id="selectTemplateCategoryById" parameterType="Long" resultMap="TemplateCategoryResult">
+        select id, name, intro, parent_id, create_time, status
+        from dc_template_category
+        where id = #{categoryId}
+    </select>
+    <!--    info -->
+
+
+
 </mapper>
 </mapper>

+ 13 - 0
创建表语句.txt

@@ -242,3 +242,16 @@ CREATE TABLE `ps_param` (
     `psp_dck_id` int COMMENT '文档块id',
     `psp_dck_id` int COMMENT '文档块id',
     PRIMARY KEY (`psp_id`)
     PRIMARY KEY (`psp_id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='产品参数表';
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='产品参数表';
+
+CREATE TABLE dc_formula (
+    id bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
+    name varchar(255) NOT NULL COMMENT '公式名称',
+    formula text COMMENT '公式内容',
+    intro varchar(255) DEFAULT NULL COMMENT '公式介绍',
+    params varchar(255) DEFAULT '[]' COMMENT '公式参数',
+    create_time datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+    use_status tinyint DEFAULT '5' COMMENT '使用状态(5-已用中 6-未使用)',
+    status tinyint DEFAULT '5' COMMENT '状态(5-使用中 4-已删除)',
+    point smallint DEFAULT '0' COMMENT '小数点标识',
+    PRIMARY KEY (id)
+) ENGINE=InnoDB COMMENT='公式管理表';