部门管理支持批量保存排序

This commit is contained in:
RuoYi
2026-03-21 11:39:53 +08:00
parent 16a78c8113
commit 01fd7be61a
7 changed files with 124 additions and 3 deletions

View File

@@ -108,6 +108,13 @@ public interface SysDeptMapper
*/
public int updateDeptChildren(@Param("depts") List<SysDept> depts);
/**
* 保存部门排序
*
* @param dept 部门信息
*/
public void updateDeptSort(SysDept dept);
/**
* 删除部门管理信息
*

View File

@@ -114,6 +114,14 @@ public interface ISysDeptService
*/
public int updateDept(SysDept dept);
/**
* 保存部门排序
*
* @param deptIds 部门ID数组
* @param orderNums 排序数组
*/
public void updateDeptSort(String[] deptIds, String[] orderNums);
/**
* 删除部门管理信息
*

View File

@@ -6,6 +6,7 @@ import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.TreeSelect;
@@ -280,6 +281,32 @@ public class SysDeptServiceImpl implements ISysDeptService
}
}
/**
* 保存部门排序
*
* @param deptIds 部门ID数组
* @param orderNums 排序数组
*/
@Override
@Transactional
public void updateDeptSort(String[] deptIds, String[] orderNums)
{
try
{
for (int i = 0; i < deptIds.length; i++)
{
SysDept dept = new SysDept();
dept.setDeptId(Convert.toLong(deptIds[i]));
dept.setOrderNum(Convert.toInt(orderNums[i]));
deptMapper.updateDeptSort(dept);
}
}
catch (Exception e)
{
throw new ServiceException("保存排序异常,请联系管理员");
}
}
/**
* 删除部门管理信息
*

View File

@@ -152,8 +152,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</update>
<update id="updateDeptSort" parameterType="SysDept">
update sys_dept set order_num = #{orderNum} where dept_id = #{deptId}
</update>
<delete id="deleteDeptById" parameterType="Long">
update sys_dept set del_flag = '2' where dept_id = #{deptId}
</delete>
</mapper>
</mapper>