Преглед на файлове

直播频道号检查
展会直播详情查询时获取最新密码

沈静伟 преди 3 години
родител
ревизия
a68645e447

+ 14 - 0
src/dsb/com/cnd3b/restcontroller/customer/live/live.java

@@ -111,6 +111,20 @@ public class live extends Controller {
      * @return
      */
     public String getLiveInfo() throws P2Exception {
+        try {
+            Rows channelidrows = dbConnect.runSqlQuery("select channelid from tlive where tagentsid='" + tagentsid + "' and categoryName = 'Õ¹»áÖ±²¥'");
+            for (Row row : channelidrows) {
+                String channelid = row.getString("channelid");
+                Polyv polyv = new Polyv();
+                LiveChannelInfoResponse liveChannelInfoResponse = polyv.getChannelInfo(channelid);
+                if (liveChannelInfoResponse != null) {
+                    String channelpasswd = liveChannelInfoResponse.getChannelPasswd();
+                    dbConnect.runSqlUpdate("update tlive set channelpasswd='" + channelpasswd + "' where channelid='" + channelid + "'");
+                }
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
         SQLFactory sqlFactory = new SQLFactory(this, "Õ¹»áÖ±²¥ÏêÇé");
         sqlFactory.addParameter("siteid", siteid);
         sqlFactory.addParameter("tagentsid", tagentsid);

+ 27 - 1
src/dsb/com/cnd3b/service/GetPolyvAnalysisData.java

@@ -1,7 +1,9 @@
 package com.cnd3b.service;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.cnd3b.common.BaseClass;
+import com.cnd3b.common.data.Row;
 import com.cnd3b.common.data.Rows;
 import com.cnd3b.common.data.RowsMap;
 import com.cnd3b.common.data.SQLFactory;
@@ -23,6 +25,7 @@ public class GetPolyvAnalysisData extends BaseClass implements Runnable {
     public void run() {
         if (new SQLiteJDBC().checkServicesUsed("GetPolyvAnalysisData", false)) {
             try {
+                checkChannelids();
                 getLiveStatusAndCoverImageUrl();
             } catch (Exception e) {
                 e.printStackTrace();
@@ -35,12 +38,35 @@ public class GetPolyvAnalysisData extends BaseClass implements Runnable {
         }
     }
 
+    /**
+     * ¼ì²éƵµÀºÅ
+     */
+    public void checkChannelids() {
+        Polyv polyv = new Polyv();
+        JSONArray channelids = polyv.getChannelids();
+        if (channelids != null) {
+            ArrayList<String> list = new ArrayList<>();
+            for (Object o : channelids) {
+                list.add(String.valueOf(o));
+            }
+            DBConnect dbConnect = new DBConnect();
+            Rows channelRows = dbConnect.runSqlQuery("select channelid from tlive");
+            for (Row row : channelRows) {
+                String channelid = row.getString("channelid");
+                if (!list.contains(channelid)) {
+                    System.err.println(channelid);
+                    dbConnect.runSqlUpdate("update tlive set livestatus='deleted' where channelid='" + channelid + "'");
+                }
+            }
+        }
+    }
+
     /**
      * ͬ²½ÆµµÀÖ±²¥×´Ì¬,¼°»ñȡֱ²¥·âÃæÍ¼
      */
     public void getLiveStatusAndCoverImageUrl() {
         DBConnect dbConnect = new DBConnect();
-        Rows channelRows = dbConnect.runSqlQuery("select channelid,livestatus,tagentsid,siteid from tlive");
+        Rows channelRows = dbConnect.runSqlQuery("select channelid,livestatus,tagentsid,siteid from tlive where livestatus!='deleted'");
         String[] channelids = channelRows.toArray("channelid");
         RowsMap map = channelRows.toRowsMap("channelid");
         Polyv polyv = new Polyv();

+ 26 - 0
src/dsb/com/cnd3b/utility/polyv/Polyv.java

@@ -598,4 +598,30 @@ public class Polyv extends BaseClass {
         return categoryMap;
     }
 
+    public JSONArray getChannelids() {
+        //公共参数,填写自己的实际
+        try {
+            String timestamp = String.valueOf(System.currentTimeMillis());
+            //业务参数
+            String url = "http://api.polyv.net/live/v3/user/channels";
+            // String categoryId = "340019";
+            //String keyword = "讨论";
+
+            //http 调用逻辑
+            Map<String, String> requestMap = new HashMap<>();
+            requestMap.put("appId", appid);
+            requestMap.put("timestamp", timestamp);
+            /// requestMap.put("categoryId", categoryId);
+            // requestMap.put("keyword", keyword);
+            requestMap.put("sign", LiveSignUtil.getSign(requestMap, appSecret));
+            String response = HttpUtil.get(url, requestMap, null);
+            JSONObject object = JSONObject.parseObject(response);
+            if ("success".equalsIgnoreCase(object.getString("status"))) {
+                return object.getJSONObject("data").getJSONArray("channels");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
 }