<?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="jnpf.attendance.mapper.DailyRuleChangeMapper" >

    <!-- 批量保存变更 -->
    <insert id="saveRecordBatch">
        INSERT INTO ftb_attendance_daily_rule_change (F_Id, F_GroupId, F_UserId, F_Day, F_TenantId)
        VALUES
        <foreach collection="list" item="item" separator=",">
            (#{item.id}, #{item.groupId}, #{item.userId}, #{item.day}, #{item.tenantId})
        </foreach>
        ON DUPLICATE KEY UPDATE
        F_LastModifyTime = NOW()
    </insert>
    <!-- 删除小于当前时间的记录 -->
    <delete id="removeBatch">
        DELETE FROM ftb_attendance_daily_rule_change
        WHERE (
        <foreach collection="list" item="item" separator=" OR ">
            (F_GroupId = #{item.groupId} AND F_UserId = #{item.userId} AND F_Day = #{item.day} AND F_LastModifyTime &lt; #{day})
        </foreach>
        )
    </delete>
</mapper>