|
@@ -820,7 +820,7 @@ public class AuthServiceImpl implements AuthService {
|
|
// }
|
|
// }
|
|
//验证token是否过期
|
|
//验证token是否过期
|
|
// long dYaccessToken = redisService.getExpireTime("DYaccessToken");
|
|
// long dYaccessToken = redisService.getExpireTime("DYaccessToken");
|
|
- return redisService.getExpireTime("DYaccessToken")<0 ? ResponseJson.success(false): ResponseJson.success(true);
|
|
|
|
|
|
+ return redisService.getExpireTime("DYaccessToken")<0 ? ResponseJson.success(false): ResponseJson.success(true);
|
|
// String clintKey = "awwwvh9tsnvo54w1";//应用唯一标识
|
|
// String clintKey = "awwwvh9tsnvo54w1";//应用唯一标识
|
|
// String responestype = "code";//写死为'code'即可
|
|
// String responestype = "code";//写死为'code'即可
|
|
// String scope = "video.data,video.list,trial.whitelist,data.external.item";//应用授权作用域,多个授权作用域以英文逗号(,)分隔
|
|
// String scope = "video.data,video.list,trial.whitelist,data.external.item";//应用授权作用域,多个授权作用域以英文逗号(,)分隔
|
|
@@ -1118,7 +1118,7 @@ public class AuthServiceImpl implements AuthService {
|
|
* @param cursor 分页游标, 第一页请求cursor是0, response中会返回下一页请求用到的cursor, 同时response还会返回has_more来表明是否有更多的数据。
|
|
* @param cursor 分页游标, 第一页请求cursor是0, response中会返回下一页请求用到的cursor, 同时response还会返回has_more来表明是否有更多的数据。
|
|
* @param count 每页数量 10
|
|
* @param count 每页数量 10
|
|
*/
|
|
*/
|
|
- public String getVideoList(String openId,Integer cursor,Integer count,String accessToken){
|
|
|
|
|
|
+ public String getVideoList(String openId,Long cursor,Integer count,String accessToken){
|
|
String requestUrl="https://open.douyin.com/video/list/?open_id="+openId+"&cursor="+cursor+"&count="+count;
|
|
String requestUrl="https://open.douyin.com/video/list/?open_id="+openId+"&cursor="+cursor+"&count="+count;
|
|
//创建httppost对象
|
|
//创建httppost对象
|
|
CloseableHttpClient closeableHttpClient = HttpClients.createDefault();
|
|
CloseableHttpClient closeableHttpClient = HttpClients.createDefault();
|
|
@@ -1131,9 +1131,7 @@ public class AuthServiceImpl implements AuthService {
|
|
HttpEntity entity = execute.getEntity();
|
|
HttpEntity entity = execute.getEntity();
|
|
String result=EntityUtils.toString(entity,StandardCharsets.UTF_8);
|
|
String result=EntityUtils.toString(entity,StandardCharsets.UTF_8);
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
- String data = jsonObject.getString("data");
|
|
|
|
- JSONObject paramslist = JSONObject.parseObject(data);
|
|
|
|
- resultList = paramslist.getString("list");
|
|
|
|
|
|
+ resultList = jsonObject.getString("data");
|
|
// resultList = JSONArray.parseArray(itemIdlist);
|
|
// resultList = JSONArray.parseArray(itemIdlist);
|
|
// String itemId = params.getJSONObject(0).get("item_id").toString();
|
|
// String itemId = params.getJSONObject(0).get("item_id").toString();
|
|
//根据itemid获取视频的数据(点赞,播放,评论量)
|
|
//根据itemid获取视频的数据(点赞,播放,评论量)
|
|
@@ -1206,7 +1204,7 @@ public class AuthServiceImpl implements AuthService {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 获取已发布视频列表
|
|
|
|
|
|
+ * 获取已发布视频列表(前端)
|
|
* @param clubUserName 手机号或者机构名
|
|
* @param clubUserName 手机号或者机构名
|
|
* @param status 用户发布状态
|
|
* @param status 用户发布状态
|
|
* @param cursor 页码
|
|
* @param cursor 页码
|
|
@@ -1214,28 +1212,146 @@ public class AuthServiceImpl implements AuthService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public ResponseJson<List<ChallengeRoundVo>> getPublishedVideoList(String clubUserName,Integer status,Integer cursor,Integer count,Integer authUserId){
|
|
|
|
- List<ChallengeRoundVo> listChallengeRoundVo=authMapper.getPublishedVideoList(clubUserName,status,authUserId);
|
|
|
|
- //调用抖音api获取视频数据
|
|
|
|
- String dyopenId=redisService.get("DyopenId").toString();
|
|
|
|
- String DYaccessToken=redisService.get("DYaccessToken").toString();
|
|
|
|
- String paramsList = getVideoList(dyopenId, cursor, count, DYaccessToken);
|
|
|
|
|
|
+ public ResponseJson<PageInfo<ChallengeRoundVo>> getPublishedVideoList(String clubUserName,Integer status,Integer cursor,Integer count,Integer authUserId,Integer pageNum,Integer pageSize){
|
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
|
+ List<ChallengeRoundVo> listChallengeRoundVo=authMapper.getPublishedVideoList(clubUserName,status,authUserId);
|
|
|
|
+ PageInfo<ChallengeRoundVo> pageData = new PageInfo<>(listChallengeRoundVo);
|
|
|
|
+ //调用抖音api获取视频数据
|
|
|
|
+ String dyopenId=null;
|
|
|
|
+ String DYaccessToken=null;
|
|
|
|
+ if(redisService.getExpireTime("DyopenId")>0&&redisService.getExpireTime("DYaccessToken")>0){
|
|
|
|
+ dyopenId=redisService.get("DyopenId").toString();
|
|
|
|
+ DYaccessToken=redisService.get("DYaccessToken").toString();
|
|
|
|
+ }
|
|
|
|
+ Long flag=1l;
|
|
|
|
+ List<DyVideoInfoVo> list=new ArrayList<>();
|
|
|
|
+ while (flag!=0){
|
|
|
|
+ if (flag==1){flag=0l;}
|
|
|
|
+ String data = getVideoList(dyopenId, flag, count, DYaccessToken);
|
|
|
|
+ JSONObject paramslist = JSONObject.parseObject(data);
|
|
|
|
+ Integer error_code = Integer.valueOf(paramslist.getString("error_code"));
|
|
|
|
+ if(error_code>0){
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ String resultList = paramslist.getString("list");
|
|
|
|
+ String cor = paramslist.getString("cursor");
|
|
|
|
+ flag=Long.parseLong(cor);
|
|
|
|
+ List<DyVideoInfoVo> listDyVideoInfoVo= JSONArray.parseArray(resultList, DyVideoInfoVo.class);
|
|
|
|
|
|
- List<DyVideoInfoVo> list= JSONArray.parseArray(paramsList, DyVideoInfoVo.class);
|
|
|
|
|
|
+ if(listDyVideoInfoVo!=null&&listDyVideoInfoVo.size()>0){
|
|
|
|
+ for (DyVideoInfoVo dv:listDyVideoInfoVo) {
|
|
|
|
+ list.add(dv);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(listChallengeRoundVo!=null&&listChallengeRoundVo.size()>0){
|
|
|
|
+ for (ChallengeRoundVo ChallengeRoundVo:listChallengeRoundVo) {
|
|
|
|
+ if(StringUtils.isEmpty(ChallengeRoundVo.getDiggCount())){
|
|
|
|
+ ChallengeRoundVo.setDiggCount("0");
|
|
|
|
+ }
|
|
|
|
+ if(StringUtils.isEmpty(ChallengeRoundVo.getPlayCount())){
|
|
|
|
+ ChallengeRoundVo.setPlayCount("0");
|
|
|
|
+ }
|
|
|
|
+ if(list!=null&&list.size()>0){
|
|
|
|
+ for (DyVideoInfoVo dyVideoInfoVo:list) {
|
|
|
|
+ if(dyVideoInfoVo.getItem_id().equals(ChallengeRoundVo.getItemId())){
|
|
|
|
+ StatisticsVo StatisticsVo= JSONObject.parseObject(dyVideoInfoVo.getStatistics(), StatisticsVo.class);
|
|
|
|
+ ChallengeRoundVo.setDiggCount(StatisticsVo.getDigg_count());
|
|
|
|
+ ChallengeRoundVo.setPlayCount(StatisticsVo.getPlay_count());
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //根据点赞量降序排序
|
|
|
|
+// PageHelper.startPage(pageNum, pageSize);
|
|
|
|
+ List<ChallengeRoundVo> collect = listChallengeRoundVo.stream().sorted(Comparator.comparing(ChallengeRoundVo::getDiggCount).reversed().thenComparing(ChallengeRoundVo::getPlayCount, Comparator.reverseOrder())).collect(Collectors.toList());//先以属性一升序,升序结果进行属性一降序,再进行属性二降序
|
|
|
|
+ PageInfo<ChallengeRoundVo> pageDa = new PageInfo<>(collect);
|
|
|
|
+ return ResponseJson.success(pageDa);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取已发布视频列表(后端)
|
|
|
|
+ * @param mobile
|
|
|
|
+ * @param authParty
|
|
|
|
+ * @param status
|
|
|
|
+ * @param cursor
|
|
|
|
+ * @param count
|
|
|
|
+ * @param authUserId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<PageInfo<ChallengeRoundVo>> getPublishedVideo(String mobile,String authParty,Integer status,Integer cursor,Integer count,Integer authUserId,Integer pageNum,Integer pageSize){
|
|
|
|
+ PageHelper.startPage(pageNum, pageSize);
|
|
|
|
+ List<ChallengeRoundVo> listChallengeRoundVo=authMapper.getPublishedVideo(mobile,authParty,status,authUserId);
|
|
|
|
+ PageInfo<ChallengeRoundVo> pageData = new PageInfo<>(listChallengeRoundVo);
|
|
|
|
+ //调用抖音api获取视频数据
|
|
|
|
+ String dyopenId=null;
|
|
|
|
+ String DYaccessToken=null;
|
|
|
|
+ if(redisService.getExpireTime("DyopenId")>0&&redisService.getExpireTime("DYaccessToken")>0){
|
|
|
|
+ dyopenId=redisService.get("DyopenId").toString();
|
|
|
|
+ DYaccessToken=redisService.get("DYaccessToken").toString();
|
|
|
|
+ }
|
|
|
|
+ Long flag=1l;
|
|
|
|
+ List<DyVideoInfoVo> list=new ArrayList<>();
|
|
|
|
+ while (flag!=0){
|
|
|
|
+ if (flag==1){flag=0l;}
|
|
|
|
+ String data = getVideoList(dyopenId, flag, count, DYaccessToken);
|
|
|
|
+ JSONObject paramslist = JSONObject.parseObject(data);
|
|
|
|
+ Integer error_code = Integer.valueOf(paramslist.getString("error_code"));
|
|
|
|
+ if(error_code>0){
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ String resultList = paramslist.getString("list");
|
|
|
|
+ String cor = paramslist.getString("cursor");
|
|
|
|
+ flag=Long.parseLong(cor);
|
|
|
|
+ List<DyVideoInfoVo> listDyVideoInfoVo= JSONArray.parseArray(resultList, DyVideoInfoVo.class);
|
|
|
|
+
|
|
|
|
+ if(listDyVideoInfoVo!=null&&listDyVideoInfoVo.size()>0){
|
|
|
|
+ for (DyVideoInfoVo dv:listDyVideoInfoVo) {
|
|
|
|
+ list.add(dv);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(listChallengeRoundVo!=null&&listChallengeRoundVo.size()>0){
|
|
for (ChallengeRoundVo ChallengeRoundVo:listChallengeRoundVo) {
|
|
for (ChallengeRoundVo ChallengeRoundVo:listChallengeRoundVo) {
|
|
|
|
+ if(StringUtils.isEmpty(ChallengeRoundVo.getDiggCount())){
|
|
|
|
+ ChallengeRoundVo.setDiggCount("0");
|
|
|
|
+ }
|
|
|
|
+ if(StringUtils.isEmpty(ChallengeRoundVo.getPlayCount())){
|
|
|
|
+ ChallengeRoundVo.setPlayCount("0");
|
|
|
|
+ }
|
|
|
|
+ if(list!=null&&list.size()>0){
|
|
for (DyVideoInfoVo dyVideoInfoVo:list) {
|
|
for (DyVideoInfoVo dyVideoInfoVo:list) {
|
|
if(dyVideoInfoVo.getItem_id().equals(ChallengeRoundVo.getItemId())){
|
|
if(dyVideoInfoVo.getItem_id().equals(ChallengeRoundVo.getItemId())){
|
|
StatisticsVo StatisticsVo= JSONObject.parseObject(dyVideoInfoVo.getStatistics(), StatisticsVo.class);
|
|
StatisticsVo StatisticsVo= JSONObject.parseObject(dyVideoInfoVo.getStatistics(), StatisticsVo.class);
|
|
- ChallengeRoundVo.setDigg_count(StatisticsVo.getDigg_count());
|
|
|
|
- ChallengeRoundVo.setPlay_count(StatisticsVo.getPlay_count());
|
|
|
|
|
|
+ ChallengeRoundVo.setDiggCount(StatisticsVo.getDigg_count());
|
|
|
|
+ ChallengeRoundVo.setPlayCount(StatisticsVo.getPlay_count());
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
//根据点赞量降序排序
|
|
//根据点赞量降序排序
|
|
- List<ChallengeRoundVo> collect = listChallengeRoundVo.stream().sorted(Comparator.comparing(ChallengeRoundVo::getDigg_count).reversed().thenComparing(ChallengeRoundVo::getPlay_count, Comparator.reverseOrder())).collect(Collectors.toList());//先以属性一升序,升序结果进行属性一降序,再进行属性二降序
|
|
|
|
- return ResponseJson.success(collect);
|
|
|
|
|
|
+// PageHelper.startPage(pageNum, pageSize);
|
|
|
|
+ List<ChallengeRoundVo> collect = listChallengeRoundVo.stream().sorted(Comparator.comparing(ChallengeRoundVo::getDiggCount).reversed().thenComparing(ChallengeRoundVo::getPlayCount, Comparator.reverseOrder())).collect(Collectors.toList());//先以属性一升序,升序结果进行属性一降序,再进行属性二降序
|
|
|
|
+ PageInfo<ChallengeRoundVo> pageDa = new PageInfo<>(collect);
|
|
|
|
+ return ResponseJson.success(pageDa);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取机构已发布视频的机构下拉列表
|
|
|
|
+ * @param authUserId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<List<ChallengeRoundVo>> getAuthPartylist(Integer authUserId){
|
|
|
|
+
|
|
|
|
+ return ResponseJson.success(authMapper.getAuthPartylist(authUserId));
|
|
}
|
|
}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 保存活动信息
|
|
* 保存活动信息
|
|
* @param startTime
|
|
* @param startTime
|
|
@@ -1246,8 +1362,12 @@ public class AuthServiceImpl implements AuthService {
|
|
@Override
|
|
@Override
|
|
public ResponseJson saveActivityTime(String startTime,String endTime,Integer status,Integer authUserId){
|
|
public ResponseJson saveActivityTime(String startTime,String endTime,Integer status,Integer authUserId){
|
|
//如果数据库有值则修改,没值则新增
|
|
//如果数据库有值则修改,没值则新增
|
|
- Integer aid = authMapper.checkActivityId();
|
|
|
|
- if(aid==null){
|
|
|
|
|
|
+ List<ChallengeActivityVo> challengeList = authMapper.checkActivityId();
|
|
|
|
+ List<Integer> authUserIdList=new ArrayList<>();
|
|
|
|
+ for (ChallengeActivityVo ac:challengeList) {
|
|
|
|
+ authUserIdList.add(ac.getAuthUserId());
|
|
|
|
+ }
|
|
|
|
+ if(challengeList.size()<0||!authUserIdList.contains(authUserId)){
|
|
authMapper.saveActivityInfo(startTime,endTime,status,authUserId);
|
|
authMapper.saveActivityInfo(startTime,endTime,status,authUserId);
|
|
}else {
|
|
}else {
|
|
authMapper.upActivityInfo(startTime,endTime,status,authUserId);
|
|
authMapper.upActivityInfo(startTime,endTime,status,authUserId);
|
|
@@ -1263,10 +1383,22 @@ public class AuthServiceImpl implements AuthService {
|
|
public ResponseJson<ChallengeActivityVo> getActivityTime(Integer authUserId){
|
|
public ResponseJson<ChallengeActivityVo> getActivityTime(Integer authUserId){
|
|
return ResponseJson.success(authMapper.getActivityTime(authUserId));
|
|
return ResponseJson.success(authMapper.getActivityTime(authUserId));
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 判断shareId是否存在
|
|
|
|
+ * @param shareId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
@Override
|
|
@Override
|
|
public boolean getShareId(String shareId){
|
|
public boolean getShareId(String shareId){
|
|
return StringUtils.isNotEmpty(authMapper.getShareId(shareId));
|
|
return StringUtils.isNotEmpty(authMapper.getShareId(shareId));
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据ShareId保存itemId (webhook触发时调用)
|
|
|
|
+ * @param shareId
|
|
|
|
+ * @param itemId
|
|
|
|
+ */
|
|
@Override
|
|
@Override
|
|
public void savaItemIdByShareId(String shareId,String itemId){
|
|
public void savaItemIdByShareId(String shareId,String itemId){
|
|
authMapper.savaItemIdByShareId(shareId,itemId);
|
|
authMapper.savaItemIdByShareId(shareId,itemId);
|
|
@@ -1280,7 +1412,7 @@ public class AuthServiceImpl implements AuthService {
|
|
if(activityTime!=null){
|
|
if(activityTime!=null){
|
|
if(activityTime.getStartTime().compareTo(releaseTime)>0){
|
|
if(activityTime.getStartTime().compareTo(releaseTime)>0){
|
|
activityTime.setActivityState(0);
|
|
activityTime.setActivityState(0);
|
|
- }else if(activityTime.getStartTime().compareTo(releaseTime)<0&&activityTime.getEndtime().compareTo(releaseTime)>0){
|
|
|
|
|
|
+ }else if(activityTime.getStartTime().compareTo(releaseTime)<0&&activityTime.getEndTime().compareTo(releaseTime)>0){
|
|
activityTime.setActivityState(1);
|
|
activityTime.setActivityState(1);
|
|
}else {
|
|
}else {
|
|
activityTime.setActivityState(2);
|
|
activityTime.setActivityState(2);
|
|
@@ -1288,4 +1420,33 @@ public class AuthServiceImpl implements AuthService {
|
|
}
|
|
}
|
|
return ResponseJson.success(activityTime);
|
|
return ResponseJson.success(activityTime);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据authId获取手机号
|
|
|
|
+ * @param authId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String getMobileByAuthId(Integer authId){
|
|
|
|
+ return authMapper.getMobileByAuthId(authId);
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 根据authId获取手机号
|
|
|
|
+ * @param authId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public String getAuthUserName(Integer authId){
|
|
|
|
+ return authMapper.getAuthUserName(authId);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 保存抖音口令
|
|
|
|
+ * @param authId
|
|
|
|
+ * @return
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public void savaDyCommand(Integer authId,String content){
|
|
|
|
+ authMapper.savaDyCommand(authId,content);
|
|
|
|
+ }
|
|
}
|
|
}
|