<?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.TEventInfoMapper">
    
    <resultMap type="TEventInfo" id="TEventInfoResult">
        <result property="eventId"    column="event_id"    />
        <result property="eventTitle"    column="event_title"    />
        <result property="eventType"    column="event_type"    />
        <result property="eventLevel"    column="event_level"    />
        <result property="eventLocation"    column="event_location"    />
        <result property="reportTime"    column="report_time"    />
        <result property="reportPerson"    column="report_person"    />
        <result property="eventDeal"    column="event_deal"    />
        <result property="eventAssessment"    column="event_assessment"    />
        <result property="beyondEnterpriseId"    column="beyond_enterprise_id"    />
        <result property="beyondEnterpriseName"    column="beyond_enterprise_name"    />
        <result property="iconUrl"    column="icon_url"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
        <result property="remarks"    column="remarks"    />
    </resultMap>

    <sql id="selectTEventInfoVo">
        select event_id, event_title, event_type, event_level, event_location, report_time, report_person, event_deal, event_assessment, beyond_enterprise_id, beyond_enterprise_name, icon_url, create_by, create_time, update_by, update_time, is_del, remarks from t_event_info
    </sql>

    <select id="selectTEventInfoList" parameterType="TEventInfo" resultMap="TEventInfoResult">
        <include refid="selectTEventInfoVo"/>
        <where>  
            <if test="eventTitle != null  and eventTitle != ''"> and event_title like concat('%', #{eventTitle}, '%')</if>
            <if test="eventType != null  and eventType != ''"> and event_type = #{eventType}</if>
            <if test="eventLevel != null  and eventLevel != ''"> and event_level = #{eventLevel}</if>
            <if test="reportPerson != null  and reportPerson != ''"> and report_person like concat('%', #{reportPerson}, '%')</if>
            <if test="beyondEnterpriseId != null  and beyondEnterpriseId != ''"> and beyond_enterprise_id = #{beyondEnterpriseId}</if>
        </where>
        order by report_time
    </select>
    
    <select id="selectTEventInfoById" parameterType="Long" resultMap="TEventInfoResult">
        <include refid="selectTEventInfoVo"/>
        where event_id = #{eventId}
    </select>
        
    <insert id="insertTEventInfo" parameterType="TEventInfo" useGeneratedKeys="true" keyProperty="eventId">
        insert into t_event_info
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="eventTitle != null">event_title,</if>
            <if test="eventType != null">event_type,</if>
            <if test="eventLevel != null">event_level,</if>
            <if test="eventLocation != null">event_location,</if>
            <if test="reportTime != null">report_time,</if>
            <if test="reportPerson != null">report_person,</if>
            <if test="eventDeal != null">event_deal,</if>
            <if test="eventAssessment != null">event_assessment,</if>
            <if test="beyondEnterpriseId != null">beyond_enterprise_id,</if>
            <if test="beyondEnterpriseName != null">beyond_enterprise_name,</if>
            <if test="iconUrl != null">icon_url,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDel != null">is_del,</if>
            <if test="remarks != null">remarks,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="eventTitle != null">#{eventTitle},</if>
            <if test="eventType != null">#{eventType},</if>
            <if test="eventLevel != null">#{eventLevel},</if>
            <if test="eventLocation != null">#{eventLocation},</if>
            <if test="reportTime != null">#{reportTime},</if>
            <if test="reportPerson != null">#{reportPerson},</if>
            <if test="eventDeal != null">#{eventDeal},</if>
            <if test="eventAssessment != null">#{eventAssessment},</if>
            <if test="beyondEnterpriseId != null">#{beyondEnterpriseId},</if>
            <if test="beyondEnterpriseName != null">#{beyondEnterpriseName},</if>
            <if test="iconUrl != null">#{iconUrl},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="remarks != null">#{remarks},</if>
         </trim>
    </insert>

    <update id="updateTEventInfo" parameterType="TEventInfo">
        update t_event_info
        <trim prefix="SET" suffixOverrides=",">
            <if test="eventTitle != null">event_title = #{eventTitle},</if>
            <if test="eventType != null">event_type = #{eventType},</if>
            <if test="eventLevel != null">event_level = #{eventLevel},</if>
            <if test="eventLocation != null">event_location = #{eventLocation},</if>
            <if test="reportTime != null">report_time = #{reportTime},</if>
            <if test="reportPerson != null">report_person = #{reportPerson},</if>
            <if test="eventDeal != null">event_deal = #{eventDeal},</if>
            <if test="eventAssessment != null">event_assessment = #{eventAssessment},</if>
            <if test="beyondEnterpriseId != null">beyond_enterprise_id = #{beyondEnterpriseId},</if>
            <if test="beyondEnterpriseName != null">beyond_enterprise_name = #{beyondEnterpriseName},</if>
            <if test="iconUrl != null">icon_url = #{iconUrl},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
        </trim>
        where event_id = #{eventId}
    </update>

    <delete id="deleteTEventInfoById" parameterType="Long">
        delete from t_event_info where event_id = #{eventId}
    </delete>

    <delete id="deleteTEventInfoByIds" parameterType="String">
        delete from t_event_info where event_id in 
        <foreach item="eventId" collection="array" open="(" separator="," close=")">
            #{eventId}
        </foreach>
    </delete>
</mapper>