LIVE_YE 1 éve
szülő
commit
287066ad50

+ 125 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/category/IndustryCategoryController.java

@@ -0,0 +1,125 @@
+package com.ruoyi.web.controller.category;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+
+import com.ruoyi.common.utils.StringUtils;
+import org.apache.commons.lang3.ArrayUtils;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.core.domain.entity.IndustryCategory;
+import com.ruoyi.system.service.IIndustryCategoryService;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.page.TableDataInfo;
+
+/**
+ * 行业类别Controller
+ *
+ * @author ruoyi
+ * @date 2024-04-23
+ */
+@RestController
+@RequestMapping("/system/category")
+public class IndustryCategoryController extends BaseController
+{
+    @Autowired
+    private IIndustryCategoryService industryCategoryService;
+
+/**
+ * 查询行业类别列表
+ */
+@PreAuthorize("@ss.hasPermi('system:category:list')")
+@GetMapping("/list")
+    public TableDataInfo list(IndustryCategory industryCategory)
+    {
+        //startPage();
+        List<IndustryCategory> list = industryCategoryService.selectIndustryCategoryList(industryCategory);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出行业类别列表
+     */
+    @PreAuthorize("@ss.hasPermi('system:category:export')")
+    @Log(title = "行业类别", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, IndustryCategory industryCategory)
+    {
+        List<IndustryCategory> list = industryCategoryService.selectIndustryCategoryList(industryCategory);
+        ExcelUtil<IndustryCategory> util = new ExcelUtil<IndustryCategory>(IndustryCategory.class);
+        util.exportExcel(response, list, "行业类别数据");
+    }
+
+    /**
+     * 获取行业类别详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('system:category:query')")
+    @GetMapping(value = "/{categoryId}")
+    public AjaxResult getInfo(@PathVariable("categoryId") Long categoryId)
+    {
+        return success(industryCategoryService.selectIndustryCategoryByCategoryId(categoryId));
+    }
+
+    /**
+     * 新增行业类别
+     */
+    @PreAuthorize("@ss.hasPermi('system:category:add')")
+    @Log(title = "行业类别", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody IndustryCategory industryCategory)
+    {
+        return toAjax(industryCategoryService.insertIndustryCategory(industryCategory));
+    }
+
+    /**
+     * 修改行业类别
+     */
+    @PreAuthorize("@ss.hasPermi('system:category:edit')")
+    @Log(title = "行业类别", businessType = BusinessType.UPDATE)
+    @PostMapping("/put")
+    public AjaxResult edit(@RequestBody IndustryCategory industryCategory)
+    {
+        return toAjax(industryCategoryService.updateIndustryCategory(industryCategory));
+    }
+
+    /**
+     * 删除行业类别
+     */
+    @PreAuthorize("@ss.hasPermi('system:category:remove')")
+    @Log(title = "行业类别", businessType = BusinessType.DELETE)
+    @GetMapping("/delete/{categoryIds}")
+    public AjaxResult remove(@PathVariable Long[] categoryIds)
+    {
+        return toAjax(industryCategoryService.deleteIndustryCategoryByCategoryIds(categoryIds));
+    }
+
+    /**
+     * 获取提案类别树列表
+     */
+    @GetMapping("/categoryTree")
+    public AjaxResult categoryTree(IndustryCategory industryCategory)
+    {
+        return success(industryCategoryService.selectCategoryTreeList(industryCategory));
+    }
+
+    /**
+     * 查询提案类别列表(排除节点)
+     */
+    @GetMapping("/list/exclude/{categoryId}")
+    public AjaxResult excludeChild(@PathVariable(value = "categoryId", required = false) Long categoryId)
+    {
+        List<IndustryCategory> list = industryCategoryService.selectIndustryCategoryList(new IndustryCategory());
+        list.removeIf(d -> d.getCategoryId().intValue() == categoryId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), categoryId + ""));
+        return success(list);
+    }
+}

+ 8 - 0
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeSelect.java

@@ -4,6 +4,7 @@ import java.io.Serializable;
 import java.util.List;
 import java.util.stream.Collectors;
 import com.fasterxml.jackson.annotation.JsonInclude;
+import com.ruoyi.common.core.domain.entity.IndustryCategory;
 import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.core.domain.entity.SysMenu;
 
