コード例 #1
0
ファイル: AlarmRuleCtl.java プロジェクト: qilifan/sky-walking
  /**
   * * 查询用户默认规则
   *
   * @param root
   * @return
   * @throws Exception
   */
  @RequestMapping(
      value = "/alarmRule/default",
      method = RequestMethod.POST,
      produces = "application/json; charset=UTF-8")
  @ResponseBody
  public String queryUserDefaultAlarmRule(
      HttpServletRequest request, ModelMap root, @RequestBody String json) throws Exception {
    HttpSession session = request.getSession();
    String uid = (String) session.getAttribute("uid");

    JSONObject reJson = new JSONObject();

    if (StringUtil.isBlank(uid)) {
      reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL);
      reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "用户会话超时");
      return reJson.toJSONString();
    }

    AlarmRuleMVO ruleMVO = new AlarmRuleMVO();
    ruleMVO.setUid(uid);

    ruleMVO = alarmRuleSer.queryUserDefaultAlarmRule(ruleMVO);

    if (ruleMVO != null && !StringUtil.isBlank(ruleMVO.getRuleId())) {
      reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_OK);
      reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "查询到默认数据");
      reJson.put(Constants.JSON_RESULT_KEY_RESULT_DATA, JSON.toJSONString(ruleMVO));
    } else {
      reJson.put(Constants.JSON_RESULT_KEY_RESULT, Constants.JSON_RESULT_KEY_RESULT_FAIL);
      reJson.put(Constants.JSON_RESULT_KEY_RESULT_MSG, "未查询到默认数据");
    }

    return reJson.toJSONString();
  }
コード例 #2
0
  @RequestMapping(value = "/doRegister", produces = "application/json; charset=UTF-8")
  @ResponseBody
  public String doRegister(SignInUserInfo signInUserInfo) {
    JSONObject result = new JSONObject();
    try {

      if (validateUserInfo(signInUserInfo, result)) {
        return result.toJSONString();
      }
      signInUserInfo.setRoleType(Constants.USR.ROLE_TYPE_USER);
      signInUserInfo.setSts(Constants.USR.STR_VAL_A);
      iUserMaintainDao.addUser(signInUserInfo);
      if (StringUtil.isBlank(signInUserInfo.getUid())) {
        result.put("code", "500");
        result.put("message", "Failed to register user" + signInUserInfo.getUserName());
        return result.toJSONString();
      }

      result.put("code", "200");
      result.put("message", "register success");
    } catch (Exception e) {
      logger.error(
          "Failed to register the user[{}]",
          signInUserInfo.getUserName(),
          signInUserInfo.getPassword(),
          e);
      result.put("code", "500");
      result.put("message", "fatal error. please try it again.");
    }
    return result.toJSONString();
  }
コード例 #3
0
  @RequestMapping(value = "/doLogin", produces = "application/json; charset=UTF-8")
  @ResponseBody
  public String doLogin(HttpServletRequest request, LoginUserInfo loginInfo) {
    JSONObject result = new JSONObject();
    try {
      if (validateUserInfo(loginInfo, result)) {
        return result.toJSONString();
      }

      LoginUserInfo dbLoginInfo = iUserMaintainDao.queryUserInfoByName(loginInfo.getUserName());

      if (dbLoginInfo == null || !loginInfo.getPassword().equals(dbLoginInfo.getPassword())) {
        result.put("code", "400");
        result.put("message", "Username or password is not correct");
        return result.toJSONString();
      }

      logger.info("The userId[{}] has been login", dbLoginInfo.getUid());
      result.put("code", "200");
      result.put("message", "Login success");
      //
      request.getSession().setAttribute(Constants.SESSION_LOGIN_INFO_KEY, dbLoginInfo);
    } catch (Exception e) {
      logger.error(
          "Failed to login the user[{}] and password[{}]",
          loginInfo.getUserName(),
          loginInfo.getPassword(),
          e);
      result.put("code", "500");
      result.put("message", "fatal error. please try it again.");
    }
    return result.toJSONString();
  }
