<?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.ruoyi.framework.recovery.mapper.RecCommodityMapper">

    <resultMap type="RecCommodity" id="RecCommodityResult">
        <result property="id"    column="id"    />
        <result property="brandId"    column="brand_id"    />
        <result property="model"    column="model"    />
        <result property="catalog"    column="catalog"    />
        <result property="sale"    column="sale"    />
        <result property="market"    column="market"    />
        <result property="createBy"    column="create_by"    />
        <result property="createDate"    column="create_date"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateDate"    column="update_date"    />
        <result property="images" column="images"/>
        <result property="specs" column="specs"/>
    </resultMap>

    <sql id="selectRecCommodityVo">
        select id, brand_id, model, catalog, sale, market, create_by, create_date, update_by,
            update_date, images, specs from rec_commodity
    </sql>

    <select id="selectRecCommodityList" parameterType="RecCommodity" resultMap="RecCommodityResult">
        <include refid="selectRecCommodityVo"/>
        <where>
            <if test="brandId != null "> and brand_id = #{brandId}</if>
            <if test="model != null  and model != ''"> and model = #{model}</if>
            <if test="catalog != null  and catalog != ''"> and catalog = #{catalog}</if>
            <if test="sale != null "> and sale = #{sale}</if>
            <if test="market != null "> and market = #{market}</if>
            <if test="createDate != null "> and create_date = #{createDate}</if>
            <if test="updateDate != null "> and update_date = #{updateDate}</if>
            <if test="images != null "> and images = #{images}</if>
            <if test="specs != null "> and specs = #{specs}</if>
        </where>
    </select>

    <select id="selectRecCommodityById" parameterType="Long" resultMap="RecCommodityResult">
        <include refid="selectRecCommodityVo"/>
        where id = #{id}
    </select>

    <insert id="insertRecCommodity" parameterType="RecCommodity" useGeneratedKeys="true" keyProperty="id">
        insert into rec_commodity
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="brandId != null">brand_id,</if>
            <if test="model != null">model,</if>
            <if test="catalog != null">catalog,</if>
            <if test="sale != null">sale,</if>
            <if test="market != null">market,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createDate != null">create_date,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateDate != null">update_date,</if>
            <if test="images != null">images,</if>
            <if test="specs != null">specs,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="brandId != null">#{brandId},</if>
            <if test="model != null">#{model},</if>
            <if test="catalog != null">#{catalog},</if>
            <if test="sale != null">#{sale},</if>
            <if test="market != null">#{market},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createDate != null">#{createDate},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateDate != null">#{updateDate},</if>
            <if test="images != null">#{images},</if>
            <if test="specs != null">#{specs},</if>
         </trim>
    </insert>

    <update id="updateRecCommodity" parameterType="RecCommodity">
        update rec_commodity
        <trim prefix="SET" suffixOverrides=",">
            <if test="brandId != null">brand_id = #{brandId},</if>
            <if test="model != null">model = #{model},</if>
            <if test="catalog != null">catalog = #{catalog},</if>
            <if test="sale != null">sale = #{sale},</if>
            <if test="market != null">market = #{market},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createDate != null">create_date = #{createDate},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateDate != null">update_date = #{updateDate},</if>
            <if test="images != null">images = #{images},</if>
            <if test="specs != null">specs = #{specs},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteRecCommodityById" parameterType="Long">
        delete from rec_commodity where id = #{id}
    </delete>

    <delete id="deleteRecCommodityByIds" parameterType="String">
        delete from rec_commodity where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
