MObjectInfoMapper.xml 4.6 KB
<?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.monitor.mysql.mapper.MObjectInfoMapper">

    <cache></cache>

    <resultMap id="mobjectInfoMapper" type="com.model.MObjectInfo">
        <id property="moId" column="id"></id>
        <id property="moName" column="alias"></id>
        <id property="moHostIp" column="host_ip"></id>
        <id property="moTypeId" column="type_id"></id>
        <id property="moTags" column="tags"></id>
        <id property="moUrl" column="url"></id>
    </resultMap>

    <resultMap id="dependencyInfoMapper" type="com.model.DependencyInfo">
        <id property="typeId" column="typeId"></id>
        <id property="dependencyTypeId" column="dTypeId"></id>
    </resultMap>

    <select id="getAllMosInfo" resultType="com.model.MObjectInfo" resultMap="mobjectInfoMapper">
      SELECT * FROM mobject_info ORDER BY id asc
    </select>

    <select id="getTypeMosInfo" parameterType="int" resultType="com.model.MObjectInfo" resultMap="mobjectInfoMapper">
      SELECT * FROM mobject_info WHERE type_id = #{moTypeId} order by host_ip DESC
    </select>

    <!-- <select id="getHostMosInfo" parameterType="int" resultType="com.model.MObjectInfo" resultMap="mobjectInfoMapper">
       SELECT * FROM mobject_info WHERE mo_hostId = #{moHostId}
     </select>-->

    <insert id="insertMoInfo" useGeneratedKeys="true" keyProperty="id" parameterType="com.model.MObjectInfo">
      INSERT  INTO  mobject_info(alias,host_ip,type_id,tags,url) VALUES (#{moName},#{moHostIp},#{moTypeId},#{moTags},#{moUrl})
    </insert>

    <delete id="deleteMoInfo" parameterType="int">
      DELETE FROM mobject_info WHERE id = #{moId}
    </delete>

    <delete id="deleteMoInfoList">
        DELETE FROM mobject_info WHERE id  in

        <foreach collection="list" open="(" close=")" separator="," item="item">
            #{item}
        </foreach>
    </delete>

    <update id="updateMoInfo" parameterType="com.model.MObjectInfo">
      UPDATE mobject_info SET alias=#{moName},host_ip=#{moHostIp},type_id=#{moTypeId},tags=#{moTags},url=#{moUrl} WHERE id = #{moId}
    </update>


    <select id="selectMObjectsInfoByTypes" resultType="com.model.MObjectInfo" resultMap="mobjectInfoMapper">
        SELECT * FROM mobject_info

        where type_id in

        <foreach collection="list" open="(" close=")" separator="," item="item">
            #{item}
        </foreach>

        ORDER BY id asc
    </select>

    <select id="getMoInfosByAlias" resultType="com.model.MObjectInfo" resultMap="mobjectInfoMapper"
            parameterType="java.lang.String">
        SELECT * FROM mobject_info where instr(alias, LOWER(#{alias})) &gt; 0 ORDER BY id asc
    </select>


    <select id="selectDistinctHostIPByTypes" resultType="com.model.MObjectInfo" resultMap="mobjectInfoMapper">
        SELECT distinct host_ip FROM mobject_info

        where type_id in

        <foreach collection="list" open="(" close=")" separator="," item="item">
            #{item}
        </foreach>

        order by host_ip DESC
    </select>


    <select id="selectJavaDistinctHostIP" resultType="com.model.MObjectInfo" resultMap="mobjectInfoMapper">
         SELECT b.`host_ip`,GROUP_CONCAT(a.`alias`) alias FROM `type_info` a,`mobject_info` b
        WHERE a.`id` = b.`type_id` AND a.`alias` IN ('gateway','order','promotion','product','message','sns','users','resources','brower')
        AND a.`parent_id` = (SELECT id FROM `type_info` t WHERE t.`alias` = 'java_app') GROUP BY b.`host_ip`
    </select>


    <select id="selectAllDistinctHostIP" resultType="com.model.MObjectInfo" resultMap="mobjectInfoMapper">
        SELECT distinct host_ip FROM mobject_info
    </select>

    <select id="selectByFuzzyName" resultType="com.model.MObjectInfo" resultMap="mobjectInfoMapper">
        SELECT * FROM mobject_info where alias like CONCAT(#{name,jdbcType=VARCHAR},'%' ) limit 1
    </select>


    <select id="queryBindDependencyList" parameterType="java.lang.Integer" resultType="com.model.DependencyInfo" resultMap="dependencyInfoMapper">
        select * from type_dependency_info WHERE  typeId = #{typeId}
    </select>

    <delete id="deleteBindDependencyList" parameterType="java.lang.Integer">
        DELETE from type_dependency_info WHERE  typeId = #{typeId}
    </delete>

    <insert id="addBindDependencyList" parameterType="java.util.List">
        INSERT INTO type_dependency_info (typeId, dTypeId) VALUES
        <foreach collection="list" item="item" index="index" separator=",">
            (#{item.typeId},#{item.dependencyTypeId})
        </foreach>
    </insert>


</mapper>