<?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.sooka.system.mapper.TempPerUserMapper">

    <resultMap type="TempPerUser" id="TempPerUserResult">
        <result property="deptId"     column="dept_id"     />
        <result property="deptName"   column="dept_name"   />
        <collection  property="users"   javaType="java.util.List"        resultMap="UserResult" />
    </resultMap>

    <resultMap id="UserResult" type="SysUser">
        <id     property="userId"       column="user_id"      />
        <result property="deptId"       column="dept_id"      />
        <result property="loginName"    column="login_name"   />
        <result property="userName"     column="user_name"    />
        <result property="userType"     column="user_type"    />
        <result property="email"        column="email"        />
        <result property="phonenumber"  column="phonenumber"  />
        <result property="sex"          column="sex"          />
        <result property="avatar"       column="avatar"       />
        <result property="password"     column="password"     />
        <result property="salt"         column="salt"         />
        <result property="status"       column="status"       />
        <result property="delFlag"      column="del_flag"     />
        <result property="loginIp"      column="login_ip"     />
        <result property="loginDate"    column="login_date"   />
        <result property="createBy"     column="create_by"    />
        <result property="createTime"   column="create_time"  />
        <result property="updateBy"     column="update_by"    />
        <result property="updateTime"   column="update_time"  />
        <result property="remark"       column="remark"       />
    </resultMap>

    <select id="listUser" resultMap="TempPerUserResult">
        SELECT
            d.dept_id,
            d.dept_name,
            u.user_id,
            u.user_name
        FROM
            sys_dept d
        LEFT JOIN sys_user u ON d.dept_id = u.dept_id
        WHERE
            user_id != ""
    </select>



</mapper>
