Browse Source

删除异常

xueyiming 3 months ago
parent
commit
dbe317a4cc

+ 1 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/video/CardGeneratorService.java

@@ -6,5 +6,5 @@ import java.io.UnsupportedEncodingException;
 
 public interface CardGeneratorService {
 
-    CardData generateCards(String ghId, String response, Integer miniprogramUseType) throws UnsupportedEncodingException;
+    CardData generateCards(String ghId, String response, Integer miniprogramUseType);
 }

+ 1 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/video/MatchVideoService.java

@@ -16,5 +16,5 @@ public interface MatchVideoService {
 
     JSONObject getOffVideos(GetOffVideosParam getOffVideosParam);
 
-    JSONObject recallVideos(RecallVideosParam recallVideosParam) throws UnsupportedEncodingException;
+    JSONObject recallVideos(RecallVideosParam recallVideosParam);
 }

+ 37 - 32
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/video/impl/CardGeneratorServiceImpl.java

@@ -22,7 +22,7 @@ public class CardGeneratorServiceImpl implements CardGeneratorService {
     @ApolloJsonValue("${miniMap:{}}")
     private JSONObject miniProgramMap;
 
-    public CardData generateCards(String ghId, String response, Integer miniprogramUseType) throws UnsupportedEncodingException {
+    public CardData generateCards(String ghId, String response, Integer miniprogramUseType) {
         JSONArray jsonArray = JSONArray.parseArray(response);
         CardData cardData = new CardData();
         List<JSONObject> cardList = new ArrayList<>();
@@ -40,7 +40,7 @@ public class CardGeneratorServiceImpl implements CardGeneratorService {
     }
 
     public JSONObject generateSingleCard(Integer index, String ghId, Integer miniId, JSONObject item,
-                                         Integer miniprogramUseType) throws UnsupportedEncodingException {
+                                         Integer miniprogramUseType) {
         String strMiniId = String.valueOf(miniId);
         JSONObject miniInfo = miniProgramMap.getJSONObject(strMiniId);
         String avatar = miniInfo.getString("avatar");
@@ -74,37 +74,42 @@ public class CardGeneratorServiceImpl implements CardGeneratorService {
         return result;
     }
 
-    public JSONObject createGzhPath(String videoId, String sharedUid, String ghId, Integer miniProgramType) throws UnsupportedEncodingException {
-        String rootShareId = UUID.randomUUID().toString();
-        String rootSourceId;
-        switch (miniProgramType) {
-            case 1:
-                rootSourceId = "longArticles_" + generateSourceId();
-                break;
-            case 2:
-                rootSourceId = "touliu_tencentGzhArticle_" + ghId + "_" + generateSourceId();
-                break;
-            case 3:
-                rootSourceId = "WeCom_" + generateSourceId();
-                break;
-            case 4:
-                rootSourceId = "DaiTou_" + ghId + "_" + generateSourceId();
-                break;
-            case 5:
-                rootSourceId = "gzhhzdx_" + generateSourceId();
-                break;
-            default:
-                rootSourceId = "Error mini_program_type " + miniProgramType;
-        }
+    public JSONObject createGzhPath(String videoId, String sharedUid, String ghId, Integer miniProgramType) {
+        try {
+            String rootShareId = UUID.randomUUID().toString();
+            String rootSourceId;
+            switch (miniProgramType) {
+                case 1:
+                    rootSourceId = "longArticles_" + generateSourceId();
+                    break;
+                case 2:
+                    rootSourceId = "touliu_tencentGzhArticle_" + ghId + "_" + generateSourceId();
+                    break;
+                case 3:
+                    rootSourceId = "WeCom_" + generateSourceId();
+                    break;
+                case 4:
+                    rootSourceId = "DaiTou_" + ghId + "_" + generateSourceId();
+                    break;
+                case 5:
+                    rootSourceId = "gzhhzdx_" + generateSourceId();
+                    break;
+                default:
+                    rootSourceId = "Error mini_program_type " + miniProgramType;
+            }
 
-        String url = String.format("pages/user-videos?id=%s&su=%s&fromGzh=1&rootShareId=%s&shareId=%s&rootSourceId=%s",
-                videoId, sharedUid, rootShareId, rootShareId, rootSourceId);
-        String productionPath = String.format("pages/category?jumpPage=%s", URLEncoder.encode(url, StandardCharsets.UTF_8.toString()));
-        JSONObject jsonObject = new JSONObject();
-        jsonObject.put("rootShareId", rootShareId);
-        jsonObject.put("rootSourceId", rootSourceId);
-        jsonObject.put("productionPath", productionPath);
-        return jsonObject;
+            String url = String.format("pages/user-videos?id=%s&su=%s&fromGzh=1&rootShareId=%s&shareId=%s&rootSourceId=%s",
+                    videoId, sharedUid, rootShareId, rootShareId, rootSourceId);
+            String productionPath = String.format("pages/category?jumpPage=%s", URLEncoder.encode(url, StandardCharsets.UTF_8.toString()));
+            JSONObject jsonObject = new JSONObject();
+            jsonObject.put("rootShareId", rootShareId);
+            jsonObject.put("rootSourceId", rootSourceId);
+            jsonObject.put("productionPath", productionPath);
+            return jsonObject;
+        } catch (UnsupportedEncodingException e) {
+            log.error("createGzhPath error", e);
+        }
+        return new JSONObject();
     }
 
     private String generateSourceId() {

+ 1 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/video/impl/MatchVideoServiceImpl.java

@@ -211,7 +211,7 @@ public class MatchVideoServiceImpl implements MatchVideoService {
     }
 
     @Override
-    public JSONObject recallVideos(RecallVideosParam recallVideosParam) throws UnsupportedEncodingException {
+    public JSONObject recallVideos(RecallVideosParam recallVideosParam){
         JSONObject res = new JSONObject();
         String traceId = recallVideosParam.getTraceId();
         Integer miniprogramUseType = recallVideosParam.getMiniprogramUseType();

+ 1 - 2
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/web/video/MatchVideoController.java

@@ -38,10 +38,9 @@ public class MatchVideoController {
     }
 
     @PostMapping("/recallideos")
-    public JSONObject recallVideos(@RequestBody RecallVideosParam recallVideosParam) throws UnsupportedEncodingException {
+    public JSONObject recallVideos(@RequestBody RecallVideosParam recallVideosParam) {
         return matchVideoService.recallVideos(recallVideosParam);
     }
 
 
-
 }