<?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.manage.mapper.WarnManageMapper">
    
    <resultMap type="WarnManage" id="WarnManageResult">
        <result property="warnId"    column="warn_id"    />
        <result property="warnType"    column="warn_type"    />
        <result property="warnSign"    column="warn_sign"    />
        <result property="channelId"    column="channel_id"    />
        <result property="videoAddress"    column="video_address"    />
        <result property="reportAddress"    column="report_address"    />
        <result property="reportStatus"    column="report_status"    />
        <result property="warnTime"    column="warn_time"    />
        <result property="warnImage"    column="warn_image"    />
        <result property="delFlag"    column="del_flag"    />
        <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="remark"    column="remark"    />
    </resultMap>

    <sql id="selectWarnManageVo">
        select warn_id, warn_type, warn_sign, channel_id, video_address, report_address, report_status, warn_time, warn_image, del_flag, create_by, create_time, update_by, update_time, remark from warn_manage
    </sql>

    <select id="selectWarnManageList" parameterType="WarnManage" resultMap="WarnManageResult">
        <include refid="selectWarnManageVo"/>
        <where>  
            <if test="warnType != null  and warnType != ''"> and warn_type = #{warnType}</if>
            <if test="warnSign != null  and warnSign != ''"> and warn_sign = #{warnSign}</if>
            <if test="channelId != null "> and channel_id = #{channelId}</if>
            <if test="videoAddress != null  and videoAddress != ''"> and video_address = #{videoAddress}</if>
            <if test="reportAddress != null  and reportAddress != ''"> and report_address = #{reportAddress}</if>
            <if test="reportStatus != null  and reportStatus != ''"> and report_status = #{reportStatus}</if>
            <if test="warnTime != null "> and warn_time = #{warnTime}</if>
            <if test="warnImage != null  and warnImage != ''"> and warn_image = #{warnImage}</if>
        </where>
    </select>
    
    <select id="selectWarnManageByWarnId" parameterType="Long" resultMap="WarnManageResult">
        <include refid="selectWarnManageVo"/>
        where warn_id = #{warnId}
    </select>

    <insert id="insertWarnManage" parameterType="WarnManage" useGeneratedKeys="true" keyProperty="warnId">
        insert into warn_manage
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="warnType != null">warn_type,</if>
            <if test="warnSign != null">warn_sign,</if>
            <if test="channelId != null">channel_id,</if>
            <if test="videoAddress != null">video_address,</if>
            <if test="reportAddress != null">report_address,</if>
            <if test="reportStatus != null">report_status,</if>
            <if test="warnTime != null">warn_time,</if>
            <if test="warnImage != null">warn_image,</if>
            <if test="delFlag != null">del_flag,</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="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="warnType != null">#{warnType},</if>
            <if test="warnSign != null">#{warnSign},</if>
            <if test="channelId != null">#{channelId},</if>
            <if test="videoAddress != null">#{videoAddress},</if>
            <if test="reportAddress != null">#{reportAddress},</if>
            <if test="reportStatus != null">#{reportStatus},</if>
            <if test="warnTime != null">#{warnTime},</if>
            <if test="warnImage != null">#{warnImage},</if>
            <if test="delFlag != null">#{delFlag},</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="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateWarnManage" parameterType="WarnManage">
        update warn_manage
        <trim prefix="SET" suffixOverrides=",">
            <if test="warnType != null">warn_type = #{warnType},</if>
            <if test="warnSign != null">warn_sign = #{warnSign},</if>
            <if test="channelId != null">channel_id = #{channelId},</if>
            <if test="videoAddress != null">video_address = #{videoAddress},</if>
            <if test="reportAddress != null">report_address = #{reportAddress},</if>
            <if test="reportStatus != null">report_status = #{reportStatus},</if>
            <if test="warnTime != null">warn_time = #{warnTime},</if>
            <if test="warnImage != null">warn_image = #{warnImage},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</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="remark != null">remark = #{remark},</if>
        </trim>
        where warn_id = #{warnId}
    </update>

    <delete id="deleteWarnManageByWarnId" parameterType="Long">
        delete from warn_manage where warn_id = #{warnId}
    </delete>

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