NoticeMapper.xml
5.82 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
<?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.yohobuy.platform.dal.cms.INoticeDao" >
<resultMap id="BaseResultMap" type="com.yohobuy.platform.dal.cms.model.Notice" >
<id column="id" property="id" jdbcType="INTEGER" />
<result column="title" property="title" jdbcType="VARCHAR" />
<result column="img" property="img" jdbcType="VARCHAR" />
<result column="url" property="url" jdbcType="VARCHAR" />
<result column="position" property="position" jdbcType="TINYINT" />
<result column="show_channels" property="showChannels" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="status" property="status" jdbcType="TINYINT" />
<result column="start_time" property="startTime" jdbcType="INTEGER" />
<result column="end_time" property="endTime" jdbcType="INTEGER" />
</resultMap>
<sql id="Base_Column_List" >
id, title, img, url, position, show_channels, create_time, status, start_time, end_time
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from notice
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from notice
where id = #{id,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.yohobuy.platform.dal.cms.model.Notice" useGeneratedKeys="true" keyProperty="id" >
insert into notice (id, title, img, url, position, create_time, status, start_time, end_time, show_channels)
values (#{id,jdbcType=INTEGER}, #{title,jdbcType=VARCHAR}, #{img,jdbcType=VARCHAR},
#{url,jdbcType=VARCHAR}, #{position,jdbcType=TINYINT}, UNIX_TIMESTAMP(),
#{status,jdbcType=TINYINT}, #{startTime,jdbcType=INTEGER},
#{endTime,jdbcType=INTEGER}, #{showChannels,jdbcType=VARCHAR}
)
</insert>
<insert id="insertSelective" parameterType="com.yohobuy.platform.dal.cms.model.Notice" useGeneratedKeys="true" keyProperty="id" >
insert into notice
<trim prefix="(" suffix=")" suffixOverrides="," >
id,
<if test="title != null" >
title,
</if>
<if test="img != null" >
img,
</if>
<if test="url != null" >
url,
</if>
<if test="position != null" >
position,
</if>
create_time,
<if test="status != null" >
status,
</if>
<if test="startTime != null" >
start_time,
</if>
<if test="endTime != null" >
end_time,
</if>
<if test="showChannels != null" >
show_channels,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
#{id,jdbcType=INTEGER},
<if test="title != null" >
#{title,jdbcType=VARCHAR},
</if>
<if test="img != null" >
#{img,jdbcType=VARCHAR},
</if>
<if test="url != null" >
#{url,jdbcType=VARCHAR},
</if>
<if test="position != null" >
#{position,jdbcType=TINYINT},
</if>
UNIX_TIMESTAMP(),
<if test="status != null" >
#{status,jdbcType=TINYINT},
</if>
<if test="startTime != null" >
#{startTime,jdbcType=INTEGER},
</if>
<if test="endTime != null" >
#{endTime,jdbcType=INTEGER},
</if>
<if test="showChannels != null" >
#{showChannels,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.yohobuy.platform.dal.cms.model.Notice" >
update notice
<set >
<if test="title != null" >
title = #{title,jdbcType=VARCHAR},
</if>
<if test="img != null" >
img = #{img,jdbcType=VARCHAR},
</if>
<if test="url != null" >
url = #{url,jdbcType=VARCHAR},
</if>
<if test="position != null" >
position = #{position,jdbcType=TINYINT},
</if>
<if test="status != null" >
status = #{status,jdbcType=TINYINT},
</if>
<if test="showChannels != null" >
show_channels = #{showChannels,jdbcType=VARCHAR},
</if>
<if test="startTime != null" >
start_time = #{startTime,jdbcType=INTEGER},
</if>
<if test="endTime != null" >
end_time = #{endTime,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.yohobuy.platform.dal.cms.model.Notice" >
update notice
set title = #{title,jdbcType=VARCHAR},
img = #{img,jdbcType=VARCHAR},
url = #{url,jdbcType=VARCHAR},
position = #{position,jdbcType=TINYINT},
show_channels = #{showChannels,jdbcType=VARCHAR},
status = #{status,jdbcType=TINYINT},
start_time = #{startTime,jdbcType=INTEGER},
end_time = #{endTime,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
<sql id="page_condition">
<trim prefix="where" prefixOverrides="and | or">
<if test="notice.title != null" >
and title like CONCAT('%',#{notice.title},'%')
</if>
<if test="notice.showChannels != null">
and ( show_channels like CONCAT('%',#{notice.showChannels},'%') or ISNULL(show_channels) or not LENGTH(show_channels) )
</if>
<if test="notice.position != null" >
and position = #{notice.position}
</if>
</trim>
</sql>
<select id="selectSelective" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from notice
<include refid="page_condition"/>
order by id DESC
limit #{start}, #{size}
</select>
<select id="selectCountSelective" resultType="java.lang.Integer">
select
count(*)
from notice
<include refid="page_condition"/>
</select>
</mapper>