f7a5387fba269136ca833930b407121cb6131bcb.svn-base 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package com.yihu.jkedu.action;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import javax.servlet.http.HttpServletRequest;
  5. import javax.servlet.http.HttpServletResponse;
  6. import net.sf.json.JSONArray;
  7. import net.sf.json.JSONObject;
  8. import org.apache.commons.lang.StringUtils;
  9. import org.springframework.stereotype.Controller;
  10. import org.springframework.web.bind.annotation.RequestMapping;
  11. import com.yihu.base.ConfigUtil;
  12. import com.yihu.utils.ApiUtil;
  13. import com.yihu.utils.StringUtil;
  14. import com.yihu.wsgw.api.ServiceBus;
  15. @Controller
  16. @RequestMapping("/user")
  17. public class UserControl
  18. {
  19. /**
  20. * @Title: queryUserInfoByID
  21. * @Description: 获取用户信息
  22. * @param @param request
  23. * @param @param response
  24. * @param @throws Exception 设定文件
  25. * @return void 返回类型
  26. * @throws
  27. */
  28. @RequestMapping(value = "/queryUserInfoByID")
  29. public void queryUserInfoByID(HttpServletRequest request,
  30. HttpServletResponse response) throws Exception {
  31. try {
  32. response.setContentType("application/json;charset=UTF-8");
  33. String userID = StringUtil.isEmpty(request.getParameter("userID")) ? null : request.getParameter("userID");
  34. JSONObject params = new JSONObject();
  35. if(StringUtils.isNotEmpty(userID)){
  36. params.put("userId", userID);
  37. }
  38. if(params.size() == 0){
  39. response.getWriter().write(ApiUtil.jsonResult(-10000, "参数:userId不能全部为空").toString());
  40. return;
  41. }
  42. String result = ServiceBus.getInstance(
  43. null,
  44. ConfigUtil.getInstance().getAppId()).call(
  45. "UserMgmt.User.queryUserInfoByID", params.toString(), false);
  46. JSONObject formResultObj = JSONObject.fromObject(result);
  47. int code = formResultObj.getInt("Code");
  48. String msg = formResultObj.getString("Message");
  49. JSONObject resultJson = new JSONObject();
  50. if (code == 10000) {// 成功
  51. JSONObject arrform = formResultObj.getJSONObject("Result");
  52. resultJson.put("Code", 10000);
  53. resultJson.put("Message", msg);
  54. resultJson.put("Result", arrform);
  55. }else{
  56. resultJson.put("Code", code);
  57. resultJson.put("Message", msg);
  58. resultJson.put("Result", null);
  59. }
  60. response.getWriter().write(resultJson.toString());
  61. return;
  62. } catch (Exception e) {
  63. e.printStackTrace();
  64. response.getWriter().write(ApiUtil.jsonResult(-14444, "获取用户信息异常").toString());
  65. return;
  66. }
  67. }
  68. }