xueyiming hace 6 meses
padre
commit
cc73241363
Se han modificado 39 ficheros con 2561 adiciones y 972 borrados
  1. 1 1
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/RedisConstant.java
  2. 5 15
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/constant/WeComConstant.java
  3. 1 1
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/enums/MessageAttachmentTypeEnum.java
  4. 19 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/common/enums/SubjectEnum.java
  5. 11 8
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/controller/WeComController.java
  6. 0 1
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/dao/mapper/SendMessageMapper.java
  7. 32 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/dao/mapper/SubjectMapper.java
  8. 1 5
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/dao/mapper/UserMapper.java
  9. 43 30
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComHistoryDataJob.java
  10. 72 47
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComMessageDataJob.java
  11. 26 12
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComStaffDataJob.java
  12. 59 75
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComUserDataJob.java
  13. 2 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/bo/XxlJobParam.java
  14. 11 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/HistoryMessage.java
  15. 60 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/HistoryMessageExample.java
  16. 11 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/SendMessage.java
  17. 60 1
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/SendMessageExample.java
  18. 33 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/Staff.java
  19. 200 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/StaffExample.java
  20. 92 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/Subject.java
  21. 662 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/SubjectExample.java
  22. 11 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/User.java
  23. 60 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/po/UserExample.java
  24. 2 0
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/model/vo/GuaranteedParam.java
  25. 1 3
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/AccessTokenService.java
  26. 29 31
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/AccessTokenServiceImpl.java
  27. 3 4
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/MessageAttachmentServiceImpl.java
  28. 3 18
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/MessageServiceImpl.java
  29. 11 9
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/Impl/UserServiceImpl.java
  30. 1 1
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/MessageAttachmentService.java
  31. 1 3
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/MessageService.java
  32. 3 3
      we-com-server/src/main/java/com/tzld/piaoquan/wecom/service/UserService.java
  33. 2 0
      we-com-server/src/main/resources/application-test.properties
  34. 51 35
      we-com-server/src/main/resources/mapper/HistoryMessageMapper.xml
  35. 321 318
      we-com-server/src/main/resources/mapper/SendMessageMapper.xml
  36. 54 6
      we-com-server/src/main/resources/mapper/StaffMapper.xml
  37. 246 0
      we-com-server/src/main/resources/mapper/SubjectMapper.xml
  38. 358 345
      we-com-server/src/main/resources/mapper/UserMapper.xml
  39. 3 0
      we-com-server/src/main/resources/mybatis-generator-config.xml

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

