<?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.rocketmq.mapper.RmInitialMonitorItemMapper">

    <resultMap type="RmInitialMonitorItem" id="RmInitialMonitorItemResult">
        <result property="id"    column="id"    />
        <result property="itemType"    column="item_type"    />
        <result property="metricKey"    column="metric_key"    />
        <result property="metricName"    column="metric_name"    />
        <result property="oid"    column="oid"    />
        <result property="filterValue"    column="filter_value"    />
        <result property="monitorDescription"    column="monitor_description"    />
        <result property="dataType"    column="data_type"    />
        <result property="resourceType"    column="resource_type"    />
        <result property="collectionCycle"    column="collection_cycle"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
    </resultMap>

    <sql id="selectRmInitialMonitorItemVo">
        select id, item_type, metric_key, metric_name, oid, filter_value, monitor_description, data_type, resource_type, collection_cycle, create_time, update_time, create_by, update_by from rm_initial_monitor_item
    </sql>

    <select id="selectRmInitialMonitorItemList" parameterType="RmInitialMonitorItem" resultMap="RmInitialMonitorItemResult">
        <include refid="selectRmInitialMonitorItemVo"/>
        <where>
            <if test="itemType != null  and itemType != ''"> and item_type = #{itemType}</if>
            <if test="metricKey != null  and metricKey != ''"> and metric_key = #{metricKey}</if>
            <if test="metricName != null  and metricName != ''"> and metric_name like concat('%', #{metricName}, '%')</if>
            <if test="oid != null  and oid != ''"> and oid = #{oid}</if>
            <if test="filterValue != null  and filterValue != ''"> and filter_value = #{filterValue}</if>
            <if test="monitorDescription != null  and monitorDescription != ''"> and monitor_description = #{monitorDescription}</if>
            <if test="dataType != null  and dataType != ''"> and data_type = #{dataType}</if>
            <if test="resourceType != null  and resourceType != ''"> and resource_type = #{resourceType}</if>
            <if test="collectionCycle != null  and collectionCycle != ''"> and collection_cycle = #{collectionCycle}</if>
        </where>
    </select>

    <select id="selectRmInitialMonitorItemById" parameterType="Long" resultMap="RmInitialMonitorItemResult">
        <include refid="selectRmInitialMonitorItemVo"/>
        where id = #{id}
    </select>

    <insert id="insertRmInitialMonitorItem" parameterType="RmInitialMonitorItem" useGeneratedKeys="true" keyProperty="id">
        insert into rm_initial_monitor_item
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="itemType != null and itemType != ''">item_type,</if>
            <if test="metricKey != null and metricKey != ''">metric_key,</if>
            <if test="metricName != null and metricName != ''">metric_name,</if>
            <if test="oid != null">oid,</if>
            <if test="filterValue != null">filter_value,</if>
            <if test="monitorDescription != null">monitor_description,</if>
            <if test="dataType != null and dataType != ''">data_type,</if>
            <if test="resourceType != null and resourceType != ''">resource_type,</if>
            <if test="collectionCycle != null">collection_cycle,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="itemType != null and itemType != ''">#{itemType},</if>
            <if test="metricKey != null and metricKey != ''">#{metricKey},</if>
            <if test="metricName != null and metricName != ''">#{metricName},</if>
            <if test="oid != null">#{oid},</if>
            <if test="filterValue != null">#{filterValue},</if>
            <if test="monitorDescription != null">#{monitorDescription},</if>
            <if test="dataType != null and dataType != ''">#{dataType},</if>
            <if test="resourceType != null and resourceType != ''">#{resourceType},</if>
            <if test="collectionCycle != null">#{collectionCycle},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
        </trim>
    </insert>

    <update id="updateRmInitialMonitorItem" parameterType="RmInitialMonitorItem">
        update rm_initial_monitor_item
        <trim prefix="SET" suffixOverrides=",">
            <if test="itemType != null and itemType != ''">item_type = #{itemType},</if>
            <if test="metricKey != null and metricKey != ''">metric_key = #{metricKey},</if>
            <if test="metricName != null and metricName != ''">metric_name = #{metricName},</if>
            <if test="oid != null">oid = #{oid},</if>
            <if test="filterValue != null">filter_value = #{filterValue},</if>
            <if test="monitorDescription != null">monitor_description = #{monitorDescription},</if>
            <if test="dataType != null and dataType != ''">data_type = #{dataType},</if>
            <if test="resourceType != null and resourceType != ''">resource_type = #{resourceType},</if>
            <if test="collectionCycle != null">collection_cycle = #{collectionCycle},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteRmInitialMonitorItemById" parameterType="Long">
        delete from rm_initial_monitor_item where id = #{id}
    </delete>

    <delete id="deleteRmInitialMonitorItemByIds" parameterType="String">
        delete from rm_initial_monitor_item where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <select id="selectRmInitialMonitorItemByIds" parameterType="java.lang.Long" resultMap="RmInitialMonitorItemResult">
        <include refid="selectRmInitialMonitorItemVo"/>
        where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </select>
</mapper>