@@ -38,6 +39,13 @@ public class TreeSelect implements Serializable
         this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
     }
 
+    public TreeSelect(IndustryCategory category)
+    {
+        this.id = category.getCategoryId();
+        this.label = category.getCategoryName();
+        this.children = category.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
+    }
+
     public TreeSelect(SysMenu menu)
     {
         this.id = menu.getMenuId();

+ 138 - 0
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/IndustryCategory.java

@@ -0,0 +1,138 @@
+package com.ruoyi.common.core.domain.entity;
+
+import org.apache.commons.lang3.builder.ToStringBuilder;
+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;
+
+/**
+ * 行业类别对象 industry_category
+ * 
+ * @author ruoyi
+ * @date 2024-04-23
+ */
+public class IndustryCategory extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** 行业类别id */
+    private Long categoryId;
+
+    /** 父类id */
+    @Excel(name = "父类id")
+    private Long parentId;
+
+    /** 祖级列表 */
+    @Excel(name = "祖级列表")
+    private String ancestors;
+
+    /** 行业类别名称 */
+    @Excel(name = "行业类别名称")
+    private String categoryName;
+
+    /** 显示顺序 */
+    @Excel(name = "显示顺序")
+    private Integer orderNum;
+
+    /** 状态(0正常 1停用) */
+    @Excel(name = "状态", readConverterExp = "0=正常,1=停用")
+    private String status;
+
+    /** 删除标志(0代表存在 2代表删除) */
+    private String delFlag;
+
+    /** 子部门 */
+    private List<IndustryCategory> children = new ArrayList<IndustryCategory>();
+
+    public List<IndustryCategory> getChildren() {
+        return children;
+    }
+
+    public void setChildren(List<IndustryCategory> children) {
+        this.children = children;
+    }
+
+    public void setCategoryId(Long categoryId)
+    {
+        this.categoryId = categoryId;
+    }
+
+    public Long getCategoryId() 
+    {
+        return categoryId;
+    }
+    public void setParentId(Long parentId) 
+    {
+        this.parentId = parentId;
+    }
+
+    public Long getParentId() 
+    {
+        return parentId;
+    }
+    public void setAncestors(String ancestors) 
+    {
+        this.ancestors = ancestors;
+    }
+
+    public String getAncestors() 
+    {
+        return ancestors;
+    }
+    public void setCategoryName(String categoryName) 
+    {
+        this.categoryName = categoryName;
+    }
+
+    public String getCategoryName() 
+    {
+        return categoryName;
+    }
+    public void setOrderNum(Integer orderNum) 
+    {
+        this.orderNum = orderNum;
+    }
+
+    public Integer getOrderNum() 
+    {
+        return orderNum;
+    }
+    public void setStatus(String status) 
+    {
+        this.status = status;
+    }
+
+    public String getStatus() 
+    {
+        return status;
+    }
+    public void setDelFlag(String delFlag) 
+    {
+        this.delFlag = delFlag;
+    }
+
+    public String getDelFlag() 
+    {
+        return delFlag;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("categoryId", getCategoryId())
+            .append("parentId", getParentId())
+            .append("ancestors", getAncestors())
+            .append("categoryName", getCategoryName())
+            .append("orderNum", getOrderNum())
+            .append("status", getStatus())
+            .append("delFlag", getDelFlag())
+            .append("createBy", getCreateBy())
+            .append("createTime", getCreateTime())
+            .append("updateBy", getUpdateBy())
+            .append("updateTime", getUpdateTime())
+            .toString();
+    }
+}

BIN
ruoyi-common/src/main/java/resources/word/zdd.docx


+ 61 - 0
ruoyi-system/src/main/java/com/ruoyi/system/mapper/IndustryCategoryMapper.java

