BrandSeriesMapper.xml
3.85 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.yoho.ufo.dal.UfoBrandSeriesMapper">
<resultMap id="brandSeriesMap" type="com.yoho.ufo.model.brand.BrandSeries">
<id property="id" column="id"/>
<result property="seriesName" column="series_name"/>
<result property="seriesSearch" column="series_search"/>
<result property="brandId" column="brand_id"/>
<result property="status" column="status"/>
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<sql id="queryColumns">
series.id, series.series_name, series.series_search, series.create_time, series.status,brand.brand_name
</sql>
<insert id="insertBrandSeries" parameterType="com.yoho.ufo.model.brand.Brand">
insert into brand_series(id, series_name, series_search, status, create_time, update_time, brand_id)
values (#{id}, #{seriesName}, #{seriesSearch}, #{status}, #{createTime}, #{updateTime}, #{brandId})
</insert>
<update id="updateBrandSeriesStatus" parameterType="com.yoho.ufo.model.brand.BrandSeries">
update brand_series set status = #{status}, update_time = #{updateTime} where id = #{id}
</update>
<update id="updateBrandSeries" parameterType="com.yoho.ufo.model.brand.BrandSeries">
update brand_series
<set>
<if test="brandSeries.seriesName != null and brandSeries.seriesName !=''">
series_name = #{brandSeries.seriesName},
</if>
<if test="brandSeries.brandId != null and brandSeries.brandId != ''">
brand_id = #{brandSeries.brandId},
</if>
<if test="brandSeries.status != null and brandSeries.status != ''">
status = #{brandSeries.status},
</if>
<if test="brandSeries.createTime != null">
create_time = #{brandSeries.createTime},
</if>
<if test="brandSeries.updateTime != null">
update_time = #{brandSeries.updateTime},
</if>
series_search = #{brandSeries.seriesSearch}
</set>
where id = #{brandSeries.id}
</update>
<select id="selectOneById" resultMap="brandSeriesMap">
select id, series_name, brand_id, series_search
from brand_series where id = #{id}
</select>
<sql id="queryParam">
from brand_series series
left join brand
on series.brand_id = brand.id
<where>
<if test="brandSeries.seriesName != null and brandSeries.seriesName !=''">
series.series_name like concat('%', #{brandSeries.seriesName}, '%')
</if>
<if test="brandSeries.status != null">
and series.status = #{brandSeries.status}
</if>
<if test="brandSeries.brandName != null and brandSeries.brandName != ''">
and brand.brand_name like concat('%', #{brandSeries.brandName}, '%')
</if>
</where>
</sql>
<select id="selectBrandSeriesCount" resultType="integer">
select count(*)
<include refid="queryParam"/>
</select>
<select id="getBrandSeriesPageList" resultMap="brandSeriesMap">
select <include refid="queryColumns"/>
<include refid="queryParam"/>
order by series.update_time desc
limit #{page.startIndex}, #{page.pageSize}
</select>
<select id="selectSeriesByBrandId" resultMap="brandSeriesMap">
select id, series_name, brand_id, series_search
from brand_series where brand_id = #{brandId}
</select>
<select id="selectAll" resultMap="brandSeriesMap">
select id, series_name, brand_id, series_search
from brand_series
</select>
</mapper>