public String getUsers() throws Exception { List<User> userList = getDefService().getListData().getList(); JSONArray ja = new JSONArray(); for (User user : userList) { JSONObject record = new JSONObject(); record.put("id", user.getId()); record.put("text", user.getEmployee().getName()); ja.add(record); } jo.put("data", ja); return render(jo); }
protected JSONObject toJsonObject(User user) throws Exception { AdminHelper record = new AdminHelper(); record.put("id", user.getId()); record.put("userName", user.getName()); record.put("userDisplayName", user.getDisplayName()); record.put("password", user.getPassword()); record.put("password2", user.getPassword()); record.put("employee", user.getEmployee()); record.put("locked", user.isLocked()); record.put("lastLoginTime", user.getLoginSession().getLastLoginTime()); record.put("logined", user.getLoginSession().isLogined()); record.put("organization", user.getEmployee().getOrganization()); record.put("role", toRoleArray(user.getRoles())); return record.getJsonObject(); }
public String getUserIsSysManager() throws Exception { Role role = roleService.getRoleByCode(Role.SYSTEM_GENERAL_STAFF); queryMap.put("roleId", role.getDbId() + ""); queryMap.put("type", "sysOperate"); List<User> list = userService.getListData(query, queryMap, 0, 0).getList(); // List<User> list = userService.getSomeUser(); JSONArray ja = new JSONArray(); for (User user : list) { JSONObject record = new JSONObject(); // Employee e = user.getEmployee(); record.put("id", user.getId()); record.put("name", user.getDisplayName()); record.put("userName", user.getName()); ja.add(record); } jo.put("data", ja); return render(jo); }