Pārlūkot izejas kodu

增加员工名称

xueyiming 9 mēneši atpakaļ
vecāks
revīzija
fe9509a1e9

+ 29 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/StaffEnum.java

@@ -0,0 +1,29 @@
+package com.tzld.longarticle.recommend.server.common.enums;
+
+import java.util.Objects;
+
+public enum StaffEnum {
+
+    STAFF_ENUM_1("XinYi ", "精彩内容分享官"),
+    STAFF_ENUM_2("SongYi", "精彩内容推荐官"),
+    STAFF_ENUM_3("17512006748", "精彩视频福利官");
+
+    StaffEnum(String userId, String name) {
+        this.userId = userId;
+        this.name = name;
+
+    }
+
+    public final String userId;
+    public final String name;
+
+    public static String getName(String userId) {
+        for (StaffEnum staffEnum : StaffEnum.values()) {
+            if (Objects.equals(staffEnum.userId, userId)) {
+                return staffEnum.name;
+            }
+        }
+        return null;
+    }
+
+}

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

@@ -1,6 +1,7 @@
 package com.tzld.longarticle.recommend.server.service.exterior.impl;
 
 import com.alibaba.fastjson.JSON;
+import com.tzld.longarticle.recommend.server.common.enums.StaffEnum;
 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;
@@ -51,7 +52,7 @@ 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())) {
+        if (param == null || StringUtils.isEmpty(param.getCorpId()) || !CORP_ID.equals(param.getCorpId()) || StringUtils.isEmpty(param.getUserId())) {
             return CommonResponse.create(ExceptionCodeEnum.PARAM_ERROR, "参数错误");
         }
         List<WeComPushMessageVo> res = new ArrayList<>();
@@ -61,6 +62,7 @@ public class WeComServiceImpl implements WeComService {
         if (CollectionUtils.isEmpty(groupList)) {
             return CommonResponse.create(500, "数据异常");
         }
+        String name = StaffEnum.getName(param.getUserId());
         for (GroupData groupData : groupList) {
             if (CollectionUtils.isEmpty(groupData.getMsgDataList())) {
                 continue;
@@ -69,14 +71,14 @@ public class WeComServiceImpl implements WeComService {
             weComPushMessageVo.setGroupIndex(groupData.getGroupIndex());
             List<MsgData> msgDataList = groupData.getMsgDataList();
             for (MsgData msgData : msgDataList) {
-                if(msgData.getTitle().getBytes(StandardCharsets.UTF_8).length > MAX_BYTES){
+                if (msgData.getTitle().getBytes(StandardCharsets.UTF_8).length > MAX_BYTES) {
                     String s = truncateString(msgData.getTitle(), 61) + "...";
-
+                    msgData.setTitle(s);
                 }
             }
             MsgData msgData = new MsgData();
             msgData.setMsgType(3);
-            msgData.setTitle("欢迎你的到来");
+            msgData.setTitle(String.format("很高兴认识您!我是员工%s,每天给您推荐精彩视频~", name));
             msgDataList.add(0, msgData);
             weComPushMessageVo.setMsgDataList(msgDataList);
             res.add(weComPushMessageVo);