<?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.custom.dao.mapper.CustomInfoDao">

    <delete id="deleteInBatch" parameterType="com.crm.rely.backend.core.entity.base.LongEntitys">
        delete from custom_info
        where id in
        <foreach collection="ids" index="idx" item="item" separator="," open="(" close=")">
            #{item}
        </foreach>
    </delete>

    <select id="countBelongs"
            parameterType="com.crm.rely.backend.model.entity.custom.info.CustomBelongsListEntity"
            resultType="Integer">
        select count(*)
        from custom_info
        where agent_id = #{agentId}
    </select>

    <select id="listBelongs"
            parameterType="com.crm.rely.backend.model.entity.custom.info.CustomBelongsListEntity"
            resultType="com.crm.rely.backend.model.pojo.view.CustomInfoView">
        select *
        from custom_info
        where agent_id=#{agentId}
        <if test="page!=null">
            limit #{page.offset},#{page.row}
        </if>
    </select>
    <select id="countRecommend"
            parameterType="com.crm.rely.backend.model.entity.custom.CustomInfoListEntity"
            resultType="Integer">
        select count(*)
        from custom_info
        where agent_id=#{agentId}
        and `status`=2
        <if test="startDate != null">
            and custom_login.add_time <![CDATA[ >= ]]> #{startDate}
        </if>
        <if test="endDate != null">
            and custom_login.add_time <![CDATA[ < ]]> #{endDate}
        </if>
    </select>
    <select id="getPageRecommend"
            parameterType="com.crm.rely.backend.model.entity.custom.CustomInfoListEntity"
            resultType="com.crm.rely.backend.model.pojo.view.CustomInfoView">
        select *
        from custom_info
        where agent_id=#{agentId}
        and `status`=2
        <if test="startDate != null">
            and custom_login.add_time <![CDATA[ >= ]]> #{startDate}
        </if>
        <if test="endDate != null">
            and custom_login.add_time <![CDATA[ < ]]> #{endDate}
        </if>
        <if test="page!=null">
            limit #{page.offset},#{page.row}
        </if>
    </select>
</mapper>