/** * 获取某个模块的角色及用户 * * @param appId * @return */ public List<SysRole> getApplicationRoleWithUsers(long appId) { List<SysRole> roles = sysRoleService.getSysRolesByAppId(appId); if (roles != null && !roles.isEmpty()) { for (SysRole role : roles) { List<SysUser> users = sysUserService.getSysUsersByRoleId(role.getId()); role.setUsers(users); } } return roles; }
public static ObjectNode toObjectNode(SysUser user) { ObjectNode jsonObject = new ObjectMapper().createObjectNode(); jsonObject.put("actorId", user.getAccount()); jsonObject.put("actorId_enc", RequestUtils.encodeString(user.getAccount())); jsonObject.put("userId", user.getAccount()); jsonObject.put("userId_enc", RequestUtils.encodeString(user.getAccount())); jsonObject.put("name", user.getName()); jsonObject.put("locked", user.getStatus()); jsonObject.put("status", user.getStatus()); if (user.getDepartment() != null) { jsonObject.put("deptId", user.getDepartment().getId()); jsonObject.put("deptName", user.getDepartment().getName()); } else { jsonObject.put("deptId", user.getDeptId()); } jsonObject.put("accountType", user.getAccountType()); jsonObject.put("userType", user.getUserType()); jsonObject.put("dumpFlag", user.getDumpFlag()); jsonObject.put("gender", user.getGender()); jsonObject.put("evection", user.getEvection()); jsonObject.put("superiorIds", user.getSuperiorIds()); jsonObject.put("fax", user.getFax()); jsonObject.put("telephone", user.getTelephone()); jsonObject.put("headship", user.getHeadship()); jsonObject.put("adminFlag", user.getAdminFlag()); if (user.getEmail() != null) { jsonObject.put("mail", user.getEmail()); jsonObject.put("email", user.getEmail()); } if (user.getMobile() != null) { jsonObject.put("mobile", user.getMobile()); } if (user.getLastLoginTime() != null) { jsonObject.put("lastLoginDate", DateUtils.getDateTime(user.getLastLoginDate())); jsonObject.put("lastLoginTime", DateUtils.getDateTime(user.getLastLoginDate())); } if (user.getLastLoginIP() != null) { jsonObject.put("loginIP", user.getLastLoginIP()); } if (user.getCreateBy() != null) { jsonObject.put("createBy", user.getCreateBy()); } if (user.getUpdateBy() != null) { jsonObject.put("updateBy", user.getUpdateBy()); } if (user.getUpdateDate() != null) { jsonObject.put("updateDate", DateUtils.getDate(user.getUpdateDate())); jsonObject.put("updateDate_date", DateUtils.getDate(user.getUpdateDate())); jsonObject.put("updateDate_datetime", DateUtils.getDateTime(user.getUpdateDate())); } if (user.getUserRoles() != null && !user.getUserRoles().isEmpty()) { ArrayNode array = new ObjectMapper().createArrayNode(); for (SysUserRole sysUserRole : user.getUserRoles()) { array.add(sysUserRole.toObjectNode()); } jsonObject.set("userRoles", array); } if (user.getRoles() != null && !user.getRoles().isEmpty()) { ArrayNode array = new ObjectMapper().createArrayNode(); for (SysRole sysRole : user.getRoles()) { array.add(sysRole.toObjectNode()); } jsonObject.set("roles", array); } if (user.getFunctions() != null && !user.getFunctions().isEmpty()) { ArrayNode array = new ObjectMapper().createArrayNode(); for (SysFunction sysFunction : user.getFunctions()) { array.add(sysFunction.toObjectNode()); } // jsonObject.set("functions", array); } if (user.getApps() != null && !user.getApps().isEmpty()) { ArrayNode array = new ObjectMapper().createArrayNode(); for (SysApplication app : user.getApps()) { array.add(app.toObjectNode()); } // jsonObject.set("apps", array); } return jsonObject; }