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

    <select id="countSearch" parameterType="com.crm.rely.backend.core.entity.sys.SysSalesLoginSearchListEntity" resultType="Integer">
        select count(sl.id)
        from sys_sales_login sl
        <include refid="whereSql"></include>
    </select>

    <select id="listSearch" parameterType="com.crm.rely.backend.core.entity.sys.SysSalesLoginSearchListEntity" resultType="com.crm.rely.backend.core.pojo.table.SysSalesLoginTable">
        select sl.*
        from sys_sales_login sl
        <include refid="whereSql"></include>
        order by sl.add_time desc
        <if test="page != null">
            limit #{page.offset},#{page.row}
        </if>
    </select>


    <sql id="whereSql">
        <where>
            <if test="ibNo != null and ibNo != ''">
                and sl.ib_no like concat('%',#{ibNo},'%')
            </if>
            <if test="login != null and login > 0 ">
                and sl.login = #{login}
            </if>
        </where>
    </sql>
</mapper>