<?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.elephant.framework.galaxy.aroad.module.attendance.mapper.AttendanceMembersMapper">

  <resultMap id="attendanceMembersMap" type="com.elephant.framework.galaxy.aroad.module.attendance.entity.AttendanceMembers">
        <id property="id" column="id"/>
        <result property="attendanceId" column="attendance_id"/>
        <result property="name" column="name"/>
  </resultMap>

  <resultMap id="memberDtoMap" type="com.elephant.framework.galaxy.aroad.module.attendance.dto.MemberDto">
      <id property="id" column="id"/>
      <result property="name" column="name"/>
      <result property="phone" column="phone"/>
      <result property="shiftName" column="shift_name"/>
      <result property="date" column="time"/>
      <result property="startTime" column="start_time"/>
      <result property="endTime" column="end_time"/>
  </resultMap>

  <select id="getMembers" resultMap="memberDtoMap">
      SELECT
        a.time,
        t.shift_name,t.start_time,t.end_time,t.is_cross_day,
        m.id,m.name,m.phone
      FROM `attendance` a
      INNER JOIN attendance_templates  t
      ON a.shift_id = t.shift_id
      INNER JOIN attendance_members m
      ON a.attendance_id = m.attendance_id
      WHERE a.attendance_id = #{attendanceId}
  </select>

</mapper>

