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

  <resultMap id="attendanceLogsMap" type="com.elephant.framework.galaxy.aroad.module.attendance.entity.AttendanceLogs">
        <id property="logId" column="log_id"/>
        <result property="dutyPerson" column="duty_person"/>
        <result property="attendanceShift" column="attendance_shift"/>
        <result property="attendanceDate" column="attendance_date"/>
        <result property="content" column="content"/>
        <result property="writePerson" column="write_person"/>
        <result property="writeTime" column="write_time"/>
  </resultMap>

  <select id="getAttendanceLogsPage" resultType="com.elephant.framework.galaxy.aroad.module.attendance.dto.AttendanceLogDto">
    select
      log_id,duty_person,attendance_shift,attendance_date,write_person,write_time,l.dept_id,write_id,
      CONCAT(LEFT(LTRIM(content),20),'......') as profileContent ,content,
      d.name as dept_name
    from
      attendance_logs l
    inner join
      sys_dept d
    on l.dept_id = d.dept_id
      <if test="deptId != null">
          <where>
              l.dept_id = #{deptId}
          </where>
      </if>
  </select>
</mapper>
