<?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="cn.cecep.talroad.mapper.PcFactoryPollutantMapper">

    <resultMap type="cn.cecep.talroad.domain.PcFactoryPollutant" id="PcFactoryPollutantResult">
        <result property="id"    column="id"    />
        <result property="factoryId"    column="factory_id"    />
        <result property="outletId"    column="outlet_id"    />
        <result property="pollutantId"    column="pollutant_id"    />
    </resultMap>


    <sql id="selectPcFactoryPollutantVo">
        select id, factory_id, outlet_id, pollutant_id from pc_factory_pollutant
    </sql>

    <select id="selectPcFactoryPollutantList" parameterType="cn.cecep.talroad.domain.PcFactoryPollutant" resultMap="PcFactoryPollutantResult">
        <include refid="selectPcFactoryPollutantVo"/>
        <where>
            <if test="factoryId != null  and factoryId != ''"> and factory_id = #{factoryId}</if>
            <if test="outletId != null  and outletId != ''"> and outlet_id = #{outletId}</if>
            <if test="pollutantId != null  and pollutantId != ''"> and pollutant_id = #{pollutantId}</if>
        </where>
    </select>

    <insert id="batchUpdateValue">
        INSERT INTO public.pc_factory_pollutant (id,factory_id,outlet_id,pollutant_id,is_status) VALUES
        <foreach collection="addList" separator="," item="item">
            (#{item.id}, #{item.factoryId}, #{item.outletId}, #{item.pollutantId}, #{item.isStatus})
        </foreach>
    </insert>
</mapper>
