|
@@ -3,8 +3,9 @@ package com.miaxis.test;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.miaxis.NbjkApplication;
|
|
import com.miaxis.NbjkApplication;
|
|
|
|
+import com.miaxis.vip.domain.VipExamVideo;
|
|
|
|
+import com.miaxis.vip.service.IVipExamVideoService;
|
|
import com.miaxis.wx.dto.WxFreepublish;
|
|
import com.miaxis.wx.dto.WxFreepublish;
|
|
-import com.miaxis.wx.dto.WxMaterialList;
|
|
|
|
import com.miaxis.wx.service.IWxGzhService;
|
|
import com.miaxis.wx.service.IWxGzhService;
|
|
import com.miaxis.wx.service.IWxService;
|
|
import com.miaxis.wx.service.IWxService;
|
|
import org.junit.Test;
|
|
import org.junit.Test;
|
|
@@ -15,6 +16,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
@SpringBootTest(classes = NbjkApplication.class)
|
|
@SpringBootTest(classes = NbjkApplication.class)
|
|
@@ -25,6 +27,9 @@ public class WxGzhTest {
|
|
private IWxGzhService wxGzhService;
|
|
private IWxGzhService wxGzhService;
|
|
@Autowired
|
|
@Autowired
|
|
private IWxService wxService;
|
|
private IWxService wxService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IVipExamVideoService vipExamVideoService;
|
|
|
|
+
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void getUserInfo() throws IOException {
|
|
public void getUserInfo() throws IOException {
|
|
@@ -48,12 +53,13 @@ public class WxGzhTest {
|
|
}
|
|
}
|
|
|
|
|
|
@Test
|
|
@Test
|
|
- public void getWxFreepublish() {
|
|
|
|
|
|
+ public void getWxFreepublish() throws InterruptedException {
|
|
String token = wxGzhService.getGzhToken();
|
|
String token = wxGzhService.getGzhToken();
|
|
int totalCount = 0;
|
|
int totalCount = 0;
|
|
int countPerPage = 20;
|
|
int countPerPage = 20;
|
|
|
|
|
|
- // do {
|
|
|
|
|
|
+ do {
|
|
|
|
+
|
|
WxFreepublish wxFreepublish = new WxFreepublish();
|
|
WxFreepublish wxFreepublish = new WxFreepublish();
|
|
wxFreepublish.setOffset(String.valueOf(totalCount));
|
|
wxFreepublish.setOffset(String.valueOf(totalCount));
|
|
wxFreepublish.setCount(String.valueOf(countPerPage));
|
|
wxFreepublish.setCount(String.valueOf(countPerPage));
|
|
@@ -64,7 +70,7 @@ public class WxGzhTest {
|
|
JSONArray jsonArray = json.getJSONArray("item");
|
|
JSONArray jsonArray = json.getJSONArray("item");
|
|
|
|
|
|
if (jsonArray==null || jsonArray.isEmpty()) {
|
|
if (jsonArray==null || jsonArray.isEmpty()) {
|
|
- // break;
|
|
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
|
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
@@ -74,18 +80,38 @@ public class WxGzhTest {
|
|
JSONArray newsItem = content.getJSONArray("news_item");
|
|
JSONArray newsItem = content.getJSONArray("news_item");
|
|
JSONObject newsItem0 = newsItem.getJSONObject(0);
|
|
JSONObject newsItem0 = newsItem.getJSONObject(0);
|
|
String title = newsItem0.getString("title");
|
|
String title = newsItem0.getString("title");
|
|
- String url = newsItem0.getString("url");
|
|
|
|
- String thumbUrl = newsItem0.getString("thumb_url");
|
|
|
|
|
|
+ String url = newsItem0.getString("url"); //播放地址
|
|
|
|
+ String thumbUrl = newsItem0.getString("thumb_url"); //图片URL
|
|
String isDeleted = newsItem0.getString("is_deleted");
|
|
String isDeleted = newsItem0.getString("is_deleted");
|
|
|
|
|
|
- System.out.println(articleId);
|
|
|
|
- System.out.println(title);
|
|
|
|
- System.out.println(url);
|
|
|
|
- System.out.println(thumbUrl);
|
|
|
|
- System.out.println(isDeleted);
|
|
|
|
|
|
+ System.out.println("articleId:"+articleId);
|
|
|
|
+ System.out.println("tltile:"+title);
|
|
|
|
+ System.out.println("url:"+url);
|
|
|
|
+ System.out.println("thumbUrl:"+thumbUrl);
|
|
|
|
+ System.out.println("isDeleted:"+isDeleted);
|
|
System.out.println(result);
|
|
System.out.println(result);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if("false".equals(isDeleted)){ //未删除
|
|
|
|
+ VipExamVideo vipExamVideo = new VipExamVideo();
|
|
|
|
+ vipExamVideo.setVideoName(title);
|
|
|
|
+ List<VipExamVideo> vipExamVideoList = vipExamVideoService.getVipExamVideoByName(vipExamVideo);
|
|
|
|
+
|
|
|
|
+ if(vipExamVideoList!=null && vipExamVideoList.size()>0) {
|
|
|
|
+ VipExamVideo examDb = vipExamVideoList.get(0);
|
|
|
|
+ examDb.setVideoUrl(url);
|
|
|
|
+ examDb.setVideoCover(thumbUrl);
|
|
|
|
+ vipExamVideoService.updateById(examDb);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
- // } while (true);
|
|
|
|
|
|
+ totalCount += jsonArray.size();
|
|
|
|
+ Thread.sleep(13000);
|
|
|
|
+ } while (true);
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|