WeKeywordGroupTaskMapper.xml
4.75 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?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.WeKeywordGroupTaskMapper">
<resultMap id="WeKeywordGroupTaskResult" type="WeKeywordGroupTask">
<id property="taskId" column="task_id"/>
<result property="taskName" column="task_name"/>
<result property="welcomeMsg" column="welcome_msg"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="keywords" column="keywords" />
<result property="groupNameList" column="group_name_list" javaType="java.lang.String"/>
<association property="groupCodeInfo" column="group_code_id" javaType="com.linkwechat.wecom.domain.vo.WeGroupCodeVo" select="selectGroupByTaskId" />
</resultMap>
<sql id="selectTaskVo">
SELECT DISTINCT
wkg.task_id,
wkg.task_name,
wkg.group_code_id,
wkg.welcome_msg,
wkg.keywords,
GROUP_CONCAT(DISTINCT wg.group_name SEPARATOR ' ') AS group_name_list,
wkg.create_by,
wkg.create_time,
wkg.update_by,
wkg.update_time,
wkg.del_flag
FROM
we_keyword_group wkg
LEFT JOIN we_group_code gc ON wkg.group_code_id = gc.id AND gc.del_flag = 0
LEFT JOIN we_group_code_actual gca ON gca.group_code_id = gc.id AND gca.del_flag = 0
LEFT JOIN we_group wg ON wg.chat_id = gca.chat_id
</sql>
<!-- <select id="selectGroupNameByTaskId" parameterType="Long" resultMap="groupNameResultMap">-->
<!-- select distinct wg.group_name-->
<!-- from we_keyword_group wkg-->
<!-- LEFT JOIN we_keyword_group_kw wkgk ON wkgk.task_id = wkg.task_id-->
<!-- LEFT JOIN we_group_code gc ON wkg.group_code_id = gc.id-->
<!-- LEFT JOIN we_group_code_actual gca ON gca.group_code_id = gc.id-->
<!-- LEFT JOIN we_group wg ON wg.chat_id = gca.chat_id-->
<!-- WHERE wkg.task_id = #{taskId}-->
<!-- </select>-->
<!-- <select id="selectKeywordByTaskId" resultMap="keywordResultMap">-->
<!-- select task_id, keyword from we_keyword_group_kw where task_id = #{taskId}-->
<!-- </select>-->
<select id="selectGroupByTaskId" parameterType="Long" resultType="WeGroupCodeVo">
select distinct wgc.id, wgc.code_url
from we_group_code wgc left join we_keyword_group wkg on wgc.id = wkg.group_code_id
where wgc.id = #{groupCodeId};
</select>
<select id="getTaskById" parameterType="Long" resultMap="WeKeywordGroupTaskResult">
<include refid="selectTaskVo" />
WHERE wkg.task_id = #{taskId} AND wkg.del_flag = 0
GROUP BY wkg.task_id
</select>
<select id="getTaskList" resultMap="WeKeywordGroupTaskResult">
<include refid="selectTaskVo" />
WHERE
wkg.del_flag = 0
<if test="taskName != null and taskName !='' ">
AND wkg.task_name LIKE CONCAT("%",#{taskName},"%")
</if>
<if test="keywords != null and keywords != ''">
AND FIND_IN_SET(#{keywords}, keywords)
</if>
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
AND date_format(wkg.create_time,'%y%m%d') >= date_format(#{beginTime},'%y%m%d')
</if>
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
AND date_format(wkg.create_time,'%y%m%d') <= date_format(#{endTime},'%y%m%d')
</if>
<if test="createBy!=null and createBy!=''">
AND wkg.create_by LIKE CONCAT("%",#{createBy},"%")
</if>
GROUP BY wkg.task_id
order by create_time desc
</select>
<!-- <select id="getGroupNameListByTaskId" parameterType="Long" resultType="String">-->
<!-- SELECT DISTINCT-->
<!-- g.group_name-->
<!-- FROM-->
<!-- we_keyword_group wkg-->
<!-- LEFT JOIN we_group_code gc ON wkg.group_code_id = gc.id-->
<!-- LEFT JOIN we_group_code_actual gca ON gca.group_code_id = gc.id-->
<!-- LEFT JOIN we_group g ON g.chat_id = gca.chat_id-->
<!-- WHERE wkg.task_id = #{taskId}-->
<!-- </select>-->
<select id="filterByNameOrKeyword" parameterType="String" resultMap="WeKeywordGroupTaskResult">
<include refid="selectTaskVo" />
WHERE wkg.task_name LIKE CONCAT("%",#{word},"%")
OR FIND_IN_SET(#{word}, wkg.keywords)
GROUP BY wkg.task_id
</select>
</mapper>