1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- package com.yihu.jkedu.action;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import net.sf.json.JSONObject;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import com.yihu.base.ConfigUtil;
- import com.yihu.utils.ApiUtil;
- import com.yihu.utils.StringUtil;
- import com.yihu.wsgw.api.ServiceBus;
- @Controller
- @RequestMapping("/user")
- public class UserControl
- {
- @RequestMapping(value = "/queryUserInfoByID")
- public void queryUserInfoByID(HttpServletRequest request,
- HttpServletResponse response) throws Exception {
- try {
- response.setContentType("application/json;charset=UTF-8");
- String userId = StringUtil.isEmpty(request.getParameter("userId")) ? null : request.getParameter("userId");
- if(StringUtil.isEmpty(userId)){
- response.getWriter().write(ApiUtil.jsonResult(-10000, "用户userId不能为空").toString());
- return;
- }
- JSONObject params = new JSONObject();
- params.put("userId", userId);
- String formResult = ServiceBus.getInstance(
- null,
- ConfigUtil.getInstance().getAppId()).call(
- "UserMgmt.User.queryUserInfoByID", params.toString(), false);
- System.out.println(formResult);
- JSONObject formResultObj = JSONObject.fromObject(formResult);
- int code = formResultObj.getInt("Code");
- String msg = formResultObj.getString("Message");
- JSONObject resultJson = new JSONObject();
- if (code == 10000) {// 成功
- JSONObject arrform = formResultObj.getJSONObject("Result");
- if(arrform!=null){
- resultJson.put("Code", 10000);
- resultJson.put("Message", msg);
- resultJson.put("Result", arrform);
- response.getWriter().write(resultJson.toString());
- return ;
- }
- }
- resultJson.put("Code", -10000);
- resultJson.put("Message", msg);
- resultJson.put("Result", null);
- response.getWriter().write(resultJson.toString());
- return ;
-
- } catch (Exception e) {
- e.printStackTrace();
- response.getWriter().write(ApiUtil.jsonResult(-14444, "获取用户信息异常").toString());
- return ;
- }
- }
- }
|