Commit 9faae60a authored by 赵啸非's avatar 赵啸非

添加菜单资源配置

parent 9e26c8a0
......@@ -8,6 +8,7 @@
package com.mortals.xhx.base.system.role.service.impl;
import cn.hutool.core.util.StrUtil;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICacheService;
......@@ -109,10 +110,26 @@ public class RoleAuthServiceImpl extends AbstractCRUDServiceImpl<RoleAuthDao, Ro
List<RoleAuthEntity> list = new ArrayList<>();
for (Long menuId : query.getMenuIdList()) {
RoleAuthEntity entity = new RoleAuthEntity();
entity.setRoleId(roleId);
entity.setMenuId(menuId);
list.add(entity);
//todo 一个菜单可以对应多个资源
MenuEntity menuEntity = menuService.get(menuId, context);
if(!ObjectUtils.isEmpty(menuEntity)){
String perms = menuEntity.getPerms();
if(!ObjectUtils.isEmpty(perms)){
List<String> split = StrUtil.split(perms, ",");
for (String s : split) {
RoleAuthEntity entity = new RoleAuthEntity();
entity.setRoleId(roleId);
entity.setMenuId(menuId);
entity.setResourceId(DataUtil.converStr2Long(s,0L));
list.add(entity);
}
}else{
RoleAuthEntity entity = new RoleAuthEntity();
entity.setRoleId(roleId);
entity.setMenuId(menuId);
list.add(entity);
}
}
}
this.dao.insertBatch(list);
List<Long> userIdList = roleUserService.find(new RoleUserQuery().roleId(query.getRoleId())).stream()
......@@ -149,4 +166,10 @@ public class RoleAuthServiceImpl extends AbstractCRUDServiceImpl<RoleAuthDao, Ro
}
}
public static void main(String[] args) {
String s = "1";
System.out.println(StrUtil.split(s, ","));
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment