<?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.tuya.mapper.BusSupplierReleaseMapper">

    <resultMap type="BusSupplierRelease" id="BusSupplierReleaseResult">
        <result property="id"    column="id"    />
        <result property="code"    column="code"    />
        <result property="uuid"    column="uuid"    />
        <result property="demandUuid"    column="demand_uuid"    />
        <result property="jdrq"    column="jdrq"    />
        <result property="updateDate"    column="update_date"    />
        <result property="priceAll"    column="price_all"    />
        <result property="titleImg"    column="title_img"    />
        <result property="offerName"    column="offer_name"    />
        <result property="priceDetail"    column="price_detail"    />
        <result property="contractFile"    column="contract_file"    />
        <result property="priceDetailText"    column="price_detail_text"    />
        <result property="other"    column="other"    />
        <result property="orderNo"    column="order_no"    />
        <result property="score"    column="score"    />
    </resultMap>

    <sql id="selectBusSupplierReleaseVo">
        select id, code, uuid, demand_uuid, jdrq, update_date, price_all, title_img, offer_name, price_detail,
               contract_file, price_detail_text, other, order_no, score, score_content, score_label, public_is_no
        from bus_supplier_release
    </sql>

    <select id="selectBusSupplierReleaseList" parameterType="BusSupplierRelease" resultMap="BusSupplierReleaseResult">
        <include refid="selectBusSupplierReleaseVo"/>
        <where>
            <if test="code != null  and code != ''"> and code like concat('%', #{code}, '%')</if>
            <if test="uuid != null  and uuid != ''"> and uuid like concat('%', #{uuid}, '%')</if>
            <if test="demandUuid != null  and demandUuid != ''"> and demand_uuid like concat('%', #{demandUuid}, '%')</if>
            <if test="jdrq != null "> and DATEADD(ms, -DATEPART(ms, jdrq), jdrq) = #{jdrq}</if>
            <if test="updateDate != null "> and DATEADD(ms, -DATEPART(ms, update_date), update_date) = #{updateDate}</if>
            <if test="priceAll != null "> and price_all = #{priceAll}</if>
            <if test="titleImg != null  and titleImg != ''"> and title_img = #{titleImg}</if>
            <if test="offerName != null  and offerName != ''"> and offer_name like concat('%', #{offerName}, '%')</if>
            <if test="priceDetail != null  and priceDetail != ''"> and price_detail = #{priceDetail}</if>
            <if test="contractFile != null  and contractFile != ''"> and contract_file = #{contractFile}</if>
            <if test="priceDetailText != null  and priceDetailText != ''"> and price_detail_text = #{priceDetailText}</if>
            <if test="other != null  and other != ''"> and other like concat('%', #{other}, '%')</if>
            <if test="orderNo != null  and orderNo != ''"> and order_no like concat('%', #{orderNo}, '%')</if>
            <if test="score != null  and score != ''"> and score = #{score}</if>
        </where>
    </select>

    <select id="selectBusSupplierReleaseById" parameterType="Long" resultMap="BusSupplierReleaseResult">
        <include refid="selectBusSupplierReleaseVo"/>
        where id = #{id}
    </select>

    <insert id="insertBusSupplierRelease" parameterType="BusSupplierRelease">
        insert into bus_supplier_release
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="code != null">code,</if>
            <if test="uuid != null">uuid,</if>
            <if test="demandUuid != null">demand_uuid,</if>
            <if test="jdrq != null">jdrq,</if>
            <if test="updateDate != null">update_date,</if>
            <if test="priceAll != null">price_all,</if>
            <if test="titleImg != null">title_img,</if>
            <if test="offerName != null">offer_name,</if>
            <if test="priceDetail != null">price_detail,</if>
            <if test="contractFile != null">contract_file,</if>
            <if test="priceDetailText != null">price_detail_text,</if>
            <if test="other != null">other,</if>
            <if test="orderNo != null">order_no,</if>
            <if test="score != null">score,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="code != null">#{code},</if>
            <if test="uuid != null">#{uuid},</if>
            <if test="demandUuid != null">#{demandUuid},</if>
            <if test="jdrq != null">#{jdrq},</if>
            <if test="updateDate != null">#{updateDate},</if>
            <if test="priceAll != null">#{priceAll},</if>
            <if test="titleImg != null">#{titleImg},</if>
            <if test="offerName != null">#{offerName},</if>
            <if test="priceDetail != null">#{priceDetail},</if>
            <if test="contractFile != null">#{contractFile},</if>
            <if test="priceDetailText != null">#{priceDetailText},</if>
            <if test="other != null">#{other},</if>
            <if test="orderNo != null">#{orderNo},</if>
            <if test="score != null">#{score},</if>
         </trim>
    </insert>

    <update id="updateBusSupplierRelease" parameterType="BusSupplierRelease">
        update bus_supplier_release
        <trim prefix="SET" suffixOverrides=",">
            <if test="code != null">code = #{code},</if>
            <if test="uuid != null">uuid = #{uuid},</if>
            <if test="demandUuid != null">demand_uuid = #{demandUuid},</if>
            <if test="jdrq != null">jdrq = #{jdrq},</if>
            <if test="updateDate != null">update_date = #{updateDate},</if>
            <if test="priceAll != null">price_all = #{priceAll},</if>
            <if test="titleImg != null">title_img = #{titleImg},</if>
            <if test="offerName != null">offer_name = #{offerName},</if>
            <if test="priceDetail != null">price_detail = #{priceDetail},</if>
            <if test="contractFile != null">contract_file = #{contractFile},</if>
            <if test="priceDetailText != null">price_detail_text = #{priceDetailText},</if>
            <if test="other != null">other = #{other},</if>
            <if test="orderNo != null">order_no = #{orderNo},</if>
            <if test="score != null">score = #{score},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBusSupplierReleaseById" parameterType="Long">
        delete from bus_supplier_release where id = #{id}
    </delete>

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

    <insert id="insertBusSupplierReleaseDiscard" parameterType="BusSupplierRelease">
        insert into bus_supplier_release_discard
        select code, uuid, demand_uuid, jdrq, update_date, price_all, title_img, offer_name, price_detail,
        contract_file, price_detail_text, other, order_no, score, score_content, score_label, public_is_no
        from bus_supplier_release where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </insert>
</mapper>
