瀏覽代碼

Merge branch 'dev-xym-update-msg' of Server/growth-manager into master

xueyiming 3 月之前
父節點
當前提交
7e4f6ab12e
共有 15 個文件被更改,包括 1264 次插入60 次删除
  1. 3 3
      api-module/src/main/resources/mybatis-generator-config.xml
  2. 10 7
      common-module/src/main/java/com/tzld/piaoquan/growth/common/common/enums/MessageAttachmentTypeEnum.java
  3. 35 0
      common-module/src/main/java/com/tzld/piaoquan/growth/common/dao/mapper/AttachmentWithMsgResultMapper.java
  4. 4 0
      common-module/src/main/java/com/tzld/piaoquan/growth/common/dao/mapper/SendMsgResultMapper.java
  5. 70 0
      common-module/src/main/java/com/tzld/piaoquan/growth/common/model/po/AttachmentWithMsgResult.java
  6. 513 0
      common-module/src/main/java/com/tzld/piaoquan/growth/common/model/po/AttachmentWithMsgResultExample.java
  7. 22 0
      common-module/src/main/java/com/tzld/piaoquan/growth/common/model/po/MessageAttachment.java
  8. 140 0
      common-module/src/main/java/com/tzld/piaoquan/growth/common/model/po/MessageAttachmentExample.java
  9. 11 0
      common-module/src/main/java/com/tzld/piaoquan/growth/common/model/po/SendMsgResult.java
  10. 35 13
      common-module/src/main/java/com/tzld/piaoquan/growth/common/service/Impl/MessageAttachmentServiceImpl.java
  11. 1 1
      common-module/src/main/java/com/tzld/piaoquan/growth/common/service/MessageAttachmentService.java
  12. 214 0
      common-module/src/main/resources/mapper/AttachmentWithMsgResultMapper.xml
  13. 42 7
      common-module/src/main/resources/mapper/MessageAttachmentMapper.xml
  14. 77 6
      common-module/src/main/resources/mapper/SendMsgResultMapper.xml
  15. 87 23
      offline-module/src/main/java/com/tzld/piaoquan/offline/job/WeComHistoryDataJob.java

+ 3 - 3
api-module/src/main/resources/mybatis-generator-config.xml

@@ -54,9 +54,9 @@
 <!--        <table tableName="gh_detail" domainObjectName="GhDetail" alias=""/>-->
 <!--        <table tableName="we_com_guarantees_video" domainObjectName="GuaranteesVideo" alias=""/>-->
 <!--        <table tableName="we_com_staff" domainObjectName="Staff" alias=""/>-->
-<!--        <table tableName="we_com_staff_with_user" domainObjectName="StaffWithUser" alias=""/>-->
-<!--        <table tableName="we_com_send_message" domainObjectName="SendMessage" alias=""/>-->
-        <table tableName="we_com_send_msg_result" domainObjectName="SendMsgResult" alias=""/>
+<!--        <table tableName="we_com_message_attachment" domainObjectName="MessageAttachment" alias=""/>-->
+        <table tableName="we_com_attachment_with_msg_result" domainObjectName="AttachmentWithMsgResult" alias=""/>
+<!--        <table tableName="we_com_send_msg_result" domainObjectName="SendMsgResult" alias=""/>-->
 <!--        <table tableName="we_com_corp" domainObjectName="Corp" alias=""/>-->
 
     </context>

+ 10 - 7
common-module/src/main/java/com/tzld/piaoquan/growth/common/common/enums/MessageAttachmentTypeEnum.java

