BrandSeriesMapper.xml 3.7 KB
<?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 <include refid="queryColumns"/>
        from brand_series where brand_id = #{brandId}
    </select>
</mapper>