/** * @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 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; }