kongdeqiang
2025-12-02 4910c350e379c180bdb7c3194e8ea0770928129f
大屏接口修改
4个文件已添加
5个文件已修改
569 ■■■■■ 已修改文件
src/main/java/com/wgcloud/WgcloudServiceApplication.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/wgcloud/controller/dp/DpController.java 32 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/wgcloud/entity/OspfErrorLog.java 82 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/wgcloud/mapper/OspfErrorLogMapper.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/wgcloud/service/OspfErrorLogService.java 94 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/wgcloud/service/OspfInfoService.java 101 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/wgcloud/service/RouterConnectionService.java 30 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/wgcloud/task/ScheduledTask.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mybatis/mapper/OspfErrorLogMapper.xml 178 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/wgcloud/WgcloudServiceApplication.java
@@ -31,7 +31,7 @@
@ServletComponentScan("com.wgcloud.filter")
@ComponentScan(basePackages = "com.wgcloud")
@EnableCaching
//@EnableScheduling
@EnableScheduling
public class WgcloudServiceApplication {
    public static void main(String[] args) {
        SpringApplication.run(WgcloudServiceApplication.class, args);
src/main/java/com/wgcloud/controller/dp/DpController.java
@@ -1,7 +1,9 @@
package com.wgcloud.controller.dp;
import com.wgcloud.entity.OspfErrorLog;
import com.wgcloud.entity.OspfInfo;
import com.wgcloud.entity.SnmpInfo;
import com.wgcloud.service.OspfErrorLogService;
import com.wgcloud.service.OspfInfoService;
import com.wgcloud.service.SnmpInfoService;
import com.wgcloud.util.R;
@@ -27,6 +29,8 @@
    @Autowired
    private OspfInfoService ospfInfoService;
    @Autowired
    private OspfErrorLogService ospfErrorLogService;
    @GetMapping("/getTop")
    public R getTop5() throws Exception {
@@ -68,14 +72,20 @@
        SimpleDateFormat sdf = new SimpleDateFormat("MM/dd");
        String format = sdf.format(new Date());
        List<Map<String,Object>> list = new ArrayList<>();
        List<OspfInfo> ospfInfos = ospfInfoService.selectAllByParams(null);
        Map<String,Object> query = new HashMap<>();
        query.put("state","1");
        List<OspfErrorLog> ospfErrorLogs = ospfErrorLogService.selectAllByParams(query);
        Map<String,Object> query2 = new HashMap<>();
        query2.put("state","0");
        List<OspfErrorLog> ospfErrorLogs2 = ospfErrorLogService.selectAllByParams(query2);
        ospfErrorLogs.addAll(ospfErrorLogs2);
        for (OspfInfo ospfInfo : ospfInfos) {
        for (OspfErrorLog ospfInfo : ospfErrorLogs) {
            HashMap<String, Object> map = new HashMap<>();
            map.put("date",format);
            map.put("date",sdf.format(ospfInfo.getCreateTime()));
            map.put("name",ospfInfo.getInfoContent());
            map.put("ipaddress",ospfInfo.getHostname());
            map.put("status",1);
            map.put("status",ospfInfo.getState());
            list.add(map);
        }
        return R.ok(list);
@@ -83,13 +93,16 @@
    @GetMapping("/getCount")
    public R getCount() throws Exception {
        Map<String,Object> queryMap = new HashMap<>();
        queryMap.put("state","1");
        List<OspfInfo> ospfInfos = ospfInfoService.selectAllByParams(null);
        List<OspfInfo> errorOspfInfos = ospfInfoService.selectAllByParams(queryMap);
        Map<String,Object> map = new HashMap<>();
        map.put("allCount",ospfInfos.size());
        map.put("normalCount",ospfInfos.size()-2);
        map.put("errorCount",2);
        double i = (double)(ospfInfos.size() - 2) /(double) ospfInfos.size();
        double o = (double)2 /(double) ospfInfos.size();
        map.put("normalCount",ospfInfos.size()-errorOspfInfos.size());
        map.put("errorCount",errorOspfInfos.size());
        double i = (double)(ospfInfos.size()-errorOspfInfos.size()) /(double) ospfInfos.size();
        double o = (double)errorOspfInfos.size() /(double) ospfInfos.size();
        BigDecimal n = new BigDecimal(i).setScale(2, BigDecimal.ROUND_HALF_UP);
        BigDecimal e = new BigDecimal(o).setScale(2, BigDecimal.ROUND_HALF_UP);
        map.put("normalProp",n);
@@ -103,7 +116,8 @@
        for (OspfInfo ospfInfo : ospfInfos) {
            HashMap<String, Object> map = new HashMap<>();
            map.put("ipAddress",ospfInfo.getHostname());
            map.put("status",1);
            map.put("name",ospfInfo.getInfoContent());
            map.put("status",ospfInfo.getState());
            list.add(map);
        }
        return R.ok(list);
src/main/java/com/wgcloud/entity/OspfErrorLog.java
New file
@@ -0,0 +1,82 @@
package com.wgcloud.entity;
import java.util.Date;
/**
 * @version v3.3
 * @ClassName:ospf.java
 * @author: http://www.wgstart.com
 * @date: 2021年1月16日
 * @Description: ospf监控设备
 * @Copyright: 2019-2021 wgcloud. All rights reserved.
 */
public class OspfErrorLog extends BaseEntity {
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    /**
     * 标题
     */
    private String hostname;
    /**
     * 描述
     */
    private String infoContent;
    /**
     * 0已处理,1未处理
     */
    private String state;
    /**
     * 创建时间
     */
    private Date createTime;
    public String getHostname() {
        return hostname;
    }
    public void setHostname(String hostname) {
        this.hostname = hostname;
    }
    public String getInfoContent() {
        return infoContent;
    }
    public void setInfoContent(String infoContent) {
        this.infoContent = infoContent;
    }
    public String getState() {
        return state;
    }
    public void setState(String state) {
        this.state = state;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}
src/main/java/com/wgcloud/mapper/OspfErrorLogMapper.java
New file
@@ -0,0 +1,39 @@
package com.wgcloud.mapper;
import com.wgcloud.entity.OspfErrorLog;
import com.wgcloud.entity.OspfMonitor;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
/**
 * @version v3.3
 * @ClassName:LogInfoDao.java
 * @author: http://www.wgstart.com
 * @date: 2021年1月16日
 * @Description: 查看日志信息
 * @Copyright: 2019-2021 wgcloud. All rights reserved.
 */
@Repository
public interface OspfErrorLogMapper {
    public List<OspfErrorLog> selectAllByParams(Map<String, Object> map);
    public int countByParams(Map<String, Object> params) throws Exception;
    public List<OspfErrorLog> selectByParams(Map<String, Object> params) throws Exception;
    public OspfErrorLog selectById(String id) throws Exception;
    public void save(OspfErrorLog LogInfo) throws Exception;
    public int deleteById(String[] id) throws Exception;
    public void insertList(List<OspfErrorLog> recordList) throws Exception;
    public int deleteByDate(Map<String, Object> map) throws Exception;
    public void updateById(OspfErrorLog ospfInfo);
}
src/main/java/com/wgcloud/service/OspfErrorLogService.java
New file
@@ -0,0 +1,94 @@
package com.wgcloud.service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wgcloud.entity.OspfErrorLog;
import com.wgcloud.entity.OspfErrorLog;
import com.wgcloud.mapper.OspfErrorLogMapper;
import com.wgcloud.util.DateUtil;
import com.wgcloud.util.UUIDUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * @version v3.3
 * @ClassName:OspfErrorLogService.java
 * @author: http://www.wgstart.com
 * @date: 2021年1月16日
 * @Description: OspfErrorLogService.java
 * @Copyright: 2019-2021 wgcloud. All rights reserved.
 */
@Service
public class OspfErrorLogService {
    private static final Logger logger = LoggerFactory.getLogger(OspfErrorLogService.class);
    public PageInfo selectByParams(Map<String, Object> params, int currPage, int pageSize) throws Exception {
        PageHelper.startPage(currPage, pageSize);
        List<OspfErrorLog> list = ospfErrorLogMapper.selectByParams(params);
        PageInfo<OspfErrorLog> pageInfo = new PageInfo<OspfErrorLog>(list);
        return pageInfo;
    }
    public void saveRecord(List<OspfErrorLog> recordList) throws Exception {
        if (recordList.size() < 1) {
            return;
        }
        Map<String, Object> map = new HashMap<String, Object>();
        for (OspfErrorLog as : recordList) {
            as.setId(UUIDUtil.getUUID());
            as.setCreateTime(DateUtil.getNowTime());
        }
        ospfErrorLogMapper.insertList(recordList);
    }
    public void save(OspfErrorLog OspfErrorLog) {
        OspfErrorLog.setId(UUIDUtil.getUUID());
        OspfErrorLog.setCreateTime(DateUtil.getNowTime());
        try {
            ospfErrorLogMapper.save(OspfErrorLog);
        } catch (Exception e) {
            logger.error("保存日志信息异常:", e);
        }
    }
    public void updateById(OspfErrorLog OspfErrorLog)
            throws Exception {
        if (StringUtils.isEmpty(OspfErrorLog.getHostname())) {
            OspfErrorLog.setHostname(OspfErrorLog.getHostname().trim());
        }
        ospfErrorLogMapper.updateById(OspfErrorLog);
    }
    public int countByParams(Map<String, Object> params) throws Exception {
        return ospfErrorLogMapper.countByParams(params);
    }
    public int deleteById(String[] id) throws Exception {
        return ospfErrorLogMapper.deleteById(id);
    }
    public OspfErrorLog selectById(String id) throws Exception {
        return ospfErrorLogMapper.selectById(id);
    }
    public List<OspfErrorLog> selectAllByParams(Map<String, Object> params) throws Exception {
        return ospfErrorLogMapper.selectAllByParams(params);
    }
    public int deleteByDate(Map<String, Object> map) throws Exception{
        return ospfErrorLogMapper.deleteByDate(map);
    }
    @Autowired
    private OspfErrorLogMapper ospfErrorLogMapper;
}
src/main/java/com/wgcloud/service/OspfInfoService.java
@@ -2,10 +2,14 @@
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wgcloud.entity.OspfErrorLog;
import com.wgcloud.entity.OspfInfo;
import com.wgcloud.entity.SnmpInfo;
import com.wgcloud.entity.vo.OspfNeighbor;
import com.wgcloud.mapper.OspfErrorLogMapper;
import com.wgcloud.mapper.OspfInfoMapper;
import com.wgcloud.util.DateUtil;
import com.wgcloud.util.OspfNeighborUtil;
import com.wgcloud.util.UUIDUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@@ -30,6 +34,10 @@
    @Autowired
    private RouterConnectionService routerConnectionService;
    @Autowired
    private OspfNeighborUtil ospfNeighborUtil;
    @Autowired
    private OspfErrorLogMapper errorLogMapper;
    private static final Logger logger = LoggerFactory.getLogger(OspfInfoService.class);
@@ -70,44 +78,81 @@
        OspfInfoMapper.updateById(ospfInfo);
    }
    public boolean checkOspfStatus() {
        String command = "display ospf brief";
        String output = routerConnectionService.executeCommand(command);
        if (output == null) {
            return false;
        }
        // 检查输出中是否包含OSPF相关信息
        boolean containsRouterId = StringUtils.containsIgnoreCase(output, "Router ID");
        boolean containsArea = StringUtils.containsIgnoreCase(output, "Area");
        boolean containsProcessId = StringUtils.containsIgnoreCase(output, "Process ID");
        // 检查是否有错误信息
        boolean containsError = StringUtils.containsIgnoreCase(output, "Error") ||
                StringUtils.containsIgnoreCase(output, "Fail") ||
                StringUtils.containsIgnoreCase(output, "Invalid");
        return (containsRouterId && containsArea && containsProcessId) && !containsError;
    }
//    public boolean checkOspfStatus() {
//        String command = "display ospf brief";
//        String output = routerConnectionService.executeCommand(command);
//
//        if (output == null) {
//            return false;
//        }
//
//        // 检查输出中是否包含OSPF相关信息
//        boolean containsRouterId = StringUtils.containsIgnoreCase(output, "Router ID");
//        boolean containsArea = StringUtils.containsIgnoreCase(output, "Area");
//        boolean containsProcessId = StringUtils.containsIgnoreCase(output, "Process ID");
//
//        // 检查是否有错误信息
//        boolean containsError = StringUtils.containsIgnoreCase(output, "Error") ||
//                StringUtils.containsIgnoreCase(output, "Fail") ||
//                StringUtils.containsIgnoreCase(output, "Invalid");
//
//        return (containsRouterId && containsArea && containsProcessId) && !containsError;
//    }
    /**
     * 获取详细的OSPF邻居信息
     */
    public String getDetailedOspfNeighborInfo() {
        String command = "display ospf peer";
        return routerConnectionService.executeCommand(command);
    public void getDetailedOspfNeighborInfo() {
        List<OspfInfo> ospfInfos = OspfInfoMapper.selectAllByParams(null);
        for (OspfInfo ospfInfo : ospfInfos) {
            String command = "display ospf peer "+ospfInfo.getHostname();
            String result =  routerConnectionService.executeCommand(command,ospfInfo.getMonitorUsername(),ospfInfo.getMonitorPassword(),ospfInfo.getMonitorIp());
            if(StringUtils.isNotBlank(result)){
                List<OspfNeighbor> neighbors = ospfNeighborUtil.analysisStr(result);
                if(neighbors != null || neighbors.size()>0){
                    OspfNeighbor ospfNeighbor = neighbors.get(0);
                    String state = ospfNeighbor.getState();
                    if (state.contains("Down") || state.contains("Init")) {
                        ospfInfo.setState("1");
                        OspfInfoMapper.updateById(ospfInfo);
                        HashMap<String, Object> hashMap = new HashMap<>();
                        hashMap.put("state","1");
                        hashMap.put("hostname",ospfInfo.getHostname());
                        List<OspfErrorLog> ospfErrorLogs = errorLogMapper.selectAllByParams(hashMap);
                        if(ospfErrorLogs==null||ospfErrorLogs.size()==0){
                            OspfErrorLog ospfErrorLog = new OspfErrorLog();
                            ospfErrorLog.setInfoContent(ospfInfo.getInfoContent());
                            ospfErrorLog.setHostname(ospfInfo.getHostname());
                            ospfErrorLog.setState("1");
                            try {
                                errorLogMapper.save(ospfErrorLog);
                            }catch (Exception e){
                                e.printStackTrace();
                            }
                        }
                    }else {
                        ospfInfo.setState("0");
                        OspfInfoMapper.updateById(ospfInfo);
                    }
                }
            }else {
                ospfInfo.setState("1");
                OspfInfoMapper.updateById(ospfInfo);
            }
        }
    }
    /**
     * 获取OSPF接口状态
     */
    public String getOspfInterfaceStatus() {
        String command = "display ospf interface";
        return routerConnectionService.executeCommand(command);
    }
//    public String getOspfInterfaceStatus() {
//        String command = "display ospf interface";
//        return routerConnectionService.executeCommand(command);
//    }
    public int countByParams(Map<String, Object> params) throws Exception {
src/main/java/com/wgcloud/service/RouterConnectionService.java
@@ -48,6 +48,28 @@
    }
    /**
     * 连接到路由器
     */
    public boolean connect(String username,String hostname,String password) {
        try {
            JSch jsch = new JSch();
            session = jsch.getSession(username, hostname, 22);
            session.setPassword(password);
            // 设置不进行主机密钥检查
            Properties config = new Properties();
            config.put("StrictHostKeyChecking", "no");
            session.setConfig(config);
            session.connect(5000); // 5秒超时
            return true;
        } catch (JSchException e) {
            System.err.println("连接路由器失败: " + e.getMessage());
            return false;
        }
    }
    /**
     * 断开连接
     */
    public void disconnect() {
@@ -59,9 +81,9 @@
    /**
     * 执行路由器命令
     */
    public String executeCommand(String command) {
    public String executeCommand(String command,String username,String password,String hostname) {
        if (!isConnected()) {
            if (!connect()) {
            if (!connect(username,hostname,password)) {
                return null;
            }
        }
@@ -69,8 +91,6 @@
        try {
            ChannelExec channel = (ChannelExec) session.openChannel("exec");
            channel.setCommand(command);
            channel.connect();
            BufferedReader reader = new BufferedReader(new InputStreamReader(channel.getInputStream()));
            StringBuilder output = new StringBuilder();
            String line;
@@ -95,4 +115,4 @@
    public boolean isConnected() {
        return session != null && session.isConnected();
    }
}
}
src/main/java/com/wgcloud/task/ScheduledTask.java
@@ -69,12 +69,23 @@
    @Autowired
    private SnmpInfoService snmpInfoService;
    @Autowired
    private OspfInfoService ospfInfoService;
    @Autowired
    private CommonConfig commonConfig;
    @Autowired
    private MailConfig mailConfig;
    @Autowired
    private ServletContext servletContext;
    /**
     * 30秒后执行,每2分钟检测一次
     * 检测ospf状态
     */
    @Scheduled(initialDelay = 30000L, fixedRate = 2 * 60 * 1000)
    public void ospfDownCheckTask() {
        logger.info("ospfDownCheckTask------------" + DateUtil.getDateTimeString(new Date()));
        ospfInfoService.getDetailedOspfNeighborInfo();
    }
    /**
     * 5秒后执行,之后每24小时刷新一次
src/main/resources/mybatis/mapper/OspfErrorLogMapper.xml
New file
@@ -0,0 +1,178 @@
<?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.OspfErrorLogMapper">
    <resultMap id="resultMap" type="com.wgcloud.entity.OspfErrorLog">
        <id column="ID" property="id" jdbcType="CHAR" />
        <result column="HOST_NAME" property="hostname" jdbcType="CHAR" />
        <result column="INFO_CONTENT" property="infoContent" jdbcType="CHAR" />
        <result column="STATE" property="state" jdbcType="CHAR" />
        <result column="CREATE_TIME" property="createTime" jdbcType="TIMESTAMP" />
    </resultMap>
    <sql id="tableColumnList">
        ID,HOST_NAME, INFO_CONTENT, STATE,CREATE_TIME
    </sql>
    <sql id="queryByParams">
        <if test="hostname != null">
            <choose>
                <when test="_databaseId == 'oracle'">
                    <![CDATA[ AND HOST_NAME LIKE  CONCAT(CONCAT('%',#{hostname}),'%') ]]>
                </when>
                <otherwise>
                    <![CDATA[ AND HOST_NAME LIKE  CONCAT('%',#{hostname},'%') ]]>
                </otherwise>
            </choose>
        </if>
        <if test="hostnameNe != null">
            <choose>
                <when test="_databaseId == 'oracle'">
                    <![CDATA[ AND HOST_NAME NOT LIKE  CONCAT(CONCAT('%',#{hostnameNe}),'%') ]]>
                </when>
                <otherwise>
                    <![CDATA[ AND HOST_NAME NOT LIKE  CONCAT('%',#{hostnameNe},'%') ]]>
                </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 test="_databaseId == 'oracle'">
                <![CDATA[ AND CREATE_TIME >= to_date(#{startTime},'yyyy-MM-dd hh24:mi:ss') and CREATE_TIME <= to_date(#{endTime},'yyyy-MM-dd hh24:mi:ss')]]>
            </if>
        </if>
        <if test="state != null">
            <![CDATA[ AND STATE = #{state} ]]>
        </if>
    </sql>
    <select id="selectById" resultMap="resultMap" parameterType="java.lang.String">
        SELECT
        <include refid="tableColumnList" />
        FROM OSPF_ERROR_LOG WHERE ID=#{id}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
        DELETE FROM OSPF_ERROR_LOG WHERE ID = #{id}
    </delete>
    <delete id="deleteByDate"  parameterType="map">
        DELETE FROM OSPF_ERROR_LOG WHERE
        <if test="_databaseId == 'mysql'">
            <![CDATA[  CREATE_TIME <=#{endTime}]]>
        </if>
        <if test="_databaseId == 'postgresql'">
            <![CDATA[  CREATE_TIME <= cast(#{endTime} as timestamp)]]>
        </if>
        <if test="_databaseId == 'oracle'">
            <![CDATA[  CREATE_TIME <=  to_date(#{endTime},'yyyy-MM-dd hh24:mi:ss')]]>
        </if>
    </delete>
    <delete id="deleteByAccHname"  parameterType="map">
        DELETE FROM OSPF_ERROR_LOG WHERE ACCOUNT = #{account} AND HOST_NAME = #{hostname}
    </delete>
    <delete id="deleteById" parameterType="java.lang.String">
        DELETE FROM OSPF_ERROR_LOG WHERE ID IN
        <foreach item="item" index="index" collection="array" open="(" separator="," close=")">
            #{item}
        </foreach>
    </delete>
    <insert id="insertList" parameterType="java.util.List" >
        <choose>
            <when test="_databaseId == 'oracle'">
                begin
                <foreach collection="list" item="item" index="index">
                    INSERT INTO OSPF_ERROR_LOG (ID,HOST_NAME,INFO_CONTENT,STATE,CREATE_TIME)  VALUES
                    (#{item.id},#{item.hostname},#{item.infoContent},#{item.state},#{item.createTime});
                </foreach>
                end;
            </when>
            <otherwise>
                INSERT INTO OSPF_ERROR_LOG (ID,HOST_NAME,INFO_CONTENT,STATE,CREATE_TIME)  VALUES
                <foreach collection="list" item="item" index="index" separator="," >
                    (#{item.id},#{item.hostname},#{item.infoContent},#{item.state},#{item.createTime})
                </foreach>
            </otherwise>
        </choose>
    </insert>
    <insert id="save" parameterType="com.wgcloud.entity.OspfErrorLog">
        INSERT INTO OSPF_ERROR_LOG
        <trim prefix="(" suffix=")" suffixOverrides="," >
              <if test="id != null" >ID,</if>
              <if test="hostname != null" > HOST_NAME,</if>
              <if test="infoContent != null">INFO_CONTENT,</if>
              <if test="state != null" >STATE,</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="infoContent != null" >#{infoContent},</if>
              <if test="state != null" >#{state},</if>
              <if test="createTime != null" >#{createTime}</if>
        </trim>
    </insert>
    <select id="countByParams" parameterType="map" resultType="java.lang.Integer">
        SELECT count(*)  FROM OSPF_ERROR_LOG t
        <where>
            <include refid="queryByParams" />
        </where>
    </select>
      <select id="selectAllByParams" parameterType="map" resultMap="resultMap">
        SELECT
        <include refid="tableColumnList" />
        FROM OSPF_ERROR_LOG t
        <where>
            <include refid="queryByParams" />
        </where>
         ORDER BY CREATE_TIME DESC
    </select>
    <select id="selectByParams" parameterType="map" resultMap="resultMap">
        SELECT
        <include refid="tableColumnList" />
        FROM OSPF_ERROR_LOG
        <where>
            <include refid="queryByParams" />
        </where>
         ORDER BY CREATE_TIME DESC
    </select>
    <update id="updateById" parameterType="com.wgcloud.entity.OspfErrorLog">
        UPDATE OSPF_ERROR_LOG
        <set>
            <if test="hostname != null">
                HOST_NAME = #{hostname},
            </if>
            <if test="infoContent != null">
                INFO_CONTENT = #{infoContent},
            </if>
            <if test="state != null">
                STATE = #{state},
            </if>
            <if test="createTime != null">
                CREATE_TIME = #{createTime},
            </if>
        </set>
        WHERE ID = #{id}
    </update>
</mapper>