<?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.xueyi.system.organize.mapper.SysDeptExtMapper">

    <resultMap type="SysDeptExt" id="SysDeptExtResult">
        <result property="deptId"      column="dept_id"       />
        <result property="onDutyHourStart"      column="on_duty_hour_start"       />
        <result property="onDutyHourEnd"      column="on_duty_hour_end"       />
        <result property="offDutyHourStart"      column="off_duty_hour_start"       />
        <result property="offDutyHourEnd"      column="off_duty_hour_end"       />
    </resultMap>

    <select id="selectWorkTimeByDeptId" parameterType="java.lang.Long" resultMap="SysDeptExtResult">
        select dept_id, on_duty_hour_start, on_duty_hour_end, off_duty_hour_start, off_duty_hour_end from sys_dept_ext u
        where dept_id = #{deptId}
    </select>

    <insert id="insertWorkTimeByDeptId" parameterType="SysDeptExt">
        insert into sys_dept_ext (dept_id,on_duty_hour_start,on_duty_hour_end,off_duty_hour_start,off_duty_hour_end)
        values (#{deptId},#{onDutyHourStart},#{onDutyHourEnd},#{offDutyHourStart},#{offDutyHourEnd})
    </insert>

    <update id="updateWorkTimeByDeptId" parameterType="SysDeptExt">
        update sys_dept_ext
        <set>
            <if test="onDutyHourStart != null  ">on_duty_hour_start = #{onDutyHourStart},</if>
            <if test="onDutyHourEnd != null  ">on_duty_hour_end = #{onDutyHourEnd},</if>
            <if test="offDutyHourStart != null  ">off_duty_hour_start = #{offDutyHourStart},</if>
            <if test="offDutyHourEnd != null  ">off_duty_hour_end = #{offDutyHourEnd},</if>
        </set>
        where dept_id = #{deptId}
    </update>
</mapper>