@@ -5,7 +5,7 @@ public interface RedisConstant {
     String PUSH_MESSAGE_TEXT = "push_message_text";
     String ACCESS_TOKEN = "ACCESS_TOKEN";
 
-    String WE_COM_ACCESS_TOKEN = "WE_COM_ACCESS_TOKEN";
+    String WE_COM_ACCESS_TOKEN = "WE_COM_ACCESS_TOKEN_%s";
 
     //小程序保底视频key
     String GUARANTEED_MINI_PROGRAM_KEY = "guaranteed_mini_program_%s";

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

@@ -1,26 +1,16 @@
 package com.tzld.piaoquan.wecom.common.constant;
 
 public interface WeComConstant {
-    String CROP_ID = "1804267877438678017";
-    String SECRET = "9fe05442559750d0cc3e71c5f81217a4";
-    String POST_ACCESS_TOKEN_URL = "https://open.weibanzhushou.com/open-api/access_token/get";
-    //获取用户接口
-    String GET_USER_URL = "https://open.weibanzhushou.com/open-api/external_user/list";
-    //更新用户接口
-    String UPDATE_USER_URL = "https://open.weibanzhushou.com/open-api/external_user/update/list";
-    //获取历史推送接口
-    String GET_HISTORY_DATA_URL = "https://open.weibanzhushou.com/open-api/group_msg/result";
-    //推送消息接口
-    String POST_MESSAGE_PUSH_URL = "https://open.weibanzhushou.com/open-api/group_msg/add";
-    //获取删除用户接口
-    String GET_DELETE_USER_URL = "https://open.weibanzhushou.com/open-api/external_user/list/outflow";
-
-    String GET_WE_COM_ACCESS_TOKEN_URL = "https://qyapi.weixin.qq.com/cgi-bin/gettoken";
 
     String WE_COM_SECRET = "X13JWOI5ud_IsT2RBXGDZmknysLKqZfGdAO8eszA090";
 
     String WE_COM_CROP_ID = "wwa4015dc7d652a21f";
 
+    String POST_MESSAGE_PUSH_URL = "https://open.weibanzhushou.com/open-api/group_msg/add";
+
+    //获取删除用户接口
+    String GET_WE_COM_ACCESS_TOKEN_URL = "https://qyapi.weixin.qq.com/cgi-bin/gettoken";
+
     //获取群发记录列表
     String POST_WE_COM_GROUP_MSG_LIST_URL = "https://qyapi.weixin.qq.com/cgi-bin/externalcontact/get_groupmsg_list_v2";
 

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

@@ -8,7 +8,7 @@ public enum MessageAttachmentTypeEnum {
     DEFAULT(0,"未知"),
     IMAGE(1,"图片"),
     LINK(2,"链接"),
-    MINIPROGRAM(3, "小程序"),
+    MINI_PROGRAM(3, "小程序"),
     VIDEO(4, "视频");
 
     final Integer type;

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

@@ -0,0 +1,19 @@
+package com.tzld.piaoquan.wecom.common.enums;
+
+import lombok.Getter;
+import org.springframework.web.bind.annotation.GetMapping;
+
+@Getter
+public enum SubjectEnum {
+
+    SUBJECT_ENUM_1(1L, "湖南为趣时代");
+
+    final Long id;
+    final String desc;
+
+    SubjectEnum(Long id, String desc) {
+        this.id = id;
+        this.desc = desc;
+    }
+
+}

+ 11 - 8
we-com-server/src/main/java/com/tzld/piaoquan/wecom/controller/WeComController.java

@@ -8,7 +8,10 @@ import com.tzld.piaoquan.wecom.utils.wecom.WxUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.ServletInputStream;
 import javax.servlet.http.HttpServletRequest;
@@ -18,6 +21,8 @@ import java.io.InputStreamReader;
 import java.io.PrintWriter;
 import java.util.Map;
 
+import static com.tzld.piaoquan.wecom.common.enums.SubjectEnum.SUBJECT_ENUM_1;
+
 @Slf4j
 @RestController
 @RequestMapping("/wecom/server")
@@ -79,17 +84,17 @@ public class WeComController {
 
             WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(WeComServerConstant.TOKEN, WeComServerConstant.ENCODING_AES_KEY, id);
 
-            String postData = "";   // 密文,对应POST请求的数据
+            StringBuilder postData = new StringBuilder();   // 密文,对应POST请求的数据
             //1.获取加密的请求消息:使用输入流获得加密请求消息postData
             ServletInputStream in = request.getInputStream();
             BufferedReader reader = new BufferedReader(new InputStreamReader(in));
 
             String tempStr = "";   //作为输出字符串的临时串,用于判断是否读取完毕
             while (null != (tempStr = reader.readLine())) {
-                postData += tempStr;
+                postData.append(tempStr);
             }
 
-            String suiteXml = wxcpt.DecryptMsg(msg_signature, timestamp, nonce, postData);
+            String suiteXml = wxcpt.DecryptMsg(msg_signature, timestamp, nonce, postData.toString());
             log.info("suiteXml: " + suiteXml);
 
             Map suiteMap = WxUtil.transferXmlToMap(suiteXml);
@@ -100,18 +105,16 @@ public class WeComController {
                     String userId = (String) suiteMap.get("UserID");
                     String externalUserId = (String) suiteMap.get("ExternalUserID");
                     log.info("addStaffWithUser userId={} externalUserId={}", userId, externalUserId);
-                    userService.addStaffWithUser(externalUserId, userId);
+                    userService.addStaffWithUser(externalUserId, userId, SUBJECT_ENUM_1.getId());
                 }
 
                 if (StringUtils.isNotEmpty(changeType) && changeType.equals("del_follow_user")) {
                     String userId = (String) suiteMap.get("UserID");
                     String externalUserId = (String) suiteMap.get("ExternalUserID");
                     log.info("delStaffWithUser userId={} externalUserId={}", userId, externalUserId);
-                    userService.delStaffWithUser(externalUserId, userId);
+                    userService.delStaffWithUser(externalUserId, userId, System.currentTimeMillis());
                 }
             }
-
-
         } catch (Exception e) {
             log.error("verifyPost error", e);
         }

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

@@ -5,7 +5,6 @@ import com.tzld.piaoquan.wecom.model.po.SendMessageExample;
 
 import java.util.Date;
 import java.util.List;
-
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 

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

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

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

@@ -1,13 +1,11 @@
 package com.tzld.piaoquan.wecom.dao.mapper;
 
+import java.util.List;
 import com.tzld.piaoquan.wecom.model.po.User;
 import com.tzld.piaoquan.wecom.model.po.UserExample;
-import java.util.List;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
-import java.util.List;
-
 @Repository
 public interface UserMapper {
     long countByExample(UserExample example);
@@ -32,8 +30,6 @@ public interface UserMapper {
 
     int updateByPrimaryKey(User record);
 
-    Long selectIdByExternalUserId3rdParty(String externalUserId3rdParty);
-
     Long selectIdByExternalUserId(String externalUserId);
 
     void insertList(@Param("list") List<User> list);

+ 43 - 30
we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComHistoryDataJob.java

@@ -8,6 +8,7 @@ import com.tzld.piaoquan.wecom.common.enums.MessageAttachmentTypeEnum;
 import com.tzld.piaoquan.wecom.component.HttpPoolClient;
 import com.tzld.piaoquan.wecom.dao.mapper.HistoryMessageMapper;
 import com.tzld.piaoquan.wecom.dao.mapper.StaffMapper;
+import com.tzld.piaoquan.wecom.dao.mapper.SubjectMapper;
 import com.tzld.piaoquan.wecom.dao.mapper.UserMapper;
 import com.tzld.piaoquan.wecom.model.bo.ExternalUser;
 import com.tzld.piaoquan.wecom.model.bo.MiniprogramRecord;
@@ -18,7 +19,6 @@ import com.tzld.piaoquan.wecom.service.AccessTokenService;
 import com.tzld.piaoquan.wecom.service.HistoryMessageService;
 import com.tzld.piaoquan.wecom.service.MessageAttachmentService;
 import com.tzld.piaoquan.wecom.service.UserService;
-import com.tzld.piaoquan.wecom.utils.HttpClientUtil;
 import com.tzld.piaoquan.wecom.utils.LarkRobotUtil;
 import com.tzld.piaoquan.wecom.utils.MessageUtil;
 import com.tzld.piaoquan.wecom.utils.page.Page;
@@ -35,6 +35,7 @@ import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.Objects;
+import java.util.stream.Collectors;
 
 import static com.tzld.piaoquan.wecom.common.constant.MessageConstant.MAX_VIDEO_NUM;
 import static com.tzld.piaoquan.wecom.common.constant.WeComConstant.*;
@@ -67,6 +68,9 @@ public class WeComHistoryDataJob {
     @Autowired
     private UserService userService;
 
+    @Autowired
+    private SubjectMapper subjectMapper;
+
 
     @XxlJob("saveHistoryMessageJob")
     public ReturnT<String> selectHistoryMessageByDay(String param) {
@@ -91,16 +95,26 @@ public class WeComHistoryDataJob {
         }
         Long startTime = xxlJobParam.getStartTime();
         Long endTime = xxlJobParam.getEndTime();
-
-        for (; startTime < endTime; startTime += TimeConstant.DAY) {
-            selectGroupMsgList(startTime, Math.min(startTime + TimeConstant.DAY, endTime));
+        SubjectExample example = new SubjectExample();
+        if (xxlJobParam.getSubjectId() != null) {
+            example.createCriteria().andIdEqualTo(xxlJobParam.getSubjectId());
+        }
+        List<Subject> subjects = subjectMapper.selectByExample(example);
+        if (CollectionUtils.isEmpty(subjects)) {
+            return ReturnT.SUCCESS;
+        }
+        for (Subject subject : subjects) {
+            for (; startTime < endTime; startTime += TimeConstant.DAY) {
+                selectGroupMsgList(startTime, Math.min(startTime + TimeConstant.DAY, endTime), subject.getId());
+            }
+        }
+        for (Subject subject : subjects) {
+            selectAlertHistoryMessage(xxlJobParam.getStartTime(), xxlJobParam.getEndTime(), subject.getId(), subject.getName());
         }
-        selectAlertHistoryMessage(xxlJobParam.getStartTime(), xxlJobParam.getEndTime());
         return ReturnT.SUCCESS;
     }
 
-    private void selectAlertHistoryMessage(Long startTime, Long endTime) {
-
+    private void selectAlertHistoryMessage(Long startTime, Long endTime, Long subjectId, String subjectName) {
         StaffExample staffExample = new StaffExample();
         List<Staff> staffList = staffMapper.selectByExample(staffExample);
         ArrayList<Integer> statusList = Lists.newArrayList(0, 1, 2, 3);
@@ -114,7 +128,8 @@ public class WeComHistoryDataJob {
                 example.createCriteria().andSendTimeBetween(new Date(startTime * 1000), new Date(endTime * 1000))
                         .andStaffIdEqualTo(staff.getId())
                         .andStatusEqualTo(status)
-                        .andIsDeleteEqualTo(0);
+                        .andIsDeleteEqualTo(0)
+                        .andSubjectIdEqualTo(subjectId);
                 long l = historyMessageMapper.countByExample(example);
                 countList.add(l / MAX_VIDEO_NUM);
             }
@@ -122,6 +137,7 @@ public class WeComHistoryDataJob {
             sendDetailList.add(sendDetail);
         }
         StringBuilder stringBuilder = new StringBuilder();
+        stringBuilder.append(subjectName).append("\n");
         for (SendDetail sendDetail : sendDetailList) {
             List<Long> sendCountList = sendDetail.getSendCountList();
             if (CollectionUtils.isEmpty(sendCountList)) {
@@ -139,12 +155,12 @@ public class WeComHistoryDataJob {
         LarkRobotUtil.sendMessage(stringBuilder.toString());
     }
 
-    public void selectGroupMsgList(Long startTime, Long endTime) {
+    private void selectGroupMsgList(Long startTime, Long endTime, Long subjectId) {
         delHistoryMessageList(startTime, endTime);
         try {
             String cursor = "";
             do {
-                String res = getGroupMsgList(startTime, endTime, cursor);
+                String res = getGroupMsgList(startTime, endTime, cursor, subjectId);
                 JSONObject jsonObject = JSONObject.parseObject(res);
                 Integer errCode = jsonObject.getInteger("errcode");
                 if (errCode != 0) {
@@ -189,10 +205,10 @@ public class WeComHistoryDataJob {
                         messageAttachment.setPage(page);
                         messageAttachment.setTitle(title);
                         messageAttachment.setMiniprogramVideoId(videoId);
-                        messageAttachment.setType(MessageAttachmentTypeEnum.MINIPROGRAM.getType());
+                        messageAttachment.setType(MessageAttachmentTypeEnum.MINI_PROGRAM.getType());
                         messageAttachmentList.add(messageAttachment);
                     }
-                    List<String> userIdList = selectGroupMsgTask(msgId);
+                    List<String> userIdList = selectGroupMsgTask(msgId, subjectId);
                     if (CollectionUtils.isEmpty(userIdList)) {
                         continue;
                     }
@@ -204,11 +220,11 @@ public class WeComHistoryDataJob {
                             LarkRobotUtil.sendMessage("企微推送报警:userId不存在请检查 " + userId);
                             continue;
                         }
-                        List<ExternalUser> externalUsers = selectGroupMsgSendResult(msgId, userId);
+                        List<ExternalUser> externalUsers = selectGroupMsgSendResult(msgId, userId, subjectId);
                         if (CollectionUtils.isEmpty(externalUsers)) {
                             continue;
                         }
-                        insertHistoryMessageList(staffList.get(0), externalUsers, miniprogramRecordList, createTime);
+                        insertHistoryMessageList(staffList.get(0), externalUsers, miniprogramRecordList, createTime, subjectId);
                         messageAttachmentService.addMiniProgram(messageAttachmentList);
                     }
                 }
@@ -224,12 +240,11 @@ public class WeComHistoryDataJob {
         }
     }
 
-
-    private List<ExternalUser> selectGroupMsgSendResult(String msgId, String userId) throws IOException {
+    private List<ExternalUser> selectGroupMsgSendResult(String msgId, String userId, Long subjectId) throws IOException {
         List<ExternalUser> resList = new ArrayList<>();
         String cursor = "";
         do {
-            String res = getGroupMsgSendResult(msgId, userId, cursor);
+            String res = getGroupMsgSendResult(msgId, userId, cursor, subjectId);
             JSONObject jsonObject = JSONObject.parseObject(res);
             Integer errCode = jsonObject.getInteger("errcode");
             if (errCode != 0) {
@@ -257,8 +272,8 @@ public class WeComHistoryDataJob {
         return resList;
     }
 
-    private String getGroupMsgSendResult(String msgId, String userId, String cursor) throws IOException {
-        String accessToken = accessTokenService.getWeComAccessToken();
+    private String getGroupMsgSendResult(String msgId, String userId, String cursor, Long subjectId) throws IOException {
+        String accessToken = accessTokenService.getWeComAccessToken(subjectId);
         String url = POST_WE_COM_GROUP_MSG_SEND_RESULT
                 + "?access_token=" + accessToken;
         JSONObject param = new JSONObject();
@@ -271,12 +286,11 @@ public class WeComHistoryDataJob {
         return httpPoolClient.post(url, param.toJSONString());
     }
 
-
-    private List<String> selectGroupMsgTask(String msgId) throws IOException {
+    private List<String> selectGroupMsgTask(String msgId, Long subjectId) throws IOException {
         List<String> resList = new ArrayList<>();
         String cursor = "";
         do {
-            String res = getGroupMsgTask(msgId, cursor);
+            String res = getGroupMsgTask(msgId, cursor, subjectId);
             JSONObject jsonObject = JSONObject.parseObject(res);
             Integer errCode = jsonObject.getInteger("errcode");
             if (errCode != 0) {
@@ -299,8 +313,8 @@ public class WeComHistoryDataJob {
         return resList;
     }
 
-    private String getGroupMsgTask(String msgId, String cursor) throws IOException {
-        String accessToken = accessTokenService.getWeComAccessToken();
+    private String getGroupMsgTask(String msgId, String cursor, Long subjectId) throws IOException {
+        String accessToken = accessTokenService.getWeComAccessToken(subjectId);
         String url = POST_WE_COM_GROUP_MSG_TASK
                 + "?access_token=" + accessToken;
         JSONObject param = new JSONObject();
@@ -317,12 +331,11 @@ public class WeComHistoryDataJob {
         historyMessage.setIsDelete(1);
         HistoryMessageExample example = new HistoryMessageExample();
         example.createCriteria().andSendTimeBetween(new Date(startTime * 1000), new Date(endTime * 1000));
-        historyMessageMapper.updateByExample(historyMessage, example);
+        historyMessageMapper.updateByExampleSelective(historyMessage, example);
 
     }
 
-
-    private void insertHistoryMessageList(Staff staff, List<ExternalUser> externalUsers, List<MiniprogramRecord> miniprogramRecordList, Long createTime) {
+    private void insertHistoryMessageList(Staff staff, List<ExternalUser> externalUsers, List<MiniprogramRecord> miniprogramRecordList, Long createTime, Long subjectId) {
         if (CollectionUtils.isEmpty(externalUsers) || CollectionUtils.isEmpty(miniprogramRecordList)) {
             return;
         }
@@ -350,6 +363,7 @@ public class WeComHistoryDataJob {
                 historyMessage.setUserId(userId);
                 historyMessage.setStaffId(staff.getId());
                 historyMessage.setStatus(status);
+                historyMessage.setSubjectId(subjectId);
                 historyMessageList.add(historyMessage);
                 if (status == 2) {
                     userService.delStaffWithUser(userId, staff.getId(), sendTime);
@@ -359,9 +373,8 @@ public class WeComHistoryDataJob {
         historyMessageService.batchInsertHistoryMessage(historyMessageList);
     }
 
-
-    private String getGroupMsgList(Long startTime, Long endTime, String cursor) throws IOException {
-        String accessToken = accessTokenService.getWeComAccessToken();
+    private String getGroupMsgList(Long startTime, Long endTime, String cursor, Long subjectId) throws IOException {
+        String accessToken = accessTokenService.getWeComAccessToken(subjectId);
         String url = POST_WE_COM_GROUP_MSG_LIST_URL
                 + "?access_token=" + accessToken;
         JSONObject param = new JSONObject();

+ 72 - 47
we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComMessageDataJob.java

@@ -61,7 +61,10 @@ public class WeComMessageDataJob {
     private StaffMapper staffMapper;
 
     @Autowired
-    SendMessageMapper sendMessageMapper;
+    private SendMessageMapper sendMessageMapper;
+
+    @Autowired
+    private SubjectMapper subjectMapper;
 
 
     //发送小程序标题限制字节数
@@ -75,27 +78,26 @@ public class WeComMessageDataJob {
     Map<String, String> pageMap = new HashMap<>();
 
     //初始化操作
-    void init() {
+    private void init() {
         //历史优质视频获取
-        String sql = String.format("SELECT * FROM loghubods.history_good_video_can_push_user_list where dt = %s;",
-                DateUtil.getBeforeDayDateString());
-        List<Record> recordList = OdpsUtil.getOdpsData(sql);
-        if (CollectionUtils.isEmpty(recordList)) {
-            return;
-        }
+//        String sql = String.format("SELECT * FROM loghubods.history_good_video_can_push_user_list where dt = %s;",
+//                DateUtil.getBeforeDayDateString());
+//        List<Record> recordList = OdpsUtil.getOdpsData(sql);
+//        if (CollectionUtils.isEmpty(recordList)) {
+//            return;
+//        }
         List<PushMessage> list = new ArrayList<>();
-        for (Record record : recordList) {
-            PushMessage pushMessage = new PushMessage();
-            Long videoId = Long.parseLong((String) record.get(0));
-            Set<Long> userIds = new HashSet<>(JSONObject.parseArray((String) record.get(1), Long.class));
-            pushMessage.setVideoId(videoId);
-            pushMessage.setUserIds(userIds);
-            list.add(pushMessage);
-        }
+//        for (Record record : recordList) {
+//            PushMessage pushMessage = new PushMessage();
+//            Long videoId = Long.parseLong((String) record.get(0));
+//            Set<Long> userIds = new HashSet<>(JSONObject.parseArray((String) record.get(1), Long.class));
+//            pushMessage.setVideoId(videoId);
+//            pushMessage.setUserIds(userIds);
+//            list.add(pushMessage);
+//        }
         goodHistoryPushList = list;
 
         //保底视频获取
-
         String key = String.format(GUARANTEED_MINI_PROGRAM_KEY, DateUtil.getThatDayDateString());
         GuaranteedParam guaranteedParam = (GuaranteedParam) redisTemplate.opsForValue().get(key);
         if (guaranteedParam == null
@@ -144,34 +146,46 @@ public class WeComMessageDataJob {
             xxlJobParam = JSONObject.parseObject(param, XxlJobParam.class);
         }
         init();
-        Long staffId = null;
-        if (xxlJobParam != null && xxlJobParam.getStaffId() != null) {
-            staffId = xxlJobParam.getStaffId();
+        SubjectExample subjectExample = new SubjectExample();
+        if (xxlJobParam.getSubjectId() != null) {
+            subjectExample.createCriteria().andIdEqualTo(xxlJobParam.getSubjectId());
         }
-        UserExample example = new UserExample();
-        example.createCriteria().andExternalUserIdIsNotNull();
-        if (xxlJobParam != null && xxlJobParam.getUserId() != null) {
-            example.createCriteria().andIdEqualTo(xxlJobParam.getUserId());
+        List<Subject> subjects = subjectMapper.selectByExample(subjectExample);
+        if (CollectionUtils.isEmpty(subjects)) {
+            return ReturnT.SUCCESS;
         }
-        long count = userMapper.countByExample(example);
-        int page = 1;
-        int pageSize = 1000;
-        long totalPageSize = count / pageSize + 1;
-        for (; page <= totalPageSize; page++) {
-            example.setPage(new Page<>(page, pageSize));
-            List<User> userList = userMapper.selectByExample(example);
-            if (CollectionUtils.isEmpty(userList)) {
-                continue;
+        for (Subject subject : subjects) {
+            Long staffId = null;
+            if (xxlJobParam.getStaffId() != null) {
+                staffId = xxlJobParam.getStaffId();
             }
-            //落库逻辑
-            List<SendMessage> allSeneMessageList = new ArrayList<>();
-            for (User user : userList) {
-                List<SendMessage> sendMessageList = getSendMessage(user, staffId);
-                if (!CollectionUtils.isEmpty(sendMessageList)) {
+            UserExample userExample = new UserExample();
+            userExample.createCriteria().andExternalUserIdIsNotNull().andSubjectIdEqualTo(subject.getId());
+            if (xxlJobParam.getUserId() != null) {
+                userExample.createCriteria().andIdEqualTo(xxlJobParam.getUserId());
+            }
+            long count = userMapper.countByExample(userExample);
+            int page = 1;
+            int pageSize = 1000;
+            long totalPageSize = count / pageSize + 1;
+            for (; page <= totalPageSize; page++) {
+                userExample.setPage(new Page<>(page, pageSize));
+                List<User> userList = userMapper.selectByExample(userExample);
+                if (CollectionUtils.isEmpty(userList)) {
+                    continue;
+                }
+                //落库逻辑
+                List<SendMessage> allSeneMessageList = new ArrayList<>();
+                for (User user : userList) {
+                    List<SendMessage> sendMessageList = getSendMessage(user, staffId, subject.getId());
+                    if (CollectionUtils.isEmpty(sendMessageList)) {
+                        continue;
+                    }
                     allSeneMessageList.addAll(sendMessageList);
                 }
-            }
-            if (!CollectionUtils.isEmpty(allSeneMessageList)) {
+                if (CollectionUtils.isEmpty(allSeneMessageList)) {
+                    continue;
+                }
                 sendMessageMapper.insertList(allSeneMessageList);
             }
         }
@@ -180,7 +194,7 @@ public class WeComMessageDataJob {
         return ReturnT.SUCCESS;
     }
 
-    public void saveGuaranteedVideoIdList() {
+    private void saveGuaranteedVideoIdList() {
         String key = String.format(GUARANTEED_MINI_PROGRAM_KEY, DateUtil.getThatDayDateString());
         GuaranteedParam guaranteedParam = (GuaranteedParam) redisTemplate.opsForValue().get(key);
         if (guaranteedParam == null || CollectionUtils.isEmpty(guaranteedParam.getVideoParamList())) {
@@ -206,7 +220,7 @@ public class WeComMessageDataJob {
         redisTemplate.delete(key);
     }
 
-    public List<SendMessage> getSendMessage(User user, Long staffId) {
+    private List<SendMessage> getSendMessage(User user, Long staffId, Long subjectId) {
         StaffWithUserExample example = new StaffWithUserExample();
         StaffWithUserExample.Criteria criteria = example.createCriteria();
         criteria.andUserIdEqualTo(user.getId());
@@ -269,6 +283,7 @@ public class WeComMessageDataJob {
                 LarkRobotUtil.sendMessage("组装数据失败 user=" + user);
                 throw new RuntimeException();
             }
+            sendMessage.setSubjectId(subjectId);
             sendMessage.setStaffId(staffWithUser.getStaffId());
             sendMessage.setUserId(staffWithUser.getUserId());
             sendMessageList.add(sendMessage);
@@ -279,9 +294,18 @@ public class WeComMessageDataJob {
 
     @XxlJob("pushSendMessageJob")
     public ReturnT<String> pushSendMessage(String param) {
-        List<SendMessage> groupList = sendMessageMapper.getGroupList(DateUtil.getThatDayDate(), 0);
+        XxlJobParam xxlJobParam = new XxlJobParam();
         if (StringUtils.isNotEmpty(param)) {
-            groupList = groupList.stream().filter(e -> e.getStaffId() == Long.parseLong(param)).collect(Collectors.toList());
+            xxlJobParam = JSONObject.parseObject(param, XxlJobParam.class);
+        }
+        List<SendMessage> groupList = sendMessageMapper.getGroupList(DateUtil.getThatDayDate(), 0);
+        if (xxlJobParam.getSubjectId() != null) {
+            Long subjectId = xxlJobParam.getSubjectId();
+            groupList = groupList.stream().filter(e -> Objects.equals(e.getStaffId(), subjectId)).collect(Collectors.toList());
+        }
+        if (xxlJobParam.getStaffId() != null) {
+            Long staffId = xxlJobParam.getStaffId();
+            groupList = groupList.stream().filter(e -> Objects.equals(e.getStaffId(), staffId)).collect(Collectors.toList());
         }
         if (CollectionUtils.isEmpty(groupList)) {
             return ReturnT.SUCCESS;
@@ -309,7 +333,7 @@ public class WeComMessageDataJob {
     }
 
 
-    public boolean pushMessage(List<String> sendUserList, SendMessage sendMessage) {
+    private boolean pushMessage(List<String> sendUserList, SendMessage sendMessage) {
         List<JSONObject> pushList = new ArrayList<>();
         StaffExample staffExample = new StaffExample();
         staffExample.createCriteria().andIdEqualTo(sendMessage.getStaffId());
@@ -334,6 +358,7 @@ public class WeComMessageDataJob {
             example.createCriteria().andMiniprogramVideoIdEqualTo(videoId);
             List<MessageAttachment> messageAttachmentList = messageAttachmentMapper.selectByExample(example);
             if (CollectionUtils.isEmpty(messageAttachmentList)) {
+                System.out.println(videoId);
                 throw new RuntimeException("附件信息查询异常");
             }
             MessageAttachment messageAttachment = messageAttachmentList.get(0);
@@ -344,7 +369,7 @@ public class WeComMessageDataJob {
                 title = ToolUtils.truncateString(title, MAX_BYTES - 3) + "...";
             }
             miniprogram.put("title", title);
-            String picMediaId = messageAttachmentService.getPicMediaId(messageAttachment.getCover());
+            String picMediaId = messageAttachmentService.getPicMediaId(messageAttachment.getCover(), sendMessage.getSubjectId());
             if (StringUtils.isEmpty(picMediaId)) {
                 log.error("pushMessage getPicMediaId error cover={}", messageAttachment.getCover());
                 return false;
@@ -380,7 +405,7 @@ public class WeComMessageDataJob {
         }
         for (JSONObject pushJsonObject : pushList) {
             log.info("pushMessage pushJsonObject={}", pushJsonObject);
-            boolean flag = messageService.pushWeComMessage(pushJsonObject);
+            boolean flag = messageService.pushWeComMessage(pushJsonObject, sendMessage.getSubjectId());
             if (!flag) {
                 return flag;
             }

+ 26 - 12
we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComStaffDataJob.java

@@ -3,8 +3,11 @@ package com.tzld.piaoquan.wecom.job;
 import com.alibaba.fastjson.JSONObject;
 import com.tzld.piaoquan.wecom.component.HttpPoolClient;
 import com.tzld.piaoquan.wecom.dao.mapper.StaffMapper;
+import com.tzld.piaoquan.wecom.dao.mapper.SubjectMapper;
 import com.tzld.piaoquan.wecom.model.po.Staff;
 import com.tzld.piaoquan.wecom.model.po.StaffExample;
+import com.tzld.piaoquan.wecom.model.po.Subject;
+import com.tzld.piaoquan.wecom.model.po.SubjectExample;
 import com.tzld.piaoquan.wecom.service.AccessTokenService;
 import com.tzld.piaoquan.wecom.utils.HttpClientUtil;
 import com.tzld.piaoquan.wecom.utils.LarkRobotUtil;
@@ -34,19 +37,30 @@ public class WeComStaffDataJob {
     @Autowired
     private StaffMapper staffMapper;
 
+    @Autowired
+    private SubjectMapper subjectMapper;
+
     @XxlJob("insertStaffJob")
     public ReturnT<String> insertStaff(String param) {
         try {
-            List<String> carrierIdList = getCarrierIdList();
-            for (String carrierId : carrierIdList) {
-                StaffExample example = new StaffExample();
-                example.createCriteria().andCarrierIdEqualTo(carrierId);
-                List<Staff> staffList = staffMapper.selectByExample(example);
-                if (CollectionUtils.isEmpty(staffList)) {
-                    Staff staff = new Staff();
-                    staff.setCarrierId(carrierId);
-                    staff.setRemark("");
-                    staffMapper.insert(staff);
+            SubjectExample subjectExample = new SubjectExample();
+            List<Subject> subjects = subjectMapper.selectByExample(subjectExample);
+            if (CollectionUtils.isEmpty(subjects)) {
+                return ReturnT.SUCCESS;
+            }
+            for (Subject subject : subjects) {
+                List<String> carrierIdList = getCarrierIdList(subject.getId());
+                for (String carrierId : carrierIdList) {
+                    StaffExample example = new StaffExample();
+                    example.createCriteria().andCarrierIdEqualTo(carrierId).andSubjectIdEqualTo(subject.getId());
+                    List<Staff> staffList = staffMapper.selectByExample(example);
+                    if (CollectionUtils.isEmpty(staffList)) {
+                        Staff staff = new Staff();
+                        staff.setSubjectId(subject.getId());
+                        staff.setCarrierId(carrierId);
+                        staff.setRemark("");
+                        staffMapper.insert(staff);
+                    }
                 }
             }
         } catch (Exception e) {
@@ -56,8 +70,8 @@ public class WeComStaffDataJob {
         return ReturnT.SUCCESS;
     }
 
-    public List<String> getCarrierIdList() throws IOException {
-        String weComAccessToken = accessTokenService.getWeComAccessToken();
+    private List<String> getCarrierIdList(Long subjectId) throws IOException {
+        String weComAccessToken = accessTokenService.getWeComAccessToken(subjectId);
         String url = String.format(GET_WE_COM_FOLLOW_USER_LIST + "?access_token=%s", weComAccessToken);
         String res = httpPoolClient.get(url);
         JSONObject jsonObject = JSONObject.parseObject(res);

+ 59 - 75
we-com-server/src/main/java/com/tzld/piaoquan/wecom/job/WeComUserDataJob.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
 import com.tzld.piaoquan.wecom.component.HttpPoolClient;
 import com.tzld.piaoquan.wecom.dao.mapper.StaffMapper;
 import com.tzld.piaoquan.wecom.dao.mapper.StaffWithUserMapper;
+import com.tzld.piaoquan.wecom.dao.mapper.SubjectMapper;
 import com.tzld.piaoquan.wecom.dao.mapper.UserMapper;
 import com.tzld.piaoquan.wecom.model.bo.XxlJobParam;
 import com.tzld.piaoquan.wecom.model.po.*;
@@ -33,41 +34,61 @@ public class WeComUserDataJob {
 
     @Autowired
     private HttpPoolClient httpPoolClient;
+
     @Autowired
     private StaffMapper staffMapper;
+
     @Autowired
     private UserMapper userMapper;
+
     @Autowired
     private AccessTokenService accessTokenService;
+
     @Autowired
     private StaffWithUserMapper staffWithUserMapper;
+
     @Autowired
     private UserService userService;
 
+    @Autowired
+    private SubjectMapper subjectMapper;
+
     @XxlJob("updateStaffWithUserJob")
     public ReturnT<String> updateStaffWithUser(String param) {
         XxlJobParam xxlJobParam = new XxlJobParam();
         if (StringUtils.isNotEmpty(param)) {
             xxlJobParam = JSONObject.parseObject(param, XxlJobParam.class);
         }
-        StaffExample example = new StaffExample();
-        StaffExample.Criteria criteria = example.createCriteria();
-        if (xxlJobParam.getStaffId() != null) {
-            criteria.andIdEqualTo(xxlJobParam.getStaffId());
+        SubjectExample subjectExample = new SubjectExample();
+        SubjectExample.Criteria subjectCriteria = subjectExample.createCriteria();
+        if (xxlJobParam.getSubjectId() != null) {
+            subjectCriteria.andIdEqualTo(xxlJobParam.getSubjectId());
         }
-        List<Staff> staffList = staffMapper.selectByExample(example);
-        for (Staff staff : staffList) {
-            updateUserList(staff);
+        List<Subject> subjects = subjectMapper.selectByExample(subjectExample);
+        for (Subject subject : subjects) {
+            StaffExample staffExample = new StaffExample();
+            StaffExample.Criteria staffCriteria = staffExample.createCriteria();
+            staffCriteria.andSubjectIdEqualTo(subject.getId());
+            if (xxlJobParam.getStaffId() != null) {
+                staffCriteria.andIdEqualTo(xxlJobParam.getStaffId());
+            }
+            List<Staff> staffList = staffMapper.selectByExample(staffExample);
+            if (CollectionUtils.isEmpty(staffList)) {
+                continue;
+            }
+            for (Staff staff : staffList) {
+                updateUserList(staff, subject.getId());
+            }
         }
         return ReturnT.SUCCESS;
     }
 
 
-    private void updateUserList(Staff staff) {
+    private void updateUserList(Staff staff, Long subjectId) {
         try {
             String cursor = "";
             do {
-                String res = getUserDetailList(staff.getCarrierId(), cursor);
+                String res = getUserDetailList(staff.getCarrierId(), cursor, subjectId);
                 log.info("updateUserList res={} cursor={}", res, cursor);
                 JSONObject jsonObject = JSONObject.parseObject(res);
                 Integer errCode = jsonObject.getInteger("errcode");
@@ -132,8 +153,8 @@ public class WeComUserDataJob {
         }
     }
 
-    private String getUserDetailList(String userId, String cursor) throws IOException {
-        String accessToken = accessTokenService.getWeComAccessToken();
+    private String getUserDetailList(String userId, String cursor, Long subjectId) throws IOException {
+        String accessToken = accessTokenService.getWeComAccessToken(subjectId);
         String url = POST_WE_COM_GET_BY_USER
                 + "?access_token=" + accessToken;
         JSONObject param = new JSONObject();
@@ -150,15 +171,32 @@ public class WeComUserDataJob {
     @XxlJob("insertStaffWithUserJob")
     public ReturnT<String> insertStaffWithUserJob(String param) {
         try {
-            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;
+            XxlJobParam xxlJobParam = new XxlJobParam();
+            if (StringUtils.isNotEmpty(param)) {
+                xxlJobParam = JSONObject.parseObject(param, XxlJobParam.class);
+            }
+            SubjectExample subjectExample = new SubjectExample();
+            SubjectExample.Criteria subjectCriteria = subjectExample.createCriteria();
+            if (xxlJobParam.getSubjectId() != null) {
+                subjectCriteria.andIdEqualTo(xxlJobParam.getSubjectId());
+            }
+            List<Subject> subjects = subjectMapper.selectByExample(subjectExample);
+            for (Subject subject : subjects) {
+                StaffExample staffExample = new StaffExample();
+                StaffExample.Criteria staffCriteria = staffExample.createCriteria();
+                staffCriteria.andSubjectIdEqualTo(subject.getId());
+                if (xxlJobParam.getStaffId() != null) {
+                    staffCriteria.andIdEqualTo(xxlJobParam.getStaffId());
                 }
-                for (String externalUserId : externalUserIds) {
-                    userService.insertStaffWithUser(externalUserId, staff);
+                List<Staff> staffList = staffMapper.selectByExample(staffExample);
+                for (Staff staff : staffList) {
+                    List<String> externalUserIds = getUserList(staff.getCarrierId(), subject.getId());
+                    if (CollectionUtils.isEmpty(externalUserIds)) {
+                        continue;
+                    }
+                    for (String externalUserId : externalUserIds) {
+                        userService.insertStaffWithUser(externalUserId, staff, subject.getId());
+                    }
                 }
             }
         } catch (Exception e) {
@@ -170,8 +208,8 @@ public class WeComUserDataJob {
 
     }
 
-    public List<String> getUserList(String userId) throws IOException {
-        String weComAccessToken = accessTokenService.getWeComAccessToken();
+    public List<String> getUserList(String userId, Long subjectId) throws IOException {
+        String weComAccessToken = accessTokenService.getWeComAccessToken(subjectId);
         String url = String.format(GET_WE_COM_EXTERNAL_CONTACT_LIST + "?access_token=%s&userid=%s", weComAccessToken, userId);
         String res = httpPoolClient.get(url);
         JSONObject jsonObject = JSONObject.parseObject(res);
@@ -181,58 +219,4 @@ public class WeComUserDataJob {
         }
         return null;
     }
-
-
-    @XxlJob("setExternalUserIdJob")
-    public ReturnT<String> setExternalUserId(String param) {
-        try {
-            UserExample example = new UserExample();
-            if (StringUtils.isNotEmpty(param)) {
-                example.createCriteria().andIdGreaterThanOrEqualTo(Long.parseLong(param));
-            }
-            long count = userMapper.countByExample(example);
-            int page = 1;
-            int pageSize = 1000;
-            long totalPageSize = count / pageSize + 1;
-            for (; page <= totalPageSize; page++) {
-                example.setPage(new Page<>(page, pageSize));
-                List<User> userList = userMapper.selectByExample(example);
-                if (CollectionUtils.isEmpty(userList)) {
-                    continue;
-                }
-                for (User user : userList) {
-                    String externalUserId3rdParty = user.getExternalUserId3rdParty();
-                    String externalUserId = getExternalUserId(externalUserId3rdParty);
-                    if (StringUtils.isEmpty(externalUserId)) {
-                        continue;
-                    }
-                    User updateUser = new User();
-                    updateUser.setId(user.getId());
-                    updateUser.setExternalUserId(externalUserId);
-                    userMapper.updateByPrimaryKeySelective(updateUser);
-                }
-            }
-        } catch (Exception e) {
-            log.error("setExternalUserId error", e);
-        }
-
-        return ReturnT.SUCCESS;
-    }
-
-    public String getExternalUserId(String externalUserId3rdParty) throws IOException {
-        String weComAccessToken = accessTokenService.getWeComAccessToken();
-        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);
-        String res = httpPoolClient.post(url, param.toJSONString());
-        JSONObject jsonObject = JSONObject.parseObject(res);
-        Integer errcode = jsonObject.getInteger("errcode");
-        if (errcode == 0) {
-            return jsonObject.getString("external_userid");
-        }
-        return null;
-    }
-
-
 }

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

@@ -5,6 +5,8 @@ import lombok.Data;
 @Data
 public class XxlJobParam {
 
+    private Long subjectId;
+
     private Long startTime;
 
     private Long endTime;

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

@@ -5,6 +5,8 @@ import java.util.Date;
 public class HistoryMessage {
     private Long id;
 
+    private Long subjectId;
+
     private Long userId;
 
     private Long staffId;
@@ -31,6 +33,14 @@ public class HistoryMessage {
         this.id = id;
     }
 
+    public Long getSubjectId() {
+        return subjectId;
+    }
+
+    public void setSubjectId(Long subjectId) {
+        this.subjectId = subjectId;
+    }
+
     public Long getUserId() {
         return userId;
     }
@@ -110,6 +120,7 @@ public class HistoryMessage {
         sb.append(" [");
         sb.append("Hash = ").append(hashCode());
         sb.append(", id=").append(id);
+        sb.append(", subjectId=").append(subjectId);
         sb.append(", userId=").append(userId);
         sb.append(", staffId=").append(staffId);
         sb.append(", videoId=").append(videoId);

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

@@ -176,6 +176,66 @@ public class HistoryMessageExample {
             return (Criteria) this;
         }
 
+        public Criteria andSubjectIdIsNull() {
+            addCriterion("subject_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdIsNotNull() {
+            addCriterion("subject_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdEqualTo(Long value) {
+            addCriterion("subject_id =", value, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdNotEqualTo(Long value) {
+            addCriterion("subject_id <>", value, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdGreaterThan(Long value) {
+            addCriterion("subject_id >", value, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("subject_id >=", value, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdLessThan(Long value) {
+            addCriterion("subject_id <", value, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdLessThanOrEqualTo(Long value) {
+            addCriterion("subject_id <=", value, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdIn(List<Long> values) {
+            addCriterion("subject_id in", values, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdNotIn(List<Long> values) {
+            addCriterion("subject_id not in", values, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdBetween(Long value1, Long value2) {
+            addCriterion("subject_id between", value1, value2, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdNotBetween(Long value1, Long value2) {
+            addCriterion("subject_id not between", value1, value2, "subjectId");
+            return (Criteria) this;
+        }
+
         public Criteria andUserIdIsNull() {
             addCriterion("user_id is null");
             return (Criteria) this;

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

@@ -5,6 +5,8 @@ import java.util.Date;
 public class SendMessage {
     private Long id;
 
+    private Long subjectId;
+
     private Long staffId;
 
     private Long userId;
@@ -29,6 +31,14 @@ public class SendMessage {
         this.id = id;
     }
 
+    public Long getSubjectId() {
+        return subjectId;
+    }
+
+    public void setSubjectId(Long subjectId) {
+        this.subjectId = subjectId;
+    }
+
     public Long getStaffId() {
         return staffId;
     }
@@ -100,6 +110,7 @@ public class SendMessage {
         sb.append(" [");
         sb.append("Hash = ").append(hashCode());
         sb.append(", id=").append(id);
+        sb.append(", subjectId=").append(subjectId);
         sb.append(", staffId=").append(staffId);
         sb.append(", userId=").append(userId);
         sb.append(", videoId1=").append(videoId1);

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

@@ -1,7 +1,6 @@
 package com.tzld.piaoquan.wecom.model.po;
 
 import com.tzld.piaoquan.wecom.utils.page.Page;
-
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -177,6 +176,66 @@ public class SendMessageExample {
             return (Criteria) this;
         }
 
+        public Criteria andSubjectIdIsNull() {
+            addCriterion("subject_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdIsNotNull() {
+            addCriterion("subject_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdEqualTo(Long value) {
+            addCriterion("subject_id =", value, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdNotEqualTo(Long value) {
+            addCriterion("subject_id <>", value, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdGreaterThan(Long value) {
+            addCriterion("subject_id >", value, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("subject_id >=", value, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdLessThan(Long value) {
+            addCriterion("subject_id <", value, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdLessThanOrEqualTo(Long value) {
+            addCriterion("subject_id <=", value, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdIn(List<Long> values) {
+            addCriterion("subject_id in", values, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdNotIn(List<Long> values) {
+            addCriterion("subject_id not in", values, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdBetween(Long value1, Long value2) {
+            addCriterion("subject_id between", value1, value2, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdNotBetween(Long value1, Long value2) {
+            addCriterion("subject_id not between", value1, value2, "subjectId");
+            return (Criteria) this;
+        }
+
         public Criteria andStaffIdIsNull() {
             addCriterion("staff_id is null");
             return (Criteria) this;

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

@@ -5,12 +5,18 @@ import java.util.Date;
 public class Staff {
     private Long id;
 
+    private Long subjectId;
+
     private String staffExtId;
 
     private String carrierId;
 
     private String remark;
 
+    private String category1;
+
+    private String category2;
+
     private Integer isDelete;
 
     private Date createTime;
@@ -25,6 +31,14 @@ public class Staff {
         this.id = id;
     }
 
+    public Long getSubjectId() {
+        return subjectId;
+    }
+
+    public void setSubjectId(Long subjectId) {
+        this.subjectId = subjectId;
+    }
+
     public String getStaffExtId() {
         return staffExtId;
     }
@@ -49,6 +63,22 @@ public class Staff {
         this.remark = remark;
     }
 
+    public String getCategory1() {
+        return category1;
+    }
+
+    public void setCategory1(String category1) {
+        this.category1 = category1;
+    }
+
+    public String getCategory2() {
+        return category2;
+    }
+
+    public void setCategory2(String category2) {
+        this.category2 = category2;
+    }
+
     public Integer getIsDelete() {
         return isDelete;
     }
@@ -80,9 +110,12 @@ public class Staff {
         sb.append(" [");
         sb.append("Hash = ").append(hashCode());
         sb.append(", id=").append(id);
+        sb.append(", subjectId=").append(subjectId);
         sb.append(", staffExtId=").append(staffExtId);
         sb.append(", carrierId=").append(carrierId);
         sb.append(", remark=").append(remark);
+        sb.append(", category1=").append(category1);
+        sb.append(", category2=").append(category2);
         sb.append(", isDelete=").append(isDelete);
         sb.append(", createTime=").append(createTime);
         sb.append(", updateTime=").append(updateTime);

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

@@ -176,6 +176,66 @@ public class StaffExample {
             return (Criteria) this;
         }
 
+        public Criteria andSubjectIdIsNull() {
+            addCriterion("subject_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdIsNotNull() {
+            addCriterion("subject_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdEqualTo(Long value) {
+            addCriterion("subject_id =", value, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdNotEqualTo(Long value) {
+            addCriterion("subject_id <>", value, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdGreaterThan(Long value) {
+            addCriterion("subject_id >", value, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("subject_id >=", value, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdLessThan(Long value) {
+            addCriterion("subject_id <", value, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdLessThanOrEqualTo(Long value) {
+            addCriterion("subject_id <=", value, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdIn(List<Long> values) {
+            addCriterion("subject_id in", values, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdNotIn(List<Long> values) {
+            addCriterion("subject_id not in", values, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdBetween(Long value1, Long value2) {
+            addCriterion("subject_id between", value1, value2, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdNotBetween(Long value1, Long value2) {
+            addCriterion("subject_id not between", value1, value2, "subjectId");
+            return (Criteria) this;
+        }
+
         public Criteria andStaffExtIdIsNull() {
             addCriterion("staff_ext_id is null");
             return (Criteria) this;
@@ -386,6 +446,146 @@ public class StaffExample {
             return (Criteria) this;
         }
 
+        public Criteria andCategory1IsNull() {
+            addCriterion("category1 is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCategory1IsNotNull() {
+            addCriterion("category1 is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCategory1EqualTo(String value) {
+            addCriterion("category1 =", value, "category1");
+            return (Criteria) this;
+        }
+
+        public Criteria andCategory1NotEqualTo(String value) {
+            addCriterion("category1 <>", value, "category1");
+            return (Criteria) this;
+        }
+
+        public Criteria andCategory1GreaterThan(String value) {
+            addCriterion("category1 >", value, "category1");
+            return (Criteria) this;
+        }
+
+        public Criteria andCategory1GreaterThanOrEqualTo(String value) {
+            addCriterion("category1 >=", value, "category1");
+            return (Criteria) this;
+        }
+
+        public Criteria andCategory1LessThan(String value) {
+            addCriterion("category1 <", value, "category1");
+            return (Criteria) this;
+        }
+
+        public Criteria andCategory1LessThanOrEqualTo(String value) {
+            addCriterion("category1 <=", value, "category1");
+            return (Criteria) this;
+        }
+
+        public Criteria andCategory1Like(String value) {
+            addCriterion("category1 like", value, "category1");
+            return (Criteria) this;
+        }
+
+        public Criteria andCategory1NotLike(String value) {
+            addCriterion("category1 not like", value, "category1");
+            return (Criteria) this;
+        }
+
+        public Criteria andCategory1In(List<String> values) {
+            addCriterion("category1 in", values, "category1");
+            return (Criteria) this;
+        }
+
+        public Criteria andCategory1NotIn(List<String> values) {
+            addCriterion("category1 not in", values, "category1");
+            return (Criteria) this;
+        }
+
+        public Criteria andCategory1Between(String value1, String value2) {
+            addCriterion("category1 between", value1, value2, "category1");
+            return (Criteria) this;
+        }
+
+        public Criteria andCategory1NotBetween(String value1, String value2) {
+            addCriterion("category1 not between", value1, value2, "category1");
+            return (Criteria) this;
+        }
+
+        public Criteria andCategory2IsNull() {
+            addCriterion("category2 is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCategory2IsNotNull() {
+            addCriterion("category2 is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCategory2EqualTo(String value) {
+            addCriterion("category2 =", value, "category2");
+            return (Criteria) this;
+        }
+
+        public Criteria andCategory2NotEqualTo(String value) {
+            addCriterion("category2 <>", value, "category2");
+            return (Criteria) this;
+        }
+
+        public Criteria andCategory2GreaterThan(String value) {
+            addCriterion("category2 >", value, "category2");
+            return (Criteria) this;
+        }
+
+        public Criteria andCategory2GreaterThanOrEqualTo(String value) {
+            addCriterion("category2 >=", value, "category2");
+            return (Criteria) this;
+        }
+
+        public Criteria andCategory2LessThan(String value) {
+            addCriterion("category2 <", value, "category2");
+            return (Criteria) this;
+        }
+
+        public Criteria andCategory2LessThanOrEqualTo(String value) {
+            addCriterion("category2 <=", value, "category2");
+            return (Criteria) this;
+        }
+
+        public Criteria andCategory2Like(String value) {
+            addCriterion("category2 like", value, "category2");
+            return (Criteria) this;
+        }
+
+        public Criteria andCategory2NotLike(String value) {
+            addCriterion("category2 not like", value, "category2");
+            return (Criteria) this;
+        }
+
+        public Criteria andCategory2In(List<String> values) {
+            addCriterion("category2 in", values, "category2");
+            return (Criteria) this;
+        }
+
+        public Criteria andCategory2NotIn(List<String> values) {
+            addCriterion("category2 not in", values, "category2");
+            return (Criteria) this;
+        }
+
+        public Criteria andCategory2Between(String value1, String value2) {
+            addCriterion("category2 between", value1, value2, "category2");
+            return (Criteria) this;
+        }
+
+        public Criteria andCategory2NotBetween(String value1, String value2) {
+            addCriterion("category2 not between", value1, value2, "category2");
+            return (Criteria) this;
+        }
+
         public Criteria andIsDeleteIsNull() {
             addCriterion("is_delete is null");
             return (Criteria) this;

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

@@ -0,0 +1,92 @@
+package com.tzld.piaoquan.wecom.model.po;
+
+import java.util.Date;
+
+public class Subject {
+    private Long id;
+
+    private String name;
+
+    private String cropId;
+
+    private String secret;
+
+    private Integer isDelete;
+
+    private Date createTime;
+
+    private Date updateTime;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getCropId() {
+        return cropId;
+    }
+
+    public void setCropId(String cropId) {
+        this.cropId = cropId;
+    }
+
+    public String getSecret() {
+        return secret;
+    }
+
+    public void setSecret(String secret) {
+        this.secret = secret;
+    }
+
+    public Integer getIsDelete() {
+        return isDelete;
+    }
+
+    public void setIsDelete(Integer isDelete) {
+        this.isDelete = isDelete;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", id=").append(id);
+        sb.append(", name=").append(name);
+        sb.append(", cropId=").append(cropId);
+        sb.append(", secret=").append(secret);
+        sb.append(", isDelete=").append(isDelete);
+        sb.append(", createTime=").append(createTime);
+        sb.append(", updateTime=").append(updateTime);
+        sb.append("]");
+        return sb.toString();
+    }
+}

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

@@ -0,0 +1,662 @@
+package com.tzld.piaoquan.wecom.model.po;
+
+import com.tzld.piaoquan.wecom.utils.page.Page;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class SubjectExample {
+    protected String orderByClause;
+
+    protected boolean distinct;
+
+    protected List<Criteria> oredCriteria;
+
+    protected Page page;
+
+    public SubjectExample() {
+        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 andNameIsNull() {
+            addCriterion("`name` is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameIsNotNull() {
+            addCriterion("`name` is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameEqualTo(String value) {
+            addCriterion("`name` =", value, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameNotEqualTo(String value) {
+            addCriterion("`name` <>", value, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameGreaterThan(String value) {
+            addCriterion("`name` >", value, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameGreaterThanOrEqualTo(String value) {
+            addCriterion("`name` >=", value, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameLessThan(String value) {
+            addCriterion("`name` <", value, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameLessThanOrEqualTo(String value) {
+            addCriterion("`name` <=", value, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameLike(String value) {
+            addCriterion("`name` like", value, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameNotLike(String value) {
+            addCriterion("`name` not like", value, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameIn(List<String> values) {
+            addCriterion("`name` in", values, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameNotIn(List<String> values) {
+            addCriterion("`name` not in", values, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameBetween(String value1, String value2) {
+            addCriterion("`name` between", value1, value2, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andNameNotBetween(String value1, String value2) {
+            addCriterion("`name` not between", value1, value2, "name");
+            return (Criteria) this;
+        }
+
+        public Criteria andCropIdIsNull() {
+            addCriterion("crop_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCropIdIsNotNull() {
+            addCriterion("crop_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCropIdEqualTo(String value) {
+            addCriterion("crop_id =", value, "cropId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCropIdNotEqualTo(String value) {
+            addCriterion("crop_id <>", value, "cropId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCropIdGreaterThan(String value) {
+            addCriterion("crop_id >", value, "cropId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCropIdGreaterThanOrEqualTo(String value) {
+            addCriterion("crop_id >=", value, "cropId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCropIdLessThan(String value) {
+            addCriterion("crop_id <", value, "cropId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCropIdLessThanOrEqualTo(String value) {
+            addCriterion("crop_id <=", value, "cropId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCropIdLike(String value) {
+            addCriterion("crop_id like", value, "cropId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCropIdNotLike(String value) {
+            addCriterion("crop_id not like", value, "cropId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCropIdIn(List<String> values) {
+            addCriterion("crop_id in", values, "cropId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCropIdNotIn(List<String> values) {
+            addCriterion("crop_id not in", values, "cropId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCropIdBetween(String value1, String value2) {
+            addCriterion("crop_id between", value1, value2, "cropId");
+            return (Criteria) this;
+        }
+
+        public Criteria andCropIdNotBetween(String value1, String value2) {
+            addCriterion("crop_id not between", value1, value2, "cropId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSecretIsNull() {
+            addCriterion("secret is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andSecretIsNotNull() {
+            addCriterion("secret is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andSecretEqualTo(String value) {
+            addCriterion("secret =", value, "secret");
+            return (Criteria) this;
+        }
+
+        public Criteria andSecretNotEqualTo(String value) {
+            addCriterion("secret <>", value, "secret");
+            return (Criteria) this;
+        }
+
+        public Criteria andSecretGreaterThan(String value) {
+            addCriterion("secret >", value, "secret");
+            return (Criteria) this;
+        }
+
+        public Criteria andSecretGreaterThanOrEqualTo(String value) {
+            addCriterion("secret >=", value, "secret");
+            return (Criteria) this;
+        }
+
+        public Criteria andSecretLessThan(String value) {
+            addCriterion("secret <", value, "secret");
+            return (Criteria) this;
+        }
+
+        public Criteria andSecretLessThanOrEqualTo(String value) {
+            addCriterion("secret <=", value, "secret");
+            return (Criteria) this;
+        }
+
+        public Criteria andSecretLike(String value) {
+            addCriterion("secret like", value, "secret");
+            return (Criteria) this;
+        }
+
+        public Criteria andSecretNotLike(String value) {
+            addCriterion("secret not like", value, "secret");
+            return (Criteria) this;
+        }
+
+        public Criteria andSecretIn(List<String> values) {
+            addCriterion("secret in", values, "secret");
+            return (Criteria) this;
+        }
+
+        public Criteria andSecretNotIn(List<String> values) {
+            addCriterion("secret not in", values, "secret");
+            return (Criteria) this;
+        }
+
+        public Criteria andSecretBetween(String value1, String value2) {
+            addCriterion("secret between", value1, value2, "secret");
+            return (Criteria) this;
+        }
+
+        public Criteria andSecretNotBetween(String value1, String value2) {
+            addCriterion("secret not between", value1, value2, "secret");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteIsNull() {
+            addCriterion("is_delete is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteIsNotNull() {
+            addCriterion("is_delete is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteEqualTo(Integer value) {
+            addCriterion("is_delete =", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteNotEqualTo(Integer value) {
+            addCriterion("is_delete <>", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteGreaterThan(Integer value) {
+            addCriterion("is_delete >", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteGreaterThanOrEqualTo(Integer value) {
+            addCriterion("is_delete >=", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteLessThan(Integer value) {
+            addCriterion("is_delete <", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteLessThanOrEqualTo(Integer value) {
+            addCriterion("is_delete <=", value, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteIn(List<Integer> values) {
+            addCriterion("is_delete in", values, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteNotIn(List<Integer> values) {
+            addCriterion("is_delete not in", values, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteBetween(Integer value1, Integer value2) {
+            addCriterion("is_delete between", value1, value2, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andIsDeleteNotBetween(Integer value1, Integer value2) {
+            addCriterion("is_delete not between", value1, value2, "isDelete");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIsNull() {
+            addCriterion("create_time is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIsNotNull() {
+            addCriterion("create_time is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeEqualTo(Date value) {
+            addCriterion("create_time =", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotEqualTo(Date value) {
+            addCriterion("create_time <>", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeGreaterThan(Date value) {
+            addCriterion("create_time >", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
+            addCriterion("create_time >=", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeLessThan(Date value) {
+            addCriterion("create_time <", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
+            addCriterion("create_time <=", value, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeIn(List<Date> values) {
+            addCriterion("create_time in", values, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotIn(List<Date> values) {
+            addCriterion("create_time not in", values, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeBetween(Date value1, Date value2) {
+            addCriterion("create_time between", value1, value2, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
+            addCriterion("create_time not between", value1, value2, "createTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeIsNull() {
+            addCriterion("update_time is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeIsNotNull() {
+            addCriterion("update_time is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeEqualTo(Date value) {
+            addCriterion("update_time =", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeNotEqualTo(Date value) {
+            addCriterion("update_time <>", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeGreaterThan(Date value) {
+            addCriterion("update_time >", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) {
+            addCriterion("update_time >=", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeLessThan(Date value) {
+            addCriterion("update_time <", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeLessThanOrEqualTo(Date value) {
+            addCriterion("update_time <=", value, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeIn(List<Date> values) {
+            addCriterion("update_time in", values, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeNotIn(List<Date> values) {
+            addCriterion("update_time not in", values, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeBetween(Date value1, Date value2) {
+            addCriterion("update_time between", value1, value2, "updateTime");
+            return (Criteria) this;
+        }
+
+        public Criteria andUpdateTimeNotBetween(Date value1, Date value2) {
+            addCriterion("update_time not between", value1, value2, "updateTime");
+            return (Criteria) this;
+        }
+    }
+
+    public static class Criteria extends GeneratedCriteria {
+
+        protected Criteria() {
+            super();
+        }
+    }
+
+    public static class Criterion {
+        private String condition;
+
+        private Object value;
+
+        private Object secondValue;
+
+        private boolean noValue;
+
+        private boolean singleValue;
+
+        private boolean betweenValue;
+
+        private boolean listValue;
+
+        private String typeHandler;
+
+        public String getCondition() {
+            return condition;
+        }
+
+        public Object getValue() {
+            return value;
+        }
+
+        public Object getSecondValue() {
+            return secondValue;
+        }
+
+        public boolean isNoValue() {
+            return noValue;
+        }
+
+        public boolean isSingleValue() {
+            return singleValue;
+        }
+
+        public boolean isBetweenValue() {
+            return betweenValue;
+        }
+
+        public boolean isListValue() {
+            return listValue;
+        }
+
+        public String getTypeHandler() {
+            return typeHandler;
+        }
+
+        protected Criterion(String condition) {
+            super();
+            this.condition = condition;
+            this.typeHandler = null;
+            this.noValue = true;
+        }
+
+        protected Criterion(String condition, Object value, String typeHandler) {
+            super();
+            this.condition = condition;
+            this.value = value;
+            this.typeHandler = typeHandler;
+            if (value instanceof List<?>) {
+                this.listValue = true;
+            } else {
+                this.singleValue = true;
+            }
+        }
+
+        protected Criterion(String condition, Object value) {
+            this(condition, value, null);
+        }
+
+        protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
+            super();
+            this.condition = condition;
+            this.value = value;
+            this.secondValue = secondValue;
+            this.typeHandler = typeHandler;
+            this.betweenValue = true;
+        }
+
+        protected Criterion(String condition, Object value, Object secondValue) {
+            this(condition, value, secondValue, null);
+        }
+    }
+}

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

@@ -5,6 +5,8 @@ import java.util.Date;
 public class User {
     private Long id;
 
+    private Long subjectId;
+
     private String externalUserId;
 
     private String unionId;
@@ -39,6 +41,14 @@ public class User {
         this.id = id;
     }
 
+    public Long getSubjectId() {
+        return subjectId;
+    }
+
+    public void setSubjectId(Long subjectId) {
+        this.subjectId = subjectId;
+    }
+
     public String getExternalUserId() {
         return externalUserId;
     }
@@ -150,6 +160,7 @@ public class User {
         sb.append(" [");
         sb.append("Hash = ").append(hashCode());
         sb.append(", id=").append(id);
+        sb.append(", subjectId=").append(subjectId);
         sb.append(", externalUserId=").append(externalUserId);
         sb.append(", unionId=").append(unionId);
         sb.append(", externalUserId3rdParty=").append(externalUserId3rdParty);

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

@@ -176,6 +176,66 @@ public class UserExample {
             return (Criteria) this;
         }
 
+        public Criteria andSubjectIdIsNull() {
+            addCriterion("subject_id is null");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdIsNotNull() {
+            addCriterion("subject_id is not null");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdEqualTo(Long value) {
+            addCriterion("subject_id =", value, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdNotEqualTo(Long value) {
+            addCriterion("subject_id <>", value, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdGreaterThan(Long value) {
+            addCriterion("subject_id >", value, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdGreaterThanOrEqualTo(Long value) {
+            addCriterion("subject_id >=", value, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdLessThan(Long value) {
+            addCriterion("subject_id <", value, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdLessThanOrEqualTo(Long value) {
+            addCriterion("subject_id <=", value, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdIn(List<Long> values) {
+            addCriterion("subject_id in", values, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdNotIn(List<Long> values) {
+            addCriterion("subject_id not in", values, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdBetween(Long value1, Long value2) {
+            addCriterion("subject_id between", value1, value2, "subjectId");
+            return (Criteria) this;
+        }
+
+        public Criteria andSubjectIdNotBetween(Long value1, Long value2) {
+            addCriterion("subject_id not between", value1, value2, "subjectId");
+            return (Criteria) this;
+        }
+
         public Criteria andExternalUserIdIsNull() {
             addCriterion("external_user_id is null");
             return (Criteria) this;

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

@@ -2,10 +2,12 @@ package com.tzld.piaoquan.wecom.model.vo;
 
 import com.tzld.piaoquan.wecom.model.bo.VideoParam;
 import lombok.Data;
+import lombok.ToString;
 
 import java.util.List;
 
 @Data
+@ToString
 public class GuaranteedParam {
 
     private String date;

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

@@ -2,8 +2,6 @@ package com.tzld.piaoquan.wecom.service;
 
 public interface AccessTokenService {
 
-    String getAccessToken();
-
-    String getWeComAccessToken();
+    String getWeComAccessToken(Long subjectId);
 
 }

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

@@ -2,15 +2,21 @@ package com.tzld.piaoquan.wecom.service.Impl;
 
 import com.alibaba.fastjson.JSONObject;
 import com.tzld.piaoquan.wecom.component.HttpPoolClient;
+import com.tzld.piaoquan.wecom.dao.mapper.SubjectMapper;
+import com.tzld.piaoquan.wecom.model.po.Subject;
+import com.tzld.piaoquan.wecom.model.po.SubjectExample;
 import com.tzld.piaoquan.wecom.service.AccessTokenService;
 import com.tzld.piaoquan.wecom.utils.HttpClientUtil;
+import com.tzld.piaoquan.wecom.utils.LarkRobotUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 
 import java.io.IOException;
+import java.util.List;
 import java.util.concurrent.TimeUnit;
 
 import static com.tzld.piaoquan.wecom.common.constant.RedisConstant.ACCESS_TOKEN;
@@ -23,48 +29,40 @@ public class AccessTokenServiceImpl implements AccessTokenService {
 
     @Autowired
     private HttpPoolClient httpPoolClient;
+
     @Autowired
     private RedisTemplate<String, Object> redisTemplate;
 
-    @Override
-    public String getAccessToken() {
-        String accessToken = (String) redisTemplate.opsForValue().get(ACCESS_TOKEN);
-        if (StringUtils.isNotEmpty(accessToken)) {
-            return accessToken;
-        }
-        JSONObject param = new JSONObject();
-        param.put("corp_id", CROP_ID);
-        param.put("secret", SECRET);
-        try {
-            String res = httpPoolClient.post(POST_ACCESS_TOKEN_URL, param.toJSONString());
-            JSONObject jsonObject = JSONObject.parseObject(res);
-            Long expiresIn = jsonObject.getLong("expires_in");
-            String newAccessToken = jsonObject.getString("access_token");
-            redisTemplate.opsForValue().set(ACCESS_TOKEN, newAccessToken, expiresIn, TimeUnit.SECONDS);
-            return newAccessToken;
-        } catch (IOException e) {
-            log.error("getAccessToken error", e);
-        }
-        return "";
-    }
+    @Autowired
+    private SubjectMapper subjectMapper;
 
     @Override
-    public String getWeComAccessToken() {
-        String accessToken = (String) redisTemplate.opsForValue().get(WE_COM_ACCESS_TOKEN);
-        if (StringUtils.isNotEmpty(accessToken)) {
-            return accessToken;
-        }
-        JSONObject param = new JSONObject();
-        param.put("corp_id", CROP_ID);
-        param.put("secret", SECRET);
+    public String getWeComAccessToken(Long subjectId) {
         try {
-            String res = httpPoolClient.get(String.format(GET_WE_COM_ACCESS_TOKEN_URL + "?corpid=%s&corpsecret=%s", WE_COM_CROP_ID, WE_COM_SECRET));
+            String key = String.format(WE_COM_ACCESS_TOKEN, subjectId);
+            String accessToken = (String) redisTemplate.opsForValue().get(key);
+            if (StringUtils.isNotEmpty(accessToken)) {
+                return accessToken;
+            }
+            SubjectExample example = new SubjectExample();
+            example.createCriteria().andIdEqualTo(subjectId);
+            List<Subject> subjects = subjectMapper.selectByExample(example);
+            if (CollectionUtils.isEmpty(subjects)) {
+                LarkRobotUtil.sendMessage("查询不到主体,获取access_token失败");
+                return "";
+            }
+            Subject subject = subjects.get(0);
+            String cropId = subject.getCropId();
+            String secret = subject.getSecret();
+            String res = httpPoolClient.get(String.format(GET_WE_COM_ACCESS_TOKEN_URL +
+                    "?corpid=%s&corpsecret=%s", cropId, secret));
             JSONObject jsonObject = JSONObject.parseObject(res);
             Long expiresIn = jsonObject.getLong("expires_in");
             String newAccessToken = jsonObject.getString("access_token");
-            redisTemplate.opsForValue().set(WE_COM_ACCESS_TOKEN, newAccessToken, expiresIn, TimeUnit.SECONDS);
+            redisTemplate.opsForValue().set(key, newAccessToken, expiresIn, TimeUnit.SECONDS);
             return newAccessToken;
         } catch (IOException e) {
+            LarkRobotUtil.sendMessage("getWeComAccessToken error:" + e);
             log.error("getWeComAccessToken error", e);
         }
         return "";

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

@@ -16,7 +16,6 @@ import com.tzld.piaoquan.wecom.model.vo.GuaranteedParam;
 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;
 import com.tzld.piaoquan.wecom.utils.LarkRobotUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
@@ -101,7 +100,7 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
                 throw new RuntimeException("获取视频详情异常");
             }
             messageAttachment.setMiniprogramVideoId(videoId);
-            messageAttachment.setType(MessageAttachmentTypeEnum.MINIPROGRAM.getType());
+            messageAttachment.setType(MessageAttachmentTypeEnum.MINI_PROGRAM.getType());
             messageAttachment.setCover(videoDetail.getCover());
             messageAttachment.setTitle(videoDetail.getTitle());
             messageAttachment.setAppid(appid);
@@ -140,7 +139,7 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
     }
 
     @Override
-    public String getPicMediaId(String cover) {
+    public String getPicMediaId(String cover, Long subjectId) {
         String mediaId = (String) redisTemplate.opsForValue().get(cover);
         if (StringUtils.isNotEmpty(mediaId)) {
             return mediaId;
@@ -162,7 +161,7 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
             inputStream.close();
             httpUrl.disconnect();
             File file = new java.io.File(filePath);
-            String weComAccessToken = accessTokenService.getWeComAccessToken();
+            String weComAccessToken = accessTokenService.getWeComAccessToken(subjectId);
             String url = String.format(POST_WE_COM_MEDIA_UPLOAD + "?access_token=%s&type=%s", weComAccessToken, "image");
             String res = httpPoolClient.post(url, file);
             JSONObject jsonObject = JSONObject.parseObject(res);

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

@@ -30,32 +30,17 @@ public class MessageServiceImpl implements MessageService {
 
     @Autowired
     private HttpPoolClient httpPoolClient;
+
     @Autowired
     private AccessTokenService accessTokenService;
 
     @Autowired
     private RedisTemplate<String, Object> redisTemplate;
 
-    public boolean pushMessage(JSONObject jsonObject) {
-        try {
-            String accessToken = accessTokenService.getAccessToken();
-            String url = POST_MESSAGE_PUSH_URL
-                    + "?access_token=" + accessToken;
-            String s = httpPoolClient.post(url, jsonObject.toJSONString());
-            JSONObject res = JSONObject.parseObject(s);
-            log.info("pushMessage res={}", res);
-            Integer code = res.getInteger("errcode");
-            return code == 0;
-        } catch (IOException e) {
-            log.error("pushMessage error", e);
-        }
-        return false;
-    }
-
     @Override
-    public boolean pushWeComMessage(JSONObject jsonObject) {
+    public boolean pushWeComMessage(JSONObject jsonObject, Long subjectId) {
         try {
-            String accessToken = accessTokenService.getWeComAccessToken();
+            String accessToken = accessTokenService.getWeComAccessToken(subjectId);
             String url = POST_WE_COM_ADD_MSG_TEMPLATE
                     + "?access_token=" + accessToken;
             String s = httpPoolClient.post(url, jsonObject.toJSONString());

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

@@ -29,6 +29,7 @@ import static com.tzld.piaoquan.wecom.common.constant.WeComConstant.GET_WE_COM_E
 public class UserServiceImpl implements UserService {
     @Autowired
     private HttpPoolClient httpPoolClient;
+
     @Autowired
     private AccessTokenService accessTokenService;
 
@@ -41,22 +42,23 @@ public class UserServiceImpl implements UserService {
     @Autowired
     private StaffMapper staffMapper;
 
-    public void addStaffWithUser(String externalUserId, String carrierId) {
+    @Override
+    public void addStaffWithUser(String externalUserId, String carrierId, Long subjectId) {
         if (StringUtils.isEmpty(externalUserId) || StringUtils.isEmpty(carrierId)) {
             return;
         }
         Staff staff = getStaff(carrierId);
-        insertStaffWithUser(externalUserId, staff);
+        insertStaffWithUser(externalUserId, staff, subjectId);
     }
 
-
-    public void insertStaffWithUser(String externalUserId, Staff staff) {
+    @Override
+    public void insertStaffWithUser(String externalUserId, Staff staff, Long subjectId) {
         try {
             UserExample userExample = new UserExample();
             userExample.createCriteria().andExternalUserIdEqualTo(externalUserId);
             List<User> userList = userMapper.selectByExample(userExample);
             if (CollectionUtils.isEmpty(userList)) {
-                JSONObject userDetail = getUserDetail(externalUserId);
+                JSONObject userDetail = getUserDetail(externalUserId, subjectId);
                 if (userDetail == null) {
                     return;
                 }
@@ -137,7 +139,7 @@ public class UserServiceImpl implements UserService {
     }
 
     @Override
-    public void delStaffWithUser(String externalUserId, String carrierId) {
+    public void delStaffWithUser(String externalUserId, String carrierId, Long deleteTime) {
         if (StringUtils.isEmpty(externalUserId) || StringUtils.isEmpty(carrierId)) {
             return;
         }
@@ -173,7 +175,7 @@ public class UserServiceImpl implements UserService {
             return;
         }
         StaffWithUser staffWithUser = staffWithUserList.get(0);
-        if(deleteTime != null){
+        if (deleteTime != null) {
             staffWithUser.setDeleteTime(new Date(deleteTime));
         }
         staffWithUser.setIsDelete(1);
@@ -204,8 +206,8 @@ public class UserServiceImpl implements UserService {
     }
 
 
-    public JSONObject getUserDetail(String externalUserId) throws IOException {
-        String weComAccessToken = accessTokenService.getWeComAccessToken();
+    public JSONObject getUserDetail(String externalUserId, Long subjectId) throws IOException {
+        String weComAccessToken = accessTokenService.getWeComAccessToken(subjectId);
         String url = String.format(GET_WE_COM_EXTERNAL_CONTACT_GET + "?access_token=%s&external_userid=%s", weComAccessToken, externalUserId);
         String res = httpPoolClient.get(url);
         JSONObject jsonObject = JSONObject.parseObject(res);

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

@@ -13,7 +13,7 @@ public interface MessageAttachmentService {
 
     CommonResponse<Void> createGuaranteedMiniProgram(GuaranteedParam guaranteedParam);
 
-    String getPicMediaId(String cover);
+    String getPicMediaId(String cover, Long subjectId);
 
     String getPage(Staff staff, Long videoId);
 }

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

@@ -5,9 +5,7 @@ import com.tzld.piaoquan.wecom.model.vo.MessageTextParam;
 
 public interface MessageService {
 
-    boolean pushMessage(JSONObject jsonObject);
-
-    boolean pushWeComMessage(JSONObject jsonObject);
+    boolean pushWeComMessage(JSONObject jsonObject, Long subjectId);
 
     void createMessageText(MessageTextParam messageTextParam);
 

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

@@ -6,11 +6,11 @@ import com.tzld.piaoquan.wecom.model.po.Staff;
 public interface UserService {
 
 
-    void addStaffWithUser(String externalUserId, String staffUserId);
+    void addStaffWithUser(String externalUserId, String staffUserId, Long subjectId);
 
-    void insertStaffWithUser(String externalUserId, Staff staff);
+    void insertStaffWithUser(String externalUserId, Staff staff, Long subjectId);
 
-    void delStaffWithUser(String externalUserId, String staffUserId);
+    void delStaffWithUser(String externalUserId, String staffUserId, Long deleteTime);
 
     void delStaffWithUser(Long userId, Long staffId, Long deleteTime);
 }

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

@@ -1,3 +1,5 @@
+server.port=8080
+
 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

+ 51 - 35
we-com-server/src/main/resources/mapper/HistoryMessageMapper.xml

@@ -3,6 +3,7 @@
 <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="subject_id" jdbcType="BIGINT" property="subjectId" />
     <result column="user_id" jdbcType="BIGINT" property="userId" />
     <result column="staff_id" jdbcType="BIGINT" property="staffId" />
     <result column="video_id" jdbcType="BIGINT" property="videoId" />
@@ -72,7 +73,7 @@
     </where>
   </sql>
   <sql id="Base_Column_List">
-    id, user_id, staff_id, video_id, attachment_idx, message_id, `status`, send_time, 
+    id, subject_id, user_id, staff_id, video_id, attachment_idx, message_id, `status`, send_time,
     is_delete, create_time
   </sql>
   <select id="selectByExample" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessageExample" resultMap="BaseResultMap">
@@ -109,13 +110,13 @@
     </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,
+    insert into we_com_history_message (id, subject_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},
+    values (#{id,jdbcType=BIGINT}, #{subjectId,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">
@@ -124,6 +125,9 @@
       <if test="id != null">
         id,
       </if>
+      <if test="subjectId != null">
+        subject_id,
+      </if>
       <if test="userId != null">
         user_id,
       </if>
@@ -156,6 +160,9 @@
       <if test="id != null">
         #{id,jdbcType=BIGINT},
       </if>
+      <if test="subjectId != null">
+        #{subjectId,jdbcType=BIGINT},
+      </if>
       <if test="userId != null">
         #{userId,jdbcType=BIGINT},
       </if>
@@ -197,6 +204,9 @@
       <if test="record.id != null">
         id = #{record.id,jdbcType=BIGINT},
       </if>
+      <if test="record.subjectId != null">
+        subject_id = #{record.subjectId,jdbcType=BIGINT},
+      </if>
       <if test="record.userId != null">
         user_id = #{record.userId,jdbcType=BIGINT},
       </if>
@@ -232,6 +242,7 @@
   <update id="updateByExample" parameterType="map">
     update we_com_history_message
     set id = #{record.id,jdbcType=BIGINT},
+      subject_id = #{record.subjectId,jdbcType=BIGINT},
       user_id = #{record.userId,jdbcType=BIGINT},
       staff_id = #{record.staffId,jdbcType=BIGINT},
       video_id = #{record.videoId,jdbcType=BIGINT},
@@ -248,6 +259,9 @@
   <update id="updateByPrimaryKeySelective" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessage">
     update we_com_history_message
     <set>
+      <if test="subjectId != null">
+        subject_id = #{subjectId,jdbcType=BIGINT},
+      </if>
       <if test="userId != null">
         user_id = #{userId,jdbcType=BIGINT},
       </if>
@@ -280,7 +294,8 @@
   </update>
   <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.wecom.model.po.HistoryMessage">
     update we_com_history_message
-    set user_id = #{userId,jdbcType=BIGINT},
+    set subject_id = #{subjectId,jdbcType=BIGINT},
+      user_id = #{userId,jdbcType=BIGINT},
       staff_id = #{staffId,jdbcType=BIGINT},
       video_id = #{videoId,jdbcType=BIGINT},
       attachment_idx = #{attachmentIdx,jdbcType=INTEGER},
@@ -291,31 +306,32 @@
       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,
-        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>
+  <insert id="insertList" parameterType="java.util.List">
+    insert into we_com_history_message
+    (
+    subject_id,
+    user_id,
+    staff_id,
+    video_id,
+    attachment_idx,
+    message_id,
+    `status`,
+    send_time,
+    create_time
+    )
+    values
+    <foreach collection="list" item="item" separator=",">
+      (
+      #{item.subjectId,jdbcType=BIGINT},
+      #{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>

+ 321 - 318
we-com-server/src/main/resources/mapper/SendMessageMapper.xml

@@ -1,335 +1,338 @@
 <?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.SendMessageMapper">
-    <resultMap id="BaseResultMap" type="com.tzld.piaoquan.wecom.model.po.SendMessage">
-        <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="video_id_1" jdbcType="BIGINT" property="videoId1"/>
-        <result column="video_id_2" jdbcType="BIGINT" property="videoId2"/>
-        <result column="video_id_3" jdbcType="BIGINT" property="videoId3"/>
-        <result column="is_send" jdbcType="INTEGER" property="isSend"/>
-        <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.SendMessage">
+    <id column="id" jdbcType="BIGINT" property="id" />
+    <result column="subject_id" jdbcType="BIGINT" property="subjectId" />
+    <result column="staff_id" jdbcType="BIGINT" property="staffId" />
+    <result column="user_id" jdbcType="BIGINT" property="userId" />
+    <result column="video_id_1" jdbcType="BIGINT" property="videoId1" />
+    <result column="video_id_2" jdbcType="BIGINT" property="videoId2" />
+    <result column="video_id_3" jdbcType="BIGINT" property="videoId3" />
+    <result column="is_send" jdbcType="INTEGER" property="isSend" />
+    <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, video_id_1, video_id_2, video_id_3, is_send, create_time, 
-    update_time
-    </sql>
-    <select id="selectByExample" parameterType="com.tzld.piaoquan.wecom.model.po.SendMessageExample"
-            resultMap="BaseResultMap">
-        select
-        <if test="distinct">
-            distinct
-        </if>
-        <include refid="Base_Column_List"/>
-        from we_com_send_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}
+          </trim>
         </if>
-    </select>
-    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
-        select
-        <include refid="Base_Column_List"/>
-        from we_com_send_message
-        where id = #{id,jdbcType=BIGINT}
-    </select>
-    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
-        delete
-        from we_com_send_message
-        where id = #{id,jdbcType=BIGINT}
-    </delete>
-    <delete id="deleteByExample" parameterType="com.tzld.piaoquan.wecom.model.po.SendMessageExample">
-        delete from we_com_send_message
-        <if test="_parameter != null">
-            <include refid="Example_Where_Clause"/>
-        </if>
-    </delete>
-    <insert id="insert" parameterType="com.tzld.piaoquan.wecom.model.po.SendMessage">
-        insert into we_com_send_message (id, staff_id, user_id,
-                                         video_id_1, video_id_2, video_id_3,
-                                         create_time, update_time)
-        values (#{id,jdbcType=BIGINT}, #{staffId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT},
-                #{videoId1,jdbcType=BIGINT}, #{videoId2,jdbcType=BIGINT}, #{videoId3,jdbcType=BIGINT},
-                #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
-    </insert>
-    <insert id="insertSelective" parameterType="com.tzld.piaoquan.wecom.model.po.SendMessage">
-        insert into we_com_send_message
-        <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="videoId1 != null">
-                video_id_1,
-            </if>
-            <if test="videoId2 != null">
-                video_id_2,
-            </if>
-            <if test="videoId3 != null">
-                video_id_3,
-            </if>
-            <if test="isSend != null">
-                is_send,
-            </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="videoId1 != null">
-                #{videoId1,jdbcType=BIGINT},
-            </if>
-            <if test="videoId2 != null">
-                #{videoId2,jdbcType=BIGINT},
-            </if>
-            <if test="videoId3 != null">
-                #{videoId3,jdbcType=BIGINT},
-            </if>
-            <if test="isSend != null">
-                #{isSend,jdbcType=INTEGER},
-            </if>
-            <if test="createTime != null">
-                #{createTime,jdbcType=TIMESTAMP},
-            </if>
-            <if test="updateTime != null">
-                #{updateTime,jdbcType=TIMESTAMP},
-            </if>
-        </trim>
-    </insert>
-    <select id="countByExample" parameterType="com.tzld.piaoquan.wecom.model.po.SendMessageExample"
-            resultType="java.lang.Long">
-        select count(*) from we_com_send_message
-        <if test="_parameter != null">
-            <include refid="Example_Where_Clause"/>
-        </if>
-    </select>
-    <update id="updateByExampleSelective" parameterType="map">
-        update we_com_send_message
-        <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.videoId1 != null">
-                video_id_1 = #{record.videoId1,jdbcType=BIGINT},
-            </if>
-            <if test="record.videoId2 != null">
-                video_id_2 = #{record.videoId2,jdbcType=BIGINT},
-            </if>
-            <if test="record.videoId3 != null">
-                video_id_3 = #{record.videoId3,jdbcType=BIGINT},
-            </if>
-            <if test="record.isSend != null">
-                is_send = #{record.isSend,jdbcType=INTEGER},
-            </if>
-            <if test="record.createTime != null">
-                create_time = #{record.createTime,jdbcType=TIMESTAMP},
-            </if>
-            <if test="record.updateTime != null">
-                update_time = #{record.updateTime,jdbcType=TIMESTAMP},
-            </if>
-        </set>
-        <if test="_parameter != null">
-            <include refid="Update_By_Example_Where_Clause"/>
+      </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_send_message
-        set id = #{record.id,jdbcType=BIGINT},
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Base_Column_List">
+    id, subject_id, staff_id, user_id, video_id_1, video_id_2, video_id_3, is_send, create_time, 
+    update_time
+  </sql>
+  <select id="selectByExample" parameterType="com.tzld.piaoquan.wecom.model.po.SendMessageExample" resultMap="BaseResultMap">
+    select
+    <if test="distinct">
+      distinct
+    </if>
+    <include refid="Base_Column_List" />
+    from we_com_send_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_send_message
+    where id = #{id,jdbcType=BIGINT}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+    delete from we_com_send_message
+    where id = #{id,jdbcType=BIGINT}
+  </delete>
+  <delete id="deleteByExample" parameterType="com.tzld.piaoquan.wecom.model.po.SendMessageExample">
+    delete from we_com_send_message
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </delete>
+  <insert id="insert" parameterType="com.tzld.piaoquan.wecom.model.po.SendMessage">
+    insert into we_com_send_message (id, subject_id, staff_id, 
+      user_id, video_id_1, video_id_2, 
+      video_id_3, is_send, create_time, 
+      update_time)
+    values (#{id,jdbcType=BIGINT}, #{subjectId,jdbcType=BIGINT}, #{staffId,jdbcType=BIGINT}, 
+      #{userId,jdbcType=BIGINT}, #{videoId1,jdbcType=BIGINT}, #{videoId2,jdbcType=BIGINT}, 
+      #{videoId3,jdbcType=BIGINT}, #{isSend,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, 
+      #{updateTime,jdbcType=TIMESTAMP})
+  </insert>
+  <insert id="insertSelective" parameterType="com.tzld.piaoquan.wecom.model.po.SendMessage">
+    insert into we_com_send_message
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <if test="subjectId != null">
+        subject_id,
+      </if>
+      <if test="staffId != null">
+        staff_id,
+      </if>
+      <if test="userId != null">
+        user_id,
+      </if>
+      <if test="videoId1 != null">
+        video_id_1,
+      </if>
+      <if test="videoId2 != null">
+        video_id_2,
+      </if>
+      <if test="videoId3 != null">
+        video_id_3,
+      </if>
+      <if test="isSend != null">
+        is_send,
+      </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="subjectId != null">
+        #{subjectId,jdbcType=BIGINT},
+      </if>
+      <if test="staffId != null">
+        #{staffId,jdbcType=BIGINT},
+      </if>
+      <if test="userId != null">
+        #{userId,jdbcType=BIGINT},
+      </if>
+      <if test="videoId1 != null">
+        #{videoId1,jdbcType=BIGINT},
+      </if>
+      <if test="videoId2 != null">
+        #{videoId2,jdbcType=BIGINT},
+      </if>
+      <if test="videoId3 != null">
+        #{videoId3,jdbcType=BIGINT},
+      </if>
+      <if test="isSend != null">
+        #{isSend,jdbcType=INTEGER},
+      </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateTime != null">
+        #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+    </trim>
+  </insert>
+  <select id="countByExample" parameterType="com.tzld.piaoquan.wecom.model.po.SendMessageExample" resultType="java.lang.Long">
+    select count(*) from we_com_send_message
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </select>
+  <update id="updateByExampleSelective" parameterType="map">
+    update we_com_send_message
+    <set>
+      <if test="record.id != null">
+        id = #{record.id,jdbcType=BIGINT},
+      </if>
+      <if test="record.subjectId != null">
+        subject_id = #{record.subjectId,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.videoId1 != null">
         video_id_1 = #{record.videoId1,jdbcType=BIGINT},
+      </if>
+      <if test="record.videoId2 != null">
         video_id_2 = #{record.videoId2,jdbcType=BIGINT},
+      </if>
+      <if test="record.videoId3 != null">
         video_id_3 = #{record.videoId3,jdbcType=BIGINT},
+      </if>
+      <if test="record.isSend != null">
         is_send = #{record.isSend,jdbcType=INTEGER},
+      </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.SendMessage">
-        update we_com_send_message
-        <set>
-            <if test="staffId != null">
-                staff_id = #{staffId,jdbcType=BIGINT},
-            </if>
-            <if test="userId != null">
-                user_id = #{userId,jdbcType=BIGINT},
-            </if>
-            <if test="videoId1 != null">
-                video_id_1 = #{videoId1,jdbcType=BIGINT},
-            </if>
-            <if test="videoId2 != null">
-                video_id_2 = #{videoId2,jdbcType=BIGINT},
-            </if>
-            <if test="videoId3 != null">
-                video_id_3 = #{videoId3,jdbcType=BIGINT},
-            </if>
-            <if test="isSend != null">
-                is_send = #{isSend,jdbcType=INTEGER},
-            </if>
-            <if test="createTime != null">
-                create_time = #{createTime,jdbcType=TIMESTAMP},
-            </if>
-            <if test="updateTime != null">
-                update_time = #{updateTime,jdbcType=TIMESTAMP},
-            </if>
-        </set>
-        where id = #{id,jdbcType=BIGINT}
-    </update>
-    <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.wecom.model.po.SendMessage">
-        update we_com_send_message
-        set staff_id    = #{staffId,jdbcType=BIGINT},
-            user_id     = #{userId,jdbcType=BIGINT},
-            video_id_1  = #{videoId1,jdbcType=BIGINT},
-            video_id_2  = #{videoId2,jdbcType=BIGINT},
-            video_id_3  = #{videoId3,jdbcType=BIGINT},
-            is_send     = #{isSend,jdbcType=INTEGER},
-            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_send_message
-        (
-        staff_id,
-        user_id,
-        video_id_1,
-        video_id_2,
-        video_id_3
-        )
-        values
-        <foreach collection="list" item="item" separator=",">
-            (
-            #{item.staffId,jdbcType=BIGINT},
-            #{item.userId,jdbcType=BIGINT},
-            #{item.videoId1,jdbcType=BIGINT},
-            #{item.videoId2,jdbcType=BIGINT},
-            #{item.videoId3,jdbcType=BIGINT}
-            )
-        </foreach>
-    </insert>
+      </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_send_message
+    set id = #{record.id,jdbcType=BIGINT},
+      subject_id = #{record.subjectId,jdbcType=BIGINT},
+      staff_id = #{record.staffId,jdbcType=BIGINT},
+      user_id = #{record.userId,jdbcType=BIGINT},
+      video_id_1 = #{record.videoId1,jdbcType=BIGINT},
+      video_id_2 = #{record.videoId2,jdbcType=BIGINT},
+      video_id_3 = #{record.videoId3,jdbcType=BIGINT},
+      is_send = #{record.isSend,jdbcType=INTEGER},
+      create_time = #{record.createTime,jdbcType=TIMESTAMP},
+      update_time = #{record.updateTime,jdbcType=TIMESTAMP}
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByPrimaryKeySelective" parameterType="com.tzld.piaoquan.wecom.model.po.SendMessage">
+    update we_com_send_message
+    <set>
+      <if test="subjectId != null">
+        subject_id = #{subjectId,jdbcType=BIGINT},
+      </if>
+      <if test="staffId != null">
+        staff_id = #{staffId,jdbcType=BIGINT},
+      </if>
+      <if test="userId != null">
+        user_id = #{userId,jdbcType=BIGINT},
+      </if>
+      <if test="videoId1 != null">
+        video_id_1 = #{videoId1,jdbcType=BIGINT},
+      </if>
+      <if test="videoId2 != null">
+        video_id_2 = #{videoId2,jdbcType=BIGINT},
+      </if>
+      <if test="videoId3 != null">
+        video_id_3 = #{videoId3,jdbcType=BIGINT},
+      </if>
+      <if test="isSend != null">
+        is_send = #{isSend,jdbcType=INTEGER},
+      </if>
+      <if test="createTime != null">
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateTime != null">
+        update_time = #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.wecom.model.po.SendMessage">
+    update we_com_send_message
+    set subject_id = #{subjectId,jdbcType=BIGINT},
+      staff_id = #{staffId,jdbcType=BIGINT},
+      user_id = #{userId,jdbcType=BIGINT},
+      video_id_1 = #{videoId1,jdbcType=BIGINT},
+      video_id_2 = #{videoId2,jdbcType=BIGINT},
+      video_id_3 = #{videoId3,jdbcType=BIGINT},
+      is_send = #{isSend,jdbcType=INTEGER},
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      update_time = #{updateTime,jdbcType=TIMESTAMP}
+    where id = #{id,jdbcType=BIGINT}
+  </update>
 
-    <select id="getGroupList" resultMap="BaseResultMap">
-        select staff_id, video_id_1, video_id_2, video_id_3
-        from we_com_send_message
-        where create_time >= #{createTime} and is_send = #{isSend}
-        group by staff_id, video_id_1, video_id_2, video_id_3
-    </select>
+  <insert id="insertList" parameterType="java.util.List">
+    insert into we_com_send_message
+    (
+    subject_id,
+    staff_id,
+    user_id,
+    video_id_1,
+    video_id_2,
+    video_id_3
+    )
+    values
+    <foreach collection="list" item="item" separator=",">
+      (
+      #{item.subjectId,jdbcType=BIGINT},
+      #{item.staffId,jdbcType=BIGINT},
+      #{item.userId,jdbcType=BIGINT},
+      #{item.videoId1,jdbcType=BIGINT},
+      #{item.videoId2,jdbcType=BIGINT},
+      #{item.videoId3,jdbcType=BIGINT}
+      )
+    </foreach>
+  </insert>
 
-    <select id="selectExternalUserId3rdParty" parameterType="com.tzld.piaoquan.wecom.model.po.SendMessage" resultType="java.lang.String">
-        select
-            t2.external_user_id_3rd_party
-        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>
+  <select id="getGroupList" resultMap="BaseResultMap">
+      select subject_id, staff_id, video_id_1, video_id_2, video_id_3
+      from we_com_send_message
+      where create_time >= #{createTime}
+        and is_send = #{isSend}
+      group by subject_id, staff_id, video_id_1, video_id_2, video_id_3
+  </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>
+  <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.subject_id = #{record.subjectId}
+      and 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>

+ 54 - 6
we-com-server/src/main/resources/mapper/StaffMapper.xml

@@ -3,9 +3,12 @@
 <mapper namespace="com.tzld.piaoquan.wecom.dao.mapper.StaffMapper">
   <resultMap id="BaseResultMap" type="com.tzld.piaoquan.wecom.model.po.Staff">
     <id column="id" jdbcType="BIGINT" property="id" />
+    <result column="subject_id" jdbcType="BIGINT" property="subjectId" />
     <result column="staff_ext_id" jdbcType="VARCHAR" property="staffExtId" />
     <result column="carrier_id" jdbcType="VARCHAR" property="carrierId" />
     <result column="remark" jdbcType="VARCHAR" property="remark" />
+    <result column="category1" jdbcType="VARCHAR" property="category1" />
+    <result column="category2" jdbcType="VARCHAR" property="category2" />
     <result column="is_delete" jdbcType="INTEGER" property="isDelete" />
     <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
     <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
@@ -69,7 +72,8 @@
     </where>
   </sql>
   <sql id="Base_Column_List">
-    id, staff_ext_id, carrier_id, remark, is_delete, create_time, update_time
+    id, subject_id, staff_ext_id, carrier_id, remark, category1, category2, is_delete, 
+    create_time, update_time
   </sql>
   <select id="selectByExample" parameterType="com.tzld.piaoquan.wecom.model.po.StaffExample" resultMap="BaseResultMap">
     select
@@ -105,11 +109,13 @@
     </if>
   </delete>
   <insert id="insert" parameterType="com.tzld.piaoquan.wecom.model.po.Staff">
-    insert into we_com_staff (id, staff_ext_id, carrier_id, 
-      remark, create_time,
+    insert into we_com_staff (id, subject_id, staff_ext_id, 
+      carrier_id, remark, category1, 
+      category2, create_time,
       update_time)
-    values (#{id,jdbcType=BIGINT}, #{staffExtId,jdbcType=VARCHAR}, #{carrierId,jdbcType=VARCHAR}, 
-      #{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
+    values (#{id,jdbcType=BIGINT}, #{subjectId,jdbcType=BIGINT}, #{staffExtId,jdbcType=VARCHAR}, 
+      #{carrierId,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{category1,jdbcType=VARCHAR}, 
+      #{category2,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
       #{updateTime,jdbcType=TIMESTAMP})
   </insert>
   <insert id="insertSelective" parameterType="com.tzld.piaoquan.wecom.model.po.Staff">
@@ -118,6 +124,9 @@
       <if test="id != null">
         id,
       </if>
+      <if test="subjectId != null">
+        subject_id,
+      </if>
       <if test="staffExtId != null">
         staff_ext_id,
       </if>
@@ -127,6 +136,12 @@
       <if test="remark != null">
         remark,
       </if>
+      <if test="category1 != null">
+        category1,
+      </if>
+      <if test="category2 != null">
+        category2,
+      </if>
       <if test="isDelete != null">
         is_delete,
       </if>
@@ -141,6 +156,9 @@
       <if test="id != null">
         #{id,jdbcType=BIGINT},
       </if>
+      <if test="subjectId != null">
+        #{subjectId,jdbcType=BIGINT},
+      </if>
       <if test="staffExtId != null">
         #{staffExtId,jdbcType=VARCHAR},
       </if>
@@ -150,6 +168,12 @@
       <if test="remark != null">
         #{remark,jdbcType=VARCHAR},
       </if>
+      <if test="category1 != null">
+        #{category1,jdbcType=VARCHAR},
+      </if>
+      <if test="category2 != null">
+        #{category2,jdbcType=VARCHAR},
+      </if>
       <if test="isDelete != null">
         #{isDelete,jdbcType=INTEGER},
       </if>
@@ -173,6 +197,9 @@
       <if test="record.id != null">
         id = #{record.id,jdbcType=BIGINT},
       </if>
+      <if test="record.subjectId != null">
+        subject_id = #{record.subjectId,jdbcType=BIGINT},
+      </if>
       <if test="record.staffExtId != null">
         staff_ext_id = #{record.staffExtId,jdbcType=VARCHAR},
       </if>
@@ -182,6 +209,12 @@
       <if test="record.remark != null">
         remark = #{record.remark,jdbcType=VARCHAR},
       </if>
+      <if test="record.category1 != null">
+        category1 = #{record.category1,jdbcType=VARCHAR},
+      </if>
+      <if test="record.category2 != null">
+        category2 = #{record.category2,jdbcType=VARCHAR},
+      </if>
       <if test="record.isDelete != null">
         is_delete = #{record.isDelete,jdbcType=INTEGER},
       </if>
@@ -199,9 +232,12 @@
   <update id="updateByExample" parameterType="map">
     update we_com_staff
     set id = #{record.id,jdbcType=BIGINT},
+      subject_id = #{record.subjectId,jdbcType=BIGINT},
       staff_ext_id = #{record.staffExtId,jdbcType=VARCHAR},
       carrier_id = #{record.carrierId,jdbcType=VARCHAR},
       remark = #{record.remark,jdbcType=VARCHAR},
+      category1 = #{record.category1,jdbcType=VARCHAR},
+      category2 = #{record.category2,jdbcType=VARCHAR},
       is_delete = #{record.isDelete,jdbcType=INTEGER},
       create_time = #{record.createTime,jdbcType=TIMESTAMP},
       update_time = #{record.updateTime,jdbcType=TIMESTAMP}
@@ -212,6 +248,9 @@
   <update id="updateByPrimaryKeySelective" parameterType="com.tzld.piaoquan.wecom.model.po.Staff">
     update we_com_staff
     <set>
+      <if test="subjectId != null">
+        subject_id = #{subjectId,jdbcType=BIGINT},
+      </if>
       <if test="staffExtId != null">
         staff_ext_id = #{staffExtId,jdbcType=VARCHAR},
       </if>
@@ -221,6 +260,12 @@
       <if test="remark != null">
         remark = #{remark,jdbcType=VARCHAR},
       </if>
+      <if test="category1 != null">
+        category1 = #{category1,jdbcType=VARCHAR},
+      </if>
+      <if test="category2 != null">
+        category2 = #{category2,jdbcType=VARCHAR},
+      </if>
       <if test="isDelete != null">
         is_delete = #{isDelete,jdbcType=INTEGER},
       </if>
@@ -235,9 +280,12 @@
   </update>
   <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.wecom.model.po.Staff">
     update we_com_staff
-    set staff_ext_id = #{staffExtId,jdbcType=VARCHAR},
+    set subject_id = #{subjectId,jdbcType=BIGINT},
+      staff_ext_id = #{staffExtId,jdbcType=VARCHAR},
       carrier_id = #{carrierId,jdbcType=VARCHAR},
       remark = #{remark,jdbcType=VARCHAR},
+      category1 = #{category1,jdbcType=VARCHAR},
+      category2 = #{category2,jdbcType=VARCHAR},
       is_delete = #{isDelete,jdbcType=INTEGER},
       create_time = #{createTime,jdbcType=TIMESTAMP},
       update_time = #{updateTime,jdbcType=TIMESTAMP}

+ 246 - 0
we-com-server/src/main/resources/mapper/SubjectMapper.xml

@@ -0,0 +1,246 @@
+<?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.SubjectMapper">
+  <resultMap id="BaseResultMap" type="com.tzld.piaoquan.wecom.model.po.Subject">
+    <id column="id" jdbcType="BIGINT" property="id" />
+    <result column="name" jdbcType="VARCHAR" property="name" />
+    <result column="crop_id" jdbcType="VARCHAR" property="cropId" />
+    <result column="secret" jdbcType="VARCHAR" property="secret" />
+    <result column="is_delete" jdbcType="INTEGER" property="isDelete" />
+    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
+    <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
+  </resultMap>
+  <sql id="Example_Where_Clause">
+    <where>
+      <foreach collection="oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Update_By_Example_Where_Clause">
+    <where>
+      <foreach collection="example.oredCriteria" item="criteria" separator="or">
+        <if test="criteria.valid">
+          <trim prefix="(" prefixOverrides="and" suffix=")">
+            <foreach collection="criteria.criteria" item="criterion">
+              <choose>
+                <when test="criterion.noValue">
+                  and ${criterion.condition}
+                </when>
+                <when test="criterion.singleValue">
+                  and ${criterion.condition} #{criterion.value}
+                </when>
+                <when test="criterion.betweenValue">
+                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
+                </when>
+                <when test="criterion.listValue">
+                  and ${criterion.condition}
+                  <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
+                    #{listItem}
+                  </foreach>
+                </when>
+              </choose>
+            </foreach>
+          </trim>
+        </if>
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Base_Column_List">
+    id, `name`, crop_id, secret, is_delete, create_time, update_time
+  </sql>
+  <select id="selectByExample" parameterType="com.tzld.piaoquan.wecom.model.po.SubjectExample" resultMap="BaseResultMap">
+    select
+    <if test="distinct">
+      distinct
+    </if>
+    <include refid="Base_Column_List" />
+    from we_com_subject
+    <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_subject
+    where id = #{id,jdbcType=BIGINT}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+    delete from we_com_subject
+    where id = #{id,jdbcType=BIGINT}
+  </delete>
+  <delete id="deleteByExample" parameterType="com.tzld.piaoquan.wecom.model.po.SubjectExample">
+    delete from we_com_subject
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </delete>
+  <insert id="insert" parameterType="com.tzld.piaoquan.wecom.model.po.Subject">
+    insert into we_com_subject (id, `name`, crop_id, 
+      secret, create_time,
+      update_time)
+    values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{cropId,jdbcType=VARCHAR}, 
+      #{secret,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP},
+      #{updateTime,jdbcType=TIMESTAMP})
+  </insert>
+  <insert id="insertSelective" parameterType="com.tzld.piaoquan.wecom.model.po.Subject">
+    insert into we_com_subject
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <if test="name != null">
+        `name`,
+      </if>
+      <if test="cropId != null">
+        crop_id,
+      </if>
+      <if test="secret != null">
+        secret,
+      </if>
+      <if test="isDelete != null">
+        is_delete,
+      </if>
+      <if test="createTime != null">
+        create_time,
+      </if>
+      <if test="updateTime != null">
+        update_time,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        #{id,jdbcType=BIGINT},
+      </if>
+      <if test="name != null">
+        #{name,jdbcType=VARCHAR},
+      </if>
+      <if test="cropId != null">
+        #{cropId,jdbcType=VARCHAR},
+      </if>
+      <if test="secret != null">
+        #{secret,jdbcType=VARCHAR},
+      </if>
+      <if test="isDelete != null">
+        #{isDelete,jdbcType=INTEGER},
+      </if>
+      <if test="createTime != null">
+        #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateTime != null">
+        #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+    </trim>
+  </insert>
+  <select id="countByExample" parameterType="com.tzld.piaoquan.wecom.model.po.SubjectExample" resultType="java.lang.Long">
+    select count(*) from we_com_subject
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </select>
+  <update id="updateByExampleSelective" parameterType="map">
+    update we_com_subject
+    <set>
+      <if test="record.id != null">
+        id = #{record.id,jdbcType=BIGINT},
+      </if>
+      <if test="record.name != null">
+        `name` = #{record.name,jdbcType=VARCHAR},
+      </if>
+      <if test="record.cropId != null">
+        crop_id = #{record.cropId,jdbcType=VARCHAR},
+      </if>
+      <if test="record.secret != null">
+        secret = #{record.secret,jdbcType=VARCHAR},
+      </if>
+      <if test="record.isDelete != null">
+        is_delete = #{record.isDelete,jdbcType=INTEGER},
+      </if>
+      <if test="record.createTime != null">
+        create_time = #{record.createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="record.updateTime != null">
+        update_time = #{record.updateTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByExample" parameterType="map">
+    update we_com_subject
+    set id = #{record.id,jdbcType=BIGINT},
+      `name` = #{record.name,jdbcType=VARCHAR},
+      crop_id = #{record.cropId,jdbcType=VARCHAR},
+      secret = #{record.secret,jdbcType=VARCHAR},
+      is_delete = #{record.isDelete,jdbcType=INTEGER},
+      create_time = #{record.createTime,jdbcType=TIMESTAMP},
+      update_time = #{record.updateTime,jdbcType=TIMESTAMP}
+    <if test="_parameter != null">
+      <include refid="Update_By_Example_Where_Clause" />
+    </if>
+  </update>
+  <update id="updateByPrimaryKeySelective" parameterType="com.tzld.piaoquan.wecom.model.po.Subject">
+    update we_com_subject
+    <set>
+      <if test="name != null">
+        `name` = #{name,jdbcType=VARCHAR},
+      </if>
+      <if test="cropId != null">
+        crop_id = #{cropId,jdbcType=VARCHAR},
+      </if>
+      <if test="secret != null">
+        secret = #{secret,jdbcType=VARCHAR},
+      </if>
+      <if test="isDelete != null">
+        is_delete = #{isDelete,jdbcType=INTEGER},
+      </if>
+      <if test="createTime != null">
+        create_time = #{createTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="updateTime != null">
+        update_time = #{updateTime,jdbcType=TIMESTAMP},
+      </if>
+    </set>
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.tzld.piaoquan.wecom.model.po.Subject">
+    update we_com_subject
+    set `name` = #{name,jdbcType=VARCHAR},
+      crop_id = #{cropId,jdbcType=VARCHAR},
+      secret = #{secret,jdbcType=VARCHAR},
+      is_delete = #{isDelete,jdbcType=INTEGER},
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      update_time = #{updateTime,jdbcType=TIMESTAMP}
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+</mapper>

+ 358 - 345
we-com-server/src/main/resources/mapper/UserMapper.xml

@@ -1,366 +1,377 @@
 <?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.UserMapper">
-    <resultMap id="BaseResultMap" type="com.tzld.piaoquan.wecom.model.po.User">
-        <id column="id" jdbcType="BIGINT" property="id"/>
-        <result column="external_user_id" jdbcType="VARCHAR" property="externalUserId"/>
-        <result column="union_id" jdbcType="VARCHAR" property="unionId"/>
-        <result column="external_user_id_3rd_party" jdbcType="VARCHAR" property="externalUserId3rdParty"/>
-        <result column="type" jdbcType="INTEGER" property="type"/>
-        <result column="name" jdbcType="VARCHAR" property="name"/>
-        <result column="avatar" jdbcType="VARCHAR" property="avatar"/>
-        <result column="gender" jdbcType="INTEGER" property="gender"/>
-        <result column="is_delete" jdbcType="INTEGER" property="isDelete"/>
-        <result column="created_at" jdbcType="BIGINT" property="createdAt"/>
-        <result column="updated_at" jdbcType="BIGINT" property="updatedAt"/>
-        <result column="deleted_at" jdbcType="BIGINT" property="deletedAt"/>
-        <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.User">
+    <id column="id" jdbcType="BIGINT" property="id" />
+    <result column="subject_id" jdbcType="BIGINT" property="subjectId" />
+    <result column="external_user_id" jdbcType="VARCHAR" property="externalUserId" />
+    <result column="union_id" jdbcType="VARCHAR" property="unionId" />
+    <result column="external_user_id_3rd_party" jdbcType="VARCHAR" property="externalUserId3rdParty" />
+    <result column="type" jdbcType="INTEGER" property="type" />
+    <result column="name" jdbcType="VARCHAR" property="name" />
+    <result column="avatar" jdbcType="VARCHAR" property="avatar" />
+    <result column="gender" jdbcType="INTEGER" property="gender" />
+    <result column="is_delete" jdbcType="INTEGER" property="isDelete" />
+    <result column="created_at" jdbcType="BIGINT" property="createdAt" />
+    <result column="updated_at" jdbcType="BIGINT" property="updatedAt" />
+    <result column="deleted_at" jdbcType="BIGINT" property="deletedAt" />
+    <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
-        , external_user_id, union_id, external_user_id_3rd_party, `type`, `name`, avatar,
-    gender, is_delete, created_at, updated_at, deleted_at, create_time, update_time
-    </sql>
-    <select id="selectByExample" parameterType="com.tzld.piaoquan.wecom.model.po.UserExample" resultMap="BaseResultMap">
-        select
-        <if test="distinct">
-            distinct
-        </if>
-        <include refid="Base_Column_List"/>
-        from we_com_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_user
-        where id = #{id,jdbcType=BIGINT}
-    </select>
-    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
-        delete
-        from we_com_user
-        where id = #{id,jdbcType=BIGINT}
-    </delete>
-    <delete id="deleteByExample" parameterType="com.tzld.piaoquan.wecom.model.po.UserExample">
-        delete from we_com_user
-        <if test="_parameter != null">
-            <include refid="Example_Where_Clause"/>
-        </if>
-    </delete>
-    <insert id="insert" parameterType="com.tzld.piaoquan.wecom.model.po.User" useGeneratedKeys="true" keyProperty="id">
-        insert into we_com_user (id, external_user_id, union_id,
-        external_user_id_3rd_party, `type`, `name`,
-        avatar, gender,
-        created_at, updated_at, deleted_at,
-        create_time, update_time)
-        values (#{id,jdbcType=BIGINT}, #{externalUserId,jdbcType=VARCHAR}, #{unionId,jdbcType=VARCHAR},
-        #{externalUserId3rdParty,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR},
-        #{avatar,jdbcType=VARCHAR}, #{gender,jdbcType=INTEGER},
-        #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT}, #{deletedAt,jdbcType=BIGINT},
-        #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
-        <selectKey resultType="java.lang.Long" order="AFTER" keyProperty="id">
-            select LAST_INSERT_ID()
-        </selectKey>
-    </insert>
-    <insert id="insertSelective" parameterType="com.tzld.piaoquan.wecom.model.po.User">
-        insert into we_com_user
-        <trim prefix="(" suffix=")" suffixOverrides=",">
-            <if test="id != null">
-                id,
-            </if>
-            <if test="externalUserId != null">
-                external_user_id,
-            </if>
-            <if test="unionId != null">
-                union_id,
-            </if>
-            <if test="externalUserId3rdParty != null">
-                external_user_id_3rd_party,
-            </if>
-            <if test="type != null">
-                `type`,
-            </if>
-            <if test="name != null">
-                `name`,
-            </if>
-            <if test="avatar != null">
-                avatar,
-            </if>
-            <if test="gender != null">
-                gender,
-            </if>
-            <if test="isDelete != null">
-                is_delete,
-            </if>
-            <if test="createdAt != null">
-                created_at,
-            </if>
-            <if test="updatedAt != null">
-                updated_at,
-            </if>
-            <if test="deletedAt != null">
-                deleted_at,
-            </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="externalUserId != null">
-                #{externalUserId,jdbcType=VARCHAR},
-            </if>
-            <if test="unionId != null">
-                #{unionId,jdbcType=VARCHAR},
-            </if>
-            <if test="externalUserId3rdParty != null">
-                #{externalUserId3rdParty,jdbcType=VARCHAR},
-            </if>
-            <if test="type != null">
-                #{type,jdbcType=INTEGER},
-            </if>
-            <if test="name != null">
-                #{name,jdbcType=VARCHAR},
-            </if>
-            <if test="avatar != null">
-                #{avatar,jdbcType=VARCHAR},
-            </if>
-            <if test="gender != null">
-                #{gender,jdbcType=INTEGER},
-            </if>
-            <if test="isDelete != null">
-                #{isDelete,jdbcType=INTEGER},
-            </if>
-            <if test="createdAt != null">
-                #{createdAt,jdbcType=BIGINT},
-            </if>
-            <if test="updatedAt != null">
-                #{updatedAt,jdbcType=BIGINT},
-            </if>
-            <if test="deletedAt != null">
-                #{deletedAt,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.UserExample"
-            resultType="java.lang.Long">
-        select count(*) from we_com_user
-        <if test="_parameter != null">
-            <include refid="Example_Where_Clause"/>
+          </trim>
         </if>
-    </select>
-    <update id="updateByExampleSelective" parameterType="map">
-        update we_com_user
-        <set>
-            <if test="record.id != null">
-                id = #{record.id,jdbcType=BIGINT},
-            </if>
-            <if test="record.externalUserId != null">
-                external_user_id = #{record.externalUserId,jdbcType=VARCHAR},
-            </if>
-            <if test="record.unionId != null">
-                union_id = #{record.unionId,jdbcType=VARCHAR},
-            </if>
-            <if test="record.externalUserId3rdParty != null">
-                external_user_id_3rd_party = #{record.externalUserId3rdParty,jdbcType=VARCHAR},
-            </if>
-            <if test="record.type != null">
-                `type` = #{record.type,jdbcType=INTEGER},
-            </if>
-            <if test="record.name != null">
-                `name` = #{record.name,jdbcType=VARCHAR},
-            </if>
-            <if test="record.avatar != null">
-                avatar = #{record.avatar,jdbcType=VARCHAR},
-            </if>
-            <if test="record.gender != null">
-                gender = #{record.gender,jdbcType=INTEGER},
-            </if>
-            <if test="record.isDelete != null">
-                is_delete = #{record.isDelete,jdbcType=INTEGER},
-            </if>
-            <if test="record.createdAt != null">
-                created_at = #{record.createdAt,jdbcType=BIGINT},
-            </if>
-            <if test="record.updatedAt != null">
-                updated_at = #{record.updatedAt,jdbcType=BIGINT},
-            </if>
-            <if test="record.deletedAt != null">
-                deleted_at = #{record.deletedAt,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_user
-        set id = #{record.id,jdbcType=BIGINT},
+      </foreach>
+    </where>
+  </sql>
+  <sql id="Base_Column_List">
+    id, subject_id, external_user_id, union_id, external_user_id_3rd_party, `type`, `name`,
+    avatar, gender, is_delete, created_at, updated_at, deleted_at, create_time, update_time
+  </sql>
+  <select id="selectByExample" parameterType="com.tzld.piaoquan.wecom.model.po.UserExample" resultMap="BaseResultMap">
+    select
+    <if test="distinct">
+      distinct
+    </if>
+    <include refid="Base_Column_List" />
+    from we_com_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_user
+    where id = #{id,jdbcType=BIGINT}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+    delete from we_com_user
+    where id = #{id,jdbcType=BIGINT}
+  </delete>
+  <delete id="deleteByExample" parameterType="com.tzld.piaoquan.wecom.model.po.UserExample">
+    delete from we_com_user
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </delete>
+  <insert id="insert" parameterType="com.tzld.piaoquan.wecom.model.po.User" useGeneratedKeys="true" keyProperty="id">
+    insert into we_com_user (id, subject_id,external_user_id, union_id,
+    external_user_id_3rd_party, `type`, `name`,
+    avatar, gender,
+    created_at, updated_at, deleted_at,
+    create_time, update_time)
+    values (#{id,jdbcType=BIGINT}, #{subjectId,jdbcType=BIGINT}, #{externalUserId,jdbcType=VARCHAR},
+    #{unionId,jdbcType=VARCHAR},
+    #{externalUserId3rdParty,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR},
+    #{avatar,jdbcType=VARCHAR}, #{gender,jdbcType=INTEGER},
+    #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT}, #{deletedAt,jdbcType=BIGINT},
+    #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP})
+    <selectKey resultType="java.lang.Long" order="AFTER" keyProperty="id">
+      select LAST_INSERT_ID()
+    </selectKey>
+  </insert>
+  <insert id="insertSelective" parameterType="com.tzld.piaoquan.wecom.model.po.User">
+    insert into we_com_user
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
+        id,
+      </if>
+      <if test="subjectId != null">
+        subject_id,
+      </if>
+      <if test="externalUserId != null">
+        external_user_id,
+      </if>
+      <if test="unionId != null">
+        union_id,
+      </if>
+      <if test="externalUserId3rdParty != null">
+        external_user_id_3rd_party,
+      </if>
+      <if test="type != null">
+        `type`,
+      </if>
+      <if test="name != null">
+        `name`,
+      </if>
+      <if test="avatar != null">
+        avatar,
+      </if>
+      <if test="gender != null">
+        gender,
+      </if>
+      <if test="isDelete != null">
+        is_delete,
+      </if>
+      <if test="createdAt != null">
+        created_at,
+      </if>
+      <if test="updatedAt != null">
+        updated_at,
+      </if>
+      <if test="deletedAt != null">
+        deleted_at,
+      </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="subjectId != null">
+        #{subjectId,jdbcType=BIGINT},
+      </if>
+      <if test="externalUserId != null">
+        #{externalUserId,jdbcType=VARCHAR},
+      </if>
+      <if test="unionId != null">
+        #{unionId,jdbcType=VARCHAR},
+      </if>
+      <if test="externalUserId3rdParty != null">
+        #{externalUserId3rdParty,jdbcType=VARCHAR},
+      </if>
+      <if test="type != null">
+        #{type,jdbcType=INTEGER},
+      </if>
+      <if test="name != null">
+        #{name,jdbcType=VARCHAR},
+      </if>
+      <if test="avatar != null">
+        #{avatar,jdbcType=VARCHAR},
+      </if>
+      <if test="gender != null">
+        #{gender,jdbcType=INTEGER},
+      </if>
+      <if test="isDelete != null">
+        #{isDelete,jdbcType=INTEGER},
+      </if>
+      <if test="createdAt != null">
+        #{createdAt,jdbcType=BIGINT},
+      </if>
+      <if test="updatedAt != null">
+        #{updatedAt,jdbcType=BIGINT},
+      </if>
+      <if test="deletedAt != null">
+        #{deletedAt,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.UserExample" resultType="java.lang.Long">
+    select count(*) from we_com_user
+    <if test="_parameter != null">
+      <include refid="Example_Where_Clause" />
+    </if>
+  </select>
+  <update id="updateByExampleSelective" parameterType="map">
+    update we_com_user
+    <set>
+      <if test="record.id != null">
+        id = #{record.id,jdbcType=BIGINT},
+      </if>
+      <if test="record.subjectId != null">
+        subject_id = #{record.subjectId,jdbcType=BIGINT},
+      </if>
+      <if test="record.externalUserId != null">
         external_user_id = #{record.externalUserId,jdbcType=VARCHAR},
+      </if>
+      <if test="record.unionId != null">
         union_id = #{record.unionId,jdbcType=VARCHAR},
+      </if>
+      <if test="record.externalUserId3rdParty != null">
         external_user_id_3rd_party = #{record.externalUserId3rdParty,jdbcType=VARCHAR},
+      </if>
+      <if test="record.type != null">
         `type` = #{record.type,jdbcType=INTEGER},
+      </if>
+      <if test="record.name != null">
         `name` = #{record.name,jdbcType=VARCHAR},
+      </if>
+      <if test="record.avatar != null">
         avatar = #{record.avatar,jdbcType=VARCHAR},
+      </if>
+      <if test="record.gender != null">
         gender = #{record.gender,jdbcType=INTEGER},
+      </if>
+      <if test="record.isDelete != null">
         is_delete = #{record.isDelete,jdbcType=INTEGER},
+      </if>
+      <if test="record.createdAt != null">
         created_at = #{record.createdAt,jdbcType=BIGINT},
+      </if>
+      <if test="record.updatedAt != null">
         updated_at = #{record.updatedAt,jdbcType=BIGINT},
+      </if>
+      <if test="record.deletedAt != null">
         deleted_at = #{record.deletedAt,jdbcType=BIGINT},
+      </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.User">
-        update we_com_user
-        <set>
-            <if test="externalUserId != null">
-                external_user_id = #{externalUserId,jdbcType=VARCHAR},
-            </if>
-            <if test="unionId != null">
-                union_id = #{unionId,jdbcType=VARCHAR},
-            </if>
-            <if test="externalUserId3rdParty != null">
-                external_user_id_3rd_party = #{externalUserId3rdParty,jdbcType=VARCHAR},
-            </if>
-            <if test="type != null">
-                `type` = #{type,jdbcType=INTEGER},
-            </if>
-            <if test="name != null">
-                `name` = #{name,jdbcType=VARCHAR},
-            </if>
-            <if test="avatar != null">
-                avatar = #{avatar,jdbcType=VARCHAR},
-            </if>
-            <if test="gender != null">
-                gender = #{gender,jdbcType=INTEGER},
-            </if>
-            <if test="isDelete != null">
-                is_delete = #{isDelete,jdbcType=INTEGER},
-            </if>
-            <if test="createdAt != null">
-                created_at = #{createdAt,jdbcType=BIGINT},
-            </if>
-            <if test="updatedAt != null">
-                updated_at = #{updatedAt,jdbcType=BIGINT},
-            </if>
-            <if test="deletedAt != null">
-                deleted_at = #{deletedAt,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.User">
-        update we_com_user
-        set external_user_id           = #{externalUserId,jdbcType=VARCHAR},
-            union_id                   = #{unionId,jdbcType=VARCHAR},
-            external_user_id_3rd_party = #{externalUserId3rdParty,jdbcType=VARCHAR},
-            `type`                     = #{type,jdbcType=INTEGER},
-            `name`                     = #{name,jdbcType=VARCHAR},
-            avatar                     = #{avatar,jdbcType=VARCHAR},
-            gender                     = #{gender,jdbcType=INTEGER},
-            is_delete                  = #{isDelete,jdbcType=INTEGER},
-            created_at                 = #{createdAt,jdbcType=BIGINT},
-            updated_at                 = #{updatedAt,jdbcType=BIGINT},
-            deleted_at                 = #{deletedAt,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_user
+    set id = #{record.id,jdbcType=BIGINT},
+      subject_id = #{record.subjectId,jdbcType=BIGINT},
+      external_user_id = #{record.externalUserId,jdbcType=VARCHAR},
+      union_id = #{record.unionId,jdbcType=VARCHAR},
+      external_user_id_3rd_party = #{record.externalUserId3rdParty,jdbcType=VARCHAR},
+      `type` = #{record.type,jdbcType=INTEGER},
+      `name` = #{record.name,jdbcType=VARCHAR},
+      avatar = #{record.avatar,jdbcType=VARCHAR},
+      gender = #{record.gender,jdbcType=INTEGER},
+      is_delete = #{record.isDelete,jdbcType=INTEGER},
+      created_at = #{record.createdAt,jdbcType=BIGINT},
+      updated_at = #{record.updatedAt,jdbcType=BIGINT},
+      deleted_at = #{record.deletedAt,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.wecom.model.po.User">
+    update we_com_user
+    <set>
+      <if test="subjectId != null">
+        subject_id = #{subjectId,jdbcType=BIGINT},
+      </if>
+      <if test="externalUserId != null">
+        external_user_id = #{externalUserId,jdbcType=VARCHAR},
+      </if>
+      <if test="unionId != null">
+        union_id = #{unionId,jdbcType=VARCHAR},
+      </if>
+      <if test="externalUserId3rdParty != null">
+        external_user_id_3rd_party = #{externalUserId3rdParty,jdbcType=VARCHAR},
+      </if>
+      <if test="type != null">
+        `type` = #{type,jdbcType=INTEGER},
+      </if>
+      <if test="name != null">
+        `name` = #{name,jdbcType=VARCHAR},
+      </if>
+      <if test="avatar != null">
+        avatar = #{avatar,jdbcType=VARCHAR},
+      </if>
+      <if test="gender != null">
+        gender = #{gender,jdbcType=INTEGER},
+      </if>
+      <if test="isDelete != null">
+        is_delete = #{isDelete,jdbcType=INTEGER},
+      </if>
+      <if test="createdAt != null">
+        created_at = #{createdAt,jdbcType=BIGINT},
+      </if>
+      <if test="updatedAt != null">
+        updated_at = #{updatedAt,jdbcType=BIGINT},
+      </if>
+      <if test="deletedAt != null">
+        deleted_at = #{deletedAt,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.User">
+    update we_com_user
+    set subject_id = #{subjectId,jdbcType=BIGINT},
+      external_user_id = #{externalUserId,jdbcType=VARCHAR},
+      union_id = #{unionId,jdbcType=VARCHAR},
+      external_user_id_3rd_party = #{externalUserId3rdParty,jdbcType=VARCHAR},
+      `type` = #{type,jdbcType=INTEGER},
+      `name` = #{name,jdbcType=VARCHAR},
+      avatar = #{avatar,jdbcType=VARCHAR},
+      gender = #{gender,jdbcType=INTEGER},
+      is_delete = #{isDelete,jdbcType=INTEGER},
+      created_at = #{createdAt,jdbcType=BIGINT},
+      updated_at = #{updatedAt,jdbcType=BIGINT},
+      deleted_at = #{deletedAt,jdbcType=BIGINT},
+      create_time = #{createTime,jdbcType=TIMESTAMP},
+      update_time = #{updateTime,jdbcType=TIMESTAMP}
+    where id = #{id,jdbcType=BIGINT}
+  </update>
 
 
     <select id="selectIdByExternalUserId3rdParty" parameterType="String" resultType="Long">
@@ -378,6 +389,7 @@
     <insert id="insertList" parameterType="java.util.List">
         insert into we_com_user
         (
+        subject_id,
         external_user_id,
         union_id,
         external_user_id_3rd_party,
@@ -394,6 +406,7 @@
         values
         <foreach collection="list" item="item" separator=",">
             (
+            #{item.subjectId,jdbcType=BIGINT}
             #{item.externalUserId,jdbcType=VARCHAR},
             #{item.unionId,jdbcType=VARCHAR},
             #{item.externalUserId3rdParty,jdbcType=VARCHAR},

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

@@ -56,6 +56,9 @@
 <!--        <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_user" domainObjectName="User" alias=""/>-->
+<!--        <table tableName="we_com_subject" domainObjectName="Subject" alias=""/>-->
+
 
 
     </context>