Bläddra i källkod

Merge branch 'dev-xym-filter-history' of Server/we-com-manage into master

xueyiming 7 månader sedan
förälder
incheckning
cab8eeb7f9
53 ändrade filer med 4141 tillägg och 640 borttagningar
  1. 21 4
      pom.xml
  2. 80 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/base/CommonResponse.java
  3. 14 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/MessageConstant.java
  4. 10 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/RedisConstant.java
  5. 13 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/ResponseConstant.java
  6. 9 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/TimeConstant.java
  7. 11 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/WeComConstant.java
  8. 27 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/enums/ExceptionCodeEnum.java
  9. 21 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/enums/MessageAttachmentTypeEnum.java
  10. 20 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/enums/TimeEnum.java
  11. 25 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/exception/CustomizeException.java
  12. 43 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/config/RedisConfig.java
  13. 39 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/controller/MessageController.java
  14. 34 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/dao/generator/MybatisGeneratorMain.java
  15. 76 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/dao/generator/PaginationPlugin.java
  16. 36 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/dao/mapper/HistoryMessageMapper.java
  17. 32 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/dao/mapper/MessageAttachmentMapper.java
  18. 8 67
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/dao/mapper/UserMapper.java
  19. 166 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComHistoryDataJob.java
  20. 204 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComMessageDataJob.java
  21. 118 38
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComUserDataJob.java
  22. 12 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/bo/MiniprogramRecord.java
  23. 13 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/bo/PushMessage.java
  24. 92 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/HistoryMessage.java
  25. 632 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/HistoryMessageExample.java
  26. 147 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/MessageAttachment.java
  27. 992 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/MessageAttachmentExample.java
  28. 0 336
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/User.java
  29. 11 102
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/UserExample.java
  30. 11 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/vo/MessageTextVo.java
  31. 18 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/vo/MiniprogramVo.java
  32. 6 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/AccessTokenService.java
  33. 10 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/HistoryMessageService.java
  34. 48 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/AccessTokenServiceImpl.java
  35. 29 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/HistoryMessageServiceImpl.java
  36. 90 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/MessageAttachmentServiceImpl.java
  37. 68 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/MessageServiceImpl.java
  38. 0 20
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/UserServiceImpl.java
  39. 14 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/MessageAttachmentService.java
  40. 13 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/MessageService.java
  41. 0 8
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/UserService.java
  42. 35 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/DateUtil.java
  43. 1 1
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/HttpClientUtil.java
  44. 8 4
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/HttpPoolClient.java
  45. 22 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/MessageUtil.java
  46. 33 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/OdpsUtil.java
  47. 10 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/URLUtil.java
  48. 108 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/page/Page.java
  49. 12 0
      we-com-server/src/main/resources/application.properties
  50. 270 0
      we-com-server/src/main/resources/mapper/HistoryMessageMapper.xml
  51. 326 0
      we-com-server/src/main/resources/mapper/MessageAttachmentMapper.xml
  52. 44 60
      we-com-server/src/main/resources/mapper/UserMapper.xml
  53. 59 0
      we-com-server/src/main/resources/mybatis-generator-config.xml

+ 21 - 4
pom.xml

@@ -18,10 +18,6 @@
     <name>we-com-manage</name>
     <description>we-com-manage</description>
 
-    <properties>
-        <stuuudy.commons.utils.version>1.0-SNAPSHOT</stuuudy.commons.utils.version>
-        <aliyun.rocketmq.version>1.8.4.Final</aliyun.rocketmq.version>
-    </properties>
 
     <dependencies>
         <dependency>
@@ -44,6 +40,21 @@
             <artifactId>pagehelper-spring-boot-starter</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-data-redis</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>io.lettuce</groupId>
+            <artifactId>lettuce-core</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-pool2</artifactId>
+        </dependency>
+
         <dependency>
             <groupId>org.mybatis.generator</groupId>
             <artifactId>mybatis-generator-core</artifactId>
@@ -97,6 +108,12 @@
             <artifactId>fastjson</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>com.aliyun.odps</groupId>
+            <artifactId>odps-sdk-core</artifactId>
+            <version>0.27.2-public</version>
+        </dependency>
+
     </dependencies>
 
 </project>

+ 80 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/base/CommonResponse.java

@@ -0,0 +1,80 @@
+package com.tzld.piaoquan.wecom.common.base;
+
+import com.tzld.piaoquan.wecom.common.enums.ExceptionCodeEnum;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+import static com.tzld.piaoquan.wecom.common.constant.ResponseConstant.SUCCESS_CODE;
+import static com.tzld.piaoquan.wecom.common.constant.ResponseConstant.SUCCESS_MSG;
+
+/**
+ * Common Response
+ *
+ * @author xueyiming
+ */
+@Setter
+@Getter
+@ToString
+public class CommonResponse<T> {
+    /**
+     * 返回状态码,0 表示业务成功
+     */
+    private int code = 0;
+    /**
+     * 返回消息
+     */
+    private String msg = "success";
+    /**
+     * 业务成功时返回数据
+     */
+    private T data;
+
+    public static <T> CommonResponse<T> success() {
+        CommonResponse<T> commonResponse = new CommonResponse<>();
+        commonResponse.setCode(SUCCESS_CODE);
+        commonResponse.setMsg(SUCCESS_MSG);
+        return commonResponse;
+    }
+
+    public static <T> CommonResponse<T> success(T data) {
+        CommonResponse<T> commonResponse = new CommonResponse<>();
+        commonResponse.setCode(SUCCESS_CODE);
+        commonResponse.setMsg(SUCCESS_MSG);
+        commonResponse.setData(data);
+        return commonResponse;
+    }
+
+    public static <T> CommonResponse<T> create() {
+        return create(SUCCESS_CODE, SUCCESS_MSG, null);
+    }
+
+    public static <T> CommonResponse<T> create(T data) {
+        return create(SUCCESS_CODE, SUCCESS_MSG, data);
+    }
+
+    public static <T> CommonResponse<T> create(ExceptionCodeEnum exceptionCodeEnum) {
+        return create(exceptionCodeEnum.getCode(), exceptionCodeEnum.getMsg(), null);
+    }
+
+    public static <T> CommonResponse<T> create(ExceptionCodeEnum exceptionCodeEnum, String msg) {
+        return create(exceptionCodeEnum.getCode(), msg, null);
+    }
+
+    public static <T> CommonResponse<T> create(int code, String msg) {
+        return create(code, msg, null);
+    }
+
+    public static <T> CommonResponse<T> create(int code, String msg, T data) {
+        CommonResponse<T> commonResponse = new CommonResponse<>();
+        commonResponse.setCode(code);
+        commonResponse.setMsg(msg);
+        commonResponse.setData(data);
+        return commonResponse;
+    }
+
+    public boolean isSuccess() {
+        return this.code == SUCCESS_CODE;
+    }
+
+}

+ 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-推荐官";
+
+
+}

+ 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";
+}

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

@@ -0,0 +1,13 @@
+package com.tzld.piaoquan.wecom.common.constant;
+
+/**
+ * 响应常量
+ *
+ * @author xueyiming
+ */
+public interface ResponseConstant {
+
+    int SUCCESS_CODE = 0;
+
+    String SUCCESS_MSG = "success";
+}

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

@@ -0,0 +1,9 @@
+package com.tzld.piaoquan.wecom.common.constant;
+
+public interface TimeConstant {
+
+    Integer MINUTE = 60;
+    Integer HOUR = 60 * 60;
+    Integer DAY = 60 * 60 * 24;
+
+}

+ 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";
+}

+ 27 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/enums/ExceptionCodeEnum.java

@@ -0,0 +1,27 @@
+package com.tzld.piaoquan.wecom.common.enums;
+
+import lombok.Getter;
+
+/**
+ * 异常
+ *
+ * @author xueyiming
+ */
+@Getter
+public enum ExceptionCodeEnum {
+    /**
+     * 自定义异常信息
+     */
+    SYSTEM_ERROR(1000, "系统错误"),
+    PARAMS_ERROR(2001, "参数错误")
+    ;
+
+    private final int code;
+    private final String msg;
+
+    ExceptionCodeEnum(int code, String msg) {
+        this.code = code;
+        this.msg = msg;
+    }
+
+}

+ 21 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/enums/MessageAttachmentTypeEnum.java

@@ -0,0 +1,21 @@
+package com.tzld.piaoquan.wecom.common.enums;
+
+import lombok.Getter;
+
+@Getter
+public enum MessageAttachmentTypeEnum {
+
+    DEFAULT(0,"未知"),
+    IMAGE(1,"图片"),
+    LINK(2,"链接"),
+    MINIPROGRAM(3, "小程序"),
+    VIDEO(4, "视频");
+
+    final Integer type;
+    final String desc;
+    MessageAttachmentTypeEnum(Integer type, String desc){
+        this.type = type;
+        this.desc = desc;
+    }
+
+}

+ 20 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/enums/TimeEnum.java

@@ -0,0 +1,20 @@
+package com.tzld.piaoquan.wecom.common.enums;
+
+import lombok.Getter;
+
+@Getter
+public enum TimeEnum {
+
+    SECOND(1, "秒"),
+    MINUTE(60, "分"),
+    HOUR(60 * 60, "小时"),
+    DAY(60 * 60 * 24, "天");
+
+    final Integer time;
+    final String desc;
+
+    TimeEnum(Integer time, String desc) {
+        this.time = time;
+        this.desc = desc;
+    }
+}

+ 25 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/exception/CustomizeException.java

@@ -0,0 +1,25 @@
+package com.tzld.piaoquan.wecom.common.exception;
+
+
+import com.tzld.piaoquan.wecom.common.enums.ExceptionCodeEnum;
+import lombok.Getter;
+import lombok.Setter;
+
+@Setter
+@Getter
+public class CustomizeException extends RuntimeException {
+
+    private static final long serialVersionUID = 1L;
+
+    private ExceptionCodeEnum exceptionCodeEnum;
+
+    public CustomizeException(ExceptionCodeEnum exceptionCodeEnum) {
+        super(exceptionCodeEnum.getMsg());
+        this.exceptionCodeEnum = exceptionCodeEnum;
+    }
+
+    public CustomizeException(ExceptionCodeEnum exceptionCodeEnum, String msg) {
+        super(msg);
+        this.exceptionCodeEnum = exceptionCodeEnum;
+    }
+}

+ 43 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/config/RedisConfig.java

@@ -0,0 +1,43 @@
+package com.tzld.piaoquan.wecom.config;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.PropertyAccessor;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.RedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+@Configuration
+public class RedisConfig {
+
+    @Bean
+    public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory){
+        RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
+        redisTemplate.setConnectionFactory(redisConnectionFactory);
+        //设置value的序列化方式json
+        redisTemplate.setValueSerializer(redisSerializer());
+        //设置key序列化方式String
+        redisTemplate.setKeySerializer(new StringRedisSerializer());
+        //设置hash key序列化方式String
+        redisTemplate.setHashKeySerializer(new StringRedisSerializer());
+        //设置hash value序列化json
+        redisTemplate.setHashValueSerializer(redisSerializer());
+        redisTemplate.afterPropertiesSet();
+        return redisTemplate;
+    }
+
+    public RedisSerializer<Object> redisSerializer() {
+        //创建JSON序列化器
+        ObjectMapper objectMapper = new ObjectMapper();
+        objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
+        //必须设置,否则无法序列化实体类对象
+        objectMapper.activateDefaultTyping(LaissezFaireSubTypeValidator.instance, ObjectMapper.DefaultTyping.NON_FINAL);
+        return new GenericJackson2JsonRedisSerializer(objectMapper);
+    }
+
+}

+ 39 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/controller/MessageController.java

@@ -0,0 +1,39 @@
+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.*;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/wecom/message")
+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();
+    }
+
+    //创建新text 有时限和无时限  新创建覆盖原text 未创建取默认保底
+    @PostMapping("/text/create")
+    public CommonResponse<Void> createMessageText(@RequestBody MessageTextVo messageTextVo){
+        messageService.createMessageText(messageTextVo);
+        return CommonResponse.success();
+    }
+
+
+}

+ 34 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/dao/generator/MybatisGeneratorMain.java

@@ -0,0 +1,34 @@
+package com.tzld.piaoquan.wecom.dao.generator;
+
+import org.mybatis.generator.api.MyBatisGenerator;
+import org.mybatis.generator.config.Configuration;
+import org.mybatis.generator.config.xml.ConfigurationParser;
+import org.mybatis.generator.exception.InvalidConfigurationException;
+import org.mybatis.generator.exception.XMLParserException;
+import org.mybatis.generator.internal.DefaultShellCallback;
+
+import java.io.File;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author ehlxr
+ * @since 2021-12-14 14:03.
+ */
+public class MybatisGeneratorMain {
+
+    public static void main(String[] args)
+            throws SQLException, IOException, InterruptedException, InvalidConfigurationException, XMLParserException {
+        List<String> warnings = new ArrayList<>();
+
+        File configFile = new File(MybatisGeneratorMain.class.getResource("/mybatis-generator-config.xml").getFile());
+        ConfigurationParser cp = new ConfigurationParser(warnings);
+        Configuration config = cp.parseConfiguration(configFile);
+        DefaultShellCallback callback = new DefaultShellCallback(true);
+        MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
+        myBatisGenerator.generate(null);
+        System.out.println("genreate finish");
+    }
+}

+ 76 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/dao/generator/PaginationPlugin.java

@@ -0,0 +1,76 @@
+package com.tzld.piaoquan.wecom.dao.generator;
+
+import org.mybatis.generator.api.CommentGenerator;
+import org.mybatis.generator.api.IntrospectedTable;
+import org.mybatis.generator.api.PluginAdapter;
+import org.mybatis.generator.api.dom.java.*;
+import org.mybatis.generator.api.dom.xml.Attribute;
+import org.mybatis.generator.api.dom.xml.TextElement;
+import org.mybatis.generator.api.dom.xml.XmlElement;
+
+import java.util.List;
+
+public class PaginationPlugin extends PluginAdapter {
+
+    @Override
+    public boolean modelExampleClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
+        addPage(topLevelClass, introspectedTable, "page");
+        return super.modelExampleClassGenerated(topLevelClass, introspectedTable);
+    }
+
+    @Override
+    public boolean sqlMapSelectByExampleWithoutBLOBsElementGenerated(XmlElement element, IntrospectedTable introspectedTable) {
+        XmlElement page = new XmlElement("if");
+        page.addAttribute(new Attribute("test", "page != null"));
+        page.addElement(new TextElement("limit #{page.offset} , #{page.pageSize}"));
+        element.addElement(page);
+        return super.sqlMapUpdateByExampleWithoutBLOBsElementGenerated(element, introspectedTable);
+    }
+
+    @Override
+    public boolean sqlMapSelectByExampleWithBLOBsElementGenerated(XmlElement element, IntrospectedTable introspectedTable) {
+        XmlElement page = new XmlElement("if");
+        page.addAttribute(new Attribute("test", "page != null"));
+        page.addElement(new TextElement("limit #{page.offset} , #{page.pageSize}"));
+        element.addElement(page);
+        return super.sqlMapSelectByExampleWithBLOBsElementGenerated(element, introspectedTable);
+    }
+
+    /**
+     * @param topLevelClass
+     * @param introspectedTable
+     * @param name
+     */
+    private void addPage(TopLevelClass topLevelClass, IntrospectedTable introspectedTable, String name) {
+        topLevelClass.addImportedType(new FullyQualifiedJavaType("com.tzld.piaoquan.wecom.utils.page.Page"));
+        CommentGenerator commentGenerator = context.getCommentGenerator();
+        Field field = new Field();
+        field.setVisibility(JavaVisibility.PROTECTED);
+        field.setType(new FullyQualifiedJavaType("com.tzld.piaoquan.wecom.utils.page.Page"));
+        field.setName(name);
+        commentGenerator.addFieldComment(field, introspectedTable);
+        topLevelClass.addField(field);
+        char c = name.charAt(0);
+        String camel = Character.toUpperCase(c) + name.substring(1);
+        Method method = new Method();
+        method.setVisibility(JavaVisibility.PUBLIC);
+        method.setName("set" + camel);
+        method.addParameter(new Parameter(new FullyQualifiedJavaType("com.tzld.piaoquan.wecom.utils.page.Page"), name));
+        method.addBodyLine("this." + name + "=" + name + ";");
+        commentGenerator.addGeneralMethodComment(method, introspectedTable);
+        topLevelClass.addMethod(method);
+        method = new Method();
+        method.setVisibility(JavaVisibility.PUBLIC);
+        method.setReturnType(new FullyQualifiedJavaType("com.tzld.piaoquan.wecom.utils.page.Page"));
+        method.setName("get" + camel);
+        method.addBodyLine("return " + name + ";");
+        commentGenerator.addGeneralMethodComment(method, introspectedTable);
+        topLevelClass.addMethod(method);
+    }
+
+    @Override
+    public boolean validate(List<String> arg0) {
+        return true;
+    }
+
+}