コード例 #4
0
ファイル: TestRedis.java プロジェクト: angelwsin/baseRedis
 @SuppressWarnings("unchecked")
 // @Test
 public void objectTOMap() {
   Post post = postDao.get(8);
   String str = JSONObject.toJSONString(post);
   HashMap<String, String> map = JSON.parseObject(JSONObject.toJSONString(post), HashMap.class);
   System.out.println(map.toString());
   System.out.println(ObjectToMap.objectToMap(post));
 }
コード例 #5
0
 @RequestMapping("deleteradiostation")
 public @ResponseBody String deleteRadioStation(int id) {
   JSONObject o = new JSONObject();
   int count = radioStationService.removeRadioStation(id);
   if (count > 0) {
     o.put("success", true);
     return o.toJSONString();
   } else {
     o.put("success", false);
     return o.toJSONString();
   }
 }
コード例 #6
0
 @Test
 public void testFastJsonConvertMap() throws Exception {
   Map<String, Object> map = new HashMap<String, Object>();
   map.put("a", 1);
   map.put("b", "");
   map.put("c", null);
   map.put("d", "2");
   map.put(null, "3");
   String jsonStr = JSONObject.toJSONString(map);
   logger.info(jsonStr);
   // 输出空值
   jsonStr = JSONObject.toJSONString(map, SerializerFeature.WriteMapNullValue);
   logger.info(jsonStr);
 }
コード例 #7
0
ファイル: Pay.java プロジェクト: Junred/wechat-company
 /**
  * 发货通知
  *
  * @param access_token
  * @param openid
  * @param transid
  * @param out_trade_no
  * @return
  * @throws IOException
  * @throws NoSuchProviderException
  * @throws NoSuchAlgorithmException
  * @throws KeyManagementException
  * @throws InterruptedException
  * @throws ExecutionException
  */
 public static boolean delivernotify(
     String access_token, String openid, String transid, String out_trade_no)
     throws IOException, ExecutionException, InterruptedException {
   Map<String, String> paras = new HashMap<String, String>();
   paras.put("appid", ConfKit.get("AppId"));
   paras.put("openid", openid);
   paras.put("transid", transid);
   paras.put("out_trade_no", out_trade_no);
   paras.put("deliver_timestamp", (System.currentTimeMillis() / 1000) + "");
   paras.put("deliver_status", "1");
   paras.put("deliver_msg", "ok");
   // 签名
   String app_signature = deliverSign(paras);
   paras.put("app_signature", app_signature);
   paras.put("sign_method", "sha1");
   String json =
       HttpKit.post(DELIVERNOTIFY_URL.concat(access_token), JSONObject.toJSONString(paras));
   if (StringUtils.isNotBlank(json)) {
     JSONObject object = JSONObject.parseObject(json);
     if (object.containsKey("errcode")) {
       int errcode = object.getIntValue("errcode");
       return errcode == 0;
     }
   }
   return false;
 }
コード例 #8
0
ファイル: UserOldRest.java プロジェクト: zyflao/rest
  /**
   * 验证手机验证码
   *
   * @param headers 头部信息
   * @param content post 请求参数
   * @return
   */
  @Path("/valid/code")
  @POST
  @Produces("application/json;charset=utf-8")
  public String validcode(String content) {

    if (StringUtils.isEmpty(content)) {
      return OpenResult.parameterError("无参数").buildJson();
    }
    JSONObject json = JSONObject.parseObject(content);
    String mobileno = json.getString("mobileno");
    String codetype = json.getString("codetype");
    String validcode = json.getString("validcode");
    if (StringUtils.isBlank(mobileno)
        || StringUtils.isBlank(codetype)
        || StringUtils.isBlank(validcode)) {
      return OpenResult.parameterError("参数错误").buildJson();
    }
    try {

      JSONObject result = registService.checkIdentifyingCode(mobileno, codetype, validcode);
      if (result != null) {
        int retcode = result.getIntValue("retcode");
        String msg = result.getString("msg");
        if (retcode != 0) {
          return OpenResult.serviceError(retcode, msg).buildJson();
        }
      } else {
        return OpenResult.unknown("服务异常").buildJson();
      }
      return result.toJSONString();
    } catch (StockServiceException e) {
      log.error("验证手机验证码异常:" + e);
      return OpenResult.serviceError(e.getRetcode(), e.getMsg()).buildJson();
    }
  }
