<?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.abuwx.mapper.CardPasswordMapper">
    
    <resultMap type="CardPassword" id="CardPasswordResult">
        <result property="id"    column="id"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
        <result property="remark"    column="remark"    />
        <result property="couponNumber"    column="coupon_number"    />
        <result property="couponId"    column="coupon_id"    />
        <result property="couponTitle"    column="coupon_title"    />
        <result property="cardNumber"    column="card_number"    />
        <result property="cardPassword"    column="card_password"    />
        <result property="deleteTime"    column="delete_time"    />
        <result property="deleteFlag"    column="delete_flag"    />
        <result property="expirationDate"    column="expiration_date"    />
    </resultMap>

    <sql id="selectCardPasswordVo">
        select id, create_time, update_time, create_by, update_by, remark, coupon_number, coupon_id, coupon_title, card_number, card_password, delete_time, delete_flag, expiration_date from card_password
    </sql>

    <select id="selectCardPasswordList" parameterType="CardPassword" resultMap="CardPasswordResult">
        <include refid="selectCardPasswordVo"/>
        <where>  
            <if test="couponNumber != null  and couponNumber != ''"> and coupon_number = #{couponNumber}</if>
            <if test="couponId != null "> and coupon_id = #{couponId}</if>
            <if test="couponTitle != null  and couponTitle != ''"> and coupon_title = #{couponTitle}</if>
            <if test="cardNumber != null  and cardNumber != ''"> and card_number = #{cardNumber}</if>
            <if test="cardPassword != null  and cardPassword != ''"> and card_password = #{cardPassword}</if>
            <if test="deleteTime != null "> and delete_time = #{deleteTime}</if>
            <if test="deleteFlag != null  and deleteFlag != ''"> and delete_flag = #{deleteFlag}</if>
            <if test="expirationDate != null "> and expiration_date = #{expirationDate}</if>
        </where>
    </select>
    
    <select id="selectCardPasswordById" parameterType="Long" resultMap="CardPasswordResult">
        <include refid="selectCardPasswordVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertCardPassword" parameterType="CardPassword" useGeneratedKeys="true" keyProperty="id">
        insert into card_password
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="remark != null">remark,</if>
            <if test="couponNumber != null">coupon_number,</if>
            <if test="couponId != null">coupon_id,</if>
            <if test="couponTitle != null">coupon_title,</if>
            <if test="cardNumber != null">card_number,</if>
            <if test="cardPassword != null">card_password,</if>
            <if test="deleteTime != null">delete_time,</if>
            <if test="deleteFlag != null">delete_flag,</if>
            <if test="expirationDate != null">expiration_date,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="remark != null">#{remark},</if>
            <if test="couponNumber != null">#{couponNumber},</if>
            <if test="couponId != null">#{couponId},</if>
            <if test="couponTitle != null">#{couponTitle},</if>
            <if test="cardNumber != null">#{cardNumber},</if>
            <if test="cardPassword != null">#{cardPassword},</if>
            <if test="deleteTime != null">#{deleteTime},</if>
            <if test="deleteFlag != null">#{deleteFlag},</if>
            <if test="expirationDate != null">#{expirationDate},</if>
         </trim>
    </insert>

    <update id="updateCardPassword" parameterType="CardPassword">
        update card_password
        <trim prefix="SET" suffixOverrides=",">
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="couponNumber != null">coupon_number = #{couponNumber},</if>
            <if test="couponId != null">coupon_id = #{couponId},</if>
            <if test="couponTitle != null">coupon_title = #{couponTitle},</if>
            <if test="cardNumber != null">card_number = #{cardNumber},</if>
            <if test="cardPassword != null">card_password = #{cardPassword},</if>
            <if test="deleteTime != null">delete_time = #{deleteTime},</if>
            <if test="deleteFlag != null">delete_flag = #{deleteFlag},</if>
            <if test="expirationDate != null">expiration_date = #{expirationDate},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCardPasswordById" parameterType="Long">
        delete from card_password where id = #{id}
    </delete>

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