/** * 我的所有微博 * * @param ac * @param oAuth * @param pBroadcastTime */ public void homeWeiboToDb( SocialUserAccount ac, OAuthV2 oAuth, TimelineParameter pBroadcastTime, boolean sign) { String response = ""; try { response = new StatusesAPI(oAuth.getOauthVersion()).homeTimeline(pBroadcastTime); } catch (Exception e) { e.printStackTrace(); } if (StringTool.judgeBlank(response)) { WeiboHandleResult r = weiboSaveDb(response, ac, DictDef.dictInt("weibo_public_timeline")); if (r.isSuccess() && r.getInfoSize() > 0) { pBroadcastTime.lastid = r.getLastid(); pBroadcastTime.pagetime = r.getPagetime(); if (!sign) { // 保存微博的最后时间 sign = true; SocialUserAccountInfo info = new SocialUserAccountInfo(); info.setKey("weibo_last_time"); // 微博最后更新时间 Date d = new Date(Long.parseLong(r.getPagetime()) * 1000); info.setAccountId(ac.getId()); info.setType(DictDef.dict("user_account_info_type")); // 帐号类型 info.setValue(StringDateUtil.parseString(d, 4)); info.setValueType(DictDef.dictInt("date")); info.setValueDate(d); socialUserAccountInfoService.createSocialUserAccountInfo(info); } homeWeiboToDb(ac, oAuth, pBroadcastTime, sign); } } }
public void updateSocialUserInfo(JSONObject userInfo, SocialUserAccount socialUserAccount) { SocialUserAccountInfo info = new SocialUserAccountInfo(); info.setType(DictDef.dict("tencent")); info.setValue(userInfo.getString("fansnum")); info.setKey(DictDef.dict("followersCount")); info.setValueType(DictDef.dictInt("int")); info.setAccountId(socialUserAccount.getId()); socialUserAccountInfoService.createSocialUserAccountInfo(info); }
/** * 设置用户帐号信息 * * @param socialUserAccount * @param key * @param value */ public void setEntityInfo(String entityId, String entityType, String key, String value) { SocialUserAccountInfo info = new SocialUserAccountInfo(); info.setKey(key); // info.setEntityId(entityId); info.setType(entityType); // 帐号类型 info.setValue(value); info.setValueString(value); info.setValueType(DictDef.dictInt("string")); createSocialUserAccountInfo(info); }
/** * 设置用户信息 * * @param socialUserAccount * @param key * @param value */ public void setSocialUserInfo(String userId, String key, String value) { SocialUserAccountInfo info = new SocialUserAccountInfo(); info.setKey(key); // info.setUserId(userId); info.setType(DictDef.dict("user_info_type")); // 用户类型 info.setValue(value); info.setValueString(value); info.setValueType(DictDef.dictInt("string")); createSocialUserAccountInfo(info); }
/** * 设置用户帐号信息 * * @param socialUserAccount * @param key * @param value */ public void setSocialUserAccountInfo( SocialUserAccount socialUserAccount, String key, String value) { SocialUserAccountInfo info = new SocialUserAccountInfo(); info.setKey(key); // info.setAccountId(socialUserAccount.getId()); info.setType(DictDef.dict("user_account_info_type")); // 帐号类型 info.setValue(value); info.setValueString(value); info.setValueType(DictDef.dictInt("string")); createSocialUserAccountInfo(info); }
private void addTokenInfos(OAuthV2 oAuth, SocialUserAccount socialUserAccount) { SocialUserAccountInfo info = newAccountInfo(socialUserAccount); info.setKey("accessToken"); info.setValue(oAuth.getAccessToken()); info.setValueType(DictDef.dictInt("string")); socialUserAccountInfoService.createSocialUserAccountInfo(info); String expireIn = oAuth.getExpiresIn(); // 失效时间 Date expiredTime = StringDateUtil.addSecond(new Date(), Integer.parseInt(expireIn)); SocialUserAccountInfo expireInfo = newAccountInfo(socialUserAccount); expireInfo.setKey("expiredTime"); expireInfo.setValue(expireIn); expireInfo.setValueDate(expiredTime); expireInfo.setValueType(DictDef.dictInt("date")); socialUserAccountInfoService.createSocialUserAccountInfo(expireInfo); SocialUserAccountInfo oInfo = newAccountInfo(socialUserAccount); oInfo.setKey("openId"); oInfo.setValue(oAuth.getOpenid()); oInfo.setValueType(DictDef.dictInt("string")); socialUserAccountInfoService.createSocialUserAccountInfo(oInfo); oInfo = newAccountInfo(socialUserAccount); oInfo.setKey("openKey"); oInfo.setValue(oAuth.getOpenkey()); oInfo.setValueType(DictDef.dictInt("string")); socialUserAccountInfoService.createSocialUserAccountInfo(oInfo); // refresh_token oInfo = newAccountInfo(socialUserAccount); oInfo.setKey("refreshToken"); oInfo.setValue(oAuth.getRefreshToken()); oInfo.setValueType(DictDef.dictInt("string")); socialUserAccountInfoService.createSocialUserAccountInfo(oInfo); }