<?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.ruoyi.zongzhi.mapper.TcYqFlMapper">
    
    <resultMap type="TcYqFl" id="TcYqFlResult">
        <result property="id"    column="id"    />
        <result property="areaId"    column="area_id"    />
        <result property="mediaType"    column="media_type"    />
        <result property="eventType"    column="event_type"    />
        <result property="mediaCount"    column="media_count"    />
        <result property="eventCount"    column="event_count"    />
        <result property="isStatus"    column="is_status"    />
    </resultMap>

    <sql id="selectTcYqFlVo">
        select id, area_id, media_type, is_status,event_type, media_count, event_count,is_status from tc_yq_fl
    </sql>

    <select id="selectTcYqFlList" parameterType="TcYqFl" resultMap="TcYqFlResult">
        <include refid="selectTcYqFlVo"/>
        <where>  
            <if test="areaId != null "> and area_id = #{areaId}</if>
            <if test="mediaType != null "> and media_type = #{mediaType}</if>
            <if test="eventType != null "> and event_type = #{eventType}</if>
            <if test="mediaCount != null  and mediaCount != ''"> and media_count = #{mediaCount}</if>
            <if test="eventCount != null  and eventCount != ''"> and event_count = #{eventCount}</if>
            <if test="isStatus != null "> and is_status = #{isStatus}</if>
        </where>
    </select>
    
    <select id="selectTcYqFlById" parameterType="Long" resultMap="TcYqFlResult">
        <include refid="selectTcYqFlVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertTcYqFl" parameterType="TcYqFl" useGeneratedKeys="true" keyProperty="id">
        insert into tc_yq_fl
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="areaId != null">area_id,</if>
            <if test="mediaType != null">media_type,</if>
            <if test="eventType != null">event_type,</if>
            <if test="mediaCount != null">media_count,</if>
            <if test="eventCount != null">event_count,</if>
            <if test="isStatus != null">is_status,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="areaId != null">#{areaId},</if>
            <if test="mediaType != null">#{mediaType},</if>
            <if test="eventType != null">#{eventType},</if>
            <if test="mediaCount != null">#{mediaCount},</if>
            <if test="eventCount != null">#{eventCount},</if>
            <if test="isStatus != null">#{isStatus},</if>
         </trim>
    </insert>

    <update id="updateTcYqFl" parameterType="TcYqFl">
        update tc_yq_fl
        <trim prefix="SET" suffixOverrides=",">
            <if test="areaId != null">area_id = #{areaId},</if>
            <if test="mediaType != null">media_type = #{mediaType},</if>
            <if test="eventType != null">event_type = #{eventType},</if>
            <if test="mediaCount != null">media_count = #{mediaCount},</if>
            <if test="eventCount != null">event_count = #{eventCount},</if>
            <if test="isStatus != null">is_status=#{isStatus},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTcYqFlById" parameterType="Long">
        delete from tc_yq_fl where id = #{id}
    </delete>

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