<?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.persagy.calendar.mapper.WorkCalendarObjectMapper">

	<resultMap id="BaseResultMap" type="com.persagy.calendar.pojo.dto.WorkCalendarObject">
		<result column="GROUP_CODE" property="groupCode" jdbcType="VARCHAR" />
		<result column="CALENDAR_ID" property="calendarId" jdbcType="VARCHAR" />
		<result column="PROJECT_ID" property="projectId" jdbcType="VARCHAR" />
		<result column="OBJECT_ID" property="objectId" jdbcType="VARCHAR" />
		<result column="CREATE_TIME" property="createTime" jdbcType="VARCHAR" />
		<result column="UPDATE_USER" property="updateUser" jdbcType="VARCHAR" />
	</resultMap>
	
	<insert id="batchInsertObjects">
		INSERT INTO work_calendar_object
		(
			GROUP_CODE, CALENDAR_ID, PROJECT_ID, OBJECT_ID, CREATE_TIME, UPDATE_USER
		) VALUES
		<foreach collection="objIds" index="index" item="objId" separator="," >
		(
			#{object.groupCode}, #{object.calendarId}, #{object.projectId}, #{objId}, #{object.createTime}, #{object.updateUser}
		)
		</foreach>
	</insert>
	
	<insert id="replaceCalendarObject">
		REPLACE INTO work_calendar_object
		(
			GROUP_CODE, CALENDAR_ID, PROJECT_ID, OBJECT_ID, CREATE_TIME, UPDATE_USER
		) VALUES
		<foreach collection="objIds" index="index" item="objId" separator="," >
		(
			#{calendarObject.groupCode}, #{calendarObject.calendarId}, #{calendarObject.projectId}, #{objId}, #{calendarObject.createTime}, #{calendarObject.updateUser}
		)
		</foreach>
	</insert>
	
</mapper>