<?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.CardPermissionMapper">

    <select id="countList" resultType="integer"
            parameterType="com.crm.rely.backend.core.entity.ucard.CardPermissionPageEntity">
        SELECT COUNT(*)
        from ucard_permission
        <where>
            <if test="cIdRegexp != null and cIdRegexp != ''">
                and c_id_regexp like concat(#{cIdRegexp},'%')
            </if>
            <if test="emailRegexp != null and emailRegexp != ''">
                and email_regexp like concat(#{emailRegexp},'%')
            </if>
            <if test="phoneRegexp != null and phoneRegexp != ''">
                and phone_regexp like concat(#{phoneRegexp},'%')
            </if>
            <if test="countryCode != null and countryCode != ''">
                and country_Codes like concat('%',#{countryCode},'%')
            </if>
            <if test="enableStatus != null">
                and enable_status = #{enableStatus}
            </if>
        </where>
    </select>

    <select id="pageList" resultType="com.crm.rely.backend.core.dto.ucard.CardPermissionDto"
            parameterType="com.crm.rely.backend.core.entity.ucard.CardPermissionPageEntity">
        select *
        from ucard_permission
        <where>
            <if test="cIdRegexp != null and cIdRegexp != ''">
                and c_id_regexp like concat(#{cIdRegexp},'%')
            </if>
            <if test="emailRegexp != null and emailRegexp != ''">
                and email_regexp like concat(#{emailRegexp},'%')
            </if>
            <if test="phoneRegexp != null and phoneRegexp != ''">
                and phone_regexp like concat(#{phoneRegexp},'%')
            </if>
            <if test="countryCode != null and countryCode != ''">
                and country_Codes like concat('%',#{countryCode},'%')
            </if>
            <if test="enableStatus != null">
                and enable_status = #{enableStatus}
            </if>
        </where>
        order by id desc
        limit #{page.offset},#{page.row}
    </select>

</mapper>