<?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.AttendanceTemplatesMapper">

  <resultMap id="attendanceTemplatesMap" type="com.elephant.framework.galaxy.aroad.module.attendance.entity.AttendanceTemplates">
        <id property="shiftId" column="shift_id"/>
        <result property="shiftName" column="shift_name"/>
        <result property="startTime" column="start_time"/>
        <result property="endTime" column="end_time"/>
        <result property="shiftType" column="shift_type"/>
        <result property="attendanceType" column="attendance_type"/>
        <result property="isCrossDay" column="is_cross_day"/>
        <result property="position" column="position"/>
        <result property="remark" column="remark"/>
        <result property="isDel" column="is_del"/>
  </resultMap>

  <select id="getShiftSelection" resultMap="attendanceTemplatesMap">
        select
          shift_name,shift_id
        from
          attendance_templates
        where
          unit_id = #{unitId}
        and
          is_del=0
  </select>


  <select id="getShiftPage" resultType="com.elephant.framework.galaxy.aroad.module.attendance.dto.AttendanceTemplateDto">
    select t.*,d.name as dept_name from attendance_templates t inner join sys_dept d
    on t.unit_id = d.dept_id
    where t.unit_id = #{unitId}
    and is_del=0
  </select>

  <update id="delTemplate">
      update attendance_templates set is_del=1
      where  shift_id=#{shiftId}
  </update>
</mapper>
