Parcourir la source

Merge remote-tracking branch 'origin/feat_file_compare_manger' into feat_20250514_wangshuo

wangshuo il y a 1 mois
Parent
commit
bdf737f46d

+ 22 - 35
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysCompanyTemplateController.java

@@ -1,8 +1,7 @@
 package com.ruoyi.web.controller.system;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.stream.Collectors;
 import javax.servlet.http.HttpServletResponse;
 
 import com.ruoyi.common.core.domain.entity.SysDictData;
@@ -50,31 +49,19 @@ public class SysCompanyTemplateController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('system:template:list')")
     @GetMapping("/list")
-    public TableDataInfo list(SysCompanyTemplate sysCompanyTemplate)
+    public AjaxResult list(SysCompanyTemplate sysCompanyTemplate)
     {
         startPage();
         List<SysCompanyTemplate> list = sysCompanyTemplateService.selectSysCompanyTemplateList(sysCompanyTemplate);
-        return getDataTable(list);
+        return AjaxResult.success(getDataTable(list));
     }
 
-    /**
-     * 导出企业模板列表
-     */
-    @PreAuthorize("@ss.hasPermi('system:template:export')")
-    @Log(title = "导出企业配置列表", businessType = BusinessType.EXPORT)
-    @PostMapping("/export")
-    public void export(HttpServletResponse response, SysCompanyTemplate sysCompanyTemplate)
-    {
-        List<SysCompanyTemplate> list = sysCompanyTemplateService.selectSysCompanyTemplateList(sysCompanyTemplate);
-        ExcelUtil<SysCompanyTemplate> util = new ExcelUtil<SysCompanyTemplate>(SysCompanyTemplate.class);
-        util.exportExcel(response, list, "企业配置数据");
-    }
 
     /**
-     * 获取企业模板列表
+     * 获取模板详情列表
      */
     @PreAuthorize("@ss.hasPermi('system:template:getTemplate')")
-    @Log(title = "获取模板列表", businessType = BusinessType.EXPORT)
+    @Log(title = "获取模板详情列表", businessType = BusinessType.EXPORT)
     @GetMapping("/getTemplate")
     public AjaxResult getTemplate(String type)
     {
@@ -92,20 +79,6 @@ public class SysCompanyTemplateController extends BaseController
         }
     }
 
-//    /**
-//     * 获取企业模板列表
-//     */
-//    @PreAuthorize("@ss.hasPermi('system:template:getTemplatefile')")
-//    @Log(title = "获取模板文件", businessType = BusinessType.EXPORT)
-//    @GetMapping("/getTemplateFiles")
-//    public AjaxResult getTemplate(SysCompanyTemplate sysCompanyTemplate)
-//    {
-//        if (sysCompanyTemplate.getTemplate() == null){
-//            return error("该公司未配置模板");
-//        }
-//        return success();
-//    }
-
     /**
      * 获取企业模板详细信息
      */
