package com.yihu.platform.api; import com.yihu.platform.utils.ApiUtil; import com.yihu.platform.utils.StringUtil; import com.yihu.wsgw.api.InterfaceMessage; import net.sf.json.JSONException; import net.sf.json.JSONObject; /** * 用户接口 * @author wengsb----yihu.com * 2017年8月17日下午3:00:15 */ public class UserApi { /** * 通过用户id获取用户信息 * @param msg * @return */ public String queryUserInfoByID(InterfaceMessage msg) { try { JSONObject json = JSONObject.fromObject(msg.getParam()); Integer id = StringUtil.isEmpty(json.get("id")) ? null : json.getInt("id"); String param = StringUtil.isEmpty(json.get("param")) ? "" : json.getString("param"); if (StringUtil.isEmpty(id)) { return ApiUtil.getRespJSON(-10000, "id不能为空").toString(); } JSONObject result = new JSONObject(); result.put("UserName", ""); result.put("PhotoUri", ""); result.put("CName", ""); result.put("Sex", ""); result.put("BirthDate", ""); result.put("IdNumber", ""); result.put("IsBear", ""); result.put("IsMarried", ""); result.put("MainPhone", ""); result.put("Phone", ""); result.put("Email", ""); result.put("ProvinceID", ""); result.put("ProvinceName", ""); result.put("CityID", ""); result.put("CityName", ""); result.put("AreaID", ""); result.put("AreaName", ""); result.put("UserID", ""); result.put("LoginType", ""); result.put("RoleType", ""); JSONObject obj = ApiUtil.getRespJSON(10000, "成功"); obj.put("Result", result); return obj.toString(); } catch (JSONException e) { return ApiUtil.getRespJSON(-10000, "非标准json:[" + msg.getParam() + "]").toString(); } catch (Exception e) { e.printStackTrace(); return ApiUtil.getRespJSON(-14444, "加载异常!" + StringUtil.getException(e)).toString(); } } /** * 通过用户id获取用户信息 * * @param msg * @return */ public String getAccLoginInfo(InterfaceMessage msg) { try { JSONObject result = new JSONObject(); result.put("UserName", ""); result.put("PhotoUri", ""); result.put("CName", ""); result.put("Sex", ""); result.put("BirthDate", ""); result.put("IdNumber", ""); result.put("IsBear", ""); result.put("IsMarried", ""); result.put("MainPhone", ""); result.put("Phone", ""); result.put("Email", ""); result.put("ProvinceID", ""); result.put("ProvinceName", ""); result.put("CityID", ""); result.put("CityName", ""); result.put("AreaID", ""); result.put("AreaName", ""); result.put("UserID", ""); result.put("LoginType", ""); result.put("RoleType", ""); JSONObject obj = ApiUtil.getRespJSON(10000, "成功"); obj.put("Result", result); return obj.toString(); } catch (JSONException e) { return ApiUtil.getRespJSON(-10000, "非标准json:[" + msg.getParam() + "]").toString(); } catch (Exception e) { e.printStackTrace(); return ApiUtil.getRespJSON(-14444, "加载异常!" + StringUtil.getException(e)).toString(); } } /** * 通过用户id获取用户信息 * * @param msg * @return */ public String queryLoginInfoByUserID(InterfaceMessage msg) { try { JSONObject result = new JSONObject(); result.put("UserName", ""); result.put("PhotoUri", ""); result.put("CName", ""); result.put("Sex", ""); result.put("BirthDate", ""); result.put("IdNumber", ""); result.put("IsBear", ""); result.put("IsMarried", ""); result.put("MainPhone", ""); result.put("Phone", ""); result.put("Email", ""); result.put("ProvinceID", ""); result.put("ProvinceName", ""); result.put("CityID", ""); result.put("CityName", ""); result.put("AreaID", ""); result.put("AreaName", ""); result.put("UserID", ""); result.put("LoginType", ""); result.put("RoleType", ""); JSONObject obj = ApiUtil.getRespJSON(10000, "成功"); obj.put("Result", result); return obj.toString(); } catch (JSONException e) { return ApiUtil.getRespJSON(-10000, "非标准json:[" + msg.getParam() + "]").toString(); } catch (Exception e) { e.printStackTrace(); return ApiUtil.getRespJSON(-14444, "加载异常!" + StringUtil.getException(e)).toString(); } } }