Kaynağa Gözat

更新用户

xueyiming 8 ay önce
ebeveyn
işleme
20e671e17b
18 değiştirilmiş dosya ile 1049 ekleme ve 638 silme
  1. 11 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/WeComConstant.java
  2. 0 119
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/controller/TestController.java
  3. 1 5
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/dao/mapper/HistoryMessageMapper.java
  4. 2 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/dao/mapper/SendMessageMapper.java
  5. 0 3
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/dao/mapper/StaffWithUserMapper.java
  6. 40 8
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComHistoryDataJob1.java
  7. 5 4
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComMessageDataJob1.java
  8. 128 9
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComUserDataJob1.java
  9. 22 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/HistoryMessage.java
  10. 120 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/HistoryMessageExample.java
  11. 22 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/StaffWithUser.java
  12. 120 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/StaffWithUserExample.java
  13. 8 3
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/MessageAttachmentServiceImpl.java
  14. 1 1
      we-com-server/src/main/resources/application-test.properties
  15. 297 256
      we-com-server/src/main/resources/mapper/HistoryMessageMapper.xml
  16. 12 0
      we-com-server/src/main/resources/mapper/SendMessageMapper.xml
  17. 258 228
      we-com-server/src/main/resources/mapper/StaffWithUserMapper.xml
  18. 2 2
      we-com-server/src/main/resources/mybatis-generator-config.xml

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

@@ -36,5 +36,16 @@ public interface WeComConstant {
     //批量获取客户详情
     String POST_WE_COM_GET_BY_USER = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/batch/get_by_user";
 
+    //上传临时素材
+    String POST_WE_COM_MEDIA_UPLOAD = "https://qyapi.weixin.qq.com/cgi-bin/media/upload";
+
+    //获取客户列表
+    String GET_WE_COM_EXTERNAL_CONTACT_LIST = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/list";
+
+    //获取客户先详情
+    String GET_WE_COM_EXTERNAL_CONTACT_GET = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get";
+
+    //external_userid转换
+    String POST_WE_COM_EXTERNAL_USER_ID = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/from_service_external_userid";
 
 }

+ 0 - 119
we-com-server/src/main/java/com/tzld/piaoquan/wecom/controller/TestController.java

@@ -1,119 +0,0 @@
-package com.tzld.piaoquan.wecom.controller;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import com.tzld.piaoquan.wecom.dao.mapper.UserMapper;
-import com.tzld.piaoquan.wecom.model.po.User;
-import com.tzld.piaoquan.wecom.model.po.UserExample;
-import com.tzld.piaoquan.wecom.service.AccessTokenService;
-import com.tzld.piaoquan.wecom.utils.HttpClientUtil;
-import com.tzld.piaoquan.wecom.utils.HttpPoolClient;
-import com.tzld.piaoquan.wecom.utils.page.Page;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.util.CollectionUtils;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.stream.Collectors;
-
-@Slf4j
-@RestController
-@RequestMapping("/test")
-public class TestController {
-
-    private static final HttpPoolClient httpPoolClientDefault = HttpClientUtil.create(30000, 30000, 2000, 5000, 5, 30000);
-
-    @Autowired
-    private AccessTokenService accessTokenService;
-
-    @Autowired
-    private UserMapper userMapper;
-
-
-    @GetMapping("/staff")
-    public void staff() throws IOException {
-        String weComAccessToken = accessTokenService.getWeComAccessToken();
-        log.info("weComAccessToken={}", weComAccessToken);
-        if (weComAccessToken == null) {
-            return;
-        }
-        String url = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_follow_user_list?access_token=" + weComAccessToken;
-        String s = httpPoolClientDefault.get(url);
-        log.info("staff={}", s);
-
-    }
-
-    @GetMapping("/user")
-    public void user() throws IOException {
-        String weComAccessToken = accessTokenService.getWeComAccessToken();
-        log.info("weComAccessToken={}", weComAccessToken);
-        if (weComAccessToken == null) {
-            return;
-        }
-        String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/externalcontact/list?access_token=%s&userid=%s", weComAccessToken, "SongYi");
-        String s = httpPoolClientDefault.get(url);
-        log.info("user={}", s);
-
-    }
-
-    @GetMapping("/userListDetail")
-    public void userListDetail() throws IOException {
-        String weComAccessToken = accessTokenService.getWeComAccessToken();
-        log.info("weComAccessToken={}", weComAccessToken);
-        if (weComAccessToken == null) {
-            return;
-        }
-        String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/externalcontact/batch/get_by_user?access_token=%s", weComAccessToken);
-        JSONObject jsonObject = new JSONObject();
-        JSONArray jsonArray = new JSONArray();
-        jsonArray.add("SongYi");
-        jsonObject.put("userid_list", jsonArray);
-        jsonObject.put("limit", 10);
-        String post = httpPoolClientDefault.post(url, jsonObject.toJSONString());
-        log.info("userListDetail={}", post);
-    }
-
-    @GetMapping("/userDetail")
-    public void userDetail(@RequestParam String userId) throws IOException {
-        String weComAccessToken = accessTokenService.getWeComAccessToken();
-        log.info("weComAccessToken={}", weComAccessToken);
-        if (weComAccessToken == null) {
-            return;
-        }
-        String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get?access_token=%s&external_userid=%s", weComAccessToken, userId);
-        String get = httpPoolClientDefault.get(url);
-        log.info("userDetail={}", get);
-    }
-
-
-    @GetMapping("/getUserId")
-    public void getUserId() throws IOException {
-        UserExample example = new UserExample();
-        Page page = new Page<>(1, 10);
-        example.setPage(page);
-        List<User> userList = userMapper.selectByExample(example);
-        if(CollectionUtils.isEmpty(userList)){
-            return;
-        }
-        List<String> collect = userList.stream().map(User::getExternalUserId3rdParty).collect(Collectors.toList());
-        String s = collect.get(0);
-        String weComAccessToken = accessTokenService.getWeComAccessToken();
-        log.info("weComAccessToken={}", weComAccessToken);
-        if (weComAccessToken == null) {
-            return;
-        }
-        String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/externalcontact/from_service_external_userid?access_token=%s", weComAccessToken);
-        JSONObject jsonObject = new JSONObject();
-        jsonObject.put("external_userid", s);
-        jsonObject.put("source_agentid", 1000009);
-        String post = httpPoolClientDefault.post(url, jsonObject.toJSONString());
-        log.info("getUserId={}", post);
-    }
-}

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

@@ -2,13 +2,9 @@ package com.tzld.piaoquan.wecom.dao.mapper;
 
 import com.tzld.piaoquan.wecom.model.po.HistoryMessage;
 import com.tzld.piaoquan.wecom.model.po.HistoryMessageExample;
-import org.apache.ibatis.annotations.Param;
-import org.springframework.stereotype.Repository;
-
 import java.util.List;
+import org.apache.ibatis.annotations.Param;
 
