WeChatItemMapper.xml
2.56 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
<?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.WeChatItemMapper">
<insert id="addItem">
INSERT INTO
we_chat_item(item_id,side_id,material_id,create_by,create_time,update_by,update_time)
VALUES
<if test="items!=null and items.size()>0">
<foreach collection="items" separator="," item="item" >
(#{item.itemId},#{item.sideId},#{item.materialId},#{item.createBy},#{item.createTime},#{item.updateBy},#{item.updateTime})
</foreach>
</if>
</insert>
<delete id="dropItem">
DELETE FROM
we_chat_item
<where>
side_id=#{sideId}
</where>
</delete>
<select id="findChatItems" resultType="com.linkwechat.wecom.domain.vo.WeChatSideVo">
SELECT
wci.material_id,
wm.material_name,
wm.material_url,
wm.content,
wc.media_type,
(
SELECT
COUNT(1)
FROM
we_chat_collection
WHERE
material_id = wci.material_id
AND user_id = #{userId}
) collection,
wci.create_time
FROM
we_chat_item wci
LEFT JOIN we_material wm ON wci.material_id = wm.id
LEFT JOIN we_category wc ON wm.category_id = wc.id
<where>
wci.side_id=#{sideId}
<if test="keyword!=null and keyword!=''">
<if test="mediaType!=null and mediaType=='0'.toString()">
AND wm.content LIKE CONCAT('%',#{keyword},'%')
</if>
<if test="mediaType!=null and mediaType=='1'.toString()">
AND wm.material_name LIKE CONCAT('%',#{keyword},'%')
</if>
<if test="mediaType!=null and mediaType=='2'.toString()">
AND wm.material_name LIKE CONCAT('%',#{keyword},'%')
</if>
<if test="mediaType!=null and mediaType=='3'.toString()">
AND wm.material_name LIKE CONCAT('%',#{keyword},'%')
</if>
<if test="mediaType!=null and mediaType=='4'.toString()">
AND wm.content LIKE CONCAT('%',#{keyword},'%')
</if>
<if test="mediaType!=null and mediaType=='5'.toString()">
AND wm.material_name LIKE CONCAT('%',#{keyword},'%')
</if>
</if>
</where>
</select>
</mapper>