コード例 #9
0
 /**
  * 创建临时二维码Ticket
  *
  * @param accessToken
  * @param expireSeconds 有效时间,单位:秒
  * @param qrID 二维码标识
  * @return
  * @throws IOException
  * @throws WechatExceprion
  */
 @Bizlet("createTempQRImage")
 public static WechatQRCodeModel createTempQRImage(
     String accessToken, long expireSeconds, int qrID) throws IOException, WechatExceprion {
   String uri = "https://api.weixin.qq.com/cgi-bin/qrcode/create";
   NameValuePair[] queryStr = new NameValuePair[1];
   queryStr[0] = new NameValuePair(IWechatConstants.KEY_ACCESS_TOKEN, accessToken);
   JSONObject jsonObj = new JSONObject();
   jsonObj.put("expire_secondes", expireSeconds);
   jsonObj.put("action_name", WechatQRCodeModel.QR_IMAGE_TEMPORARY);
   JSONObject obj = new JSONObject();
   obj.put("scene_id", qrID);
   JSONObject obj1 = new JSONObject();
   obj1.put("scene", obj);
   jsonObj.put("action_info", obj1);
   RequestEntity requestEntity =
       new StringRequestEntity(
           jsonObj.toJSONString(),
           IWechatConstants.CONTENT_TYPE,
           IWechatConstants.DEFAULT_CHARSET);
   String result = HttpExecuter.executePostAsString(uri, queryStr, requestEntity);
   String returnCode = JSONObject.parseObject(result).getString(IWechatConstants.ERROR_CODE);
   if (returnCode == null || IWechatConstants.RETURN_CODE_SUCCESS.equals(returnCode)) {
     return JSONObject.parseObject(result, WechatQRCodeModel.class);
   } else throw new WechatExceprion("[AccountOperations#createTempQRImage]" + result);
 }
コード例 #10
0
ファイル: BaseEntity.java プロジェクト: cclouds/publish
 public void addField(String field, String value) {
   if (StringUtil.isNotBlank(field) && StringUtil.isNotBlank(value)) {
     initJsonMap();
     fieldsMap.put(field, value);
     setJson(JSONObject.toJSONString(fieldsMap));
   }
 }
コード例 #11
0
ファイル: UserOldRest.java プロジェクト: zyflao/rest
 @Path("/findpwd/validcode")
 @POST
 @Produces("application/json;charset=utf-8")
 public String validCodeForFindPwd(String content) {
   if (StringUtils.isEmpty(content)) {
     return OpenResult.parameterError("无参数").buildJson();
   }
   JSONObject json = JSONObject.parseObject(content);
   String userId = json.getString("userid");
   String mobileno = json.getString("mobileno");
   String validcode = json.getString("validcode");
   if (StringUtils.isEmpty(userId)
       || StringUtils.isEmpty(mobileno)
       || StringUtils.isEmpty(validcode)) {
     return OpenResult.parameterError("参数错误").buildJson();
   }
   try {
     JSONObject result = personalService.validCodeForFindPasswd(userId, mobileno, validcode);
     if (result != null) {
       if (result.getInteger("retcode") != 0) {
         return result.toJSONString();
       }
       MobileCodeResult codeResult = new MobileCodeResult();
       codeResult.setExpiredtime(result.getLong("expiredtime"));
       return OpenResult.ok().add("data", codeResult).buildJson();
     } else {
       return OpenResult.unknown("服务异常").buildJson();
     }
   } catch (StockServiceException e) {
     log.error("找回密码时验证验证码异常:" + e);
     return OpenResult.serviceError(e.getRetcode(), e.getMsg()).buildJson();
   }
 }
