<?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.wgcloud.mapper.SnmpInterfaceInfoMapper">
|
<resultMap id="resultMap" type="com.wgcloud.entity.SnmpInterfaceInfo">
|
<id column="ID" property="id" jdbcType="CHAR" />
|
<result column="HOST_NAME" property="hostname" jdbcType="CHAR" />
|
<result column="INTERFACE_NAME" property="interfaceName" jdbcType="CHAR" />
|
<result column="IS_UP" property="isUp" jdbcType="INTEGER" />
|
<result column="INET_ADDRESS_IPV4_MASK" property="inetAddressIPV4Mask" jdbcType="CHAR" />
|
<result column="ACTUAL_SPEED" property="actualSpeed" jdbcType="INTEGER" />
|
<result column="WORK_MTU" property="workMTU" jdbcType="INTEGER" />
|
<result column="ACTUAL_MTU" property="actualMTU" jdbcType="INTEGER" />
|
<result column="LOOPBACK" property="loopback" jdbcType="INTEGER" />
|
<result column="DESCRIPTION" property="description" jdbcType="CHAR" />
|
<result column="CREATE_TIME" property="createTime" jdbcType="TIMESTAMP" />
|
</resultMap>
|
|
<sql id="tableColumnList">
|
ID,HOST_NAME, INTERFACE_NAME,IS_UP,INET_ADDRESS_IPV4_MASK,ACTUAL_SPEED,WORK_MTU,ACTUAL_MTU,LOOPBACK,DESCRIPTION,CREATE_TIME
|
</sql>
|
|
<sql id="queryByParams">
|
<if test="hostname != null">
|
<choose>
|
<when test="_databaseId == 'oracle'">
|
<![CDATA[ AND ( HOST_NAME = #{hostname} OR REMARK LIKE CONCAT(CONCAT('%',#{hostname}),'%') )]]>
|
</when>
|
<otherwise>
|
<![CDATA[ AND ( HOST_NAME = #{hostname} OR REMARK LIKE CONCAT('%',#{hostname},'%') )]]>
|
</otherwise>
|
</choose>
|
</if>
|
<if test="startTime != null and endTime !=null and startTime !='' and endTime != '' ">
|
<if test="_databaseId == 'mysql'">
|
<![CDATA[ AND CREATE_TIME >= #{startTime} and CREATE_TIME <=#{endTime}]]>
|
</if>
|
<if test="_databaseId == 'postgresql'">
|
<![CDATA[ AND CREATE_TIME >= cast(#{startTime} as timestamp) and CREATE_TIME <= cast(#{endTime} as timestamp)]]>
|
</if>
|
</if>
|
<if test="state != null">
|
<![CDATA[ AND STATE = #{state} ]]>
|
</if>
|
<if test="account != null">
|
<![CDATA[ AND ACCOUNT = #{account} ]]>
|
</if>
|
<if test="snmpHostNames != null">
|
<![CDATA[ AND HOST_NAME IN ]]>
|
<foreach item="item" index="index" collection="snmpHostNames" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</if>
|
</sql>
|
|
|
<select id="selectById" resultMap="resultMap" parameterType="java.lang.String">
|
SELECT
|
<include refid="tableColumnList" />
|
FROM SNMP_INTERFACE_INFO
|
WHERE ID=#{id}
|
</select>
|
|
<select id="selectByHostName" resultMap="resultMap" parameterType="java.lang.String">
|
SELECT
|
<include refid="tableColumnList" />
|
FROM SNMP_INTERFACE_INFO
|
WHERE HOST_NAME=#{hostname}
|
</select>
|
|
|
<delete id="deleteById" parameterType="java.lang.String">
|
DELETE FROM
|
SNMP_INTERFACE_INFO
|
WHERE ID IN
|
<foreach item="item" index="index" collection="array" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</delete>
|
|
<delete id="deleteByHostName" parameterType="java.lang.String">
|
DELETE FROM
|
SNMP_INTERFACE_INFO
|
WHERE HOST_NAME=#{hostname}
|
</delete>
|
|
<insert id="save" parameterType="com.wgcloud.entity.SnmpInterfaceInfo">
|
INSERT INTO SNMP_INTERFACE_INFO
|
<trim prefix="(" suffix=")" suffixOverrides="," >
|
<if test="id != null" >ID,</if>
|
<if test="hostname != null" >HOST_NAME,</if>
|
<if test="interfaceName != null">INTERFACE_NAME,</if>
|
<if test="isUp != null">IS_UP,</if>
|
<if test="inetAddressIPV4Mask != null">INTER_ADDRESS_IPV4_MASK,</if>
|
<if test="actualSpeed != null">ACTUAL_SPEED,</if>
|
<if test="workMTU != null">WORK_MTU,</if>
|
<if test="actualMTU != null">ACTUAL_MTU,</if>
|
<if test="loopback != null">LOOPBACK,</if>
|
<if test="description != null">DESCRIPTION,</if>
|
<if test="createTime != null" >CREATE_TIME</if>
|
</trim>
|
<trim prefix="values (" suffix=")" suffixOverrides="," >
|
<if test="id != null" >#{id},</if>
|
<if test="hostname != null" >#{hostname},</if>
|
<if test="interfaceName != null" >#{interfaceName},</if>
|
<if test="isUp != null" >#{isUp},</if>
|
<if test="inetAddressIPV4Mask != null" >#{inetAddressIPV4Mask},</if>
|
<if test="actualSpeed != null" >#{actualSpeed},</if>
|
<if test="workMTU != null" >#{workMTU},</if>
|
<if test="actualMTU != null" >#{actualMTU},</if>
|
<if test="loopback != null" >#{loopback},</if>
|
<if test="description != null" >#{description},</if>
|
<if test="createTime != null" >#{createTime},</if>
|
</trim>
|
</insert>
|
|
|
<update id="updateList" parameterType="java.util.List" >
|
<if test="_databaseId == 'oracle'">
|
begin
|
</if>
|
<foreach collection="list" item="item" index="index" separator=";" >
|
UPDATE SNMP_INTERFACE_INFO
|
<set>
|
<if test="item.hostname != null">
|
HOST_NAME = #{item.hostname},
|
</if>
|
<if test="item.interfaceName != null">
|
INTERFACE_NAME = #{item.interfaceName},
|
</if>
|
<if test="item.isUp != null">
|
IS_UP = #{item.isUp},
|
</if>
|
<if test="item.inetAddressIPV4Mask != null">
|
INET_ADDRESS_IPV4_MASK = #{item.inetAddressIPV4Mask},
|
</if>
|
<if test="item.actualSpeed != null">
|
ACTUAL_SPEED = #{item.actualSpeed},
|
</if>
|
<if test="item.workMTU != null">
|
WORK_MTU = #{item.workMTU},
|
</if>
|
<if test="item.actualMTU != null">
|
ACTUAL_MTU = #{item.actualMTU},
|
</if>
|
<if test="item.loopback != null">
|
LOOPBACK = #{item.loopback,
|
</if>
|
<if test="item.description != null">
|
DESCRIPTION = #{item.description},
|
</if>
|
<if test="item.createTime != null" >
|
CREATE_TIME= #{item.createTime}
|
</if>
|
</set>
|
WHERE ID = #{item.id};
|
</foreach>
|
<if test="_databaseId == 'oracle'">
|
end;
|
</if>
|
</update>
|
|
<select id="selectAllByParams" parameterType="map" resultMap="resultMap">
|
SELECT
|
<include refid="tableColumnList" />
|
FROM SNMP_INTERFACE_INFO t
|
<where>
|
<include refid="queryByParams" />
|
</where>
|
ORDER BY ID DESC
|
</select>
|
|
<select id="selectByParams" parameterType="map" resultMap="resultMap">
|
SELECT
|
<include refid="tableColumnList" />
|
FROM SNMP_INTERFACE_INFO
|
<where>
|
<include refid="queryByParams" />
|
</where>
|
<choose>
|
<when test="orderBy !=null and orderBy != ''">
|
<![CDATA[ ORDER BY ${orderBy} ${orderType}]]>
|
</when>
|
<otherwise>
|
ORDER BY ID DESC
|
</otherwise>
|
</choose>
|
|
</select>
|
|
<insert id="insertList" parameterType="java.util.List" >
|
<choose>
|
<when test="_databaseId == 'oracle'">
|
begin
|
<foreach collection="list" item="item" index="index">
|
INSERT INTO SNMP_INTERFACE_INFO (ID,HOST_NAME, INTERFACE_NAME,IS_UP,INET_ADDRESS_IPV4_MASK,ACTUAL_SPEED,WORK_MTU,ACTUAL_MTU,LOOPBACK,DESCRIPTION,CREATE_TIME) VALUES
|
(#{item.id},#{item.hostname},#{item.interfaceName},#{item.isUp},#{item.inetAddressIPV4Mask},#{item.actualSpeed},#{item.workMTU},#{item.actualMTU},#{item.loopback},#{item.description},#{item.createTime})
|
</foreach>
|
end;
|
</when>
|
<otherwise>
|
INSERT INTO SNMP_INTERFACE_INFO (ID,HOST_NAME, INTERFACE_NAME,IS_UP,INET_ADDRESS_IPV4_MASK,ACTUAL_SPEED,WORK_MTU,ACTUAL_MTU,LOOPBACK,DESCRIPTION,CREATE_TIME) VALUES
|
<foreach collection="list" item="item" index="index" separator="," >
|
(#{item.id},#{item.hostname},#{item.interfaceName},#{item.isUp},#{item.inetAddressIPV4Mask},#{item.actualSpeed},#{item.workMTU},#{item.actualMTU},#{item.loopback},#{item.description},#{item.createTime})
|
</foreach>
|
</otherwise>
|
</choose>
|
</insert>
|
|
|
|
</mapper>
|