瀏覽代碼

增加text修改,优化代码

xueyiming 7 月之前
父節點
當前提交
eba4df6ee2
共有 18 個文件被更改,包括 146 次插入99 次删除
  1. 14 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/MessageConstant.java
  2. 0 9
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/MiniprogramConstant.java
  3. 10 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/RedisConstant.java
  4. 11 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/WeComConstant.java
  5. 12 4
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/controller/MessageController.java
  6. 7 8
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComHistoryDataJob.java
  7. 9 10
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComMessageDataJob.java
  8. 7 12
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComUserDataJob.java
  9. 11 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/vo/MessageTextVo.java
  10. 4 10
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/AccessTokenServiceImpl.java
  11. 6 6
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/MessageAttachmentServiceImpl.java
  12. 36 6
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/MessageServiceImpl.java
  13. 0 23
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/UserServiceImpl.java
  14. 1 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/MessageAttachmentService.java
  15. 5 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/MessageService.java
  16. 0 8
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/UserService.java
  17. 5 2
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/DateUtil.java
  18. 8 1
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/MessageUtil.java

+ 14 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/MessageConstant.java

@@ -0,0 +1,14 @@
+package com.tzld.piaoquan.wecom.common.constant;
+
+public interface MessageConstant {
+
+    //推送保底内容
+    String guaranteedText = "- 晚上好!愿这宁静的夜晚带给你心灵的放松与安宁,以下是大家都在看的爆款视频!";
+
+    //小程序id
+    String appid = "wx7187c217efef24a7";
+
+    String defaultName = "日常push-%s-推荐官";
+
+
+}

+ 0 - 9
we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/MiniprogramConstant.java

@@ -1,9 +0,0 @@
-package com.tzld.piaoquan.wecom.common.constant;
-
-public interface MiniprogramConstant {
-
-    String appid = "wx7187c217efef24a7";
-
-    String GUARANTEED_MINIPROGRAM_KEY = "guaranteed_miniprogram_list";
-
-}

+ 10 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/RedisConstant.java

@@ -0,0 +1,10 @@
+package com.tzld.piaoquan.wecom.common.constant;
+
+public interface RedisConstant {
+
+    String PUSH_MESSAGE_TEXT = "push_message_text";
+    String ACCESS_TOKEN = "ACCESS_TOKEN";
+
+    //小程序保底视频列表key
+    String GUARANTEED_MINIPROGRAM_KEY = "guaranteed_miniprogram_list";
+}

+ 11 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/WeComConstant.java

@@ -0,0 +1,11 @@
+package com.tzld.piaoquan.wecom.common.constant;
+
+public interface WeComConstant {
+    String CROP_ID = "1804267877438678017";
+    String SECRET = "9fe05442559750d0cc3e71c5f81217a4";
+    String POST_ACCESS_TOKEN_URL = "https://open.weibanzhushou.com/open-api/access_token/get";
+    String GET_USER_URL = "https://open.weibanzhushou.com/open-api/external_user/list";
+    String UPDATE_USER_URL = "https://open.weibanzhushou.com/open-api/external_user/update/list";
+    String GET_HISTORY_DATA_URL = "https://open.weibanzhushou.com/open-api/group_msg/result";
+    String POST_MESSAGE_PUSH_URL = "https://open.weibanzhushou.com/open-api/group_msg/add";
+}

+ 12 - 4
we-com-server/src/main/java/com/tzld/piaoquan/wecom/controller/MessageController.java

@@ -2,13 +2,12 @@ package com.tzld.piaoquan.wecom.controller;
 
 
 import com.tzld.piaoquan.wecom.common.base.CommonResponse;
+import com.tzld.piaoquan.wecom.model.vo.MessageTextVo;
 import com.tzld.piaoquan.wecom.model.vo.MiniprogramVo;
 import com.tzld.piaoquan.wecom.service.MessageAttachmentService;
