<?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.BidSiteMapper">
    
    <resultMap type="BidSite" id="BidSiteResult">
        <result property="id"    column="id"    />
        <result property="siteName"    column="site_name"    />
        <result property="site"    column="site"    />
        <result property="favorite"    column="favorite"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectBidSiteVo">
        select id, site_name, site, favorite, remark from bid_site
    </sql>

    <select id="selectBidSiteList" parameterType="BidSite" resultMap="BidSiteResult">
        <include refid="selectBidSiteVo"/>
        <where>  
            <if test="siteName != null  and siteName != ''"> and site_name like concat('%', #{siteName}, '%')</if>
            <if test="site != null  and site != ''"> and site = #{site}</if>
            <if test="favorite != null  and favorite != ''"> and favorite = #{favorite}</if>
        </where>
    </select>
    
    <select id="selectBidSiteById" parameterType="Long" resultMap="BidSiteResult">
        <include refid="selectBidSiteVo"/>
        where id = #{id}
    </select>

    <insert id="insertBidSite" parameterType="BidSite" useGeneratedKeys="true" keyProperty="id">
        insert into bid_site
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="siteName != null">site_name,</if>
            <if test="site != null">site,</if>
            <if test="favorite != null">favorite,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="siteName != null">#{siteName},</if>
            <if test="site != null">#{site},</if>
            <if test="favorite != null">#{favorite},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateBidSite" parameterType="BidSite">
        update bid_site
        <trim prefix="SET" suffixOverrides=",">
            <if test="siteName != null">site_name = #{siteName},</if>
            <if test="site != null">site = #{site},</if>
            <if test="favorite != null">favorite = #{favorite},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBidSiteById" parameterType="Long">
        delete from bid_site where id = #{id}
    </delete>

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