8fc9413f50d53011710b7716243d4e467e878963.svn-base 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package com.yihu.platform.api;
  2. import com.yihu.platform.utils.ApiUtil;
  3. import com.yihu.platform.utils.StringUtil;
  4. import com.yihu.wsgw.api.InterfaceMessage;
  5. import net.sf.json.JSONException;
  6. import net.sf.json.JSONObject;
  7. /**
  8. * 用户接口
  9. * @author wengsb----yihu.com
  10. * 2017年8月17日下午3:00:15
  11. */
  12. public class UserApi {
  13. /**
  14. * 通过用户id获取用户信息
  15. * @param msg
  16. * @return
  17. */
  18. public String queryUserInfoByID(InterfaceMessage msg) {
  19. try {
  20. JSONObject json = JSONObject.fromObject(msg.getParam());
  21. Integer userId = StringUtil.isEmpty(json.get("userId")) ? null : json.getInt("userId");
  22. if (StringUtil.isEmpty(userId)) {
  23. return ApiUtil.getRespJSON(-10000, "id不能为空").toString();
  24. }
  25. JSONObject result = new JSONObject();
  26. result.put("UserName", "");
  27. result.put("PhotoUri", "");
  28. result.put("CName", "");
  29. result.put("Sex", "");
  30. result.put("BirthDate", "");
  31. result.put("IdNumber", "");
  32. result.put("MainPhone", "");
  33. result.put("Phone", "");
  34. result.put("ProvinceID", "");
  35. result.put("ProvinceName", "");
  36. result.put("CityID", "");
  37. result.put("CityName", "");
  38. result.put("AreaID", "");
  39. result.put("AreaName", "");
  40. result.put("UserID", "");
  41. JSONObject obj = ApiUtil.getRespJSON(10000, "成功");
  42. obj.put("Result", result);
  43. return obj.toString();
  44. } catch (JSONException e) {
  45. return ApiUtil.getRespJSON(-10000, "非标准json:[" + msg.getParam() + "]").toString();
  46. } catch (Exception e) {
  47. e.printStackTrace();
  48. return ApiUtil.getRespJSON(-14444, "加载异常!" + StringUtil.getException(e)).toString();
  49. }
  50. }
  51. /**
  52. * 通过用户id获取用户信息
  53. *
  54. * @param msg
  55. * @return
  56. */
  57. public String getAccLoginInfo(InterfaceMessage msg) {
  58. return this.queryUserInfoByID(msg);
  59. }
  60. /**
  61. * 通过用户id获取用户信息
  62. *
  63. * @param msg
  64. * @return
  65. */
  66. public String queryLoginInfoByUserID(InterfaceMessage msg) {
  67. return this.queryUserInfoByID(msg);
  68. }
  69. }