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