Procházet zdrojové kódy

修改返回格式

xueyiming před 3 měsíci
rodič
revize
25deafef0e

+ 0 - 15
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/vo/ChooseMinigramResponse.java

@@ -1,15 +0,0 @@
-package com.tzld.longarticle.recommend.server.model.vo;
-
-import lombok.Data;
-
-@Data
-public class ChooseMinigramResponse {
-
-    private String programAvatar;
-
-    private String programId;
-
-    private String programName;
-
-    private String trace_id;
-}

+ 0 - 15
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/vo/SearchVideoResponse.java

@@ -1,15 +0,0 @@
-package com.tzld.longarticle.recommend.server.model.vo;
-
-import lombok.Data;
-
-@Data
-public class SearchVideoResponse {
-
-    private String status;
-
-    private Integer code;
-
-    private String traceId;
-
-    private String info;
-}

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

@@ -5,15 +5,13 @@ import com.tzld.longarticle.recommend.server.model.param.ChooseMinigramParam;
 import com.tzld.longarticle.recommend.server.model.param.GetOffVideosParam;
 import com.tzld.longarticle.recommend.server.model.param.RecallVideosParam;
 import com.tzld.longarticle.recommend.server.model.param.SearchVideoParam;
-import com.tzld.longarticle.recommend.server.model.vo.ChooseMinigramResponse;
-import com.tzld.longarticle.recommend.server.model.vo.SearchVideoResponse;
 
 import java.io.UnsupportedEncodingException;
 
 public interface MatchVideoService {
-    CommonResponse<SearchVideoResponse> searchVideo(SearchVideoParam searchVideoParam);
+    String searchVideo(SearchVideoParam searchVideoParam);
 
-    CommonResponse<ChooseMinigramResponse> chooseMinigram(ChooseMinigramParam chooseMinigramParam);
+    String chooseMinigram(ChooseMinigramParam chooseMinigramParam);
 
     String getOffVideos(GetOffVideosParam getOffVideosParam);
 

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

@@ -12,8 +12,6 @@ import com.tzld.longarticle.recommend.server.model.param.ChooseMinigramParam;
 import com.tzld.longarticle.recommend.server.model.param.GetOffVideosParam;
 import com.tzld.longarticle.recommend.server.model.param.RecallVideosParam;
 import com.tzld.longarticle.recommend.server.model.param.SearchVideoParam;
-import com.tzld.longarticle.recommend.server.model.vo.ChooseMinigramResponse;
-import com.tzld.longarticle.recommend.server.model.vo.SearchVideoResponse;
 import com.tzld.longarticle.recommend.server.repository.longArticle.*;
 import com.tzld.longarticle.recommend.server.service.video.CardGeneratorService;
 import com.tzld.longarticle.recommend.server.service.video.MatchVideoService;
@@ -75,17 +73,17 @@ public class MatchVideoServiceImpl implements MatchVideoService {
 
     @Transactional
     @Override
-    public CommonResponse<SearchVideoResponse> searchVideo(SearchVideoParam searchVideoParam) {
+    public String searchVideo(SearchVideoParam searchVideoParam) {
+        JSONObject res = new JSONObject();
         if (StringUtils.isEmpty(searchVideoParam.getContent())
                 || StringUtils.isEmpty(searchVideoParam.getArticleId())
                 || StringUtils.isEmpty(searchVideoParam.getGhId())
                 || StringUtils.isEmpty(searchVideoParam.getAccountName())
                 || StringUtils.isEmpty(searchVideoParam.getTitle())) {
-            SearchVideoResponse searchVideoResponse = new SearchVideoResponse();
-            searchVideoResponse.setCode(1);
-            searchVideoResponse.setStatus("fail");
-            searchVideoResponse.setInfo("params check error");
-            return CommonResponse.success(searchVideoResponse);
+            res.put("code", 1);
+            res.put("status", "fail");
+            res.put("info", "params check error");
+            return res.toJSONString();
         }
         String traceId = String.format("search-%s-%s", UUID.randomUUID(), System.currentTimeMillis() / 1000);
         LongArticlesMatchVideo longArticlesMatchVideo = new LongArticlesMatchVideo();
@@ -94,6 +92,7 @@ public class MatchVideoServiceImpl implements MatchVideoService {
         longArticlesMatchVideo.setFlowPoolLevel(searchVideoParam.getFlowPoolLevelTag());
         longArticlesMatchVideo.setGhId(searchVideoParam.getGhId());
         longArticlesMatchVideo.setAccountName(searchVideoParam.getAccountName());
+        longArticlesMatchVideo.setUpdateTime(new Date());
         longArticlesMatchVideo.setRequestTimestamp(System.currentTimeMillis() / 1000);
         if (searchVideoParam.getPublishFlag() == null) {
             longArticlesMatchVideo.setPublishFlag(1);
@@ -115,34 +114,34 @@ public class MatchVideoServiceImpl implements MatchVideoService {
             crawlerProduceIdMap.setContentId(searchVideoParam.getArticleId());
             crawlerProduceIdMapRepository.save(crawlerProduceIdMap);
         }
-        SearchVideoResponse searchVideoResponse = new SearchVideoResponse();
-        searchVideoResponse.setCode(0);
-        searchVideoResponse.setStatus("success input to article queue");
-        searchVideoResponse.setTraceId(traceId);
-        return CommonResponse.success(searchVideoResponse);
+
+        res.put("code", 0);
+        res.put("status", "success input to article queue");
+        res.put("traceId", traceId);
+        return res.toJSONString();
     }
 
     @Override
-    public CommonResponse<ChooseMinigramResponse> chooseMinigram(ChooseMinigramParam chooseMinigramParam) {
+    public String chooseMinigram(ChooseMinigramParam chooseMinigramParam) {
         String ghId = chooseMinigramParam.getGhId();
-        ChooseMinigramResponse chooseMinigramResponse = new ChooseMinigramResponse();
+        JSONObject res = new JSONObject();
         if (ghId != null && EXPERIMENT_27_GH_ID_SET.contains(ghId)) {
-            chooseMinigramResponse.setProgramAvatar(MinigramEnum.XYMHFQDD_27.getAvatar());
-            chooseMinigramResponse.setProgramId(MinigramEnum.XYMHFQDD_27.getId());
-            chooseMinigramResponse.setProgramName(MinigramEnum.XYMHFQDD_27.getName());
-            chooseMinigramResponse.setTrace_id(chooseMinigramParam.getTraceId());
+            res.put("programAvatar", MinigramEnum.XYMHFQDD_27.getAvatar());
+            res.put("programId", MinigramEnum.XYMHFQDD_27.getId());
+            res.put("programName", MinigramEnum.XYMHFQDD_27.getName());
+            res.put("trace_id", chooseMinigramParam.getTraceId());
         } else if (ghId != null && ghIdInPqVideo.contains(ghId)) {
-            chooseMinigramResponse.setProgramAvatar(MinigramEnum.PQSP4.getAvatar());
-            chooseMinigramResponse.setProgramId(MinigramEnum.PQSP4.getId());
-            chooseMinigramResponse.setProgramName(MinigramEnum.PQSP4.getName());
-            chooseMinigramResponse.setTrace_id(chooseMinigramParam.getTraceId());
+            res.put("programAvatar", MinigramEnum.PQSP4.getAvatar());
+            res.put("programId", MinigramEnum.PQSP4.getId());
+            res.put("programName", MinigramEnum.PQSP4.getName());
+            res.put("trace_id", chooseMinigramParam.getTraceId());
         } else {
-            chooseMinigramResponse.setProgramAvatar(MinigramEnum.VLOG0.getAvatar());
-            chooseMinigramResponse.setProgramId(MinigramEnum.VLOG0.getId());
-            chooseMinigramResponse.setProgramName(MinigramEnum.VLOG0.getName());
-            chooseMinigramResponse.setTrace_id(chooseMinigramParam.getTraceId());
+            res.put("programAvatar", MinigramEnum.VLOG0.getAvatar());
+            res.put("programId", MinigramEnum.VLOG0.getId());
+            res.put("programName", MinigramEnum.VLOG0.getName());
+            res.put("trace_id", chooseMinigramParam.getTraceId());
         }
-        return CommonResponse.success(chooseMinigramResponse);
+        return res.toJSONString();
     }
 
     @Override

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

@@ -5,8 +5,6 @@ import com.tzld.longarticle.recommend.server.model.param.ChooseMinigramParam;
 import com.tzld.longarticle.recommend.server.model.param.GetOffVideosParam;
 import com.tzld.longarticle.recommend.server.model.param.RecallVideosParam;
 import com.tzld.longarticle.recommend.server.model.param.SearchVideoParam;
-import com.tzld.longarticle.recommend.server.model.vo.ChooseMinigramResponse;
-import com.tzld.longarticle.recommend.server.model.vo.SearchVideoResponse;
 import com.tzld.longarticle.recommend.server.service.video.MatchVideoService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -24,12 +22,12 @@ public class MatchVideoController {
     private MatchVideoService matchVideoService;
 
     @PostMapping("/searchVideos")
-    public CommonResponse<SearchVideoResponse> searchVideo(@RequestBody SearchVideoParam searchVideoParam) {
+    public String searchVideo(@RequestBody SearchVideoParam searchVideoParam) {
         return matchVideoService.searchVideo(searchVideoParam);
     }
 
     @PostMapping("/chooseMinigram")
-    public CommonResponse<ChooseMinigramResponse> chooseMinigram(@RequestBody ChooseMinigramParam chooseMinigramParam) {
+    public String chooseMinigram(@RequestBody ChooseMinigramParam chooseMinigramParam) {
         return matchVideoService.chooseMinigram(chooseMinigramParam);
     }