<?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.RecStoresMapper">

    <resultMap type="RecStores" id="RecStoresResult">
        <result property="id"    column="id"    />
        <result property="storesName"    column="stores_name"    />
        <result property="saleType"    column="sale_type"    />
        <result property="saleTime"    column="sale_time"    />
        <result property="checkTime"    column="check_time"    />
        <result property="checkType"    column="check_type"    />
        <result property="buyTime"    column="buy_time"    />
        <result property="saleLink"    column="sale_link"    />
        <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="commondityId"    column="commondity_id"    />
        <result property="storesAddress"    column="stores_address"    />
        <result property="notice" column="notice" />
        <result property="saleNum" column="sale_num" />
        <result property="cityId" column="city_id" />
        <result property="images" column="images" />
        <result property="skipLink" column="skip_link" />
    </resultMap>

    <sql id="selectRecStoresVo">
        select id, stores_name, sale_type, sale_time, check_time, check_type, buy_time, sale_link, create_by,
               create_date, update_by, update_date, commondity_id, stores_address, notice, sale_num, city_id, images, skip_link
        from rec_stores
    </sql>

    <select id="selectRecStoresList" parameterType="RecStores" resultMap="RecStoresResult">
        <include refid="selectRecStoresVo"/>
        <where>
            <if test="storesName != null  and storesName != ''"> and stores_name like concat('%', #{storesName}, '%')</if>
            <if test="saleType != null  and saleType != ''"> and sale_type = #{saleType}</if>
            <if test="saleTime != null  and saleTime != ''"> and sale_time = #{saleTime}</if>
            <if test="checkTime != null "> and check_time = #{checkTime}</if>
            <if test="checkType != null  and checkType != ''"> and check_type = #{checkType}</if>
            <if test="buyTime != null  and buyTime != ''"> and buy_time = #{buyTime}</if>
            <if test="saleLink != null  and saleLink != ''"> and sale_link = #{saleLink}</if>
            <if test="createDate != null "> and create_date = #{createDate}</if>
            <if test="updateDate != null "> and update_date = #{updateDate}</if>
            <if test="commondityId != null "> and commondity_id = #{commondityId}</if>
            <if test="storesAddress != null  and storesAddress != ''"> and stores_address = #{storesAddress}</if>
            <if test="notice != null  and notice != ''"> and notice = #{notice}</if>
            <if test="saleNum != null  and saleNum != ''"> and sale_num = #{saleNum}</if>
            <if test="cityId != null  and cityId != ''"> and city_id = #{cityId}</if>
            <if test="images != null  and images != ''"> and images = #{images}</if>
            <if test="skipLink != null  and skipLink != ''"> and skip_link = #{skipLink}</if>
        </where>
    </select>

    <select id="selectRecStoresById" parameterType="Long" resultMap="RecStoresResult">
        <include refid="selectRecStoresVo"/>
        where id = #{id}
    </select>

    <insert id="insertRecStores" parameterType="RecStores">
        insert into rec_stores
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="storesName != null">stores_name,</if>
            <if test="saleType != null">sale_type,</if>
            <if test="saleTime != null">sale_time,</if>
            <if test="checkTime != null">check_time,</if>
            <if test="checkType != null">check_type,</if>
            <if test="buyTime != null">buy_time,</if>
            <if test="saleLink != null">sale_link,</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="commondityId != null">commondity_id,</if>
            <if test="storesAddress != null">stores_address,</if>
            <if test="notice != null">notice,</if>
            <if test="saleNum != null">sale_num,</if>
            <if test="cityId != null">city_id,</if>
            <if test="images != null">images,</if>
            <if test="skipLink != null">skip_link,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="storesName != null">#{storesName},</if>
            <if test="saleType != null">#{saleType},</if>
            <if test="saleTime != null">#{saleTime},</if>
            <if test="checkTime != null">#{checkTime},</if>
            <if test="checkType != null">#{checkType},</if>
            <if test="buyTime != null">#{buyTime},</if>
            <if test="saleLink != null">#{saleLink},</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="commondityId != null">#{commondityId},</if>
            <if test="storesAddress != null">#{storesAddress},</if>
            <if test="notice != null">#{notice},</if>
            <if test="saleNum != null">#{saleNum},</if>
            <if test="cityId != null">#{cityId},</if>
            <if test="images != null">#{images},</if>
            <if test="skipLink != null">#{skipLink},</if>
         </trim>
    </insert>

    <update id="updateRecStores" parameterType="RecStores">
        update rec_stores
        <trim prefix="SET" suffixOverrides=",">
            <if test="storesName != null">stores_name = #{storesName},</if>
            <if test="saleType != null">sale_type = #{saleType},</if>
            <if test="saleTime != null">sale_time = #{saleTime},</if>
            <if test="checkTime != null">check_time = #{checkTime},</if>
            <if test="checkType != null">check_type = #{checkType},</if>
            <if test="buyTime != null">buy_time = #{buyTime},</if>
            <if test="saleLink != null">sale_link = #{saleLink},</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="commondityId != null">commondity_id = #{commondityId},</if>
            <if test="storesAddress != null">stores_address = #{storesAddress},</if>
            <if test="notice != null">notice = #{notice},</if>
            <if test="saleNum != null">sale_num = #{saleNum},</if>
            <if test="cityId != null">city_id = #{cityId},</if>
            <if test="images != null">images = #{images},</if>
            <if test="skipLink != null">skip_link = #{skipLink},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteRecStoresById" parameterType="Long">
        delete from rec_stores where id = #{id}
    </delete>

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