Browse Source

仓库模块

李英俊ya 1 month ago
parent
commit
9cb2d45985

+ 92 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRepoController.java

@@ -0,0 +1,92 @@
+package com.ruoyi.web.controller.system;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+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.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+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.system.domain.SysRepo;
+import com.ruoyi.system.service.ISysRepoService;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.page.TableDataInfo;
+
+/**
+ * 仓库管理Controller
+ * 
+ * @author ruoyi
+ * @date 2025-05-15
+ */
+@RestController
+@RequestMapping("/system/repo")
+public class SysRepoController extends BaseController
+{
+    @Autowired
+    private ISysRepoService sysRepoService;
+
+    /**
+     * 查询仓库列表
+     */
+    @PreAuthorize("@ss.hasPermi('system:repo:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(SysRepo sysRepo)
+    {
+        startPage();
+        List<SysRepo> list = sysRepoService.selectSysRepoList(sysRepo);
+        return getDataTable(list);
+    }
+
+
+    /**
+     * 获取仓库详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('system:repo:query')")
+    @GetMapping(value = "/{repoId}")
+    public AjaxResult getInfo(@PathVariable("repoId") Long repoId)
+    {
+        return success(sysRepoService.selectSysRepoByRepoId(repoId));
+    }
+
+    /**
+     * 新增仓库
+     */
+    @PreAuthorize("@ss.hasPermi('system:repo:add')")
+    @Log(title = "新增仓库", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody SysRepo sysRepo)
+    {
+        return toAjax(sysRepoService.insertSysRepo(sysRepo));
+    }
+
+    /**
+     * 修改仓库
+     */
+    @PreAuthorize("@ss.hasPermi('system:repo:edit')")
+    @Log(title = "修改仓库", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody SysRepo sysRepo)
+    {
+        return toAjax(sysRepoService.updateSysRepo(sysRepo));
+    }
+
+    /**
+     * 删除仓库
+     */
+    @PreAuthorize("@ss.hasPermi('system:repo:remove')")
+    @Log(title = "删除仓库", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{repoIds}")
+    public AjaxResult remove(@PathVariable Long[] repoIds)
+    {
+        return toAjax(sysRepoService.deleteSysRepoByRepoIds(repoIds));
+    }
+}

+ 146 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRepo.java

@@ -0,0 +1,146 @@
+package com.ruoyi.system.domain;
+
+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;
+
+/**
+ * 【请填写功能名称】对象 sys_repo
+ * 
+ * @author ruoyi
+ * @date 2025-05-15
+ */
+public class SysRepo extends BaseEntity
+{
+    private static final long serialVersionUID = 1L;
+
+    /** $column.columnComment */
+    private Long repoId;
+
+    /** 名称 */
+    @Excel(name = "名称")
+    private String repoName;
+
+    /** 类别(目录、文件) */
+    @Excel(name = "类别", readConverterExp = "目=录、文件")
+    private String repoType;
+
+    /** 状态(私密、公开) */
+    @Excel(name = "状态", readConverterExp = "私=密、公开")
+    private String repoStatus;
+
+    /** 父级 */
+    @Excel(name = "父级")
+    private Long parentId;
+
+    /** 等级(一级只能是目录类型) */
+    @Excel(name = "等级", readConverterExp = "一=级只能是目录类型")
+    private Long repoLevel;
+
+    /** 描述 */
+    @Excel(name = "描述")
+    private String description;
+
+    /** 是否删除 */
+    @Excel(name = "是否删除")
+    private Integer isDelete;
+
+    public void setRepoId(Long repoId) 
+    {
+        this.repoId = repoId;
+    }
+
+    public Long getRepoId() 
+    {
+        return repoId;
+    }
+
+    public void setRepoName(String repoName) 
+    {
+        this.repoName = repoName;
+    }
+
+    public String getRepoName() 
+    {
+        return repoName;
+    }
+
+    public void setRepoType(String repoType) 
+    {
+        this.repoType = repoType;
+    }
+
+    public String getRepoType() 
+    {
+        return repoType;
+    }
+
+    public void setRepoStatus(String repoStatus) 
+    {
+        this.repoStatus = repoStatus;
+    }
+
+    public String getRepoStatus() 
+    {
+        return repoStatus;
+    }
+
+    public void setParentId(Long parentId) 
+    {
+        this.parentId = parentId;
+    }
+
+    public Long getParentId() 
+    {
+        return parentId;
+    }
+
+    public void setRepoLevel(Long repoLevel) 
+    {
+        this.repoLevel = repoLevel;
+    }
+
+    public Long getRepoLevel() 
+    {
+        return repoLevel;
+    }
+
+    public void setDescription(String description) 
+    {
+        this.description = description;
+    }
+
+    public String getDescription() 
+    {
+        return description;
+    }
+
+    public void setIsDelete(Integer isDelete) 
+    {
+        this.isDelete = isDelete;
+    }
+
+    public Integer getIsDelete() 
+    {
+        return isDelete;
+    }
+
+    @Override
+    public String toString() {
+        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+            .append("repoId", getRepoId())
+            .append("repoName", getRepoName())
+            .append("createBy", getCreateBy())
+            .append("updateBy", getUpdateBy())
+            .append("repoType", getRepoType())
+            .append("repoStatus", getRepoStatus())
+            .append("createTime", getCreateTime())
+            .append("updateTime", getUpdateTime())
+            .append("parentId", getParentId())
+            .append("repoLevel", getRepoLevel())
+            .append("description", getDescription())
+            .append("isDelete", getIsDelete())
+            .toString();
+    }
+}

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

@@ -0,0 +1,61 @@
+package com.ruoyi.system.mapper;
+
+import java.util.List;
+import com.ruoyi.system.domain.SysRepo;
+
+/**
+ * 【请填写功能名称】Mapper接口
+ * 
+ * @author ruoyi
+ * @date 2025-05-15
+ */
+public interface SysRepoMapper 
+{
+    /**
+     * 查询【请填写功能名称】
+     * 
+     * @param repoId 【请填写功能名称】主键
+     * @return 【请填写功能名称】
+     */
+    public SysRepo selectSysRepoByRepoId(Long repoId);
+
+    /**
+     * 查询【请填写功能名称】列表
+     * 
+     * @param sysRepo 【请填写功能名称】
+     * @return 【请填写功能名称】集合
+     */
+    public List<SysRepo> selectSysRepoList(SysRepo sysRepo);
+
+    /**
+     * 新增【请填写功能名称】
+     * 
+     * @param sysRepo 【请填写功能名称】
+     * @return 结果
+     */
+    public int insertSysRepo(SysRepo sysRepo);
+
+    /**
+     * 修改【请填写功能名称】
+     * 
+     * @param sysRepo 【请填写功能名称】
+     * @return 结果
+     */
+    public int updateSysRepo(SysRepo sysRepo);
+
+    /**
+     * 删除【请填写功能名称】
+     * 
+     * @param repoId 【请填写功能名称】主键
+     * @return 结果
+     */
+    public int deleteSysRepoByRepoId(Long repoId);
+
+    /**
+     * 批量删除【请填写功能名称】
+     * 
+     * @param repoIds 需要删除的数据主键集合
+     * @return 结果
+     */
+    public int deleteSysRepoByRepoIds(Long[] repoIds);
+}

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

@@ -0,0 +1,61 @@
+package com.ruoyi.system.service;
+
+import java.util.List;
+import com.ruoyi.system.domain.SysRepo;
+
+/**
+ * 【请填写功能名称】Service接口
+ * 
+ * @author ruoyi
+ * @date 2025-05-15
+ */
+public interface ISysRepoService 
+{
+    /**
+     * 查询【请填写功能名称】
+     * 
+     * @param repoId 【请填写功能名称】主键
+     * @return 【请填写功能名称】
+     */
+    public SysRepo selectSysRepoByRepoId(Long repoId);
+
+    /**
+     * 查询【请填写功能名称】列表
+     * 
+     * @param sysRepo 【请填写功能名称】
+     * @return 【请填写功能名称】集合
+     */
+    public List<SysRepo> selectSysRepoList(SysRepo sysRepo);
+
+    /**
+     * 新增【请填写功能名称】
+     * 
+     * @param sysRepo 【请填写功能名称】
+     * @return 结果
+     */
+    public int insertSysRepo(SysRepo sysRepo);
+
+    /**
+     * 修改【请填写功能名称】
+     * 
+     * @param sysRepo 【请填写功能名称】
+     * @return 结果
+     */
+    public int updateSysRepo(SysRepo sysRepo);
+
+    /**
+     * 批量删除【请填写功能名称】
+     * 
+     * @param repoIds 需要删除的【请填写功能名称】主键集合
+     * @return 结果
+     */
+    public int deleteSysRepoByRepoIds(Long[] repoIds);
+
+    /**
+     * 删除【请填写功能名称】信息
+     * 
+     * @param repoId 【请填写功能名称】主键
+     * @return 结果
+     */
+    public int deleteSysRepoByRepoId(Long repoId);
+}

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

@@ -0,0 +1,96 @@
+package com.ruoyi.system.service.impl;
+
+import java.util.List;
+import com.ruoyi.common.utils.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import com.ruoyi.system.mapper.SysRepoMapper;
+import com.ruoyi.system.domain.SysRepo;
+import com.ruoyi.system.service.ISysRepoService;
+
+/**
+ * 【请填写功能名称】Service业务层处理
+ * 
+ * @author ruoyi
+ * @date 2025-05-15
+ */
+@Service
+public class SysRepoServiceImpl implements ISysRepoService 
+{
+    @Autowired
+    private SysRepoMapper sysRepoMapper;
+
+    /**
+     * 查询【请填写功能名称】
+     * 
+     * @param repoId 【请填写功能名称】主键
+     * @return 【请填写功能名称】
+     */
+    @Override
+    public SysRepo selectSysRepoByRepoId(Long repoId)
+    {
+        return sysRepoMapper.selectSysRepoByRepoId(repoId);
+    }
+
+    /**
+     * 查询【请填写功能名称】列表
+     * 
+     * @param sysRepo 【请填写功能名称】
+     * @return 【请填写功能名称】
+     */
+    @Override
+    public List<SysRepo> selectSysRepoList(SysRepo sysRepo)
+    {
+        return sysRepoMapper.selectSysRepoList(sysRepo);
+    }
+
+    /**
+     * 新增【请填写功能名称】
+     * 
+     * @param sysRepo 【请填写功能名称】
+     * @return 结果
+     */
+    @Override
+    public int insertSysRepo(SysRepo sysRepo)
+    {
+        sysRepo.setCreateTime(DateUtils.getNowDate());
+        return sysRepoMapper.insertSysRepo(sysRepo);
+    }
+
+    /**
+     * 修改【请填写功能名称】
+     * 
+     * @param sysRepo 【请填写功能名称】
+     * @return 结果
+     */
+    @Override
+    public int updateSysRepo(SysRepo sysRepo)
+    {
+        sysRepo.setUpdateTime(DateUtils.getNowDate());
+        return sysRepoMapper.updateSysRepo(sysRepo);
+    }
+
+    /**
+     * 批量删除【请填写功能名称】
+     * 
+     * @param repoIds 需要删除的【请填写功能名称】主键
+     * @return 结果
+     */
+    @Override
+    public int deleteSysRepoByRepoIds(Long[] repoIds)
+    {
+        return sysRepoMapper.deleteSysRepoByRepoIds(repoIds);
+    }
+
+    /**
+     * 删除【请填写功能名称】信息
+     * 
+     * @param repoId 【请填写功能名称】主键
+     * @return 结果
+     */
+    @Override
+    public int deleteSysRepoByRepoId(Long repoId)
+    {
+        return sysRepoMapper.deleteSysRepoByRepoId(repoId);
+    }
+}

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

@@ -0,0 +1,104 @@
+<?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.SysRepoMapper">
+    
+    <resultMap type="SysRepo" id="SysRepoResult">
+        <result property="repoId"    column="repo_Id"    />
+        <result property="repoName"    column="repo_name"    />
+        <result property="createBy"    column="create_by"    />
+        <result property="updateBy"    column="update_by"    />
+        <result property="repoType"    column="repo_type"    />
+        <result property="repoStatus"    column="repo_status"    />
+        <result property="createTime"    column="create_Time"    />
+        <result property="updateTime"    column="update_Time"    />
+        <result property="parentId"    column="parent_id"    />
+        <result property="repoLevel"    column="repo_level"    />
+        <result property="description"    column="description"    />
+        <result property="isDelete"    column="is_delete"    />
+    </resultMap>
+
+    <sql id="selectSysRepoVo">
+        select repo_Id, repo_name, create_by, update_by, repo_type, repo_status, create_Time, update_Time, parent_id, repo_level, description, is_delete from sys_repo
+    </sql>
+
+    <select id="selectSysRepoList" parameterType="SysRepo" resultMap="SysRepoResult">
+        <include refid="selectSysRepoVo"/>
+        <where>  
+            <if test="repoName != null  and repoName != ''"> and repo_name like concat('%', #{repoName}, '%')</if>
+            <if test="repoType != null  and repoType != ''"> and repo_type = #{repoType}</if>
+            <if test="repoStatus != null  and repoStatus != ''"> and repo_status = #{repoStatus}</if>
+            <if test="createTime != null "> and create_Time = #{createTime}</if>
+            <if test="updateTime != null "> and update_Time = #{updateTime}</if>
+            <if test="parentId != null "> and parent_id = #{parentId}</if>
+            <if test="repoLevel != null "> and repo_level = #{repoLevel}</if>
+            <if test="description != null  and description != ''"> and description = #{description}</if>
+            <if test="isDelete != null "> and is_delete = #{isDelete}</if>
+        </where>
+    </select>
+    
+    <select id="selectSysRepoByRepoId" parameterType="Long" resultMap="SysRepoResult">
+        <include refid="selectSysRepoVo"/>
+        where repo_Id = #{repoId}
+    </select>
+
+    <insert id="insertSysRepo" parameterType="SysRepo" useGeneratedKeys="true" keyProperty="repoId">
+        insert into sys_repo
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="repoName != null and repoName != ''">repo_name,</if>
+            <if test="createBy != null">create_by,</if>
+            <if test="updateBy != null">update_by,</if>
+            <if test="repoType != null and repoType != ''">repo_type,</if>
+            <if test="repoStatus != null and repoStatus != ''">repo_status,</if>
+            <if test="createTime != null">create_Time,</if>
+            <if test="updateTime != null">update_Time,</if>
+            <if test="parentId != null">parent_id,</if>
+            <if test="repoLevel != null">repo_level,</if>
+            <if test="description != null">description,</if>
+            <if test="isDelete != null">is_delete,</if>
+         </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="repoName != null and repoName != ''">#{repoName},</if>
+            <if test="createBy != null">#{createBy},</if>
+            <if test="updateBy != null">#{updateBy},</if>
+            <if test="repoType != null and repoType != ''">#{repoType},</if>
+            <if test="repoStatus != null and repoStatus != ''">#{repoStatus},</if>
+            <if test="createTime != null">#{createTime},</if>
+            <if test="updateTime != null">#{updateTime},</if>
+            <if test="parentId != null">#{parentId},</if>
+            <if test="repoLevel != null">#{repoLevel},</if>
+            <if test="description != null">#{description},</if>
+            <if test="isDelete != null">#{isDelete},</if>
+         </trim>
+    </insert>
+
+    <update id="updateSysRepo" parameterType="SysRepo">
+        update sys_repo
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="repoName != null and repoName != ''">repo_name = #{repoName},</if>
+            <if test="createBy != null">create_by = #{createBy},</if>
+            <if test="updateBy != null">update_by = #{updateBy},</if>
+            <if test="repoType != null and repoType != ''">repo_type = #{repoType},</if>
+            <if test="repoStatus != null and repoStatus != ''">repo_status = #{repoStatus},</if>
+            <if test="createTime != null">create_Time = #{createTime},</if>
+            <if test="updateTime != null">update_Time = #{updateTime},</if>
+            <if test="parentId != null">parent_id = #{parentId},</if>
+            <if test="repoLevel != null">repo_level = #{repoLevel},</if>
+            <if test="description != null">description = #{description},</if>
+            <if test="isDelete != null">is_delete = #{isDelete},</if>
+        </trim>
+        where repo_Id = #{repoId}
+    </update>
+
+    <delete id="deleteSysRepoByRepoId" parameterType="Long">
+        delete from sys_repo where repo_Id = #{repoId}
+    </delete>
+
+    <delete id="deleteSysRepoByRepoIds" parameterType="String">
+        delete from sys_repo where repo_Id in 
+        <foreach item="repoId" collection="array" open="(" separator="," close=")">
+            #{repoId}
+        </foreach>
+    </delete>
+</mapper>

+ 22 - 0
sql/repoMenu.sql

@@ -0,0 +1,22 @@
+-- 菜单 SQL
+insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
+values('【请填写功能名称】', '3', '1', 'repo', 'system/repo/index', 1, 0, 'C', '0', '0', 'system:repo:list', '#', 'admin', sysdate(), '', null, '【请填写功能名称】菜单');
+
+-- 按钮父菜单ID
+SELECT @parentId := LAST_INSERT_ID();
+
+-- 按钮 SQL
+insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
+values('【请填写功能名称】查询', @parentId, '1',  '#', '', 1, 0, 'F', '0', '0', 'system:repo:query',        '#', 'admin', sysdate(), '', null, '');
+
+insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
+values('【请填写功能名称】新增', @parentId, '2',  '#', '', 1, 0, 'F', '0', '0', 'system:repo:add',          '#', 'admin', sysdate(), '', null, '');
+
+insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
+values('【请填写功能名称】修改', @parentId, '3',  '#', '', 1, 0, 'F', '0', '0', 'system:repo:edit',         '#', 'admin', sysdate(), '', null, '');
+
+insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
+values('【请填写功能名称】删除', @parentId, '4',  '#', '', 1, 0, 'F', '0', '0', 'system:repo:remove',       '#', 'admin', sysdate(), '', null, '');
+
+insert into sys_menu (menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_by, create_time, update_by, update_time, remark)
+values('【请填写功能名称】导出', @parentId, '5',  '#', '', 1, 0, 'F', '0', '0', 'system:repo:export',       '#', 'admin', sysdate(), '', null, '');