Pārlūkot izejas kodu

添加公式表

cxd 7 mēneši atpakaļ
vecāks
revīzija
a8f27c82b7

+ 15 - 0
gqy-admin/src/main/java/com/gqy/web/controller/document/TemplateCategoryController.java

@@ -2,13 +2,16 @@ package com.gqy.web.controller.document;
 
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
+import com.gqy.common.core.domain.AjaxResult;
 import com.gqy.common.core.domain.AjaxResultCQY;
 import com.gqy.common.utils.StringUtils;
 import com.gqy.document.domain.TemplateCategory;
 import com.gqy.document.domain.vo.PageResult;
 import com.gqy.document.service.ITemplateCategoryService;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
 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;
 
@@ -25,6 +28,18 @@ public class TemplateCategoryController {
     @Autowired
     private ITemplateCategoryService templateCategoryService;
 
+
+    /**
+     * 创建模板分类
+     */
+//    @PreAuthorize("@ss.hasPermi('system:category:add')")
+    @PostMapping("/create")
+    public AjaxResultCQY create(@RequestBody TemplateCategory templateCategory) {
+        return templateCategoryService.create(templateCategory);
+    }
+
+
+
     /**
      * 模板树查询
      * @return

+ 7 - 0
gqy-system/src/main/java/com/gqy/document/domain/TemplateCategory.java

@@ -52,6 +52,13 @@ public class TemplateCategory extends TreeEntity {
     public void setParent_id(String parent_id) {
         this.parent_id = parent_id;
     }
+//    public Long getParent_id() {
+//        return parent_id;
+//    }
+//
+//    public void setParent_id(Long parent_id) {
+//        this.parent_id = parent_id;
+//    }
 
     public Date getCreate_time() {
         return create_time;

+ 8 - 0
gqy-system/src/main/java/com/gqy/document/mapper/TemplateCategoryMapper.java

@@ -31,5 +31,13 @@ public interface TemplateCategoryMapper {
      */
     public List<TemplateCategory> selectTemplateCategoryList();
 
+    /**
+     * 新增模板分类
+     *
+     * @param templateCategory 模板分类信息
+     * @return 结果
+     */
+    public int insertTemplateCategory(TemplateCategory templateCategory);
+
 
 }

+ 9 - 0
gqy-system/src/main/java/com/gqy/document/service/ITemplateCategoryService.java

@@ -34,4 +34,13 @@ public interface ITemplateCategoryService {
      */
     public AjaxResultCQY treeCategory();
 
+    /**
+     * 创建模板分类
+     *
+     * @param templateCategory 模板分类信息
+     * @return 结果
+     */
+    public AjaxResultCQY create(TemplateCategory templateCategory);
+
+
 }

+ 24 - 0
gqy-system/src/main/java/com/gqy/document/service/impl/TemplateCategoryServiceImpl.java

@@ -2,11 +2,13 @@ package com.gqy.document.service.impl;
 
 import com.gqy.common.core.domain.AjaxResult;
 import com.gqy.common.core.domain.AjaxResultCQY;
+import com.gqy.common.utils.DateUtils;
 import com.gqy.document.domain.TemplateCategory;
 import com.gqy.document.mapper.TemplateCategoryMapper;
 import com.gqy.document.service.ITemplateCategoryService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.HashMap;
 import java.util.List;
@@ -52,6 +54,28 @@ public class TemplateCategoryServiceImpl  implements ITemplateCategoryService {
     }
 
 
+    /**
+     * 创建模板分类
+     *
+     * @param templateCategory 模板分类信息
+     * @return 结果
+     */
+    @Transactional
+    public AjaxResultCQY create(TemplateCategory templateCategory) {
+        try {
+            // 设置默认值
+            templateCategory.setStatus(5);
+            templateCategory.setCreate_time(DateUtils.getNowDate());
+            // templateCategory.setUpdate_time(DateUtils.getNowDate());
+            // 保存数据
+            templateCategoryMapper.insertTemplateCategory(templateCategory);
+            return  AjaxResultCQY.success("新增成功");
+        }catch (Exception e){
+            return  AjaxResultCQY.error(e.getMessage());
+        }
+    }
+
+
     /**
      * 递归构建树形结构
      *

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

@@ -15,6 +15,22 @@
     </resultMap>
 
 
+    <!-- 添加模版信息 -->
+    <insert id="insertTemplateCategory" parameterType="TemplateCategory" useGeneratedKeys="true" keyProperty="id">
+        insert into dc_template_category (
+            name,
+            parent_id,
+            intro,
+            status
+        ) values (
+                     #{name},
+                     #{parent_id},
+                     #{intro},
+                     #{status}
+                 )
+    </insert>
+
+
     <!-- 查询所有有效分类 -->
     <select id="selectTemplateCategoryList" resultMap="TemplateCategoryResult">
         select
@@ -60,4 +76,7 @@
         where parent_id = #{category_id}
           and status != 4
     </select>
+
+
+
 </mapper>

+ 4 - 3
gqy-system/src/main/resources/mapper/document/WorkMapper.xml

@@ -8,11 +8,12 @@
         <result property="wkName"         column="wk_name"         />
         <result property="wkRemark"       column="wk_remark"       />
         <result property="wkStaus"        column="wk_staus"        />
+
     </resultMap>
 
     <sql id="selectWorkVo">
         select wk_id, wk_no, wk_name, wk_remark, wk_staus
-        from work
+        from dc_work
     </sql>
 
     <select id="selectWorkList" parameterType="Work" resultMap="WorkResult">
@@ -36,7 +37,7 @@
     </select>
 
     <insert id="insertWork" parameterType="Work" useGeneratedKeys="true" keyProperty="wkId">
-        insert into work (
+        insert into dc_work (
             wk_no, wk_name, wk_remark, wk_staus
         ) values (
                      #{wkNo}, #{wkName}, #{wkSysId}, #{wkRemark}, #{wkStaus}
@@ -44,7 +45,7 @@
     </insert>
 
     <update id="updateWork" parameterType="Work">
-        update work
+        update dc_work
         <set>
             <if test="wkNo != null">wk_no = #{wkNo},</if>
             <if test="wkName != null">wk_name = #{wkName},</if>

+ 1 - 1
创建表语句.txt

@@ -242,7 +242,7 @@ CREATE TABLE `ps_param` (
     `psp_dck_id` int COMMENT '文档块id',
     PRIMARY KEY (`psp_id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='产品参数表';
-
+--- 公式表
 CREATE TABLE dc_formula (
     id bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
     name varchar(255) NOT NULL COMMENT '公式名称',