コード例 #12
0
  /** 应用客户端值分布相关 */
  @RequestMapping("/valueDistribute")
  public ModelAndView doValueDistribute(
      HttpServletRequest request, HttpServletResponse response, Model model) throws ParseException {
    // 1.1 应用信息
    Long appId = NumberUtils.toLong(request.getParameter("appId"));
    if (appId <= 0) {
      return new ModelAndView("");
    }
    AppDesc appDesc = appService.getByAppId(appId);
    model.addAttribute("appDesc", appDesc);

    // 1.2 时间格式转换
    TimeBetween timeBetween = new TimeBetween();
    try {
      timeBetween = fillWithValueDistriTime(request, model);
    } catch (ParseException e) {
      logger.error(e.getMessage(), e);
    }
    long startTime = timeBetween.getStartTime();
    long endTime = timeBetween.getEndTime();

    // 值分布列表
    List<AppClientValueDistriSimple> appClientValueDistriSimpleList =
        clientReportValueDistriServiceV2.getAppValueDistriList(appId, startTime, endTime);
    model.addAttribute("appClientValueDistriSimpleList", appClientValueDistriSimpleList);

    // 值分布json
    model.addAttribute(
        "appClientValueDistriSimpleListJson",
        JSONObject.toJSONString(appClientValueDistriSimpleList));

    return new ModelAndView("client/clientValueDistribute");
  }
コード例 #13
0
  public SysApplication findById(long id) {
    String cacheKey = "sys_app_" + id;

    if (SystemConfig.getBoolean("use_query_cache") && CacheFactory.getString(cacheKey) != null) {
      String text = CacheFactory.getString(cacheKey);
      com.alibaba.fastjson.JSONObject json = JSON.parseObject(text);
      SysApplication app = SysApplicationJsonFactory.jsonToObject(json);
      if (app != null && app.getNodeId() > 0) {
        SysTree node = sysTreeService.findById(app.getNodeId());
        app.setNode(node);
      }
      return app;
    }

    SysApplication app = sysApplicationMapper.getSysApplicationById(id);
    if (app != null && app.getNodeId() > 0) {
      SysTree node = sysTreeService.findById(app.getNodeId());
      app.setNode(node);
    }

    if (app != null && SystemConfig.getBoolean("use_query_cache")) {
      com.alibaba.fastjson.JSONObject json = app.toJsonObject();
      CacheFactory.put(cacheKey, json.toJSONString());
    }

    return app;
  }
コード例 #14
0
  /**
   * 位置和周边
   *
   * @param inv
   * @param cityName
   * @param groupId
   * @param whatfor 需要地图还是周边信息
   * @return
   * @throws InvocationTargetException
   * @throws IllegalAccessException
   * @throws MalformedURLException
   */
  @Get({"/{groupId:[0-9]+}/zhoubian/", "/{groupId:[0-9]+}/ditu/"})
  public String mapAndArround(
      Invocation inv,
      @Param("cityName") @DefValue("bj") String cityName,
      @Param("groupId") @DefValue("0") int groupId,
      @Param("whatfor") @DefValue("whatfor") String whatfor)
      throws IllegalAccessException, InvocationTargetException, MalformedURLException {
    BuildingInfo buildingDetailInfo = buildingService.getBuildingDetailInfo(groupId);
    if (null != buildingDetailInfo) {
      String longtitude = buildingDetailInfo.getLongitude();
      String latitude = buildingDetailInfo.getLatitude();
      if (null == longtitude
          || !longtitude.matches(lngLatPattern)
          || null == latitude
          || !latitude.matches(lngLatPattern)) {
        return "e:404";
      }
    } else {
      return "e:404";
    }

    int phone400 = 0;
    if (null != buildingDetailInfo) {
      phone400 = buildingDetailInfo.getPhone400();
    }
    inv.addModel("phone400", phone400);

    DictCity city = null;
    try {
      city = cityService.getCity(buildingDetailInfo.getCityId());
    } catch (Exception e) {
      logger.error("", e);
    }
    City cityInfo = new City();
    BeanUtils.copyProperties(cityInfo, city);
    cityInfo.setCityStatus(AppConstants.CityPageStatus.getCityStatus(cityInfo.getCityName()));
    cityInfo.setEsfUrl("http://" + city.getCityPinyinAbbr() + "." + CityPageStatus.getEsfUrl());
    cityInfo.setXinfangUrl("/" + city.getCityPinyinAbbr() + "/search/list/");
    cityInfo.setSuggestUrl("/" + city.getCityPinyinAbbr() + "/search/suggest/");
    inv.addModel("cityStr", JSONObject.toJSONString(cityInfo));
    inv.addModel("_city", cityInfo);
    inv.addModel("groupId", groupId);
    inv.addModel("info", buildingDetailInfo);

    String buildingName = buildingDetailInfo.getProjName();
    if (buildingName.length() >= 5) {
      buildingName = buildingName.substring(0, 4) + "...";
    }
    inv.addModel("buildName", buildingName);
    // 返回标志 0表示返回历史记录 1 表示返回首页
    int returnFlag = Utils.getBackStatus(inv.getRequest());
    inv.addModel("returnFlag", returnFlag);
    // phone展示页
    if (inv.getRequestPath().getUri().contains("ditu")) {
      return "phone/map";
    } else {
      return "phone/arround";
    }
  }