+import com.tzld.piaoquan.wecom.service.MessageService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 
@@ -19,11 +18,20 @@ public class MessageController {
     @Autowired
     private MessageAttachmentService messageAttachmentService;
 
+    @Autowired
+    private MessageService messageService;
+
     @PostMapping("/miniprogram/guaranteed/create")
     public CommonResponse<Void> createGuaranteedMiniprogram(@RequestBody List<MiniprogramVo> miniprogramVoList){
         messageAttachmentService.createGuaranteedMiniprogram(miniprogramVoList);
         return CommonResponse.success();
     }
 
+    @PostMapping("/text/create")
+    public CommonResponse<Void> createMessageText(@RequestBody MessageTextVo messageTextVo){
+        messageService.createMessageText(messageTextVo);
+        return CommonResponse.success();
+    }
+
 
 }

+ 7 - 8
we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComHistoryDataJob.java

@@ -15,7 +15,7 @@ import com.tzld.piaoquan.wecom.service.HistoryMessageService;
 import com.tzld.piaoquan.wecom.service.MessageAttachmentService;
 import com.tzld.piaoquan.wecom.utils.HttpClientUtil;
 import com.tzld.piaoquan.wecom.utils.HttpPoolClient;
-import com.tzld.piaoquan.wecom.utils.MiniprogramUtil;
+import com.tzld.piaoquan.wecom.utils.MessageUtil;
 import com.tzld.piaoquan.wecom.utils.page.Page;
 import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -27,19 +27,18 @@ import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
