<?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.willalp.clockingin.mapper.HsPnsClockingInMapper">

    <resultMap type="com.willalp.clockingin.domain.HsPnsClockingIn" id="HsPnsClockingInResult">
        <result property="clockingInId" column="clocking_in_id"/>
        <result property="userNo" column="user_no"/>
        <result property="orgNo" column="org_no"/>
        <result property="userName" column="user_name"/>
        <result property="todayTime" column="today_time"/>
        <result property="week" column="week"/>
        <result property="shiftId" column="shift_id"/>
        <result property="dutyClockTime" column="duty_clock_time"/>
        <result property="offDutyClockTime" column="off_duty_clock_time"/>
        <result property="clockingInType" column="clocking_in_type"/>
        <result property="belateTimeNum" column="belate_time_num"/>
        <result property="remark" column="remark"/>
        <result property="isDelete" column="is_delete"/>
        <result property="createBy" column="create_by"/>
        <result property="createTime" column="create_time"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <resultMap id="HsPnsClockingInHsPnsShiftResult" type="HsPnsClockingIn" extends="HsPnsClockingInResult">
        <collection property="hsPnsShiftList" notNullColumn="sub_shift_id"
                    javaType="java.util.List" resultMap="HsPnsShiftResult"/>
    </resultMap>

    <resultMap type="HsPnsShift" id="HsPnsShiftResult">
        <result property="shiftId" column="sub_shift_id"/>
        <result property="shiftName" column="sub_shift_name"/>
        <result property="shiftType" column="sub_shift_type"/>
        <result property="dutyTime" column="sub_duty_time"/>
        <result property="offDutyTime" column="sub_off_duty_time"/>
        <result property="remark" column="sub_remark"/>
        <result property="isDelete" column="sub_is_delete"/>
        <result property="createBy" column="sub_create_by"/>
        <result property="createTime" column="sub_create_time"/>
        <result property="updateBy" column="sub_update_by"/>
        <result property="updateTime" column="sub_update_time"/>
    </resultMap>

    <sql id="selectHsPnsClockingInVo">
        select clocking_in_id,
               user_no,
               org_no,
               user_name,
               today_time,
               week,
               shift_id,
               duty_clock_time,
               off_duty_clock_time,
               clocking_in_type,
               belate_time_num,
               remark,
               is_delete,
               create_by,
               create_time,
               update_by,
               update_time
        from hs_pns_clocking_in
    </sql>

    <select id="selectHsPnsClockingInList" resultMap="HsPnsClockingInResult">
        <include refid="selectHsPnsClockingInVo"/>
        <where>
            is_delete = 0
            <if test="userNo != null  and userNo != ''">
                  and user_no like concat('%', #{userNo}, '%')
            </if>
            <if test="userName != null  and userName != ''">
                  and
                        user_name
                        like
                        concat('%',
                               #{userName},
                               '%')
            </if>
            <if test="todayTime != null  and todayTime != ''">
                  and today_time like concat('%', #{todayTime}, '%')
            </if>
            <if test="week != null  and week != ''">
                  and week = #{week}
            </if>
            <if test="shiftId != null  and shiftId != ''">
                  and shift_id = #{shiftId}
            </if>
            <if test="dutyClockTime != null ">
                  and duty_clock_time = #{dutyClockTime}
            </if>
            <if test="offDutyClockTime != null ">
                  and off_duty_clock_time = #{offDutyClockTime}
            </if>
            <if test="clockingInType != null  and clockingInType != ''">
                  and clocking_in_type = #{clockingInType}
            </if>
            <if test="belateTimeNum != null  and belateTimeNum != ''">
                  and belate_time_num = #{belateTimeNum}
            </if>
        </where>
    </select>
</mapper>
