UfoSizeMapper.xml
3.64 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
<?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="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, CONCAT(IFNULL(CONCAT(sort2.sort_name,'/'),''),sort1.sort_name) AS sortName, size.order_by
</sql>
<insert id="insertSize" parameterType="com.yoho.ufo.model.commoditybasicrole.size.Size">
insert into size(id, size_name, sort_id, order_by, create_time, update_time)
values (#{id}, #{sizeName}, #{sortId}, #{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.sortId != null and size.sortId != ''">
sort_id = #{size.sortId},
</if>
<if test="size.orderBy != null and size.orderBy != ''">
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>
</set>
where id = #{size.id}
</update>
<select id="selectOneById" resultMap="sizeMap">
select id, size_name, sort_id, order_by
from size where id = #{id}
</select>
<sql id="queryPage">
from size
LEFT JOIN product_sort sort1
ON size.sort_id = sort1.id
left join product_sort sort2
on sort1.parent_id = sort2.id
<where>
<if test="size.sortName != null and size.sortName != ''">
sort1.sort_name like concat('%', #{size.sortName}, '%') or sort2.sort_name like concat('%', #{size.sortName}, '%')
</if>
<if test="size.sizeName != null and size.sizeName !=''">
and size.size_name like concat('%', #{size.sizeName}, '%')
</if>
</where>
</sql>
<select id="selectSizeCount" resultType="integer">
select count(*)
<include refid="queryPage"/>
</select>
<select id="getSizePageList" resultMap="sizeMap">
select <include refid="queryColumns"/>
<include refid="queryPage"/>
order by size.update_time desc
limit #{page.startIndex}, #{page.pageSize}
</select>
<select id="selectAllSizeBySortId" resultMap="sizeMap">
select <include refid="queryColumns"/>
from size where sort_id = #{sortId}
</select>
<select id="selectAllSizeBySortId" resultMap="sizeMap">
select id,size_name
from size where sort_id in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</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>
</mapper>