mirror of
https://github.com/yangzongzhuan/RuoYi.git
synced 2025-10-15 18:18:28 +00:00
菜单管理支持批量保存排序
This commit is contained in:
@@ -121,6 +121,14 @@ public interface SysMenuMapper
|
||||
*/
|
||||
public int updateMenu(SysMenu menu);
|
||||
|
||||
/**
|
||||
* 保存菜单排序
|
||||
*
|
||||
* @param menuIds 菜单ID
|
||||
* @param orderNums 排序ID
|
||||
*/
|
||||
public void updateMenuSort(SysMenu menu);
|
||||
|
||||
/**
|
||||
* 校验菜单名称是否唯一
|
||||
*
|
||||
|
@@ -129,6 +129,14 @@ public interface ISysMenuService
|
||||
*/
|
||||
public int updateMenu(SysMenu menu);
|
||||
|
||||
/**
|
||||
* 保存菜单排序
|
||||
*
|
||||
* @param menuIds 菜单ID
|
||||
* @param orderNums 排序ID
|
||||
*/
|
||||
public void updateMenuSort(String[] menuIds, String[] orderNums);
|
||||
|
||||
/**
|
||||
* 校验菜单名称是否唯一
|
||||
*
|
||||
|
@@ -11,11 +11,14 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.Ztree;
|
||||
import com.ruoyi.common.core.domain.entity.SysMenu;
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.system.mapper.SysMenuMapper;
|
||||
import com.ruoyi.system.mapper.SysRoleMenuMapper;
|
||||
@@ -321,6 +324,31 @@ public class SysMenuServiceImpl implements ISysMenuService
|
||||
return menuMapper.updateMenu(menu);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存菜单排序
|
||||
*
|
||||
* @param menuIds 菜单ID
|
||||
* @param orderNums 排序ID
|
||||
*/
|
||||
@Transactional
|
||||
public void updateMenuSort(String[] menuIds, String[] orderNums)
|
||||
{
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < menuIds.length; i++)
|
||||
{
|
||||
SysMenu menu = new SysMenu();
|
||||
menu.setMenuId(Convert.toLong(menuIds[i]));
|
||||
menu.setOrderNum(orderNums[i]);
|
||||
menuMapper.updateMenuSort(menu);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new ServiceException("保存排序异常,请联系管理员");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验菜单名称是否唯一
|
||||
*
|
||||
|
@@ -188,4 +188,10 @@
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateMenuSort" parameterType="SysMenu">
|
||||
update sys_menu
|
||||
set order_num = #{orderNum}
|
||||
where menu_id = #{menuId}
|
||||
</update>
|
||||
|
||||
</mapper>
|
Reference in New Issue
Block a user