Bladeren bron

增加历史记录获取

xueyiming 7 maanden geleden
bovenliggende
commit
cd0dbc74c4
18 gewijzigde bestanden met toevoegingen van 1222 en 554 verwijderingen
  1. 33 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/dao/mapper/HistoryMessageMapper.java
  2. 2 66
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/dao/mapper/UserMapper.java
  3. 126 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComHistoryDataJob.java
  4. 0 4
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComUserDataJob.java
  5. 15 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/bo/Miniprogram.java
  6. 92 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/HistoryMessage.java
  7. 634 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/HistoryMessageExample.java
  8. 1 331
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/User.java
  9. 1 90
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/UserExample.java
  10. 10 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/HistoryMessageService.java
  11. 33 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/HistoryMessageServiceImpl.java
  12. 8 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/UserServiceImpl.java
  13. 3 1
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/UserService.java
  14. 1 1
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/HttpClientUtil.java
  15. 1 1
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/HttpPoolClient.java
  16. 10 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/utils/URLUtil.java
  17. 244 0
      we-com-server/src/main/resources/mapper/HistoryMessageMapper.xml
  18. 8 60
      we-com-server/src/main/resources/mapper/UserMapper.xml

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

@@ -0,0 +1,33 @@
+package com.tzld.piaoquan.wecom.dao.mapper;
+
+import com.tzld.piaoquan.wecom.model.po.HistoryMessage;
+import com.tzld.piaoquan.wecom.model.po.HistoryMessageExample;
+import java.util.List;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+@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);
+}

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

@@ -6,91 +6,27 @@ import java.util.List;
 import org.apache.ibatis.annotations.Param;
 
 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);
 }

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

@@ -0,0 +1,126 @@
+package com.tzld.piaoquan.wecom.job;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.tzld.piaoquan.wecom.dao.mapper.UserMapper;
+import com.tzld.piaoquan.wecom.model.bo.Miniprogram;
+import com.tzld.piaoquan.wecom.model.po.HistoryMessage;
+import com.tzld.piaoquan.wecom.model.po.User;
+import com.tzld.piaoquan.wecom.service.HistoryMessageService;
+import com.tzld.piaoquan.wecom.utils.HttpClientUtil;
+import com.tzld.piaoquan.wecom.utils.HttpPoolClient;
+import com.tzld.piaoquan.wecom.utils.URLUtil;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.util.CollectionUtils;
+
+import java.io.IOException;
+import java.net.URLDecoder;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+@Component
+public class WeComHistoryDataJob {
+
+
+    String GET_HISTORY_DATA_URL = "https://open.weibanzhushou.com/open-api/group_msg/result";
+
+    String ACCESS_TOKEN = "b41281675156a3355c2f4d61398a24d3";
+
+    private static final HttpPoolClient httpPoolClientDefault = HttpClientUtil.create(30000, 30000, 2000, 5000, 5, 30000);
+
+    final int size = 20;
+
+    @Autowired
+    private UserMapper userMapper;
+
+    @Autowired
+    private HistoryMessageService historyMessageService;
+
+    public void selectHistoryMessage() {
+        String res = null;
+        try {
+            //TODO accessToken 暂时写死 后续增加接口刷新和存储
+            res = getHistoryData(ACCESS_TOKEN, size, 0, 1726416000L, 1726588800L);
+            //TODO 记录查询数据 info日志
+        } catch (IOException e) {
+            //TODO 记录异常日志 记录起止时间和页数 startTime endTime i
+            e.printStackTrace();
+        }
+        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<Miniprogram> miniprogramList = 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++) {
+                Miniprogram miniprogram = new Miniprogram();
+                String page = attachments.getJSONObject(j).getJSONObject("miniprogram").getString("page");
+                //历史先用切割法
+                String translate = URLUtil.translate(page);
+                String videoId = translate.split("id=")[1].split("&")[0];
+                if (StringUtils.isNotEmpty(videoId) && StringUtils.isNumeric(videoId)) {
+                    miniprogram.setVideoId(Long.parseLong(videoId));
+                }
+                miniprogram.setAttachmentIdx(j + 1);
+                miniprogramList.add(miniprogram);
+            }
+            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, miniprogramList, createdAt);
+        }
+
+
+    }
+
+
+
+
+    private void insertHistoryMessageList(List<String> allExternalUserList, List<Miniprogram> miniprogramList, Date sendTime) {
+        List<HistoryMessage> historyMessageList = new ArrayList<>();
+        for (String externalUserId3rdParty : allExternalUserList) {
+            Long userId = userMapper.selectIdByExternalUserId3rdParty(externalUserId3rdParty);
+            if (userId == null) {
+                continue;
+            }
+            for (Miniprogram miniprogram : miniprogramList) {
+                HistoryMessage historyMessage = new HistoryMessage();
+                historyMessage.setCreateTime(sendTime);
+                historyMessage.setAttachmentIdx(miniprogram.getAttachmentIdx());
+                historyMessage.setVideoId(miniprogram.getVideoId());
+                historyMessage.setUserId(userId);
+                historyMessageList.add(historyMessage);
+            }
+        }
+        historyMessageService.batchInsertHistoryMessage(historyMessageList);
+    }
+
+    public String getHistoryData(String accessToken, Integer limit, Integer offset, Long startTime, Long endTime) throws IOException {
+        String url = GET_HISTORY_DATA_URL
+                + "?access_token=" + accessToken
+                + "&limit=" + limit + "&offset=" + offset + "&start_time=" + startTime + "&end_time=" + endTime;
+        return httpPoolClientDefault.get(url);
+    }
+}
+
+
+
+
+
+

