|
|
@@ -15,6 +15,7 @@ import com.sckw.core.model.enums.SystemTypeEnum;
|
|
|
import com.sckw.core.utils.BeanUtils;
|
|
|
import com.sckw.core.utils.CollectionUtils;
|
|
|
import com.sckw.core.utils.IdWorker;
|
|
|
+import com.sckw.core.utils.StringUtils;
|
|
|
import com.sckw.core.web.constant.HttpStatus;
|
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
|
import com.sckw.system.dao.*;
|
|
|
@@ -382,13 +383,15 @@ public class KwsMenuService {
|
|
|
* @date: 2023/6/13
|
|
|
*/
|
|
|
public void roleBindMenu(RoleBindMenuReqVo reqVo) {
|
|
|
- String[] split = reqVo.getMenuIds().split(",");
|
|
|
- List<KwsMenuRights> list = new ArrayList<>();
|
|
|
+ List<Long> menuIdList = Arrays.stream(reqVo.getMenuIds().split(Global.COMMA)).map(Long::parseLong).collect(Collectors.toList());
|
|
|
+ List<Long> allMenus = getAllMenus(menuIdList, new ArrayList<>());
|
|
|
+ allMenus = allMenus.stream().distinct().toList();
|
|
|
Date date = new Date();
|
|
|
- for (String menuId : split) {
|
|
|
+ List<KwsMenuRights> list = new ArrayList<>();
|
|
|
+ for (Long menuId : allMenus) {
|
|
|
KwsMenuRights kwsMenuRights = new KwsMenuRights();
|
|
|
kwsMenuRights.setEntId(reqVo.getEntId());
|
|
|
- kwsMenuRights.setMenuId(Long.parseLong(menuId));
|
|
|
+ kwsMenuRights.setMenuId(menuId);
|
|
|
kwsMenuRights.setRoleId(reqVo.getRoleId());
|
|
|
kwsMenuRights.setId(new IdWorker(1L).nextId());
|
|
|
kwsMenuRights.setRemark(reqVo.getRemark());
|
|
|
@@ -406,6 +409,19 @@ public class KwsMenuService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ public List<Long> getAllMenus(List<Long> menuIdList, List<Long> list) {
|
|
|
+ List<KwsMenu> menuList = kwsMenuDao.selectByKeys(menuIdList);
|
|
|
+ List<KwsMenu> childList = menuList.stream().filter(item -> !item.getParentId().equals(0L)).toList();
|
|
|
+ if (CollectionUtils.isEmpty(childList)) {
|
|
|
+ list.addAll(menuList.stream().map(KwsMenu::getId).toList());
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+ list.addAll(childList.stream().map(KwsMenu::getId).toList());
|
|
|
+ return getAllMenus(childList.stream().map(KwsMenu::getParentId).collect(Collectors.toList()), list);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public List<KwsMenu> selectAll() {
|
|
|
return kwsMenuDao.selectAll();
|
|
|
}
|
|
|
@@ -535,4 +551,7 @@ public class KwsMenuService {
|
|
|
return list;
|
|
|
}
|
|
|
|
|
|
+ public List<Long> test(String ids) {
|
|
|
+ return getAllMenus(StringUtils.splitStrToList(ids, Long.class), new ArrayList<>());
|
|
|
+ }
|
|
|
}
|