private String getClientUpdateLogWhere(JSONObject jsonobject) { if (null != jsonobject) { StringBuilder sql = new StringBuilder(); Integer equip_id = jsonobject.getInteger("equip_id"); if (null != equip_id) { sql.append("equip_id =" + equip_id + " "); } else { sql.append("equip_id is null "); } Integer column_id = jsonobject.getInteger("column_id"); sql.append("and "); if (null != column_id) { sql.append("column_id =" + column_id + " "); } else { sql.append("column_id is null "); } Integer version_id = jsonobject.getInteger("version_id"); sql.append("and "); if (null != version_id) { sql.append("version_id =" + version_id + " "); } else { sql.append("version_id is null "); } Integer version_type = jsonobject.getInteger("version_type"); sql.append("and "); if (null != version_type) { sql.append("version_type =" + version_type + " "); } else { sql.append("version_type is null "); } return sql.toString(); } return ""; }
@Override public void handleMessage(Message msg) { switch (msg.what) { case HttpClientUtil.NET_SUCCESS: for (int i = 0; i < m_person.size(); i++) { JSONObject jsonObj = m_person.getJSONObject(i); m_UserNameContent = jsonObj.getString("username"); m_UserTitleContent = jsonObj.getString("usertitle"); m_IDContent = jsonObj.getInteger("userid"); m_PostsContent = jsonObj.getInteger("posts"); m_MoneyContent = jsonObj.getInteger("money"); m_GoodnessContent = jsonObj.getInteger("goodnees"); m_UserNameContentView.setText(Html.fromHtml(m_UserNameContent)); m_UserTitleContentView.setText(Html.fromHtml(m_UserTitleContent)); m_IDContentView.setText("" + m_IDContent); m_PostsContentView.setText("" + m_PostsContent); m_MoneyContentView.setText("" + m_MoneyContent + " Kx"); m_GoodnessContentView.setText("" + m_GoodnessContent); } break; case HttpClientUtil.NET_TIMEOUT: Toast.makeText(UserInfoPage.this, R.string.net_timeout, Toast.LENGTH_SHORT).show(); break; case HttpClientUtil.NET_FAILED: Toast.makeText(UserInfoPage.this, R.string.net_failed, Toast.LENGTH_SHORT).show(); break; default: break; } }
@RequestMapping("replyList") @ResponseBody public String replyList(String uid, String params) { Result result = null; try { JSONObject jsonObject = JSON.parseObject(params); Integer pageNum = jsonObject.getInteger("pageNum"); Integer newsId = jsonObject.getInteger("cofId"); if (newsId != null) { List<COFReplyVO> replyList = cofService.getReplyListByNewsId(newsId, pageNum); result = Result.getSuccessResult(); Map<String, Object> map = Maps.newHashMap(); if (replyList != null) { map.put("size", replyList.size()); map.put("replyList", replyList); } else { map.put("size", 0); map.put("replyList", null); } result.setRe(map); } else { result = new Result(EEchoCode.ERROR.getCode(), "读取失败,动态ID不能为空"); } } catch (Exception e) { log.error(e.getMessage(), e); } finally { if (result == null) { result = new Result(EEchoCode.ERROR.getCode(), "读取失败,未找到相关的回复"); } } return ResultUtil.getJsonString(result); }
@RequestMapping("memberNewsList") @ResponseBody public String memberNewsList(String uid, String params) { Result result = null; try { JSONObject jsonObject = JSON.parseObject(params); Integer pageNum = jsonObject.getInteger("pageNum"); Integer memberId = jsonObject.getInteger("memberId"); if (memberId != null) { List<CofNewsVO> newsList = cofService.getMemberCofNewsList(pageNum, memberId); result = Result.getSuccessResult(); Map<String, Object> map = Maps.newHashMap(); if (newsList != null) { map.put("size", newsList.size()); map.put("newsList", newsList); } else { map.put("size", 0); map.put("newsList", null); } result.setRe(map); } else { result = new Result(EEchoCode.ERROR.getCode(), "读取失败,缺少用户ID"); } } catch (Exception e) { log.error(e.getMessage(), e); } finally { if (result == null) { result = new Result(EEchoCode.ERROR.getCode(), "读取失败,未找到相关的新鲜事"); } } return ResultUtil.getJsonString(result); }
@Override public String accessInfoInsert(String json) throws Exception { if (null == json || json.length() == 0) { return "{\"state\":1}"; } else { try { JSONArray jsonarray = JSON.parseArray(json); if (jsonarray.size() > 0) { Map paramMap = new HashMap(); for (int i = 0; i < jsonarray.size(); i++) { JSONObject jsonobject = (JSONObject) jsonarray.get(i); StringBuilder sql = new StringBuilder(); sql.append( "insert into access_info(box_id, res_id, action, device_type, access_time) " + "values(?,?,?,?,cast(? as datetime))"); paramMap.clear(); Integer box_id = jsonobject.getInteger("box_id"); if (null != box_id) { paramMap.put("1", box_id); } else { paramMap.put("1", " null "); } Integer res_id = jsonobject.getInteger("res_id"); if (null != res_id) { paramMap.put("2", res_id); } else { paramMap.put("2", " null "); } String action = jsonobject.getString("action"); if (null != action) { paramMap.put("3", action); } else { paramMap.put("3", " null "); } Integer device_type = jsonobject.getInteger("device_type"); if (null != device_type) { paramMap.put("4", device_type); } else { paramMap.put("4", " null "); } String access_time = jsonobject.getString("access_time"); if (access_time == null) { SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); access_time = df.format(new Date()); } paramMap.put("5", access_time); DbFactory.getSqlDdlDao().delAddUptSql(sql.toString(), paramMap); } } } catch (Exception e) { return "{\"state\":1}"; } } return "{\"state\":0}"; }
public Student(JSONObject obj) { this.userId = obj.getInteger("userId"); this.groupId = obj.getInteger("groupId"); this.userName = obj.getString("userName"); this.password = obj.getString("password"); this.userHome = obj.getString("userHome"); this.studentName = obj.getString("studentName"); this.telephone = obj.getString("telephone"); this.email = obj.getString("email"); this.weibo = obj.getString("weibo"); this.introduction = obj.getString("introduction"); this.classroomName = obj.getString("classroomName"); this.departmentName = obj.getString("departmentName"); }
@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..."); } }
// 面试中心中申请岗位 public String applyPosition() { Apply apply = new Apply(); Position position = positionDAO.findById(jsonObject.getInteger("pid")); // Staff staff = staffDAO.findById(1);//暂时默认该登录的人为1 // int sid = (Integer) ServletActionContext.getRequest().getSession().getAttribute("sid"); Staff staff = staffDAO.findById(1); // 判断是否可以插入到Apply表 if (canInsert(staff, jsonObject.getInteger("pid"))) { // 如果没有重复记录,则可以插入 apply.setPosition(position); apply.setStaff(staff); applyDAO.save(apply); applyDAO.attachDirty(apply); // 更新数据库 } return SUCCESS; }
private List<Score> generateProblemScore( JSONObject jsonInfoObj, String entityId, WeixinUser weixinUser, EntityAccount entityAccount) { // 获取问题 Score score = null; List<Score> scoreList = new ArrayList<Score>(); JSONObject jsonObj = null; // 实体用户信息 if (jsonInfoObj.containsKey("problemScore")) { JSONArray jsonArray = jsonInfoObj.getJSONArray("problemScore"); Integer var = null; if (!CollectionUtils.isEmpty(jsonArray)) { for (Object obj : jsonArray) { jsonObj = (JSONObject) obj; score = new Score(); score.setId(CommonUtil.GeneGUID()); score.setAppraisalId(entityId); score.setProblemId(jsonObj.getString("id")); var = jsonObj.getInteger("score"); score.setScore((var == null ? 0 : var)); score.setOpinion(jsonObj.getString("opinion")); score.setRaterId(weixinUser.getUserid()); score.setRaterName(weixinUser.getName()); score.setUserId(entityAccount.getAccountId()); score.setUserName(entityAccount.getAccountName()); scoreList.add(score); } } } return scoreList; }
@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(); } }
// 添加面试人记录 public String addInterview() { // System.out.println(jsonObject.getInteger("apid")); Apply apply = applyDAO.findById(jsonObject.getInteger("apid")); // System.out.println(apply); // 判断是否面试表已有该记录 if (apply.getInterviews().isEmpty()) { // 如果没有该记录,则可添加 Interview interview = new Interview(); // interview.setStaff(staffDAO.findById(1));//暂时默认面试官为1号面试官,interviewerId // int sid = (Integer) ServletActionContext.getRequest().getSession().getAttribute("sid"); interview.setStaff(staffDAO.findById(1)); interview.setApply(apply); // 通过关联映射,设置apid的值。 interview.setTime(jsonObject.getDate("date")); interview.setRemark(jsonObject.getString("remark")); // 给ranK设置一个""空字符代替NULL值,方便操作 interview.setRank(""); interview.setPass(-1); interview.setEvaluate(""); interviewDAO.save(interview); interviewDAO.attachDirty(interview); } else { map.put("exist", 1); } return SUCCESS; }
@RequestMapping("shareNews") @ResponseBody public String shareNews(String uid, String params) { Result result = null; try { JSONObject jsonObject = JSON.parseObject(params); Integer newsId = jsonObject.getInteger("cofId"); Member member = memberService.getMemberByUID(uid); if (newsId != null && member != null) { COFAffiliatedInfo affiliatedInfo = new COFAffiliatedInfo(); affiliatedInfo.setCofId(newsId); affiliatedInfo.setType(EAffiliatedType.SHARE.getCode()); affiliatedInfo.setMemberId(member.getId()); cofService.addCofAffiliated(affiliatedInfo); result = Result.getSuccessResult(); } else { result = new Result(EEchoCode.ERROR.getCode(), "缺少动态ID"); } } catch (Exception e) { log.error(e.getMessage(), e); } finally { if (result == null) { result = new Result(EEchoCode.ERROR.getCode(), "系统异常"); } } return ResultUtil.getJsonString(result); }
@RequestMapping("search") @ResponseBody public String searchNews(String uid, String params) { Result result = null; try { JSONObject jsonObject = JSON.parseObject(params); Integer pageNum = jsonObject.getInteger("pageNum"); String keyword = jsonObject.getString("keyword"); if (StringUtils.isNotEmpty(keyword)) { List<CofNewsVO> newsList = cofService.searchNews(pageNum, keyword); result = Result.getSuccessResult(); Map<String, Object> map = Maps.newHashMap(); if (newsList != null) { map.put("size", newsList.size()); map.put("newsList", newsList); } else { map.put("size", 0); map.put("newsList", null); } result.setRe(map); } else { result = new Result(EEchoCode.ERROR.getCode(), "请输入查询关键字"); } } catch (Exception e) { log.error(e.getMessage(), e); } finally { if (result == null) { result = new Result(EEchoCode.ERROR.getCode(), "读取失败,未找到相关的新鲜事"); } } return ResultUtil.getJsonString(result); }
public static YjsReqMsgDTO transViewmodelToDtoByYjsReqMsg(JSONObject data) { YjsReqMsgDTO dto = new YjsReqMsgDTO(); dto.setChannelId(data.getInteger("channelId")); dto.setCityId(data.getInteger("cityId")); dto.setCoType(data.getInteger("coType")); dto.setMobile(data.getString("phone")); dto.setOperatorUserId(data.getInteger("userId")); dto.setProvinceId(data.getInteger("provinceId")); dto.setQq(data.getString("qq")); dto.setRealname(data.getString("name")); dto.setRemark(data.getString("remark")); dto.setWechat(data.getString("wechat")); dto.setCcity(data.getInteger("ccity")); return dto; }
// 面试官给出评分 public String saveScore() { Interview interview = interviewDAO.findById((Integer) jsonObject.get("iid")); interview.setRank((String) jsonObject.get("rank")); interview.setEvaluate((String) jsonObject.get("evaluate")); interview.setPass(jsonObject.getInteger("pass")); interviewDAO.attachDirty(interview); return SUCCESS; }
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; }
@Override public PushResponse<Integer> handleResponseParams(JSONObject paramsObj) { PushResponse<Integer> response = new PushResponse<Integer>(); Integer pushCount = paramsObj.getInteger("success_amount"); response.setResult(pushCount); return response; }
/** * 更新用户信息 * * @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(); } }
/** * @param需要提供订单id,物品的消耗情况 * @need 订单进行结算,将状态修改为40,插入一条销售记录,并计算出对应订单的销售金*额的并修改(信息来源配送人员) */ @RequestMapping(value = "/order_balance_update", method = RequestMethod.POST) @ResponseBody public JSONObject order_balance_update( HttpSession httpSession, long order_id, String sell_items) { staff staff = (staff) httpSession.getAttribute("staff"); // 获取员工 if (staff == null) { return CommonUtil.constructResponse(0, "员工不存在", null); } JSONObject jsonObject = JSONObject.parseObject(sell_items); JSONArray goods = (JSONArray) jsonObject.get("foods"); List<Snacks> snacks = orderItemService.getOrderitemByDefaultOrderId_4(order_id); Float order_cost_money = Float.valueOf(0); Float order_sell_money = Float.valueOf(0); for (Object j : goods) { JSONObject jo = JSONObject.parseObject(j.toString()); for (Snacks s : snacks) { long snacks_id = Long.valueOf(jo.get("snacks_id").toString()); if (snacks_id == s.getSnacks_id()) { Integer nu = jo.getInteger("snacks_num"); if (nu == null || nu < 0 || nu > s.getSnacks_number()) { return CommonUtil.constructResponse(0, "食品数量返回错误", null); } else { order_cost_money += nu * s.getSnacks_cost_price(); order_sell_money += nu * s.getSnacks_sell_price(); } } } } for (Object j : goods) { JSONObject jo = JSONObject.parseObject(j.toString()); long snacks_id = Long.valueOf(jo.get("snacks_id").toString()); Integer snacks_number = jo.getInteger("snacks_num"); sellItemService.insertsell_items(snacks_id, snacks_number, order_id); } orderService.update_order_price_1(order_id, order_cost_money, order_sell_money); loadTask.delTask(order_id + "", "BalanceJob"); loadTask.delTask(order_id + "", "BalanceJob_1"); return CommonUtil.constructResponse(1, "结算完成", 0); }
public static Comment FromJSon(JSONObject json) { Comment comment = new Comment(); comment.competitionId = json.getString("competitionId"); comment.content = json.getString("content"); comment.likes = json.getInteger("likes"); comment.objectId = json.getString("objectId"); String dateString = json.getString("createdAt"); comment.createdAt = DateFormat.UtcToDate(dateString); String dateString2 = json.getString("updatedAt"); if (dateString == null || dateString.equals("")) comment.updateAt = comment.createdAt; else comment.updateAt = DateFormat.UtcToDate(dateString2); return comment; }
/** * 获取微信分组列表 * * @param accessToken * @return 分组列表 * @throws ServiceException ServiceException */ public static List<Group> getGroupList(String accessToken) throws ServiceException { // url String url = getRequestUrl(WechatUrlConstants.GROUPS_GET, accessToken); // call wechat service and get group list List<Group> groupList = new ArrayList<Group>(); JSONObject responseJson = getWxJSONObjectResponseFromHttpGetMethod(url); JSONArray groupArr = responseJson.getJSONArray("groups"); for (int index = 0; index < groupArr.size(); index++) { JSONObject groupJson = groupArr.getJSONObject(index); int id = groupJson.getInteger("id"); String name = groupJson.getString("name"); Integer count = groupJson.getInteger("count"); Group group = new Group(); group.setId(id); group.setName(name); group.setCount(count); groupList.add(group); } return groupList; }
public static AreaDomain getUserAreaByIP(final String ip) { AreaDomain areaDomain = null; try { JSONObject jsonObject = HttpService.doHttpRequestGetJson(requestURL.replaceAll("USERIP", ip), "GET", null); if (jsonObject.getInteger("code") == 0) { jsonObject = jsonObject.getJSONObject("data"); areaDomain = JSONObject.toJavaObject(jsonObject, AreaDomain.class); } } catch (Exception e) { logger.warn("通过淘宝API根据IP获取地址出错"); } return areaDomain; }
@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(); } }
public static boolean isSuccess(String respstr) { try { if (respstr != null) { JSONObject jo = (JSONObject) JSONObject.parse(respstr); int code = jo.getInteger("code"); if (code == 200) { return true; } } return false; } catch (Exception ex) { Log.d("MyLog", "调用删除异常"); return false; } }
/** * 查询用户所在分组 * * @param user 用户对象 * @param accessToken * @return 分组对象 * @throws ServiceException ServiceException */ public static Group getGroupOfUser(WechatUserDto user, String accessToken) throws ServiceException { // url and params String url = getRequestUrl(WechatUrlConstants.GROUPS_GET_ID, accessToken); JSONObject requestJson = new JSONObject(); requestJson.put("openid", user.getOpenId()); // call weixin service and get group object JSONObject responseJson = getWxJSONObjectResponseFromHttpPostMethod(url, requestJson); int groupId = responseJson.getInteger("groupid"); Group group = new Group(); group.setId(groupId); return group; }
/** * 微信创建分组 * * @param group 分组对象 * @param accessToken * @return 分组信息 * @throws ServiceException ServiceException */ public static Group createGroup(Group group, String accessToken) throws ServiceException { // url and params String url = getRequestUrl(WechatUrlConstants.GROUPS_CREATE, accessToken); JSONObject groupJson = new JSONObject(); groupJson.put("name", group.getName()); JSONObject requestJson = new JSONObject(); requestJson.put("group", groupJson); // call weixin service and get group object JSONObject responseJson = getWxJSONObjectResponseFromHttpPostMethod(url, requestJson); JSONObject respGroupJson = responseJson.getJSONObject("group"); Integer id = respGroupJson.getInteger("id"); group.setId(id); LOGGER.debug(respGroupJson.toJSONString()); return group; }
public ModuloQuestion(String rootString) { // parse json string JSONObject root = JSONObject.parseObject(rootString); // set question setLevel(root.getInteger("level")); setModu(root.getString("modu")); ArrayList<String> arrayBuffer = new ArrayList<>(); for (Object object : root.getJSONArray("map")) { arrayBuffer.add((String) object); } setMap(arrayBuffer); arrayBuffer.clear(); for (Object object : root.getJSONArray("pieces")) { arrayBuffer.add((String) object); } setPieces(arrayBuffer); }
@RequestMapping("getNewsInfo") @ResponseBody public String getNewsInfo(String uid, String params) { Result result = null; try { JSONObject jsonObject = JSON.parseObject(params); Integer newsId = jsonObject.getInteger("cofId"); if (newsId != null) { CofNewsVO cofNewsVO = cofService.getNewsInfoById(newsId); result = Result.getSuccessResult(); result.setRe(cofNewsVO); } else { result = new Result(EEchoCode.ERROR.getCode(), "缺少动态ID"); } } catch (Exception e) { log.error(e.getMessage(), e); } finally { if (result == null) { result = new Result(EEchoCode.ERROR.getCode(), "系统异常"); } } return ResultUtil.getJsonString(result); }
private List<ProblemTemplate> generateProblemTemplate(JSONObject jsonInfoObj, String entityId) { // 获取问题 ProblemTemplate problemTemplate = null; List<ProblemTemplate> problemTemplateList = new ArrayList<ProblemTemplate>(); JSONObject jsonObj = null; // 实体用户信息 if (jsonInfoObj.containsKey("problemList")) { JSONArray jsonArray = jsonInfoObj.getJSONArray("problemList"); if (!CollectionUtils.isEmpty(jsonArray)) { for (Object obj : jsonArray) { jsonObj = (JSONObject) obj; problemTemplate = new ProblemTemplate(); problemTemplate.setId(CommonUtil.GeneGUID()); problemTemplate.setAppraisalId(entityId); problemTemplate.setQuota(jsonObj.getString("quota")); problemTemplate.setStandard(jsonObj.getString("standard")); problemTemplate.setScores(jsonObj.getInteger("score")); problemTemplateList.add(problemTemplate); } } } return problemTemplateList; }
/** 初始化数据 */ private static void _init() { Map<Integer, ConfSkillGroup> dataMap = new HashMap<>(); // JSON数据 String confJSON = _readConfFile(); if (StringUtils.isBlank(confJSON)) return; // 填充实体数据 JSONArray confs = (JSONArray) JSONArray.parse(confJSON); for (int i = 0; i < confs.size(); i++) { JSONObject conf = confs.getJSONObject(i); ConfSkillGroup object = new ConfSkillGroup( conf.getIntValue("sn"), parseIntArray(conf.getString("activeSkills")), parseIntArray(conf.getString("passiveSkills")), conf.getIntValue("defaultSkill"), parseIntArray(conf.getString("relSkill"))); dataMap.put(conf.getInteger("sn"), object); } // 保存数据 _map = Collections.unmodifiableMap(dataMap); }