コード例 #15
0
  @RequestMapping("/server/remove")
  public String remove(long id) {
    JSONObject result = new JSONObject();

    serverService.remove(id);

    result.put("ret", 0);
    return result.toJSONString();
  }
コード例 #16
0
  @Test
  public void testFastJsonEnum() {
    FastJson_Msg_Bean bean = new FastJson_Msg_Bean(1, Enum_StatusCodeEnum.OK);
    String jsonStr = JSONObject.toJSONString(bean);
    logger.info(jsonStr);

    FastJson_Msg_Bean bean2 = JSONObject.parseObject(jsonStr, FastJson_Msg_Bean.class);
    logger.info(bean2);
  }
コード例 #17
0
ファイル: BaseEntity.java プロジェクト: cclouds/publish
 public void addField(String field, String value, String json) {
   if (StringUtil.isNotBlank(field) && StringUtil.isNotBlank(value)) {
     Map<String, Object> map = JSONObject.parseObject(json);
     if (map == null) {
       map = new HashMap<String, Object>();
     }
     map.put(field, value);
     setJson(JSONObject.toJSONString(map));
   }
 }
コード例 #18
0
ファイル: ExpBrwUtil.java プロジェクト: pabi2/pb2_pabiweb
  public static String jsonReportSuccess(List<Map<String, Object>> list) throws Exception {

    Map<String, Object> obj = new HashMap<String, Object>();

    obj.put(JsonConstant.SUCCESS, true);
    obj.put(JsonConstant.TOTAL, 0);
    obj.put(JsonConstant.DATA, list);

    return com.alibaba.fastjson.JSONObject.toJSONString(obj);
  }
コード例 #19
0
 @RequestMapping(
     value = "/view",
     method = {RequestMethod.GET, RequestMethod.POST})
 public String list(Page page, Map<String, Object> map) {
   List<BizTransRecord> transRecords = null;
   transRecords = transRecordService.findAll(page);
   map.put("page", page);
   map.put("transRecords", transRecords);
   return JSONObject.toJSONString(map);
 }
コード例 #20
0
ファイル: UserOldRest.java プロジェクト: zyflao/rest
 /**
  * 更新用户信息
  *
  * @param headers
  * @param content
  * @return
  */
 @Path("/update/userInfo")
 @POST
 @Produces("application/json;charset=utf-8")
 public String updateUserInfo(String content) {
   if (StringUtils.isEmpty(content)) {
     return OpenResult.parameterError("无参数").buildJson();
   }
   JSONObject json = JSONObject.parseObject(content);
   String userId = json.getString("userId");
   String sessionId = json.getString("sessionId");
   String validdate = json.getString("validdate");
   String postcode = json.getString("postcode");
   String regioncode = json.getString("regioncode");
   String address = json.getString("address");
   Integer sex = json.getInteger("sex");
   String description = json.getString("description");
   String reservedinfo = json.getString("reservedinfo");
   if (StringUtils.isEmpty(userId) || StringUtils.isEmpty(sessionId)) {
     return OpenResult.parameterError("参数错误").buildJson();
   }
   // 校验性别
   if (sex != null) {
     if (sex > 1 || sex < 0) {
       return OpenResult.parameterError("性别参数错误").buildJson();
     }
   }
   if (StringUtils.isNotEmpty(postcode)) {
     // 校验邮政编码
     boolean flag = registService.checkPostCode(postcode);
     if (!flag) {
       return OpenResult.parameterError("请输入正确的邮编").buildJson();
     }
   }
   if (checkSessionId(userId, sessionId)) {
     try {
       JSONObject userRes =
           registService.updateUserInfo(
               userId, validdate, postcode, regioncode, address, sex, description, reservedinfo);
       if (userRes != null) {
         int retcode = userRes.getIntValue("retcode");
         String msg = userRes.getString("msg");
         if (retcode != 0) {
           return OpenResult.parameterError(retcode, msg).buildJson();
         }
         return userRes.toJSONString();
       } else {
         return OpenResult.unknown("服务异常").buildJson();
       }
     } catch (StockServiceException e) {
       return OpenResult.serviceError(e.getRetcode(), e.getMsg()).buildJson();
     }
   } else {
     return OpenResult.noAccess("未授权").buildJson();
   }
 }
