<?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.BEnterpriseIrBusinessAlertsMapper">

    <resultMap type="cn.cecep.talroad.domain.BEnterpriseIrBusinessAlerts" id="BEnterpriseIrBusinessAlertsResult">
        <result property="businessId"    column="business_id"    />
        <result property="factoryId"    column="factory_id"    />
        <result property="businessType"    column="business_type"    />
        <result property="businessTitle"    column="business_title"    />
        <result property="businessDetails"    column="business_details"    />
        <result property="businessTime"    column="business_time"    />
        <result property="status"    column="status"    />
    </resultMap>


    <sql id="selectBEnterpriseIrBusinessAlertsVo">
        select business_id, factory_id, business_type, business_title, business_details, business_time, status from b_enterprise_ir_business_alerts
    </sql>

    <select id="selectBEnterpriseIrBusinessAlertsList" parameterType="cn.cecep.talroad.domain.BEnterpriseIrBusinessAlerts" resultMap="BEnterpriseIrBusinessAlertsResult">
        <include refid="selectBEnterpriseIrBusinessAlertsVo"/>
        <where>
            <if test="factoryId != null  and factoryId != ''"> and factory_id = #{factoryId}</if>
            <if test="businessType != null  and businessType != ''"> and business_type = #{businessType}</if>
            <if test="businessDetails != null  and businessDetails != ''"> and business_details = #{businessDetails}</if>
            <if test="businessTime != null  and businessTime != ''"> and business_time = #{businessTime}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
    </select>

    <select id="selectOptions" resultType="java.util.Map">
        SELECT
        business_type AS label,
        business_type AS value
        FROM
        b_enterprise_ir_business_alerts
        WHERE
        factory_id = #{factoryId}
        AND del_flag = '0'
        GROUP BY
        business_type
    </select>

    <insert id="insertBatch">
        INSERT INTO b_enterprise_ir_business_alerts (factory_id,business_type,business_details,business_time,create_time) VALUES
        <foreach collection="addList" separator="," item="item">
            (#{item.factoryId}, #{item.businessType}, #{item.businessDetails}, #{item.businessTime}, #{item.createTime})
        </foreach>
    </insert>
</mapper>
