コード例 #1
0
ファイル: Program.java プロジェクト: kefr/sdk4j
  private void init(JSONObject json) throws XimalayaException {
    if (json != null) {
      id = json.getLong("id");
      kind = json.getString("kind");
      programName = json.getString("program_name");
      backPicUrl = json.getString("back_pic_url");

      supportBitRates = new ArrayList<Integer>();
      JSONArray supportBitRatesJsonArray = json.getJSONArray("support_bitrates");
      for (int i = 0; i < supportBitRatesJsonArray.size(); i++) {
        supportBitRates.add(supportBitRatesJsonArray.getIntValue(i));
      }

      rate24AacUrl = json.getString("rate24_aac_url");
      rate24TsUrl = json.getString("rate24_ts_url");
      rate64AacUrl = json.getString("rate64_aac_url");
      rate64TsUrl = json.getString("rate64_ts_url");

      List<LiveAnnouncer> liveAnnouncers = new ArrayList<LiveAnnouncer>();
      JSONArray liveAnnouncersJsonArray = json.getJSONArray("live_announcers");
      for (int i = 0; i < liveAnnouncersJsonArray.size(); i++) {
        liveAnnouncers.add(new LiveAnnouncer(liveAnnouncersJsonArray.getJSONObject(i)));
      }
      this.liveAnnouncers = liveAnnouncers;
      this.updatedAt = json.getLong("updated_at");
    }
  }
コード例 #2
0
ファイル: PurchaseJsonFactory.java プロジェクト: jior/glaf
  public static Purchase jsonToObject(JSONObject jsonObject) {
    Purchase model = new Purchase();
    if (jsonObject.containsKey("purchaseid")) {
      model.setPurchaseid(jsonObject.getLong("purchaseid"));
    }
    if (jsonObject.containsKey("purchaseno")) {
      model.setPurchaseno(jsonObject.getString("purchaseno"));
    }
    if (jsonObject.containsKey("area")) {
      model.setArea(jsonObject.getString("area"));
    }
    if (jsonObject.containsKey("company")) {
      model.setCompany(jsonObject.getString("company"));
    }
    if (jsonObject.containsKey("dept")) {
      model.setDept(jsonObject.getString("dept"));
    }
    if (jsonObject.containsKey("post")) {
      model.setPost(jsonObject.getString("post"));
    }
    if (jsonObject.containsKey("appuser")) {
      model.setAppuser(jsonObject.getString("appuser"));
    }
    if (jsonObject.containsKey("appdate")) {
      model.setAppdate(jsonObject.getDate("appdate"));
    }
    if (jsonObject.containsKey("purchasesum")) {
      model.setPurchasesum(jsonObject.getDouble("purchasesum"));
    }
    if (jsonObject.containsKey("status")) {
      model.setStatus(jsonObject.getInteger("status"));
    }
    if (jsonObject.containsKey("processname")) {
      model.setProcessname(jsonObject.getString("processname"));
    }
    if (jsonObject.containsKey("processinstanceid")) {
      model.setProcessinstanceid(jsonObject.getLong("processinstanceid"));
    }
    if (jsonObject.containsKey("wfstatus")) {
      model.setWfstatus(jsonObject.getLong("wfstatus"));
    }
    if (jsonObject.containsKey("createBy")) {
      model.setCreateBy(jsonObject.getString("createBy"));
    }
    if (jsonObject.containsKey("createDate")) {
      model.setCreateDate(jsonObject.getDate("createDate"));
    }
    if (jsonObject.containsKey("updateDate")) {
      model.setUpdateDate(jsonObject.getDate("updateDate"));
    }
    if (jsonObject.containsKey("updateBy")) {
      model.setUpdateBy(jsonObject.getString("updateBy"));
    }

    return model;
  }
コード例 #3
0
ファイル: FriendService.java プロジェクト: huangludong/cotty
  @Override
  public void onResponse(CottyResponse cottyResponse) {
    System.out.println(cottyResponse.getContent());
    JSONObject jsonObject = JSONObject.parseObject(cottyResponse.getContent());
    Map<Long, CottyFriend> cottyFriendMap = new HashMap<Long, CottyFriend>();

    if (jsonObject.getInteger("retcode").equals(0)) {
      JSONObject resultObject = jsonObject.getJSONObject("result");
      JSONArray friendArray = resultObject.getJSONArray("friends");
      JSONArray infoArray = resultObject.getJSONArray("info");
      JSONArray marknameArray = resultObject.getJSONArray("marknames");
      JSONArray vipArray = resultObject.getJSONArray("vipinfo");

      for (int i = 0; i < friendArray.size(); i++) {
        JSONObject friendObject = friendArray.getJSONObject(i);
        CottyFriend cottyFriend = new CottyFriend().setUIN(friendObject.getLong("uin"));
        cottyFriendMap.put(friendObject.getLong("uin"), cottyFriend);
      }
      for (int i = 0; i < infoArray.size(); i++) {
        JSONObject infoObject = infoArray.getJSONObject(i);
        CottyFriend cottyFriend = cottyFriendMap.get(infoObject.getLong("uin"));
        if (cottyFriend != null) {
          cottyFriend
              .setFaceCode(infoObject.getInteger("face"))
              .setNick(infoObject.getString("nick"));
        }
      }

      for (int i = 0; i < marknameArray.size(); i++) {
        JSONObject markObject = marknameArray.getJSONObject(i);
        CottyFriend cottyFriend = cottyFriendMap.get(markObject.getLong("uin"));
        if (cottyFriend != null) {
          cottyFriend.setMarkName(markObject.getString("markname"));
        }
      }

      for (int i = 0; i < vipArray.size(); i++) {
        JSONObject vipObject = vipArray.getJSONObject(i);
        CottyFriend cottyFriend = cottyFriendMap.get(vipObject.getLong("u"));
        if (cottyFriend != null) {
          cottyFriend
              .setVIP(vipObject.getInteger("is_vip").equals(1) ? true : false)
              .setVIPLevel(vipObject.getInteger("vip_level"));
        }
      }
      this.cottySession.addAttribute("cottyFriend", cottyFriendMap);
    } else {
      throw new CottyException("friend return unknow data...");
    }
  }
