<?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.ruoyi.dpc.mapper.DpcEmployeeMapper">

    <resultMap type="com.ruoyi.dpc.domain.vo.DpcEmployeeVO" id="DpcEmployeeVOResult">
        <id property="employeeId" column="employee_id"/>
        <result property="name" column="name"/>
        <result property="tellerNo" column="teller_no"/>
        <result property="orgNo" column="org_no"/>
        <result property="idCard" column="id_card"/>
        <result property="phone" column="phone"/>
        <result property="hireDate" column="hire_date"/>
        <result property="status" column="status"/>
        <result property="createTime" column="create_time"/>
        <collection property="relatives" ofType="com.ruoyi.dpc.domain.vo.DpcEmployeeRelativeVO">
            <id property="relativeId" column="relative_id"/>
            <result property="employeeId" column="employee_id"/>
            <result property="relativeName" column="relative_name"/>
            <result property="relativeIdCard" column="relative_id_card"/>
            <result property="relativePhone" column="relative_phone"/>
            <result property="relationship" column="relationship"/>
        </collection>
    </resultMap>

    <select id="selectEmployeeWithRelatives" parameterType="Long" resultMap="DpcEmployeeVOResult">
        SELECT
            e.employee_id, e.name, e.teller_no, e.org_no, e.id_card, e.phone, e.hire_date, e.status, e.create_time,
            r.relative_id, r.employee_id, r.relative_name, r.relative_id_card, r.relative_phone, r.relationship
        FROM dpc_employee e
        LEFT JOIN dpc_employee_relative r ON e.employee_id = r.employee_id
        WHERE e.employee_id = #{employeeId}
    </select>

</mapper>
