|
@@ -9,6 +9,7 @@ import com.fdkankan.manage.mapper.ISysRoleMenuMapper;
|
|
|
import com.fdkankan.manage.service.ISysMenuService;
|
|
|
import com.fdkankan.manage.service.ISysRoleMenuService;
|
|
|
import com.fdkankan.manage.service.ISysRoleService;
|
|
|
+import org.opencv.ml.EM;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -43,14 +44,12 @@ public class SysRoleMenuServiceImpl extends ServiceImpl<ISysRoleMenuMapper, SysR
|
|
|
@Override
|
|
|
public void saveBatchByRoleId(Long roleId, List<Long> menuIds) {
|
|
|
List<SysRoleMenu> sysMenus = new ArrayList<>();
|
|
|
- HashMap<Long, SysMenu> menuMap = sysMenuService.getByIds(menuIds);
|
|
|
+ HashMap<Long, SysMenu> menuMap = new HashMap<>();
|
|
|
+ List<SysMenu> list = sysMenuService.list();
|
|
|
+ list.forEach(entity -> menuMap.put(entity.getId(),entity));
|
|
|
+
|
|
|
HashSet<Long> menuIdsSet = new HashSet<>();
|
|
|
- for (Long menuId : menuIds) {
|
|
|
- Long parentId = menuMap.get(menuId).getParentId();
|
|
|
- if(parentId != null && !menuIds.contains(parentId) ){
|
|
|
- menuIdsSet.add(parentId);
|
|
|
- }
|
|
|
- }
|
|
|
+ this.getAllMenuIds(menuMap,menuIdsSet,menuIds);
|
|
|
menuIdsSet.addAll(menuIds);
|
|
|
for (Long menuId : menuIdsSet) {
|
|
|
SysRoleMenu roleMenu = new SysRoleMenu();
|
|
@@ -61,6 +60,19 @@ public class SysRoleMenuServiceImpl extends ServiceImpl<ISysRoleMenuMapper, SysR
|
|
|
this.saveBatch(sysMenus);
|
|
|
}
|
|
|
|
|
|
+ private void getAllMenuIds(HashMap<Long, SysMenu> menuMap, HashSet<Long> menuIdsSet,List<Long> menuIds ) {
|
|
|
+ List<Long> parentIds = new ArrayList<>();
|
|
|
+ for (Long menuId : menuIds) {
|
|
|
+ Long parentId = menuMap.get(menuId).getParentId();
|
|
|
+ if(parentId != null && ! menuIds.contains(parentId) ){
|
|
|
+ menuIdsSet.add(parentId);
|
|
|
+ parentIds.add(parentId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(parentIds.size() >0){
|
|
|
+ getAllMenuIds(menuMap,menuIdsSet,parentIds);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
@Override
|