<?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="aclsSqlMapper">
	<sql id="base_column">
		banner_id as bannerId,
		logical ,
		type,
		comparison,
		data,
		executionorder as executionOrder,
		adgroup_id as adGroupId
	</sql>
	<insert id="addAcls" parameterType="com.cloudcross.ssp.model.Acls">
		insert into  	t_acls(banner_id,logical,type,comparison,data,<if test="null!=executionOrder" >executionorder,</if>adgroup_id)
		values (#{bannerId},#{logical},#{type},#{comparison},#{data},<if test="null!=executionOrder" >#{executionOrder},</if>#{adGroupId})
	</insert>
	<update id="editAcls" parameterType="com.cloudcross.ssp.model.Acls">
		update t_acls
		set logical=
		#{logical},comparison = #{comparison},data=#{data}
		where type=#{type} and adgroup_id=#{adGroupId}
	</update>
	
	<select id="findById" parameterType="long"  resultType="com.cloudcross.ssp.model.Acls">
		select  <include refid="base_column"/>  from t_acls  where  banner_id  =  #{bannerId}
	</select>
	
	<delete id="deleteAcls" parameterType="long">
		delete from t_acls where  banner_id = #{id} 
	</delete>
	
	<delete id="deleteAclsBatch" parameterType="map">
			delete from t_acls where  type=#{type} and banner_id in
				<foreach item="id" collection="idList" open="("  separator="," close=")">
				#{id}
				</foreach>
	</delete>
	
	<insert  id="addAclsBatch" parameterType="map">
	    insert into t_acls  (banner_id,logical,type,comparison,data,
						<if test="null!=acls.executionOrder" >executionorder,</if>adgroup_id)
          values    <foreach collection="idList" item="item" index="index" separator=",">
    					(#{item},#{acls.logical},#{acls.type},#{acls.comparison},#{acls.data},
    					<if test="null!=acls.executionOrder" >#{acls.executionOrder},</if>#{adGroupId})
    			    </foreach> 
	</insert>
</mapper>