Commit df539710 by 水库浪子

修改客户群相关bug

1 parent 16935b8c
package com.linkwechat.web.controller.wecom;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.wecom.domain.WeGroup;
import com.linkwechat.wecom.domain.WeGroupMember;
......@@ -45,4 +47,18 @@ public class WeGroupController extends BaseController {
List<WeGroupMember> list = this.weGroupMemberService.selectWeGroupMemberList(weGroupMember);
return getDataTable(list);
}
/**
* 同步客户群
* @return
*/
@PreAuthorize("@ss.hasPermi('wecom:group:synchWeGroup')")
@GetMapping({"/synchWeGroup"})
public AjaxResult synchWeGroup(){
weGroupService.synchWeGroup();
return AjaxResult.success(WeConstans.SYNCH_TIP);
}
}
......@@ -9,6 +9,7 @@ import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.wecom.domain.WeUser;
import com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo;
import com.linkwechat.wecom.domain.vo.WeLeaveUserVo;
import com.linkwechat.wecom.service.IWeCustomerService;
import com.linkwechat.wecom.service.IWeUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -30,9 +31,12 @@ import java.util.List;
@RequestMapping("/wecom/user")
@Api("通讯录人员接口")
public class WeUserController extends BaseController {
@Autowired
private IWeUserService weUserService;
/**
* 查询通讯录相关客户列表
*/
......
......@@ -133,5 +133,15 @@ wecome:
serverUrl: https://qyapi.weixin.qq.com/
weComePrefix: cgi-bin
noAccessTokenUrl: /gettoken
needContactTokenUrl: /externalcontact/get_follow_user_list,/externalcontact/add_contact_way,/externalcontact/add_corp_tag,/externalcontact/get_corp_tag_list,/externalcontact/del_corp_tag,/externalcontact/edit_corp_tag,/externalcontact/list,/externalcontact/get
needContactTokenUrl:
- /externalcontact/get_follow_user_list
- /externalcontact/add_contact_way
- /externalcontact/add_corp_tag
- /externalcontact/get_corp_tag_list
- /externalcontact/del_corp_tag
- /externalcontact/edit_corp_tag
- /externalcontact/list
- /externalcontact/get
- /externalcontact/groupchat/list
- /externalcontact/groupchat/get
fileUplodUrl: /media/upload,/media/uploadimg
package com.linkwechat.wecom.client;
import com.dtflys.forest.annotation.DataObject;
import com.dtflys.forest.annotation.Query;
import com.dtflys.forest.annotation.Request;
import com.linkwechat.wecom.domain.dto.customer.CustomerGroupDetail;
import com.linkwechat.wecom.domain.dto.customer.CustomerGroupList;
/**
* @description: 客户群
* @author: HaoN
* @create: 2020-10-20 21:50
**/
public interface WeCustomerGroupClient {
/**
* 获取客户群列表
* @param params
* @return
*/
@Request(url="/externalcontact/groupchat/list",
type = "POST"
)
CustomerGroupList groupChatLists(@DataObject CustomerGroupList.Params params);
/**
* 获取客户群详情
* @param params
* @return
*/
@Request(url="/externalcontact/groupchat/get",
type = "POST"
)
CustomerGroupDetail groupChatDetail(@DataObject CustomerGroupDetail.Params params);
}
\ No newline at end of file
package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.common.utils.SnowFlakeUtil;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
*
* @Author: Robin
* @Description:
* @Date: create in 2020/9/21 0021 23:55
......@@ -16,18 +24,29 @@ import lombok.NoArgsConstructor;
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class WeGroup extends BaseEntity {
@TableName("we_group")
public class WeGroup {
private static final long serialVersionUID = 1L;
private Long id= SnowFlakeUtil.nextId();
@TableId
private String chatId;
private String groupName;
@TableField(exist = false)
private Long memberNum;
private String groupLeader;
private String notice;
private String groupLeaderUserId;
private String owner;
private Integer status;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date createTime;
@TableField(exist = false)
private String groupLeaderName;
}
package com.linkwechat.wecom.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.linkwechat.common.core.domain.BaseEntity;
import com.linkwechat.common.utils.SnowFlakeUtil;
import io.swagger.models.auth.In;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotBlank;
import java.util.Date;
......@@ -13,18 +21,38 @@ import java.util.Date;
* @Date: create in 2020/9/21 0021 23:56
*/
@Data
public class WeGroupMember extends BaseEntity {
@TableName("we_group_member")
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class WeGroupMember {
private static final long serialVersionUID = 1L;
private Long id;
@TableId
private Long id= SnowFlakeUtil.nextId();;
@NotBlank(message = "groupId")
private Long groupId;
private String chatId;
@TableField(exist = false)
private String memberName;
@JsonFormat(pattern = "yyyy-MM-dd")
private Date joinTime;
private Long joinType;
private Integer joinScene;
@TableField(value="type")
private Integer joinType;
private String userId;
private String unionId;
}
package com.linkwechat.wecom.domain.dto;
import com.linkwechat.wecom.domain.WeUser;
import lombok.Data;
/**
......
package com.linkwechat.wecom.domain.dto.customer;
import com.linkwechat.wecom.domain.dto.WeResultDto;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @description: 客户群相关
* @author: HaoN
* @create: 2020-10-20 21:52
**/
@Data
public class CustomerGroupDetail extends WeResultDto {
private List<GroupChat> group_chat;
@Data
public class GroupChat{
/**客户群ID*/
private String chat_id;
/**群名*/
private String name;
/**群主ID*/
private String owner;
/**群的创建时间*/
private Date create_time;
/**群公告*/
private String notice;
/**群成员列表*/
private List<CustomerGroupMember> member_list;
}
/**
* 请求参数
*/
@Data
public class Params{
private String chat_id;
public Params(String chat_id) {
this.chat_id = chat_id;
}
}
}
package com.linkwechat.wecom.domain.dto.customer;
import com.linkwechat.wecom.domain.dto.WeResultDto;
import lombok.Data;
import java.util.Date;
import java.util.List;
/**
* @description: 客户群相关
* @author: HaoN
* @create: 2020-10-20 21:52
**/
@Data
public class CustomerGroupList extends WeResultDto {
//返回结果
private List<GroupChat> group_chat_list;
/**
* 请求参数
*/
@Data
public class Params{
/**群状态过滤: 0 - 所有列表;1 - 离职待继承;2 - 离职继承中;3 - 离职继承完成; */
private Integer status_filter;
/**分页,偏移量。默认为0 */
private Integer offset=new Integer(0);
/**分页,预期请求的数据量,取值范围 1 ~ 1000 */
private Integer limit=new Integer(1000);
}
@Data
public class GroupChat{
/**客户群ID*/
private String chat_id;
/**0 - 正常;1 - 跟进人离职;2 - 离职继承中;3 - 离职继承完成*/
private Integer status;
}
}
package com.linkwechat.wecom.domain.dto.customer;
import lombok.Data;
import java.util.Date;
/**
* @description: 客户群成员
* @author: HaoN
* @create: 2020-10-20 22:37
**/
@Data
public class CustomerGroupMember {
/**群成员id*/
private String userid;
/**1 - 企业成员;2 - 外部联系人*/
private Integer type;
/**入群时间*/
private Date join_time;
/**1 - 由成员邀请入群(直接邀请入群);2 - 由成员邀请入群(通过邀请链接入群);3 - 通过扫描群二维码入群*/
private Integer join_scene;
/**外部联系人在微信开放平台的唯一身份标识(微信unionid);通过此字段企业可将外部联系人与公众号/小程序用户关联起来。*/
private String unionid;
}
package com.linkwechat.wecom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeGroup;
import org.apache.ibatis.annotations.Param;
......@@ -10,20 +11,20 @@ import java.util.List;
* @Description:
* @Date: create in 2020/9/21 0021 23:58
*/
public interface WeGroupMapper {
WeGroup selectWeGroupById(Long paramLong);
public interface WeGroupMapper extends BaseMapper<WeGroup> {
// WeGroup selectWeGroupById(Long paramLong);
//
List<WeGroup> selectWeGroupList(WeGroup paramWeGroup);
int insertWeGroup(WeGroup paramWeGroup);
int updateWeGroup(WeGroup paramWeGroup);
int deleteWeGroupById(Long paramLong);
int deleteWeGroupByIds(Long[] paramArrayOfLong);
int batchLogicDeleteByIds(@Param("ids") List<Long> ids);
int batchInsetWeGroup(@Param("weGroups") List<WeGroup> weGroups);
//
// int insertWeGroup(WeGroup paramWeGroup);
//
// int updateWeGroup(WeGroup paramWeGroup);
//
// int deleteWeGroupById(Long paramLong);
//
// int deleteWeGroupByIds(Long[] paramArrayOfLong);
//
// int batchLogicDeleteByIds(@Param("ids") List<Long> ids);
//
// int batchInsetWeGroup(@Param("weGroups") List<WeGroup> weGroups);
}
package com.linkwechat.wecom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeGroupMember;
import java.util.List;
......@@ -9,16 +10,16 @@ import java.util.List;
* @Description:
* @Date: create in 2020/9/21 0021 23:58
*/
public interface WeGroupMemberMapper {
WeGroupMember selectWeGroupMemberById(Long paramLong);
public interface WeGroupMemberMapper extends BaseMapper<WeGroupMember> {
// WeGroupMember selectWeGroupMemberById(Long paramLong);
List<WeGroupMember> selectWeGroupMemberList(WeGroupMember paramWeGroupMember);
int insertWeGroupMember(WeGroupMember paramWeGroupMember);
int updateWeGroupMember(WeGroupMember paramWeGroupMember);
int deleteWeGroupMemberById(Long paramLong);
int deleteWeGroupMemberByIds(Long[] paramArrayOfLong);
// int insertWeGroupMember(WeGroupMember paramWeGroupMember);
//
// int updateWeGroupMember(WeGroupMember paramWeGroupMember);
//
// int deleteWeGroupMemberById(Long paramLong);
//
// int deleteWeGroupMemberByIds(Long[] paramArrayOfLong);
}
package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeGroupMember;
import java.util.List;
......@@ -9,16 +10,8 @@ import java.util.List;
* @Description:
* @Date: create in 2020/9/22 0022 0:02
*/
public interface IWeGroupMemberService {
WeGroupMember selectWeGroupMemberById(Long paramLong);
public interface IWeGroupMemberService extends IService<WeGroupMember> {
List<WeGroupMember> selectWeGroupMemberList(WeGroupMember paramWeGroupMember);
int insertWeGroupMember(WeGroupMember paramWeGroupMember);
int updateWeGroupMember(WeGroupMember paramWeGroupMember);
int deleteWeGroupMemberByIds(Long[] paramArrayOfLong);
int deleteWeGroupMemberById(Long paramLong);
}
package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeGroup;
import com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo;
......@@ -10,22 +11,17 @@ import java.util.List;
* @Description:
* @Date: create in 2020/9/22 0022 0:01
*/
public interface IWeGroupService {
WeGroup selectWeGroupById(Long paramLong);
public interface IWeGroupService extends IService<WeGroup> {
List<WeGroup> selectWeGroupList(WeGroup paramWeGroup);
int insertWeGroup(WeGroup paramWeGroup);
int updateWeGroup(WeGroup paramWeGroup);
// int batchLogicDeleteByIds(List<Long> ids);
//
// int batchInsetWeGroup(List<WeGroup> weGroups);
int deleteWeGroupByIds(Long[] paramArrayOfLong);
int deleteWeGroupById(Long paramLong);
int batchLogicDeleteByIds(List<Long> ids);
void allocateWeGroup(WeLeaveUserInfoAllocateVo weLeaveUserInfoAllocateVo);
int batchInsetWeGroup(List<WeGroup> weGroups);
void allocateWeGroup(WeLeaveUserInfoAllocateVo weLeaveUserInfoAllocateVo);
void synchWeGroup();
}
package com.linkwechat.wecom.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.wecom.domain.WeGroupMember;
import com.linkwechat.wecom.mapper.WeGroupMemberMapper;
import com.linkwechat.wecom.service.IWeGroupMemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
......@@ -14,31 +14,13 @@ import java.util.List;
* @Date: create in 2020/9/22 0022 0:03
*/
@Service
public class WeGroupMemberServiceImpl implements IWeGroupMemberService {
@Autowired
private WeGroupMemberMapper weGroupMemberMapper;
public class WeGroupMemberServiceImpl extends ServiceImpl<WeGroupMemberMapper,WeGroupMember> implements IWeGroupMemberService {
public WeGroupMember selectWeGroupMemberById(Long id) {
return this.weGroupMemberMapper.selectWeGroupMemberById(id);
}
public List<WeGroupMember> selectWeGroupMemberList(WeGroupMember weGroupMember) {
return this.weGroupMemberMapper.selectWeGroupMemberList(weGroupMember);
}
public int insertWeGroupMember(WeGroupMember weGroupMember) {
return this.weGroupMemberMapper.insertWeGroupMember(weGroupMember);
}
public int updateWeGroupMember(WeGroupMember weGroupMember) {
return this.weGroupMemberMapper.updateWeGroupMember(weGroupMember);
public List<WeGroupMember> selectWeGroupMemberList(WeGroupMember weGroupMember) {
return this.baseMapper.selectWeGroupMemberList(weGroupMember);
}
public int deleteWeGroupMemberByIds(Long[] ids) {
return this.weGroupMemberMapper.deleteWeGroupMemberByIds(ids);
}
public int deleteWeGroupMemberById(Long id) {
return this.weGroupMemberMapper.deleteWeGroupMemberById(id);
}
}
package com.linkwechat.wecom.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.linkwechat.common.utils.DateUtils;
import com.linkwechat.common.utils.SnowFlakeUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.wecom.client.WeCustomerGroupClient;
import com.linkwechat.wecom.domain.WeGroup;
import com.linkwechat.wecom.domain.WeGroupMember;
import com.linkwechat.wecom.domain.dto.customer.CustomerGroupDetail;
import com.linkwechat.wecom.domain.dto.customer.CustomerGroupList;
import com.linkwechat.wecom.domain.dto.customer.CustomerGroupMember;
import com.linkwechat.wecom.domain.vo.WeLeaveUserInfoAllocateVo;
import com.linkwechat.wecom.mapper.WeGroupMapper;
import com.linkwechat.wecom.service.IWeCustomerService;
import com.linkwechat.wecom.service.IWeGroupMemberService;
import com.linkwechat.wecom.service.IWeGroupService;
import com.linkwechat.wecom.service.IWeUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
......@@ -20,82 +30,128 @@ import java.util.stream.Collectors;
* @Date: create in 2020/9/22 0022 0:03
*/
@Service
public class WeGroupServiceImpl implements IWeGroupService {
@Autowired
private WeGroupMapper weGroupMapper;
public class WeGroupServiceImpl extends ServiceImpl<WeGroupMapper,WeGroup> implements IWeGroupService {
public WeGroup selectWeGroupById(Long id) {
return this.weGroupMapper.selectWeGroupById(id);
}
public List<WeGroup> selectWeGroupList(WeGroup weGroup) {
return this.weGroupMapper.selectWeGroupList(weGroup);
}
public int insertWeGroup(WeGroup weGroup) {
weGroup.setCreateTime(DateUtils.getNowDate());
return this.weGroupMapper.insertWeGroup(weGroup);
}
@Autowired
private WeCustomerGroupClient weCustomerGroupClient;
public int updateWeGroup(WeGroup weGroup) {
return this.weGroupMapper.updateWeGroup(weGroup);
}
public int deleteWeGroupByIds(Long[] ids) {
return this.weGroupMapper.deleteWeGroupByIds(ids);
}
@Autowired
private IWeGroupMemberService iWeGroupMemberService;
public int deleteWeGroupById(Long id) {
return this.weGroupMapper.deleteWeGroupById(id);
}
@Autowired
private IWeUserService weUserService;
/**
* 逻辑批量删除
* @param ids
*/
@Override
public int batchLogicDeleteByIds(List<Long> ids) {
@Autowired
private IWeCustomerService weCustomerService;
return weGroupMapper.batchLogicDeleteByIds(ids);
}
public List<WeGroup> selectWeGroupList(WeGroup weGroup) {
return this.baseMapper.selectWeGroupList(weGroup);
}
/**
* 批量保存
* @param weGroups
* 离职员工群分配
* @param weLeaveUserInfoAllocateVo
* @return
*/
@Override
public int batchInsetWeGroup(List<WeGroup> weGroups) {
return weGroupMapper.batchInsetWeGroup(weGroups);
@Transactional
public void allocateWeGroup(WeLeaveUserInfoAllocateVo weLeaveUserInfoAllocateVo) {
// //分配群
// List<WeGroup> weGroups = this.selectWeGroupList(WeGroup.builder()
// .groupLeaderUserId(weLeaveUserInfoAllocateVo.getHandoverUserid())
// .build());
// if(CollectionUtil.isNotEmpty(weGroups)){
//
// this.batchLogicDeleteByIds(
// weGroups.stream().map(WeGroup::getId).collect(Collectors.toList())
// );
//
// weGroups.stream().forEach(k->{
// k.setId(SnowFlakeUtil.nextId());
// k.setGroupLeaderUserId(weLeaveUserInfoAllocateVo.getTakeoverUserid());
// });
//
// this.batchInsetWeGroup(weGroups);
// }
}
/**
* 离职员工群分配
* @param weLeaveUserInfoAllocateVo
* @return
* 客户群同步
*/
@Override
@Transactional
public void allocateWeGroup(WeLeaveUserInfoAllocateVo weLeaveUserInfoAllocateVo) {
//分配群
List<WeGroup> weGroups = this.selectWeGroupList(WeGroup.builder()
.groupLeaderUserId(weLeaveUserInfoAllocateVo.getHandoverUserid())
.build());
if(CollectionUtil.isNotEmpty(weGroups)){
this.batchLogicDeleteByIds(
weGroups.stream().map(WeGroup::getId).collect(Collectors.toList())
);
weGroups.stream().forEach(k->{
k.setId(SnowFlakeUtil.nextId());
k.setGroupLeaderUserId(weLeaveUserInfoAllocateVo.getTakeoverUserid());
@Transactional(rollbackFor = Exception.class)
public void synchWeGroup() {
CustomerGroupList customerGroupList =
weCustomerGroupClient.groupChatLists(new CustomerGroupList().new Params());
if(customerGroupList.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)
&& CollectionUtil.isNotEmpty(customerGroupList.getGroup_chat_list())){
List<WeGroup> weGroups=new ArrayList<>();
List<WeGroupMember> weGroupMembers=new ArrayList<>();
customerGroupList.getGroup_chat_list().stream().forEach(k->{
CustomerGroupDetail customerGroupDetail = weCustomerGroupClient.groupChatDetail(
new CustomerGroupDetail().new Params(k.getChat_id())
);
if(customerGroupDetail.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)
&& CollectionUtil.isNotEmpty(customerGroupDetail.getGroup_chat())){
customerGroupDetail.getGroup_chat().stream().forEach(kk->{
weGroups.add(
WeGroup.builder()
.chatId(kk.getChat_id())
.groupName(kk.getName())
.notice(kk.getNotice())
.owner(kk.getOwner())
.createTime(kk.getCreate_time())
.status(k.getStatus())
.build()
);
List<CustomerGroupMember> memberLists = kk.getMember_list();
if(CollectionUtil.isNotEmpty(memberLists)){
memberLists.stream().forEach(member->{
weGroupMembers.add(
WeGroupMember.builder()
.chatId(kk.getChat_id())
.userId(member.getUserid())
.joinTime(member.getJoin_time())
.joinScene(member.getJoin_scene())
.joinType(member.getType())
.unionId(member.getUnionid())
.build()
);
});
}
});
}
});
this.batchInsetWeGroup(weGroups);
//同步组织架构成员
weUserService.synchWeUser();
//同步客户
weCustomerService.synchWeCustomer();
this.saveOrUpdateBatch(weGroups);
iWeGroupMemberService.remove(new LambdaQueryWrapper<WeGroupMember>().in(WeGroupMember::getChatId,
weGroups.stream().map(WeGroup::getChatId).collect(Collectors.toList())));
iWeGroupMemberService.saveOrUpdateBatch(weGroupMembers);
}
}
}
......@@ -4,96 +4,89 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.linkwechat.wecom.mapper.WeGroupMapper">
<resultMap type="WeGroup" id="WeGroupResult">
<result property="id" column="id" />
<result property="groupName" column="group_name" />
<result property="memberNum" column="member_num" />
<result property="groupLeader" column="group_leader" />
<result property="createTime" column="create_time" />
<result property="notice" column="notice" />
<result property="groupLeaderUserId" column="group_leader_user_id"/>
</resultMap>
<sql id="selectWeGroupVo">
select id, group_name, member_num, group_leader, create_time, notice, group_leader_user_id from we_group
</sql>
<select id="selectWeGroupList" parameterType="WeGroup" resultMap="WeGroupResult">
<include refid="selectWeGroupVo"/>
<select id="selectWeGroupList" parameterType="WeGroup" resultType="com.linkwechat.wecom.domain.WeGroup">
SELECT
wg.chat_id,
wg.group_name,
wg.create_time,
wg.notice,
wu.user_name as groupLeaderName,
(SELECT COUNT(*) FROM we_group_member wgm WHERE wgm.chat_id=wg.chat_id) as memberNum
FROM
we_group wg
INNER JOIN we_user wu ON wg.`owner`=wu.user_id
<where>
<if test="groupName != null and groupName != ''"> and group_name like concat('%', #{groupName}, '%')</if>
<if test="memberNum != null "> and member_num = #{memberNum}</if>
<if test="groupLeader != null and groupLeader != ''"> and group_leader = #{groupLeader}</if>
<if test="notice != null and notice != ''"> and notice = #{notice}</if>
<if test="groupLeaderUserId != null and groupLeaderUserId !=''">and group_leader_user_id =#{groupLeaderUserId}</if>
<if test="groupName != null and groupName != ''"> and wg.group_name like concat('%', #{groupName}, '%')</if>
<if test="owner != null and owner != ''"> and owner = #{owner}</if>
</where>
</select>
<select id="selectWeGroupById" parameterType="Long" resultMap="WeGroupResult">
<include refid="selectWeGroupVo"/>
where id = #{id}
</select>
<!-- <select id="selectWeGroupById" parameterType="Long" resultMap="WeGroupResult">-->
<!-- <include refid="selectWeGroupVo"/>-->
<!-- where id = #{id}-->
<!-- </select>-->
<insert id="insertWeGroup" parameterType="WeGroup">
insert into we_group
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="groupName != null">group_name,</if>
<if test="memberNum != null">member_num,</if>
<if test="groupLeader != null">group_leader,</if>
<if test="createTime != null">create_time,</if>
<if test="notice != null">notice,</if>
<if test="groupLeaderUserId != null and groupLeaderUserId !=''">group_leader_user_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="groupName != null">#{groupName},</if>
<if test="memberNum != null">#{memberNum},</if>
<if test="groupLeader != null">#{groupLeader},</if>
<if test="createTime != null">#{createTime},</if>
<if test="notice != null">#{notice},</if>
<if test="groupLeaderUserId != null and groupLeaderUserId !=''">#{groupLeaderUserId},</if>
</trim>
</insert>
<!-- <insert id="insertWeGroup" parameterType="WeGroup">-->
<!-- insert into we_group-->
<!-- <trim prefix="(" suffix=")" suffixOverrides=",">-->
<!-- <if test="id != null">id,</if>-->
<!-- <if test="groupName != null">group_name,</if>-->
<!-- <if test="memberNum != null">member_num,</if>-->
<!-- <if test="groupLeader != null">group_leader,</if>-->
<!-- <if test="createTime != null">create_time,</if>-->
<!-- <if test="notice != null">notice,</if>-->
<!-- <if test="groupLeaderUserId != null and groupLeaderUserId !=''">group_leader_user_id,</if>-->
<!-- </trim>-->
<!-- <trim prefix="values (" suffix=")" suffixOverrides=",">-->
<!-- <if test="id != null">#{id},</if>-->
<!-- <if test="groupName != null">#{groupName},</if>-->
<!-- <if test="memberNum != null">#{memberNum},</if>-->
<!-- <if test="groupLeader != null">#{groupLeader},</if>-->
<!-- <if test="createTime != null">#{createTime},</if>-->
<!-- <if test="notice != null">#{notice},</if>-->
<!-- <if test="groupLeaderUserId != null and groupLeaderUserId !=''">#{groupLeaderUserId},</if>-->
<!-- </trim>-->
<!-- </insert>-->
<update id="updateWeGroup" parameterType="WeGroup">
update we_group
<trim prefix="SET" suffixOverrides=",">
<if test="groupName != null">group_name = #{groupName},</if>
<if test="memberNum != null">member_num = #{memberNum},</if>
<if test="groupLeader != null">group_leader = #{groupLeader},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="notice != null">notice = #{notice},</if>
<if test="groupLeaderUserId != null and groupLeaderUserId !=''">group_leader_user_id =#{groupLeaderUserId},</if>
</trim>
where id = #{id}
</update>
<!-- <update id="updateWeGroup" parameterType="WeGroup">-->
<!-- update we_group-->
<!-- <trim prefix="SET" suffixOverrides=",">-->
<!-- <if test="groupName != null">group_name = #{groupName},</if>-->
<!-- <if test="memberNum != null">member_num = #{memberNum},</if>-->
<!-- <if test="groupLeader != null">group_leader = #{groupLeader},</if>-->
<!-- <if test="createTime != null">create_time = #{createTime},</if>-->
<!-- <if test="notice != null">notice = #{notice},</if>-->
<!-- <if test="groupLeaderUserId != null and groupLeaderUserId !=''">group_leader_user_id =#{groupLeaderUserId},</if>-->
<!-- </trim>-->
<!-- where id = #{id}-->
<!-- </update>-->
<delete id="deleteWeGroupById" parameterType="Long">
delete from we_group where id = #{id}
</delete>
<!-- <delete id="deleteWeGroupById" parameterType="Long">-->
<!-- delete from we_group where id = #{id}-->
<!-- </delete>-->
<delete id="deleteWeGroupByIds" parameterType="String">
delete from we_group where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<!-- <delete id="deleteWeGroupByIds" parameterType="String">-->
<!-- delete from we_group where id in-->
<!-- <foreach item="id" collection="array" open="(" separator="," close=")">-->
<!-- #{id}-->
<!-- </foreach>-->
<!-- </delete>-->
<update id="batchLogicDeleteByIds" parameterType="String">
update we_group set del_flag=2
where id in
<foreach item="id" collection="ids" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<!-- <update id="batchLogicDeleteByIds" parameterType="String">-->
<!-- update we_group set del_flag=2-->
<!-- where id in-->
<!-- <foreach item="id" collection="ids" open="(" separator="," close=")">-->
<!-- #{id}-->
<!-- </foreach>-->
<!-- </update>-->
<insert id="batchInsetWeGroup" >
insert into we_group (id, group_name, member_num, group_leader, create_time, notice, group_leader_user_id)
values
<foreach collection="weGroups" item="weGroup" index="index" separator=",">
(#{weGroup.id},#{weGroup.groupName},#{weGroup.memberNum},#{weGroup.groupLeader},#{weGroup.createTime},#{weGroup.notice},#{weGroup.groupLeaderUserId})
</foreach>
</insert>
<!-- <insert id="batchInsetWeGroup" >-->
<!-- insert into we_group (id, group_name, member_num, group_leader, create_time, notice, group_leader_user_id)-->
<!-- values-->
<!-- <foreach collection="weGroups" item="weGroup" index="index" separator=",">-->
<!-- (#{weGroup.id},#{weGroup.groupName},#{weGroup.memberNum},#{weGroup.groupLeader},#{weGroup.createTime},#{weGroup.notice},#{weGroup.groupLeaderUserId})-->
<!-- </foreach>-->
<!-- </insert>-->
</mapper>
\ No newline at end of file
......@@ -4,71 +4,75 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.linkwechat.wecom.mapper.WeGroupMemberMapper">
<resultMap type="WeGroupMember" id="WeGroupMemberResult">
<result property="id" column="id" />
<result property="groupId" column="group_id" />
<result property="memberName" column="member_name" />
<result property="joinTime" column="join_time" />
<result property="joinType" column="join_type" />
</resultMap>
<!-- <resultMap type="WeGroupMember" id="WeGroupMemberResult">-->
<!-- <result property="id" column="id" />-->
<!-- <result property="groupId" column="group_id" />-->
<!-- <result property="memberName" column="member_name" />-->
<!-- <result property="joinTime" column="join_time" />-->
<!-- <result property="joinType" column="join_type" />-->
<!-- </resultMap>-->
<sql id="selectWeGroupMemberVo">
select id, group_id, member_name, join_time, join_type from we_group_member
</sql>
<!-- <sql id="selectWeGroupMemberVo">-->
<!-- select id, group_id, member_name, join_time, join_type from we_group_member-->
<!-- </sql>-->
<select id="selectWeGroupMemberList" parameterType="WeGroupMember" resultMap="WeGroupMemberResult">
<include refid="selectWeGroupMemberVo"/>
<select id="selectWeGroupMemberList" parameterType="WeGroupMember" resultType="com.linkwechat.wecom.domain.WeGroupMember">
SELECT
wc.`name` AS memberName,
wgm.join_time,
wgm.type
FROM
we_group_member wgm
LEFT JOIN we_customer wc ON wgm.user_id=wc.external_userid
<where>
<if test="groupId != null "> and group_id = #{groupId}</if>
<if test="memberName != null and memberName != ''"> and member_name like concat('%', #{memberName}, '%')</if>
<if test="joinTime != null "> and join_time = #{joinTime}</if>
<if test="joinType != null "> and join_type = #{joinType}</if>
<if test="chatId != null "> and wgm.chat_id = #{chatId}</if>
<if test="memberName != null and memberName != ''"> and wc.`name` like concat('%', #{memberName}, '%')</if>
</where>
</select>
<select id="selectWeGroupMemberById" parameterType="Long" resultMap="WeGroupMemberResult">
<include refid="selectWeGroupMemberVo"/>
where id = #{id}
</select>
<!-- <select id="selectWeGroupMemberById" parameterType="Long" resultMap="WeGroupMemberResult">-->
<!-- <include refid="selectWeGroupMemberVo"/>-->
<!-- where id = #{id}-->
<!-- </select>-->
<insert id="insertWeGroupMember" parameterType="WeGroupMember">
insert into we_group_member
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="groupId != null">group_id,</if>
<if test="memberName != null">member_name,</if>
<if test="joinTime != null">join_time,</if>
<if test="joinType != null">join_type,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="groupId != null">#{groupId},</if>
<if test="memberName != null">#{memberName},</if>
<if test="joinTime != null">#{joinTime},</if>
<if test="joinType != null">#{joinType},</if>
</trim>
</insert>
<!-- <insert id="insertWeGroupMember" parameterType="WeGroupMember">-->
<!-- insert into we_group_member-->
<!-- <trim prefix="(" suffix=")" suffixOverrides=",">-->
<!-- <if test="id != null">id,</if>-->
<!-- <if test="groupId != null">group_id,</if>-->
<!-- <if test="memberName != null">member_name,</if>-->
<!-- <if test="joinTime != null">join_time,</if>-->
<!-- <if test="joinType != null">join_type,</if>-->
<!-- </trim>-->
<!-- <trim prefix="values (" suffix=")" suffixOverrides=",">-->
<!-- <if test="id != null">#{id},</if>-->
<!-- <if test="groupId != null">#{groupId},</if>-->
<!-- <if test="memberName != null">#{memberName},</if>-->
<!-- <if test="joinTime != null">#{joinTime},</if>-->
<!-- <if test="joinType != null">#{joinType},</if>-->
<!-- </trim>-->
<!-- </insert>-->
<update id="updateWeGroupMember" parameterType="WeGroupMember">
update we_group_member
<trim prefix="SET" suffixOverrides=",">
<if test="groupId != null">group_id = #{groupId},</if>
<if test="memberName != null">member_name = #{memberName},</if>
<if test="joinTime != null">join_time = #{joinTime},</if>
<if test="joinType != null">join_type = #{joinType},</if>
</trim>
where id = #{id}
</update>
<!-- <update id="updateWeGroupMember" parameterType="WeGroupMember">-->
<!-- update we_group_member-->
<!-- <trim prefix="SET" suffixOverrides=",">-->
<!-- <if test="groupId != null">group_id = #{groupId},</if>-->
<!-- <if test="memberName != null">member_name = #{memberName},</if>-->
<!-- <if test="joinTime != null">join_time = #{joinTime},</if>-->
<!-- <if test="joinType != null">join_type = #{joinType},</if>-->
<!-- </trim>-->
<!-- where id = #{id}-->
<!-- </update>-->
<delete id="deleteWeGroupMemberById" parameterType="Long">
delete from we_group_member where id = #{id}
</delete>
<!-- <delete id="deleteWeGroupMemberById" parameterType="Long">-->
<!-- delete from we_group_member where id = #{id}-->
<!-- </delete>-->
<delete id="deleteWeGroupMemberByIds" parameterType="String">
delete from we_group_member where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<!-- <delete id="deleteWeGroupMemberByIds" parameterType="String">-->
<!-- delete from we_group_member where id in-->
<!-- <foreach item="id" collection="array" open="(" separator="," close=")">-->
<!-- #{id}-->
<!-- </foreach>-->
<!-- </delete>-->
</mapper>
\ 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!