12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- package com.yihu.jkedu.action;
- import java.util.ArrayList;
- import java.util.List;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import net.sf.json.JSONArray;
- import net.sf.json.JSONObject;
- import org.apache.commons.lang.StringUtils;
- 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
- {
- /**
- * @Title: queryUserInfoByID
- * @Description: 获取用户信息
- * @param @param request
- * @param @param response
- * @param @throws Exception 设定文件
- * @return void 返回类型
- * @throws
- */
- @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");
- JSONObject params = new JSONObject();
- if(StringUtils.isNotEmpty(userID)){
- params.put("userId", userID);
- }
- if(params.size() == 0){
- response.getWriter().write(ApiUtil.jsonResult(-10000, "参数:userId不能全部为空").toString());
- return;
- }
- String result = ServiceBus.getInstance(
- null,
- ConfigUtil.getInstance().getAppId()).call(
- "UserMgmt.User.queryUserInfoByID", params.toString(), false);
- JSONObject formResultObj = JSONObject.fromObject(result);
- int code = formResultObj.getInt("Code");
- String msg = formResultObj.getString("Message");
- JSONObject resultJson = new JSONObject();
- if (code == 10000) {// 成功
- JSONObject arrform = formResultObj.getJSONObject("Result");
- resultJson.put("Code", 10000);
- resultJson.put("Message", msg);
- resultJson.put("Result", arrform);
- }else{
- resultJson.put("Code", code);
- 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;
- }
- }
-
- }
|