<?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.njcn.user.mapper.UserMapper">
    <select id="selectDeptsId" resultType="User">
        select sys_user.*
        from sys_user sys_user
        where sys_user.Dept_Id in
        <foreach item="item" index="index" collection="ids" open="("
                 separator="," close=")">
            #{item}
        </foreach>
        and sys_user.state =#{state}
    </select>

    <select id="page" resultType="UserVO">
        SELECT
        sys_user.* ,
        sys_dept.name deptName
        FROM
        sys_user sys_user LEFT JOIN
        sys_dept sys_dept
        ON sys_user.Dept_Id = sys_dept.Id
        <where>
            <if test="state != -1">
                sys_user.State = #{state}
            </if>
            <if test="type != -1">
                and sys_user.Casual_User = #{type}
            </if>
            and ${ew.sqlSegment}
        </where>


    </select>

    <select id="checkPage" resultType="UserVO">
        SELECT
        sys_user.* ,
        sys_dept.name deptId
        FROM
        sys_user sys_user LEFT JOIN
        sys_dept sys_dept
        ON sys_user.Dept_Id = sys_dept.Id
        <where>
            and ${ew.sqlSegment}
        </where>
    </select>

    <select id="queryExportUser" resultType="UserExcel">
        SELECT
               sys_user.id,
               sys_user.name,
               sys_user.login_name    loginName,
               sys_user.phone,
               sys_user.Register_Time registerTime,
               sys_user.Login_Time    loginTime,
               sys_user.Casual_User   casualUser,
               sys_user.State         state,
               sys_dept.name          deptName
        FROM sys_user sys_user
                 LEFT JOIN
             sys_dept sys_dept
             ON sys_user.Dept_Id = sys_dept.Id
        Where ${ew.sqlSegment}
    </select>



</mapper>
