<?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="adgroupZoneSqlMapper">
	<sql id="column">
		id,adgroup_id as adgroupId,zone_id as zoneId,status,supdated
	</sql>
	
	<!-- 插入 -->
	<insert id="addAdgroupZone" parameterType="com.cloudcross.ssp.model.AdgroupZone">
		insert into t_adgroup_zone (adgroup_id,zone_id,status,supdated)
		values (#{adgroupId},#{zoneId},#{status},#{supdated})
	</insert>
	
	<select id="queryZoneIdByAdgroupId" parameterType="java.lang.Long" resultType="java.lang.Long">
		select zone_id zoneId from t_adgroup_zone where status = 0 and adgroup_id = #{adgroupId}
	</select>
	
	<update id="updateAdgroupZoneByAdgroupId" parameterType="java.util.Map">
		update t_adgroup_zone set status = -1 and supdated = #{supdated} where adgroup_id = #{adgroupId} 
	</update>
	
	<!-- 批量插入 -->
	<insert id="addAdGroupZoneBatch" parameterType="java.util.Map">
		insert into t_adgroup_zone
		(adgroup_id,zone_id,status,supdated)
		values
		<foreach collection="zoneIdList" item="zoneId" index="index" separator=",">
			(#{adgroupZone.adgroupId},#{zoneId},#{adgroupZone.status},#{adgroupZone.supdated})
		</foreach>
	</insert>
</mapper>