Browse Source

修改企微推送策略

xueyiming 9 tháng trước cách đây
mục cha
commit
0af20e143b

+ 11 - 4
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/exterior/impl/WeComServiceImpl.java

@@ -3,6 +3,7 @@ package com.tzld.longarticle.recommend.server.service.exterior.impl;
 import com.alibaba.fastjson.JSON;
 import com.tzld.longarticle.recommend.server.common.enums.cgi.ReplyStrategyServiceEnum;
 import com.tzld.longarticle.recommend.server.common.response.CommonResponse;
+import com.tzld.longarticle.recommend.server.common.response.ExceptionCodeEnum;
 import com.tzld.longarticle.recommend.server.model.bo.MiniData;
 import com.tzld.longarticle.recommend.server.model.cgi.BucketDataParam;
 import com.tzld.longarticle.recommend.server.model.cgi.GroupData;
@@ -15,6 +16,7 @@ import com.tzld.longarticle.recommend.server.model.vo.WeComPushMessageVo;
 import com.tzld.longarticle.recommend.server.service.exterior.WeComService;
 import com.tzld.longarticle.recommend.server.service.strategy.reply.ReplyStrategyService;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.ApplicationContext;
@@ -31,6 +33,8 @@ import java.util.Map;
 @Service
 public class WeComServiceImpl implements WeComService {
 
+    private static final String CORP_ID = "wwa4015dc7d652a21f";
+
     @Autowired
     private ApplicationContext applicationContext;
 
@@ -43,12 +47,15 @@ public class WeComServiceImpl implements WeComService {
 
     @Override
     public CommonResponse<List<WeComPushMessageVo>> getPushMessage(WeComPushMessageParam param) {
+        if (param == null || StringUtils.isEmpty(param.getCorpId()) || !CORP_ID.equals(param.getCorpId())) {
+            return CommonResponse.create(ExceptionCodeEnum.PARAM_ERROR, "参数错误");
+        }
         List<WeComPushMessageVo> res = new ArrayList<>();
         ReplyBucketData replyBucketData = getPushMessageData(param);
         List<GroupData> groupList = replyBucketData.getGroupList();
-        log.info("groupList={}",groupList);
-        if(CollectionUtils.isEmpty(groupList)){
-            return CommonResponse.create(500,"数据异常");
+        log.info("groupList={}", groupList);
+        if (CollectionUtils.isEmpty(groupList)) {
+            return CommonResponse.create(500, "数据异常");
         }
         for (GroupData groupData : groupList) {
             if (CollectionUtils.isEmpty(groupData.getMsgDataList())) {
@@ -64,7 +71,7 @@ public class WeComServiceImpl implements WeComService {
             weComPushMessageVo.setMsgDataList(msgDataList);
             res.add(weComPushMessageVo);
         }
-        log.info("res={}",res);
+        log.info("res={}", res);
         return CommonResponse.success(res);
     }
 

+ 1 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/strategy/reply/impl/WeComPushMessageStrategyV1.java

@@ -36,7 +36,7 @@ public class WeComPushMessageStrategyV1 implements ReplyStrategyService {
      * {"base":[0,1,2,3],"stg0909-base":[4,5],"stg0909-explore1":[6,7,8],"stg0909-explore2":[9]}
      * {"stg0909-base":[5,6],"stg0909-explore1":[7],"stg0909-explore2":[8,9]}
      */
-    private static final String bucketStrategyConfig = "{\"3rd-party-base\":[0,1,2,3,4,5,6],\"3rd-party-explore1\":[7],\"3rd-party-explore2\":[8,9]}";
+    private static final String bucketStrategyConfig = "{\"we-com-base\":[0,1,2,3,4,5,6],\"we-com-explore1\":[7],\"we-com-explore2\":[8,9]}";
 
     /**
      * 自动回复使用小程序Id