@@ -113,7 +86,18 @@ public class SysCompanyTemplateController extends BaseController
     @GetMapping(value = "/{id}")
     public AjaxResult getInfo(@PathVariable("id") Long id)
     {
-        return success(sysCompanyTemplateService.selectSysCompanyTemplateById(id));
+        SysCompanyTemplate sysCompanyTemplate = sysCompanyTemplateService.selectSysCompanyTemplateById(id);
+        if(sysCompanyTemplate.getTemplate() != null && !"".equals(sysCompanyTemplate.getTemplate())){
+//            String template = sysCompanyTemplate.getTemplate().substring(1, sysCompanyTemplate.getTemplate().length()-1);
+            String[] templateList = sysCompanyTemplate.getTemplate().split(",");
+            Long[] templateIds = new Long[templateList.length];
+            for(int i = 0;i<templateList.length;i++){
+                templateIds[i] = Long.parseLong(templateList[i]);
+            }
+            sysCompanyTemplate.setTemplateIds(new ArrayList<>(Arrays.asList(templateIds)));
+            sysCompanyTemplate.setTemplateList(sysRepoServiceImpl.selectSysRepoListByRepoIds(templateIds));
+        }
+        return success(sysCompanyTemplate);
     }
 
     /**
@@ -124,17 +108,20 @@ public class SysCompanyTemplateController extends BaseController
     @PostMapping
     public AjaxResult add(@RequestBody SysCompanyTemplate sysCompanyTemplate)
     {
+        sysCompanyTemplate.setUpdateBy(getUsername());
         return toAjax(sysCompanyTemplateService.insertSysCompanyTemplate(sysCompanyTemplate));
     }
 
     /**
-     * 修改企业模板
+     * 修改企业模板接口
      */
     @PreAuthorize("@ss.hasPermi('system:template:edit')")
     @Log(title = "修改企业模板信息", businessType = BusinessType.UPDATE)
     @PutMapping
     public AjaxResult edit(@RequestBody SysCompanyTemplate sysCompanyTemplate)
     {
+        sysCompanyTemplate.setUpdateBy(getUsername());
+        sysCompanyTemplate.setTemplate(sysCompanyTemplate.getTemplateIds().stream().map(String::valueOf).collect(Collectors.joining(",")));
         return toAjax(sysCompanyTemplateService.updateSysCompanyTemplate(sysCompanyTemplate));
     }
 

+ 29 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysCompanyTemplate.java

@@ -5,6 +5,9 @@ import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.BaseEntity;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * 企业模板对象
  * 
@@ -24,9 +27,16 @@ public class SysCompanyTemplate extends BaseEntity
     /** 企业模板配置 */
     private String template;
 
+
     /** 企业ID */
     private Long companyId;
 
+    /** 模板id列表 */
+    private List<Long> templateIds;
+
+    /** 模板列表 */
+    private List<SysRepo> templateList = new ArrayList<SysRepo>();
+
     public void setId(Long id) 
     {
         this.id = id;
@@ -65,6 +75,23 @@ public class SysCompanyTemplate extends BaseEntity
 		this.companyId = companyId;
 	}
 
+    public List<SysRepo> getTemplateList() {
+		return templateList;
+	}
+
+    public void setTemplateList(List<SysRepo> templateList) {
+		this.templateList = templateList;
+
+	}
+
+    public List<Long> getTemplateIds() {
+		return templateIds;
+	}
+
+    public void setTemplateIds(ArrayList<Long> templateIds) {
+		this.templateIds = templateIds;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@@ -72,6 +99,8 @@ public class SysCompanyTemplate extends BaseEntity
             .append("companyName", getCompanyName())
             .append("template", getTemplate())
             .append("companyId", getCompanyId())
+            .append("templateList", getTemplateList())
+            .append("templateIds", getTemplateIds())
             .toString();
     }
 }

+ 9 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRepoMapper.java

@@ -19,6 +19,15 @@ public interface SysRepoMapper
      */
     public SysRepo selectSysRepoByRepoId(Long repoId);
 
+    /**
+     * 通过主键列表查询文件仓库信息列表
+     *
+     * @param repoIds 需要查询的文件仓库主键集合
+     * @return 结果
+     */
+
+    public List<SysRepo> selectSysRepoListByRepoIds(Long[] repoIds);
+
     /**
      * 根据条件查询仓库文件列表
      * 

+ 9 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRepoService.java

@@ -19,6 +19,15 @@ public interface ISysRepoService
      */
     public SysRepo selectSysRepoByRepoId(Long repoId);
 