コード例 #4
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();
   }
 }
コード例 #5
0
 /**
  * JsonObject 转换为User对象
  *
  * @param userJson
  * @return
  */
 private static WechatUserDto jsonObject2User(JSONObject userJson) {
   String subscribe = userJson.getString("subscribe");
   String openId = userJson.getString("openid");
   String nickname = userJson.getString("nickname");
   int sex = userJson.getIntValue("sex");
   String language = userJson.getString("language");
   String city = userJson.getString("city");
   String province = userJson.getString("province");
   String country = userJson.getString("country");
   String headImgUrl = userJson.getString("headimgurl");
   long subscribeTime = userJson.getLong("subscribe_time");
   String unionid = userJson.getString("unionid");
   String remark = userJson.getString("remark");
   int groupid = userJson.getIntValue("groupid");
   WechatUserDto responseUser = new WechatUserDto();
   responseUser.setCity(city);
   responseUser.setSubscribe(subscribe);
   responseUser.setOpenId(openId);
   responseUser.setNickname(nickname);
   responseUser.setSex(sex);
   responseUser.setLanguage(language);
   responseUser.setProvince(province);
   responseUser.setCountry(country);
   responseUser.setHeadImgUrl(headImgUrl);
   responseUser.setSubscribeTime(subscribeTime);
   responseUser.setUnionId(unionid);
   responseUser.setRemark(remark);
   responseUser.getGroup().setId(groupid);
   return responseUser;
 }
コード例 #6
0
ファイル: UserOldRest.java プロジェクト: zyflao/rest
  /**
   * 获取手机验证码
   *
   * @param headers
   * @param content
   * @return
   */
  @Path("/get/code")
  @POST
  @Produces("application/json;charset=utf-8")
  public String getCode(String content) {
    // 参数是否为空
    if (StringUtils.isEmpty("content")) {
      return OpenResult.parameterError("无参数").buildJson();
    }
    JSONObject json = JSONObject.parseObject(content);
    String mobileno = json.getString("mobileno");

    // 手机注册验证码:201;手机找回密码:205,重置密码:253
    String codetype = json.getString("codetype");
    if (StringUtils.isEmpty(mobileno) || StringUtils.isEmpty(codetype)) {
      return OpenResult.parameterError("参数错误").buildJson();
    }
    // 验证手机号格式是否正确
    boolean flag = ValidateUtil.isMobile(mobileno);
    if (!flag) {
      return OpenResult.serviceError(10119, "手机号码有误").buildJson();
    }
    // 手机号是否已被注册
    JSONObject result = registService.mobileUnique(mobileno);

    if (result != null) {
      if (result.getIntValue("retcode") != 0) {
        return OpenResult.serviceError(result.getIntValue("retcode"), result.getString("msg"))
            .buildJson();
      }
    } else {
      return OpenResult.unknown("服务异常").buildJson();
    }
    try {
      // 获取手机验证码
      result = registService.getIdentifyingCode(mobileno);
      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();
      }
      MobileCodeResult mobileCodeResult = new MobileCodeResult();
      Long expiredtime = result.getLong("expiredtime");
      mobileCodeResult.setExpiredtime(expiredtime);
      return OpenResult.ok().add("data", mobileCodeResult).buildJson();
    } catch (StockServiceException e) {
      log.error("注册时获取手机验证码异常:" + e);
      return OpenResult.serviceError(e.getRetcode(), e.getMsg()).buildJson();
    }
  }
コード例 #7
0
ファイル: UserOldRest.java プロジェクト: zyflao/rest
 @Path("/findpwd/getcode")
 @POST
 @Produces("application/json;charset=utf-8")
 public String getCodeForFindPwd(String content) {
   if (StringUtils.isEmpty(content)) {
     return OpenResult.parameterError("无参数").buildJson();
   }
   JSONObject json = JSONObject.parseObject(content);
   String idNumber = json.getString("idNumber");
   if (StringUtils.isEmpty(idNumber)) {
     return OpenResult.parameterError("参数错误").buildJson();
   }
   try {
     boolean flag = checkIdNumber(idNumber);
     if (log.isDebugEnabled()) {
       log.debug("找回密码自延期" + flag);
     }
     JSONObject result = null;
     String userId = null;
     String mobileno = null;
     json = getUser(idNumber);
     if (json != null) {
       userId = json.getString("userid");
       mobileno = json.getString("mobileno");
     } else {
       JSONObject info = personalService.queryUserInfo(idNumber);
       if (info != null) {
         mobileno = info.getString("mobileno");
         userId = info.getString("userid");
       } else {
         return OpenResult.parameterError("请输入注册身份证号码").buildJson();
       }
     }
     result = personalService.getCodeForfindPasswd(userId, mobileno);
     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();
   }
 }