WeCategoryMapper.xml
3.55 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
<?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.WeCategoryMapper">
<resultMap id="categoryMap" type="com.linkwechat.wecom.domain.WeCategory">
<id property="id" column="id"/>
<result property="mediaType" column="media_type"/>
<result property="name" column="name"/>
<result property="parentId" column="parent_id"/>
</resultMap>
<insert id="insertWeCategory">
INSERT INTO we_category
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="mediaType != null">media_type,</if>
<if test="name != null">name,</if>
<if test="parentId != null">parent_id,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="mediaType != null">#{mediaType},</if>
<if test="name != null">#{name},</if>
<if test="parentId != null">#{parentId},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateWeCategory">
UPDATE we_category
<trim prefix="set" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="mediaType != null">media_type,</if>
<if test="name != null">name,</if>
<if test="parentId != null">parent_id,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<where>
id=#{id}
</where>
</update>
<delete id="deleteWeCategoryById">
UPDATE we_category
set del_flag=1
<where>
id=#{id}
</where>
</delete>
<delete id="deleteWeCategoryByIds">
UPDATE we_category
set del_flag=1
<where>
id in
<foreach collection="array" open="(" close=")" item="item" separator=",">
#{item}
</foreach>
</where>
</delete>
<select id="findWeCategoryByMediaType" resultType="com.linkwechat.wecom.domain.WeCategory">
SELECT
<include refid="categoryVo"/>
FROM we_category
<where>
media_type=#{mediaType} and del_flag=0
</where>
</select>
<select id="findWeCategoryById" resultType="com.linkwechat.wecom.domain.WeCategory">
SELECT
<include refid="categoryVo"/>
FROM we_category
<where>
id=#{id} and del_flag=0
</where>
</select>
<select id="findWeCategoryByMediaTypeAndName" resultType="com.linkwechat.wecom.domain.WeCategory">
SELECT
<include refid="categoryVo"/>
FROM we_category
<where>
media_type=#{mediaType} and del_flag=0 and `name`=#{name}
</where>
</select>
<sql id="categoryVo">
id,media_type,parent_id,`name`
</sql>
</mapper>