|
@@ -1,5 +1,6 @@
|
|
package com.boman.system.service.impl;
|
|
package com.boman.system.service.impl;
|
|
|
|
|
|
|
|
+import com.boman.common.core.utils.collection.CollectionUtils;
|
|
import com.boman.domain.constant.TableNameConst;
|
|
import com.boman.domain.constant.TableNameConst;
|
|
import com.boman.domain.dto.RoleMenuDto;
|
|
import com.boman.domain.dto.RoleMenuDto;
|
|
import com.boman.system.api.domain.SysMenu;
|
|
import com.boman.system.api.domain.SysMenu;
|
|
@@ -66,14 +67,18 @@ public class SysRoleMenuServiceImpl implements ISysRoleMenuService{
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 父类下所有的子类
|
|
|
|
+ List<SysMenu> originChildList = Lists.newArrayList(childList);
|
|
// 把parentList放进去
|
|
// 把parentList放进去
|
|
childList.addAll(parentList);
|
|
childList.addAll(parentList);
|
|
// 根据子菜单和前台传过来的head来判断包含AMD...中的哪些
|
|
// 根据子菜单和前台传过来的head来判断包含AMD...中的哪些
|
|
childList = buildBtnByHead(head, childList);
|
|
childList = buildBtnByHead(head, childList);
|
|
- List<SysRoleMenu> roleMenuList = buildRoleMenu(roleId, map(childList, SysMenu::getId));
|
|
|
|
|
|
+ List<Long> childIdList = map(childList, SysMenu::getId);
|
|
|
|
+ List<SysRoleMenu> roleMenuList = buildRoleMenu(roleId, childIdList);
|
|
|
|
+ List<Long> distinct = CollectionUtils.distinct(childIdList, map(originChildList, SysMenu::getId));
|
|
try {
|
|
try {
|
|
// 先删除,再添加,防止联合索引报错
|
|
// 先删除,再添加,防止联合索引报错
|
|
- deleteByRoleIdList(Collections.singletonList(roleId));
|
|
|
|
|
|
+ deleteByRoleIdList(Collections.singletonList(roleId), distinct);
|
|
effective += batchRoleMenu(roleMenuList);
|
|
effective += batchRoleMenu(roleMenuList);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
@@ -101,7 +106,7 @@ public class SysRoleMenuServiceImpl implements ISysRoleMenuService{
|
|
|
|
|
|
String perms = menu.getPerms();
|
|
String perms = menu.getPerms();
|
|
if (isEmpty(perms)) {
|
|
if (isEmpty(perms)) {
|
|
- continue;
|
|
|
|
|
|
+ throw new IllegalArgumentException(menu.getMenuName() + " 未配置权限标识, 请配置以后再次保存");
|
|
}
|
|
}
|
|
|
|
|
|
if (head.contains(RoleMenuDto.getBtnFromPerms(menu.getPerms()))) {
|
|
if (head.contains(RoleMenuDto.getBtnFromPerms(menu.getPerms()))) {
|
|
@@ -116,14 +121,15 @@ public class SysRoleMenuServiceImpl implements ISysRoleMenuService{
|
|
* 功能描述: 根据roleIdList删除
|
|
* 功能描述: 根据roleIdList删除
|
|
*
|
|
*
|
|
* @param roleIdList roleIdList
|
|
* @param roleIdList roleIdList
|
|
|
|
+ * @param menuIdList menuIdList
|
|
* @return int
|
|
* @return int
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public int deleteByRoleIdList(List<Long> roleIdList) {
|
|
|
|
- if (isEmpty(roleIdList)) {
|
|
|
|
|
|
+ public int deleteByRoleIdList(List<Long> roleIdList, List<Long> menuIdList) {
|
|
|
|
+ if (isEmpty(roleIdList) ||isEmpty(menuIdList) ) {
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
- return mapper.deleteByRoleIdList(roleIdList);
|
|
|
|
|
|
+ return mapper.deleteByRoleIdList(roleIdList, menuIdList);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|