BrandMapper.xml 4.75 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.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>