<?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.voluntary.mapper.BusiCardsOpenDetailMapper">
    
    <resultMap type="BusiCardsOpenDetail" id="BusiCardsOpenDetailResult">
        <result property="id"    column="id"    />
        <result property="openId"    column="open_id"    />
        <result property="cardNo"    column="card_no"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectBusiCardsOpenDetailVo">
        select id, open_id, card_no, create_time from b_busi_cards_open_detail
    </sql>

    <select id="selectBusiCardsOpenDetailList" parameterType="BusiCardsOpenDetail" resultMap="BusiCardsOpenDetailResult">
        <include refid="selectBusiCardsOpenDetailVo"/>
        <where>  
            <if test="openId != null "> and open_id = #{openId}</if>
            <if test="cardNo != null  and cardNo != ''"> and card_no = #{cardNo}</if>
        </where>
    </select>
    
    <select id="selectBusiCardsOpenDetailById" parameterType="Long" resultMap="BusiCardsOpenDetailResult">
        <include refid="selectBusiCardsOpenDetailVo"/>
        where id = #{id}
    </select>

    <insert id="insertBatch" useGeneratedKeys="true" keyProperty="id" parameterType="java.util.List">
        INSERT INTO b_busi_cards_open_detail
        (open_id, card_no, create_time)
        VALUES
        <foreach collection ="list" item="detail" separator =",">
            (#{detail.openId}, #{detail.cardNo}, #{detail.createTime})
        </foreach >
    </insert>
        
    <insert id="insertBusiCardsOpenDetail" parameterType="BusiCardsOpenDetail" useGeneratedKeys="true" keyProperty="id">
        insert into b_busi_cards_open_detail
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="openId != null">open_id,</if>
            <if test="cardNo != null">card_no,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="openId != null">#{openId},</if>
            <if test="cardNo != null">#{cardNo},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateBusiCardsOpenDetail" parameterType="BusiCardsOpenDetail">
        update b_busi_cards_open_detail
        <trim prefix="SET" suffixOverrides=",">
            <if test="openId != null">open_id = #{openId},</if>
            <if test="cardNo != null">card_no = #{cardNo},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteBusiCardsOpenDetailById" parameterType="Long">
        delete from b_busi_cards_open_detail where id = #{id}
    </delete>

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