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

    <select id="countList" resultType="integer"
            parameterType="com.crm.rely.backend.core.entity.system.source.SysSourceSearchPageEntity">

        select count(*)
        from sys_source
        <where>
            <if test="name != null and name != ''">
                and `name`=#{name}
            </if>
            <if test="nameEn != null and nameEn != ''">
                and `name_en`=#{nameEn}
            </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.SysSourceTable"
            parameterType="com.crm.rely.backend.core.entity.system.source.SysSourceSearchPageEntity">

        select * from sys_source
        <where>
            <if test="name != null and name != ''">
                and `name`=#{name}
            </if>
            <if test="nameEn != null and nameEn != ''">
                and `name_en`=#{nameEn}
            </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>