<?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.bid.mapper.BidInfoMapper">
    
    <resultMap type="BidInfo" id="BidInfoResult">
        <result property="id"    column="id"    />
        <result property="title"    column="title"    />
        <result property="link"    column="link"    />
        <result property="fbDate"    column="fb_date"    />
        <result property="sourceSite"    column="source_site"    />
        <result property="province"    column="province"    />
        <result property="customerType"    column="customer_type"    />
        <result property="estimatedAmount"    column="estimated_amount"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectBidInfoVo">
        select id, title, link, fb_date, source_site, province, customer_type, estimated_amount, create_by, create_time, update_by, update_time, remark from bid_info
    </sql>

    <select id="selectBidInfoList" parameterType="BidInfo" resultMap="BidInfoResult">
        <include refid="selectBidInfoVo"/>
        <where>  
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="link != null  and link != ''"> and link = #{link}</if>
            <if test="fbDate != null "> and fb_date = #{fbDate}</if>
            <if test="sourceSite != null  and sourceSite != ''"> and source_site = #{sourceSite}</if>
            <if test="province != null  and province != ''"> and province = #{province}</if>
            <if test="customerType != null  and customerType != ''"> and customer_type = #{customerType}</if>
            <if test="estimatedAmount != null "> and estimated_amount = #{estimatedAmount}</if>
        </where>
    </select>
    
    <select id="selectBidInfoById" parameterType="Long" resultMap="BidInfoResult">
        <include refid="selectBidInfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertBidInfo" parameterType="BidInfo" useGeneratedKeys="true" keyProperty="id">
        insert into bid_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="title != null">title,</if>
            <if test="link != null">link,</if>
            <if test="fbDate != null">fb_date,</if>
            <if test="sourceSite != null">source_site,</if>
            <if test="province != null">province,</if>
            <if test="customerType != null">customer_type,</if>
            <if test="estimatedAmount != null">estimated_amount,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="title != null">#{title},</if>
            <if test="link != null">#{link},</if>
            <if test="fbDate != null">#{fbDate},</if>
            <if test="sourceSite != null">#{sourceSite},</if>
            <if test="province != null">#{province},</if>
            <if test="customerType != null">#{customerType},</if>
            <if test="estimatedAmount != null">#{estimatedAmount},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateBidInfo" parameterType="BidInfo">
        update bid_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="title != null">title = #{title},</if>
            <if test="link != null">link = #{link},</if>
            <if test="fbDate != null">fb_date = #{fbDate},</if>
            <if test="sourceSite != null">source_site = #{sourceSite},</if>
            <if test="province != null">province = #{province},</if>
            <if test="customerType != null">customer_type = #{customerType},</if>
            <if test="estimatedAmount != null">estimated_amount = #{estimatedAmount},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBidInfoById" parameterType="Long">
        delete from bid_info where id = #{id}
    </delete>

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