+ 36 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/dao/mapper/HistoryMessageMapper.java

@@ -0,0 +1,36 @@
+package com.tzld.piaoquan.wecom.dao.mapper;
+
+import com.tzld.piaoquan.wecom.model.po.HistoryMessage;
+import com.tzld.piaoquan.wecom.model.po.HistoryMessageExample;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
+
+
+@Repository
+public interface HistoryMessageMapper {
+    long countByExample(HistoryMessageExample example);
+
+    int deleteByExample(HistoryMessageExample example);
+
+    int deleteByPrimaryKey(Long id);
+
+    int insert(HistoryMessage record);
+
+    int insertSelective(HistoryMessage record);
+
+    List<HistoryMessage> selectByExample(HistoryMessageExample example);
+
+    HistoryMessage selectByPrimaryKey(Long id);
+
+    int updateByExampleSelective(@Param("record") HistoryMessage record, @Param("example") HistoryMessageExample example);
+
+    int updateByExample(@Param("record") HistoryMessage record, @Param("example") HistoryMessageExample example);
+
+    int updateByPrimaryKeySelective(HistoryMessage record);
+
+    int updateByPrimaryKey(HistoryMessage record);
+
+    void insertList(@Param("list") List<HistoryMessage> list);
+}

+ 32 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/dao/mapper/MessageAttachmentMapper.java

@@ -0,0 +1,32 @@
+package com.tzld.piaoquan.wecom.dao.mapper;
+
+import com.tzld.piaoquan.wecom.model.po.MessageAttachment;
+import com.tzld.piaoquan.wecom.model.po.MessageAttachmentExample;
+import java.util.List;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface MessageAttachmentMapper {
+    long countByExample(MessageAttachmentExample example);
+
+    int deleteByExample(MessageAttachmentExample example);
+
+    int deleteByPrimaryKey(Long id);
+
+    int insert(MessageAttachment record);
+
+    int insertSelective(MessageAttachment record);
+
+    List<MessageAttachment> selectByExample(MessageAttachmentExample example);
+
+    MessageAttachment selectByPrimaryKey(Long id);
+
+    int updateByExampleSelective(@Param("record") MessageAttachment record, @Param("example") MessageAttachmentExample example);
+
+    int updateByExample(@Param("record") MessageAttachment record, @Param("example") MessageAttachmentExample example);
+
+    int updateByPrimaryKeySelective(MessageAttachment record);
+
+    int updateByPrimaryKey(MessageAttachment record);
+}

+ 8 - 67
we-com-server/src/main/java/com/tzld/piaoquan/wecom/dao/mapper/UserMapper.java

@@ -2,95 +2,36 @@ package com.tzld.piaoquan.wecom.dao.mapper;
 
 import com.tzld.piaoquan.wecom.model.po.User;
 import com.tzld.piaoquan.wecom.model.po.UserExample;
-import java.util.List;
 import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+import java.util.List;
 
+@Repository
 public interface UserMapper {
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
     long countByExample(UserExample example);
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
     int deleteByExample(UserExample example);
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
     int deleteByPrimaryKey(Long id);
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
     int insert(User record);
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
     int insertSelective(User record);
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
     List<User> selectByExample(UserExample example);
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
     User selectByPrimaryKey(Long id);
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
     int updateByExampleSelective(@Param("record") User record, @Param("example") UserExample example);
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
     int updateByExample(@Param("record") User record, @Param("example") UserExample example);
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
     int updateByPrimaryKeySelective(User record);
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
     int updateByPrimaryKey(User record);
+
+    Long selectIdByExternalUserId3rdParty(String externalUserId3rdParty);
+
+    void insertList(@Param("list") List<User> list);
 }

+ 166 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComHistoryDataJob.java

@@ -0,0 +1,166 @@
+package com.tzld.piaoquan.wecom.job;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.tzld.piaoquan.wecom.common.constant.TimeConstant;
+import com.tzld.piaoquan.wecom.common.enums.MessageAttachmentTypeEnum;
+import com.tzld.piaoquan.wecom.dao.mapper.HistoryMessageMapper;
+import com.tzld.piaoquan.wecom.dao.mapper.UserMapper;
+import com.tzld.piaoquan.wecom.model.bo.MiniprogramRecord;
+import com.tzld.piaoquan.wecom.model.po.HistoryMessage;
+import com.tzld.piaoquan.wecom.model.po.HistoryMessageExample;
+import com.tzld.piaoquan.wecom.model.po.MessageAttachment;
+import com.tzld.piaoquan.wecom.service.AccessTokenService;
+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.MessageUtil;
+import com.tzld.piaoquan.wecom.utils.page.Page;
+import org.apache.commons.lang3.ObjectUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+import java.io.IOException;
+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 {
+
+    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;
+
+    @Autowired
+    private HistoryMessageMapper historyMessageMapper;
+
+    @Autowired
+    private HistoryMessageService historyMessageService;
+
+    @Autowired
+    private MessageAttachmentService messageAttachmentService;
+
+    public void selectHistoryMessageByDay() {
+        HistoryMessageExample example = new HistoryMessageExample();
+        example.setOrderByClause("create_time desc");
+        example.setPage(new Page<>(1, 1));
+        List<HistoryMessage> historyMessages = historyMessageMapper.selectByExample(example);
+        long startTime = historyMessages.get(0).getCreateTime().getTime() / 1000;
+        long endTime = System.currentTimeMillis() / 1000;
+        for (; startTime < endTime; startTime += TimeConstant.DAY) {
+            selectHistoryMessage(startTime, Math.min(startTime + TimeConstant.DAY, endTime));
+        }
+    }
+
+    public void selectHistoryMessage(Long startTime, Long endTime) {
+        try {
+            Integer total = getHistoryDataTotal(startTime, endTime);
+            if (total == null || total == 0) {
+                return;
+            }
+            int page = total / size + 1;
+            for (int n = 0; n < page; n++) {
+                String res = getHistoryData(size, n * size, startTime, endTime);
+                //TODO 记录查询数据 info日志
+                if (ObjectUtils.isEmpty(res)) {
+                    return;
+                }
+                JSONObject jsonObject = JSONObject.parseObject(res);
+                JSONArray jsonArray = jsonObject.getJSONArray("missions");
+                for (int i = 0; i < jsonArray.size(); i++) {
+                    List<String> allExternalUserList = new ArrayList<>();
+                    List<MiniprogramRecord> miniprogramRecordList = new ArrayList<>();
+                    List<MessageAttachment> messageAttachmentList = new ArrayList<>();
+                    Date createdAt = jsonArray.getJSONObject(i).getDate("created_at");
+                    JSONArray attachments = jsonArray.getJSONObject(i).getJSONObject("msg_data").getJSONArray("attachments");
+                    for (int j = 0; j < attachments.size(); j++) {
+                        MiniprogramRecord miniprogramRecord = new MiniprogramRecord();
+                        MessageAttachment messageAttachment = new MessageAttachment();
+                        String indexPage = attachments.getJSONObject(j).getJSONObject("miniprogram").getString("page");
+                        Long videoId = MessageUtil.getVideoId(indexPage);
+                        miniprogramRecord.setVideoId(videoId);
+                        miniprogramRecord.setAttachmentIdx(j + 1);
+                        miniprogramRecordList.add(miniprogramRecord);
+
+                        String cover = attachments.getJSONObject(j).getJSONObject("miniprogram").getString("cover");
+                        String appid = attachments.getJSONObject(j).getJSONObject("miniprogram").getString("appid");
+                        String title = attachments.getJSONObject(j).getJSONObject("miniprogram").getString("title");
+                        messageAttachment.setAppid(appid);
+                        messageAttachment.setCover(cover);
+                        messageAttachment.setPage(indexPage);
+                        messageAttachment.setTitle(title);
+                        messageAttachment.setMiniprogramVideoId(videoId);
+                        messageAttachment.setType(MessageAttachmentTypeEnum.MINIPROGRAM.getType());
+                        messageAttachmentList.add(messageAttachment);
+                    }
+                    JSONArray subMissionList = jsonArray.getJSONObject(i).getJSONArray("sub_mission_list");
+                    for (int k = 0; k < subMissionList.size(); k++) {
+                        if (!"sended".equals(subMissionList.getJSONObject(k).getString("status"))) {
+                            continue;
+                        }
+                        List<String> externalUserList = subMissionList.getJSONObject(k).getJSONArray("external_user_list").toJavaList(String.class);
+                        if (CollectionUtils.isEmpty(externalUserList)) {
+                            continue;
+                        }
+                        allExternalUserList.addAll(externalUserList);
+                    }
+                    insertHistoryMessageList(allExternalUserList, miniprogramRecordList, createdAt);
+                    messageAttachmentService.addMiniprogram(messageAttachmentList);
+                }
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+
+    private void insertHistoryMessageList(List<String> allExternalUserList, List<MiniprogramRecord> miniprogramRecordList, Date sendTime) {
+        List<HistoryMessage> historyMessageList = new ArrayList<>();
+        for (String externalUserId3rdParty : allExternalUserList) {
+            Long userId = userMapper.selectIdByExternalUserId3rdParty(externalUserId3rdParty);
+            if (userId == null) {
+                continue;
+            }
+            for (MiniprogramRecord miniprogramRecord : miniprogramRecordList) {
+                HistoryMessage historyMessage = new HistoryMessage();
+                historyMessage.setSendTime(sendTime);
+                historyMessage.setAttachmentIdx(miniprogramRecord.getAttachmentIdx());
+                historyMessage.setVideoId(miniprogramRecord.getVideoId());
+                historyMessage.setUserId(userId);
+                historyMessageList.add(historyMessage);
+            }
+        }
+        historyMessageService.batchInsertHistoryMessage(historyMessageList);
+    }
+
+    public Integer getHistoryDataTotal(Long startTime, Long endTime) throws IOException {
+        String res = getHistoryData(1, 0, startTime, endTime);
+        JSONObject jsonObject = JSONObject.parseObject(res);
+        return jsonObject.getInteger("total_count");
+    }
+
+    public String getHistoryData(Integer limit, Integer offset, Long startTime, Long endTime) throws IOException {
+        String accessToken = accessTokenService.getAccessToken();
+        String url = GET_HISTORY_DATA_URL
+                + "?access_token=" + accessToken
+                + "&limit=" + limit + "&offset=" + offset + "&start_time=" + startTime + "&end_time=" + endTime;
+        return httpPoolClientDefault.get(url);
+    }
+}
+
+
+
+
+
+

+ 204 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComMessageDataJob.java

@@ -0,0 +1,204 @@
+package com.tzld.piaoquan.wecom.job;
+
+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.dao.mapper.MessageAttachmentMapper;
+import com.tzld.piaoquan.wecom.dao.mapper.UserMapper;
+import com.tzld.piaoquan.wecom.model.bo.PushMessage;
+import com.tzld.piaoquan.wecom.model.po.MessageAttachment;
+import com.tzld.piaoquan.wecom.model.po.MessageAttachmentExample;
+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;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Component;
+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 {
+
+    @Autowired
+    private UserMapper userMapper;
+
+    @Autowired
+    private MessageAttachmentMapper messageAttachmentMapper;
+
+    @Autowired
+    private RedisTemplate<String, Object> redisTemplate;
+
+    @Autowired
+    private MessageService messageService;
+
+    private static final int MAX_VIDEO_NUM = 3;
+
+    //历史优质视频可推送用户列表
+    List<PushMessage> goodHistoryPushList = new ArrayList<>();
+
+    //保底视频列表
+    List<Long> guaranteedVideoIdList = new ArrayList<>();
+
+    //初始化操作
+    void init() {
+        String sql = String.format("SELECT * FROM loghubods.history_good_video_can_push_user_list where dt = %s;", DateUtil.getBeforeDayDateString());
+        List<Record> recordList = OdpsUtil.getOdpsData(sql);
+        if (CollectionUtils.isEmpty(recordList)) {
+            return;
+        }
+        List<PushMessage> list = new ArrayList<>();
+        for (Record record : recordList) {
+            PushMessage pushMessage = new PushMessage();
+            Long videoId = Long.parseLong((String) record.get(0));
+            Set<Long> userIds = new HashSet<>(JSONObject.parseArray((String) record.get(1), Long.class));
+            pushMessage.setVideoId(videoId);
+            pushMessage.setUserIds(userIds);
+            list.add(pushMessage);
+        }
+        goodHistoryPushList = list;
+        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("保底数据为空");
+        }
+        MessageAttachmentExample example = new MessageAttachmentExample();
+        example.createCriteria().andMiniprogramVideoIdIn(saveVideoIds);
+        List<MessageAttachment> messageAttachmentList = messageAttachmentMapper.selectByExample(example);
+        if (CollectionUtils.isEmpty(messageAttachmentList) || messageAttachmentList.size() < saveVideoIds.size()) {
+            throw new RuntimeException("保底数据获取失败");
+        }
+        for (MessageAttachment messageAttachment : messageAttachmentList) {
+            if (messageAttachment.getUpdateTime().compareTo(DateUtil.getThatDayDate()) < 0) {
+                throw new RuntimeException("保底数据不是最新的");
+            }
+        }
+        guaranteedVideoIdList = saveVideoIds;
+    }
+
+    public void assemble() {
+        init();
+        Map<String, List<String>> res = new HashMap<>();
+        UserExample example = new UserExample();
+        long count = userMapper.countByExample(example);
+        int page = 1;
+        int pageSize = 1000;
+        long totalPageSize = count / pageSize + 1;
+        for (; page <= totalPageSize; page++) {
+            example.setPage(new Page<>(page, pageSize));
+            List<User> userList = userMapper.selectByExample(example);
+            if (CollectionUtils.isEmpty(userList)) {
+                continue;
+            }
+            for (User user : userList) {
+                String pushKey = getPushKey(user);
+                if (res.containsKey(pushKey)) {
+                    res.get(pushKey).add(user.getExternalUserId3rdParty());
+                } else {
+                    res.put(pushKey, Lists.newArrayList(user.getExternalUserId3rdParty()));
+                }
+            }
+        }
+        pushMessage(res);
+    }
+
+
+    public String getPushKey(User user) {
+        int n = 0;
+        StringBuilder key = new StringBuilder();
+        for (PushMessage pushMessage : goodHistoryPushList) {
+            if (pushMessage.getUserIds().contains(user.getId())) {
+                if (key.length() == 0) {
+                    key.append(pushMessage.getVideoId());
+                    n++;
+                } else {
+                    key.append("_");
+                    key.append(pushMessage.getVideoId());
+                }
+                n++;
+                if (n > MAX_VIDEO_NUM) {
+                    return key.toString();
+                }
+            }
+        }
+        for (Long videoId : guaranteedVideoIdList) {
+            if (key.length() == 0) {
+                key.append(videoId);
+                n++;
+            } else {
+                key.append("_");
+                key.append(videoId);
+            }
+            n++;
+            if (n > MAX_VIDEO_NUM) {
+                return key.toString();
+            }
+        }
+        return key.toString();
+    }
+
+    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", 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) {
+                JSONObject attachment = new JSONObject();
+                attachment.put("msgtype", "miniprogram");
+                MessageAttachmentExample example = new MessageAttachmentExample();
+                example.createCriteria().andMiniprogramVideoIdEqualTo(videoId);
+                List<MessageAttachment> messageAttachmentList = messageAttachmentMapper.selectByExample(example);
+                if (CollectionUtils.isEmpty(messageAttachmentList)) {
+                    throw new RuntimeException("附件信息查询异常");
+                }
+                MessageAttachment messageAttachment = messageAttachmentList.get(0);
+                JSONObject miniprogram = new JSONObject();
+                miniprogram.put("appid", messageAttachment.getAppid());
+                miniprogram.put("title", messageAttachment.getTitle());
+                miniprogram.put("page", messageAttachment.getPage());
+                miniprogram.put("cover", messageAttachment.getCover());
+                attachment.put("miniprogram", miniprogram);
+                attachments.add(attachment);
+            }
+            jsonObject.put("attachments", attachments);
+            List<List<String>> lists = Lists.partition(entry.getValue(), 10000);
+            for (List<String> list : lists) {
+                List<JSONObject> staffEuList = new ArrayList<>();
+                JSONObject newJSONObject = new JSONObject();
+                newJSONObject.putAll(jsonObject);
+                for (String staffExtId : staffExtIdList) {
+                    JSONObject staff_eu = new JSONObject();
+                    staff_eu.put("staff_ext_id", staffExtId);
+                    staff_eu.put("eu_ext_ids", list);
+                    staffEuList.add(staff_eu);
+                }
+                newJSONObject.put("staff_eu_list", staffEuList);
+                pushList.add(newJSONObject);
+            }
+        }
+        if (CollectionUtils.isEmpty(pushList)) {
+            throw new RuntimeException("推送视频生成失败");
+        }
+        for (JSONObject jsonObject : pushList) {
+            messageService.pushMessage(jsonObject);
+        }
+    }
+}

