Commit 2e5f22d4 by 孙喜旺

1、删除老会话存档接口

2、客户群相关字段添加和业务修改
1 parent 01478808
Showing 27 changed files with 226 additions and 1017 deletions
package com.linkwechat.web.controller.wecom;
import com.github.pagehelper.PageInfo;
import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.common.utils.poi.ExcelUtil;
import com.linkwechat.wecom.domain.WeChatContactMapping;
import com.linkwechat.wecom.domain.WeCustomer;
import com.linkwechat.wecom.service.IWeChatContactMappingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 聊天关系映射Controller
*
* @author ruoyi
* @date 2020-12-27
*/
@Api("聊天关系映射Controller")
@RestController
@RequestMapping("/chat/mapping")
public class WeChatContactMappingController extends BaseController
{
@Autowired
private IWeChatContactMappingService weChatContactMappingService;
/**
* 查询聊天关系映射列表
*/
// @PreAuthorize("@ss.hasPermi('chat:mapping:list')")
@ApiOperation(value = "查询聊天关系映射列表",httpMethod = "GET")
@GetMapping("/list")
public TableDataInfo<List<WeChatContactMapping>> list(WeChatContactMapping weChatContactMapping)
{
startPage();
List<WeChatContactMapping> list = weChatContactMappingService.selectWeChatContactMappingList(weChatContactMapping);
return getDataTable(list);
}
/**
* 按客户查询关系映射列表
*/
// @PreAuthorize("@ss.hasPermi('chat:mapping:listByCustomer')")
@ApiOperation(value = "按客户查询关系映射列表",httpMethod = "GET")
@GetMapping("/listByCustomer")
public TableDataInfo<PageInfo<WeCustomer>> listByCustomer()
{
startPage();
PageInfo<WeCustomer> weCustomerPageInfo = weChatContactMappingService.listByCustomer();
return getDataTable(weCustomerPageInfo);
}
/**
* 导出聊天关系映射列表
*/
// @PreAuthorize("@ss.hasPermi('chat:mapping:export')")
@Log(title = "聊天关系映射", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(WeChatContactMapping weChatContactMapping)
{
List<WeChatContactMapping> list = weChatContactMappingService.selectWeChatContactMappingList(weChatContactMapping);
ExcelUtil<WeChatContactMapping> util = new ExcelUtil<WeChatContactMapping>(WeChatContactMapping.class);
return util.exportExcel(list, "mapping");
}
/**
* 获取聊天关系映射详细信息
*/
// @PreAuthorize("@ss.hasPermi('chat:mapping:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return AjaxResult.success(weChatContactMappingService.selectWeChatContactMappingById(id));
}
/**
* 新增聊天关系映射
*/
// @PreAuthorize("@ss.hasPermi('chat:mapping:add')")
@Log(title = "聊天关系映射", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody WeChatContactMapping weChatContactMapping)
{
return toAjax(weChatContactMappingService.insertWeChatContactMapping(weChatContactMapping));
}
/**
* 修改聊天关系映射
*/
// @PreAuthorize("@ss.hasPermi('chat:mapping:edit')")
@Log(title = "聊天关系映射", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody WeChatContactMapping weChatContactMapping)
{
return toAjax(weChatContactMappingService.updateWeChatContactMapping(weChatContactMapping));
}
/**
* 删除聊天关系映射
*/
// @PreAuthorize("@ss.hasPermi('chat:mapping:remove')")
@Log(title = "聊天关系映射", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(weChatContactMappingService.deleteWeChatContactMappingByIds(ids));
}
}
package com.linkwechat.web.controller.wecom;
import com.github.pagehelper.PageInfo;
import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.ConversationArchiveQuery;
import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.wecom.domain.vo.ConversationArchiveVo;
import com.linkwechat.wecom.service.IWeConversationArchiveService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author danmo
* @description 会话存档controller
* @date 2020/12/19 13:51
**/
@Api("会话存档controller")
@Slf4j
@RestController
@RequestMapping("/wecom/finance")
public class WeConversationArchiveController extends BaseController {
@Autowired
private IWeConversationArchiveService weConversationArchiveService;
/**
* 获取单聊会话数据接口
*
* @param query 入参
* @param /fromId 发送人id
* @param /reveiceId 接收人id
* @return
*/
// @PreAuthorize("@ss.hasPermi('conversationArchive:chatContact:list')")
@ApiOperation(value = "获取单聊会话数据接口",httpMethod = "GET")
@GetMapping("/getChatContactList")
public TableDataInfo<PageInfo<ConversationArchiveVo>> getChatContactList(ConversationArchiveQuery query) {
return getDataTable(weConversationArchiveService.getChatContactList(query));
}
/**
* 获取群聊会话数据接口
*
* @param query 入参
* @param /fromId 发送人id
* @param /room 接收人id
* @return
*/
// @PreAuthorize("@ss.hasPermi('conversationArchive:chatRoomContact:list')")
@ApiOperation(value = "获取群聊会话数据接口",httpMethod = "GET")
@GetMapping("/getChatRoomContactList")
public TableDataInfo<PageInfo<ConversationArchiveVo>> getChatRoomContactList(ConversationArchiveQuery query) {
return getDataTable(weConversationArchiveService.getChatRoomContactList(query));
}
/**
* 获取全局会话数据接口
*
* @param query 入参
* @return
*/
// @PreAuthorize("@ss.hasPermi('conversationArchive:chatAllContact:list')")
@ApiOperation(value = "获取全局会话数据接口",httpMethod = "GET")
@GetMapping("/getChatAllList")
public TableDataInfo<PageInfo<ConversationArchiveVo>> getChatAllList(ConversationArchiveQuery query) {
return getDataTable(weConversationArchiveService.getChatAllList(query));
}
}
package com.linkwechat.wecom.aspectj;
import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.common.utils.SecurityUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.context.annotation.Configuration;
import java.util.Collection;
import java.util.Date;
/**
* @author danmo
*/
@Aspect
@Configuration
public class InsertAndUpdateAspect {
@Pointcut("execution( * com.linkwechat.wecom.mapper.*Mapper.insert*(..)))")
public void executeInsert() {
}
@Pointcut("execution( * com.linkwechat.wecom.mapper.*Mapper.update*(..)))")
public void executeUpdate() {
}
@Before(value = "executeInsert()")
public void insertHandle(JoinPoint joinPoint) {
Object[] args = joinPoint.getArgs();
if (args.length > 0L) {
for (int i = 0; i < args.length; i++) {
Object arg = args[i];
if (arg instanceof Collection) {
Collection collection = (Collection) arg;
for (Object next : collection) {
isInsertBaseEntity(next);
}
} else if (arg instanceof BaseEntity) {
isInsertBaseEntity(arg);
}
}
}
}
private void isInsertBaseEntity(Object arg) {
if (arg instanceof BaseEntity) {
BaseEntity next1 = (BaseEntity) arg;
next1.setCreateBy(SecurityUtils.getUsername());
next1.setUpdateBy(SecurityUtils.getUsername());
Date date = new Date();
if (next1.getCreateTime() == null) {
next1.setCreateTime(date);
}
if (next1.getUpdateTime() == null) {
next1.setUpdateTime(date);
}
}
}
@Before(value = "executeUpdate()")
public void updateHandle(JoinPoint joinPoint) {
Object[] args = joinPoint.getArgs();
if (args.length > 0L) {
for (int i = 0; i < args.length; i++) {
Object arg = args[i];
if (arg instanceof Collection) {
Collection collection = (Collection) arg;
for (Object next : collection) {
if (next instanceof BaseEntity) {
BaseEntity next1 = (BaseEntity) next;
next1.setUpdateBy(SecurityUtils.getUsername());
Date date = new Date();
if (next1.getUpdateTime() == null) {
next1.setUpdateTime(date);
}
}
}
} else if (arg instanceof BaseEntity) {
BaseEntity arg1 = (BaseEntity) arg;
arg1.setUpdateBy(SecurityUtils.getUsername());
Date date = new Date();
if (arg1.getUpdateTime() == null) {
arg1.setUpdateTime(date);
}
}
}
}
}
}
package com.linkwechat.wecom.domain;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.linkwechat.common.annotation.Excel;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 聊天关系映射对象 we_chat_contact_mapping
*
* @author ruoyi
* @date 2020-12-27
*/
@ApiModel
@Data
public class WeChatContactMapping {
private static final long serialVersionUID = 1L;
/**
* 主键id
*/
private Long id;
/**
* 发送人id
*/
@ApiModelProperty("发送人id")
@Excel(name = "发送人id")
private String fromId;
/**
* 接收人id
*/
@ApiModelProperty("接收人id")
@Excel(name = "接收人id")
private String receiveId;
/**
* 群聊id
*/
@ApiModelProperty("群聊id")
@Excel(name = "群聊id")
private String roomId;
/**
* 是否为客户 0-成员 1-客户 2-机器人
*/
@ApiModelProperty("是否为客户 0-成员 1-客户 2-机器人")
@Excel(name = "是否为客户 0-成员 1-客户 2-机器人")
private Integer isCustom;
/**
* 是否为客户 0-内部 1-外部 2-群聊
*/
@ApiModelProperty("是否为客户 0-内部 1-外部 2-群聊")
@TableField(exist = false)
private Integer searchType;
/**
* 内部发送人信息
*/
@ApiModelProperty("内部发送人信息")
@TableField(exist = false)
private WeUser fromWeUser;
/**
* 外部发送人信息
*/
@ApiModelProperty("外部发送人信息")
@TableField(exist = false)
private WeCustomer fromWeCustomer;
/**
* 内部接收人信息
*/
@ApiModelProperty("内部接收人信息")
@TableField(exist = false)
private WeUser receiveWeUser;
/**
* 外部接收人信息
*/
@ApiModelProperty("外部接收人信息")
@TableField(exist = false)
private WeCustomer receiveWeCustomer;
/**
* 群信息
*/
@ApiModelProperty("群信息")
@TableField(exist = false)
private WeGroup roomInfo;
/**
* 最后一条聊天数据
*/
@ApiModelProperty("最后一条聊天数据")
@TableField(exist = false)
private JSONObject finalChatContext;
}
...@@ -86,11 +86,4 @@ private static final long serialVersionUID=1L; ...@@ -86,11 +86,4 @@ private static final long serialVersionUID=1L;
@ApiModelProperty(value = "是否为外部聊天 0 外部 1 内部", hidden = true) @ApiModelProperty(value = "是否为外部聊天 0 外部 1 内部", hidden = true)
private Integer isExternal; private Integer isExternal;
/**
* 名称
*/
@ApiModelProperty("名称")
@TableField(exist = false)
private String name;
} }
...@@ -28,7 +28,7 @@ import java.util.Date; ...@@ -28,7 +28,7 @@ import java.util.Date;
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@TableName("we_group") @TableName("we_group")
public class WeGroup { public class WeGroup extends BaseEntity{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@TableId @TableId
...@@ -38,9 +38,6 @@ public class WeGroup { ...@@ -38,9 +38,6 @@ public class WeGroup {
@ApiModelProperty(value = "群名") @ApiModelProperty(value = "群名")
private String groupName; private String groupName;
@TableField(exist = false)
private Long memberNum;
@ApiModelProperty(value = "群公告") @ApiModelProperty(value = "群公告")
private String notice; private String notice;
...@@ -50,36 +47,25 @@ public class WeGroup { ...@@ -50,36 +47,25 @@ public class WeGroup {
@ApiModelProperty(value = "0 - 正常;1 - 跟进人离职;2 - 离职继承中;3 - 离职继承完成") @ApiModelProperty(value = "0 - 正常;1 - 跟进人离职;2 - 离职继承中;3 - 离职继承完成")
private Integer status; private Integer status;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime; private Date addTime;
@TableField(exist = false) @ApiModelProperty(value = "管理员id")
private String groupLeaderName; private String adminUserId;
@TableField(exist = false) @TableField(exist = false)
private String groupLeader; private String groupLeaderName;
@TableField(exist = false) @TableField(exist = false)
@JsonFormat( pattern = "yyyy-MM-dd") private String groupLeader;
private String beginTime;
@TableField(exist = false) @TableField(exist = false)
@JsonFormat(pattern = "yyyy-MM-dd") private Long memberNum;
private String endTime;
/**员工id*/ /**员工id*/
@TableField(exist = false) @TableField(exist = false)
@ApiModelProperty(value = "员工id") @ApiModelProperty(value = "员工id")
private String userIds; private String userIds;
/**
* 群头像
*/
@TableField(exist = false)
@ApiModelProperty(value = "群头像")
private String avatar;
} }
package com.linkwechat.wecom.domain; package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.linkwechat.common.core.domain.BaseEntity; import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.common.utils.SnowFlakeUtil; import com.linkwechat.common.utils.SnowFlakeUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.models.auth.In; import io.swagger.models.auth.In;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
...@@ -20,40 +23,46 @@ import java.util.Date; ...@@ -20,40 +23,46 @@ import java.util.Date;
* @Description: * @Description:
* @Date: create in 2020/9/21 0021 23:56 * @Date: create in 2020/9/21 0021 23:56
*/ */
@ApiModel
@Data @Data
@TableName("we_group_member") @TableName("we_group_member")
@Builder @Builder
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class WeGroupMember { public class WeGroupMember extends BaseEntity{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@TableId @ApiModelProperty(value = "主键id")
private Long id= SnowFlakeUtil.nextId();; @TableId(type = IdType.AUTO)
@TableField("id")
private Long id;
@NotBlank(message = "groupId") @ApiModelProperty(value = "群id")
private String chatId; private String chatId;
@TableField(exist = false) @ApiModelProperty(value = "入群时间")
private String memberName; @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date joinTime; private Date joinTime;
/**入群方式: 1 - 由成员邀请入群(直接邀请入群) ; 2 - 由成员邀请入群(通过邀请链接入群); 3 - 通过扫描群二维码入群 */ /**入群方式: 1 - 由成员邀请入群(直接邀请入群) ; 2 - 由成员邀请入群(通过邀请链接入群); 3 - 通过扫描群二维码入群 */
@ApiModelProperty(value = "入群方式: 1 - 由成员邀请入群(直接邀请入群) ; 2 - 由成员邀请入群(通过邀请链接入群); 3 - 通过扫描群二维码入群")
private Integer joinScene; private Integer joinScene;
@TableField(value="type") @ApiModelProperty(value = "成员类型:1 - 企业成员;2 - 外部联系人")
private Integer joinType; private Integer type;
@ApiModelProperty("群成员id")
private String userId; private String userId;
@ApiModelProperty("外部联系人在微信开放平台的唯一身份标识")
private String unionId; private String unionId;
@ApiModelProperty("在群里的昵称")
private String groupNickName;
@ApiModelProperty("名字")
private String name;
@ApiModelProperty("邀请人userId")
private String invitorUserId;
} }
package com.linkwechat.wecom.domain.dto.customer; package com.linkwechat.wecom.domain.dto.customer;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.linkwechat.wecom.domain.dto.WeResultDto; import com.linkwechat.wecom.domain.dto.WeResultDto;
import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import java.util.Date; import java.util.Date;
...@@ -14,14 +17,14 @@ import java.util.List; ...@@ -14,14 +17,14 @@ import java.util.List;
@Data @Data
public class CustomerGroupDetail extends WeResultDto { public class CustomerGroupDetail extends WeResultDto {
private List<GroupChat> group_chat; private List<GroupChat> groupChat;
@Data @Data
public class GroupChat{ public class GroupChat{
/**客户群ID*/ /**客户群ID*/
private String chat_id; private String chatId;
/**群名*/ /**群名*/
...@@ -31,13 +34,16 @@ public class CustomerGroupDetail extends WeResultDto { ...@@ -31,13 +34,16 @@ public class CustomerGroupDetail extends WeResultDto {
private String owner; private String owner;
/**群的创建时间*/ /**群的创建时间*/
private long create_time; private long createTime;
/**群公告*/ /**群公告*/
private String notice; private String notice;
/**群成员列表*/ /**群成员列表*/
private List<CustomerGroupMember> member_list; private List<CustomerGroupMember> memberList;
/**群管理员列表*/
private List<JSONObject> adminList;
} }
...@@ -45,16 +51,15 @@ public class CustomerGroupDetail extends WeResultDto { ...@@ -45,16 +51,15 @@ public class CustomerGroupDetail extends WeResultDto {
/** /**
* 请求参数 * 请求参数
*/ */
@AllArgsConstructor
@Data @Data
public class Params{ public class Params{
private String chat_id; private String chat_id;
private Integer need_name;
public Params(String chat_id) {
this.chat_id = chat_id;
}
} }
......
...@@ -14,8 +14,10 @@ import java.util.List; ...@@ -14,8 +14,10 @@ import java.util.List;
@Data @Data
public class CustomerGroupList extends WeResultDto { public class CustomerGroupList extends WeResultDto {
//返回结果 /**
private List<GroupChat> group_chat_list; * 客户群列表
*/
private List<GroupChat> groupChatList;
/** /**
...@@ -41,7 +43,7 @@ public class CustomerGroupList extends WeResultDto { ...@@ -41,7 +43,7 @@ public class CustomerGroupList extends WeResultDto {
public class GroupChat{ public class GroupChat{
/**客户群ID*/ /**客户群ID*/
private String chat_id; private String chatId;
/**0 - 正常;1 - 跟进人离职;2 - 离职继承中;3 - 离职继承完成*/ /**0 - 正常;1 - 跟进人离职;2 - 离职继承中;3 - 离职继承完成*/
private Integer status; private Integer status;
......
package com.linkwechat.wecom.domain.dto.customer; package com.linkwechat.wecom.domain.dto.customer;
import com.alibaba.fastjson.JSONObject;
import lombok.Data; import lombok.Data;
import java.util.Date; import java.util.Date;
...@@ -12,17 +13,26 @@ import java.util.Date; ...@@ -12,17 +13,26 @@ import java.util.Date;
@Data @Data
public class CustomerGroupMember { public class CustomerGroupMember {
/**群成员id*/ /**群成员id*/
private String userid; private String userId;
/**1 - 企业成员;2 - 外部联系人*/ /**1 - 企业成员;2 - 外部联系人*/
private Integer type; private Integer type;
/**入群时间*/ /**入群时间*/
private long join_time; private long joinTime;
/**1 - 由成员邀请入群(直接邀请入群);2 - 由成员邀请入群(通过邀请链接入群);3 - 通过扫描群二维码入群*/ /**1 - 由成员邀请入群(直接邀请入群);2 - 由成员邀请入群(通过邀请链接入群);3 - 通过扫描群二维码入群*/
private Integer join_scene; private Integer joinScene;
/**外部联系人在微信开放平台的唯一身份标识(微信unionid);通过此字段企业可将外部联系人与公众号/小程序用户关联起来。*/ /**外部联系人在微信开放平台的唯一身份标识(微信unionid);通过此字段企业可将外部联系人与公众号/小程序用户关联起来。*/
private String unionid; private String unionId;
/** 在群里的昵称 **/
private String groupNickName;
/** 名字。仅当 need_name = 1 时返回 如果是微信用户,则返回其在微信中设置的名字 如果是企业微信联系人,则返回其设置对外展示的别名或实名 **/
private String name;
/** 邀请者 **/
private JSONObject invitor;
} }
package com.linkwechat.wecom.domain.vo;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* @author danmo
* @description 会话对象返回值
* @date 2021/4/21 17:18
**/
@ApiModel
@Data
public class ConversationArchiveVo {
@ApiModelProperty("消息id")
private String msgId;
@ApiModelProperty("音频id")
private String voiceId;
@ApiModelProperty("消息发送时间戳")
private Long time;
@ApiModelProperty("具体为切换企业的成员的userid")
private String user;
@ApiModelProperty("消息动作,目前有send(发送消息)/recall(撤回消息)/switch(切换企业日志)三种类型")
private String action;
@ApiModelProperty("消息发送方id。同一企业内容为userid,非相同企业为external_userid。消息如果是机器人发出,也为external_userid")
private String from;
@ApiModelProperty("消息发送方详情")
private JSONObject fromInfo;
@ApiModelProperty("消息接收方列表,可能是多个,同一个企业内容为userid,非相同企业为external_userid")
private List<String> toList;
@ApiModelProperty("消息接收方详情")
private JSONObject toListInfo;
@ApiModelProperty("群聊消息的群id。如果是单聊则为空")
private String roomId;
@ApiModelProperty("消息发送时间戳,utc时间,ms单位。")
private Long msgTime;
@ApiModelProperty("消息类型")
private String msgType;
@ApiModelProperty("文本消息内容")
private Content text=new Content();
@ApiModelProperty("图片消息内容")
private Content image=new Content();
@ApiModelProperty("撤回消息")
private Content revoke=new Content();
@ApiModelProperty("同意会话聊天内容")
private Content disagree=new Content();
@ApiModelProperty("语音内容")
private Content voice=new Content();
@ApiModelProperty("视频内容")
private Content video=new Content();
@ApiModelProperty("名片")
private Content card=new Content();
@ApiModelProperty("位置")
private Content location=new Content();
@ApiModelProperty("表情")
private Content emotion=new Content();
@ApiModelProperty("文件")
private Content file=new Content();
@ApiModelProperty("链接")
private Content link=new Content();
@ApiModelProperty("小程序消息")
private Content weApp=new Content();
@ApiModelProperty("会话记录消息")
private Content chatReCord=new Content();
@ApiModelProperty("待办消息")
private Content todo=new Content();
@ApiModelProperty("投票消息")
private Content vote=new Content();
@ApiModelProperty("填表消息")
private Collect collect=new Collect();
@ApiModelProperty("红包消息")
private RedPacket redPacket=new RedPacket();
@ApiModelProperty("会议邀请消息")
private Meeting meeting=new Meeting();
@ApiModelProperty("在线文档消息")
private Content doc=new Content();
@ApiModelProperty("MarkDown格式消息/图文消息")
private JSONObject info;
@ApiModelProperty("混合消息")
private JSONObject mixed;
@ApiModelProperty("音频存档消息")
private JSONObject meetingVoiceCall;
@ApiModelProperty("日程消息")
private Calendar calendar=new Calendar();
@ApiModel
@Data
private class Content{
@ApiModelProperty("文件路径")
private String attachment;
@ApiModelProperty("文本消息内容")
private String content;
@ApiModelProperty("图片资源的md5值")
private String md5Sum;
@ApiModelProperty("媒体资源的id信息")
private String sdkFileId;
@ApiModelProperty("文件大小")
private Long fileSize;
@ApiModelProperty("标识撤回的原消息的msgid")
private String preMsgId;
@ApiModelProperty("同意/不同意协议者的userid,外部企业默认为external_userid")
private String userId;
@ApiModelProperty("同意/不同意协议的时间 ms单位")
private Long agreeTime;
@ApiModelProperty("语音消息大小")
private Long voiceSize;
@ApiModelProperty("播放长度")
private Integer playLength;
@ApiModelProperty("名片所有者所在的公司名称")
private String corpName;
@ApiModelProperty("经度")
private Double longitude;
@ApiModelProperty("纬度")
private Double latitude;
@ApiModelProperty("地址信息")
private String address;
@ApiModelProperty("标题")
private String title;
@ApiModelProperty("缩放比例")
private Integer zoom;
@ApiModelProperty("表情类型,png或者gif.1表示gif 2表示png")
private Integer type;
@ApiModelProperty("表情图片宽度")
private Integer width;
@ApiModelProperty("表情图片高度")
private Integer height;
@ApiModelProperty("资源的文件大小")
private Integer imageSize;
@ApiModelProperty("文件名称")
private String fileName;
@ApiModelProperty("文件类型后缀")
private String fileExt;
@ApiModelProperty("消息描述")
private String description;
@ApiModelProperty("链接url地址")
private String linkUrl;
@ApiModelProperty("链接图片url")
private String imageUrl;
@ApiModelProperty("用户名称")
private String userName;
@ApiModelProperty("小程序名称")
private String displayName;
@ApiModelProperty("消息记录内的消息内容")
private List<Item> item;
@ApiModelProperty("投票主题")
private String voteTitle;
@ApiModelProperty("投票选项,可能多个内容")
private List<String> voteItem;
@ApiModelProperty("投票类型.101发起投票、102参与投票")
private Integer voteType;
@ApiModelProperty("投票id,方便将参与投票消息与发起投票消息进行前后对照")
private String voteId;
@ApiModelProperty("在线文档创建者。本企业成员创建为userid;外部企业成员创建为external_userid")
private String docCreator;
}
@Data
@ApiModel
private class Item{
@ApiModelProperty("每条聊天记录的具体消息类型:ChatRecordText/ ChatRecordFile/ ChatRecordImage/ " +
"ChatRecordVideo/ ChatRecordLink/ ChatRecordLocation/ ChatRecordMixed")
private String type;
@ApiModelProperty("消息时间,utc时间,单位秒")
private Long msgTime;
@ApiModelProperty("消息内容。Json串,内容为对应类型的json")
private String content;
@ApiModelProperty("是否来自群会话")
private Boolean fromChatRoom;
}
@Data
@ApiModel
private class Calendar{
@ApiModelProperty("日程主题")
private String title;
@ApiModelProperty("日程备注")
private String creatorName;
@ApiModelProperty("日程参与人")
private List<String> attendeeName;
@ApiModelProperty("日程开始时间")
private Long startTime;
@ApiModelProperty("日程结束时间")
private Long endTime;
@ApiModelProperty("日程地点")
private String place;
@ApiModelProperty("日程备注")
private String remarks;
}
@Data
@ApiModel
private class Collect{
@ApiModelProperty("填表消息所在的群名称")
private String roomName;
@ApiModelProperty("创建者在群中的名字")
private String creator;
@ApiModelProperty("创建的时间")
private Long createTime;
@ApiModelProperty("表名")
private String title;
@ApiModelProperty("表内容")
private String details;
@ApiModelProperty("表项id")
private Long id;
@ApiModelProperty("表项名称")
private String ques;
@ApiModelProperty("表项类型,有Text(文本),Number(数字),Date(日期),Time(时间)")
private String type;
}
@Data
@ApiModel
private class RedPacket{
@ApiModelProperty("红包总金额 单位为分")
private Integer totalAmount;
@ApiModelProperty("红包总个数")
private Integer totalCnt;
@ApiModelProperty("红包祝福语")
private String wish;
@ApiModelProperty("红包消息类型。1 普通红包、2 拼手气群红包、3 激励群红包")
private Integer type;
}
@Data
@ApiModel
private class Meeting{
@ApiModelProperty("会议主题")
private String topic;
@ApiModelProperty("红包总个数")
private Long startTime;
@ApiModelProperty("会议结束时间")
private Long endTime;
@ApiModelProperty("会议地址")
private String address;
@ApiModelProperty("会议备注")
private String remarks;
@ApiModelProperty("会议消息类型。101发起会议邀请消息、102处理会议邀请消息")
private String meetingType;
@ApiModelProperty("会议id。方便将发起、处理消息进行对照")
private Long meetingId;
@ApiModelProperty("会议邀请处理状态。1 参加会议、2 拒绝会议、3 待定、4 未被邀请、5 会议已取消、6 会议已过期、7 不在房间内。" +
"只有meetingtype为102的时候此字段才有内容。")
private Integer status;
}
}
package com.linkwechat.wecom.factory.impl.customer; package com.linkwechat.wecom.factory.impl.customer;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.wecom.client.WeMessagePushClient;
import com.linkwechat.wecom.domain.WeChatContactMapping;
import com.linkwechat.wecom.domain.vo.WxCpXmlMessageVO; import com.linkwechat.wecom.domain.vo.WxCpXmlMessageVO;
import com.linkwechat.wecom.factory.WeEventStrategy; import com.linkwechat.wecom.factory.WeEventStrategy;
import com.linkwechat.wecom.service.*; import com.linkwechat.wecom.service.IWeCustomerService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -20,24 +17,12 @@ import org.springframework.stereotype.Component; ...@@ -20,24 +17,12 @@ import org.springframework.stereotype.Component;
public class WeCallBackMsgAuditApprovedImpl extends WeEventStrategy { public class WeCallBackMsgAuditApprovedImpl extends WeEventStrategy {
@Autowired @Autowired
private IWeCustomerService weCustomerService; private IWeCustomerService weCustomerService;
@Autowired
private IWeChatContactMappingService weChatContactMappingService;
@Override @Override
public void eventHandle(WxCpXmlMessageVO message) { public void eventHandle(WxCpXmlMessageVO message) {
String userId = message.getUserId(); String userId = message.getUserId();
String externalUserId = message.getExternalUserId(); String externalUserId = message.getExternalUserId();
WeChatContactMapping fromMapping = new WeChatContactMapping();
fromMapping.setFromId(userId);
fromMapping.setReceiveId(externalUserId);
fromMapping.setIsCustom(WeConstans.ID_TYPE_EX);
weChatContactMappingService.insertWeChatContactMapping(fromMapping);
WeChatContactMapping receiveMapping = new WeChatContactMapping();
receiveMapping.setFromId(externalUserId);
receiveMapping.setReceiveId(userId);
receiveMapping.setIsCustom(WeConstans.ID_TYPE_USER);
weChatContactMappingService.insertWeChatContactMapping(receiveMapping);
weCustomerService.updateCustomerChatStatus(externalUserId); weCustomerService.updateCustomerChatStatus(externalUserId);
} }
} }
\ No newline at end of file \ No newline at end of file
package com.linkwechat.wecom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeChatContactMapping;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* 聊天关系映射Mapper接口
*
* @author ruoyi
* @date 2020-12-27
*/
@Mapper
public interface WeChatContactMappingMapper extends BaseMapper<WeChatContactMapping> {
/**
* 查询聊天关系映射
*
* @param id 聊天关系映射ID
* @return 聊天关系映射
*/
public WeChatContactMapping selectWeChatContactMappingById(Long id);
/**
* 查询聊天关系映射列表
*
* @param weChatContactMapping 聊天关系映射
* @return 聊天关系映射集合
*/
public List<WeChatContactMapping> selectWeChatContactMappingList(WeChatContactMapping weChatContactMapping);
/**
* 新增聊天关系映射
*
* @param weChatContactMapping 聊天关系映射
* @return 结果
*/
public int insertWeChatContactMapping(WeChatContactMapping weChatContactMapping);
/**
* 修改聊天关系映射
*
* @param weChatContactMapping 聊天关系映射
* @return 结果
*/
public int updateWeChatContactMapping(WeChatContactMapping weChatContactMapping);
/**
* 删除聊天关系映射
*
* @param id 聊天关系映射ID
* @return 结果
*/
public int deleteWeChatContactMappingById(Long id);
/**
* 批量删除聊天关系映射
*
* @param ids 需要删除的数据ID
* @return 结果
*/
public int deleteWeChatContactMappingByIds(Long[] ids);
}
...@@ -30,4 +30,6 @@ public interface WeGroupMapper extends BaseMapper<WeGroup> { ...@@ -30,4 +30,6 @@ public interface WeGroupMapper extends BaseMapper<WeGroup> {
// int batchInsetWeGroup(@Param("weGroups") List<WeGroup> weGroups); // int batchInsetWeGroup(@Param("weGroups") List<WeGroup> weGroups);
List<WeCustomerAddGroup> findWeGroupByCustomer(@Param("userId") String userId,@Param("externalUserid") String externalUserid); List<WeCustomerAddGroup> findWeGroupByCustomer(@Param("userId") String userId,@Param("externalUserid") String externalUserid);
void insertBatch(@Param("weGroups") List<WeGroup> weGroups);
} }
...@@ -3,6 +3,7 @@ package com.linkwechat.wecom.mapper; ...@@ -3,6 +3,7 @@ package com.linkwechat.wecom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeGroupMember; import com.linkwechat.wecom.domain.WeGroupMember;
import com.linkwechat.wecom.domain.dto.WeGroupMemberDto; import com.linkwechat.wecom.domain.dto.WeGroupMemberDto;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
...@@ -18,6 +19,8 @@ public interface WeGroupMemberMapper extends BaseMapper<WeGroupMember> { ...@@ -18,6 +19,8 @@ public interface WeGroupMemberMapper extends BaseMapper<WeGroupMember> {
List<WeGroupMemberDto> selectWeGroupMemberListByChatId(String chatId); List<WeGroupMemberDto> selectWeGroupMemberListByChatId(String chatId);
void insertBatch(@Param("weGroupMembers") List<WeGroupMember> weGroupMembers);
// int insertWeGroupMember(WeGroupMember paramWeGroupMember); // int insertWeGroupMember(WeGroupMember paramWeGroupMember);
// //
// int updateWeGroupMember(WeGroupMember paramWeGroupMember); // int updateWeGroupMember(WeGroupMember paramWeGroupMember);
......
package com.linkwechat.wecom.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService;
import com.github.pagehelper.PageInfo;
import com.linkwechat.common.core.domain.elastic.ElasticSearchEntity;
import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.wecom.domain.WeChatContactMapping;
import com.linkwechat.wecom.domain.WeCustomer;
import java.util.List;
/**
* 聊天关系映射Service接口
*
* @author ruoyi
* @date 2020-12-27
*/
public interface IWeChatContactMappingService extends IService<WeChatContactMapping> {
/**
* 查询聊天关系映射
*
* @param id 聊天关系映射ID
* @return 聊天关系映射
*/
public WeChatContactMapping selectWeChatContactMappingById(Long id);
/**
* 查询聊天关系映射列表
*
* @param weChatContactMapping 聊天关系映射
* @return 聊天关系映射集合
*/
public List<WeChatContactMapping> selectWeChatContactMappingList(WeChatContactMapping weChatContactMapping);
/**
* 新增聊天关系映射
*
* @param weChatContactMapping 聊天关系映射
* @return 结果
*/
public int insertWeChatContactMapping(WeChatContactMapping weChatContactMapping);
/**
* 修改聊天关系映射
*
* @param weChatContactMapping 聊天关系映射
* @return 结果
*/
public int updateWeChatContactMapping(WeChatContactMapping weChatContactMapping);
/**
* 批量删除聊天关系映射
*
* @param ids 需要删除的聊天关系映射ID
* @return 结果
*/
public int deleteWeChatContactMappingByIds(Long[] ids);
/**
* 删除聊天关系映射信息
*
* @param id 聊天关系映射ID
* @return 结果
*/
public int deleteWeChatContactMappingById(Long id);
/**
* 保存
*
* @param query
*/
public List<JSONObject> saveWeChatContactMapping(List<JSONObject> query);
/**
* 按客户查询关系映射列表
*/
PageInfo<WeCustomer> listByCustomer();
}
package com.linkwechat.wecom.service;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.linkwechat.common.core.domain.ConversationArchiveQuery;
import com.linkwechat.wecom.domain.vo.ConversationArchiveVo;
import java.util.List;
/**
* @author danmo
* @description 会话存档业务接口
* @date 2020/12/19 13:59
**/
public interface IWeConversationArchiveService {
/**
* 根据用户ID 获取对应内部联系人列表
* @param query 入参
* @param /fromId 发送人id
* @param /reveiceId 接收人id
* @return
*/
PageInfo<ConversationArchiveVo> getChatContactList(ConversationArchiveQuery query);
PageInfo<ConversationArchiveVo> getChatRoomContactList(ConversationArchiveQuery query);
/**
* 查询最早聊天记录
* @param fromId
* @param receiveId
* @return
*/
JSONObject getFinalChatContactInfo(String fromId, String receiveId);
/**
* 查询最早群聊记录
* @param fromId
* @param roomId
* @return
*/
JSONObject getFinalChatRoomContactInfo(String fromId, String roomId);
/**
* 获取全局会话数据接口
*
* @param query 参
* @return
*/
PageInfo<ConversationArchiveVo> getChatAllList(ConversationArchiveQuery query);
}
...@@ -18,4 +18,6 @@ public interface IWeGroupMemberService extends IService<WeGroupMember> { ...@@ -18,4 +18,6 @@ public interface IWeGroupMemberService extends IService<WeGroupMember> {
List<WeGroupMemberDto> selectWeGroupMemberListByChatId(String chatId); List<WeGroupMemberDto> selectWeGroupMemberListByChatId(String chatId);
WeGroupMember selectWeGroupMemberByUnionId(String chatId, String unionId); WeGroupMember selectWeGroupMemberByUnionId(String chatId, String unionId);
void insertBatch(List<WeGroupMember> weGroupMembers);
} }
...@@ -96,7 +96,7 @@ public class WeChatContactMsgServiceImpl extends ServiceImpl<WeChatContactMsgMap ...@@ -96,7 +96,7 @@ public class WeChatContactMsgServiceImpl extends ServiceImpl<WeChatContactMsgMap
} }
}); });
} }
return this.baseMapper.selectGroupChatList(fromId); return weChatContactMsgVos;
} }
@Override @Override
......
...@@ -37,5 +37,10 @@ public class WeGroupMemberServiceImpl extends ServiceImpl<WeGroupMemberMapper,We ...@@ -37,5 +37,10 @@ public class WeGroupMemberServiceImpl extends ServiceImpl<WeGroupMemberMapper,We
.eq(WeGroupMember::getUnionId,unionId)); .eq(WeGroupMember::getUnionId,unionId));
} }
@Override
public void insertBatch(List<WeGroupMember> weGroupMembers) {
this.baseMapper.insertBatch(weGroupMembers);
}
} }
<?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.linkwechat.wecom.mapper.WeChatContactMappingMapper">
<resultMap type="WeChatContactMapping" id="WeChatContactMappingResult">
<result property="id" column="id" />
<result property="fromId" column="from_id" />
<result property="receiveId" column="receive_id" />
<result property="roomId" column="room_id" />
<result property="isCustom" column="is_custom" />
</resultMap>
<sql id="selectWeChatContactMappingVo">
select id, from_id, receive_id, room_id, is_custom from we_chat_contact_mapping
</sql>
<select id="selectWeChatContactMappingList" parameterType="WeChatContactMapping" resultMap="WeChatContactMappingResult">
<include refid="selectWeChatContactMappingVo"/>
<where>
<if test="fromId != null and fromId != ''"> and from_id = #{fromId}</if>
<if test="receiveId != null and receiveId != ''"> and receive_id = #{receiveId}</if>
<if test="roomId != null and roomId != ''"> and room_id = #{roomId}</if>
<choose>
<when test="searchType != null and searchType == 0">
and is_custom = 0
</when>
<when test="searchType != null and searchType == 1">
and is_custom in (1,2)
</when>
<when test="searchType != null and searchType == 2">
and room_id is not null
</when>
<when test="searchType != null and searchType == 3">
and is_custom in (0,1,2)
</when>
</choose>
</where>
</select>
<select id="selectWeChatContactMappingById" parameterType="Long" resultMap="WeChatContactMappingResult">
<include refid="selectWeChatContactMappingVo"/>
where id = #{id}
</select>
<insert id="insertWeChatContactMapping" parameterType="WeChatContactMapping" useGeneratedKeys="true" keyProperty="id">
insert into we_chat_contact_mapping
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="fromId != null and fromId != ''">from_id,</if>
<if test="receiveId != null and receiveId != ''">receive_id,</if>
<if test="roomId != null">room_id,</if>
<if test="isCustom != null">is_custom,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="fromId != null and fromId != ''">#{fromId},</if>
<if test="receiveId != null and receiveId != ''">#{receiveId},</if>
<if test="roomId != null">#{roomId},</if>
<if test="isCustom != null">#{isCustom},</if>
</trim>
</insert>
<update id="updateWeChatContactMapping" parameterType="WeChatContactMapping">
update we_chat_contact_mapping
<trim prefix="SET" suffixOverrides=",">
<if test="fromId != null and fromId != ''">from_id = #{fromId},</if>
<if test="receiveId != null and receiveId != ''">receive_id = #{receiveId},</if>
<if test="roomId != null">room_id = #{roomId},</if>
<if test="isCustom != null">is_custom = #{isCustom},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteWeChatContactMappingById" parameterType="Long">
delete from we_chat_contact_mapping where id = #{id}
</delete>
<delete id="deleteWeChatContactMappingByIds" parameterType="String">
delete from we_chat_contact_mapping where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file \ No newline at end of file
...@@ -109,29 +109,35 @@ ...@@ -109,29 +109,35 @@
contact, contact,
if((case when LOCATE('wm', from_id) or LOCATE('wo', from_id) then 0 else 1 end), if((case when LOCATE('wm', from_id) or LOCATE('wo', from_id) then 0 else 1 end),
(select wu.user_name from we_user wu where wccm.from_id = wu.user_id), (select wu.user_name from we_user wu where wccm.from_id = wu.user_id),
(select wc.name from we_customer wc where wccm.from_id = wc.external_userid)) as name (select wc.name from we_customer wc where wccm.from_id = wc.external_userid)) as name,
if((case when LOCATE('wm', from_id) or LOCATE('wo', from_id) then 0 else 1 end),
(select wu.user_name from we_user wu where wccm.from_id = wu.user_id),
(select wc.name from we_customer wc where wccm.from_id = wc.external_userid)) as name,
from we_chat_contact_msg wccm from we_chat_contact_msg wccm
<where>
<if test="fromId != null and fromId != ''">
and t.fromId = #{fromId}
</if>
<if test="action != null and action != ''">
and t.action = #{action}
</if>
<if test="contact != null and contact != ''">
and t.contact like concat('%', #{contact}, '%')
</if>
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
AND date_format(t.msg_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
</if>
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
AND date_format(t.msg_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
</if>
</where>
) t ) t
<where> <where>
<if test="name != null and name != ''"> <if test="name != null and name != ''">
and t.name like concat('%', #{name}, '%') and t.name like concat('%', #{name}, '%')
</if> </if>
<if test="fromId != null and fromId != ''">
and t.fromId = #{fromId}
</if>
<if test="action != null and action != ''">
and t.action = #{action}
</if>
<if test="contact != null and contact != ''">
and t.contact like concat('%', #{contact}, '%')
</if>
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
AND date_format(t.msg_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
</if>
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
AND date_format(t.msg_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
</if>
</where> </where>
</select> </select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
SELECT SELECT
wg.chat_id, wg.chat_id,
wg.group_name, wg.group_name,
wg.create_time, wg.add_time,
wg.notice, wg.notice,
wu.user_name as groupLeaderName, wu.user_name as groupLeaderName,
(SELECT COUNT(*) FROM we_group_member wgm WHERE wgm.chat_id=wg.chat_id) as memberNum, (SELECT COUNT(*) FROM we_group_member wgm WHERE wgm.chat_id=wg.chat_id) as memberNum,
...@@ -22,11 +22,11 @@ ...@@ -22,11 +22,11 @@
<if test="groupName != null and groupName != ''"> and wg.group_name like concat('%', #{groupName}, '%')</if> <if test="groupName != null and groupName != ''"> and wg.group_name like concat('%', #{groupName}, '%')</if>
<if test="groupLeader != null and groupLeader != ''"> and wu.user_name like concat('%', #{groupLeader}, '%')</if> <if test="groupLeader != null and groupLeader != ''"> and wu.user_name like concat('%', #{groupLeader}, '%')</if>
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 --> <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
AND date_format(wg.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d') AND date_format(wg.add_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
</if> </if>
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 --> <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
AND date_format(wg.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d') AND date_format(wg.add_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
</if> </if>
<if test="userIds != null and userIds !=''"> <if test="userIds != null and userIds !=''">
<if test="userIds.indexOf(',') != -1"> <if test="userIds.indexOf(',') != -1">
...@@ -60,4 +60,15 @@ ...@@ -60,4 +60,15 @@
</select> </select>
<insert id="insertBatch">
insert into we_group (chat_id, group_name, owner, add_time, notice, status,admin_user_id, create_by, create_time,update_by, update_time)
values
<foreach collection="weGroups" item="weGroup" index="index" separator=",">
(#{weGroup.chatId},#{weGroup.groupName},#{weGroup.owner},#{weGroup.addTime},#{weGroup.notice},#{weGroup.status},#{weGroup.adminUserId},
#{weGroup.createBy},#{weGroup.createTime},#{weGroup.updateBy},#{weGroup.updateTime})
</foreach>
on duplicate key update group_name= values(group_name),owner= values(owner),
notice= values(notice),status= values(status),admin_user_id= values(admin_user_id),
update_by= values(update_by),update_time= values(update_time)
</insert>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -55,4 +55,21 @@ ...@@ -55,4 +55,21 @@
</where> </where>
</select> </select>
<insert id="insertBatch">
insert into we_group_member (chat_id, user_id, union_id, join_time, join_scene, `type`,
group_nick_name,`name`,invitor_user_id,
create_by, create_time,update_by, update_time)
values
<foreach collection="weGroupMembers" item="weGroupMember" index="index" separator=",">
(#{weGroupMember.chatId},#{weGroupMember.userId},#{weGroupMember.unionId},
#{weGroupMember.joinTime},#{weGroupMember.joinScene},#{weGroupMember.type},
#{weGroupMember.groupNickName},#{weGroupMember.name},#{weGroupMember.invitorUserId},
#{weGroupMember.createBy},#{weGroupMember.createTime},
#{weGroupMember.updateBy},#{weGroupMember.updateTime})
</foreach>
on duplicate key update
join_time= values(join_time),join_scene= values(join_scene),
group_nick_name= values(group_nick_name),`name`= values(`name`),invitor_user_id= values(invitor_user_id),
`type`= values(`type`),update_by= values(update_by),update_time= values(update_time)
</insert>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!