+ 0 - 4
we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComUserDataJob.java

@@ -8,15 +8,11 @@ import com.tzld.piaoquan.wecom.model.po.UserExample;
 import com.tzld.piaoquan.wecom.utils.HttpClientUtil;
 import com.tzld.piaoquan.wecom.utils.HttpPoolClient;
 import org.apache.commons.lang3.ObjectUtils;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Bean;
 import org.springframework.stereotype.Component;
 import org.springframework.util.CollectionUtils;
 
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 
 @Component

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

@@ -0,0 +1,15 @@
+package com.tzld.piaoquan.wecom.model.bo;
+
+import lombok.Data;
+import lombok.Getter;
+
+import java.util.Date;
+
+@Data
+public class Miniprogram {
+
+    private Long videoId;
+
+    private Integer attachmentIdx;
+
+}

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

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

@@ -0,0 +1,634 @@
+package com.tzld.piaoquan.wecom.model.po;
+
+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;
+
+    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;
+    }
+
+    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;
+        }
+    }
+
+    /**
+     * This class was generated by MyBatis Generator.
+     * This class corresponds to the database table we_com_history_message
+     *
+     * @mbg.generated do_not_delete_during_merge
+     */
+    public static class Criteria extends GeneratedCriteria {
+
+        protected Criteria() {
+            super();
+        }
+    }
+
+    /**
+     * This class was generated by MyBatis Generator.
+     * This class corresponds to the database table we_com_history_message
+     *
+     * @mbg.generated
+     */
+    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);
+        }
+    }
+}

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

@@ -8,467 +8,137 @@ import java.util.Date;
  * 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();

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

@@ -5,118 +5,47 @@ 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
-     */
     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 +54,17 @@ 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
-     */
     protected abstract static class GeneratedCriteria {
         protected List<Criterion> criteria;
 

+ 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 {
+
+    boolean batchInsertHistoryMessage(List<HistoryMessage> historyMessageList);
+}

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

@@ -0,0 +1,33 @@
+package com.tzld.piaoquan.wecom.service.Impl;
+
+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 java.util.List;
+
+@Service
+public class HistoryMessageServiceImpl implements HistoryMessageService {
+
+    @Autowired
+    private HistoryMessageMapper historyMessageMapper;
+
+    @Override
+    public boolean batchInsertHistoryMessage(List<HistoryMessage> historyMessageList) {
+        for (HistoryMessage historyMessage : historyMessageList) {
+            //处理异常  保证大部分数据处理成功
+            try {
+                int insert = historyMessageMapper.insert(historyMessage);
+                if (insert <= 0) {
+                    //TODO 记录异常日志
+                }
+            } catch (Exception e) {
+                //TODO 输出异常信息 记录插入失败信息 historyMessage
+                e.printStackTrace();
+            }
+        }
+        return true;
+    }
+}

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

@@ -6,6 +6,8 @@ import com.tzld.piaoquan.wecom.service.UserService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 @Service
 public class UserServiceImpl implements UserService {
 
@@ -17,4 +19,10 @@ public class UserServiceImpl implements UserService {
         int insert = userMapper.insert(user);
         return insert > 0;
     }
+
+    @Override
+    public Long getIdByExternalUserId3rdParty(String externalUserId3rdParty) {
+        return userMapper.selectIdByExternalUserId3rdParty(externalUserId3rdParty);
+
+    }
 }

+ 3 - 1
we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/UserService.java

@@ -4,5 +4,7 @@ import com.tzld.piaoquan.wecom.model.po.User;
 
 public interface UserService {
 
-    public boolean addUser(User user);
+    boolean addUser(User user);
+
+    Long getIdByExternalUserId3rdParty(String externalUserId3rdParty);
 }

+ 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 {
 

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

@@ -42,7 +42,7 @@ import java.util.concurrent.TimeUnit;
 /**
  * http client
  *
- * @author supeng
+ * @author xueyiming
  */
 public class HttpPoolClient {
 

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

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

@@ -0,0 +1,244 @@
+<?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>
+  </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>
+</mapper>

+ 8 - 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
@@ -113,38 +93,22 @@
     </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 +121,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 +206,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 +259,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 +278,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 +320,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 +335,12 @@
       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>
 </mapper>