<?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.system.mapper.operatingmanage.TOperatingmanageNoticeRangeMapper">

    <resultMap type="com.ruoyi.system.domain.operatingmanage.TOperatingmanageNoticeRange" id="TOperatingmanageNoticeRangeResult">
        <result property="id"    column="id"    />
        <result property="noticeId"    column="notice_id"    />
        <result property="gridCode"    column="grid_code"    />
        <result property="gridName"    column="grid_name"    />
    </resultMap>

    <sql id="selectTOperatingmanageNoticeRangeVo">
        select id, notice_id, grid_code, grid_name from t_operatingmanage_notice_range
    </sql>

    <select id="list" parameterType="com.ruoyi.system.domain.operatingmanage.TOperatingmanageNoticeRange" resultMap="TOperatingmanageNoticeRangeResult">
        <include refid="selectTOperatingmanageNoticeRangeVo"/>
        <where>
            <if test="noticeId != null "> and notice_id = #{noticeId}</if>
            <if test="gridCode != null  and gridCode != ''"> and grid_code = #{gridCode}</if>
            <if test="gridName != null  and gridName != ''"> and grid_name like concat('%', #{gridName}, '%')</if>
        </where>
    </select>

    <select id="getObjectById" resultMap="TOperatingmanageNoticeRangeResult">
        <include refid="selectTOperatingmanageNoticeRangeVo"/>
        where id = #{id}
    </select>

    <insert id="save" parameterType="com.ruoyi.system.domain.operatingmanage.TOperatingmanageNoticeRange">
        insert into t_operatingmanage_notice_range
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="noticeId != null">notice_id,</if>
            <if test="gridCode != null">grid_code,</if>
            <if test="gridName != null">grid_name,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="noticeId != null">#{noticeId},</if>
            <if test="gridCode != null">#{gridCode},</if>
            <if test="gridName != null">#{gridName},</if>
         </trim>
    </insert>

    <update id="update" parameterType="com.ruoyi.system.domain.operatingmanage.TOperatingmanageNoticeRange">
        update t_operatingmanage_notice_range
        <trim prefix="SET" suffixOverrides=",">
            <if test="noticeId != null">notice_id = #{noticeId},</if>
            <if test="gridCode != null">grid_code = #{gridCode},</if>
            <if test="gridName != null">grid_name = #{gridName},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="remove">
        delete from t_operatingmanage_notice_range
        where id = #{id}
    </delete>

    <delete id="batchRemove">
        delete from t_operatingmanage_notice_range where
        id in
        <foreach item="id" collection="id" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <delete id="removeByNoticeId">
        delete from t_operatingmanage_notice_range
        where notice_id = #{noticeId}
    </delete>
</mapper>
