mirror of
https://gitee.com/y_project/RuoYi-Vue.git
synced 2026-05-23 10:18:39 +00:00
菜单管理支持批量保存排序
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package com.ruoyi.web.controller.system;
|
package com.ruoyi.web.controller.system;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -129,6 +130,19 @@ public class SysMenuController extends BaseController
|
|||||||
return toAjax(menuService.updateMenu(menu));
|
return toAjax(menuService.updateMenu(menu));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存菜单排序
|
||||||
|
*/
|
||||||
|
@Log(title = "保存菜单排序", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping("/updateSort")
|
||||||
|
public AjaxResult updateSort(@RequestBody Map<String, String> params)
|
||||||
|
{
|
||||||
|
String[] menuIds = params.get("menuIds").split(",");
|
||||||
|
String[] orderNums = params.get("orderNums").split(",");
|
||||||
|
menuService.updateMenuSort(menuIds, orderNums);
|
||||||
|
return success();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除菜单
|
* 删除菜单
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -106,6 +106,13 @@ public interface SysMenuMapper
|
|||||||
*/
|
*/
|
||||||
public int updateMenu(SysMenu menu);
|
public int updateMenu(SysMenu menu);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存菜单排序
|
||||||
|
*
|
||||||
|
* @param menu 菜单信息
|
||||||
|
*/
|
||||||
|
public void updateMenuSort(SysMenu menu);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除菜单管理信息
|
* 删除菜单管理信息
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -126,6 +126,14 @@ public interface ISysMenuService
|
|||||||
*/
|
*/
|
||||||
public int updateMenu(SysMenu menu);
|
public int updateMenu(SysMenu menu);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存菜单排序
|
||||||
|
*
|
||||||
|
* @param menuIds 菜单ID
|
||||||
|
* @param orderNums 排序ID
|
||||||
|
*/
|
||||||
|
public void updateMenuSort(String[] menuIds, String[] orderNums);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除菜单管理信息
|
* 删除菜单管理信息
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -12,11 +12,14 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.domain.TreeSelect;
|
import com.ruoyi.common.core.domain.TreeSelect;
|
||||||
import com.ruoyi.common.core.domain.entity.SysMenu;
|
import com.ruoyi.common.core.domain.entity.SysMenu;
|
||||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||||
|
import com.ruoyi.common.core.text.Convert;
|
||||||
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
import com.ruoyi.system.domain.vo.MetaVo;
|
import com.ruoyi.system.domain.vo.MetaVo;
|
||||||
@@ -321,6 +324,32 @@ public class SysMenuServiceImpl implements ISysMenuService
|
|||||||
return menuMapper.updateMenu(menu);
|
return menuMapper.updateMenu(menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存菜单排序
|
||||||
|
*
|
||||||
|
* @param menuIds 菜单ID
|
||||||
|
* @param orderNums 排序ID
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@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(Convert.toInt(orderNums[i]));
|
||||||
|
menuMapper.updateMenuSort(menu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
throw new ServiceException("保存排序异常,请联系管理员");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除菜单管理信息
|
* 删除菜单管理信息
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -204,6 +204,10 @@
|
|||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateMenuSort" parameterType="SysMenu">
|
||||||
|
update sys_menu set order_num = #{orderNum} where menu_id = #{menuId}
|
||||||
|
</update>
|
||||||
|
|
||||||
<delete id="deleteMenuById" parameterType="Long">
|
<delete id="deleteMenuById" parameterType="Long">
|
||||||
delete from sys_menu where menu_id = #{menuId}
|
delete from sys_menu where menu_id = #{menuId}
|
||||||
</delete>
|
</delete>
|
||||||
|
|||||||
Reference in New Issue
Block a user