WeChatContactMappingMapper.xml
3.79 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
<?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>