WeGroupMapper.xml
1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?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.WeGroupMapper">
<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,
wg.status,
wg.`owner`
FROM
we_group wg
LEFT JOIN we_user wu ON wg.`owner`=wu.user_id
<where>
<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="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
AND date_format(wg.create_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
</if>
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
AND date_format(wg.create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
</if>
<if test="userIds != null and userIds !=''">
<if test="userIds.indexOf(',') != -1">
AND wg.`owner` in
<foreach item="item" index="index" collection="userIds.split(',')" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="userIds.indexOf(',') == -1">
AND wg.`owner`=#{userIds}
</if>
</if>
</where>
</select>
</mapper>