-
-@Repository
 public interface HistoryMessageMapper {
     long countByExample(HistoryMessageExample example);
 

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

@@ -39,4 +39,6 @@ public interface SendMessageMapper {
 
     List<String> selectExternalUserId3rdParty(@Param("record") SendMessage record);
 
+    List<String> selectExternalUserId(@Param("record") SendMessage record);
+
 }

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

@@ -3,11 +3,8 @@ package com.tzld.piaoquan.wecom.dao.mapper;
 import com.tzld.piaoquan.wecom.model.po.StaffWithUser;
 import com.tzld.piaoquan.wecom.model.po.StaffWithUserExample;
 import java.util.List;
-
 import org.apache.ibatis.annotations.Param;
-import org.springframework.stereotype.Repository;
 
-@Repository
 public interface StaffWithUserMapper {
     long countByExample(StaffWithUserExample example);
 

+ 40 - 8
we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComHistoryDataJob1.java

@@ -4,10 +4,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.tzld.piaoquan.wecom.common.constant.TimeConstant;
 import com.tzld.piaoquan.wecom.common.enums.MessageAttachmentTypeEnum;
-import com.tzld.piaoquan.wecom.dao.mapper.AlertMessageMapper;
-import com.tzld.piaoquan.wecom.dao.mapper.HistoryMessageMapper;
-import com.tzld.piaoquan.wecom.dao.mapper.StaffMapper;
-import com.tzld.piaoquan.wecom.dao.mapper.UserMapper;
+import com.tzld.piaoquan.wecom.dao.mapper.*;
 import com.tzld.piaoquan.wecom.model.bo.ExternalUser;
 import com.tzld.piaoquan.wecom.model.bo.MiniprogramRecord;
 import com.tzld.piaoquan.wecom.model.bo.XxlJobParam;
@@ -50,6 +47,15 @@ public class WeComHistoryDataJob1 {
     @Autowired
     private HistoryMessageService historyMessageService;
 
+    @Autowired
+    private MessageAttachmentService messageAttachmentService;
+
+    @Autowired
+    private StaffMapper staffMapper;
+
+    @Autowired
+    private StaffWithUserMapper staffWithUserMapper;
+
 
     @XxlJob("saveHistoryMessageJob1")
     public ReturnT<String> selectHistoryMessageByDay(String param) {
@@ -62,7 +68,12 @@ public class WeComHistoryDataJob1 {
             example.setOrderByClause("create_time desc");
             example.setPage(new Page<>(1, 1));
             List<HistoryMessage> historyMessages = historyMessageMapper.selectByExample(example);
-            xxlJobParam.setStartTime(historyMessages.get(0).getCreateTime().getTime() / 1000);
+            if (CollectionUtils.isEmpty(historyMessages)) {
+                xxlJobParam.setStartTime(1721404800L);
+            } else {
+                xxlJobParam.setStartTime(historyMessages.get(0).getCreateTime().getTime() / 1000);
+            }
+
         }
         if (xxlJobParam.getEndTime() == null) {
             xxlJobParam.setEndTime(System.currentTimeMillis() / 1000);
@@ -130,12 +141,18 @@ public class WeComHistoryDataJob1 {
                         continue;
                     }
                     for (String userId : userIdList) {
+                        StaffExample example = new StaffExample();
+                        example.createCriteria().andCarrierIdEqualTo(userId);
+                        List<Staff> staffList = staffMapper.selectByExample(example);
+                        if (CollectionUtils.isEmpty(staffList)) {
+                            continue;
+                        }
                         List<ExternalUser> externalUsers = selectGroupMsgSendResult(msgId, userId);
                         if (CollectionUtils.isEmpty(externalUsers)) {
                             continue;
                         }
-//                        insertHistoryMessageList(externalUsers, miniprogramRecordList);
-//                        messageAttachmentService.addMiniprogram(messageAttachmentList);
+                        insertHistoryMessageList(staffList.get(0), externalUsers, miniprogramRecordList);
+                        messageAttachmentService.addMiniprogram(messageAttachmentList);
                     }
 
 
@@ -225,7 +242,7 @@ public class WeComHistoryDataJob1 {
     }
 
 
-    private void insertHistoryMessageList(List<ExternalUser> externalUsers, List<MiniprogramRecord> miniprogramRecordList) {
+    private void insertHistoryMessageList(Staff staff, List<ExternalUser> externalUsers, List<MiniprogramRecord> miniprogramRecordList) {
         if (CollectionUtils.isEmpty(externalUsers) || CollectionUtils.isEmpty(miniprogramRecordList)) {
             return;
         }
@@ -236,14 +253,29 @@ public class WeComHistoryDataJob1 {
                 continue;
             }
             for (MiniprogramRecord miniprogramRecord : miniprogramRecordList) {
+                Integer status = externalUser.getStatus();
                 HistoryMessage historyMessage = new HistoryMessage();
                 if (externalUser.getSendTime() != null) {
                     historyMessage.setSendTime(new Date(externalUser.getSendTime()));
                 }
+
                 historyMessage.setAttachmentIdx(miniprogramRecord.getAttachmentIdx());
                 historyMessage.setVideoId(miniprogramRecord.getVideoId());
                 historyMessage.setUserId(userId);
+                historyMessage.setStaffId(staff.getId());
+                historyMessage.setStatus(status);
                 historyMessageList.add(historyMessage);
+                if (status == 2) {
+                    StaffWithUserExample example = new StaffWithUserExample();
+                    example.createCriteria().andUserIdEqualTo(userId).andStaffIdEqualTo(staff.getId());
+                    List<StaffWithUser> staffWithUserList = staffWithUserMapper.selectByExample(example);
+                    if (CollectionUtils.isEmpty(staffWithUserList)) {
+                        continue;
+                    }
+                    StaffWithUser staffWithUser = staffWithUserList.get(0);
+                    staffWithUser.setIsDelete(1);
+                    staffWithUserMapper.updateByPrimaryKeySelective(staffWithUser);
+                }
             }
         }
         historyMessageService.batchInsertHistoryMessage(historyMessageList);

+ 5 - 4
we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComMessageDataJob1.java

@@ -256,7 +256,7 @@ public class WeComMessageDataJob1 {
         for (SendMessage sendMessage : groupList) {
             sendMessage.setIsSend(0);
             sendMessage.setCreateTime(DateUtil.getThatDayDate());
-            List<String> sendUserList = sendMessageMapper.selectExternalUserId3rdParty(sendMessage);
+            List<String> sendUserList = sendMessageMapper.selectExternalUserId(sendMessage);
             boolean flag = pushMessage(sendUserList, sendMessage);
             if (flag) {
                 SendMessage updateSendMessage = new SendMessage();
@@ -282,10 +282,11 @@ public class WeComMessageDataJob1 {
         staffExample.createCriteria().andIdEqualTo(sendMessage.getStaffId());
         List<Staff> staffList = staffMapper.selectByExample(staffExample);
         Staff staff = staffList.get(0);
-        String text = messageService.getMessageText();
-
         JSONObject jsonObject = new JSONObject();
         jsonObject.put("chat_type", "single");
+        JSONObject text = new JSONObject();
+        String content = messageService.getMessageText();
+        text.put("content", content);
         jsonObject.put("text", text);
         jsonObject.put("sender", staff.getCarrierId());
         JSONArray attachments = new JSONArray();
@@ -346,7 +347,7 @@ public class WeComMessageDataJob1 {
         }
         for (JSONObject pushJsonObject : pushList) {
             log.info("pushMessage pushJsonObject={}", pushJsonObject);
-            boolean flag = messageService.pushMessage(pushJsonObject);
+            boolean flag = messageService.pushWeComMessage(pushJsonObject);
             if (!flag) {
                 return flag;
             }

+ 128 - 9
we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComUserDataJob1.java

@@ -2,7 +2,6 @@ package com.tzld.piaoquan.wecom.job;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.tzld.piaoquan.wecom.common.constant.TimeConstant;
 import com.tzld.piaoquan.wecom.dao.mapper.StaffMapper;
 import com.tzld.piaoquan.wecom.dao.mapper.StaffWithUserMapper;
 import com.tzld.piaoquan.wecom.dao.mapper.UserMapper;
@@ -15,7 +14,6 @@ import com.tzld.piaoquan.wecom.utils.page.Page;
 import com.xxl.job.core.biz.model.ReturnT;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
@@ -24,9 +22,9 @@ import org.springframework.util.CollectionUtils;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.stream.Collectors;
 
-import static com.tzld.piaoquan.wecom.common.constant.WeComConstant.POST_WE_COM_GET_BY_USER;
-import static com.tzld.piaoquan.wecom.common.constant.WeComConstant.UPDATE_USER_URL;
+import static com.tzld.piaoquan.wecom.common.constant.WeComConstant.*;
 
 @Slf4j
 @Component
@@ -66,7 +64,7 @@ public class WeComUserDataJob1 {
         try {
             String cursor = "";
             do {
-                String res = getUserList(staff.getCarrierId(), cursor);
+                String res = getUserDetailList(staff.getCarrierId(), cursor);
                 JSONObject jsonObject = JSONObject.parseObject(res);
                 Integer errCode = jsonObject.getInteger("errcode");
                 if (errCode != 0) {
@@ -77,7 +75,7 @@ public class WeComUserDataJob1 {
                 JSONArray externalContactList = jsonObject.getJSONArray("external_contact_list");
                 for (int i = 0; i < externalContactList.size(); i++) {
                     JSONObject externalContact = externalContactList.getJSONObject(i).getJSONObject("external_contact");
-                    JSONObject followInfo =  externalContactList.getJSONObject(i).getJSONObject("follow_info");
+                    JSONObject followInfo = externalContactList.getJSONObject(i).getJSONObject("follow_info");
                     Long createAt = followInfo.getLong("createtime");
                     String externalUserId = externalContact.getString("external_userid");
                     String name = externalContact.getString("name");
@@ -125,7 +123,7 @@ public class WeComUserDataJob1 {
         }
     }
 
-    private String getUserList(String userId, String cursor) throws IOException {
+    private String getUserDetailList(String userId, String cursor) throws IOException {
         String accessToken = accessTokenService.getWeComAccessToken();
         String url = POST_WE_COM_GET_BY_USER
                 + "?access_token=" + accessToken;
@@ -145,7 +143,7 @@ public class WeComUserDataJob1 {
     public ReturnT<String> setExternalUserId(String param) {
         try {
             UserExample example = new UserExample();
-            if(StringUtils.isNotEmpty(param)){
+            if (StringUtils.isNotEmpty(param)) {
                 example.createCriteria().andIdGreaterThanOrEqualTo(Long.parseLong(param));
             }
             long count = userMapper.countByExample(example);
@@ -179,7 +177,7 @@ public class WeComUserDataJob1 {
 
     public String getExternalUserId(String externalUserId3rdParty) throws IOException {
         String weComAccessToken = accessTokenService.getWeComAccessToken();
-        String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/externalcontact/from_service_external_userid?access_token=%s", weComAccessToken);
+        String url = String.format(POST_WE_COM_EXTERNAL_USER_ID + "?access_token=%s", weComAccessToken);
         JSONObject param = new JSONObject();
         param.put("external_userid", externalUserId3rdParty);
         param.put("source_agentid", 1000009);
@@ -192,5 +190,126 @@ public class WeComUserDataJob1 {
         return null;
     }
 
+    @XxlJob("insertStaffWithUserJob1")
+    public ReturnT<String> insertStaffWithUserJob(String param) throws IOException {
+        StaffExample example = new StaffExample();
+        List<Staff> staffList = staffMapper.selectByExample(example);
+        for (Staff staff : staffList) {
+            List<String> externalUserIds = getUserList(staff.getCarrierId());
+            if (CollectionUtils.isEmpty(externalUserIds)) {
+                continue;
+            }
+            for (String externalUserId : externalUserIds) {
+                UserExample userExample = new UserExample();
+                userExample.createCriteria().andExternalUserIdEqualTo(externalUserId);
+                List<User> userList = userMapper.selectByExample(userExample);
+                if (CollectionUtils.isEmpty(userList)) {
+                    JSONObject userDetail = getUserDetail(externalUserId);
+                    if (userDetail == null) {
+                        continue;
+                    }
+                    JSONObject externalContact = userDetail.getJSONObject("external_contact");
+                    JSONArray followUserList = userDetail.getJSONArray("follow_user");
+                    Long createAt = null;
+                    List<String> staffUserIdList = new ArrayList<>();
+                    for (int i = 0; i < followUserList.size(); i++) {
+                        JSONObject followUser = followUserList.getJSONObject(i);
+                        if (createAt == null) {
+                            createAt = followUser.getLong("createtime");
+                        } else {
+                            createAt = Math.min(createAt, followUser.getLong("createtime"));
+                        }
+                        String userId = followUser.getString("userid");
+                        if (StringUtils.isNotEmpty(userId)) {
+                            staffUserIdList.add(userId);
+                        }
+                    }
+                    String name = externalContact.getString("name");
+                    String unionId = externalContact.getString("unionid");
+                    String avatar = externalContact.getString("avatar");
+                    Integer type = externalContact.getInteger("type");
+                    Integer gender = externalContact.getInteger("gender");
+                    User user = new User();
+                    user.setExternalUserId(externalUserId);
+                    user.setCreatedAt(createAt);
+                    user.setName(name);
+                    user.setUnionId(unionId);
+                    user.setAvatar(avatar);
+                    user.setType(type);
+                    user.setGender(gender);
+                    userMapper.insert(user);
+                    Long userId = user.getId();
+                    if (userId == null) {
+                        log.error("insertStaffWithUserJob insert user error user={}", user);
+                        continue;
+                    }
+                    if (CollectionUtils.isEmpty(staffUserIdList)) {
+                        continue;
+                    }
+                    for (String staffUserId : staffUserIdList) {
+                        StaffExample staffExample = new StaffExample();
+                        staffExample.createCriteria().andCarrierIdEqualTo(staffUserId);
+                        List<Staff> staffList1 = staffMapper.selectByExample(staffExample);
+                        if (CollectionUtils.isEmpty(staffList1)) {
+                            continue;
+                        }
+                        Staff staff1 = staffList1.get(0);
+                        Long staffId = staff1.getId();
+                        StaffWithUser staffWithUser = new StaffWithUser();
+                        staffWithUser.setStaffId(staffId);
+                        staffWithUser.setUserId(userId);
+                        staffWithUserMapper.insert(staffWithUser);
+                    }
+                } else {
+                    User user = userList.get(0);
+                    StaffWithUserExample staffWithUserExample = new StaffWithUserExample();
+                    staffWithUserExample.createCriteria().andUserIdEqualTo(user.getId()).andStaffIdEqualTo(staff.getId());
+                    List<StaffWithUser> staffWithUserList = staffWithUserMapper.selectByExample(staffWithUserExample);
+                    if (CollectionUtils.isEmpty(staffWithUserList)) {
+                        StaffWithUser staffWithUser = new StaffWithUser();
+                        staffWithUser.setStaffId(staff.getId());
+                        staffWithUser.setUserId(user.getId());
+                        staffWithUserMapper.insert(staffWithUser);
+                    } else {
+                        StaffWithUser staffWithUser = staffWithUserList.get(0);
+                        if (staffWithUser.getIsDelete() == 1) {
+                            staffWithUser.setIsDelete(0);
+                            staffWithUserMapper.updateByPrimaryKeySelective(staffWithUser);
+                        }
+                    }
+                }
+
+            }
+
+        }
+
+        return ReturnT.SUCCESS;
+
+    }
+
+    public List<String> getUserList(String userId) throws IOException {
+        String weComAccessToken = accessTokenService.getWeComAccessToken();
+        String url = String.format(GET_WE_COM_EXTERNAL_CONTACT_LIST + "?access_token=%s&userid=%s", weComAccessToken, userId);
+        String res = httpPoolClientDefault.get(url);
+        JSONObject jsonObject = JSONObject.parseObject(res);
+        Integer errcode = jsonObject.getInteger("errcode");
+        if (errcode == 0) {
+            return jsonObject.getJSONArray("external_userid").stream().map(String::valueOf).collect(Collectors.toList());
+        }
+        return null;
+    }
+
+    public JSONObject getUserDetail(String externalUserId) throws IOException {
+        String weComAccessToken = accessTokenService.getWeComAccessToken();
+        String url = String.format(GET_WE_COM_EXTERNAL_CONTACT_GET + "?access_token=%s&external_userid=%s", weComAccessToken, externalUserId);
+        String res = httpPoolClientDefault.get(url);
+        JSONObject jsonObject = JSONObject.parseObject(res);
+        Integer errcode = jsonObject.getInteger("errcode");
+        if (errcode == 0) {
+            return jsonObject;
+        }
+        return null;
+    }
+
 
 }

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

@@ -7,12 +7,16 @@ public class HistoryMessage {
 
     private Long userId;
 
+    private Long staffId;
+
     private Long videoId;
 
     private Integer attachmentIdx;
 
     private Long messageId;
 
+    private Integer status;
+
     private Date sendTime;
 
     private Date createTime;
@@ -33,6 +37,14 @@ public class HistoryMessage {
         this.userId = userId;
     }
 
+    public Long getStaffId() {
+        return staffId;
+    }
+
+    public void setStaffId(Long staffId) {
+        this.staffId = staffId;
+    }
+
     public Long getVideoId() {
         return videoId;
     }
@@ -57,6 +69,14 @@ public class HistoryMessage {
         this.messageId = messageId;
     }
 
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
     public Date getSendTime() {
         return sendTime;
     }
@@ -81,9 +101,11 @@ public class HistoryMessage {
         sb.append("Hash = ").append(hashCode());
         sb.append(", id=").append(id);
         sb.append(", userId=").append(userId);
+        sb.append(", staffId=").append(staffId);
         sb.append(", videoId=").append(videoId);
         sb.append(", attachmentIdx=").append(attachmentIdx);
         sb.append(", messageId=").append(messageId);
+        sb.append(", status=").append(status);
         sb.append(", sendTime=").append(sendTime);
         sb.append(", createTime=").append(createTime);
         sb.append("]");

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

@@ -236,6 +236,66 @@ public class HistoryMessageExample {
             return (Criteria) this;
         }
 
+        public Criteria andStaffIdIsNull() {
+            addCriterion("staff_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdIsNotNull() {
+            addCriterion("staff_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdEqualTo(Long value) {
+            addCriterion("staff_id =", value, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdNotEqualTo(Long value) {
+            addCriterion("staff_id <>", value, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdGreaterThan(Long value) {
+            addCriterion("staff_id >", value, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("staff_id >=", value, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdLessThan(Long value) {
+            addCriterion("staff_id <", value, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdLessThanOrEqualTo(Long value) {
+            addCriterion("staff_id <=", value, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdIn(List<Long> values) {
+            addCriterion("staff_id in", values, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdNotIn(List<Long> values) {
+            addCriterion("staff_id not in", values, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdBetween(Long value1, Long value2) {
+            addCriterion("staff_id between", value1, value2, "staffId");
+            return (Criteria) this;
+        }
+
+        public Criteria andStaffIdNotBetween(Long value1, Long value2) {
+            addCriterion("staff_id not between", value1, value2, "staffId");
+            return (Criteria) this;
+        }
+
         public Criteria andVideoIdIsNull() {
             addCriterion("video_id is null");
             return (Criteria) this;
@@ -416,6 +476,66 @@ public class HistoryMessageExample {
             return (Criteria) this;
         }
 
+        public Criteria andStatusIsNull() {
+            addCriterion("`status` is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusIsNotNull() {
+            addCriterion("`status` is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusEqualTo(Integer value) {
+            addCriterion("`status` =", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusNotEqualTo(Integer value) {
+            addCriterion("`status` <>", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusGreaterThan(Integer value) {
+            addCriterion("`status` >", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusGreaterThanOrEqualTo(Integer value) {
+            addCriterion("`status` >=", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusLessThan(Integer value) {
+            addCriterion("`status` <", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusLessThanOrEqualTo(Integer value) {
+            addCriterion("`status` <=", value, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusIn(List<Integer> values) {
+            addCriterion("`status` in", values, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusNotIn(List<Integer> values) {
+            addCriterion("`status` not in", values, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusBetween(Integer value1, Integer value2) {
+            addCriterion("`status` between", value1, value2, "status");
+            return (Criteria) this;
+        }
+
+        public Criteria andStatusNotBetween(Integer value1, Integer value2) {
+            addCriterion("`status` not between", value1, value2, "status");
+            return (Criteria) this;
+        }
+
         public Criteria andSendTimeIsNull() {
             addCriterion("send_time is null");
             return (Criteria) this;

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

@@ -9,6 +9,10 @@ public class StaffWithUser {
 
     private Long userId;
 
+    private Integer isDelete;
+
+    private Date deleteTime;
+
     private Date createTime;
 
     private Date updateTime;
@@ -37,6 +41,22 @@ public class StaffWithUser {
         this.userId = userId;
     }
 
+    public Integer getIsDelete() {
+        return isDelete;
+    }
+
+    public void setIsDelete(Integer isDelete) {
+        this.isDelete = isDelete;
+    }
+
+    public Date getDeleteTime() {
+        return deleteTime;
+    }
+
+    public void setDeleteTime(Date deleteTime) {
+        this.deleteTime = deleteTime;
+    }
+
     public Date getCreateTime() {
         return createTime;
     }
@@ -62,6 +82,8 @@ public class StaffWithUser {
         sb.append(", id=").append(id);
         sb.append(", staffId=").append(staffId);
         sb.append(", userId=").append(userId);
+        sb.append(", isDelete=").append(isDelete);
+        sb.append(", deleteTime=").append(deleteTime);
         sb.append(", createTime=").append(createTime);
         sb.append(", updateTime=").append(updateTime);
         sb.append("]");

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

@@ -296,6 +296,126 @@ public class StaffWithUserExample {
             return (Criteria) this;
         }
 
+        public Criteria andIsDeleteIsNull() {
+            addCriterion("is_delete is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteIsNotNull() {
+            addCriterion("is_delete is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteEqualTo(Integer value) {
+            addCriterion("is_delete =", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteNotEqualTo(Integer value) {
+            addCriterion("is_delete <>", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteGreaterThan(Integer value) {
+            addCriterion("is_delete >", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteGreaterThanOrEqualTo(Integer value) {
+            addCriterion("is_delete >=", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteLessThan(Integer value) {
+            addCriterion("is_delete <", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteLessThanOrEqualTo(Integer value) {
+            addCriterion("is_delete <=", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteIn(List<Integer> values) {
+            addCriterion("is_delete in", values, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteNotIn(List<Integer> values) {
+            addCriterion("is_delete not in", values, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteBetween(Integer value1, Integer value2) {
+            addCriterion("is_delete between", value1, value2, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteNotBetween(Integer value1, Integer value2) {
+            addCriterion("is_delete not between", value1, value2, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andDeleteTimeIsNull() {
+            addCriterion("delete_time is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andDeleteTimeIsNotNull() {
+            addCriterion("delete_time is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andDeleteTimeEqualTo(Date value) {
+            addCriterion("delete_time =", value, "deleteTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andDeleteTimeNotEqualTo(Date value) {
+            addCriterion("delete_time <>", value, "deleteTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andDeleteTimeGreaterThan(Date value) {
+            addCriterion("delete_time >", value, "deleteTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andDeleteTimeGreaterThanOrEqualTo(Date value) {
+            addCriterion("delete_time >=", value, "deleteTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andDeleteTimeLessThan(Date value) {
+            addCriterion("delete_time <", value, "deleteTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andDeleteTimeLessThanOrEqualTo(Date value) {
+            addCriterion("delete_time <=", value, "deleteTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andDeleteTimeIn(List<Date> values) {
+            addCriterion("delete_time in", values, "deleteTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andDeleteTimeNotIn(List<Date> values) {
+            addCriterion("delete_time not in", values, "deleteTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andDeleteTimeBetween(Date value1, Date value2) {
+            addCriterion("delete_time between", value1, value2, "deleteTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andDeleteTimeNotBetween(Date value1, Date value2) {
+            addCriterion("delete_time not between", value1, value2, "deleteTime");
+            return (Criteria) this;
+        }
+
         public Criteria andCreateTimeIsNull() {
             addCriterion("create_time is null");
             return (Criteria) this;

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

@@ -10,6 +10,7 @@ import com.tzld.piaoquan.wecom.model.bo.VideoDetail;
 import com.tzld.piaoquan.wecom.model.po.MessageAttachment;
 import com.tzld.piaoquan.wecom.model.po.MessageAttachmentExample;
 import com.tzld.piaoquan.wecom.model.po.Staff;
+import com.tzld.piaoquan.wecom.service.AccessTokenService;
 import com.tzld.piaoquan.wecom.service.MessageAttachmentService;
 import com.tzld.piaoquan.wecom.utils.DateUtil;
 import com.tzld.piaoquan.wecom.utils.HttpClientUtil;
@@ -37,6 +38,7 @@ import static com.tzld.piaoquan.wecom.common.constant.MessageConstant.appid;
 import static com.tzld.piaoquan.wecom.common.constant.OtherServerURL.POST_ADD_TENCENT;
 import static com.tzld.piaoquan.wecom.common.constant.OtherServerURL.POST_VIDEO_DETAIL_URL;
 import static com.tzld.piaoquan.wecom.common.constant.RedisConstant.GUARANTEED_MINIPROGRAM_KEY;
+import static com.tzld.piaoquan.wecom.common.constant.WeComConstant.POST_WE_COM_MEDIA_UPLOAD;
 import static com.tzld.piaoquan.wecom.common.enums.ExceptionCodeEnum.PARAMS_ERROR;
 
 
@@ -46,6 +48,9 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
 
     private static final HttpPoolClient httpPoolClientDefault = HttpClientUtil.create(30000, 30000, 2000, 5000, 5, 30000);
 
+    @Autowired
+    private AccessTokenService accessTokenService;
+
     @Autowired
     private MessageAttachmentMapper messageAttachmentMapper;
 
@@ -144,8 +149,8 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
             inputStream.close();
             httpUrl.disconnect();
             File file = new java.io.File(filePath);
-            String url = String.format("https://qyapi.weixin.qq.com/cgi-bin/media/upload?access_token=%s&type=image",
-                    "gj_f699xkVm62jtoNTZVbmMcrxCRo3ZWYEcodnmbuZDj1M5oms1Nnp4B-FSD6Lm2puKlxOurb-j8t-WiXgwtbXtEoP7M5qwjHY9E8yfuJaDkzYh54pUSzxSVF5whSetby6venHVGi9SnAtNt5ykyAbjpPQl3mKSG_HL3i3j45b4UJUXXtTWTuqNyxnEIGFbR1FHw0SaMTV8Hpsm5mv8FVg");
+            String weComAccessToken = accessTokenService.getWeComAccessToken();
+            String url = String.format(POST_WE_COM_MEDIA_UPLOAD + "?access_token=%s&type=%s", weComAccessToken, "image");
             String res = httpPoolClientDefault.post(url, file);
             JSONObject jsonObject = JSONObject.parseObject(res);
             if (jsonObject != null && jsonObject.getInteger("errcode") == 0) {
@@ -154,7 +159,7 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
                 return mediaId;
             }
         } catch (Exception e) {
-            e.printStackTrace();
+            log.error("getPicMediaId error", e);
         }
 
         return null;

+ 1 - 1
we-com-server/src/main/resources/application-test.properties

@@ -1,6 +1,6 @@
 spring.datasource.username=crawler
 spring.datasource.password=crawler123456@
-spring.datasource.url=jdbc:mysql://rm-bp1k5853td1r25g3n690.mysql.rds.aliyuncs.com:3306/piaoquan-crawler?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true
+spring.datasource.url=jdbc:mysql://rm-bp1159bu17li9hi94.mysql.rds.aliyuncs.com:3306/piaoquan-crawler?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowMultiQueries=true
 
 spring.redis.database=2
 spring.redis.host=r-bp154bpw97gptefiqkpd.redis.rds.aliyuncs.com

+ 297 - 256
we-com-server/src/main/resources/mapper/HistoryMessageMapper.xml

@@ -1,270 +1,311 @@
 <?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>
+    <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="staff_id" jdbcType="BIGINT" property="staffId"/>
+        <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="status" jdbcType="INTEGER" property="status"/>
+        <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>
-          </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>
+        </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>
-          </trim>
+        </where>
+    </sql>
+    <sql id="Base_Column_List">
+        id
+        , user_id, staff_id, video_id, attachment_idx, message_id, `status`, send_time,
+    create_time
+    </sql>
+    <select id="selectByExample" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessageExample"
+            resultMap="BaseResultMap">
+        select
+        <if test="distinct">
+            distinct
         </if>
-      </foreach>
-    </where>
-  </sql>
-  <sql id="Base_Column_List">
-    id, user_id, video_id, attachment_idx, message_id, send_time, create_time
-  </sql>
-  <select id="selectByExample" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessageExample" resultMap="BaseResultMap">
-    select
-    <if test="distinct">
-      distinct
-    </if>
-    <include refid="Base_Column_List" />
-    from we_com_history_message
-    <if test="_parameter != null">
-      <include refid="Example_Where_Clause" />
-    </if>
-    <if test="orderByClause != null">
-      order by ${orderByClause}
-    </if>
-    <if test="page != null">
-      limit #{page.offset} , #{page.pageSize}
-    </if>
-  </select>
-  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
-    select 
-    <include refid="Base_Column_List" />
-    from we_com_history_message
-    where id = #{id,jdbcType=BIGINT}
-  </select>
-  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
-    delete from we_com_history_message
-    where id = #{id,jdbcType=BIGINT}
-  </delete>
-  <delete id="deleteByExample" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessageExample">
-    delete from we_com_history_message
-    <if test="_parameter != null">
-      <include refid="Example_Where_Clause" />
-    </if>
-  </delete>
-  <insert id="insert" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessage">
-    insert into we_com_history_message (id, user_id, video_id, 
-      attachment_idx, message_id, send_time, 
-      create_time)
-    values (#{id,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{videoId,jdbcType=BIGINT}, 
-      #{attachmentIdx,jdbcType=INTEGER}, #{messageId,jdbcType=BIGINT}, #{sendTime,jdbcType=TIMESTAMP}, 
-      #{createTime,jdbcType=TIMESTAMP})
-  </insert>
-  <insert id="insertSelective" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessage">
-    insert into we_com_history_message
-    <trim prefix="(" suffix=")" suffixOverrides=",">
-      <if test="id != null">
-        id,
-      </if>
-      <if test="userId != null">
-        user_id,
-      </if>
-      <if test="videoId != null">
-        video_id,
-      </if>
-      <if test="attachmentIdx != null">
-        attachment_idx,
-      </if>
-      <if test="messageId != null">
-        message_id,
-      </if>
-      <if test="sendTime != null">
-        send_time,
-      </if>
-      <if test="createTime != null">
-        create_time,
-      </if>
-    </trim>
-    <trim prefix="values (" suffix=")" suffixOverrides=",">
-      <if test="id != null">
-        #{id,jdbcType=BIGINT},
-      </if>
-      <if test="userId != null">
-        #{userId,jdbcType=BIGINT},
-      </if>
-      <if test="videoId != null">
-        #{videoId,jdbcType=BIGINT},
-      </if>
-      <if test="attachmentIdx != null">
-        #{attachmentIdx,jdbcType=INTEGER},
-      </if>
-      <if test="messageId != null">
-        #{messageId,jdbcType=BIGINT},
-      </if>
-      <if test="sendTime != null">
-        #{sendTime,jdbcType=TIMESTAMP},
-      </if>
-      <if test="createTime != null">
-        #{createTime,jdbcType=TIMESTAMP},
-      </if>
-    </trim>
-  </insert>
-  <select id="countByExample" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessageExample" resultType="java.lang.Long">
-    select count(*) from we_com_history_message
-    <if test="_parameter != null">
-      <include refid="Example_Where_Clause" />
-    </if>
-  </select>
-  <update id="updateByExampleSelective" parameterType="map">
-    update we_com_history_message
-    <set>
-      <if test="record.id != null">
-        id = #{record.id,jdbcType=BIGINT},
-      </if>
-      <if test="record.userId != null">
+        <include refid="Base_Column_List"/>
+        from we_com_history_message
+        <if test="_parameter != null">
+            <include refid="Example_Where_Clause"/>
+        </if>
+        <if test="orderByClause != null">
+            order by ${orderByClause}
+        </if>
+        <if test="page != null">
+            limit #{page.offset} , #{page.pageSize}
+        </if>
+    </select>
+    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
+        select
+        <include refid="Base_Column_List"/>
+        from we_com_history_message
+        where id = #{id,jdbcType=BIGINT}
+    </select>
+    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+        delete
+        from we_com_history_message
+        where id = #{id,jdbcType=BIGINT}
+    </delete>
+    <delete id="deleteByExample" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessageExample">
+        delete from we_com_history_message
+        <if test="_parameter != null">
+            <include refid="Example_Where_Clause"/>
+        </if>
+    </delete>
+    <insert id="insert" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessage">
+        insert into we_com_history_message (id, user_id, staff_id,
+                                            video_id, attachment_idx, message_id,
+                                            `status`, send_time, create_time)
+        values (#{id,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{staffId,jdbcType=BIGINT},
+                #{videoId,jdbcType=BIGINT}, #{attachmentIdx,jdbcType=INTEGER}, #{messageId,jdbcType=BIGINT},
+                #{status,jdbcType=INTEGER}, #{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="staffId != null">
+                staff_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="status != null">
+                `status`,
+            </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="staffId != null">
+                #{staffId,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="status != null">
+                #{status,jdbcType=INTEGER},
+            </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.staffId != null">
+                staff_id = #{record.staffId,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.status != null">
+                `status` = #{record.status,jdbcType=INTEGER},
+            </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},
-      </if>
-      <if test="record.videoId != null">
+        staff_id = #{record.staffId,jdbcType=BIGINT},
         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">
+        `status` = #{record.status,jdbcType=INTEGER},
         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>
+        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="staffId != null">
+                staff_id = #{staffId,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="status != null">
+                `status` = #{status,jdbcType=INTEGER},
+            </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},
+            staff_id       = #{staffId,jdbcType=BIGINT},
+            video_id       = #{videoId,jdbcType=BIGINT},
+            attachment_idx = #{attachmentIdx,jdbcType=INTEGER},
+            message_id     = #{messageId,jdbcType=BIGINT},
+            `status`       = #{status,jdbcType=INTEGER},
+            send_time      = #{sendTime,jdbcType=TIMESTAMP},
+            create_time    = #{createTime,jdbcType=TIMESTAMP}
+        where id = #{id,jdbcType=BIGINT}
+    </update>
 
-  <insert id="insertList" parameterType="java.util.List">
-    insert into we_com_history_message
-    (
-     user_id,
-     video_id,
-     attachment_idx,
-     message_id,
-     send_time,
-     create_time
-    )
-    values
-    <foreach collection="list" item="item" separator=",">
-      (
-       #{item.userId,jdbcType=BIGINT},
-       #{item.videoId,jdbcType=BIGINT},
-       #{item.attachmentIdx,jdbcType=INTEGER},
-       #{item.messageId,jdbcType=BIGINT},
-       #{item.sendTime,jdbcType=TIMESTAMP},
-       #{item.createTime,jdbcType=TIMESTAMP}
-      )
-    </foreach>
-  </insert>
+    <insert id="insertList" parameterType="java.util.List">
+        insert into we_com_history_message
+        (
+        user_id,
+        staff_id,
+        video_id,
+        attachment_idx,
+        message_id,
+        `status`,
+        send_time,
+        create_time
+        )
+        values
+        <foreach collection="list" item="item" separator=",">
+            (
+            #{item.userId,jdbcType=BIGINT},
+            #{item.staffId,jdbcType=BIGINT},
+            #{item.videoId,jdbcType=BIGINT},
+            #{item.attachmentIdx,jdbcType=INTEGER},
+            #{item.messageId,jdbcType=BIGINT},
+            #{item.status,jdbcType=INTEGER},
+            #{item.sendTime,jdbcType=TIMESTAMP},
+            #{item.createTime,jdbcType=TIMESTAMP}
+            )
+        </foreach>
+    </insert>
 
 </mapper>

+ 12 - 0
we-com-server/src/main/resources/mapper/SendMessageMapper.xml

@@ -320,4 +320,16 @@
           and t1.create_time > #{record.createTime}
           and t1.is_send = #{record.isSend}
     </select>
+
+    <select id="selectExternalUserId" parameterType="com.tzld.piaoquan.wecom.model.po.SendMessage" resultType="java.lang.String">
+        select
+            t2.external_user_id
+        from we_com_send_message t1 left join we_com_user t2 on t1.user_id = t2.id
+        where t1.staff_id = #{record.staffId}
+          and t1.video_id_1 = #{record.videoId1}
+          and t1.video_id_2 = #{record.videoId2}
+          and t1.video_id_3 = #{record.videoId3}
+          and t1.create_time > #{record.createTime}
+          and t1.is_send = #{record.isSend}
+    </select>
 </mapper>

+ 258 - 228
we-com-server/src/main/resources/mapper/StaffWithUserMapper.xml

@@ -1,239 +1,269 @@
 <?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.StaffWithUserMapper">
-    <resultMap id="BaseResultMap" type="com.tzld.piaoquan.wecom.model.po.StaffWithUser">
-        <id column="id" jdbcType="BIGINT" property="id"/>
-        <result column="staff_id" jdbcType="BIGINT" property="staffId"/>
-        <result column="user_id" jdbcType="BIGINT" property="userId"/>
-        <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>
+  <resultMap id="BaseResultMap" type="com.tzld.piaoquan.wecom.model.po.StaffWithUser">
+    <id column="id" jdbcType="BIGINT" property="id" />
+    <result column="staff_id" jdbcType="BIGINT" property="staffId" />
+    <result column="user_id" jdbcType="BIGINT" property="userId" />
+    <result column="is_delete" jdbcType="INTEGER" property="isDelete" />
+    <result column="delete_time" jdbcType="TIMESTAMP" property="deleteTime" />
+    <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>
-        </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
-        , staff_id, user_id, create_time, update_time
-    </sql>
-    <select id="selectByExample" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUserExample"
-            resultMap="BaseResultMap">
-        select
-        <if test="distinct">
-            distinct
-        </if>
-        <include refid="Base_Column_List"/>
-        from we_com_staff_with_user
-        <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}
+          </trim>
         </if>
-    </select>
-    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
-        select
-        <include refid="Base_Column_List"/>
-        from we_com_staff_with_user
-        where id = #{id,jdbcType=BIGINT}
-    </select>
-    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
-        delete
-        from we_com_staff_with_user
-        where id = #{id,jdbcType=BIGINT}
-    </delete>
-    <delete id="deleteByExample" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUserExample">
-        delete from we_com_staff_with_user
-        <if test="_parameter != null">
-            <include refid="Example_Where_Clause"/>
-        </if>
-    </delete>
-    <insert id="insert" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUser">
-        insert into we_com_staff_with_user (id, staff_id, user_id,
-                                            create_time, update_time)
-        values (#{id,jdbcType=BIGINT}, #{staffId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT},
-                #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
-    </insert>
-    <insert id="insertSelective" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUser">
-        insert into we_com_staff_with_user
-        <trim prefix="(" suffix=")" suffixOverrides=",">
-            <if test="id != null">
-                id,
-            </if>
-            <if test="staffId != null">
-                staff_id,
-            </if>
-            <if test="userId != null">
-                user_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="staffId != null">
-                #{staffId,jdbcType=BIGINT},
-            </if>
-            <if test="userId != null">
-                #{userId,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.wecom.model.po.StaffWithUserExample"
-            resultType="java.lang.Long">
-        select count(*) from we_com_staff_with_user
-        <if test="_parameter != null">
-            <include refid="Example_Where_Clause"/>
-        </if>
-    </select>
-    <update id="updateByExampleSelective" parameterType="map">
-        update we_com_staff_with_user
-        <set>
-            <if test="record.id != null">
-                id = #{record.id,jdbcType=BIGINT},
-            </if>
-            <if test="record.staffId != null">
-                staff_id = #{record.staffId,jdbcType=BIGINT},
-            </if>
-            <if test="record.userId != null">
-                user_id = #{record.userId,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"/>
+      </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>
-    </update>
-    <update id="updateByExample" parameterType="map">
-        update we_com_staff_with_user
-        set id = #{record.id,jdbcType=BIGINT},
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Base_Column_List">
+    id, staff_id, user_id, is_delete, delete_time, create_time, update_time
+  </sql>
+  <select id="selectByExample" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUserExample" resultMap="BaseResultMap">
+    select
+    <if test="distinct">
+      distinct
+    </if>
+    <include refid="Base_Column_List" />
+    from we_com_staff_with_user
+    <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_staff_with_user
+    where id = #{id,jdbcType=BIGINT}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+    delete from we_com_staff_with_user
+    where id = #{id,jdbcType=BIGINT}
+  </delete>
+  <delete id="deleteByExample" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUserExample">
+    delete from we_com_staff_with_user
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </delete>
+  <insert id="insert" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUser">
+    insert into we_com_staff_with_user (id, staff_id, user_id,
+      is_delete, delete_time, create_time,
+      update_time)
+    values (#{id,jdbcType=BIGINT}, #{staffId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT},
+      #{isDelete,jdbcType=INTEGER}, #{deleteTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP},
+      #{updateTime,jdbcType=TIMESTAMP})
+  </insert>
+  <insert id="insertSelective" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUser">
+    insert into we_com_staff_with_user
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <if test="staffId != null">
+        staff_id,
+      </if>
+      <if test="userId != null">
+        user_id,
+      </if>
+      <if test="isDelete != null">
+        is_delete,
+      </if>
+      <if test="deleteTime != null">
+        delete_time,
+      </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="staffId != null">
+        #{staffId,jdbcType=BIGINT},
+      </if>
+      <if test="userId != null">
+        #{userId,jdbcType=BIGINT},
+      </if>
+      <if test="isDelete != null">
+        #{isDelete,jdbcType=INTEGER},
+      </if>
+      <if test="deleteTime != null">
+        #{deleteTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateTime != null">
+        #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+    </trim>
+  </insert>
+  <select id="countByExample" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUserExample" resultType="java.lang.Long">
+    select count(*) from we_com_staff_with_user
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </select>
+  <update id="updateByExampleSelective" parameterType="map">
+    update we_com_staff_with_user
+    <set>
+      <if test="record.id != null">
+        id = #{record.id,jdbcType=BIGINT},
+      </if>
+      <if test="record.staffId != null">
         staff_id = #{record.staffId,jdbcType=BIGINT},
+      </if>
+      <if test="record.userId != null">
         user_id = #{record.userId,jdbcType=BIGINT},
+      </if>
+      <if test="record.isDelete != null">
+        is_delete = #{record.isDelete,jdbcType=INTEGER},
+      </if>
+      <if test="record.deleteTime != null">
+        delete_time = #{record.deleteTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="record.createTime != null">
         create_time = #{record.createTime,jdbcType=TIMESTAMP},
-        update_time = #{record.updateTime,jdbcType=TIMESTAMP}
-        <if test="_parameter != null">
-            <include refid="Update_By_Example_Where_Clause"/>
-        </if>
-    </update>
-    <update id="updateByPrimaryKeySelective" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUser">
-        update we_com_staff_with_user
-        <set>
-            <if test="staffId != null">
-                staff_id = #{staffId,jdbcType=BIGINT},
-            </if>
-            <if test="userId != null">
-                user_id = #{userId,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.wecom.model.po.StaffWithUser">
-        update we_com_staff_with_user
-        set staff_id    = #{staffId,jdbcType=BIGINT},
-            user_id     = #{userId,jdbcType=BIGINT},
-            create_time = #{createTime,jdbcType=TIMESTAMP},
-            update_time = #{updateTime,jdbcType=TIMESTAMP}
-        where id = #{id,jdbcType=BIGINT}
-    </update>
+      </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_staff_with_user
+    set id = #{record.id,jdbcType=BIGINT},
+      staff_id = #{record.staffId,jdbcType=BIGINT},
+      user_id = #{record.userId,jdbcType=BIGINT},
+      is_delete = #{record.isDelete,jdbcType=INTEGER},
+      delete_time = #{record.deleteTime,jdbcType=TIMESTAMP},
+      create_time = #{record.createTime,jdbcType=TIMESTAMP},
+      update_time = #{record.updateTime,jdbcType=TIMESTAMP}
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByPrimaryKeySelective" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUser">
+    update we_com_staff_with_user
+    <set>
+      <if test="staffId != null">
+        staff_id = #{staffId,jdbcType=BIGINT},
+      </if>
+      <if test="userId != null">
+        user_id = #{userId,jdbcType=BIGINT},
+      </if>
+      <if test="isDelete != null">
+        is_delete = #{isDelete,jdbcType=INTEGER},
+      </if>
+      <if test="deleteTime != null">
+        delete_time = #{deleteTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="createTime != null">
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateTime != null">
+        update_time = #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.wecom.model.po.StaffWithUser">
+    update we_com_staff_with_user
+    set staff_id = #{staffId,jdbcType=BIGINT},
+      user_id = #{userId,jdbcType=BIGINT},
+      is_delete = #{isDelete,jdbcType=INTEGER},
+      delete_time = #{deleteTime,jdbcType=TIMESTAMP},
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      update_time = #{updateTime,jdbcType=TIMESTAMP}
+    where id = #{id,jdbcType=BIGINT}
+  </update>
 
-    <insert id="insertList" parameterType="java.util.List">
-        insert into we_com_staff_with_user
-        (
-        staff_id,
-        user_id,
-        create_time,
-        update_time
-        )
-        values
-        <foreach collection="list" item="item" separator=",">
-            (
-            #{item.staffId,jdbcType=BIGINT},
-            #{item.userId,jdbcType=BIGINT},
-            #{item.createTime,jdbcType=TIMESTAMP},
-            #{item.updateTime,jdbcType=TIMESTAMP}
-            )
-        </foreach>
-    </insert>
+  <insert id="insertList" parameterType="java.util.List">
+    insert into we_com_staff_with_user
+    (
+    staff_id,
+    user_id,
+    is_delete,
+    delete_time,
+    create_time,
+    update_time
+    )
+    values
+    <foreach collection="list" item="item" separator=",">
+      (
+      #{item.staffId,jdbcType=BIGINT},
+      #{item.userId,jdbcType=BIGINT},
+      #{item.isDelete,jdbcType=INTEGER},
+      #{item.deleteTime,jdbcType=TIMESTAMP},
+      #{item.createTime,jdbcType=TIMESTAMP},
+      #{item.updateTime,jdbcType=TIMESTAMP}
+      )
+    </foreach>
+  </insert>
 </mapper>

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

@@ -50,11 +50,11 @@
             <property name="enableSubPackages" value="true"/>
         </javaClientGenerator>
 
-        <table tableName="we_com_alert_message" domainObjectName="AlertMessage" alias=""/>
+<!--        <table tableName="we_com_alert_message" domainObjectName="AlertMessage" alias=""/>-->
 <!--        <table tableName="we_com_history_message" domainObjectName="HistoryMessage" alias=""/>-->
 <!--        <table tableName="we_com_message_attachment" domainObjectName="MessageAttachment" alias=""/>-->
 <!--        <table tableName="we_com_staff" domainObjectName="Staff" alias=""/>-->
-<!--        <table tableName="we_com_staff_with_user" domainObjectName="StaffWithUser" alias=""/>-->
+        <table tableName="we_com_staff_with_user" domainObjectName="StaffWithUser" alias=""/>
 <!--        <table tableName="we_com_send_message" domainObjectName="SendMessage" alias=""/>-->