<?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.oa.mapper.CmcBrandPaymentMapper">
    
    <resultMap type="CmcBrandPayment" id="CmcBrandPaymentResult">
        <result property="brandPaymentId"    column="brand_payment_id"    />
        <result property="brandId"    column="brand_id"    />
        <result property="paymentTime"    column="payment_time"    />
        <result property="cwComment"    column="cw_comment"    />
    </resultMap>

    <sql id="selectCmcBrandPaymentVo">
        select brand_payment_id, brand_id, payment_time, cw_comment from cmc_brand_payment
    </sql>

    <select id="selectCmcBrandPaymentList" parameterType="CmcBrandPayment" resultMap="CmcBrandPaymentResult">
        <include refid="selectCmcBrandPaymentVo"/>
        <where>  
            <if test="brandId != null  and brandId != ''"> and brand_id = #{brandId}</if>
            <if test="paymentTime != null "> and payment_time = #{paymentTime}</if>
            <if test="cwComment != null  and cwComment != ''"> and cw_comment = #{cwComment}</if>
        </where>
    </select>
    
    <select id="selectCmcBrandPaymentByBrandId" parameterType="String" resultMap="CmcBrandPaymentResult">
        <include refid="selectCmcBrandPaymentVo"/>
        where brand_id = #{brandId}
    </select>
        
    <insert id="insertCmcBrandPayment" parameterType="CmcBrandPayment">
        insert into cmc_brand_payment
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="brandPaymentId != null">brand_payment_id,</if>
            <if test="brandId != null">brand_id,</if>
            <if test="paymentTime != null">payment_time,</if>
            <if test="cwComment != null">cw_comment,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="brandPaymentId != null">#{brandPaymentId},</if>
            <if test="brandId != null">#{brandId},</if>
            <if test="paymentTime != null">#{paymentTime},</if>
            <if test="cwComment != null">#{cwComment},</if>
         </trim>
    </insert>

    <update id="updateCmcBrandPayment" parameterType="CmcBrandPayment">
        update cmc_brand_payment
        <trim prefix="SET" suffixOverrides=",">
            <if test="brandId != null">brand_id = #{brandId},</if>
            <if test="paymentTime != null">payment_time = #{paymentTime},</if>
            <if test="cwComment != null">cw_comment = #{cwComment},</if>
        </trim>
        where brand_payment_id = #{brandPaymentId}
    </update>

    <delete id="deleteCmcBrandPaymentByBrandId" parameterType="String">
        delete from cmc_brand_payment where brand_id = #{brandId}
    </delete>

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