Commit 7718fbd4 authored by hezhen's avatar hezhen

Merge branch 'hz_master'

parents 59d0abff 94dff032
......@@ -131,23 +131,27 @@ public class GroupBiz extends BaseBiz<GroupMapper, Group> {
@CacheClear(keys = {"permission:menu","permission:u","app:permission:u"})
public void modifyAuthorityMenu(int groupId, String[] menus) {
resourceAuthorityMapper.deleteByAuthorityIdAndResourceType(groupId + "", AdminCommonConstant.RESOURCE_TYPE_MENU);
List<Menu> menuList = menuMapper.selectAll();
Map<String, String> map = new HashMap<String, String>();
for (Menu menu : menuList) {
map.put(menu.getId().toString(), menu.getParentId().toString());
}
Set<String> relationMenus = new HashSet<String>();
relationMenus.addAll(Arrays.asList(menus));
ResourceAuthority authority = null;
for (String menuId : menus) {
findParentID(map, relationMenus, menuId);
}
for (String menuId : relationMenus) {
authority = new ResourceAuthority(AdminCommonConstant.AUTHORITY_TYPE_GROUP, AdminCommonConstant.RESOURCE_TYPE_MENU);
authority.setAuthorityId(groupId + "");
authority.setResourceId(menuId);
authority.setParentId("-1");
resourceAuthorityMapper.insertSelective(authority);
if (menus.length>0){
List<Menu> menuList = menuMapper.selectAll();
Map<String, String> map = new HashMap<String, String>();
for (Menu menu : menuList) {
map.put(menu.getId().toString(), menu.getParentId().toString());
}
Set<String> relationMenus = new HashSet<String>();
relationMenus.addAll(Arrays.asList(menus));
ResourceAuthority authority = null;
for (String menuId : menus) {
findParentID(map, relationMenus, menuId);
}
for (String menuId : relationMenus) {
authority = new ResourceAuthority(AdminCommonConstant.AUTHORITY_TYPE_GROUP, AdminCommonConstant.RESOURCE_TYPE_MENU);
authority.setAuthorityId(groupId + "");
authority.setResourceId(menuId);
authority.setParentId("-1");
resourceAuthorityMapper.insertSelective(authority);
}
}
}
......
......@@ -73,11 +73,15 @@ public class GroupController extends BaseController<GroupBiz, Group> {
@RequestMapping(value = "/{id}/authority/menu", method = RequestMethod.PUT)
@ResponseBody
public ObjectRestResponse modifyMenuAuthority(@PathVariable int id, String menuTrees){
String [] menus = menuTrees.split(",");
String [] menus =new String[]{};
if (StringUtils.isNotBlank(menuTrees)){
menus= menuTrees.split(",");
}
baseBiz.modifyAuthorityMenu(id, menus);
return new ObjectRestResponse().rel(true);
}
@RequestMapping(value = "/{id}/authority/menu", method = RequestMethod.GET)
@ResponseBody
public ObjectRestResponse<List<AuthorityMenuTree>> getMenuAuthority(@PathVariable int id){
......
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