Browse Source

Merge branch '20250814-wyp-eurekaFeign' into test

wangyunpeng 3 weeks ago
parent
commit
4b73991838

+ 4 - 0
api-module/src/main/java/com/tzld/piaoquan/api/GrowthServerApplication.java

@@ -3,6 +3,8 @@ package com.tzld.piaoquan.api;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.web.servlet.ServletComponentScan;
+import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
+import org.springframework.cloud.openfeign.EnableFeignClients;
 import org.springframework.context.annotation.ComponentScan;
 import springfox.documentation.swagger2.annotations.EnableSwagger2;
 
@@ -15,6 +17,8 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
 })
 @EnableSwagger2
 @ServletComponentScan("com.tzld.piaoquan.api.filter")
+@EnableDiscoveryClient
+@EnableFeignClients
 public class GrowthServerApplication {
     public static void main(String[] args) {
         SpringApplication.run(GrowthServerApplication.class, args);

+ 1 - 0
api-module/src/main/java/com/tzld/piaoquan/api/common/enums/ExceptionEnum.java

@@ -50,6 +50,7 @@ public enum ExceptionEnum {
 
     // 自动回复
     CGI_REPLY_BUCKET_DATA_NOT_FOUND(10000, "自动回复数据不存在"),
+    CGI_REPLY_BUCKET_DATA_NOT_AUTO_REPLY(10001, "非自动回复数据"),
     ;
     private int code;
     private String msg;

+ 1 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/impl/ContentPlatformPlanServiceImpl.java

@@ -309,6 +309,7 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
             } else {
                 BucketDataParam bucketDataParam = new BucketDataParam();
                 bucketDataParam.setGhId(account.getGhId());
+                bucketDataParam.setAccountName(account.getName());
                 cgiReplyService.getRgiReplyData(bucketDataParam);
             }
         }

+ 10 - 1
api-module/src/main/java/com/tzld/piaoquan/api/service/impl/CgiReplyServiceImpl.java

@@ -131,19 +131,28 @@ public class CgiReplyServiceImpl implements CgiReplyService {
     @Override
     public List<CgiReplyBucketData> getCgiReplyBucketDataListByRootSourceId(String rootSourceId) {
         CgiReplyBucketDataExample example = new CgiReplyBucketDataExample();
-        example.createCriteria().andRootSourceIdEqualTo(rootSourceId).andIsDeleteEqualTo(0);
+        example.createCriteria().andRootSourceIdEqualTo(rootSourceId);
         return cgiReplyBucketDataMapper.selectByExample(example);
     }
 
     @Override
     public VideoCharacteristicVO getVideoCharacteristicByRootSourceId(String rootSourceId) {
+        if (!rootSourceId.startsWith("dyyjs")) {
+            throw new CommonException(ExceptionEnum.CGI_REPLY_BUCKET_DATA_NOT_AUTO_REPLY);
+        }
         String redisKey = "auto_reply_video_detail_" + rootSourceId;
         String value = redisUtils.get(redisKey);
         if (StringUtils.isNotEmpty(value)) {
             return JSONObject.parseObject(value, VideoCharacteristicVO.class);
         }
+        String blackListKey = "auto_reply_video_detail_black_list_" + rootSourceId;
+        String blackListValue = redisUtils.get(blackListKey);
+        if (StringUtils.isNotEmpty(blackListValue)) {
+            throw new CommonException(ExceptionEnum.CGI_REPLY_BUCKET_DATA_NOT_FOUND);
+        }
         List<CgiReplyBucketData> list = getCgiReplyBucketDataListByRootSourceId(rootSourceId);
         if (CollectionUtils.isEmpty(list)) {
+            redisUtils.set(blackListKey, "1", 60 * 60);
             throw new CommonException(ExceptionEnum.CGI_REPLY_BUCKET_DATA_NOT_FOUND);
         }
         list.sort(Comparator.comparing(CgiReplyBucketData::getCreateTime).reversed());

+ 1 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/impl/ThirdPartyServiceImpl.java

@@ -171,6 +171,7 @@ public class ThirdPartyServiceImpl implements ThirdPartyService {
             if (replyStrategyService.support(ReplyStrategyServiceEnum.THIRD_PARTY_PUSH_MESSAGE_STRATEGY_V1)) {
                 BucketDataParam bucketDataParam = new BucketDataParam();
                 bucketDataParam.setGhId(ghDetail.getGhId());
+                bucketDataParam.setAccountName(ghDetail.getGhName());
                 bucketDataParam.setChannel(ghDetail.getChannel());
                 bucketDataParam.setStrategyStatus(ghDetail.getStrategyStatus());
                 if (StringUtils.isNotEmpty(ghDetail.getVideoIds())) {

+ 13 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/strategy/impl/BuckStrategyV1.java

@@ -7,6 +7,7 @@ import com.tzld.piaoquan.api.common.enums.ReplyStrategyServiceEnum;
 import com.tzld.piaoquan.api.component.TouLiuHttpClient;
 import com.tzld.piaoquan.api.dao.mapper.AlgGhAutoreplyVideoRankDataMapper;
 import com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhPlanVideo;
+import com.tzld.piaoquan.api.model.vo.VideoCharacteristicVO;
 import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformPlanService;
 import com.tzld.piaoquan.growth.common.common.enums.StrategyStatusEnum;
 import com.tzld.piaoquan.growth.common.dao.mapper.CgiReplyBucketDataMapper;
@@ -18,6 +19,7 @@ import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketData;
 import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketDataExample;
 import com.tzld.piaoquan.api.service.strategy.ReplyStrategyService;
 import com.tzld.piaoquan.growth.common.utils.MessageUtil;
+import com.tzld.piaoquan.growth.common.utils.RedisUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
@@ -76,6 +78,9 @@ public class BuckStrategyV1 implements ReplyStrategyService {
     @Autowired
     private ContentPlatformPlanService contentPlatformPlanService;
 
+    @Autowired
+    private RedisUtils redisUtils;
+
     @Override
     public ReplyBucketData getResult(BucketDataParam bucketDataParam) {
         // 0 获取策略key
@@ -256,6 +261,14 @@ public class BuckStrategyV1 implements ReplyStrategyService {
             // 入库
             for (CgiReplyBucketData cgiReplyBucketData : collect) {
                 cgiReplyBucketDataMapper.insertSelective(cgiReplyBucketData);
+                String redisKey = "auto_reply_video_detail_" + cgiReplyBucketData.getRootSourceId();
+                VideoCharacteristicVO vo = new VideoCharacteristicVO();
+                vo.setGhId(cgiReplyBucketData.getGhId());
+                vo.setName(bucketDataParam.getAccountName());
+                vo.setVideoId(cgiReplyBucketData.getMiniVideoId());
+                vo.setTitle(cgiReplyBucketData.getTitle());
+                vo.setCover(cgiReplyBucketData.getCoverUrl());
+                redisUtils.set(redisKey, JSONObject.toJSONString(vo), 3L * 24 * 60 * 60);
             }
         }
     }

+ 13 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/strategy/impl/ThirdPartyPushMessageStrategyV1.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 
 import com.tzld.piaoquan.api.common.enums.ReplyStrategyServiceEnum;
 import com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhPlanVideo;
+import com.tzld.piaoquan.api.model.vo.VideoCharacteristicVO;
 import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformPlanService;
 import com.tzld.piaoquan.growth.common.common.enums.StrategyStatusEnum;
 import com.tzld.piaoquan.api.component.TouLiuHttpClient;
@@ -17,6 +18,7 @@ import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketData;
 import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketDataExample;
 import com.tzld.piaoquan.api.service.strategy.ReplyStrategyService;
 import com.tzld.piaoquan.growth.common.utils.MessageUtil;
+import com.tzld.piaoquan.growth.common.utils.RedisUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
@@ -66,6 +68,9 @@ public class ThirdPartyPushMessageStrategyV1 implements ReplyStrategyService {
     @Autowired
     private ContentPlatformPlanService contentPlatformPlanService;
 
+    @Autowired
+    private RedisUtils redisUtils;
+
     @Override
     public ReplyBucketData getResult(BucketDataParam bucketDataParam) {
         log.info("ThirdPartyPushMessageStrategyV1 start");
@@ -161,6 +166,14 @@ public class ThirdPartyPushMessageStrategyV1 implements ReplyStrategyService {
             // 入库
             for (CgiReplyBucketData cgiReplyBucketData : collect) {
                 cgiReplyBucketDataMapper.insertSelective(cgiReplyBucketData);
+                String redisKey = "auto_reply_video_detail_" + cgiReplyBucketData.getRootSourceId();
+                VideoCharacteristicVO vo = new VideoCharacteristicVO();
+                vo.setGhId(cgiReplyBucketData.getGhId());
+                vo.setName(bucketDataParam.getAccountName());
+                vo.setVideoId(cgiReplyBucketData.getMiniVideoId());
+                vo.setTitle(cgiReplyBucketData.getTitle());
+                vo.setCover(cgiReplyBucketData.getCoverUrl());
+                redisUtils.set(redisKey, JSONObject.toJSONString(vo), 3L * 24 * 60 * 60);
             }
         }
     }

+ 13 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/strategy/impl/WeComPushMessageStrategyV1.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.tzld.piaoquan.api.common.enums.ReplyStrategyServiceEnum;
 import com.tzld.piaoquan.api.component.TouLiuHttpClient;
 import com.tzld.piaoquan.api.dao.mapper.AlgGhAutoreplyVideoRankDataMapper;
+import com.tzld.piaoquan.api.model.vo.VideoCharacteristicVO;
 import com.tzld.piaoquan.growth.common.common.enums.StrategyStatusEnum;
 import com.tzld.piaoquan.growth.common.dao.mapper.CgiReplyBucketDataMapper;
 import com.tzld.piaoquan.api.model.bo.*;
@@ -14,6 +15,7 @@ import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketData;
 import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketDataExample;
 import com.tzld.piaoquan.api.service.strategy.ReplyStrategyService;
 import com.tzld.piaoquan.growth.common.utils.MessageUtil;
+import com.tzld.piaoquan.growth.common.utils.RedisUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
@@ -60,6 +62,9 @@ public class WeComPushMessageStrategyV1 implements ReplyStrategyService {
     @Autowired
     private TouLiuHttpClient touLiuHttpClient;
 
+    @Autowired
+    private RedisUtils redisUtils;
+
     @Override
     public ReplyBucketData getResult(BucketDataParam bucketDataParam) {
         log.info("ThirdPartyPushMessageStrategyV1 start");
@@ -155,6 +160,14 @@ public class WeComPushMessageStrategyV1 implements ReplyStrategyService {
             // 入库
             for (CgiReplyBucketData cgiReplyBucketData : collect) {
                 cgiReplyBucketDataMapper.insertSelective(cgiReplyBucketData);
+                String redisKey = "auto_reply_video_detail_" + cgiReplyBucketData.getRootSourceId();
+                VideoCharacteristicVO vo = new VideoCharacteristicVO();
+                vo.setGhId(cgiReplyBucketData.getGhId());
+                vo.setName(bucketDataParam.getAccountName());
+                vo.setVideoId(cgiReplyBucketData.getMiniVideoId());
+                vo.setTitle(cgiReplyBucketData.getTitle());
+                vo.setCover(cgiReplyBucketData.getCoverUrl());
+                redisUtils.set(redisKey, JSONObject.toJSONString(vo), 3L * 24 * 60 * 60);
             }
         }
     }

+ 6 - 0
api-module/src/main/resources/application-dev.properties

@@ -19,3 +19,9 @@ apollo.meta: http://devapolloconfig-internal.piaoquantv.com
 logging.file.path=./${spring.application.name}/logs/
 
 aliyun.log.project=growth-manager-test
+
+feign.client.config.default.logger-level=NONE
+feign.client.config.default.connect-timeout=20000
+feign.client.config.default.read-timeout=20000
+
+eureka.client.serviceUrl.defaultZone=http://deveureka-internal.piaoquantv.com/eureka/

+ 6 - 0
api-module/src/main/resources/application-prod.properties

@@ -17,3 +17,9 @@ pushMessage.callback.tag=mini
 apollo.meta: http://apolloconfig-internal.piaoquantv.com
 
 aliyun.log.project=growth-manager-prod
+
+feign.client.config.default.logger-level=NONE
+feign.client.config.default.connect-timeout=20000
+feign.client.config.default.read-timeout=20000
+
+eureka.client.serviceUrl.defaultZone=http://eureka-internal.piaoquantv.com/eureka/

+ 6 - 0
api-module/src/main/resources/application-test.properties

@@ -21,3 +21,9 @@ apollo.meta: http://testapolloconfig-internal.piaoquantv.com
 logging.file.path=./${spring.application.name}/logs/
 
 aliyun.log.project=growth-manager-test
+
+feign.client.config.default.logger-level=NONE
+feign.client.config.default.connect-timeout=20000
+feign.client.config.default.read-timeout=20000
+
+eureka.client.serviceUrl.defaultZone=http://testeureka-internal.piaoquantv.com/eureka/

+ 12 - 0
pom.xml

@@ -252,6 +252,18 @@
             <artifactId>spring-boot-starter-validation</artifactId>
         </dependency>
 
+        <!-- Eureka 客户端 -->
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
+        </dependency>
+
+        <!-- OpenFeign -->
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-openfeign</artifactId>
+        </dependency>
+
     </dependencies>
 
 </project>