<?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="cn.iocoder.yudao.module.partner.mapper.PartnerBankInfoMapper">

    <resultMap type="cn.iocoder.yudao.module.partner.entity.PartnerBankInfo" id="PartnerBankInfoResult">
        <result property="id"    column="id"    />
        <result property="partnerId"    column="partner_id"    />
        <result property="bankCardNum"    column="bank_card_num"    />
        <result property="bankName"    column="bank_name"    />
    </resultMap>

    <sql id="selectPartnerBankInfoVo">
        select id, partner_id, bank_card_num, bank_name from partner_bank_info
    </sql>

    <select id="selectPartnerBankInfoList" parameterType="cn.iocoder.yudao.module.partner.entity.PartnerBankInfo" resultMap="PartnerBankInfoResult">
        <include refid="selectPartnerBankInfoVo"/>
        <where>
            <if test="partnerId != null "> and partner_id = #{partnerId}</if>
            <if test="bankCardNum != null  and bankCardNum != ''"> and bank_card_num = #{bankCardNum}</if>
            <if test="bankName != null  and bankName != ''"> and bank_name like concat('%', #{bankName}, '%')</if>
        </where>
    </select>

    <select id="selectPartnerBankInfoById" parameterType="Long" resultMap="PartnerBankInfoResult">
        <include refid="selectPartnerBankInfoVo"/>
        where id = #{id}
    </select>

    <insert id="insertPartnerBankInfo" parameterType="cn.iocoder.yudao.module.partner.entity.PartnerBankInfo">
        insert into partner_bank_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="partnerId != null">partner_id,</if>
            <if test="bankCardNum != null">bank_card_num,</if>
            <if test="bankName != null">bank_name,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="partnerId != null">#{partnerId},</if>
            <if test="bankCardNum != null">#{bankCardNum},</if>
            <if test="bankName != null">#{bankName},</if>
         </trim>
    </insert>

    <update id="updatePartnerBankInfo" parameterType="cn.iocoder.yudao.module.partner.entity.PartnerBankInfo">
        update partner_bank_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="partnerId != null">partner_id = #{partnerId},</if>
            <if test="bankCardNum != null">bank_card_num = #{bankCardNum},</if>
            <if test="bankName != null">bank_name = #{bankName},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePartnerBankInfoById" parameterType="Long">
        delete from partner_bank_info where id = #{id}
    </delete>

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