/** * 获取应用代理 * * @return */ public static Result<QiYeAgent> getAgent(String token, String agentid) { Result<QiYeAgent> result = new Result<QiYeAgent>(); JSONObject jo = UserAPI.getAgent(token, agentid); if (jo != null) { System.out.println(jo); result.setErrmsg(ErrorCodeText.errorMsg(jo.getString("errcode"))); result.setErrcode(jo.getString("errcode")); if (result.getErrcode().equals("0")) { QiYeAgent agent = new QiYeAgent(); agent.setName(jo.getString("name")); agent.setAgentid(jo.getString("agentid")); JSONObject jsonObject = jo.getJSONObject("allowpartys"); agent.setAllowpartys(new PartyContainer(jsonObject.getString("partyid"))); agent.setAllowusers(new UserContainer(jo.getString("allowusers"))); agent.setMode(jo.getString("mode")); if (agent.getMode() == "1") { agent.setCallbackurl(jo.getString("callbackurl")); agent.setUrltoken(jo.getString("urltoken")); agent.setReport_location_flag(jo.getString("report_location_flag")); } agent.setDescription(jo.getString("description")); agent.setRedirectdomain(jo.getString("redirectdomain")); agent.setRoundUrl(jo.getString("RoundUrl")); agent.setSquareUrl(jo.getString("SquareUrl")); agent.setUseridlist(jo.getString("useridlist")); agent.setClose(jo.getInt("close")); result.setObject(agent); } } return result; }
/** * 获取用户信息,必须必填列 * * @param token * @param userId * @return */ public static Result<QiYeUser> getUser4Column(String token, String userId) { Result<QiYeUser> result = new Result<QiYeUser>(); JSONObject jo = UserAPI.getUser(token, userId); if (jo != null) { result.setErrmsg(ErrorCodeText.errorMsg(jo.getString("errcode"))); result.setErrcode(jo.getString("errcode")); if (result.getErrcode().equals("0")) { QiYeUser user = new QiYeUser(); user.setUserId(jo.getString("userid")); user.setName(jo.getString("name")); user.setDepartment(jo.getString("department")); user.setStatus(jo.getInt("status")); result.setObject(user); } } return result; }
/** * 获取菜单列表 * * @param AgentID * @return */ public static Result<JSONObject> getMenu(String token, int AgentID) { Result<JSONObject> result = new Result<JSONObject>(); JSONObject jo = MenuAPI.getMenu(token, AgentID); if (jo != null) { String errmsg = null; String errcode = null; try { errmsg = ErrorCodeText.errorMsg(jo.getString("errcode")); errcode = jo.getString("errcode"); System.out.println("errmsg=" + errmsg); System.out.println("errcode=" + errcode); result.setErrmsg(errmsg); result.setErrcode(errcode); } catch (Exception e) { } if (result.getErrcode() == null && result.getErrmsg() == null) { result.setObject(jo.getJSONObject("menu")); } } return result; }
/** * 获取成员 * * @return */ public static Result<QiYeUser> getUser(String token, String userId) { Result<QiYeUser> result = new Result<QiYeUser>(); JSONObject jo = UserAPI.getUser(token, userId); if (jo != null) { result.setErrmsg(ErrorCodeText.errorMsg(jo.getString("errcode"))); result.setErrcode(jo.getString("errcode")); if (result.getErrcode().equals("0")) { QiYeUser user = new QiYeUser(); user.setUserId(jo.getString("userid")); user.setName(jo.getString("name")); user.setDepartment(jo.getString("department")); if (isEmpty(jo.toString(), "position", jo.getString("position"))) { user.setPosition(jo.getString("position")); } if (isEmpty(jo.toString(), "mobile", jo.getString("mobile"))) { user.setMobile(jo.getString("mobile")); } user.setGender(jo.getInt("gender")); if (isEmpty(jo.toString(), "tel", jo.getString("tel"))) { user.setTel(jo.getString("tel")); } if (isEmpty(jo.toString(), "email", jo.getString("email"))) { user.setEmail(jo.getString("email")); } if (isEmpty(jo.toString(), "weixinid", jo.getString("weixinid"))) { user.setWeixinid(jo.getString("weixinid")); } if (isEmpty(jo.toString(), "avatar", jo.getString("avatar"))) { user.setAvatar(jo.getString("avatar")); } user.setStatus(jo.getInt("status")); result.setObject(user); } } return result; }