123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- package com.yihu.platform.api;
- import com.yihu.platform.apiservice.IHealthService;
- 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());
- String userId = StringUtil.isEmpty(json.get("userId")) ? null : json.getString("userId");
- if (StringUtil.isEmpty(userId)) {
- return ApiUtil.getRespJSON(-10000, "userId不能为空").toString();
- }
- IHealthService api = new IHealthService();
- String resp = api.queryPatient(userId);
- JSONObject re = JSONObject.fromObject(resp);
- if (re.getInt("status") != 10000) {
- return ApiUtil.getRespJSON(-10000, "查询用户信息失败:" + re).toString();
- }
- JSONObject userInfo = re.getJSONObject("result");
- JSONObject result = new JSONObject();
- if(userInfo.size()>0){
- result.put("UserName", userInfo.get("name"));
- result.put("PhotoUri", userInfo.get("photo"));
- result.put("CName", userInfo.get("name"));
- result.put("Sex", userInfo.get("sex"));
- result.put("BirthDate", userInfo.get("birthday"));
- result.put("IdNumber", userInfo.get("idcard"));
- result.put("MainPhone", userInfo.get("mobile"));
- result.put("Phone", userInfo.get("phone"));
- result.put("ProvinceID", userInfo.get("province"));
- result.put("ProvinceName", userInfo.get("provinceName"));
- result.put("CityID", userInfo.get("city"));
- result.put("CityName", userInfo.get("cityName"));
- result.put("AreaID", userInfo.get("town"));
- result.put("AreaName", userInfo.get("townName"));
- result.put("UserID", userId);
- }
- 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) {
- return this.queryUserInfoByID(msg);
- }
- /**
- * 通过用户id获取用户信息
- *
- * @param msg
- * @return
- */
- public String queryLoginInfoByUserID(InterfaceMessage msg) {
- return this.queryUserInfoByID(msg);
- }
- }
|