+
+    /**
+     * 通过主键列表查询文件仓库信息列表
+     *
+     * @param repoIds 需要查询的文件仓库主键集合
+     * @return 结果
+     */
+
+    public List<SysRepo> selectSysRepoListByRepoIds(Long[] repoIds);
     /**
      * 查询文件仓库列表
      * 

+ 10 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRepoServiceImpl.java

@@ -32,6 +32,16 @@ public class SysRepoServiceImpl implements ISysRepoService
         return sysRepoMapper.selectSysRepoByRepoId(repoId);
     }
 
+    /**
+     * 通过主键列表查询文件仓库信息列表
+     *
+     * @param repoIds 需要查询的文件仓库主键集合
+     * @return 结果
+     */
+
+    public List<SysRepo> selectSysRepoListByRepoIds(Long[] repoIds){
+        return sysRepoMapper.selectSysRepoListByRepoIds(repoIds);
+    }
     /**
      * 查询仓库文件列表
      * 

+ 12 - 1
ruoyi-system/src/main/resources/mapper/system/SysCompanyTemplateMapper.xml

@@ -9,10 +9,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="companyName"    column="company_name"    />
         <result property="template"    column="template"    />
         <result property="companyId"    column="company_id"    />
+        <result property="updateTime"    column="update_time"    />
+        <result property="updateBy"    column="update_by"    />
     </resultMap>
 
     <sql id="selectSysCompanyTemplateVo">
-        select id, company_name, template, company_id from sys_company_template
+        select id, company_name, template, company_id, update_time, update_by from sys_company_template
     </sql>
 
     <select id="selectSysCompanyTemplateList" parameterType="SysCompanyTemplate" resultMap="SysCompanyTemplateResult">
@@ -21,6 +23,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="companyName != null  and companyName != ''"> and company_name like concat('%', #{companyName}, '%')</if>
             <if test="template != null  and template != ''"> and template = #{template}</if>
             <if test="companyId != null "> and company_id = #{companyId}</if>
+            <if test="updateTime != null"> and update_time = #{updateTime}</if>
+            <if test="updateBy != null and updateBy !=''"> and update_by = #{updateBy}</if>
         </where>
     </select>
     
@@ -35,11 +39,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="companyName != null and companyName != ''">company_name,</if>
             <if test="template != null">template,</if>
             <if test="companyId != null">company_id,</if>
+            <if test="updateTime != null">update_time,</if>
+            <if test="updateBy != null and updateBy !=''">update_by,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="companyName != null and companyName != ''">#{companyName},</if>
             <if test="template != null">#{template},</if>
             <if test="companyId != null">#{companyId},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="updateBy != null and updateBy !=''">#{updateBy},</if>
          </trim>
     </insert>
 
@@ -49,6 +57,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="companyName != null and companyName != ''">company_name = #{companyName},</if>
             <if test="template != null">template = #{template},</if>
             <if test="companyId != null">company_id = #{companyId},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+            <if test="updateBy != null and updateBy !=''">update_by = #{updateBy},</if>
         </trim>
         where id = #{id}
     </update>
@@ -63,4 +73,5 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{id}
         </foreach>
     </delete>
+
 </mapper>

+ 8 - 0
ruoyi-system/src/main/resources/mapper/system/SysRepoMapper.xml

@@ -111,4 +111,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{repoId}
         </foreach>
     </delete>
+
+    <select id="selectSysRepoListByRepoIds" parameterType="String" resultMap="SysRepoResult">
+        <include refid="selectSysRepoVo"/>
+        where repo_Id in
+        <foreach item="repoId" collection="array" open="(" separator="," close=")">
+            #{repoId}
+        </foreach>
+    </select>
 </mapper>

+ 4 - 2
sql/sys_company_template.sql

@@ -11,7 +11,7 @@
  Target Server Version : 50741
  File Encoding         : 65001
 
- Date: 21/05/2025 14:55:28
+ Date: 21/05/2025 17:01:00
 */
 
 SET NAMES utf8mb4;
@@ -26,7 +26,9 @@ CREATE TABLE `sys_company_template`  (
   `company_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '企业名称',
   `template` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT '模板配置',
   `company_id` bigint(20) DEFAULT NULL COMMENT '企业id',
+  `update_time` datetime(0) DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '更新时间',
+  `update_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '更改人',
   PRIMARY KEY (`id`) USING BTREE
-) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '企业模板表' ROW_FORMAT = Dynamic;
+) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '企业模板表' ROW_FORMAT = Dynamic;
 
 SET FOREIGN_KEY_CHECKS = 1;