<?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.SysLoginTypeMapper">
    <select id="countList" resultType="integer"
            parameterType="com.crm.rely.backend.core.entity.system.logintype.SysLoginTypeSearchEntity">
        select count(*) from sys_login_type
        <where>
            <if test="comPoint!=null">
                and `com_point` = #{comPoint}
            </if>
            <if test="hide!=null">
                and `hide` = #{hide}
            </if>
            <if test="loginTypes != null and loginTypes.size() > 0">
                AND (
                <foreach collection="loginTypes" index="idx" item="item" separator="and" open="" close="">
                    FIND_IN_SET(#{item}, login_types)
                </foreach>
                )
            </if>
        </where>
    </select>

    <select id="pageList" resultType="com.crm.rely.backend.core.pojo.table.SysLoginTypeTable"
            parameterType="com.crm.rely.backend.core.entity.system.logintype.SysLoginTypeSearchEntity">
        select * from sys_login_type
        <where>
            <if test="comPoint!=null">
                and `com_point` = #{comPoint}
            </if>
            <if test="hide!=null">
                and `hide` = #{hide}
            </if>
            <if test="loginTypes != null and loginTypes.size() > 0">
                AND (
                <foreach collection="loginTypes" index="idx" item="item" separator="and" open="" close="">
                    FIND_IN_SET(#{item}, login_types)
                </foreach>
                )
            </if>
        </where>
        order by id desc
        limit #{page.offset},#{page.row}
    </select>
</mapper>