コード例 #21
0
ファイル: UserManager.java プロジェクト: whueric/wechat4j
 /**
  * 删除分组
  *
  * @param groupId
  * @throws WeChatException
  */
 public void deleteGroup(int groupId) throws WeChatException {
   JSONObject idJson = new JSONObject();
   idJson.put("id", groupId);
   JSONObject groupJson = new JSONObject();
   groupJson.put("group", idJson);
   String requestData = groupJson.toJSONString();
   logger.info("request data " + requestData);
   String resultStr = HttpUtils.post(GROUP_DELETE_POST_URL + this.accessToken, requestData);
   logger.info("return data " + resultStr);
   WeChatUtil.isSuccess(resultStr);
 }
コード例 #22
0
ファイル: ModelAction.java プロジェクト: opure/eclipse1
 /**
  * 主页
  *
  * @return 主页页面
  */
 @RequestMapping("/{managerId}/queryModelByRoleId")
 public void queryModelByRoleId(
     @PathVariable int managerId, HttpServletRequest request, HttpServletResponse response) {
   ManagerEntity manager = (ManagerEntity) managerBiz.getEntity(managerId);
   if (manager == null) {
     return;
   }
   List<BaseEntity> modelList = new ArrayList<BaseEntity>();
   modelList = modelBiz.queryModelByRoleId(manager.getManagerRoleID());
   this.outJson(response, null, true, JSONObject.toJSONString(modelList));
 }
コード例 #23
0
ファイル: Util.java プロジェクト: bingkuaix3/MFBaas
  /**
   * 输出JSON
   *
   * @param response
   * @param json
   * @throws IOException
   */
  public static void writeJsonToResponse(ServletResponse response, JSONObject json)
      throws IOException {
    response.setContentType("text/html;charset=utf-8");

    /*//放开下面注释的代码就可以支持跨域
    if (response instanceof javax.servlet.http.HttpServletResponse) {
     //"*"表明允许任何地址的跨域调用,正式部署时应替换为正式地址
     ((javax.servlet.http.HttpServletResponse)response).addHeader("Access-Control-Allow-Origin", "*");
    }*/

    response.getWriter().write(json.toJSONString());
  }
コード例 #24
0
ファイル: UserOldRest.java プロジェクト: zyflao/rest
  @Path("/get/userInfo")
  @POST
  @Produces("application/json;charset=utf-8")
  public String getUserInfo(@Context HttpServletRequest request, String content) {
    if (StringUtils.isEmpty(content)) {
      return OpenResult.parameterError("无参数").buildJson();
    }
    JSONObject json = JSONObject.parseObject(content);
    String idNumber = json.getString("idNumber");
    String captcha = json.getString("captcha");
    String uuId = json.getString("uuId");
    if (StringUtils.isEmpty(idNumber)
        || StringUtils.isEmpty(captcha)
        || StringUtils.isEmpty(uuId)) {
      return OpenResult.parameterError("参数错误").buildJson();
    }
    try {
      if (!ValidateUtil.isIdNumber(idNumber)) {
        return OpenResult.parameterError(10103, "身份证号有误,请正确填写您的18位身份证号").buildJson();
      }
      if (!ImageCaptchaValidator.validateResponse(uuId, captcha)) {
        return OpenResult.parameterError(10203, "验证码不正确").buildJson();
      }
      JSONObject result = personalService.queryUserInfo(idNumber);
      if (result != null) {
        int retcode = result.getIntValue("retcode");
        if (retcode != 0) {
          return result.toJSONString();
        }
        NoPwdResult pwdResult = new NoPwdResult();
        String mobileNo = result.getString("mobileno");
        mobileNo = InfoMasker.masker(mobileNo, 3, 4, "*", 1);
        pwdResult.setMobileno(mobileNo);

        JSONObject userInfo = new JSONObject();
        userInfo.put("mobileno", result.getString("mobileno"));
        userInfo.put("userid", result.getString("userid"));
        userInfo.put("email", result.getString("email"));
        setMemcacheJSON(idNumber, userInfo);

        return OpenResult.ok().add("data", pwdResult).buildJson();
      } else {
        return OpenResult.unknown("服务异常").buildJson();
      }

    } catch (StockRestException e) {
      log.error("找回密码时获取用户信息异常:" + e);
      return OpenResult.serviceError(e.getRetcode(), e.getMsg()).buildJson();
    } catch (StockServiceException e) {
      log.error("找回密码时获取用户信息异常:" + e);
      return OpenResult.serviceError(e.getRetcode(), e.getMsg()).buildJson();
    }
  }
