<?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.BidZizhiMapper">
    
    <resultMap type="BidZizhi" id="BidZizhiResult">
        <result property="id"    column="id"    />
        <result property="tenantCode"    column="tenant_code"    />
        <result property="documentName"    column="document_name"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectBidZizhiVo">
        select id, tenant_code, document_name, remark from bid_zizhi
    </sql>

    <select id="selectBidZizhiList" parameterType="BidZizhi" resultMap="BidZizhiResult">
        <include refid="selectBidZizhiVo"/>
        <where>  
            <if test="tenantCode != null  and tenantCode != ''"> and tenant_code = #{tenantCode}</if>
            <if test="documentName != null  and documentName != ''"> and document_name like concat('%', #{documentName}, '%')</if>
        </where>
    </select>
    
    <select id="selectBidZizhiById" parameterType="Long" resultMap="BidZizhiResult">
        <include refid="selectBidZizhiVo"/>
        where id = #{id}
    </select>

    <insert id="insertBidZizhi" parameterType="BidZizhi" useGeneratedKeys="true" keyProperty="id">
        insert into bid_zizhi
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="tenantCode != null">tenant_code,</if>
            <if test="documentName != null">document_name,</if>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="tenantCode != null">#{tenantCode},</if>
            <if test="documentName != null">#{documentName},</if>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateBidZizhi" parameterType="BidZizhi">
        update bid_zizhi
        <trim prefix="SET" suffixOverrides=",">
            <if test="tenantCode != null">tenant_code = #{tenantCode},</if>
            <if test="documentName != null">document_name = #{documentName},</if>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBidZizhiById" parameterType="Long">
        delete from bid_zizhi where id = #{id}
    </delete>

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