+ 118 - 38
we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComUserDataJob.java

@@ -4,73 +4,83 @@ 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.User;
+import com.tzld.piaoquan.wecom.model.po.UserExample;
+import com.tzld.piaoquan.wecom.service.AccessTokenService;
 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.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
 
 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";
-
     private static final HttpPoolClient httpPoolClientDefault = HttpClientUtil.create(30000, 30000, 2000, 5000, 5, 30000);
 
-    final int size = 30;
+    final int size = 100;
 
     @Autowired
     private UserMapper userMapper;
 
+    @Autowired
+    private AccessTokenService accessTokenService;
+
+    //初始化用户使用此任务
     public void insertAllUser() {
-        Long endTime = System.currentTimeMillis() / 1000;
-        int sum = 0;
-        for (int i = 0; i < 5; i++) {
-            String res = null;
-            try {
-                //TODO accessToken 暂时写死 后续增加接口刷新和存储
-                res = getUser("12c11f5504cecdc89210070ccfd72461", size, i * size, 1720540800L, endTime);
-                //TODO 记录查询数据 info日志
-            } catch (IOException e) {
-                //TODO 记录异常日志 记录起止时间和页数 startTime endTime i
-                e.printStackTrace();
+        try {
+            Long endTime = System.currentTimeMillis() / 1000;
+            Long startTime = 1720540800L;
+            Integer total = getUserTotal(startTime, endTime);
+            if (total == null || total == 0) {
+                return;
             }
-            if (ObjectUtils.isEmpty(res)) {
-                continue;
-            }
-            JSONObject jsonObject = JSONObject.parseObject(res);
-            Integer total = (Integer) jsonObject.get("total");
-            JSONArray jsonArray = jsonObject.getJSONArray("external_user_list");
-            for (int j = 0; j < jsonArray.size(); j++) {
-                String id = (String) jsonArray.getJSONObject(j).get("id");
-                jsonArray.getJSONObject(j).put("id", null);
-                User user = jsonArray.getJSONObject(j).toJavaObject(User.class);
-                user.setExternalUserId3rdParty(id);
-                //TODO 记录对象数据  info日志
-                int insert = userMapper.insert(user);
-                if (insert <= 0) {
-                    //TODO  异常日志
+            int page = total / size + 1;
+            int sum = 0;
+            for (int i = 0; i < page; i++) {
+                String res = getUser(size, i * size, 1720540800L, endTime);
+                if (ObjectUtils.isEmpty(res)) {
                     continue;
                 }
-                sum++;
-            }
-            if (jsonArray.size() < size) {
-                if (total != null && total > sum) {
-                    //TODO 输出异常  插入数量不足
-                    System.out.println("插入数量不足");
+                JSONObject jsonObject = JSONObject.parseObject(res);
+                JSONArray jsonArray = jsonObject.getJSONArray("external_user_list");
+                List<User> userList = new ArrayList<>();
+                for (int j = 0; j < jsonArray.size(); j++) {
+                    String id = (String) jsonArray.getJSONObject(j).get("id");
+                    jsonArray.getJSONObject(j).put("id", null);
+                    User user = jsonArray.getJSONObject(j).toJavaObject(User.class);
+                    user.setExternalUserId3rdParty(id);
+                    userList.add(user);
+                    sum++;
+                }
+                userMapper.insertList(userList);
+                if (jsonArray.size() < size) {
+                    if (total > sum) {
+                        System.out.println("插入数量不足");
+                    }
+                    break;
                 }
-                break;
             }
+        } catch (Exception e) {
+            e.printStackTrace();
         }
+    }
 
-
+    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(String accessToken, 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
                 + "&limit=" + limit + "&offset=" + offset + "&start_time=" + startTime + "&end_time=" + endTime;
@@ -78,4 +88,74 @@ public class WeComUserDataJob {
     }
 
 
+    public void updateUser() {
+        try {
+            UserExample userExample = new UserExample();
+            userExample.setOrderByClause("create_time desc");
+            userExample.setPage(new Page<>(1, 1));
+            List<User> userList = userMapper.selectByExample(userExample);
+            long startTime = userList.get(0).getCreateTime().getTime() / 1000;
+            Long endTime = System.currentTimeMillis() / 1000;
+            Integer total = getUpdateUserTotal(startTime, endTime);
+            if (total == null || total == 0) {
+                return;
+            }
+            int page = total / size + 1;
+            int sum = 0;
+            for (int i = 0; i < page; i++) {
+                String res = getUpdateUser(size, i * size, startTime, endTime);
+                if (ObjectUtils.isEmpty(res)) {
+                    continue;
+                }
+                JSONObject jsonObject = JSONObject.parseObject(res);
+                JSONArray jsonArray = jsonObject.getJSONArray("external_user_list");
+                for (int j = 0; j < jsonArray.size(); j++) {
+                    String id = (String) jsonArray.getJSONObject(j).get("id");
+                    jsonArray.getJSONObject(j).put("id", null);
+                    User user = jsonArray.getJSONObject(j).toJavaObject(User.class);
+                    user.setExternalUserId3rdParty(id);
+                    UserExample example = new UserExample();
+                    example.createCriteria().andExternalUserId3rdPartyEqualTo(user.getExternalUserId3rdParty());
+                    List<User> list = userMapper.selectByExample(example);
+                    if (CollectionUtils.isEmpty(list)) {
+                        //没有用户,走插入逻辑
+                        userMapper.insert(user);
+                    } else {
+                        User oldUser = list.get(0);
+                        user.setId(oldUser.getId());
+                        userMapper.updateByPrimaryKeySelective(user);
+                    }
+                    sum++;
+                }
+                if (jsonArray.size() < size) {
+                    if (total > sum) {
+                        //TODO 输出异常  插入数量不足
+                        System.out.println(total);
+                        System.out.println(sum);
+                        System.out.println("插入数量不足");
+                    }
+                    break;
+                }
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    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");
+    }
+
+    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
+                + "&limit=" + limit + "&offset=" + offset + "&start_update_time=" + startTime + "&end_update_time=" + endTime
+                + "&source=external_user";
+        return httpPoolClientDefault.get(url);
+    }
+
+
 }

+ 12 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/bo/MiniprogramRecord.java

@@ -0,0 +1,12 @@
+package com.tzld.piaoquan.wecom.model.bo;
+
+import lombok.Data;
+
+@Data
+public class MiniprogramRecord {
+
+    private Long videoId;
+
+    private Integer attachmentIdx;
+
+}

+ 13 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/bo/PushMessage.java

@@ -0,0 +1,13 @@
+package com.tzld.piaoquan.wecom.model.bo;
+
+import lombok.Data;
+
+import java.util.Set;
+
+@Data
+public class PushMessage {
+
+    private Long videoId;
+
+    private Set<Long> userIds;
+}

+ 92 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/HistoryMessage.java

@@ -0,0 +1,92 @@
+package com.tzld.piaoquan.wecom.model.po;
+
+import java.util.Date;
+
+public class HistoryMessage {
+    private Long id;
+
+    private Long userId;
+
+    private Long videoId;
+
+    private Integer attachmentIdx;
+
+    private Long messageId;
+
+    private Date sendTime;
+
+    private Date createTime;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    public Long getVideoId() {
+        return videoId;
+    }
+
+    public void setVideoId(Long videoId) {
+        this.videoId = videoId;
+    }
+
+    public Integer getAttachmentIdx() {
+        return attachmentIdx;
+    }
+
+    public void setAttachmentIdx(Integer attachmentIdx) {
+        this.attachmentIdx = attachmentIdx;
+    }
+
+    public Long getMessageId() {
+        return messageId;
+    }
+
+    public void setMessageId(Long messageId) {
+        this.messageId = messageId;
+    }
+
+    public Date getSendTime() {
+        return sendTime;
+    }
+
+    public void setSendTime(Date sendTime) {
+        this.sendTime = sendTime;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", id=").append(id);
+        sb.append(", userId=").append(userId);
+        sb.append(", videoId=").append(videoId);
+        sb.append(", attachmentIdx=").append(attachmentIdx);
+        sb.append(", messageId=").append(messageId);
+        sb.append(", sendTime=").append(sendTime);
+        sb.append(", createTime=").append(createTime);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 632 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/HistoryMessageExample.java

@@ -0,0 +1,632 @@
+package com.tzld.piaoquan.wecom.model.po;
+
+import com.tzld.piaoquan.wecom.utils.page.Page;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class HistoryMessageExample {
+    protected String orderByClause;
+
+    protected boolean distinct;
+
+    protected List<Criteria> oredCriteria;
+
+    protected Page page;
+
+    public HistoryMessageExample() {
+        oredCriteria = new ArrayList<Criteria>();
+    }
+
+    public void setOrderByClause(String orderByClause) {
+        this.orderByClause = orderByClause;
+    }
+
+    public String getOrderByClause() {
+        return orderByClause;
+    }
+
+    public void setDistinct(boolean distinct) {
+        this.distinct = distinct;
+    }
+
+    public boolean isDistinct() {
+        return distinct;
+    }
+
+    public List<Criteria> getOredCriteria() {
+        return oredCriteria;
+    }
+
+    public void or(Criteria criteria) {
+        oredCriteria.add(criteria);
+    }
+
+    public Criteria or() {
+        Criteria criteria = createCriteriaInternal();
+        oredCriteria.add(criteria);
+        return criteria;
+    }
+
+    public Criteria createCriteria() {
+        Criteria criteria = createCriteriaInternal();
+        if (oredCriteria.size() == 0) {
+            oredCriteria.add(criteria);
+        }
+        return criteria;
+    }
+
+    protected Criteria createCriteriaInternal() {
+        Criteria criteria = new Criteria();
+        return criteria;
+    }
+
+    public void clear() {
+        oredCriteria.clear();
+        orderByClause = null;
+        distinct = false;
+    }
+
+    public void setPage(Page page) {
+        this.page=page;
+    }
+
+    public Page getPage() {
+        return page;
+    }
+
+    protected abstract static class GeneratedCriteria {
+        protected List<Criterion> criteria;
+
+        protected GeneratedCriteria() {
+            super();
+            criteria = new ArrayList<Criterion>();
+        }
+
+        public boolean isValid() {
+            return criteria.size() > 0;
+        }
+
+        public List<Criterion> getAllCriteria() {
+            return criteria;
+        }
+
+        public List<Criterion> getCriteria() {
+            return criteria;
+        }
+
+        protected void addCriterion(String condition) {
+            if (condition == null) {
+                throw new RuntimeException("Value for condition cannot be null");
+            }
+            criteria.add(new Criterion(condition));
+        }
+
+        protected void addCriterion(String condition, Object value, String property) {
+            if (value == null) {
+                throw new RuntimeException("Value for " + property + " cannot be null");
+            }
+            criteria.add(new Criterion(condition, value));
+        }
+
+        protected void addCriterion(String condition, Object value1, Object value2, String property) {
+            if (value1 == null || value2 == null) {
+                throw new RuntimeException("Between values for " + property + " cannot be null");
+            }
+            criteria.add(new Criterion(condition, value1, value2));
+        }
+
+        public Criteria andIdIsNull() {
+            addCriterion("id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdIsNotNull() {
+            addCriterion("id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdEqualTo(Long value) {
+            addCriterion("id =", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotEqualTo(Long value) {
+            addCriterion("id <>", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdGreaterThan(Long value) {
+            addCriterion("id >", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("id >=", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdLessThan(Long value) {
+            addCriterion("id <", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdLessThanOrEqualTo(Long value) {
+            addCriterion("id <=", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdIn(List<Long> values) {
+            addCriterion("id in", values, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotIn(List<Long> values) {
+            addCriterion("id not in", values, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdBetween(Long value1, Long value2) {
+            addCriterion("id between", value1, value2, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotBetween(Long value1, Long value2) {
+            addCriterion("id not between", value1, value2, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdIsNull() {
+            addCriterion("user_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdIsNotNull() {
+            addCriterion("user_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdEqualTo(Long value) {
+            addCriterion("user_id =", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdNotEqualTo(Long value) {
+            addCriterion("user_id <>", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdGreaterThan(Long value) {
+            addCriterion("user_id >", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("user_id >=", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdLessThan(Long value) {
+            addCriterion("user_id <", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdLessThanOrEqualTo(Long value) {
+            addCriterion("user_id <=", value, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdIn(List<Long> values) {
+            addCriterion("user_id in", values, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdNotIn(List<Long> values) {
+            addCriterion("user_id not in", values, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdBetween(Long value1, Long value2) {
+            addCriterion("user_id between", value1, value2, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andUserIdNotBetween(Long value1, Long value2) {
+            addCriterion("user_id not between", value1, value2, "userId");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoIdIsNull() {
+            addCriterion("video_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoIdIsNotNull() {
+            addCriterion("video_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoIdEqualTo(Long value) {
+            addCriterion("video_id =", value, "videoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoIdNotEqualTo(Long value) {
+            addCriterion("video_id <>", value, "videoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoIdGreaterThan(Long value) {
+            addCriterion("video_id >", value, "videoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("video_id >=", value, "videoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoIdLessThan(Long value) {
+            addCriterion("video_id <", value, "videoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoIdLessThanOrEqualTo(Long value) {
+            addCriterion("video_id <=", value, "videoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoIdIn(List<Long> values) {
+            addCriterion("video_id in", values, "videoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoIdNotIn(List<Long> values) {
+            addCriterion("video_id not in", values, "videoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoIdBetween(Long value1, Long value2) {
+            addCriterion("video_id between", value1, value2, "videoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andVideoIdNotBetween(Long value1, Long value2) {
+            addCriterion("video_id not between", value1, value2, "videoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andAttachmentIdxIsNull() {
+            addCriterion("attachment_idx is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andAttachmentIdxIsNotNull() {
+            addCriterion("attachment_idx is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andAttachmentIdxEqualTo(Integer value) {
+            addCriterion("attachment_idx =", value, "attachmentIdx");
+            return (Criteria) this;
+        }
+
+        public Criteria andAttachmentIdxNotEqualTo(Integer value) {
+            addCriterion("attachment_idx <>", value, "attachmentIdx");
+            return (Criteria) this;
+        }
+
+        public Criteria andAttachmentIdxGreaterThan(Integer value) {
+            addCriterion("attachment_idx >", value, "attachmentIdx");
+            return (Criteria) this;
+        }
+
+        public Criteria andAttachmentIdxGreaterThanOrEqualTo(Integer value) {
+            addCriterion("attachment_idx >=", value, "attachmentIdx");
+            return (Criteria) this;
+        }
+
+        public Criteria andAttachmentIdxLessThan(Integer value) {
+            addCriterion("attachment_idx <", value, "attachmentIdx");
+            return (Criteria) this;
+        }
+
+        public Criteria andAttachmentIdxLessThanOrEqualTo(Integer value) {
+            addCriterion("attachment_idx <=", value, "attachmentIdx");
+            return (Criteria) this;
+        }
+
+        public Criteria andAttachmentIdxIn(List<Integer> values) {
+            addCriterion("attachment_idx in", values, "attachmentIdx");
+            return (Criteria) this;
+        }
+
+        public Criteria andAttachmentIdxNotIn(List<Integer> values) {
+            addCriterion("attachment_idx not in", values, "attachmentIdx");
+            return (Criteria) this;
+        }
+
+        public Criteria andAttachmentIdxBetween(Integer value1, Integer value2) {
+            addCriterion("attachment_idx between", value1, value2, "attachmentIdx");
+            return (Criteria) this;
+        }
+
+        public Criteria andAttachmentIdxNotBetween(Integer value1, Integer value2) {
+            addCriterion("attachment_idx not between", value1, value2, "attachmentIdx");
+            return (Criteria) this;
+        }
+
+        public Criteria andMessageIdIsNull() {
+            addCriterion("message_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andMessageIdIsNotNull() {
+            addCriterion("message_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andMessageIdEqualTo(Long value) {
+            addCriterion("message_id =", value, "messageId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMessageIdNotEqualTo(Long value) {
+            addCriterion("message_id <>", value, "messageId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMessageIdGreaterThan(Long value) {
+            addCriterion("message_id >", value, "messageId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMessageIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("message_id >=", value, "messageId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMessageIdLessThan(Long value) {
+            addCriterion("message_id <", value, "messageId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMessageIdLessThanOrEqualTo(Long value) {
+            addCriterion("message_id <=", value, "messageId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMessageIdIn(List<Long> values) {
+            addCriterion("message_id in", values, "messageId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMessageIdNotIn(List<Long> values) {
+            addCriterion("message_id not in", values, "messageId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMessageIdBetween(Long value1, Long value2) {
+            addCriterion("message_id between", value1, value2, "messageId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMessageIdNotBetween(Long value1, Long value2) {
+            addCriterion("message_id not between", value1, value2, "messageId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimeIsNull() {
+            addCriterion("send_time is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimeIsNotNull() {
+            addCriterion("send_time is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimeEqualTo(Date value) {
+            addCriterion("send_time =", value, "sendTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimeNotEqualTo(Date value) {
+            addCriterion("send_time <>", value, "sendTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimeGreaterThan(Date value) {
+            addCriterion("send_time >", value, "sendTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimeGreaterThanOrEqualTo(Date value) {
+            addCriterion("send_time >=", value, "sendTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimeLessThan(Date value) {
+            addCriterion("send_time <", value, "sendTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimeLessThanOrEqualTo(Date value) {
+            addCriterion("send_time <=", value, "sendTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimeIn(List<Date> values) {
+            addCriterion("send_time in", values, "sendTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimeNotIn(List<Date> values) {
+            addCriterion("send_time not in", values, "sendTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimeBetween(Date value1, Date value2) {
+            addCriterion("send_time between", value1, value2, "sendTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andSendTimeNotBetween(Date value1, Date value2) {
+            addCriterion("send_time not between", value1, value2, "sendTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIsNull() {
+            addCriterion("create_time is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIsNotNull() {
+            addCriterion("create_time is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeEqualTo(Date value) {
+            addCriterion("create_time =", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotEqualTo(Date value) {
+            addCriterion("create_time <>", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeGreaterThan(Date value) {
+            addCriterion("create_time >", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
+            addCriterion("create_time >=", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeLessThan(Date value) {
+            addCriterion("create_time <", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
+            addCriterion("create_time <=", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIn(List<Date> values) {
+            addCriterion("create_time in", values, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotIn(List<Date> values) {
+            addCriterion("create_time not in", values, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeBetween(Date value1, Date value2) {
+            addCriterion("create_time between", value1, value2, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
+            addCriterion("create_time not between", value1, value2, "createTime");
+            return (Criteria) this;
+        }
+    }
+
+    public static class Criteria extends GeneratedCriteria {
+
+        protected Criteria() {
+            super();
+        }
+    }
+
+    public static class Criterion {
+        private String condition;
+
+        private Object value;
+
+        private Object secondValue;
+
+        private boolean noValue;
+
+        private boolean singleValue;
+
+        private boolean betweenValue;
+
+        private boolean listValue;
+
+        private String typeHandler;
+
+        public String getCondition() {
+            return condition;
+        }
+
+        public Object getValue() {
+            return value;
+        }
+
+        public Object getSecondValue() {
+            return secondValue;
+        }
+
+        public boolean isNoValue() {
+            return noValue;
+        }
+
+        public boolean isSingleValue() {
+            return singleValue;
+        }
+
+        public boolean isBetweenValue() {
+            return betweenValue;
+        }
+
+        public boolean isListValue() {
+            return listValue;
+        }
+
+        public String getTypeHandler() {
+            return typeHandler;
+        }
+
+        protected Criterion(String condition) {
+            super();
+            this.condition = condition;
+            this.typeHandler = null;
+            this.noValue = true;
+        }
+
+        protected Criterion(String condition, Object value, String typeHandler) {
+            super();
+            this.condition = condition;
+            this.value = value;
+            this.typeHandler = typeHandler;
+            if (value instanceof List<?>) {
+                this.listValue = true;
+            } else {
+                this.singleValue = true;
+            }
+        }
+
+        protected Criterion(String condition, Object value) {
+            this(condition, value, null);
+        }
+
+        protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
+            super();
+            this.condition = condition;
+            this.value = value;
+            this.secondValue = secondValue;
+            this.typeHandler = typeHandler;
+            this.betweenValue = true;
+        }
+
+        protected Criterion(String condition, Object value, Object secondValue) {
+            this(condition, value, secondValue, null);
+        }
+    }
+}

+ 147 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/MessageAttachment.java

@@ -0,0 +1,147 @@
+package com.tzld.piaoquan.wecom.model.po;
+
+import java.util.Date;
+
+public class MessageAttachment {
+    private Long id;
+
+    private Integer type;
+
+    private String url;
+
+    private String title;
+
+    private String desc;
+
+    private String appid;
+
+    private String page;
+
+    private String cover;
+
+    private Long miniprogramVideoId;
+
+    private Integer isDelete;
+
+    private Date createTime;
+
+    private Date updateTime;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Integer getType() {
+        return type;
+    }
+
+    public void setType(Integer type) {
+        this.type = type;
+    }
+
+    public String getUrl() {
+        return url;
+    }
+
+    public void setUrl(String url) {
+        this.url = url;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getDesc() {
+        return desc;
+    }
+
+    public void setDesc(String desc) {
+        this.desc = desc;
+    }
+
+    public String getAppid() {
+        return appid;
+    }
+
+    public void setAppid(String appid) {
+        this.appid = appid;
+    }
+
+    public String getPage() {
+        return page;
+    }
+
+    public void setPage(String page) {
+        this.page = page;
+    }
+
+    public String getCover() {
+        return cover;
+    }
+
+    public void setCover(String cover) {
+        this.cover = cover;
+    }
+
+    public Long getMiniprogramVideoId() {
+        return miniprogramVideoId;
+    }
+
+    public void setMiniprogramVideoId(Long miniprogramVideoId) {
+        this.miniprogramVideoId = miniprogramVideoId;
+    }
+
+    public Integer getIsDelete() {
+        return isDelete;
+    }
+
+    public void setIsDelete(Integer isDelete) {
+        this.isDelete = isDelete;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", id=").append(id);
+        sb.append(", type=").append(type);
+        sb.append(", url=").append(url);
+        sb.append(", title=").append(title);
+        sb.append(", desc=").append(desc);
+        sb.append(", appid=").append(appid);
+        sb.append(", page=").append(page);
+        sb.append(", cover=").append(cover);
+        sb.append(", miniprogramVideoId=").append(miniprogramVideoId);
+        sb.append(", isDelete=").append(isDelete);
+        sb.append(", createTime=").append(createTime);
+        sb.append(", updateTime=").append(updateTime);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 992 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/MessageAttachmentExample.java

@@ -0,0 +1,992 @@
+package com.tzld.piaoquan.wecom.model.po;
+
+import com.tzld.piaoquan.wecom.utils.page.Page;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class MessageAttachmentExample {
+    protected String orderByClause;
+
+    protected boolean distinct;
+
+    protected List<Criteria> oredCriteria;
+
+    protected Page page;
+
+    public MessageAttachmentExample() {
+        oredCriteria = new ArrayList<Criteria>();
+    }
+
+    public void setOrderByClause(String orderByClause) {
+        this.orderByClause = orderByClause;
+    }
+
+    public String getOrderByClause() {
+        return orderByClause;
+    }
+
+    public void setDistinct(boolean distinct) {
+        this.distinct = distinct;
+    }
+
+    public boolean isDistinct() {
+        return distinct;
+    }
+
+    public List<Criteria> getOredCriteria() {
+        return oredCriteria;
+    }
+
+    public void or(Criteria criteria) {
+        oredCriteria.add(criteria);
+    }
+
+    public Criteria or() {
+        Criteria criteria = createCriteriaInternal();
+        oredCriteria.add(criteria);
+        return criteria;
+    }
+
+    public Criteria createCriteria() {
+        Criteria criteria = createCriteriaInternal();
+        if (oredCriteria.size() == 0) {
+            oredCriteria.add(criteria);
+        }
+        return criteria;
+    }
+
+    protected Criteria createCriteriaInternal() {
+        Criteria criteria = new Criteria();
+        return criteria;
+    }
+
+    public void clear() {
+        oredCriteria.clear();
+        orderByClause = null;
+        distinct = false;
+    }
+
+    public void setPage(Page page) {
+        this.page=page;
+    }
+
+    public Page getPage() {
+        return page;
+    }
+
+    protected abstract static class GeneratedCriteria {
+        protected List<Criterion> criteria;
+
+        protected GeneratedCriteria() {
+            super();
+            criteria = new ArrayList<Criterion>();
+        }
+
+        public boolean isValid() {
+            return criteria.size() > 0;
+        }
+
+        public List<Criterion> getAllCriteria() {
+            return criteria;
+        }
+
+        public List<Criterion> getCriteria() {
+            return criteria;
+        }
+
+        protected void addCriterion(String condition) {
+            if (condition == null) {
+                throw new RuntimeException("Value for condition cannot be null");
+            }
+            criteria.add(new Criterion(condition));
+        }
+
+        protected void addCriterion(String condition, Object value, String property) {
+            if (value == null) {
+                throw new RuntimeException("Value for " + property + " cannot be null");
+            }
+            criteria.add(new Criterion(condition, value));
+        }
+
+        protected void addCriterion(String condition, Object value1, Object value2, String property) {
+            if (value1 == null || value2 == null) {
+                throw new RuntimeException("Between values for " + property + " cannot be null");
+            }
+            criteria.add(new Criterion(condition, value1, value2));
+        }
+
+        public Criteria andIdIsNull() {
+            addCriterion("id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdIsNotNull() {
+            addCriterion("id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdEqualTo(Long value) {
+            addCriterion("id =", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotEqualTo(Long value) {
+            addCriterion("id <>", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdGreaterThan(Long value) {
+            addCriterion("id >", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("id >=", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdLessThan(Long value) {
+            addCriterion("id <", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdLessThanOrEqualTo(Long value) {
+            addCriterion("id <=", value, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdIn(List<Long> values) {
+            addCriterion("id in", values, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotIn(List<Long> values) {
+            addCriterion("id not in", values, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdBetween(Long value1, Long value2) {
+            addCriterion("id between", value1, value2, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andIdNotBetween(Long value1, Long value2) {
+            addCriterion("id not between", value1, value2, "id");
+            return (Criteria) this;
+        }
+
+        public Criteria andTypeIsNull() {
+            addCriterion("`type` is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andTypeIsNotNull() {
+            addCriterion("`type` is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andTypeEqualTo(Integer value) {
+            addCriterion("`type` =", value, "type");
+            return (Criteria) this;
+        }
+
+        public Criteria andTypeNotEqualTo(Integer value) {
+            addCriterion("`type` <>", value, "type");
+            return (Criteria) this;
+        }
+
+        public Criteria andTypeGreaterThan(Integer value) {
+            addCriterion("`type` >", value, "type");
+            return (Criteria) this;
+        }
+
+        public Criteria andTypeGreaterThanOrEqualTo(Integer value) {
+            addCriterion("`type` >=", value, "type");
+            return (Criteria) this;
+        }
+
+        public Criteria andTypeLessThan(Integer value) {
+            addCriterion("`type` <", value, "type");
+            return (Criteria) this;
+        }
+
+        public Criteria andTypeLessThanOrEqualTo(Integer value) {
+            addCriterion("`type` <=", value, "type");
+            return (Criteria) this;
+        }
+
+        public Criteria andTypeIn(List<Integer> values) {
+            addCriterion("`type` in", values, "type");
+            return (Criteria) this;
+        }
+
+        public Criteria andTypeNotIn(List<Integer> values) {
+            addCriterion("`type` not in", values, "type");
+            return (Criteria) this;
+        }
+
+        public Criteria andTypeBetween(Integer value1, Integer value2) {
+            addCriterion("`type` between", value1, value2, "type");
+            return (Criteria) this;
+        }
+
+        public Criteria andTypeNotBetween(Integer value1, Integer value2) {
+            addCriterion("`type` not between", value1, value2, "type");
+            return (Criteria) this;
+        }
+
+        public Criteria andUrlIsNull() {
+            addCriterion("url is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUrlIsNotNull() {
+            addCriterion("url is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUrlEqualTo(String value) {
+            addCriterion("url =", value, "url");
+            return (Criteria) this;
+        }
+
+        public Criteria andUrlNotEqualTo(String value) {
+            addCriterion("url <>", value, "url");
+            return (Criteria) this;
+        }
+
+        public Criteria andUrlGreaterThan(String value) {
+            addCriterion("url >", value, "url");
+            return (Criteria) this;
+        }
+
+        public Criteria andUrlGreaterThanOrEqualTo(String value) {
+            addCriterion("url >=", value, "url");
+            return (Criteria) this;
+        }
+
+        public Criteria andUrlLessThan(String value) {
+            addCriterion("url <", value, "url");
+            return (Criteria) this;
+        }
+
+        public Criteria andUrlLessThanOrEqualTo(String value) {
+            addCriterion("url <=", value, "url");
+            return (Criteria) this;
+        }
+
+        public Criteria andUrlLike(String value) {
+            addCriterion("url like", value, "url");
+            return (Criteria) this;
+        }
+
+        public Criteria andUrlNotLike(String value) {
+            addCriterion("url not like", value, "url");
+            return (Criteria) this;
+        }
+
+        public Criteria andUrlIn(List<String> values) {
+            addCriterion("url in", values, "url");
+            return (Criteria) this;
+        }
+
+        public Criteria andUrlNotIn(List<String> values) {
+            addCriterion("url not in", values, "url");
+            return (Criteria) this;
+        }
+
+        public Criteria andUrlBetween(String value1, String value2) {
+            addCriterion("url between", value1, value2, "url");
+            return (Criteria) this;
+        }
+
+        public Criteria andUrlNotBetween(String value1, String value2) {
+            addCriterion("url not between", value1, value2, "url");
+            return (Criteria) this;
+        }
+
+        public Criteria andTitleIsNull() {
+            addCriterion("title is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andTitleIsNotNull() {
+            addCriterion("title is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andTitleEqualTo(String value) {
+            addCriterion("title =", value, "title");
+            return (Criteria) this;
+        }
+
+        public Criteria andTitleNotEqualTo(String value) {
+            addCriterion("title <>", value, "title");
+            return (Criteria) this;
+        }
+
+        public Criteria andTitleGreaterThan(String value) {
+            addCriterion("title >", value, "title");
+            return (Criteria) this;
+        }
+
+        public Criteria andTitleGreaterThanOrEqualTo(String value) {
+            addCriterion("title >=", value, "title");
+            return (Criteria) this;
+        }
+
+        public Criteria andTitleLessThan(String value) {
+            addCriterion("title <", value, "title");
+            return (Criteria) this;
+        }
+
+        public Criteria andTitleLessThanOrEqualTo(String value) {
+            addCriterion("title <=", value, "title");
+            return (Criteria) this;
+        }
+
+        public Criteria andTitleLike(String value) {
+            addCriterion("title like", value, "title");
+            return (Criteria) this;
+        }
+
+        public Criteria andTitleNotLike(String value) {
+            addCriterion("title not like", value, "title");
+            return (Criteria) this;
+        }
+
+        public Criteria andTitleIn(List<String> values) {
+            addCriterion("title in", values, "title");
+            return (Criteria) this;
+        }
+
+        public Criteria andTitleNotIn(List<String> values) {
+            addCriterion("title not in", values, "title");
+            return (Criteria) this;
+        }
+
+        public Criteria andTitleBetween(String value1, String value2) {
+            addCriterion("title between", value1, value2, "title");
+            return (Criteria) this;
+        }
+
+        public Criteria andTitleNotBetween(String value1, String value2) {
+            addCriterion("title not between", value1, value2, "title");
+            return (Criteria) this;
+        }
+
+        public Criteria andDescIsNull() {
+            addCriterion("`desc` is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andDescIsNotNull() {
+            addCriterion("`desc` is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andDescEqualTo(String value) {
+            addCriterion("`desc` =", value, "desc");
+            return (Criteria) this;
+        }
+
+        public Criteria andDescNotEqualTo(String value) {
+            addCriterion("`desc` <>", value, "desc");
+            return (Criteria) this;
+        }
+
+        public Criteria andDescGreaterThan(String value) {
+            addCriterion("`desc` >", value, "desc");
+            return (Criteria) this;
+        }
+
+        public Criteria andDescGreaterThanOrEqualTo(String value) {
+            addCriterion("`desc` >=", value, "desc");
+            return (Criteria) this;
+        }
+
+        public Criteria andDescLessThan(String value) {
+            addCriterion("`desc` <", value, "desc");
+            return (Criteria) this;
+        }
+
+        public Criteria andDescLessThanOrEqualTo(String value) {
+            addCriterion("`desc` <=", value, "desc");
+            return (Criteria) this;
+        }
+
+        public Criteria andDescLike(String value) {
+            addCriterion("`desc` like", value, "desc");
+            return (Criteria) this;
+        }
+
+        public Criteria andDescNotLike(String value) {
+            addCriterion("`desc` not like", value, "desc");
+            return (Criteria) this;
+        }
+
+        public Criteria andDescIn(List<String> values) {
+            addCriterion("`desc` in", values, "desc");
+            return (Criteria) this;
+        }
+
+        public Criteria andDescNotIn(List<String> values) {
+            addCriterion("`desc` not in", values, "desc");
+            return (Criteria) this;
+        }
+
+        public Criteria andDescBetween(String value1, String value2) {
+            addCriterion("`desc` between", value1, value2, "desc");
+            return (Criteria) this;
+        }
+
+        public Criteria andDescNotBetween(String value1, String value2) {
+            addCriterion("`desc` not between", value1, value2, "desc");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppidIsNull() {
+            addCriterion("appid is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppidIsNotNull() {
+            addCriterion("appid is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppidEqualTo(String value) {
+            addCriterion("appid =", value, "appid");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppidNotEqualTo(String value) {
+            addCriterion("appid <>", value, "appid");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppidGreaterThan(String value) {
+            addCriterion("appid >", value, "appid");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppidGreaterThanOrEqualTo(String value) {
+            addCriterion("appid >=", value, "appid");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppidLessThan(String value) {
+            addCriterion("appid <", value, "appid");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppidLessThanOrEqualTo(String value) {
+            addCriterion("appid <=", value, "appid");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppidLike(String value) {
+            addCriterion("appid like", value, "appid");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppidNotLike(String value) {
+            addCriterion("appid not like", value, "appid");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppidIn(List<String> values) {
+            addCriterion("appid in", values, "appid");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppidNotIn(List<String> values) {
+            addCriterion("appid not in", values, "appid");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppidBetween(String value1, String value2) {
+            addCriterion("appid between", value1, value2, "appid");
+            return (Criteria) this;
+        }
+
+        public Criteria andAppidNotBetween(String value1, String value2) {
+            addCriterion("appid not between", value1, value2, "appid");
+            return (Criteria) this;
+        }
+
+        public Criteria andPageIsNull() {
+            addCriterion("page is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andPageIsNotNull() {
+            addCriterion("page is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andPageEqualTo(String value) {
+            addCriterion("page =", value, "page");
+            return (Criteria) this;
+        }
+
+        public Criteria andPageNotEqualTo(String value) {
+            addCriterion("page <>", value, "page");
+            return (Criteria) this;
+        }
+
+        public Criteria andPageGreaterThan(String value) {
+            addCriterion("page >", value, "page");
+            return (Criteria) this;
+        }
+
+        public Criteria andPageGreaterThanOrEqualTo(String value) {
+            addCriterion("page >=", value, "page");
+            return (Criteria) this;
+        }
+
+        public Criteria andPageLessThan(String value) {
+            addCriterion("page <", value, "page");
+            return (Criteria) this;
+        }
+
+        public Criteria andPageLessThanOrEqualTo(String value) {
+            addCriterion("page <=", value, "page");
+            return (Criteria) this;
+        }
+
+        public Criteria andPageLike(String value) {
+            addCriterion("page like", value, "page");
+            return (Criteria) this;
+        }
+
+        public Criteria andPageNotLike(String value) {
+            addCriterion("page not like", value, "page");
+            return (Criteria) this;
+        }
+
+        public Criteria andPageIn(List<String> values) {
+            addCriterion("page in", values, "page");
+            return (Criteria) this;
+        }
+
+        public Criteria andPageNotIn(List<String> values) {
+            addCriterion("page not in", values, "page");
+            return (Criteria) this;
+        }
+
+        public Criteria andPageBetween(String value1, String value2) {
+            addCriterion("page between", value1, value2, "page");
+            return (Criteria) this;
+        }
+
+        public Criteria andPageNotBetween(String value1, String value2) {
+            addCriterion("page not between", value1, value2, "page");
+            return (Criteria) this;
+        }
+
+        public Criteria andCoverIsNull() {
+            addCriterion("cover is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCoverIsNotNull() {
+            addCriterion("cover is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCoverEqualTo(String value) {
+            addCriterion("cover =", value, "cover");
+            return (Criteria) this;
+        }
+
+        public Criteria andCoverNotEqualTo(String value) {
+            addCriterion("cover <>", value, "cover");
+            return (Criteria) this;
+        }
+
+        public Criteria andCoverGreaterThan(String value) {
+            addCriterion("cover >", value, "cover");
+            return (Criteria) this;
+        }
+
+        public Criteria andCoverGreaterThanOrEqualTo(String value) {
+            addCriterion("cover >=", value, "cover");
+            return (Criteria) this;
+        }
+
+        public Criteria andCoverLessThan(String value) {
+            addCriterion("cover <", value, "cover");
+            return (Criteria) this;
+        }
+
+        public Criteria andCoverLessThanOrEqualTo(String value) {
+            addCriterion("cover <=", value, "cover");
+            return (Criteria) this;
+        }
+
+        public Criteria andCoverLike(String value) {
+            addCriterion("cover like", value, "cover");
+            return (Criteria) this;
+        }
+
+        public Criteria andCoverNotLike(String value) {
+            addCriterion("cover not like", value, "cover");
+            return (Criteria) this;
+        }
+
+        public Criteria andCoverIn(List<String> values) {
+            addCriterion("cover in", values, "cover");
+            return (Criteria) this;
+        }
+
+        public Criteria andCoverNotIn(List<String> values) {
+            addCriterion("cover not in", values, "cover");
+            return (Criteria) this;
+        }
+
+        public Criteria andCoverBetween(String value1, String value2) {
+            addCriterion("cover between", value1, value2, "cover");
+            return (Criteria) this;
+        }
+
+        public Criteria andCoverNotBetween(String value1, String value2) {
+            addCriterion("cover not between", value1, value2, "cover");
+            return (Criteria) this;
+        }
+
+        public Criteria andMiniprogramVideoIdIsNull() {
+            addCriterion("miniprogram_video_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andMiniprogramVideoIdIsNotNull() {
+            addCriterion("miniprogram_video_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andMiniprogramVideoIdEqualTo(Long value) {
+            addCriterion("miniprogram_video_id =", value, "miniprogramVideoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMiniprogramVideoIdNotEqualTo(Long value) {
+            addCriterion("miniprogram_video_id <>", value, "miniprogramVideoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMiniprogramVideoIdGreaterThan(Long value) {
+            addCriterion("miniprogram_video_id >", value, "miniprogramVideoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMiniprogramVideoIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("miniprogram_video_id >=", value, "miniprogramVideoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMiniprogramVideoIdLessThan(Long value) {
+            addCriterion("miniprogram_video_id <", value, "miniprogramVideoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMiniprogramVideoIdLessThanOrEqualTo(Long value) {
+            addCriterion("miniprogram_video_id <=", value, "miniprogramVideoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMiniprogramVideoIdIn(List<Long> values) {
+            addCriterion("miniprogram_video_id in", values, "miniprogramVideoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMiniprogramVideoIdNotIn(List<Long> values) {
+            addCriterion("miniprogram_video_id not in", values, "miniprogramVideoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMiniprogramVideoIdBetween(Long value1, Long value2) {
+            addCriterion("miniprogram_video_id between", value1, value2, "miniprogramVideoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMiniprogramVideoIdNotBetween(Long value1, Long value2) {
+            addCriterion("miniprogram_video_id not between", value1, value2, "miniprogramVideoId");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteIsNull() {
+            addCriterion("is_delete is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteIsNotNull() {
+            addCriterion("is_delete is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteEqualTo(Integer value) {
+            addCriterion("is_delete =", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteNotEqualTo(Integer value) {
+            addCriterion("is_delete <>", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteGreaterThan(Integer value) {
+            addCriterion("is_delete >", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteGreaterThanOrEqualTo(Integer value) {
+            addCriterion("is_delete >=", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteLessThan(Integer value) {
+            addCriterion("is_delete <", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteLessThanOrEqualTo(Integer value) {
+            addCriterion("is_delete <=", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteIn(List<Integer> values) {
+            addCriterion("is_delete in", values, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteNotIn(List<Integer> values) {
+            addCriterion("is_delete not in", values, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteBetween(Integer value1, Integer value2) {
+            addCriterion("is_delete between", value1, value2, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteNotBetween(Integer value1, Integer value2) {
+            addCriterion("is_delete not between", value1, value2, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIsNull() {
+            addCriterion("create_time is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIsNotNull() {
+            addCriterion("create_time is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeEqualTo(Date value) {
+            addCriterion("create_time =", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotEqualTo(Date value) {
+            addCriterion("create_time <>", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeGreaterThan(Date value) {
+            addCriterion("create_time >", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
+            addCriterion("create_time >=", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeLessThan(Date value) {
+            addCriterion("create_time <", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
+            addCriterion("create_time <=", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIn(List<Date> values) {
+            addCriterion("create_time in", values, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotIn(List<Date> values) {
+            addCriterion("create_time not in", values, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeBetween(Date value1, Date value2) {
+            addCriterion("create_time between", value1, value2, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
+            addCriterion("create_time not between", value1, value2, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeIsNull() {
+            addCriterion("update_time is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeIsNotNull() {
+            addCriterion("update_time is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeEqualTo(Date value) {
+            addCriterion("update_time =", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeNotEqualTo(Date value) {
+            addCriterion("update_time <>", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeGreaterThan(Date value) {
+            addCriterion("update_time >", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) {
+            addCriterion("update_time >=", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeLessThan(Date value) {
+            addCriterion("update_time <", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeLessThanOrEqualTo(Date value) {
+            addCriterion("update_time <=", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeIn(List<Date> values) {
+            addCriterion("update_time in", values, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeNotIn(List<Date> values) {
+            addCriterion("update_time not in", values, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeBetween(Date value1, Date value2) {
+            addCriterion("update_time between", value1, value2, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeNotBetween(Date value1, Date value2) {
+            addCriterion("update_time not between", value1, value2, "updateTime");
+            return (Criteria) this;
+        }
+    }
+
+    public static class Criteria extends GeneratedCriteria {
+
+        protected Criteria() {
+            super();
+        }
+    }
+
+    public static class Criterion {
+        private String condition;
+
+        private Object value;
+
+        private Object secondValue;
+
+        private boolean noValue;
+
+        private boolean singleValue;
+
+        private boolean betweenValue;
+
+        private boolean listValue;
+
+        private String typeHandler;
+
+        public String getCondition() {
+            return condition;
+        }
+
+        public Object getValue() {
+            return value;
+        }
+
+        public Object getSecondValue() {
+            return secondValue;
+        }
+
+        public boolean isNoValue() {
+            return noValue;
+        }
+
+        public boolean isSingleValue() {
+            return singleValue;
+        }
+
+        public boolean isBetweenValue() {
+            return betweenValue;
+        }
+
+        public boolean isListValue() {
+            return listValue;
+        }
+
+        public String getTypeHandler() {
+            return typeHandler;
+        }
+
+        protected Criterion(String condition) {
+            super();
+            this.condition = condition;
+            this.typeHandler = null;
+            this.noValue = true;
+        }
+
+        protected Criterion(String condition, Object value, String typeHandler) {
+            super();
+            this.condition = condition;
+            this.value = value;
+            this.typeHandler = typeHandler;
+            if (value instanceof List<?>) {
+                this.listValue = true;
+            } else {
+                this.singleValue = true;
+            }
+        }
+
+        protected Criterion(String condition, Object value) {
+            this(condition, value, null);
+        }
+
+        protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
+            super();
+            this.condition = condition;
+            this.value = value;
+            this.secondValue = secondValue;
+            this.typeHandler = typeHandler;
+            this.betweenValue = true;
+        }
+
+        protected Criterion(String condition, Object value, Object secondValue) {
+            this(condition, value, secondValue, null);
+        }
+    }
+}

+ 0 - 336
we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/User.java

@@ -2,473 +2,137 @@ package com.tzld.piaoquan.wecom.model.po;
 
 import java.util.Date;
 
-/**
- *
- * This class was generated by MyBatis Generator.
- * This class corresponds to the database table we_com_user
- */
 public class User {
-    /**
-     * Database Column Remarks:
-     *   主键
-     *
-     * This field was generated by MyBatis Generator.
-     * This field corresponds to the database column we_com_user.id
-     *
-     * @mbg.generated
-     */
     private Long id;
 
-    /**
-     * Database Column Remarks:
-     *   外部客户id
-     *
-     * This field was generated by MyBatis Generator.
-     * This field corresponds to the database column we_com_user.external_user_id
-     *
-     * @mbg.generated
-     */
     private String externalUserId;
 
-    /**
-     * Database Column Remarks:
-     *   微信统一id
-     *
-     * This field was generated by MyBatis Generator.
-     * This field corresponds to the database column we_com_user.union_id
-     *
-     * @mbg.generated
-     */
     private String unionId;
 
-    /**
-     * Database Column Remarks:
-     *   第三方应用外部客户id(微伴助手)
-     *
-     * This field was generated by MyBatis Generator.
-     * This field corresponds to the database column we_com_user.external_user_id_3rd_party
-     *
-     * @mbg.generated
-     */
     private String externalUserId3rdParty;
 
-    /**
-     * Database Column Remarks:
-     *   1-微信用户 2-企业微信
-     *
-     * This field was generated by MyBatis Generator.
-     * This field corresponds to the database column we_com_user.type
-     *
-     * @mbg.generated
-     */
     private Integer type;
 
-    /**
-     * Database Column Remarks:
-     *   昵称
-     *
-     * This field was generated by MyBatis Generator.
-     * This field corresponds to the database column we_com_user.name
-     *
-     * @mbg.generated
-     */
     private String name;
 
-    /**
-     * Database Column Remarks:
-     *   头像url
-     *
-     * This field was generated by MyBatis Generator.
-     * This field corresponds to the database column we_com_user.avatar
-     *
-     * @mbg.generated
-     */
     private String avatar;
 
-    /**
-     * Database Column Remarks:
-     *   性别 0-未知 1-男性 2-女性
-     *
-     * This field was generated by MyBatis Generator.
-     * This field corresponds to the database column we_com_user.gender
-     *
-     * @mbg.generated
-     */
     private Integer gender;
 
-    /**
-     * Database Column Remarks:
-     *   是否删除(0正常 1删除)
-     *
-     * This field was generated by MyBatis Generator.
-     * This field corresponds to the database column we_com_user.is_delete
-     *
-     * @mbg.generated
-     */
     private Integer isDelete;
 
-    /**
-     * Database Column Remarks:
-     *   微伴助手创建时间
-     *
-     * This field was generated by MyBatis Generator.
-     * This field corresponds to the database column we_com_user.created_at
-     *
-     * @mbg.generated
-     */
     private Long createdAt;
 
-    /**
-     * Database Column Remarks:
-     *   微伴助手更新时间
-     *
-     * This field was generated by MyBatis Generator.
-     * This field corresponds to the database column we_com_user.updated_at
-     *
-     * @mbg.generated
-     */
     private Long updatedAt;
 
-    /**
-     * Database Column Remarks:
-     *   创建时间
-     *
-     * This field was generated by MyBatis Generator.
-     * This field corresponds to the database column we_com_user.create_time
-     *
-     * @mbg.generated
-     */
     private Date createTime;
 
-    /**
-     * Database Column Remarks:
-     *   更新时间
-     *
-     * This field was generated by MyBatis Generator.
-     * This field corresponds to the database column we_com_user.update_time
-     *
-     * @mbg.generated
-     */
     private Date updateTime;
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method returns the value of the database column we_com_user.id
-     *
-     * @return the value of we_com_user.id
-     *
-     * @mbg.generated
-     */
     public Long getId() {
         return id;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method sets the value of the database column we_com_user.id
-     *
-     * @param id the value for we_com_user.id
-     *
-     * @mbg.generated
-     */
     public void setId(Long id) {
         this.id = id;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method returns the value of the database column we_com_user.external_user_id
-     *
-     * @return the value of we_com_user.external_user_id
-     *
-     * @mbg.generated
-     */
     public String getExternalUserId() {
         return externalUserId;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method sets the value of the database column we_com_user.external_user_id
-     *
-     * @param externalUserId the value for we_com_user.external_user_id
-     *
-     * @mbg.generated
-     */
     public void setExternalUserId(String externalUserId) {
         this.externalUserId = externalUserId;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method returns the value of the database column we_com_user.union_id
-     *
-     * @return the value of we_com_user.union_id
-     *
-     * @mbg.generated
-     */
     public String getUnionId() {
         return unionId;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method sets the value of the database column we_com_user.union_id
-     *
-     * @param unionId the value for we_com_user.union_id
-     *
-     * @mbg.generated
-     */
     public void setUnionId(String unionId) {
         this.unionId = unionId;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method returns the value of the database column we_com_user.external_user_id_3rd_party
-     *
-     * @return the value of we_com_user.external_user_id_3rd_party
-     *
-     * @mbg.generated
-     */
     public String getExternalUserId3rdParty() {
         return externalUserId3rdParty;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method sets the value of the database column we_com_user.external_user_id_3rd_party
-     *
-     * @param externalUserId3rdParty the value for we_com_user.external_user_id_3rd_party
-     *
-     * @mbg.generated
-     */
     public void setExternalUserId3rdParty(String externalUserId3rdParty) {
         this.externalUserId3rdParty = externalUserId3rdParty;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method returns the value of the database column we_com_user.type
-     *
-     * @return the value of we_com_user.type
-     *
-     * @mbg.generated
-     */
     public Integer getType() {
         return type;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method sets the value of the database column we_com_user.type
-     *
-     * @param type the value for we_com_user.type
-     *
-     * @mbg.generated
-     */
     public void setType(Integer type) {
         this.type = type;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method returns the value of the database column we_com_user.name
-     *
-     * @return the value of we_com_user.name
-     *
-     * @mbg.generated
-     */
     public String getName() {
         return name;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method sets the value of the database column we_com_user.name
-     *
-     * @param name the value for we_com_user.name
-     *
-     * @mbg.generated
-     */
     public void setName(String name) {
         this.name = name;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method returns the value of the database column we_com_user.avatar
-     *
-     * @return the value of we_com_user.avatar
-     *
-     * @mbg.generated
-     */
     public String getAvatar() {
         return avatar;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method sets the value of the database column we_com_user.avatar
-     *
-     * @param avatar the value for we_com_user.avatar
-     *
-     * @mbg.generated
-     */
     public void setAvatar(String avatar) {
         this.avatar = avatar;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method returns the value of the database column we_com_user.gender
-     *
-     * @return the value of we_com_user.gender
-     *
-     * @mbg.generated
-     */
     public Integer getGender() {
         return gender;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method sets the value of the database column we_com_user.gender
-     *
-     * @param gender the value for we_com_user.gender
-     *
-     * @mbg.generated
-     */
     public void setGender(Integer gender) {
         this.gender = gender;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method returns the value of the database column we_com_user.is_delete
-     *
-     * @return the value of we_com_user.is_delete
-     *
-     * @mbg.generated
-     */
     public Integer getIsDelete() {
         return isDelete;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method sets the value of the database column we_com_user.is_delete
-     *
-     * @param isDelete the value for we_com_user.is_delete
-     *
-     * @mbg.generated
-     */
     public void setIsDelete(Integer isDelete) {
         this.isDelete = isDelete;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method returns the value of the database column we_com_user.created_at
-     *
-     * @return the value of we_com_user.created_at
-     *
-     * @mbg.generated
-     */
     public Long getCreatedAt() {
         return createdAt;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method sets the value of the database column we_com_user.created_at
-     *
-     * @param createdAt the value for we_com_user.created_at
-     *
-     * @mbg.generated
-     */
     public void setCreatedAt(Long createdAt) {
         this.createdAt = createdAt;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method returns the value of the database column we_com_user.updated_at
-     *
-     * @return the value of we_com_user.updated_at
-     *
-     * @mbg.generated
-     */
     public Long getUpdatedAt() {
         return updatedAt;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method sets the value of the database column we_com_user.updated_at
-     *
-     * @param updatedAt the value for we_com_user.updated_at
-     *
-     * @mbg.generated
-     */
     public void setUpdatedAt(Long updatedAt) {
         this.updatedAt = updatedAt;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method returns the value of the database column we_com_user.create_time
-     *
-     * @return the value of we_com_user.create_time
-     *
-     * @mbg.generated
-     */
     public Date getCreateTime() {
         return createTime;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method sets the value of the database column we_com_user.create_time
-     *
-     * @param createTime the value for we_com_user.create_time
-     *
-     * @mbg.generated
-     */
     public void setCreateTime(Date createTime) {
         this.createTime = createTime;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method returns the value of the database column we_com_user.update_time
-     *
-     * @return the value of we_com_user.update_time
-     *
-     * @mbg.generated
-     */
     public Date getUpdateTime() {
         return updateTime;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method sets the value of the database column we_com_user.update_time
-     *
-     * @param updateTime the value for we_com_user.update_time
-     *
-     * @mbg.generated
-     */
     public void setUpdateTime(Date updateTime) {
         this.updateTime = updateTime;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
     @Override
     public String toString() {
         StringBuilder sb = new StringBuilder();

+ 11 - 102
we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/UserExample.java

@@ -1,122 +1,53 @@
 package com.tzld.piaoquan.wecom.model.po;
 
+import com.tzld.piaoquan.wecom.utils.page.Page;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
 public class UserExample {
-    /**
-     * This field was generated by MyBatis Generator.
-     * This field corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
     protected String orderByClause;
 
-    /**
-     * This field was generated by MyBatis Generator.
-     * This field corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
     protected boolean distinct;
 
-    /**
-     * This field was generated by MyBatis Generator.
-     * This field corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
     protected List<Criteria> oredCriteria;
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
+    protected Page page;
+
     public UserExample() {
         oredCriteria = new ArrayList<Criteria>();
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
     public void setOrderByClause(String orderByClause) {
         this.orderByClause = orderByClause;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
     public String getOrderByClause() {
         return orderByClause;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
     public void setDistinct(boolean distinct) {
         this.distinct = distinct;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
     public boolean isDistinct() {
         return distinct;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
     public List<Criteria> getOredCriteria() {
         return oredCriteria;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
     public void or(Criteria criteria) {
         oredCriteria.add(criteria);
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
     public Criteria or() {
         Criteria criteria = createCriteriaInternal();
         oredCriteria.add(criteria);
         return criteria;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
     public Criteria createCriteria() {
         Criteria criteria = createCriteriaInternal();
         if (oredCriteria.size() == 0) {
@@ -125,35 +56,25 @@ public class UserExample {
         return criteria;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
     protected Criteria createCriteriaInternal() {
         Criteria criteria = new Criteria();
         return criteria;
     }
 
-    /**
-     * This method was generated by MyBatis Generator.
-     * This method corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
     public void clear() {
         oredCriteria.clear();
         orderByClause = null;
         distinct = false;
     }
 
-    /**
-     * This class was generated by MyBatis Generator.
-     * This class corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
+    public void setPage(Page page) {
+        this.page=page;
+    }
+
+    public Page getPage() {
+        return page;
+    }
+
     protected abstract static class GeneratedCriteria {
         protected List<Criterion> criteria;
 
@@ -1026,12 +947,6 @@ public class UserExample {
         }
     }
 
-    /**
-     * This class was generated by MyBatis Generator.
-     * This class corresponds to the database table we_com_user
-     *
-     * @mbg.generated do_not_delete_during_merge
-     */
     public static class Criteria extends GeneratedCriteria {
 
         protected Criteria() {
@@ -1039,12 +954,6 @@ public class UserExample {
         }
     }
 
-    /**
-     * This class was generated by MyBatis Generator.
-     * This class corresponds to the database table we_com_user
-     *
-     * @mbg.generated
-     */
     public static class Criterion {
         private String condition;
 

+ 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;
+}

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

@@ -0,0 +1,18 @@
+package com.tzld.piaoquan.wecom.model.vo;
+
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class MiniprogramVo {
+
+    private String title;
+
+    private String appid;
+
+    private String page;
+
+    private String cover;
+
+}

+ 6 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/AccessTokenService.java

@@ -0,0 +1,6 @@
+package com.tzld.piaoquan.wecom.service;
+
+public interface AccessTokenService {
+
+    String getAccessToken();
+}

+ 10 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/HistoryMessageService.java

@@ -0,0 +1,10 @@
+package com.tzld.piaoquan.wecom.service;
+
+import com.tzld.piaoquan.wecom.model.po.HistoryMessage;
+
+import java.util.List;
+
+public interface HistoryMessageService {
+
+    void batchInsertHistoryMessage(List<HistoryMessage> historyMessageList);
+}

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

@@ -0,0 +1,48 @@
+package com.tzld.piaoquan.wecom.service.Impl;
+
+import com.alibaba.fastjson.JSONObject;
+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.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.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);
+
+    @Autowired
+    private RedisTemplate<String, Object> redisTemplate;
+
+    @Override
+    public String getAccessToken() {
+        String accessToken = (String) redisTemplate.opsForValue().get(ACCESS_TOKEN);
+        if (StringUtils.isNotEmpty(accessToken)) {
+            return accessToken;
+        }
+        JSONObject param = new JSONObject();
+        param.put("corp_id", CROP_ID);
+        param.put("secret", SECRET);
+        try {
+            String res = httpPoolClientDefault.post(POST_ACCESS_TOKEN_URL, param.toJSONString());
+            JSONObject jsonObject = JSONObject.parseObject(res);
+            Long expiresIn = jsonObject.getLong("expires_in");
+            String newAccessToken = jsonObject.getString("access_token");
+            redisTemplate.opsForValue().set(ACCESS_TOKEN, newAccessToken, expiresIn, TimeUnit.SECONDS);
+            return newAccessToken;
+        } catch (IOException e) {
+            //TODO 打印错误日志
+            e.printStackTrace();
+        }
+        return "";
+    }
+}

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

@@ -0,0 +1,29 @@
+package com.tzld.piaoquan.wecom.service.Impl;
+
+import com.google.common.collect.Lists;
+import com.tzld.piaoquan.wecom.dao.mapper.HistoryMessageMapper;
+import com.tzld.piaoquan.wecom.model.po.HistoryMessage;
+import com.tzld.piaoquan.wecom.service.HistoryMessageService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.util.List;
+
+@Service
+public class HistoryMessageServiceImpl implements HistoryMessageService {
+
+    @Autowired
+    private HistoryMessageMapper historyMessageMapper;
+
+    @Override
+    public void batchInsertHistoryMessage(List<HistoryMessage> historyMessageList) {
+        if (CollectionUtils.isEmpty(historyMessageList)) {
+            return;
+        }
+        List<List<HistoryMessage>> partition = Lists.partition(historyMessageList, 1000);
+        for (List<HistoryMessage> historyMessages : partition) {
+            historyMessageMapper.insertList(historyMessages);
+        }
+    }
+}

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

@@ -0,0 +1,90 @@
+package com.tzld.piaoquan.wecom.service.Impl;
+
+import com.tzld.piaoquan.wecom.common.enums.MessageAttachmentTypeEnum;
+import com.tzld.piaoquan.wecom.common.exception.CustomizeException;
+import com.tzld.piaoquan.wecom.dao.mapper.MessageAttachmentMapper;
+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.MessageUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+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 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;
+
+
+@Service
+public class MessageAttachmentServiceImpl implements MessageAttachmentService {
+
+
+    @Autowired
+    private MessageAttachmentMapper messageAttachmentMapper;
+
+    @Autowired
+    private RedisTemplate<String, Object> redisTemplate;
+
+    @Override
+    public void addMiniprogram(List<MessageAttachment> messageAttachmentList) {
+        for (MessageAttachment messageAttachment : messageAttachmentList) {
+            MessageAttachmentExample example = new MessageAttachmentExample();
+            example.createCriteria()
+                    .andAppidEqualTo(messageAttachment.getAppid())
+                    .andTypeEqualTo(messageAttachment.getType())
+                    .andMiniprogramVideoIdEqualTo(messageAttachment.getMiniprogramVideoId());
+            List<MessageAttachment> messageAttachments = messageAttachmentMapper.selectByExample(example);
+            if (CollectionUtils.isEmpty(messageAttachments)) {
+                messageAttachmentMapper.insert(messageAttachment);
+                continue;
+            }
+            messageAttachment.setId(messageAttachments.get(0).getId());
+            messageAttachmentMapper.updateByPrimaryKeySelective(messageAttachment);
+        }
+    }
+
+    @Override
+    public void createGuaranteedMiniprogram(List<MiniprogramVo> miniprogramVoList) {
+        List<MessageAttachment> messageAttachmentList = new ArrayList<>();
+        List<Long> videoList = new ArrayList<>();
+        for (MiniprogramVo miniprogramVo : miniprogramVoList) {
+            if (StringUtils.isEmpty(miniprogramVo.getPage())) {
+                throw new CustomizeException(PARAMS_ERROR);
+            }
+            if (StringUtils.isEmpty(miniprogramVo.getCover())) {
+                throw new CustomizeException(PARAMS_ERROR);
+            }
+            if (StringUtils.isEmpty(miniprogramVo.getTitle())) {
+                throw new CustomizeException(PARAMS_ERROR);
+            }
+            Long videoId = MessageUtil.getVideoId(miniprogramVo.getPage());
+            if (videoId == null) {
+                throw new CustomizeException(PARAMS_ERROR);
+            }
+            if (StringUtils.isEmpty(miniprogramVo.getAppid())) {
+                miniprogramVo.setAppid(appid);
+            }
+            MessageAttachment messageAttachment = new MessageAttachment();
+            BeanUtils.copyProperties(miniprogramVo, messageAttachment);
+            messageAttachment.setMiniprogramVideoId(videoId);
+            messageAttachment.setType(MessageAttachmentTypeEnum.MINIPROGRAM.getType());
+            messageAttachmentList.add(messageAttachment);
+            videoList.add(videoId);
+        }
+        addMiniprogram(messageAttachmentList);
+        redisTemplate.delete(GUARANTEED_MINIPROGRAM_KEY);
+        Collections.reverse(videoList);
+        for (Long video : videoList) {
+            redisTemplate.opsForList().leftPush(GUARANTEED_MINIPROGRAM_KEY, video);
+        }
+    }
+}

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

@@ -0,0 +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.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);
+
+    @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;
+            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 - 20
we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/UserServiceImpl.java

@@ -1,20 +0,0 @@
-package com.tzld.piaoquan.wecom.service.Impl;
-
-import com.tzld.piaoquan.wecom.dao.mapper.UserMapper;
-import com.tzld.piaoquan.wecom.model.po.User;
-import com.tzld.piaoquan.wecom.service.UserService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-@Service
-public class UserServiceImpl implements UserService {
-
-    @Autowired
-    private UserMapper userMapper;
-
-    @Override
-    public boolean addUser(User user) {
-        int insert = userMapper.insert(user);
-        return insert > 0;
-    }
-}

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

@@ -0,0 +1,14 @@
+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;
+
+public interface MessageAttachmentService {
+
+    void addMiniprogram(List<MessageAttachment> messageAttachmentList);
+
+    void createGuaranteedMiniprogram(List<MiniprogramVo> miniprogramVoList);
+}

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

@@ -0,0 +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 {
-
-    public boolean addUser(User user);
-}

+ 35 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/DateUtil.java

@@ -0,0 +1,35 @@
+package com.tzld.piaoquan.wecom.utils;
+
+
+import java.time.LocalDate;
+import java.time.format.DateTimeFormatter;
+import java.util.Calendar;
+import java.util.Date;
+
+public class DateUtil {
+
+    //获取当天的日期
+    public static Date getThatDayDate() {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(new Date());
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        return calendar.getTime();
+    }
+
+    public static String getBeforeDayDateString() {
+        DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyyMMdd");
+        LocalDate today = LocalDate.now();
+        LocalDate yesterday = today.minusDays(1);
+        return dateFormat.format(yesterday);
+    }
+
+    public static String getDayDateString(String pattern) {
+        DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern(pattern);
+        LocalDate today = LocalDate.now();
+        return dateFormat.format(today);
+    }
+
+
+}

+ 1 - 1
we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/HttpClientUtil.java

@@ -8,7 +8,7 @@ import java.util.concurrent.locks.ReentrantLock;
 /**
  * http util
  *
- * @author supeng
+ * @author xueyiming
  */
 public class HttpClientUtil {
 

+ 8 - 4
we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/HttpPoolClient.java

@@ -1,8 +1,10 @@
 package com.tzld.piaoquan.wecom.utils;
 
+import com.alibaba.fastjson.JSONObject;
 import com.google.common.collect.Lists;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.concurrent.BasicThreadFactory;
+import org.apache.http.Consts;
 import org.apache.http.HttpEntity;
 import org.apache.http.HttpRequestInterceptor;
 import org.apache.http.HttpStatus;
@@ -20,6 +22,7 @@ import org.apache.http.impl.client.CloseableHttpClient;
 import org.apache.http.impl.client.DefaultHttpRequestRetryHandler;
 import org.apache.http.impl.client.HttpClientBuilder;
 import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+import org.apache.http.params.HttpParams;
 import org.apache.http.ssl.SSLContexts;
 import org.apache.http.util.EntityUtils;
 import org.slf4j.Logger;
@@ -30,11 +33,12 @@ import javax.net.ssl.SSLContext;
 import java.io.IOException;
 import java.net.SocketTimeoutException;
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.security.KeyManagementException;
 import java.security.KeyStoreException;
 import java.security.NoSuchAlgorithmException;
 import java.util.List;
-import java.util.Optional;
+import java.util.Map;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
@@ -42,7 +46,7 @@ import java.util.concurrent.TimeUnit;
 /**
  * http client
  *
- * @author supeng
+ * @author xueyiming
  */
 public class HttpPoolClient {
 
@@ -93,12 +97,12 @@ public class HttpPoolClient {
     }
 
 
-    public String postJson(String url, String json) throws IOException {
+    public String post(String url, String json) throws IOException {
         HttpPost httpPost = new HttpPost(url);
         if (StringUtils.isBlank(json)) {
             return request(httpPost);
         }
-        StringEntity entity = new StringEntity(json, Charset.forName("UTF-8"));
+        StringEntity entity = new StringEntity(json, StandardCharsets.UTF_8);
         entity.setContentEncoding("UTF-8");
         entity.setContentType("application/json");
         httpPost.setEntity(entity);

+ 22 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/MessageUtil.java

@@ -0,0 +1,22 @@
+package com.tzld.piaoquan.wecom.utils;
+
+import org.apache.commons.lang3.StringUtils;
+
+import static com.tzld.piaoquan.wecom.common.constant.MessageConstant.defaultName;
+
+public class MessageUtil {
+
+    public static Long getVideoId(String page){
+        String translate = URLUtil.translate(page);
+        String videoId = translate.split("id=")[1].split("&")[0];
+        if (StringUtils.isNotEmpty(videoId) && StringUtils.isNumeric(videoId)) {
+            return Long.parseLong(videoId);
+        }
+        return null;
+    }
+
+    public static String getName(){
+        return String.format(defaultName, DateUtil.getDayDateString("MMdd"));
+    }
+
+}

+ 33 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/OdpsUtil.java

@@ -0,0 +1,33 @@
+package com.tzld.piaoquan.wecom.utils;
+
+import com.aliyun.odps.Instance;
+import com.aliyun.odps.Odps;
+import com.aliyun.odps.OdpsException;
+import com.aliyun.odps.account.Account;
+import com.aliyun.odps.account.AliyunAccount;
+import com.aliyun.odps.data.Record;
+import com.aliyun.odps.task.SQLTask;
+
+import java.util.List;
+
+public class OdpsUtil {
+
+    public static List<Record> getOdpsData(String sql) {
+        String accessId = "LTAI9EBa0bd5PrDa";
+        String accessKey = "vAalxds7YxhfOA2yVv8GziCg3Y87v5";
+        String endpoint = "http://service.odps.aliyun.com/api";
+        Account account = new AliyunAccount(accessId, accessKey);
+        Odps odps = new Odps(account);
+        odps.setEndpoint(endpoint);
+        odps.setDefaultProject("loghubods");
+        Instance i;
+        try {
+            i = SQLTask.run(odps, sql);
+            i.waitForSuccess();
+            return SQLTask.getResult(i);
+        } catch (OdpsException e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+}

+ 10 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/URLUtil.java

@@ -0,0 +1,10 @@
+package com.tzld.piaoquan.wecom.utils;
+
+import java.net.URLDecoder;
+
+public class URLUtil {
+
+    public static String translate(String url) {
+        return URLDecoder.decode(url);
+    }
+}

+ 108 - 0
we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/page/Page.java

@@ -0,0 +1,108 @@
+package com.tzld.piaoquan.wecom.utils.page;
+
+import java.util.List;
+
+public class Page<T> {
+
+    public static final String DEFAULT_PAGE_SIZE = "20";
+    public static final String DEFAULT_CURRENT_PAGE = "1";
+
+    private int currentPage = Integer.valueOf(DEFAULT_CURRENT_PAGE);
+    private int totalSize;
+    private int pageSize = Integer.valueOf(DEFAULT_PAGE_SIZE);
+
+    private List<T> objs;
+
+    private T obj;
+
+    public Page() {
+    }
+
+    public Page(int currentPage) {
+        this.currentPage = currentPage;
+    }
+
+    public Page(int currentPage, int pageSize) {
+        setCurrentPage(currentPage);
+        setPageSize(pageSize);
+    }
+
+    public int getNextPage() {
+        return currentPage == getTotalPage() ? currentPage : currentPage + 1;
+    }
+
+    public int getPrePage() {
+        return currentPage > 1 ? currentPage - 1 : 1;
+    }
+
+    public int getOffset() {
+        return getCurPageFirstRecNum() - 1;
+    }
+
+    public int getCurPageFirstRecNum() {
+        return (getCurrentPage() - 1) * pageSize + 1;
+    }
+
+    public int getCurPageLastRecNum() {
+        return getCurrentPage() * pageSize;
+    }
+
+    public int getTotalPage() {
+        int t = totalSize % pageSize > 0 ? totalSize / pageSize + 1 : totalSize / pageSize;
+        if (t <= 0) {
+            t = 1;
+        }
+        return t;
+    }
+
+    public void setObjs(List<T> objs) {
+        this.objs = objs;
+    }
+
+    public List<T> getObjs() {
+        return objs;
+    }
+
+    public int getCurrentPage() {
+        return currentPage;
+    }
+
+    public void setCurrentPage(int currentPage) {
+        this.currentPage = currentPage;
+    }
+
+    public int getTotalSize() {
+        return totalSize;
+    }
+
+    public void setTotalSize(int totalSize) {
+        this.totalSize = totalSize;
+    }
+
+    public int getPageSize() {
+        return pageSize;
+    }
+
+    public void setPageSize(int pageSize) {
+        if (pageSize > 0) {
+            this.pageSize = pageSize;
+        }
+    }
+
+    public boolean containData() {
+        return getTotalSize() > 0;
+    }
+    @Override
+    public String toString() {
+        return "Page [currentPage=" + getCurrentPage() + ", totalSize=" + getTotalSize() + ", pageSize=" + getPageSize()
+                + "]";
+    }
+
+    public T getObj() {
+        return obj;
+    }
+
+    public void setObj(T obj) {
+        this.obj = obj;
+    }
+}

+ 12 - 0
we-com-server/src/main/resources/application.properties

@@ -15,3 +15,15 @@ spring.datasource.testOnReturn=false
 spring.datasource.poolPreparedStatements=true
 
 
+
+spring.redis.database=2
+spring.redis.host=r-bp154bpw97gptefiqkpd.redis.rds.aliyuncs.com
+spring.redis.port=6379
+spring.redis.password=Qingqu2019
+spring.redis.lettuce.pool.max-active=8
+spring.redis.lettuce.pool.max-wait=-1
+spring.redis.lettuce.pool.max-idle=8
+spring.redis.lettuce.pool.min-idle=0
+
+
+

+ 270 - 0
we-com-server/src/main/resources/mapper/HistoryMessageMapper.xml

@@ -0,0 +1,270 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.tzld.piaoquan.wecom.dao.mapper.HistoryMessageMapper">
+  <resultMap id="BaseResultMap" type="com.tzld.piaoquan.wecom.model.po.HistoryMessage">
+    <id column="id" jdbcType="BIGINT" property="id" />
+    <result column="user_id" jdbcType="BIGINT" property="userId" />
+    <result column="video_id" jdbcType="BIGINT" property="videoId" />
+    <result column="attachment_idx" jdbcType="INTEGER" property="attachmentIdx" />
+    <result column="message_id" jdbcType="BIGINT" property="messageId" />
+    <result column="send_time" jdbcType="TIMESTAMP" property="sendTime" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+  </resultMap>
+  <sql id="Example_Where_Clause">
+    <where>
+      <foreach collection="oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Update_By_Example_Where_Clause">
+    <where>
+      <foreach collection="example.oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Base_Column_List">
+    id, user_id, video_id, attachment_idx, message_id, send_time, create_time
+  </sql>
+  <select id="selectByExample" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessageExample" resultMap="BaseResultMap">
+    select
+    <if test="distinct">
+      distinct
+    </if>
+    <include refid="Base_Column_List" />
+    from we_com_history_message
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+    <if test="orderByClause != null">
+      order by ${orderByClause}
+    </if>
+    <if test="page != null">
+      limit #{page.offset} , #{page.pageSize}
+    </if>
+  </select>
+  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
+    select 
+    <include refid="Base_Column_List" />
+    from we_com_history_message
+    where id = #{id,jdbcType=BIGINT}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+    delete from we_com_history_message
+    where id = #{id,jdbcType=BIGINT}
+  </delete>
+  <delete id="deleteByExample" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessageExample">
+    delete from we_com_history_message
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </delete>
+  <insert id="insert" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessage">
+    insert into we_com_history_message (id, user_id, video_id, 
+      attachment_idx, message_id, send_time, 
+      create_time)
+    values (#{id,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{videoId,jdbcType=BIGINT}, 
+      #{attachmentIdx,jdbcType=INTEGER}, #{messageId,jdbcType=BIGINT}, #{sendTime,jdbcType=TIMESTAMP}, 
+      #{createTime,jdbcType=TIMESTAMP})
+  </insert>
+  <insert id="insertSelective" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessage">
+    insert into we_com_history_message
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <if test="userId != null">
+        user_id,
+      </if>
+      <if test="videoId != null">
+        video_id,
+      </if>
+      <if test="attachmentIdx != null">
+        attachment_idx,
+      </if>
+      <if test="messageId != null">
+        message_id,
+      </if>
+      <if test="sendTime != null">
+        send_time,
+      </if>
+      <if test="createTime != null">
+        create_time,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id,jdbcType=BIGINT},
+      </if>
+      <if test="userId != null">
+        #{userId,jdbcType=BIGINT},
+      </if>
+      <if test="videoId != null">
+        #{videoId,jdbcType=BIGINT},
+      </if>
+      <if test="attachmentIdx != null">
+        #{attachmentIdx,jdbcType=INTEGER},
+      </if>
+      <if test="messageId != null">
+        #{messageId,jdbcType=BIGINT},
+      </if>
+      <if test="sendTime != null">
+        #{sendTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+    </trim>
+  </insert>
+  <select id="countByExample" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessageExample" resultType="java.lang.Long">
+    select count(*) from we_com_history_message
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </select>
+  <update id="updateByExampleSelective" parameterType="map">
+    update we_com_history_message
+    <set>
+      <if test="record.id != null">
+        id = #{record.id,jdbcType=BIGINT},
+      </if>
+      <if test="record.userId != null">
+        user_id = #{record.userId,jdbcType=BIGINT},
+      </if>
+      <if test="record.videoId != null">
+        video_id = #{record.videoId,jdbcType=BIGINT},
+      </if>
+      <if test="record.attachmentIdx != null">
+        attachment_idx = #{record.attachmentIdx,jdbcType=INTEGER},
+      </if>
+      <if test="record.messageId != null">
+        message_id = #{record.messageId,jdbcType=BIGINT},
+      </if>
+      <if test="record.sendTime != null">
+        send_time = #{record.sendTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="record.createTime != null">
+        create_time = #{record.createTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByExample" parameterType="map">
+    update we_com_history_message
+    set id = #{record.id,jdbcType=BIGINT},
+      user_id = #{record.userId,jdbcType=BIGINT},
+      video_id = #{record.videoId,jdbcType=BIGINT},
+      attachment_idx = #{record.attachmentIdx,jdbcType=INTEGER},
+      message_id = #{record.messageId,jdbcType=BIGINT},
+      send_time = #{record.sendTime,jdbcType=TIMESTAMP},
+      create_time = #{record.createTime,jdbcType=TIMESTAMP}
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByPrimaryKeySelective" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessage">
+    update we_com_history_message
+    <set>
+      <if test="userId != null">
+        user_id = #{userId,jdbcType=BIGINT},
+      </if>
+      <if test="videoId != null">
+        video_id = #{videoId,jdbcType=BIGINT},
+      </if>
+      <if test="attachmentIdx != null">
+        attachment_idx = #{attachmentIdx,jdbcType=INTEGER},
+      </if>
+      <if test="messageId != null">
+        message_id = #{messageId,jdbcType=BIGINT},
+      </if>
+      <if test="sendTime != null">
+        send_time = #{sendTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="createTime != null">
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessage">
+    update we_com_history_message
+    set user_id = #{userId,jdbcType=BIGINT},
+      video_id = #{videoId,jdbcType=BIGINT},
+      attachment_idx = #{attachmentIdx,jdbcType=INTEGER},
+      message_id = #{messageId,jdbcType=BIGINT},
+      send_time = #{sendTime,jdbcType=TIMESTAMP},
+      create_time = #{createTime,jdbcType=TIMESTAMP}
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+
+  <insert id="insertList" parameterType="java.util.List">
+    insert into we_com_history_message
+    (
+     user_id,
+     video_id,
+     attachment_idx,
+     message_id,
+     send_time,
+     create_time
+    )
+    values
+    <foreach collection="list" item="item" separator=",">
+      (
+       #{item.userId,jdbcType=BIGINT},
+       #{item.videoId,jdbcType=BIGINT},
+       #{item.attachmentIdx,jdbcType=INTEGER},
+       #{item.messageId,jdbcType=BIGINT},
+       #{item.sendTime,jdbcType=TIMESTAMP},
+       #{item.createTime,jdbcType=TIMESTAMP}
+      )
+    </foreach>
+  </insert>
+
+</mapper>

+ 326 - 0
we-com-server/src/main/resources/mapper/MessageAttachmentMapper.xml

@@ -0,0 +1,326 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.tzld.piaoquan.wecom.dao.mapper.MessageAttachmentMapper">
+  <resultMap id="BaseResultMap" type="com.tzld.piaoquan.wecom.model.po.MessageAttachment">
+    <id column="id" jdbcType="BIGINT" property="id" />
+    <result column="type" jdbcType="INTEGER" property="type" />
+    <result column="url" jdbcType="VARCHAR" property="url" />
+    <result column="title" jdbcType="VARCHAR" property="title" />
+    <result column="desc" jdbcType="VARCHAR" property="desc" />
+    <result column="appid" jdbcType="VARCHAR" property="appid" />
+    <result column="page" jdbcType="VARCHAR" property="page" />
+    <result column="cover" jdbcType="VARCHAR" property="cover" />
+    <result column="miniprogram_video_id" jdbcType="BIGINT" property="miniprogramVideoId" />
+    <result column="is_delete" jdbcType="INTEGER" property="isDelete" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
+  </resultMap>
+  <sql id="Example_Where_Clause">
+    <where>
+      <foreach collection="oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Update_By_Example_Where_Clause">
+    <where>
+      <foreach collection="example.oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Base_Column_List">
+    id, `type`, url, title, `desc`, appid, page, cover, miniprogram_video_id, is_delete, 
+    create_time, update_time
+  </sql>
+  <select id="selectByExample" parameterType="com.tzld.piaoquan.wecom.model.po.MessageAttachmentExample" resultMap="BaseResultMap">
+    select
+    <if test="distinct">
+      distinct
+    </if>
+    <include refid="Base_Column_List" />
+    from we_com_message_attachment
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+    <if test="orderByClause != null">
+      order by ${orderByClause}
+    </if>
+    <if test="page != null">
+      limit #{page.offset} , #{page.pageSize}
+    </if>
+  </select>
+  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
+    select 
+    <include refid="Base_Column_List" />
+    from we_com_message_attachment
+    where id = #{id,jdbcType=BIGINT}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+    delete from we_com_message_attachment
+    where id = #{id,jdbcType=BIGINT}
+  </delete>
+  <delete id="deleteByExample" parameterType="com.tzld.piaoquan.wecom.model.po.MessageAttachmentExample">
+    delete from we_com_message_attachment
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </delete>
+  <insert id="insert" parameterType="com.tzld.piaoquan.wecom.model.po.MessageAttachment">
+    insert into we_com_message_attachment (id, `type`, url, 
+      title, `desc`, appid, 
+      page, cover, miniprogram_video_id, 
+      create_time, update_time
+      )
+    values (#{id,jdbcType=BIGINT}, #{type,jdbcType=INTEGER}, #{url,jdbcType=VARCHAR}, 
+      #{title,jdbcType=VARCHAR}, #{desc,jdbcType=VARCHAR}, #{appid,jdbcType=VARCHAR}, 
+      #{page,jdbcType=VARCHAR}, #{cover,jdbcType=VARCHAR}, #{miniprogramVideoId,jdbcType=BIGINT}, 
+      #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
+      )
+  </insert>
+  <insert id="insertSelective" parameterType="com.tzld.piaoquan.wecom.model.po.MessageAttachment">
+    insert into we_com_message_attachment
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <if test="type != null">
+        `type`,
+      </if>
+      <if test="url != null">
+        url,
+      </if>
+      <if test="title != null">
+        title,
+      </if>
+      <if test="desc != null">
+        `desc`,
+      </if>
+      <if test="appid != null">
+        appid,
+      </if>
+      <if test="page != null">
+        page,
+      </if>
+      <if test="cover != null">
+        cover,
+      </if>
+      <if test="miniprogramVideoId != null">
+        miniprogram_video_id,
+      </if>
+      <if test="isDelete != null">
+        is_delete,
+      </if>
+      <if test="createTime != null">
+        create_time,
+      </if>
+      <if test="updateTime != null">
+        update_time,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id,jdbcType=BIGINT},
+      </if>
+      <if test="type != null">
+        #{type,jdbcType=INTEGER},
+      </if>
+      <if test="url != null">
+        #{url,jdbcType=VARCHAR},
+      </if>
+      <if test="title != null">
+        #{title,jdbcType=VARCHAR},
+      </if>
+      <if test="desc != null">
+        #{desc,jdbcType=VARCHAR},
+      </if>
+      <if test="appid != null">
+        #{appid,jdbcType=VARCHAR},
+      </if>
+      <if test="page != null">
+        #{page,jdbcType=VARCHAR},
+      </if>
+      <if test="cover != null">
+        #{cover,jdbcType=VARCHAR},
+      </if>
+      <if test="miniprogramVideoId != null">
+        #{miniprogramVideoId,jdbcType=BIGINT},
+      </if>
+      <if test="isDelete != null">
+        #{isDelete,jdbcType=INTEGER},
+      </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateTime != null">
+        #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+    </trim>
+  </insert>
+  <select id="countByExample" parameterType="com.tzld.piaoquan.wecom.model.po.MessageAttachmentExample" resultType="java.lang.Long">
+    select count(*) from we_com_message_attachment
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </select>
+  <update id="updateByExampleSelective" parameterType="map">
+    update we_com_message_attachment
+    <set>
+      <if test="record.id != null">
+        id = #{record.id,jdbcType=BIGINT},
+      </if>
+      <if test="record.type != null">
+        `type` = #{record.type,jdbcType=INTEGER},
+      </if>
+      <if test="record.url != null">
+        url = #{record.url,jdbcType=VARCHAR},
+      </if>
+      <if test="record.title != null">
+        title = #{record.title,jdbcType=VARCHAR},
+      </if>
+      <if test="record.desc != null">
+        `desc` = #{record.desc,jdbcType=VARCHAR},
+      </if>
+      <if test="record.appid != null">
+        appid = #{record.appid,jdbcType=VARCHAR},
+      </if>
+      <if test="record.page != null">
+        page = #{record.page,jdbcType=VARCHAR},
+      </if>
+      <if test="record.cover != null">
+        cover = #{record.cover,jdbcType=VARCHAR},
+      </if>
+      <if test="record.miniprogramVideoId != null">
+        miniprogram_video_id = #{record.miniprogramVideoId,jdbcType=BIGINT},
+      </if>
+      <if test="record.isDelete != null">
+        is_delete = #{record.isDelete,jdbcType=INTEGER},
+      </if>
+      <if test="record.createTime != null">
+        create_time = #{record.createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="record.updateTime != null">
+        update_time = #{record.updateTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByExample" parameterType="map">
+    update we_com_message_attachment
+    set id = #{record.id,jdbcType=BIGINT},
+      `type` = #{record.type,jdbcType=INTEGER},
+      url = #{record.url,jdbcType=VARCHAR},
+      title = #{record.title,jdbcType=VARCHAR},
+      `desc` = #{record.desc,jdbcType=VARCHAR},
+      appid = #{record.appid,jdbcType=VARCHAR},
+      page = #{record.page,jdbcType=VARCHAR},
+      cover = #{record.cover,jdbcType=VARCHAR},
+      miniprogram_video_id = #{record.miniprogramVideoId,jdbcType=BIGINT},
+      is_delete = #{record.isDelete,jdbcType=INTEGER},
+      create_time = #{record.createTime,jdbcType=TIMESTAMP},
+      update_time = #{record.updateTime,jdbcType=TIMESTAMP}
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByPrimaryKeySelective" parameterType="com.tzld.piaoquan.wecom.model.po.MessageAttachment">
+    update we_com_message_attachment
+    <set>
+      <if test="type != null">
+        `type` = #{type,jdbcType=INTEGER},
+      </if>
+      <if test="url != null">
+        url = #{url,jdbcType=VARCHAR},
+      </if>
+      <if test="title != null">
+        title = #{title,jdbcType=VARCHAR},
+      </if>
+      <if test="desc != null">
+        `desc` = #{desc,jdbcType=VARCHAR},
+      </if>
+      <if test="appid != null">
+        appid = #{appid,jdbcType=VARCHAR},
+      </if>
+      <if test="page != null">
+        page = #{page,jdbcType=VARCHAR},
+      </if>
+      <if test="cover != null">
+        cover = #{cover,jdbcType=VARCHAR},
+      </if>
+      <if test="miniprogramVideoId != null">
+        miniprogram_video_id = #{miniprogramVideoId,jdbcType=BIGINT},
+      </if>
+      <if test="isDelete != null">
+        is_delete = #{isDelete,jdbcType=INTEGER},
+      </if>
+      <if test="createTime != null">
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateTime != null">
+        update_time = #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.wecom.model.po.MessageAttachment">
+    update we_com_message_attachment
+    set `type` = #{type,jdbcType=INTEGER},
+      url = #{url,jdbcType=VARCHAR},
+      title = #{title,jdbcType=VARCHAR},
+      `desc` = #{desc,jdbcType=VARCHAR},
+      appid = #{appid,jdbcType=VARCHAR},
+      page = #{page,jdbcType=VARCHAR},
+      cover = #{cover,jdbcType=VARCHAR},
+      miniprogram_video_id = #{miniprogramVideoId,jdbcType=BIGINT},
+      is_delete = #{isDelete,jdbcType=INTEGER},
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      update_time = #{updateTime,jdbcType=TIMESTAMP}
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+</mapper>

+ 44 - 60
we-com-server/src/main/resources/mapper/UserMapper.xml

@@ -2,10 +2,6 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.tzld.piaoquan.wecom.dao.mapper.UserMapper">
   <resultMap id="BaseResultMap" type="com.tzld.piaoquan.wecom.model.po.User">
-    <!--
-      WARNING - @mbg.generated
-      This element is automatically generated by MyBatis Generator, do not modify.
-    -->
     <id column="id" jdbcType="BIGINT" property="id" />
     <result column="external_user_id" jdbcType="VARCHAR" property="externalUserId" />
     <result column="union_id" jdbcType="VARCHAR" property="unionId" />
@@ -21,10 +17,6 @@
     <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
   </resultMap>
   <sql id="Example_Where_Clause">
-    <!--
-      WARNING - @mbg.generated
-      This element is automatically generated by MyBatis Generator, do not modify.
-    -->
     <where>
       <foreach collection="oredCriteria" item="criteria" separator="or">
         <if test="criteria.valid">
@@ -54,10 +46,6 @@
     </where>
   </sql>
   <sql id="Update_By_Example_Where_Clause">
-    <!--
-      WARNING - @mbg.generated
-      This element is automatically generated by MyBatis Generator, do not modify.
-    -->
     <where>
       <foreach collection="example.oredCriteria" item="criteria" separator="or">
         <if test="criteria.valid">
@@ -87,18 +75,10 @@
     </where>
   </sql>
   <sql id="Base_Column_List">
-    <!--
-      WARNING - @mbg.generated
-      This element is automatically generated by MyBatis Generator, do not modify.
-    -->
     id, external_user_id, union_id, external_user_id_3rd_party, `type`, `name`, avatar, 
     gender, is_delete, created_at, updated_at, create_time, update_time
   </sql>
   <select id="selectByExample" parameterType="com.tzld.piaoquan.wecom.model.po.UserExample" resultMap="BaseResultMap">
-    <!--
-      WARNING - @mbg.generated
-      This element is automatically generated by MyBatis Generator, do not modify.
-    -->
     select
     <if test="distinct">
       distinct
@@ -111,40 +91,27 @@
     <if test="orderByClause != null">
       order by ${orderByClause}
     </if>
+    <if test="page != null">
+      limit #{page.offset} , #{page.pageSize}
+    </if>
   </select>
   <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
-    <!--
-      WARNING - @mbg.generated
-      This element is automatically generated by MyBatis Generator, do not modify.
-    -->
     select 
     <include refid="Base_Column_List" />
     from we_com_user
     where id = #{id,jdbcType=BIGINT}
   </select>
   <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
-    <!--
-      WARNING - @mbg.generated
-      This element is automatically generated by MyBatis Generator, do not modify.
-    -->
     delete from we_com_user
     where id = #{id,jdbcType=BIGINT}
   </delete>
   <delete id="deleteByExample" parameterType="com.tzld.piaoquan.wecom.model.po.UserExample">
-    <!--
-      WARNING - @mbg.generated
-      This element is automatically generated by MyBatis Generator, do not modify.
-    -->
     delete from we_com_user
     <if test="_parameter != null">
       <include refid="Example_Where_Clause" />
     </if>
   </delete>
   <insert id="insert" parameterType="com.tzld.piaoquan.wecom.model.po.User">
-    <!--
-      WARNING - @mbg.generated
-      This element is automatically generated by MyBatis Generator, do not modify.
-    -->
     insert into we_com_user (id, external_user_id, union_id, 
       external_user_id_3rd_party, `type`, `name`, 
       avatar, gender,
@@ -157,10 +124,6 @@
       #{updateTime,jdbcType=TIMESTAMP})
   </insert>
   <insert id="insertSelective" parameterType="com.tzld.piaoquan.wecom.model.po.User">
-    <!--
-      WARNING - @mbg.generated
-      This element is automatically generated by MyBatis Generator, do not modify.
-    -->
     insert into we_com_user
     <trim prefix="(" suffix=")" suffixOverrides=",">
       <if test="id != null">
@@ -246,20 +209,12 @@
     </trim>
   </insert>
   <select id="countByExample" parameterType="com.tzld.piaoquan.wecom.model.po.UserExample" resultType="java.lang.Long">
-    <!--
-      WARNING - @mbg.generated
-      This element is automatically generated by MyBatis Generator, do not modify.
-    -->
     select count(*) from we_com_user
     <if test="_parameter != null">
       <include refid="Example_Where_Clause" />
     </if>
   </select>
   <update id="updateByExampleSelective" parameterType="map">
-    <!--
-      WARNING - @mbg.generated
-      This element is automatically generated by MyBatis Generator, do not modify.
-    -->
     update we_com_user
     <set>
       <if test="record.id != null">
@@ -307,10 +262,6 @@
     </if>
   </update>
   <update id="updateByExample" parameterType="map">
-    <!--
-      WARNING - @mbg.generated
-      This element is automatically generated by MyBatis Generator, do not modify.
-    -->
     update we_com_user
     set id = #{record.id,jdbcType=BIGINT},
       external_user_id = #{record.externalUserId,jdbcType=VARCHAR},
@@ -330,10 +281,6 @@
     </if>
   </update>
   <update id="updateByPrimaryKeySelective" parameterType="com.tzld.piaoquan.wecom.model.po.User">
-    <!--
-      WARNING - @mbg.generated
-      This element is automatically generated by MyBatis Generator, do not modify.
-    -->
     update we_com_user
     <set>
       <if test="externalUserId != null">
@@ -376,10 +323,6 @@
     where id = #{id,jdbcType=BIGINT}
   </update>
   <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.wecom.model.po.User">
-    <!--
-      WARNING - @mbg.generated
-      This element is automatically generated by MyBatis Generator, do not modify.
-    -->
     update we_com_user
     set external_user_id = #{externalUserId,jdbcType=VARCHAR},
       union_id = #{unionId,jdbcType=VARCHAR},
@@ -395,4 +338,45 @@
       update_time = #{updateTime,jdbcType=TIMESTAMP}
     where id = #{id,jdbcType=BIGINT}
   </update>
+
+
+  <select id="selectIdByExternalUserId3rdParty" parameterType="String" resultType="Long">
+    select
+        id
+    from we_com_user
+    where external_user_id_3rd_party = #{externalUserId3rdParty}
+  </select>
+
+  <insert id="insertList" parameterType="java.util.List">
+    insert into we_com_user
+    (
+     external_user_id,
+     union_id,
+     external_user_id_3rd_party,
+     `type`,
+     `name`,
+     avatar,
+     gender,
+     created_at,
+     updated_at,
+     create_time,
+     update_time
+    )
+    values
+    <foreach collection="list" item="item" separator=",">
+      (
+       #{item.externalUserId,jdbcType=VARCHAR},
+       #{item.unionId,jdbcType=VARCHAR},
+       #{item.externalUserId3rdParty,jdbcType=VARCHAR},
+       #{item.type,jdbcType=INTEGER},
+       #{item.name,jdbcType=VARCHAR},
+       #{item.avatar,jdbcType=VARCHAR},
+       #{item.gender,jdbcType=INTEGER},
+       #{item.createdAt,jdbcType=BIGINT},
+       #{item.updatedAt,jdbcType=BIGINT},
+       #{item.createTime,jdbcType=TIMESTAMP},
+       #{item.updateTime,jdbcType=TIMESTAMP}
+      )
+    </foreach>
+  </insert>
 </mapper>

+ 59 - 0
we-com-server/src/main/resources/mybatis-generator-config.xml

@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE generatorConfiguration
+        PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
+        "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
+<!-- 配置生成器 -->
+<generatorConfiguration>
+    <context id="mysql" defaultModelType="flat">
+        <property name="autoDelimitKeywords" value="true"/>
+        <!-- 生成的Java文件的编码 -->
+        <property name="javaFileEncoding" value="UTF-8"/>
+        <!-- 格式化java代码 -->
+        <property name="javaFormatter" value="org.mybatis.generator.api.dom.DefaultJavaFormatter"/>
+        <!-- 格式化XML代码 -->
+        <property name="xmlFormatter" value="org.mybatis.generator.api.dom.DefaultXmlFormatter"/>
+        <!-- beginningDelimiter和endingDelimiter:指明数据库的用于标记数据库对象名的符号,比如ORACLE就是双引号,MYSQL默认是`反引号; -->
+        <property name="beginningDelimiter" value="`"/>
+        <property name="endingDelimiter" value="`"/>
+
+        <plugin type="org.mybatis.generator.plugins.ToStringPlugin"/>
+        <plugin type="org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin"/>
+        <plugin type="com.tzld.piaoquan.wecom.dao.generator.PaginationPlugin"/>
+
+        <commentGenerator>
+<!--            <property name="addRemarkComments" value="true"/>-->
+            <property name="suppressDate" value="true"/>
+            <property name="suppressAllComments" value="true"/>
+        </commentGenerator>
+
+        <jdbcConnection driverClass="com.mysql.jdbc.Driver"
+                        connectionURL="jdbc:mysql://rm-bp1k5853td1r25g3n690.mysql.rds.aliyuncs.com:3306/piaoquan-crawler?useUnicode=true&amp;characterEncoding=utf-8&amp;zeroDateTimeBehavior=convertToNull&amp;useSSL=false"
+                        userId="crawler" password="crawler123456@">
+        </jdbcConnection>
+
+        <javaTypeResolver type="org.mybatis.generator.internal.types.JavaTypeResolverDefaultImpl">
+            <property name="forceBigDecimals" value="false"/>
+        </javaTypeResolver>
+
+        <javaModelGenerator targetPackage="com.tzld.piaoquan.wecom.model.po" targetProject="/Users/shimeng/Desktop/project/we-com-manage/we-com-server/src/main/java">
+            <property name="constructorBased" value="false"/>
+            <property name="enableSubPackages" value="true"/>
+            <property name="immutable" value="false"/>
+        </javaModelGenerator>
+
+        <sqlMapGenerator targetPackage="mapper" targetProject="/Users/shimeng/Desktop/project/we-com-manage/we-com-server/src/main/resources">
+            <property name="enableSubPackages" value="true"/>
+        </sqlMapGenerator>
+
+        <javaClientGenerator targetPackage="com.tzld.piaoquan.wecom.dao.mapper" type="XMLMAPPER"
+                             targetProject="/Users/shimeng/Desktop/project/we-com-manage/we-com-server/src/main/java">
+            <property name="enableSubPackages" value="true"/>
+        </javaClientGenerator>
+
+<!--        <table tableName="we_com_user" domainObjectName="User" alias=""/>-->
+        <table tableName="we_com_history_message" domainObjectName="HistoryMessage" alias=""/>
+        <table tableName="we_com_message_attachment" domainObjectName="MessageAttachment" alias=""/>
+
+    </context>
+
+</generatorConfiguration>