BrandMapper.xml
4.75 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
<?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.BrandMapper">
<resultMap id="brandMap" type="com.yoho.ufo.model.brand.Brand">
<id property="id" column="id"/>
<result property="brandName" column="brand_name"/>
<result property="brandNameEn" column="brand_name_en"/>
<result property="brandNameCn" column="brand_name_cn"/>
<result property="brandLogo" column="brand_logo"/>
<result property="brandSearch" column="brand_search"/>
<result property="status" column="status"/>
<result property="editTime" column="edit_time"/>
<result property="createTime" column="create_time"/>
<result property="editPid" column="edit_pid"/>
<result property="search_show_image" column="searchShowImage"/>
<result property="ex_raise" column="exRaise"/>
</resultMap>
<sql id="queryColumns">
id, brand_name, brand_name_cn, brand_name_en, brand_logo, brand_search, status, create_time, search_show_image,ex_raise
</sql>
<insert id="insertBrand" parameterType="com.yoho.ufo.model.brand.Brand">
insert into brand(id, brand_name, brand_name_cn, brand_name_en, brand_logo, search_show_image, brand_search, status, create_time, edit_time, edit_pid,ex_raise)
values (#{id}, #{brandName},#{brandNameCn}, #{brandNameEn}, #{brandLogo}, #{searchShowImage}, #{brandSearch}, #{status}, #{createTime}, #{editTime}, #{editPid}, #{exRaise})
</insert>
<update id="updateBrandStatus" parameterType="com.yoho.ufo.model.brand.Brand">
update brand set status = #{status}, edit_time = #{editTime}, edit_pid = #{editPid} where id = #{id}
</update>
<update id="updateBrand">
update brand
<set>
<if test="brand.brandName != null and brand.brandName !=''">
brand_name = #{brand.brandName},
</if>
<if test="brand.brandNameEn != null and brand.brandNameEn != ''">
brand_name_en = #{brand.brandNameEn},
</if>
<if test="brand.brandNameCn != null and brand.brandNameCn != ''">
brand_name_cn = #{brand.brandNameCn},
</if>
<if test="brand.brandLogo != null and brand.brandLogo != ''">
brand_logo = #{brand.brandLogo},
</if>
<if test="brand.status != null and brand.status != ''">
status = #{brand.status},
</if>
<if test="brand.createTime != null">
create_time = #{brand.createTime},
</if>
<if test="brand.editTime != null">
edit_time = #{brand.editTime},
</if>
<if test="brand.editPid != null">
edit_pid = #{brand.editPid},
</if>
<if test="brand.exRaise != null">
ex_raise = #{brand.exRaise},
</if>
brand_search = #{brand.brandSearch},
search_show_image = #{brand.searchShowImage}
</set>
where id = #{brand.id}
</update>
<select id="selectOneById" resultMap="brandMap">
select <include refid="queryColumns" />
from brand where id = #{id}
</select>
<select id="selectBrandCount" resultType="integer">
select count(*)
from brand
<where>
<if test="brand.brandName != null and brand.brandName != ''">
brand_name like concat('%', #{brand.brandName}, '%')
</if>
<if test="brand.status != null">
and status = #{brand.status}
</if>
</where>
</select>
<select id="getBrandPageList" resultMap="brandMap">
select <include refid="queryColumns"/>
from brand
<where>
<if test="brand.brandName != null and brand.brandName != ''">
brand_name like concat('%', #{brand.brandName}, '%') or brand_name_en like concat('%', #{brand.brandName}, '%')
</if>
<if test="brand.status != null">
status = #{brand.status}
</if>
</where>
order by create_time desc
limit #{page.startIndex}, #{page.pageSize}
</select>
<select id="getAllBrand" resultMap="brandMap">
select id, brand_name
from brand
</select>
<select id="getAllValidBrand" resultMap="brandMap">
select id, brand_name
from brand where status = 1
</select>
<select id="selectBrandByIdList" resultMap="brandMap">
select id, brand_name
from brand where id in
<foreach item="item" index="index" collection="list" open="(" separator="," close=")">
#{item}
</foreach>
</select>
</mapper>