コード例 #25
0
 public static MediaUploadResult upload(String accessToken, String type, File file)
     throws OApiException {
   String url = Env.OAPI_HOST + "/media/upload?" + "access_token=" + accessToken + "&type=" + type;
   JSONObject response = HttpHelper.uploadMedia(url, file);
   if (!response.containsKey("type")
       || !response.containsKey("media_id")
       || response.containsKey("created_at")) {
     return JSON.parseObject(response.toJSONString(), MediaUploadResult.class);
   } else {
     throw new OApiResultException("type or media_id or create_at");
   }
 }
コード例 #26
0
 @RequestMapping("updateradiostation")
 public @ResponseBody String updateRadioStation(RadioStation radioStation) {
   JSONObject o = new JSONObject();
   try {
     radioStationService.updateRadioStation(radioStation);
     o.put("success", true);
   } catch (Exception e) {
     e.printStackTrace();
     o.put("success", false);
   }
   return o.toJSONString();
 }
コード例 #27
0
ファイル: HttpEngine.java プロジェクト: thekey123/andthink
  /**
   * 设置请求参数
   *
   * @param hashMap
   * @return
   */
  public HttpEngine setRequestParams(HashMap<String, Object> hashMap) {

    Iterator iter = hashMap.entrySet().iterator();
    JSONObject jsonObject = new JSONObject();
    while (iter.hasNext()) {
      Map.Entry entry = (Map.Entry) iter.next();
      String key = (String) entry.getKey();
      Object object = entry.getValue();
      jsonObject.put(key, object);
    }
    params.put("data", jsonObject.toJSONString());
    return this;
  }
コード例 #28
0
  @RequestMapping("/server/update")
  public String update(String params) {
    LOG.info("server update: {}", params);

    JSONObject result = new JSONObject();

    Server server = JSON.parseObject(params, Server.class);
    serverService.save(server);

    result.put("ret", 0);
    result.put("data", server);
    return result.toJSONString();
  }
コード例 #29
0
 @Override
 public ConsoleCommandBean handleCommand(
     ConsoleCommandBean bean, ConsoleCommandManager manager, Object... args) {
   ConsoleCommandBean re = new ConsoleCommandBean();
   try {
     List<String> ll = JSONObject.parseArray(JSONObject.toJSONString(bean.getOb()), String.class);
     manager.getSpiderManager().stop(ll.get(0));
     re.setCommand(ConsoleCommand.STOPSUCCESS);
   } catch (Exception e) {
     re.setCommand(ConsoleCommand.STOPFAILURE);
     re.setOb(e.getLocalizedMessage());
   }
   return re;
 }
コード例 #30
0
 @RequestMapping(value = "/doLogout", produces = "application/json; charset=UTF-8")
 @ResponseBody
 public String doLogout(HttpServletRequest request) {
   JSONObject result = new JSONObject();
   try {
     request.getSession().removeAttribute(Constants.SESSION_LOGIN_INFO_KEY);
     result.put("code", "200");
     result.put("message", "register success");
   } catch (Exception e) {
     result.put("code", "500");
     result.put("message", "fatal error. please try it again.");
   }
   return result.toJSONString();
 }