소스 검색

更新traceId写入

xueyiming 7 달 전
부모
커밋
91d09f8f33

+ 26 - 18
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/impl/ContentServiceImpl.java

@@ -16,10 +16,7 @@ import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.concurrent.TimeUnit;
 
 @Slf4j
@@ -40,6 +37,7 @@ public class ContentServiceImpl implements ContentService {
     @Autowired
     private PublishContentMapper publishContentMapper;
 
+
     public MatchVideo getContent(String contentId, String ghId, Integer publishFlag) {
         MatchVideoExample matchVideoExample = new MatchVideoExample();
         matchVideoExample.createCriteria().andGhIdEqualTo(ghId).andContentIdEqualTo(contentId)
@@ -61,24 +59,34 @@ public class ContentServiceImpl implements ContentService {
         return publishMiniprograms;
     }
 
-    public String updateMatchContent(String contentId, String ghId, JSONArray jsonArray, Integer publishFlag) {
-        MatchVideoExample matchVideoExample = new MatchVideoExample();
-        matchVideoExample.createCriteria().andGhIdEqualTo(ghId).andContentIdEqualTo(contentId)
-                .andPublishFlagEqualTo(publishFlag);
-        List<MatchVideo> matchVideos = matchVideoMapper.selectByExample(matchVideoExample);
-        if (CollectionUtils.isEmpty(matchVideos)) {
-            return null;
+    public void updateMatchContent(PublishContent publishContent, String ghId, JSONArray jsonArray) {
+        try {
+            MatchVideoExample matchVideoExample = new MatchVideoExample();
+            matchVideoExample.createCriteria().andGhIdEqualTo(ghId).andContentIdEqualTo(publishContent.getSourceId())
+                    .andPublishFlagIn(Arrays.asList(1, 2));
+            matchVideoExample.setOrderByClause("publish_flag desc");
+            List<MatchVideo> matchVideos = matchVideoMapper.selectByExample(matchVideoExample);
+            if (CollectionUtils.isEmpty(matchVideos)) {
+                return;
+            }
+            String traceId = matchVideos.get(0).getTraceId();
+            MatchVideo matchVideo = matchVideos.get(0);
+            MatchVideo updateMatchVideo = new MatchVideo();
+            updateMatchVideo.setId(matchVideo.getId());
+            updateMatchVideo.setContentStatus(4);
+            updateMatchVideo.setPublishFlag(2);
+            updateMatchVideo.setResponse(jsonArray.toJSONString());
+            matchVideoMapper.updateByPrimaryKeySelective(updateMatchVideo);
+            updatePublishContentTraceId(traceId, publishContent.getId());
+        } catch (Exception e) {
+            log.error("updateMatchContent error", e);
         }
-        MatchVideo matchVideo = matchVideos.get(0);
-        MatchVideo updateMatchVideo = new MatchVideo();
-        updateMatchVideo.setId(matchVideo.getId());
-        updateMatchVideo.setContentStatus(4);
-        updateMatchVideo.setResponse(jsonArray.toJSONString());
-        matchVideoMapper.updateByPrimaryKeySelective(updateMatchVideo);
-        return matchVideo.getTraceId();
     }
 
     public void updatePublishContentTraceId(String traceId, Long publishContentId) {
+        if (StringUtils.isEmpty(traceId)) {
+            return;
+        }
         PublishContent publishContent = new PublishContent();
         publishContent.setTraceId(traceId);
         publishContent.setId(publishContentId);

+ 1 - 2
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/impl/CoreServiceImpl.java

@@ -545,8 +545,7 @@ public class CoreServiceImpl implements CoreService {
                         publishMiniprogramMapper.insertSelective(publishMiniprogram);
                         publishMiniprogramList.add(publishMiniprogram);
                     }
-                    String traceId = contentService.updateMatchContent(publishArticleData.getSourceId(), planAccount.getGhId(), jsonArray, 2);
-                    contentService.updatePublishContentTraceId(traceId, publishContent.getId());
+                    contentService.updateMatchContent(publishContent, planAccount.getGhId(), jsonArray);
                 }
 
                 List<PublishMiniprogramParam> publishCardList = new ArrayList<>();

+ 2 - 2
long-article-server/src/main/java/com/tzld/piaoquan/longarticle/service/local/impl/PlanAccountServiceImpl.java

@@ -96,7 +96,7 @@ public class PlanAccountServiceImpl implements PlanAccountService {
         PlanAccount updatePlanAccount = new PlanAccount();
         updatePlanAccount.setId(id);
         updatePlanAccount.setMatchStatus(status);
-        planAccountMapper.updateByPrimaryKey(updatePlanAccount);
+        planAccountMapper.updateByPrimaryKeySelective(updatePlanAccount);
     }
 
     @Override
@@ -104,7 +104,7 @@ public class PlanAccountServiceImpl implements PlanAccountService {
         PlanAccount updatePlanAccount = new PlanAccount();
         updatePlanAccount.setId(id);
         updatePlanAccount.setStatus(status);
-        planAccountMapper.updateByPrimaryKey(updatePlanAccount);
+        planAccountMapper.updateByPrimaryKeySelective(updatePlanAccount);
     }
 
     public PlanAccount getPlanAccountById(Long id) {