<?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.manager.dao.mapper.SysCountryGroupTypeMapper">

    <select id="countList" resultType="integer"
            parameterType="com.crm.rely.backend.core.entity.system.country.group.type.SysCountryGroupTypeSearchListEntity">

        select count(*) from sys_county_group_type
        <where>
            <if test="country!=null">
                and country=#{country}
            </if>
            <if test="groupType!=null">
                and group_type=#{groupType}
            </if>
            <if test="startDate != null">
                and add_time <![CDATA[>=]]>#{startDate}
            </if>
            <if test="endDate != null">
                and add_time <![CDATA[<=]]>#{endDate}
            </if>
        </where>
    </select>

    <select id="pageList" resultType="com.crm.rely.backend.core.pojo.table.SysCountryGroupTypeTable"
            parameterType="com.crm.rely.backend.core.entity.system.country.group.type.SysCountryGroupTypeSearchListEntity">
        select * from sys_county_group_type
        <where>
            <if test="country!=null">
                and country=#{country}
            </if>
            <if test="groupType!=null">
                and group_type=#{groupType}
            </if>
            <if test="startDate != null">
                and add_time <![CDATA[>=]]>#{startDate}
            </if>
            <if test="endDate != null">
                and add_time <![CDATA[<=]]>#{endDate}
            </if>
        </where>
        order by add_time desc
        <if test="page!=null">
            limit #{page.offset},#{page.row}
        </if>

    </select>


</mapper>