@@ -0,0 +1,61 @@
+package com.ruoyi.system.mapper;
+
+import java.util.List;
+import com.ruoyi.common.core.domain.entity.IndustryCategory;
+
+/**
+ * 行业类别Mapper接口
+ * 
+ * @author ruoyi
+ * @date 2024-04-23
+ */
+public interface IndustryCategoryMapper 
+{
+    /**
+     * 查询行业类别
+     * 
+     * @param categoryId 行业类别主键
+     * @return 行业类别
+     */
+    public IndustryCategory selectIndustryCategoryByCategoryId(Long categoryId);
+
+    /**
+     * 查询行业类别列表
+     * 
+     * @param industryCategory 行业类别
+     * @return 行业类别集合
+     */
+    public List<IndustryCategory> selectIndustryCategoryList(IndustryCategory industryCategory);
+
+    /**
+     * 新增行业类别
+     * 
+     * @param industryCategory 行业类别
+     * @return 结果
+     */
+    public int insertIndustryCategory(IndustryCategory industryCategory);
+
+    /**
+     * 修改行业类别
+     * 
+     * @param industryCategory 行业类别
+     * @return 结果
+     */
+    public int updateIndustryCategory(IndustryCategory industryCategory);
+
+    /**
+     * 删除行业类别
+     * 
+     * @param categoryId 行业类别主键
+     * @return 结果
+     */
+    public int deleteIndustryCategoryByCategoryId(Long categoryId);
+
+    /**
+     * 批量删除行业类别
+     * 
+     * @param categoryIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteIndustryCategoryByCategoryIds(Long[] categoryIds);
+}

+ 67 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/IIndustryCategoryService.java

@@ -0,0 +1,67 @@
+package com.ruoyi.system.service;
+
+import java.util.List;
+
+import com.ruoyi.common.core.domain.TreeSelect;
+import com.ruoyi.common.core.domain.entity.IndustryCategory;
+
+/**
+ * 行业类别Service接口
+ * 
+ * @author ruoyi
+ * @date 2024-04-23
+ */
+public interface IIndustryCategoryService 
+{
+    /**
+     * 查询行业类别
+     * 
+     * @param categoryId 行业类别主键
+     * @return 行业类别
+     */
+    public IndustryCategory selectIndustryCategoryByCategoryId(Long categoryId);
+
+    /**
+     * 查询行业类别列表
+     * 
+     * @param industryCategory 行业类别
+     * @return 行业类别集合
+     */
+    public List<IndustryCategory> selectIndustryCategoryList(IndustryCategory industryCategory);
+
+    /**
+     * 新增行业类别
+     * 
+     * @param industryCategory 行业类别
+     * @return 结果
+     */
+    public int insertIndustryCategory(IndustryCategory industryCategory);
+
+    /**
+     * 修改行业类别
+     * 
+     * @param industryCategory 行业类别
+     * @return 结果
+     */
+    public int updateIndustryCategory(IndustryCategory industryCategory);
+
+    /**
+     * 批量删除行业类别
+     * 
+     * @param categoryIds 需要删除的行业类别主键集合
+     * @return 结果
+     */
+    public int deleteIndustryCategoryByCategoryIds(Long[] categoryIds);
+
+    /**
+     * 删除行业类别信息
+     * 
+     * @param categoryId 行业类别主键
+     * @return 结果
+     */
+    public int deleteIndustryCategoryByCategoryId(Long categoryId);
+
+    List<TreeSelect> selectCategoryTreeList(IndustryCategory industryCategory);
+
+    public List<TreeSelect> buildCategoryTreeSelect(List<IndustryCategory> industryCategorys);
+}

+ 180 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/IndustryCategoryServiceImpl.java

@@ -0,0 +1,180 @@
+package com.ruoyi.system.service.impl;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import com.ruoyi.common.core.domain.TreeSelect;
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.spring.SpringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.system.mapper.IndustryCategoryMapper;
+import com.ruoyi.common.core.domain.entity.IndustryCategory;
+import com.ruoyi.system.service.IIndustryCategoryService;
+
+/**
+ * 行业类别Service业务层处理
+ * 
+ * @author ruoyi
+ * @date 2024-04-23
+ */
+@Service
+public class IndustryCategoryServiceImpl implements IIndustryCategoryService 
+{
+    @Autowired
+    private IndustryCategoryMapper industryCategoryMapper;
+
+    /**
+     * 查询行业类别
+     * 
+     * @param categoryId 行业类别主键
+     * @return 行业类别
+     */
+    @Override
+    public IndustryCategory selectIndustryCategoryByCategoryId(Long categoryId)
+    {
+        return industryCategoryMapper.selectIndustryCategoryByCategoryId(categoryId);
+    }
+
+    /**
+     * 查询行业类别列表
+     * 
+     * @param industryCategory 行业类别
+     * @return 行业类别
+     */
+    @Override
+    public List<IndustryCategory> selectIndustryCategoryList(IndustryCategory industryCategory)
+    {
+        return industryCategoryMapper.selectIndustryCategoryList(industryCategory);
+    }
+
+    /**
+     * 新增行业类别
+     * 
+     * @param industryCategory 行业类别
+     * @return 结果
+     */
+    @Override
+    public int insertIndustryCategory(IndustryCategory industryCategory)
+    {
+        industryCategory.setCreateTime(DateUtils.getNowDate());
+        return industryCategoryMapper.insertIndustryCategory(industryCategory);
+    }
+
+    /**
+     * 修改行业类别
+     * 
+     * @param industryCategory 行业类别
+     * @return 结果
+     */
+    @Override
+    public int updateIndustryCategory(IndustryCategory industryCategory)
+    {
+        industryCategory.setUpdateTime(DateUtils.getNowDate());
+        return industryCategoryMapper.updateIndustryCategory(industryCategory);
+    }
+
+    /**
+     * 批量删除行业类别
+     * 
+     * @param categoryIds 需要删除的行业类别主键
+     * @return 结果
+     */
+    @Override
+    public int deleteIndustryCategoryByCategoryIds(Long[] categoryIds)
+    {
+        return industryCategoryMapper.deleteIndustryCategoryByCategoryIds(categoryIds);
+    }
+
+    /**
+     * 删除行业类别信息
+     * 
+     * @param categoryId 行业类别主键
+     * @return 结果
+     */
+    @Override
+    public int deleteIndustryCategoryByCategoryId(Long categoryId)
+    {
+        return industryCategoryMapper.deleteIndustryCategoryByCategoryId(categoryId);
+    }
+
+    @Override
+    public List<TreeSelect> selectCategoryTreeList(IndustryCategory industryCategory) {
+        List<IndustryCategory> industryCategorys = SpringUtils.getAopProxy(this).selectIndustryCategoryList(industryCategory);
+        return buildCategoryTreeSelect(industryCategorys);
+    }
+
+    @Override
+    public List<TreeSelect> buildCategoryTreeSelect(List<IndustryCategory> industryCategorys) {
+        List<IndustryCategory> categoryTrees = buildCategoryTree(industryCategorys);
+        return categoryTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
+    }
+
+    /**
+     * 构建前端所需要树结构
+     *
+     * @param
+     * @return 树结构列表
+     */
+    private List<IndustryCategory> buildCategoryTree(List<IndustryCategory> industryCategorys) {
+        List<IndustryCategory> returnList = new ArrayList<IndustryCategory>();
+        List<Long> tempList = industryCategorys.stream().map(IndustryCategory::getCategoryId).collect(Collectors.toList());
+        for (IndustryCategory category : industryCategorys)
+        {
+            // 如果是顶级节点, 遍历该父节点的所有子节点
+            if (!tempList.contains(category.getParentId()))
+            {
+                recursionFn(industryCategorys, category);
+                returnList.add(category);
+            }
+        }
+        if (returnList.isEmpty())
+        {
+            returnList = industryCategorys;
+        }
+        return returnList;
+    }
+
+    /**
+     * 递归列表
+     */
+    private void recursionFn(List<IndustryCategory> industryCategorys, IndustryCategory category) {
+        // 得到子节点列表
+        List<IndustryCategory> childList = getChildList(industryCategorys, category);
+        category.setChildren(childList);
+        for (IndustryCategory tChild : childList)
+        {
+            if (hasChild(industryCategorys, tChild))
+            {
+                recursionFn(industryCategorys, tChild);
+            }
+        }
+    }
+
+    /**
+     * 得到子节点列表
+     */
+    private List<IndustryCategory> getChildList(List<IndustryCategory> industryCategorys, IndustryCategory category) {
+        List<IndustryCategory> tlist = new ArrayList<IndustryCategory>();
+        Iterator<IndustryCategory> it = industryCategorys.iterator();
+        while (it.hasNext())
+        {
+            IndustryCategory n = (IndustryCategory) it.next();
+            if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == category.getCategoryId().longValue())
+            {
+                tlist.add(n);
+            }
+        }
+        return tlist;
+    }
+
+    /**
+     * 判断是否有子节点
+     */
+    private boolean hasChild(List<IndustryCategory> industryCategorys, IndustryCategory tChild) {
+        return getChildList(industryCategorys, tChild).size() > 0;
+    }
+}

