UfoSizeMapper.xml
7.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
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
<?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.yoho.ufo.dal.UfoSizeMapper">
<resultMap id="sizeMap" type="com.yoho.ufo.model.commoditybasicrole.size.Size">
<id property="id" column="id"/>
<result property="sizeName" column="size_name"/>
<result property="sortId" column="sort_id"/>
<result property="sizeId" column="size_id"/>
<result property="orderBy" column="order_by"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<sql id="queryColumns">
size.id, size.size_name, size.order_by
</sql>
<insert id="insertSize" parameterType="com.yoho.ufo.model.commoditybasicrole.size.Size" useGeneratedKeys="true" keyProperty="id" >
insert into size(id, size_name, order_by, create_time, update_time)
values (#{id}, #{sizeName}, #{orderBy}, #{createTime}, #{updateTime})
</insert>
<update id="updateSize" parameterType="com.yoho.ufo.model.commoditybasicrole.size.Size">
update size
<set>
<if test="size.sizeName != null and size.sizeName !=''">
size_name = #{size.sizeName},
</if>
<if test="size.createTime != null">
create_time = #{size.createTime},
</if>
<if test="size.updateTime != null">
update_time = #{size.updateTime},
</if>
<if test="size.orderBy != null and size.orderBy !=''">
order_by = #{size.orderBy},
</if>
</set>
where id = #{size.id}
</update>
<select id="selectOneById" resultMap="sizeMap">
select id, size_name, order_by
from size where id = #{id}
</select>
<sql id="queryPage">
<where>
<if test="size.sizeName != null and size.sizeName !=''">
and size.size_name like concat('%', #{size.sizeName}, '%')
</if>
<if test="list != null and list.size() > 0">
and sort_size.del = 0 and sort_size.sort_id in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</sql>
<select id="selectSizeCount" resultType="integer">
select count(*) from size
<if test="list != null and list.size() > 0">
inner join sort_size on size.id = sort_size.size_id
</if>
<include refid="queryPage"/>
</select>
<select id="getSizePageList" resultMap="sizeMap">
select <include refid="queryColumns"/> from size
<if test="list != null and list.size() > 0">
inner join sort_size on size.id = sort_size.size_id
</if>
<include refid="queryPage"/>
order by size.order_by
limit #{page.startIndex}, #{page.pageSize}
</select>
<select id="selectAllSizeBySortId" resultMap="sizeMap">
select s.id, s.size_name
from size s inner join sort_size ss on s.id = ss.size_id where ss.del = 0
<if test="sortId != null and sortId >0 ">
and ss.sort_id = #{sortId}
</if>
order by ss.order_by, ss.id
</select>
<select id="selectByIdList" resultMap="sizeMap">
select id, size_name
from size where id in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</select>
<select id="getOrderBySortLevel2Id" resultMap="sizeMap">
select s.id, s.size_name,ss.order_by
from size s inner join sort_size ss on s.id = ss.size_id where ss.del = 0
<if test="sortId != null and sortId >0 ">
and ss.sort_id = #{sortId}
</if>
order by ss.order_by, ss.id
</select>
<select id="selectAllSize" resultMap="sizeMap">
select * from size
</select>
<insert id="addBind" parameterType="com.yoho.ufo.model.commoditybasicrole.size.Size">
insert into sort_size(id, sort_id,size_id,order_by, create_time, update_time,del)
values (#{id}, #{sortId},#{sizeId}, #{orderBy}, #{createTime}, #{updateTime},0)
</insert>
<update id="updateBind" parameterType="com.yoho.ufo.model.commoditybasicrole.size.Size">
update sort_size
<set>
<if test="size.sortId != null and size.sortId >0">
sort_id = #{size.sortId},
</if>
<if test="size.sizeId != null and size.sizeId >0">
size_id = #{size.sizeId},
</if>
<if test="size.orderBy != null">
order_by = #{size.orderBy},
</if>
<if test="size.createTime != null">
create_time = #{size.createTime},
</if>
<if test="size.updateTime != null">
update_time = #{size.updateTime},
</if>
<if test="size.del != null">
del = #{size.del}
</if>
</set>
where id = #{size.id}
</update>
<select id="getBySizeIdAndSortId" resultMap="sizeMap">
select id, size_id,sort_id,order_by
from sort_size where del = 0
<if test="sortId != null and sortId >0 ">
and sort_id = #{sortId}
</if>
<if test="sizeId != null and sizeId >0 ">
and size_id = #{sizeId}
</if>
</select>
<select id="selectAllSizeBySortIdList" resultMap="sizeMap">
select s.id, s.size_name,ss.order_by
from size s inner join sort_size ss on s.id = ss.size_id where ss.del = 0
<if test="sortIdList != null and sortIdList.size() >0 ">
and ss.sort_id in
<foreach item="item" index="index" collection="sortIdList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
order by ss.order_by, ss.id
</select>
<select id="getBindPageList" resultMap="sizeMap">
select * from sort_size ss where del = 0
<if test="sortIdList != null and sortIdList.size() >0 ">
and ss.sort_id in
<foreach item="item" index="index" collection="sortIdList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="size.sizeId != null and size.sizeId >0">
and ss.size_id = #{size.sizeId}
</if>
order by ss.sort_id,ss.order_by
limit #{page.startIndex}, #{page.pageSize}
</select>
<select id="getBindCount" resultType="integer">
select count(*) from sort_size ss where del = 0
<if test="sortIdList != null and sortIdList.size() >0 ">
and ss.sort_id in
<foreach item="item" index="index" collection="sortIdList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="size.sizeId != null and size.sizeId >0">
and ss.size_id = #{size.sizeId}
</if>
</select>
<select id="getBindById" resultMap="sizeMap">
select * from sort_size ss where id = #{id}
</select>
<select id="selectBySizeName" resultMap="sizeMap">
select id, size_name from size where size_name = #{sizeName}
</select>
<select id="selectBySizeNameList" resultMap="sizeMap">
select id, size_name
from size where size_name in
<foreach item="item" index="index" collection="sizeNameList" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>