<?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.xunmei.core.access.mapper.TMonitoringRetrievalPlanMapper">

    <resultMap type="com.xunmei.core.access.domain.TMonitoringRetrievalPlan" id="TMonitoringRetrievalPlanResult">
                <result property="id" column="id"/>
                <result property="planName" column="plan_name"/>
                <result property="orgId" column="org_id"/>
                <result property="orgPath" column="org_path"/>
                <result property="orgName" column="org_name"/>
                <result property="orgType" column="org_type"/>
                <result property="roleId" column="role_id"/>
                <result property="planCycle" column="plan_cycle"/>
                <result property="planFrequency" column="plan_frequency"/>
                <result property="planStatus" column="plan_status"/>
                <result property="createTime" column="create_time"/>
                <result property="createBy" column="create_by"/>
                <result property="updateTime" column="update_time"/>
                <result property="updateBy" column="update_by"/>
                <result property="description" column="description"/>
                <result property="isDeleted" column="is_deleted"/>
    </resultMap>

    <sql id="selectTMonitoringRetrievalPlanVo">
        select id, plan_name, org_id, org_path, org_name, org_type, role_id, plan_cycle, plan_frequency, plan_status, create_time, create_by, update_time, update_by, description, is_deleted
        from core_monitoring_retrieval_plan
    </sql>

    <select id="selectTMonitoringRetrievalPlanList" parameterType="com.xunmei.core.access.domain.TMonitoringRetrievalPlan"
            resultMap="TMonitoringRetrievalPlanResult">
        <include refid="selectTMonitoringRetrievalPlanVo"/>
        <where>
                        <if test="planName != null  and planName != ''">
                            and plan_name like concat('%', #{planName}, '%')
                        </if>
                        <if test="orgId != null ">
                            and org_id = #{orgId}
                        </if>
                        <if test="orgPath != null  and orgPath != ''">
                            and org_path = #{orgPath}
                        </if>
                        <if test="orgName != null  and orgName != ''">
                            and org_name like concat('%', #{orgName}, '%')
                        </if>
                        <if test="orgType != null ">
                            and org_type = #{orgType}
                        </if>
                        <if test="roleId != null ">
                            and role_id = #{roleId}
                        </if>
                        <if test="planCycle != null  and planCycle != ''">
                            and plan_cycle = #{planCycle}
                        </if>
                        <if test="planFrequency != null ">
                            and plan_frequency = #{planFrequency}
                        </if>
                        <if test="planStatus != null ">
                            and plan_status = #{planStatus}
                        </if>
                        <if test="description != null  and description != ''">
                            and description = #{description}
                        </if>
                        <if test="isDeleted != null ">
                            and is_deleted = #{isDeleted}
                        </if>
        </where>
    </select>

    <select id="selectTMonitoringRetrievalPlanById" parameterType="Long"
            resultMap="TMonitoringRetrievalPlanResult">
            <include refid="selectTMonitoringRetrievalPlanVo"/>
            where id = #{id}
    </select>

    <insert id="insertTMonitoringRetrievalPlan" parameterType="com.xunmei.core.access.domain.TMonitoringRetrievalPlan">
        insert into t_monitoring_retrieval_plan
        <trim prefix="(" suffix=")" suffixOverrides=",">
                    <if test="id != null">id,
                    </if>
                    <if test="planName != null">plan_name,
                    </if>
                    <if test="orgId != null">org_id,
                    </if>
                    <if test="orgPath != null">org_path,
                    </if>
                    <if test="orgName != null">org_name,
                    </if>
                    <if test="orgType != null">org_type,
                    </if>
                    <if test="roleId != null">role_id,
                    </if>
                    <if test="planCycle != null">plan_cycle,
                    </if>
                    <if test="planFrequency != null">plan_frequency,
                    </if>
                    <if test="planStatus != null">plan_status,
                    </if>
                    <if test="createTime != null">create_time,
                    </if>
                    <if test="createBy != null">create_by,
                    </if>
                    <if test="updateTime != null">update_time,
                    </if>
                    <if test="updateBy != null">update_by,
                    </if>
                    <if test="description != null">description,
                    </if>
                    <if test="isDeleted != null">is_deleted,
                    </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                    <if test="id != null">#{id},
                    </if>
                    <if test="planName != null">#{planName},
                    </if>
                    <if test="orgId != null">#{orgId},
                    </if>
                    <if test="orgPath != null">#{orgPath},
                    </if>
                    <if test="orgName != null">#{orgName},
                    </if>
                    <if test="orgType != null">#{orgType},
                    </if>
                    <if test="roleId != null">#{roleId},
                    </if>
                    <if test="planCycle != null">#{planCycle},
                    </if>
                    <if test="planFrequency != null">#{planFrequency},
                    </if>
                    <if test="planStatus != null">#{planStatus},
                    </if>
                    <if test="createTime != null">#{createTime},
                    </if>
                    <if test="createBy != null">#{createBy},
                    </if>
                    <if test="updateTime != null">#{updateTime},
                    </if>
                    <if test="updateBy != null">#{updateBy},
                    </if>
                    <if test="description != null">#{description},
                    </if>
                    <if test="isDeleted != null">#{isDeleted},
                    </if>
        </trim>
    </insert>

    <update id="updateTMonitoringRetrievalPlan" parameterType="com.xunmei.core.access.domain.TMonitoringRetrievalPlan">
        update t_monitoring_retrieval_plan
        <trim prefix="SET" suffixOverrides=",">
                    <if test="planName != null">plan_name =
                        #{planName},
                    </if>
                    <if test="orgId != null">org_id =
                        #{orgId},
                    </if>
                    <if test="orgPath != null">org_path =
                        #{orgPath},
                    </if>
                    <if test="orgName != null">org_name =
                        #{orgName},
                    </if>
                    <if test="orgType != null">org_type =
                        #{orgType},
                    </if>
                    <if test="roleId != null">role_id =
                        #{roleId},
                    </if>
                    <if test="planCycle != null">plan_cycle =
                        #{planCycle},
                    </if>
                    <if test="planFrequency != null">plan_frequency =
                        #{planFrequency},
                    </if>
                    <if test="planStatus != null">plan_status =
                        #{planStatus},
                    </if>
                    <if test="createTime != null">create_time =
                        #{createTime},
                    </if>
                    <if test="createBy != null">create_by =
                        #{createBy},
                    </if>
                    <if test="updateTime != null">update_time =
                        #{updateTime},
                    </if>
                    <if test="updateBy != null">update_by =
                        #{updateBy},
                    </if>
                    <if test="description != null">description =
                        #{description},
                    </if>
                    <if test="isDeleted != null">is_deleted =
                        #{isDeleted},
                    </if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteTMonitoringRetrievalPlanById" parameterType="Long">
        delete
        from core_monitoring_retrieval_plan where id = #{id}
    </delete>

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