+ 96 - 0
ruoyi-system/src/main/resources/mapper/system/IndustryCategoryMapper.xml

@@ -0,0 +1,96 @@
+<?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.ruoyi.system.mapper.IndustryCategoryMapper">
+    
+    <resultMap type="IndustryCategory" id="IndustryCategoryResult">
+        <result property="categoryId"    column="category_id"    />
+        <result property="parentId"    column="parent_id"    />
+        <result property="ancestors"    column="ancestors"    />
+        <result property="categoryName"    column="category_name"    />
+        <result property="orderNum"    column="order_num"    />
+        <result property="status"    column="status"    />
+        <result property="delFlag"    column="del_flag"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="createTime"    column="create_time"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="updateTime"    column="update_time"    />
+    </resultMap>
+
+    <sql id="selectIndustryCategoryVo">
+        select category_id, parent_id, ancestors, category_name, order_num, status, del_flag, create_by, create_time, update_by, update_time from industry_category
+    </sql>
+
+    <select id="selectIndustryCategoryList" parameterType="IndustryCategory" resultMap="IndustryCategoryResult">
+        <include refid="selectIndustryCategoryVo"/>
+        <where>  
+            <if test="parentId != null "> and parent_id = #{parentId}</if>
+            <if test="ancestors != null  and ancestors != ''"> and ancestors = #{ancestors}</if>
+            <if test="categoryName != null  and categoryName != ''"> and category_name like concat('%', #{categoryName}, '%')</if>
+            <if test="orderNum != null "> and order_num = #{orderNum}</if>
+            <if test="status != null  and status != ''"> and status = #{status}</if>
+        </where>
+    </select>
+    
+    <select id="selectIndustryCategoryByCategoryId" parameterType="Long" resultMap="IndustryCategoryResult">
+        <include refid="selectIndustryCategoryVo"/>
+        where category_id = #{categoryId}
+    </select>
+        
+    <insert id="insertIndustryCategory" parameterType="IndustryCategory" useGeneratedKeys="true" keyProperty="categoryId">
+        insert into industry_category
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="parentId != null">parent_id,</if>
+            <if test="ancestors != null">ancestors,</if>
+            <if test="categoryName != null">category_name,</if>
+            <if test="orderNum != null">order_num,</if>
+            <if test="status != null">status,</if>
+            <if test="delFlag != null">del_flag,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="createTime != null">create_time,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="updateTime != null">update_time,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="parentId != null">#{parentId},</if>
+            <if test="ancestors != null">#{ancestors},</if>
+            <if test="categoryName != null">#{categoryName},</if>
+            <if test="orderNum != null">#{orderNum},</if>
+            <if test="status != null">#{status},</if>
+            <if test="delFlag != null">#{delFlag},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+         </trim>
+    </insert>
+
+    <update id="updateIndustryCategory" parameterType="IndustryCategory">
+        update industry_category
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="parentId != null">parent_id = #{parentId},</if>
+            <if test="ancestors != null">ancestors = #{ancestors},</if>
+            <if test="categoryName != null">category_name = #{categoryName},</if>
+            <if test="orderNum != null">order_num = #{orderNum},</if>
+            <if test="status != null">status = #{status},</if>
+            <if test="delFlag != null">del_flag = #{delFlag},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="createTime != null">create_time = #{createTime},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="updateTime != null">update_time = #{updateTime},</if>
+        </trim>
+        where category_id = #{categoryId}
+    </update>
+
+    <delete id="deleteIndustryCategoryByCategoryId" parameterType="Long">
+        delete from industry_category where category_id = #{categoryId}
+    </delete>
+
+    <delete id="deleteIndustryCategoryByCategoryIds" parameterType="String">
+        delete from industry_category where category_id in 
+        <foreach item="categoryId" collection="array" open="(" separator="," close=")">
+            #{categoryId}
+        </foreach>
+    </delete>
+</mapper>