<?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.zehong.system.mapper.TEventHandleMapper">
    
    <resultMap type="TEventHandle" id="TEventHandleResult">
        <result property="handleId"    column="handle_id"    />
        <result property="eventId"    column="event_id"    />
        <result property="eventType"    column="event_type"    />
        <result property="enterpriseId"    column="enterprise_id"    />
        <result property="enterpriseName"    column="enterprise_name"    />
        <result property="management"    column="management"    />
        <result property="managementEvent"    column="management_event"    />
        <result property="planId"    column="plan_id"    />
        <result property="planTitle"    column="plan_title"    />
        <result property="planUrl"    column="plan_url"    />
        <result property="guidanceOpinion"    column="guidance_opinion"    />
        <result property="guidanceTime"    column="guidance_time"    />
        <result property="isDel"    column="is_del"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectTEventHandleVo">
        select handle_id, event_id,event_type, enterprise_id, enterprise_name, management,management_event, plan_id,plan_title,plan_url, guidance_opinion, guidance_time, is_del, create_time from t_event_handle
    </sql>

    <select id="selectTEventHandleList" parameterType="TEventHandle" resultMap="TEventHandleResult">
        <include refid="selectTEventHandleVo"/>
        <where>  
            <if test="eventId != null "> and event_id = #{eventId}</if>
            <if test="eventType != null "> and event_type = #{eventType}</if>
        </where>
    </select>
    
    <select id="selectTEventHandleById" parameterType="Long" resultMap="TEventHandleResult">
        <include refid="selectTEventHandleVo"/>
        where handle_id = #{handleId}
    </select>
        
    <insert id="insertTEventHandle" parameterType="TEventHandle" useGeneratedKeys="true" keyProperty="handleId">
        insert into t_event_handle
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="eventId != null">event_id,</if>
            <if test="eventType != null">event_type,</if>
            <if test="enterpriseId != null">enterprise_id,</if>
            <if test="enterpriseName != null">enterprise_name,</if>
            <if test="management != null">management,</if>
            <if test="managementEvent != null">management_event,</if>
            <if test="planId != null">plan_id,</if>
            <if test="planTitle != null">plan_title,</if>
            <if test="planUrl != null">plan_url,</if>
            <if test="guidanceOpinion != null">guidance_opinion,</if>
            <if test="guidanceTime != null">guidance_time,</if>
            <if test="isDel != null">is_del,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="eventId != null">#{eventId},</if>
            <if test="eventType != null">#{eventType},</if>
            <if test="enterpriseId != null">#{enterpriseId},</if>
            <if test="enterpriseName != null">#{enterpriseName},</if>
            <if test="management != null">#{management},</if>
            <if test="managementEvent != null">#{managementEvent},</if>
            <if test="planId != null">#{planId},</if>
            <if test="planTitle != null">#{planTitle},</if>
            <if test="planUrl != null">#{planUrl},</if>
            <if test="guidanceOpinion != null">#{guidanceOpinion},</if>
            <if test="guidanceTime != null">#{guidanceTime},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateTEventHandle" parameterType="TEventHandle">
        update t_event_handle
        <trim prefix="SET" suffixOverrides=",">
            <if test="eventId != null">event_id = #{eventId},</if>
            <if test="eventType != null">event_type = #{eventType},</if>
            <if test="enterpriseId != null">enterprise_id = #{enterpriseId},</if>
            <if test="enterpriseName != null">enterprise_name = #{enterpriseName},</if>
            <if test="management != null">management = #{management},</if>
            <if test="managementEvent != null">management_event = #{managementEvent},</if>
            <if test="planId != null">plan_id = #{planId},</if>
            <if test="planTitle != null">plan_title = #{planTitle},</if>
            <if test="planUrl != null">plan_url = #{planUrl},</if>
            <if test="guidanceOpinion != null">guidance_opinion = #{guidanceOpinion},</if>
            <if test="guidanceTime != null">guidance_time = #{guidanceTime},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where handle_id = #{handleId}
    </update>

    <delete id="deleteTEventHandleById" parameterType="Long">
        delete from t_event_handle where handle_id = #{handleId}
    </delete>

    <delete id="deleteTEventHandleByIds" parameterType="String">
        delete from t_event_handle where handle_id in 
        <foreach item="handleId" collection="array" open="(" separator="," close=")">
            #{handleId}
        </foreach>
    </delete>
</mapper>