<?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.crm.ucard.dao.mapper.UcardCardNumberMapper">

    <select id="countList" resultType="integer"
            parameterType="com.crm.rely.backend.core.entity.ucard.CardNumberPageEntity">
        SELECT COUNT(*) FROM ucard_card_number
        <where>
            <if test="cardNumber != null and cardNumber != ''">
                and `card_number` like concat('%',#{cardNumber},'%')
            </if>
            <if test="status != null and status > 0">
                and `status` = #{status}
            </if>
        </where>
    </select>

    <select id="pageList" resultType="com.crm.rely.backend.core.dto.ucard.CardNumberDto"
            parameterType="com.crm.rely.backend.core.entity.ucard.CardNumberPageEntity">
        SELECT
        `id`,
        card_number,
        `status`,
        add_time
        FROM ucard_card_number
        <where>
            <if test="cardNumber != null and cardNumber != ''">
                and `card_number` like concat('%',#{cardNumber},'%')
            </if>
            <if test="status != null and status > 0">
                and `status` = #{status}
            </if>
        </where>
        ORDER BY id DESC
        <if test="page != null">
            limit #{page.offset},#{page.row}
        </if>
    </select>

    <insert id="batchSave" parameterType="com.crm.rely.backend.core.pojo.table.ucard.UcardCardNumberTable">
        insert ignore into ucard_card_number(
        `card_number`,
        `status`,
        `add_time`
        )
        values
        <foreach collection="list" item="item" index="index" separator=",">
            (
            #{item.cardNumber},
            #{item.status},
            now()
            )
        </foreach>
    </insert>

</mapper> 