/** * @param request * @param response * @param roleId * @return * @throws Exception */ @RequestMapping("/getUserListByRoleId") @ResponseBody public Map<String, Object> getUserListByRoleId( HttpServletRequest request, HttpServletResponse response, @RequestParam int limit, @RequestParam int offset, @RequestParam String search, @RequestParam String order, @RequestParam String sort, String roleId) throws Exception { Map<String, Object> map = new HashMap<String, Object>(); List<Root> list = userService.getUserList(offset, limit, sort, order, null); List<Map<String, Object>> result = new ArrayList<Map<String, Object>>(); List<String> userIds = roleService.getUserIdsByRoleId(roleId); for (Root root : list) { Map<String, Object> mapUser = GeneralBeanOrMapUtils.convertBean2Map(root); if (userIds != null && userIds.contains(mapUser.get("id").toString())) { mapUser.put("selected", true); } else mapUser.put("selected", false); result.add(mapUser); } map.put("rows", result); map.put("total", userService.getUserList(0, -1, sort, order, null).size()); return map; }
/** * 更新角色 * * @param request * @param response * @param role * @return * @throws Exception */ @RequestMapping("/updateRole") @ResponseBody public String updateRole(HttpServletRequest request, HttpServletResponse response, Role role) throws Exception { roleService.updateRole(role); return "success"; }
/** * 得到角色列表 * * @param request * @param response * @param limit * @param offset * @param search * @param order * @param sort * @return * @throws Exception */ @RequestMapping("/getRoleList") @ResponseBody public Map<String, Object> getRoleList( HttpServletRequest request, HttpServletResponse response, @RequestParam int limit, @RequestParam int offset, @RequestParam String search, @RequestParam String order, @RequestParam String sort) throws Exception { Map<String, Object> map = new HashMap<String, Object>(); List<Root> list = roleService.getRoleList(offset, limit, sort, order, search); map.put("total", roleService.getRoleList(0, -1, sort, order, search).size()); map.put("rows", list); return map; }
@RequestMapping("/updateRoleToUserRel") @ResponseBody public String updateRoleToUserRel( HttpServletRequest request, HttpServletResponse response, @RequestParam String roleId, @RequestParam String[] userIds) throws Exception { roleService.updateRoleToUserRel(roleId, userIds); return "success"; }
/** * 删除角色 * * @param request * @param response * @param ids * @return * @throws Exception */ @RequestMapping("/deleteRole") @ResponseBody public String deleteRole( HttpServletRequest request, HttpServletResponse response, @RequestParam String ids) throws Exception { String[] idA = ids.split(","); List<String> idList = new ArrayList<String>(); for (int i = 0; i < idA.length; i++) { idList.add(idA[i]); } roleService.deleteRole(idList); return "success"; }
/** * 得到角色列表(角色分配) * * @param request * @param response * @param search * @param order * @param sort * @return * @throws Exception */ @RequestMapping("/roleList") @ResponseBody public List<Map<String, Object>> roleList( HttpServletRequest request, HttpServletResponse response, @RequestParam String search, @RequestParam String order, @RequestParam String sort) throws Exception { Map<String, Object> map = new HashMap<String, Object>(); List<Root> list = roleService.getRoleList(0, -1, sort, order, search); List<Map<String, Object>> result = new ArrayList<Map<String, Object>>(); for (Root root : list) { result.add(GeneralBeanOrMapUtils.convertBean2Map(root)); } return result; }