+import static com.tzld.piaoquan.wecom.common.constant.WeComConstant.GET_HISTORY_DATA_URL;
+
 @Component
 public class WeComHistoryDataJob {
 
-    @Autowired
-    private AccessTokenService accessTokenService;
-
-
-    String GET_HISTORY_DATA_URL = "https://open.weibanzhushou.com/open-api/group_msg/result";
-
     private static final HttpPoolClient httpPoolClientDefault = HttpClientUtil.create(30000, 30000, 2000, 5000, 5, 30000);
 
     final int size = 20;
 
+    @Autowired
+    private AccessTokenService accessTokenService;
+
     @Autowired
     private UserMapper userMapper;
 
@@ -89,7 +88,7 @@ public class WeComHistoryDataJob {
                         MiniprogramRecord miniprogramRecord = new MiniprogramRecord();
                         MessageAttachment messageAttachment = new MessageAttachment();
                         String indexPage = attachments.getJSONObject(j).getJSONObject("miniprogram").getString("page");
-                        Long videoId = MiniprogramUtil.getVideoId(indexPage);
+                        Long videoId = MessageUtil.getVideoId(indexPage);
                         miniprogramRecord.setVideoId(videoId);
                         miniprogramRecord.setAttachmentIdx(j + 1);
                         miniprogramRecordList.add(miniprogramRecord);

+ 9 - 10
we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComMessageDataJob.java

@@ -1,11 +1,9 @@
 package com.tzld.piaoquan.wecom.job;
 
-import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.aliyun.odps.data.Record;
 import com.google.common.collect.Lists;
-import com.tzld.piaoquan.wecom.common.constant.MiniprogramConstant;
 import com.tzld.piaoquan.wecom.dao.mapper.MessageAttachmentMapper;
 import com.tzld.piaoquan.wecom.dao.mapper.UserMapper;
 import com.tzld.piaoquan.wecom.model.bo.PushMessage;
@@ -15,6 +13,7 @@ import com.tzld.piaoquan.wecom.model.po.User;
 import com.tzld.piaoquan.wecom.model.po.UserExample;
 import com.tzld.piaoquan.wecom.service.MessageService;
 import com.tzld.piaoquan.wecom.utils.DateUtil;
+import com.tzld.piaoquan.wecom.utils.MessageUtil;
 import com.tzld.piaoquan.wecom.utils.OdpsUtil;
 import com.tzld.piaoquan.wecom.utils.page.Page;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -25,6 +24,8 @@ import org.springframework.util.CollectionUtils;
 import java.util.*;
 import java.util.stream.Collectors;
 
+import static com.tzld.piaoquan.wecom.common.constant.RedisConstant.GUARANTEED_MINIPROGRAM_KEY;
+
 @Component
 public class WeComMessageDataJob {
 
@@ -48,8 +49,6 @@ public class WeComMessageDataJob {
     //初始化操作
     void init() {
         String sql = String.format("SELECT * FROM loghubods.history_good_video_can_push_user_list where dt = %s;", DateUtil.getBeforeDayDateString());
-//        String sql = String.format("SELECT * FROM loghubods.history_good_video_can_push_user_list where dt = %s;", "20240922");
-
         List<Record> recordList = OdpsUtil.getOdpsData(sql);
         if (CollectionUtils.isEmpty(recordList)) {
             return;
@@ -64,7 +63,7 @@ public class WeComMessageDataJob {
             list.add(pushMessage);
         }
         goodList = list;
-        List<Long> saveVideoIds = Objects.requireNonNull(redisTemplate.opsForList().range(MiniprogramConstant.GUARANTEED_MINIPROGRAM_KEY, 0, 2))
+        List<Long> saveVideoIds = Objects.requireNonNull(redisTemplate.opsForList().range(GUARANTEED_MINIPROGRAM_KEY, 0, 2))
                 .stream().map(o -> (Integer) o).map(String::valueOf).map(Long::parseLong).collect(Collectors.toList());
         if (CollectionUtils.isEmpty(saveVideoIds)) {
             throw new RuntimeException("保底数据为空");
@@ -106,8 +105,6 @@ public class WeComMessageDataJob {
                 }
             }
         }
-
-        System.out.println(res.size());
         pushMessage(res);
     }
 
@@ -148,13 +145,16 @@ public class WeComMessageDataJob {
 
     public void pushMessage(Map<String, List<String>> map) {
         List<JSONObject> pushList = new ArrayList<>();
+        //发送人员  暂时写死 只有两个
         List<String> staffExtIdList = new ArrayList<>();
         staffExtIdList.add("wogizUDQAAk5Z_5nLRD-XTAPU9poaRCw");
         staffExtIdList.add("wogizUDQAAzM5HbqIyA4k3KR6D8vKp3w");
+        String text = messageService.getMessageText();
+        String name = MessageUtil.getName();
         for (Map.Entry<String, List<String>> entry : map.entrySet()) {
             JSONObject jsonObject = new JSONObject();
-            jsonObject.put("name", "日常push-0926-推荐官");
-            jsonObject.put("text", "- 晚上好!愿这宁静的夜晚带给你心灵的放松与安宁,以下是大家都在看的爆款视频!");
+            jsonObject.put("name", name);
+            jsonObject.put("text", text);
             JSONArray attachments = new JSONArray();
             List<Long> videoIdList = Arrays.stream(entry.getKey().split("_")).map(Long::parseLong).collect(Collectors.toList());
             for (Long videoId : videoIdList) {
@@ -197,6 +197,5 @@ public class WeComMessageDataJob {
         for (JSONObject jsonObject : pushList) {
             messageService.pushMessage(jsonObject);
         }
-        System.out.println(pushList.get(0));
     }
 }

+ 7 - 12
we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComUserDataJob.java

@@ -3,17 +3,13 @@ package com.tzld.piaoquan.wecom.job;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.tzld.piaoquan.wecom.dao.mapper.UserMapper;
-import com.tzld.piaoquan.wecom.model.po.HistoryMessage;
-import com.tzld.piaoquan.wecom.model.po.HistoryMessageExample;
 import com.tzld.piaoquan.wecom.model.po.User;
 import com.tzld.piaoquan.wecom.model.po.UserExample;
 import com.tzld.piaoquan.wecom.service.AccessTokenService;
-import com.tzld.piaoquan.wecom.service.MessageService;
 import com.tzld.piaoquan.wecom.utils.HttpClientUtil;
 import com.tzld.piaoquan.wecom.utils.HttpPoolClient;
 import com.tzld.piaoquan.wecom.utils.page.Page;
 import org.apache.commons.lang3.ObjectUtils;
-import org.checkerframework.checker.units.qual.A;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
@@ -22,13 +18,11 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
+import static com.tzld.piaoquan.wecom.common.constant.WeComConstant.*;
+
 @Component
 public class WeComUserDataJob {
 
-    String GET_USER_URL = "https://open.weibanzhushou.com/open-api/external_user/list";
-
-    String UPDATE_USER_URL = "https://open.weibanzhushou.com/open-api/external_user/update/list";
-
     private static final HttpPoolClient httpPoolClientDefault = HttpClientUtil.create(30000, 30000, 2000, 5000, 5, 30000);
 
     final int size = 100;
@@ -39,6 +33,7 @@ public class WeComUserDataJob {
     @Autowired
     private AccessTokenService accessTokenService;
 
+    //初始化用户使用此任务
     public void insertAllUser() {
         try {
             Long endTime = System.currentTimeMillis() / 1000;
@@ -78,13 +73,13 @@ public class WeComUserDataJob {
         }
     }
 
-    public Integer getUserTotal(Long startTime, Long endTime) throws IOException {
+    private Integer getUserTotal(Long startTime, Long endTime) throws IOException {
         String res = getUser(1, 0, startTime, endTime);
         JSONObject jsonObject = JSONObject.parseObject(res);
         return jsonObject.getInteger("total");
     }
 
-    public String getUser(Integer limit, Integer offset, Long startTime, Long endTime) throws IOException {
+    private String getUser(Integer limit, Integer offset, Long startTime, Long endTime) throws IOException {
         String accessToken = accessTokenService.getAccessToken();
         String url = GET_USER_URL
                 + "?access_token=" + accessToken
@@ -147,13 +142,13 @@ public class WeComUserDataJob {
         }
     }
 
-    public Integer getUpdateUserTotal(Long startTime, Long endTime) throws IOException {
+    private Integer getUpdateUserTotal(Long startTime, Long endTime) throws IOException {
         String res = getUpdateUser(1, 0, startTime, endTime);
         JSONObject jsonObject = JSONObject.parseObject(res);
         return jsonObject.getInteger("total");
     }
 
-    public String getUpdateUser(Integer limit, Integer offset, Long startTime, Long endTime) throws IOException {
+    private String getUpdateUser(Integer limit, Integer offset, Long startTime, Long endTime) throws IOException {
         String accessToken = accessTokenService.getAccessToken();
         String url = UPDATE_USER_URL
                 + "?access_token=" + accessToken

+ 11 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/vo/MessageTextVo.java

@@ -0,0 +1,11 @@
+package com.tzld.piaoquan.wecom.model.vo;
+
+import lombok.Data;
+
+@Data
+public class MessageTextVo {
+
+    private String text;
+
+    private Integer hour;
+}

+ 4 - 10
we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/AccessTokenServiceImpl.java

@@ -5,8 +5,6 @@ import com.tzld.piaoquan.wecom.service.AccessTokenService;
 import com.tzld.piaoquan.wecom.utils.HttpClientUtil;
 import com.tzld.piaoquan.wecom.utils.HttpPoolClient;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.http.client.HttpClient;
-import org.apache.http.params.HttpParams;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
@@ -14,18 +12,14 @@ import org.springframework.stereotype.Service;
 import java.io.IOException;
 import java.util.concurrent.TimeUnit;
 
+import static com.tzld.piaoquan.wecom.common.constant.RedisConstant.ACCESS_TOKEN;
+import static com.tzld.piaoquan.wecom.common.constant.WeComConstant.*;
+
 @Service
 public class AccessTokenServiceImpl implements AccessTokenService {
 
     private static final HttpPoolClient httpPoolClientDefault = HttpClientUtil.create(30000, 30000, 2000, 5000, 5, 30000);
 
-    private String POST_ACCESS_TOKEN_URL = "https://open.weibanzhushou.com/open-api/access_token/get";
-    private String ACCESS_TOKEN = "ACCESS_TOKEN";
-
-    private String CROP_ID = "1804267877438678017";
-
-    private String SECRET = "9fe05442559750d0cc3e71c5f81217a4";
-
     @Autowired
     private RedisTemplate<String, Object> redisTemplate;
 
@@ -49,6 +43,6 @@ public class AccessTokenServiceImpl implements AccessTokenService {
             //TODO 打印错误日志
             e.printStackTrace();
         }
-        return null;
+        return "";
     }
 }

+ 6 - 6
we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/MessageAttachmentServiceImpl.java

@@ -1,6 +1,5 @@
 package com.tzld.piaoquan.wecom.service.Impl;
 
-import com.tzld.piaoquan.wecom.common.constant.MiniprogramConstant;
 import com.tzld.piaoquan.wecom.common.enums.MessageAttachmentTypeEnum;
 import com.tzld.piaoquan.wecom.common.exception.CustomizeException;
 import com.tzld.piaoquan.wecom.dao.mapper.MessageAttachmentMapper;
@@ -8,7 +7,7 @@ import com.tzld.piaoquan.wecom.model.po.MessageAttachment;
 import com.tzld.piaoquan.wecom.model.po.MessageAttachmentExample;
 import com.tzld.piaoquan.wecom.model.vo.MiniprogramVo;
 import com.tzld.piaoquan.wecom.service.MessageAttachmentService;
-import com.tzld.piaoquan.wecom.utils.MiniprogramUtil;
+import com.tzld.piaoquan.wecom.utils.MessageUtil;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -20,7 +19,8 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
-import static com.tzld.piaoquan.wecom.common.constant.MiniprogramConstant.*;
+import static com.tzld.piaoquan.wecom.common.constant.MessageConstant.appid;
+import static com.tzld.piaoquan.wecom.common.constant.RedisConstant.GUARANTEED_MINIPROGRAM_KEY;
 import static com.tzld.piaoquan.wecom.common.enums.ExceptionCodeEnum.PARAMS_ERROR;
 
 
@@ -66,12 +66,12 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
             if (StringUtils.isEmpty(miniprogramVo.getTitle())) {
                 throw new CustomizeException(PARAMS_ERROR);
             }
-            Long videoId = MiniprogramUtil.getVideoId(miniprogramVo.getPage());
+            Long videoId = MessageUtil.getVideoId(miniprogramVo.getPage());
             if (videoId == null) {
                 throw new CustomizeException(PARAMS_ERROR);
             }
             if (StringUtils.isEmpty(miniprogramVo.getAppid())) {
-                miniprogramVo.setAppid(MiniprogramConstant.appid);
+                miniprogramVo.setAppid(appid);
             }
             MessageAttachment messageAttachment = new MessageAttachment();
             BeanUtils.copyProperties(miniprogramVo, messageAttachment);
@@ -83,7 +83,7 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
         addMiniprogram(messageAttachmentList);
         redisTemplate.delete(GUARANTEED_MINIPROGRAM_KEY);
         Collections.reverse(videoList);
-        for (Long video : videoList){
+        for (Long video : videoList) {
             redisTemplate.opsForList().leftPush(GUARANTEED_MINIPROGRAM_KEY, video);
         }
     }

+ 36 - 6
we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/MessageServiceImpl.java

@@ -1,38 +1,68 @@
 package com.tzld.piaoquan.wecom.service.Impl;
 
 import com.alibaba.fastjson.JSONObject;
+import com.tzld.piaoquan.wecom.common.constant.MessageConstant;
+import com.tzld.piaoquan.wecom.common.exception.CustomizeException;
+import com.tzld.piaoquan.wecom.model.vo.MessageTextVo;
 import com.tzld.piaoquan.wecom.service.AccessTokenService;
 import com.tzld.piaoquan.wecom.service.MessageService;
 import com.tzld.piaoquan.wecom.utils.HttpClientUtil;
 import com.tzld.piaoquan.wecom.utils.HttpPoolClient;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpParams;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
 
 import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+import static com.tzld.piaoquan.wecom.common.constant.RedisConstant.PUSH_MESSAGE_TEXT;
+import static com.tzld.piaoquan.wecom.common.enums.ExceptionCodeEnum.PARAMS_ERROR;
+import static com.tzld.piaoquan.wecom.common.constant.WeComConstant.POST_MESSAGE_PUSH_URL;
+
 
 @Service
 public class MessageServiceImpl implements MessageService {
 
     private static final HttpPoolClient httpPoolClientDefault = HttpClientUtil.create(30000, 30000, 2000, 5000, 5, 30000);
 
-    private final String POST_MESSAGE_PUSH_URL = "https://open.weibanzhushou.com/open-api/group_msg/add";
-
     @Autowired
     private AccessTokenService accessTokenService;
 
+    @Autowired
+    private RedisTemplate<String, Object> redisTemplate;
+
     public void pushMessage(JSONObject jsonObject) {
         try {
             String accessToken = accessTokenService.getAccessToken();
             String url = POST_MESSAGE_PUSH_URL
                     + "?access_token=" + accessToken;
-//            HttpParams params = new BasicHttpParams();
-//            params.setParameter("access_token", accessToken);
             String s = httpPoolClientDefault.post(url, jsonObject.toJSONString());
             System.out.println(s);
         } catch (IOException e) {
             e.printStackTrace();
         }
     }
+
+    @Override
+    public void createMessageText(MessageTextVo messageTextVo) {
+        if (messageTextVo == null || messageTextVo.getHour() == null) {
+            throw new CustomizeException(PARAMS_ERROR);
+        }
+        if (messageTextVo.getHour() == -1) {
+            redisTemplate.opsForValue().set(PUSH_MESSAGE_TEXT, messageTextVo.getText());
+        } else {
+            redisTemplate.opsForValue().set(PUSH_MESSAGE_TEXT, messageTextVo.getText(), messageTextVo.getHour(), TimeUnit.HOURS);
+        }
+    }
+
+
+    @Override
+    public String getMessageText() {
+        String text = (String) redisTemplate.opsForValue().get(PUSH_MESSAGE_TEXT);
+        if (StringUtils.isEmpty(text)) {
+            return MessageConstant.guaranteedText;
+        }
+        return text;
+    }
 }

+ 0 - 23
we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/UserServiceImpl.java

@@ -1,23 +0,0 @@
-package com.tzld.piaoquan.wecom.service.Impl;
-
-import com.google.common.collect.Lists;
-import com.tzld.piaoquan.wecom.dao.mapper.UserMapper;
-import com.tzld.piaoquan.wecom.model.po.HistoryMessage;
-import com.tzld.piaoquan.wecom.service.UserService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
-
-import java.util.List;
-
-@Service
-public class UserServiceImpl implements UserService {
-
-    @Autowired
-    private UserMapper userMapper;
-
-    @Override
-    public Long getIdByExternalUserId3rdParty(String externalUserId3rdParty) {
-        return userMapper.selectIdByExternalUserId3rdParty(externalUserId3rdParty);
-    }
-}

+ 1 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/MessageAttachmentService.java

@@ -1,6 +1,7 @@
 package com.tzld.piaoquan.wecom.service;
 
 import com.tzld.piaoquan.wecom.model.po.MessageAttachment;
+import com.tzld.piaoquan.wecom.model.vo.MessageTextVo;
 import com.tzld.piaoquan.wecom.model.vo.MiniprogramVo;
 
 import java.util.List;

+ 5 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/MessageService.java

@@ -1,8 +1,13 @@
 package com.tzld.piaoquan.wecom.service;
 
 import com.alibaba.fastjson.JSONObject;
+import com.tzld.piaoquan.wecom.model.vo.MessageTextVo;
 
 public interface MessageService {
 
     void pushMessage(JSONObject jsonObject);
+
+    void createMessageText(MessageTextVo messageTextVo);
+
+    String getMessageText();
 }

+ 0 - 8
we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/UserService.java

@@ -1,8 +0,0 @@
-package com.tzld.piaoquan.wecom.service;
-
-import com.tzld.piaoquan.wecom.model.po.User;
-
-public interface UserService {
-
-    Long getIdByExternalUserId3rdParty(String externalUserId3rdParty);
-}

+ 5 - 2
we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/DateUtil.java

@@ -17,12 +17,15 @@ public class DateUtil {
         return calendar.getTime();
     }
 
-    public static String getBeforeDayDateString(){
+    public static String getBeforeDayDateString() {
         SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
         return dateFormat.format(new Date().getTime() - 86400000);
     }
 
-
+    public static String getDayDateString(String pattern) {
+        SimpleDateFormat dateFormat = new SimpleDateFormat(pattern);
+        return dateFormat.format(new Date().getTime());
+    }
 
 
 }

+ 8 - 1
we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/MiniprogramUtil.java → we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/MessageUtil.java

@@ -2,7 +2,9 @@ package com.tzld.piaoquan.wecom.utils;
 
 import org.apache.commons.lang3.StringUtils;
 
-public class MiniprogramUtil {
+import static com.tzld.piaoquan.wecom.common.constant.MessageConstant.defaultName;
+
+public class MessageUtil {
 
     public static Long getVideoId(String page){
         String translate = URLUtil.translate(page);
@@ -12,4 +14,9 @@ public class MiniprogramUtil {
         }
         return null;
     }
+
+    public static String getName(){
+        return String.format(defaultName, DateUtil.getDayDateString("MMdd"));
+    }
+
 }