@@ -5,15 +5,18 @@ import lombok.Getter;
 @Getter
 public enum MessageAttachmentTypeEnum {
 
-    DEFAULT(0,"未知"),
-    IMAGE(1,"图片"),
-    LINK(2,"链接"),
-    MINI_PROGRAM(3, "小程序"),
-    VIDEO(4, "视频");
+    DEFAULT(0, "", "未知"),
+    IMAGE(1, "image", "图片"),
+    LINK(2, "link", "链接"),
+    MINI_PROGRAM(3, "miniprogram", "小程序"),
+    VIDEO(4, "video", "视频");
 
-    final Integer type;
+    final Integer code;
+    final String type;
     final String desc;
-    MessageAttachmentTypeEnum(Integer type, String desc){
+
+    MessageAttachmentTypeEnum(Integer code, String type, String desc) {
+        this.code = code;
         this.type = type;
         this.desc = desc;
     }

+ 35 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/dao/mapper/AttachmentWithMsgResultMapper.java

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

+ 4 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/dao/mapper/SendMsgResultMapper.java

@@ -27,9 +27,13 @@ public interface SendMsgResultMapper {
 
     int updateByExampleSelective(@Param("record") SendMsgResult record, @Param("example") SendMsgResultExample example);
 
+    int updateByExampleWithBLOBs(@Param("record") SendMsgResult record, @Param("example") SendMsgResultExample example);
+
     int updateByExample(@Param("record") SendMsgResult record, @Param("example") SendMsgResultExample example);
 
     int updateByPrimaryKeySelective(SendMsgResult record);
 
+    int updateByPrimaryKeyWithBLOBs(SendMsgResult record);
+
     int updateByPrimaryKey(SendMsgResult record);
 }

+ 70 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/model/po/AttachmentWithMsgResult.java

@@ -0,0 +1,70 @@
+package com.tzld.piaoquan.growth.common.model.po;
+
+import java.util.Date;
+
+public class AttachmentWithMsgResult {
+    private Long id;
+
+    private Long attachmentId;
+
+    private Long msgResultId;
+
+    private Date createTime;
+
+    private Date updateTime;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getAttachmentId() {
+        return attachmentId;
+    }
+
+    public void setAttachmentId(Long attachmentId) {
+        this.attachmentId = attachmentId;
+    }
+
+    public Long getMsgResultId() {
+        return msgResultId;
+    }
+
+    public void setMsgResultId(Long msgResultId) {
+        this.msgResultId = msgResultId;
+    }
+
+    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(", attachmentId=").append(attachmentId);
+        sb.append(", msgResultId=").append(msgResultId);
+        sb.append(", createTime=").append(createTime);
+        sb.append(", updateTime=").append(updateTime);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 513 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/model/po/AttachmentWithMsgResultExample.java

@@ -0,0 +1,513 @@
+package com.tzld.piaoquan.growth.common.model.po;
+
+import com.tzld.piaoquan.growth.common.utils.page.Page;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class AttachmentWithMsgResultExample {
+    protected String orderByClause;
+
+    protected boolean distinct;
+
+    protected List<Criteria> oredCriteria;
+
+    protected Page page;
+
+    public AttachmentWithMsgResultExample() {
+        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 andAttachmentIdIsNull() {
+            addCriterion("attachment_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andAttachmentIdIsNotNull() {
+            addCriterion("attachment_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andAttachmentIdEqualTo(Long value) {
+            addCriterion("attachment_id =", value, "attachmentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andAttachmentIdNotEqualTo(Long value) {
+            addCriterion("attachment_id <>", value, "attachmentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andAttachmentIdGreaterThan(Long value) {
+            addCriterion("attachment_id >", value, "attachmentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andAttachmentIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("attachment_id >=", value, "attachmentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andAttachmentIdLessThan(Long value) {
+            addCriterion("attachment_id <", value, "attachmentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andAttachmentIdLessThanOrEqualTo(Long value) {
+            addCriterion("attachment_id <=", value, "attachmentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andAttachmentIdIn(List<Long> values) {
+            addCriterion("attachment_id in", values, "attachmentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andAttachmentIdNotIn(List<Long> values) {
+            addCriterion("attachment_id not in", values, "attachmentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andAttachmentIdBetween(Long value1, Long value2) {
+            addCriterion("attachment_id between", value1, value2, "attachmentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andAttachmentIdNotBetween(Long value1, Long value2) {
+            addCriterion("attachment_id not between", value1, value2, "attachmentId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgResultIdIsNull() {
+            addCriterion("msg_result_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgResultIdIsNotNull() {
+            addCriterion("msg_result_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgResultIdEqualTo(Long value) {
+            addCriterion("msg_result_id =", value, "msgResultId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgResultIdNotEqualTo(Long value) {
+            addCriterion("msg_result_id <>", value, "msgResultId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgResultIdGreaterThan(Long value) {
+            addCriterion("msg_result_id >", value, "msgResultId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgResultIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("msg_result_id >=", value, "msgResultId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgResultIdLessThan(Long value) {
+            addCriterion("msg_result_id <", value, "msgResultId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgResultIdLessThanOrEqualTo(Long value) {
+            addCriterion("msg_result_id <=", value, "msgResultId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgResultIdIn(List<Long> values) {
+            addCriterion("msg_result_id in", values, "msgResultId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgResultIdNotIn(List<Long> values) {
+            addCriterion("msg_result_id not in", values, "msgResultId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgResultIdBetween(Long value1, Long value2) {
+            addCriterion("msg_result_id between", value1, value2, "msgResultId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMsgResultIdNotBetween(Long value1, Long value2) {
+            addCriterion("msg_result_id not between", value1, value2, "msgResultId");
+            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);
+        }
+    }
+}

+ 22 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/model/po/MessageAttachment.java

@@ -11,10 +11,14 @@ public class MessageAttachment {
 
     private String url;
 
+    private String picUrl;
+
     private String title;
 
     private String desc;
 
+    private String mediaId;
+
     private String appid;
 
     private String page;
@@ -63,6 +67,14 @@ public class MessageAttachment {
         this.url = url;
     }
 
+    public String getPicUrl() {
+        return picUrl;
+    }
+
+    public void setPicUrl(String picUrl) {
+        this.picUrl = picUrl;
+    }
+
     public String getTitle() {
         return title;
     }
@@ -79,6 +91,14 @@ public class MessageAttachment {
         this.desc = desc;
     }
 
+    public String getMediaId() {
+        return mediaId;
+    }
+
+    public void setMediaId(String mediaId) {
+        this.mediaId = mediaId;
+    }
+
     public String getAppid() {
         return appid;
     }
@@ -153,8 +173,10 @@ public class MessageAttachment {
         sb.append(", staffId=").append(staffId);
         sb.append(", type=").append(type);
         sb.append(", url=").append(url);
+        sb.append(", picUrl=").append(picUrl);
         sb.append(", title=").append(title);
         sb.append(", desc=").append(desc);
+        sb.append(", mediaId=").append(mediaId);
         sb.append(", appid=").append(appid);
         sb.append(", page=").append(page);
         sb.append(", cover=").append(cover);

+ 140 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/model/po/MessageAttachmentExample.java

@@ -367,6 +367,76 @@ public class MessageAttachmentExample {
             return (Criteria) this;
         }
 
+        public Criteria andPicUrlIsNull() {
+            addCriterion("pic_url is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andPicUrlIsNotNull() {
+            addCriterion("pic_url is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andPicUrlEqualTo(String value) {
+            addCriterion("pic_url =", value, "picUrl");
+            return (Criteria) this;
+        }
+
+        public Criteria andPicUrlNotEqualTo(String value) {
+            addCriterion("pic_url <>", value, "picUrl");
+            return (Criteria) this;
+        }
+
+        public Criteria andPicUrlGreaterThan(String value) {
+            addCriterion("pic_url >", value, "picUrl");
+            return (Criteria) this;
+        }
+
+        public Criteria andPicUrlGreaterThanOrEqualTo(String value) {
+            addCriterion("pic_url >=", value, "picUrl");
+            return (Criteria) this;
+        }
+
+        public Criteria andPicUrlLessThan(String value) {
+            addCriterion("pic_url <", value, "picUrl");
+            return (Criteria) this;
+        }
+
+        public Criteria andPicUrlLessThanOrEqualTo(String value) {
+            addCriterion("pic_url <=", value, "picUrl");
+            return (Criteria) this;
+        }
+
+        public Criteria andPicUrlLike(String value) {
+            addCriterion("pic_url like", value, "picUrl");
+            return (Criteria) this;
+        }
+
+        public Criteria andPicUrlNotLike(String value) {
+            addCriterion("pic_url not like", value, "picUrl");
+            return (Criteria) this;
+        }
+
+        public Criteria andPicUrlIn(List<String> values) {
+            addCriterion("pic_url in", values, "picUrl");
+            return (Criteria) this;
+        }
+
+        public Criteria andPicUrlNotIn(List<String> values) {
+            addCriterion("pic_url not in", values, "picUrl");
+            return (Criteria) this;
+        }
+
+        public Criteria andPicUrlBetween(String value1, String value2) {
+            addCriterion("pic_url between", value1, value2, "picUrl");
+            return (Criteria) this;
+        }
+
+        public Criteria andPicUrlNotBetween(String value1, String value2) {
+            addCriterion("pic_url not between", value1, value2, "picUrl");
+            return (Criteria) this;
+        }
+
         public Criteria andTitleIsNull() {
             addCriterion("title is null");
             return (Criteria) this;
@@ -507,6 +577,76 @@ public class MessageAttachmentExample {
             return (Criteria) this;
         }
 
+        public Criteria andMediaIdIsNull() {
+            addCriterion("media_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andMediaIdIsNotNull() {
+            addCriterion("media_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andMediaIdEqualTo(String value) {
+            addCriterion("media_id =", value, "mediaId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMediaIdNotEqualTo(String value) {
+            addCriterion("media_id <>", value, "mediaId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMediaIdGreaterThan(String value) {
+            addCriterion("media_id >", value, "mediaId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMediaIdGreaterThanOrEqualTo(String value) {
+            addCriterion("media_id >=", value, "mediaId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMediaIdLessThan(String value) {
+            addCriterion("media_id <", value, "mediaId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMediaIdLessThanOrEqualTo(String value) {
+            addCriterion("media_id <=", value, "mediaId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMediaIdLike(String value) {
+            addCriterion("media_id like", value, "mediaId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMediaIdNotLike(String value) {
+            addCriterion("media_id not like", value, "mediaId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMediaIdIn(List<String> values) {
+            addCriterion("media_id in", values, "mediaId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMediaIdNotIn(List<String> values) {
+            addCriterion("media_id not in", values, "mediaId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMediaIdBetween(String value1, String value2) {
+            addCriterion("media_id between", value1, value2, "mediaId");
+            return (Criteria) this;
+        }
+
+        public Criteria andMediaIdNotBetween(String value1, String value2) {
+            addCriterion("media_id not between", value1, value2, "mediaId");
+            return (Criteria) this;
+        }
+
         public Criteria andAppidIsNull() {
             addCriterion("appid is null");
             return (Criteria) this;

+ 11 - 0
common-module/src/main/java/com/tzld/piaoquan/growth/common/model/po/SendMsgResult.java

@@ -21,6 +21,8 @@ public class SendMsgResult {
 
     private Date updateTime;
 
+    private String textContent;
+
     public Long getId() {
         return id;
     }
@@ -93,6 +95,14 @@ public class SendMsgResult {
         this.updateTime = updateTime;
     }
 
+    public String getTextContent() {
+        return textContent;
+    }
+
+    public void setTextContent(String textContent) {
+        this.textContent = textContent;
+    }
+
     @Override
     public String toString() {
         StringBuilder sb = new StringBuilder();
@@ -108,6 +118,7 @@ public class SendMsgResult {
         sb.append(", isDelete=").append(isDelete);
         sb.append(", createTime=").append(createTime);
         sb.append(", updateTime=").append(updateTime);
+        sb.append(", textContent=").append(textContent);
         sb.append("]");
         return sb.toString();
     }

+ 35 - 13
common-module/src/main/java/com/tzld/piaoquan/growth/common/service/Impl/MessageAttachmentServiceImpl.java

@@ -63,25 +63,47 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
     private GuaranteesVideoMapper guaranteesVideoMapper;
 
     @Override
-    public void addMiniProgram(List<MessageAttachment> messageAttachmentList, Long createTime) {
+    public List<Long> addMessageAttachment(List<MessageAttachment> messageAttachmentList, Long createTime) {
+        List<Long> messageAttachmentIds = new ArrayList<>();
         for (MessageAttachment messageAttachment : messageAttachmentList) {
             MessageAttachmentExample example = new MessageAttachmentExample();
-            example.createCriteria()
-                    .andAppidEqualTo(messageAttachment.getAppid())
-                    .andTypeEqualTo(messageAttachment.getType())
-                    .andMiniprogramVideoIdEqualTo(messageAttachment.getMiniprogramVideoId())
-                    .andStaffIdEqualTo(messageAttachment.getStaffId());
+            if (messageAttachment.getType().equals(MessageAttachmentTypeEnum.IMAGE.getCode())) {
+                example.createCriteria()
+                        .andTypeEqualTo(messageAttachment.getType())
+                        .andMediaIdEqualTo(messageAttachment.getMediaId())
+                        .andPicUrlEqualTo(messageAttachment.getPicUrl());
+            }
+            if (messageAttachment.getType().equals(MessageAttachmentTypeEnum.MINI_PROGRAM.getCode())) {
+                example.createCriteria()
+                        .andTypeEqualTo(messageAttachment.getType())
+                        .andAppidEqualTo(messageAttachment.getAppid())
+                        .andMiniprogramVideoIdEqualTo(messageAttachment.getMiniprogramVideoId())
+                        .andStaffIdEqualTo(messageAttachment.getStaffId());
+            }
+
+            if (messageAttachment.getType().equals(MessageAttachmentTypeEnum.LINK.getCode())) {
+                example.createCriteria()
+                        .andTypeEqualTo(messageAttachment.getType())
+                        .andTitleEqualTo(messageAttachment.getTitle())
+                        .andPicUrlEqualTo(messageAttachment.getPicUrl())
+                        .andDescEqualTo(messageAttachment.getDesc())
+                        .andUrlEqualTo(messageAttachment.getUrl());
+            }
+
             List<MessageAttachment> messageAttachments = messageAttachmentMapper.selectByExample(example);
             if (CollectionUtils.isEmpty(messageAttachments)) {
-                if (createTime != null) {
+                if (messageAttachment.getType().equals(MessageAttachmentTypeEnum.MINI_PROGRAM.getCode()) &&
+                        createTime != null) {
                     messageAttachment.setSendTime(new Date(createTime));
                 }
-                messageAttachmentMapper.insert(messageAttachment);
-                continue;
+                messageAttachmentMapper.insertSelective(messageAttachment);
+            } else {
+                messageAttachment.setId(messageAttachments.get(0).getId());
+                messageAttachmentMapper.updateByPrimaryKeySelective(messageAttachment);
             }
-            messageAttachment.setId(messageAttachments.get(0).getId());
-            messageAttachmentMapper.updateByPrimaryKeySelective(messageAttachment);
+            messageAttachmentIds.add(messageAttachment.getId());
         }
+        return messageAttachmentIds;
     }
 
 
@@ -103,7 +125,7 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
             addMessageAttachments(videoParam, messageAttachmentMap, guaranteedParam.getDate(), messageAttachmentList);
         }
 
-        addMiniProgram(messageAttachmentList, null);
+        addMessageAttachment(messageAttachmentList, null);
         return CommonResponse.success();
     }
 
@@ -158,7 +180,7 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
             }
             MessageAttachment messageAttachment = new MessageAttachment();
             messageAttachment.setMiniprogramVideoId(videoId);
-            messageAttachment.setType(MessageAttachmentTypeEnum.MINI_PROGRAM.getType());
+            messageAttachment.setType(MessageAttachmentTypeEnum.MINI_PROGRAM.getCode());
             messageAttachment.setCover(videoDetail.getCover());
             messageAttachment.setTitle(videoDetail.getTitle());
             messageAttachment.setAppid(appid);

+ 1 - 1
common-module/src/main/java/com/tzld/piaoquan/growth/common/service/MessageAttachmentService.java

@@ -9,7 +9,7 @@ import java.util.List;
 
 public interface MessageAttachmentService {
 
-    void addMiniProgram(List<MessageAttachment> messageAttachmentList, Long createTime);
+    List<Long> addMessageAttachment(List<MessageAttachment> messageAttachmentList, Long createTime);
 
     CommonResponse<Void> createGuaranteedMiniProgram(GuaranteedParam guaranteedParam);
 

+ 214 - 0
common-module/src/main/resources/mapper/AttachmentWithMsgResultMapper.xml

@@ -0,0 +1,214 @@
+<?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.growth.common.dao.mapper.AttachmentWithMsgResultMapper">
+  <resultMap id="BaseResultMap" type="com.tzld.piaoquan.growth.common.model.po.AttachmentWithMsgResult">
+    <id column="id" jdbcType="BIGINT" property="id" />
+    <result column="attachment_id" jdbcType="BIGINT" property="attachmentId" />
+    <result column="msg_result_id" jdbcType="BIGINT" property="msgResultId" />
+    <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, attachment_id, msg_result_id, create_time, update_time
+  </sql>
+  <select id="selectByExample" parameterType="com.tzld.piaoquan.growth.common.model.po.AttachmentWithMsgResultExample" resultMap="BaseResultMap">
+    select
+    <if test="distinct">
+      distinct
+    </if>
+    <include refid="Base_Column_List" />
+    from we_com_attachment_with_msg_result
+    <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_attachment_with_msg_result
+    where id = #{id,jdbcType=BIGINT}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+    delete from we_com_attachment_with_msg_result
+    where id = #{id,jdbcType=BIGINT}
+  </delete>
+  <delete id="deleteByExample" parameterType="com.tzld.piaoquan.growth.common.model.po.AttachmentWithMsgResultExample">
+    delete from we_com_attachment_with_msg_result
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </delete>
+  <insert id="insert" parameterType="com.tzld.piaoquan.growth.common.model.po.AttachmentWithMsgResult">
+    insert into we_com_attachment_with_msg_result (id, attachment_id, msg_result_id, 
+      create_time, update_time)
+    values (#{id,jdbcType=BIGINT}, #{attachmentId,jdbcType=BIGINT}, #{msgResultId,jdbcType=BIGINT}, 
+      #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
+  </insert>
+  <insert id="insertSelective" parameterType="com.tzld.piaoquan.growth.common.model.po.AttachmentWithMsgResult">
+    insert into we_com_attachment_with_msg_result
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <if test="attachmentId != null">
+        attachment_id,
+      </if>
+      <if test="msgResultId != null">
+        msg_result_id,
+      </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="attachmentId != null">
+        #{attachmentId,jdbcType=BIGINT},
+      </if>
+      <if test="msgResultId != null">
+        #{msgResultId,jdbcType=BIGINT},
+      </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.growth.common.model.po.AttachmentWithMsgResultExample" resultType="java.lang.Long">
+    select count(*) from we_com_attachment_with_msg_result
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </select>
+  <update id="updateByExampleSelective" parameterType="map">
+    update we_com_attachment_with_msg_result
+    <set>
+      <if test="record.id != null">
+        id = #{record.id,jdbcType=BIGINT},
+      </if>
+      <if test="record.attachmentId != null">
+        attachment_id = #{record.attachmentId,jdbcType=BIGINT},
+      </if>
+      <if test="record.msgResultId != null">
+        msg_result_id = #{record.msgResultId,jdbcType=BIGINT},
+      </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_attachment_with_msg_result
+    set id = #{record.id,jdbcType=BIGINT},
+      attachment_id = #{record.attachmentId,jdbcType=BIGINT},
+      msg_result_id = #{record.msgResultId,jdbcType=BIGINT},
+      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.growth.common.model.po.AttachmentWithMsgResult">
+    update we_com_attachment_with_msg_result
+    <set>
+      <if test="attachmentId != null">
+        attachment_id = #{attachmentId,jdbcType=BIGINT},
+      </if>
+      <if test="msgResultId != null">
+        msg_result_id = #{msgResultId,jdbcType=BIGINT},
+      </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.growth.common.model.po.AttachmentWithMsgResult">
+    update we_com_attachment_with_msg_result
+    set attachment_id = #{attachmentId,jdbcType=BIGINT},
+      msg_result_id = #{msgResultId,jdbcType=BIGINT},
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      update_time = #{updateTime,jdbcType=TIMESTAMP}
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+</mapper>

+ 42 - 7
common-module/src/main/resources/mapper/MessageAttachmentMapper.xml

@@ -6,8 +6,10 @@
     <result column="staff_id" jdbcType="BIGINT" property="staffId" />
     <result column="type" jdbcType="INTEGER" property="type" />
     <result column="url" jdbcType="VARCHAR" property="url" />
+    <result column="pic_url" jdbcType="VARCHAR" property="picUrl" />
     <result column="title" jdbcType="VARCHAR" property="title" />
     <result column="desc" jdbcType="VARCHAR" property="desc" />
+    <result column="media_id" jdbcType="VARCHAR" property="mediaId" />
     <result column="appid" jdbcType="VARCHAR" property="appid" />
     <result column="page" jdbcType="VARCHAR" property="page" />
     <result column="cover" jdbcType="VARCHAR" property="cover" />
@@ -76,8 +78,8 @@
     </where>
   </sql>
   <sql id="Base_Column_List">
-    id, staff_id, `type`, url, title, `desc`, appid, page, cover, miniprogram_video_id, 
-    is_delete, send_time, create_time, update_time
+    id, staff_id, `type`, url, pic_url, title, `desc`, media_id, appid, page, cover, 
+    miniprogram_video_id, is_delete, send_time, create_time, update_time
   </sql>
   <select id="selectByExample" parameterType="com.tzld.piaoquan.growth.common.model.po.MessageAttachmentExample" resultMap="BaseResultMap">
     select
@@ -114,17 +116,19 @@
   </delete>
   <insert id="insert" parameterType="com.tzld.piaoquan.growth.common.model.po.MessageAttachment">
     insert into we_com_message_attachment (id, staff_id, `type`, 
-      url, title, `desc`, appid, 
+      url, pic_url, title, 
+      `desc`, media_id, appid, 
       page, cover, miniprogram_video_id, 
-      send_time, create_time,
+      is_delete, send_time, create_time, 
       update_time)
     values (#{id,jdbcType=BIGINT}, #{staffId,jdbcType=BIGINT}, #{type,jdbcType=INTEGER}, 
-      #{url,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR}, #{desc,jdbcType=VARCHAR}, #{appid,jdbcType=VARCHAR}, 
+      #{url,jdbcType=VARCHAR}, #{picUrl,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR}, 
+      #{desc,jdbcType=VARCHAR}, #{mediaId,jdbcType=VARCHAR}, #{appid,jdbcType=VARCHAR}, 
       #{page,jdbcType=VARCHAR}, #{cover,jdbcType=VARCHAR}, #{miniprogramVideoId,jdbcType=BIGINT}, 
-      #{sendTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP},
+      #{isDelete,jdbcType=INTEGER}, #{sendTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP}, 
       #{updateTime,jdbcType=TIMESTAMP})
   </insert>
-  <insert id="insertSelective" parameterType="com.tzld.piaoquan.growth.common.model.po.MessageAttachment">
+  <insert id="insertSelective" parameterType="com.tzld.piaoquan.growth.common.model.po.MessageAttachment" useGeneratedKeys="true" keyProperty="id">
     insert into we_com_message_attachment
     <trim prefix="(" suffix=")" suffixOverrides=",">
       <if test="id != null">
@@ -139,12 +143,18 @@
       <if test="url != null">
         url,
       </if>
+      <if test="picUrl != null">
+        pic_url,
+      </if>
       <if test="title != null">
         title,
       </if>
       <if test="desc != null">
         `desc`,
       </if>
+      <if test="mediaId != null">
+        media_id,
+      </if>
       <if test="appid != null">
         appid,
       </if>
@@ -183,12 +193,18 @@
       <if test="url != null">
         #{url,jdbcType=VARCHAR},
       </if>
+      <if test="picUrl != null">
+        #{picUrl,jdbcType=VARCHAR},
+      </if>
       <if test="title != null">
         #{title,jdbcType=VARCHAR},
       </if>
       <if test="desc != null">
         #{desc,jdbcType=VARCHAR},
       </if>
+      <if test="mediaId != null">
+        #{mediaId,jdbcType=VARCHAR},
+      </if>
       <if test="appid != null">
         #{appid,jdbcType=VARCHAR},
       </if>
@@ -214,6 +230,9 @@
         #{updateTime,jdbcType=TIMESTAMP},
       </if>
     </trim>
+    <selectKey resultType="java.lang.Long" order="AFTER" keyProperty="id">
+      select LAST_INSERT_ID()
+    </selectKey>
   </insert>
   <select id="countByExample" parameterType="com.tzld.piaoquan.growth.common.model.po.MessageAttachmentExample" resultType="java.lang.Long">
     select count(*) from we_com_message_attachment
@@ -236,12 +255,18 @@
       <if test="record.url != null">
         url = #{record.url,jdbcType=VARCHAR},
       </if>
+      <if test="record.picUrl != null">
+        pic_url = #{record.picUrl,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.mediaId != null">
+        media_id = #{record.mediaId,jdbcType=VARCHAR},
+      </if>
       <if test="record.appid != null">
         appid = #{record.appid,jdbcType=VARCHAR},
       </if>
@@ -277,8 +302,10 @@
       staff_id = #{record.staffId,jdbcType=BIGINT},
       `type` = #{record.type,jdbcType=INTEGER},
       url = #{record.url,jdbcType=VARCHAR},
+      pic_url = #{record.picUrl,jdbcType=VARCHAR},
       title = #{record.title,jdbcType=VARCHAR},
       `desc` = #{record.desc,jdbcType=VARCHAR},
+      media_id = #{record.mediaId,jdbcType=VARCHAR},
       appid = #{record.appid,jdbcType=VARCHAR},
       page = #{record.page,jdbcType=VARCHAR},
       cover = #{record.cover,jdbcType=VARCHAR},
@@ -303,12 +330,18 @@
       <if test="url != null">
         url = #{url,jdbcType=VARCHAR},
       </if>
+      <if test="picUrl != null">
+        pic_url = #{picUrl,jdbcType=VARCHAR},
+      </if>
       <if test="title != null">
         title = #{title,jdbcType=VARCHAR},
       </if>
       <if test="desc != null">
         `desc` = #{desc,jdbcType=VARCHAR},
       </if>
+      <if test="mediaId != null">
+        media_id = #{mediaId,jdbcType=VARCHAR},
+      </if>
       <if test="appid != null">
         appid = #{appid,jdbcType=VARCHAR},
       </if>
@@ -341,8 +374,10 @@
     set staff_id = #{staffId,jdbcType=BIGINT},
       `type` = #{type,jdbcType=INTEGER},
       url = #{url,jdbcType=VARCHAR},
+      pic_url = #{picUrl,jdbcType=VARCHAR},
       title = #{title,jdbcType=VARCHAR},
       `desc` = #{desc,jdbcType=VARCHAR},
+      media_id = #{mediaId,jdbcType=VARCHAR},
       appid = #{appid,jdbcType=VARCHAR},
       page = #{page,jdbcType=VARCHAR},
       cover = #{cover,jdbcType=VARCHAR},

+ 77 - 6
common-module/src/main/resources/mapper/SendMsgResultMapper.xml

@@ -12,6 +12,9 @@
     <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
     <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
   </resultMap>
+  <resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="com.tzld.piaoquan.growth.common.model.po.SendMsgResult">
+    <result column="text_content" jdbcType="LONGVARCHAR" property="textContent" />
+  </resultMap>
   <sql id="Example_Where_Clause">
     <where>
       <foreach collection="oredCriteria" item="criteria" separator="or">
@@ -73,6 +76,28 @@
   <sql id="Base_Column_List">
     id, msg_id, user_id, staff_id, `status`, send_time, is_delete, create_time, update_time
   </sql>
+  <sql id="Blob_Column_List">
+    text_content
+  </sql>
+  <select id="selectByExampleWithBLOBs" parameterType="com.tzld.piaoquan.growth.common.model.po.SendMsgResultExample" resultMap="ResultMapWithBLOBs">
+    select
+    <if test="distinct">
+      distinct
+    </if>
+    <include refid="Base_Column_List" />
+    ,
+    <include refid="Blob_Column_List" />
+    from we_com_send_msg_result
+    <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="selectByExample" parameterType="com.tzld.piaoquan.growth.common.model.po.SendMsgResultExample" resultMap="BaseResultMap">
     select
     <if test="distinct">
@@ -90,9 +115,11 @@
       limit #{page.offset} , #{page.pageSize}
     </if>
   </select>
-  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
+  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="ResultMapWithBLOBs">
     select 
     <include refid="Base_Column_List" />
+    ,
+    <include refid="Blob_Column_List" />
     from we_com_send_msg_result
     where id = #{id,jdbcType=BIGINT}
   </select>
@@ -109,14 +136,14 @@
   <insert id="insert" parameterType="com.tzld.piaoquan.growth.common.model.po.SendMsgResult">
     insert into we_com_send_msg_result (id, msg_id, user_id, 
       staff_id, `status`, send_time, 
-      is_delete, create_time, update_time
-      )
+      is_delete, create_time, update_time, 
+      text_content)
     values (#{id,jdbcType=BIGINT}, #{msgId,jdbcType=VARCHAR}, #{userId,jdbcType=BIGINT}, 
       #{staffId,jdbcType=BIGINT}, #{status,jdbcType=INTEGER}, #{sendTime,jdbcType=TIMESTAMP}, 
-      #{isDelete,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}
-      )
+      #{isDelete,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, 
+      #{textContent,jdbcType=LONGVARCHAR})
   </insert>
-  <insert id="insertSelective" parameterType="com.tzld.piaoquan.growth.common.model.po.SendMsgResult">
+  <insert id="insertSelective" parameterType="com.tzld.piaoquan.growth.common.model.po.SendMsgResult" useGeneratedKeys="true" keyProperty="id">
     insert into we_com_send_msg_result
     <trim prefix="(" suffix=")" suffixOverrides=",">
       <if test="id != null">
@@ -146,6 +173,9 @@
       <if test="updateTime != null">
         update_time,
       </if>
+      <if test="textContent != null">
+        text_content,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="id != null">
@@ -175,7 +205,13 @@
       <if test="updateTime != null">
         #{updateTime,jdbcType=TIMESTAMP},
       </if>
+      <if test="textContent != null">
+        #{textContent,jdbcType=LONGVARCHAR},
+      </if>
     </trim>
+    <selectKey resultType="java.lang.Long" order="AFTER" keyProperty="id">
+      select LAST_INSERT_ID()
+    </selectKey>
   </insert>
   <select id="countByExample" parameterType="com.tzld.piaoquan.growth.common.model.po.SendMsgResultExample" resultType="java.lang.Long">
     select count(*) from we_com_send_msg_result
@@ -213,11 +249,30 @@
       <if test="record.updateTime != null">
         update_time = #{record.updateTime,jdbcType=TIMESTAMP},
       </if>
+      <if test="record.textContent != null">
+        text_content = #{record.textContent,jdbcType=LONGVARCHAR},
+      </if>
     </set>
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
     </if>
   </update>
+  <update id="updateByExampleWithBLOBs" parameterType="map">
+    update we_com_send_msg_result
+    set id = #{record.id,jdbcType=BIGINT},
+      msg_id = #{record.msgId,jdbcType=VARCHAR},
+      user_id = #{record.userId,jdbcType=BIGINT},
+      staff_id = #{record.staffId,jdbcType=BIGINT},
+      `status` = #{record.status,jdbcType=INTEGER},
+      send_time = #{record.sendTime,jdbcType=TIMESTAMP},
+      is_delete = #{record.isDelete,jdbcType=INTEGER},
+      create_time = #{record.createTime,jdbcType=TIMESTAMP},
+      update_time = #{record.updateTime,jdbcType=TIMESTAMP},
+      text_content = #{record.textContent,jdbcType=LONGVARCHAR}
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
   <update id="updateByExample" parameterType="map">
     update we_com_send_msg_result
     set id = #{record.id,jdbcType=BIGINT},
@@ -260,9 +315,25 @@
       <if test="updateTime != null">
         update_time = #{updateTime,jdbcType=TIMESTAMP},
       </if>
+      <if test="textContent != null">
+        text_content = #{textContent,jdbcType=LONGVARCHAR},
+      </if>
     </set>
     where id = #{id,jdbcType=BIGINT}
   </update>
+  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.tzld.piaoquan.growth.common.model.po.SendMsgResult">
+    update we_com_send_msg_result
+    set msg_id = #{msgId,jdbcType=VARCHAR},
+      user_id = #{userId,jdbcType=BIGINT},
+      staff_id = #{staffId,jdbcType=BIGINT},
+      `status` = #{status,jdbcType=INTEGER},
+      send_time = #{sendTime,jdbcType=TIMESTAMP},
+      is_delete = #{isDelete,jdbcType=INTEGER},
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      update_time = #{updateTime,jdbcType=TIMESTAMP},
+      text_content = #{textContent,jdbcType=LONGVARCHAR}
+    where id = #{id,jdbcType=BIGINT}
+  </update>
   <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.growth.common.model.po.SendMsgResult">
     update we_com_send_msg_result
     set msg_id = #{msgId,jdbcType=VARCHAR},

+ 87 - 23
offline-module/src/main/java/com/tzld/piaoquan/offline/job/WeComHistoryDataJob.java

@@ -77,6 +77,9 @@ public class WeComHistoryDataJob {
     @Autowired
     private SendMsgResultMapper sendMsgResultMapper;
 
+    @Autowired
+    private AttachmentWithMsgResultMapper attachmentWithMsgResultMapper;
+
 
     @XxlJob("saveHistoryMessageJob")
     public ReturnT<String> selectHistoryMessageByDay(String param) {
@@ -193,35 +196,66 @@ public class WeComHistoryDataJob {
                     JSONObject groupMsg = groupMsgList.getJSONObject(i);
                     JSONArray attachments = groupMsg.getJSONArray("attachments");
                     String msgId = groupMsg.getString("msgid");
+                    String textContent = Optional.ofNullable(groupMsg.getJSONObject("text"))
+                            .map(textObj -> textObj.getString("content"))
+                            .orElse(null);
                     Long createTime = null;
                     if (groupMsg.getLong("create_time") != null) {
                         createTime = groupMsg.getLong("create_time") * 1000;
                     }
+
                     List<MiniprogramRecord> miniprogramRecordList = new ArrayList<>();
                     List<MessageAttachment> messageAttachmentList = new ArrayList<>();
                     if (!CollectionUtils.isEmpty(attachments)) {
                         for (int j = 0; j < attachments.size(); j++) {
-                            JSONObject miniprogram = attachments.getJSONObject(j).getJSONObject("miniprogram");
-                            if (miniprogram == null) {
-                                continue;
-                            }
-                            MiniprogramRecord miniprogramRecord = new MiniprogramRecord();
                             MessageAttachment messageAttachment = new MessageAttachment();
-                            String title = miniprogram.getString("title");
-                            String appid = miniprogram.getString("appid");
-                            String page = miniprogram.getString("page");
-                            Long videoId = MessageUtil.getVideoId(page);
-
-                            miniprogramRecord.setVideoId(videoId);
-                            miniprogramRecord.setAttachmentIdx(j + 1);
-                            miniprogramRecordList.add(miniprogramRecord);
-
-                            messageAttachment.setAppid(appid);
-                            messageAttachment.setPage(page);
-                            messageAttachment.setTitle(title);
-                            messageAttachment.setMiniprogramVideoId(videoId);
-                            messageAttachment.setType(MessageAttachmentTypeEnum.MINI_PROGRAM.getType());
-                            messageAttachmentList.add(messageAttachment);
+                            String msgtype = attachments.getJSONObject(j).getString("msgtype");
+                            if (Objects.equals(MessageAttachmentTypeEnum.IMAGE.getType(), msgtype)) {
+                                JSONObject image = attachments.getJSONObject(j)
+                                        .getJSONObject(MessageAttachmentTypeEnum.IMAGE.getType());
+                                messageAttachment.setMediaId(image.getString("media_id"));
+                                messageAttachment.setPicUrl(image.getString("pic_url"));
+                                messageAttachment.setType(MessageAttachmentTypeEnum.MINI_PROGRAM.getCode());
+                                messageAttachmentList.add(messageAttachment);
+                            }
+
+                            if (Objects.equals(MessageAttachmentTypeEnum.LINK.getType(), msgtype)) {
+                                JSONObject link = attachments.getJSONObject(j)
+                                        .getJSONObject(MessageAttachmentTypeEnum.LINK.getType());
+
+                                messageAttachment.setTitle(link.getString("title"));
+                                messageAttachment.setPicUrl(link.getString("picurl"));
+                                messageAttachment.setDesc(link.getString("desc"));
+                                messageAttachment.setUrl(link.getString("url"));
+                                messageAttachment.setType(MessageAttachmentTypeEnum.MINI_PROGRAM.getCode());
+                                messageAttachmentList.add(messageAttachment);
+
+                            }
+
+                            if (Objects.equals(MessageAttachmentTypeEnum.MINI_PROGRAM.getType(), msgtype)) {
+                                JSONObject miniprogram = attachments.getJSONObject(j)
+                                        .getJSONObject(MessageAttachmentTypeEnum.MINI_PROGRAM.getType());
+                                if (miniprogram == null) {
+                                    continue;
+                                }
+                                MiniprogramRecord miniprogramRecord = new MiniprogramRecord();
+
+                                String title = miniprogram.getString("title");
+                                String appid = miniprogram.getString("appid");
+                                String page = miniprogram.getString("page");
+                                Long videoId = MessageUtil.getVideoId(page);
+
+                                miniprogramRecord.setVideoId(videoId);
+                                miniprogramRecord.setAttachmentIdx(j + 1);
+                                miniprogramRecordList.add(miniprogramRecord);
+
+                                messageAttachment.setAppid(appid);
+                                messageAttachment.setPage(page);
+                                messageAttachment.setTitle(title);
+                                messageAttachment.setMiniprogramVideoId(videoId);
+                                messageAttachment.setType(MessageAttachmentTypeEnum.MINI_PROGRAM.getCode());
+                                messageAttachmentList.add(messageAttachment);
+                            }
                         }
                     }
                     List<String> carrierIdList = selectGroupMsgTask(msgId, corpId);
@@ -246,13 +280,16 @@ public class WeComHistoryDataJob {
                         if (CollectionUtils.isEmpty(externalUsers)) {
                             continue;
                         }
+                        List<Long> attachmentIds = new ArrayList<>();
                         if (!CollectionUtils.isEmpty(messageAttachmentList)) {
                             for (MessageAttachment messageAttachment : messageAttachmentList) {
                                 messageAttachment.setStaffId(staffList.get(0).getId());
                             }
-                            messageAttachmentService.addMiniProgram(messageAttachmentList, createTime);
+                            attachmentIds = messageAttachmentService
+                                    .addMessageAttachment(messageAttachmentList, createTime);
                         }
-                        insertHistoryMessageList(msgId, staffList.get(0), externalUsers, miniprogramRecordList, createTime, corpId, startTime, endTime);
+                        insertHistoryMessageList(msgId, staffList.get(0), externalUsers, miniprogramRecordList,
+                                createTime, corpId, startTime, endTime, attachmentIds);
                     }
                 }
                 String nextCursor = jsonObject.getString("next_cursor");
@@ -369,7 +406,7 @@ public class WeComHistoryDataJob {
 
     private void insertHistoryMessageList(String msgId, Staff staff, List<ExternalUser> externalUsers,
                                           List<MiniprogramRecord> miniprogramRecordList,
-                                          Long createTime, Long corpId, Long startTime, Long endTime) {
+                                          Long createTime, Long corpId, Long startTime, Long endTime, List<Long> attachmentIds) {
         if (CollectionUtils.isEmpty(externalUsers)) {
             return;
         }
@@ -384,6 +421,7 @@ public class WeComHistoryDataJob {
         Long sendTime = externalUsers.stream()
                 .map(ExternalUser::getSendTime).filter(Objects::nonNull).findFirst().orElse(null);
         List<HistoryMessage> historyMessageList = new ArrayList<>();
+        List<Long> sendMsgResultIds = new ArrayList<>();
         for (ExternalUser externalUser : externalUsers) {
             Long userId = weComUserMapper.selectIdByExternalUserId(externalUser.getExternalUserId());
             if (userId == null) {
@@ -406,6 +444,7 @@ public class WeComHistoryDataJob {
                 }
                 sendMsgResult.setStatus(status);
                 sendMsgResultMapper.insertSelective(sendMsgResult);
+                sendMsgResultIds.add(sendMsgResult.getId());
             } else {
                 SendMsgResult sendMsgResult = sendMsgResults.get(0);
                 if (sendTime != null) {
@@ -413,6 +452,7 @@ public class WeComHistoryDataJob {
                 }
                 sendMsgResult.setStatus(status);
                 sendMsgResultMapper.updateByPrimaryKeySelective(sendMsgResult);
+                sendMsgResultIds.add(sendMsgResult.getId());
             }
             //小程序发送历史
             if (!CollectionUtils.isEmpty(miniprogramRecordList)) {
@@ -444,6 +484,30 @@ public class WeComHistoryDataJob {
             }
         }
         historyMessageService.batchInsertHistoryMessage(historyMessageList);
+        insertAttachmentWithMsgResult(attachmentIds, sendMsgResultIds);
+    }
+
+    private void insertAttachmentWithMsgResult(List<Long> attachmentIds, List<Long> sendMsgResultIds) {
+        if (CollectionUtils.isEmpty(attachmentIds) || CollectionUtils.isEmpty(sendMsgResultIds)) {
+            return;
+        }
+        for (Long attachmentId : attachmentIds) {
+            for (Long sendMsgResultId : sendMsgResultIds) {
+                AttachmentWithMsgResultExample example = new AttachmentWithMsgResultExample();
+                example.createCriteria().andAttachmentIdEqualTo(attachmentId).andMsgResultIdEqualTo(sendMsgResultId);
+                long l = attachmentWithMsgResultMapper.countByExample(example);
+                if (l == 0) {
+                    try {
+                        AttachmentWithMsgResult attachmentWithMsgResult = new AttachmentWithMsgResult();
+                        attachmentWithMsgResult.setAttachmentId(attachmentId);
+                        attachmentWithMsgResult.setMsgResultId(sendMsgResultId);
+                        attachmentWithMsgResultMapper.insertSelective(attachmentWithMsgResult);
+                    } catch (Exception e) {
+                        log.error("insert error", e);
+                    }
+                }
+            }
+        }
     }
 
     private String getGroupMsgList(Long startTime, Long endTime, String cursor, Long corpId) throws IOException {