refactor(bps): 重构代码并添加 Qodana 配置

- 修改 FastJsonRedisSerializer 类中的 deserialize 方法
- 删除未使用的 OsConstant 类
- 更新 OtherController 中的代码
- 添加 Qodana 配置文件 qodana.yaml
- 删除未使用的 RabbitMqConstant 类
- 精简 RedisConstant 类
- 大幅精简 SystemConstant 类
- 删除未使用的 UrlConstant 类
This commit is contained in:
2025-03-26 18:05:27 +08:00
parent 849ddb78bd
commit bdaff206f2
8 changed files with 33 additions and 203 deletions
+31
View File
@@ -0,0 +1,31 @@
#-------------------------------------------------------------------------------#
# Qodana analysis is configured by qodana.yaml file #
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
#-------------------------------------------------------------------------------#
version: "1.0"
#Specify inspection profile for code analysis
profile:
name: qodana.starter
#Enable inspections
#include:
# - name: <SomeEnabledInspectionId>
#Disable inspections
#exclude:
# - name: <SomeDisabledInspectionId>
# paths:
# - <path/where/not/run/inspection>
projectJDK: "17" #(Applied in CI/CD pipeline)
#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
#bootstrap: sh ./prepare-qodana.sh
#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
#plugins:
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)
#Specify Qodana linter for analysis (Applied in CI/CD pipeline)
linter: jetbrains/qodana-jvm:latest
@@ -41,7 +41,7 @@ public class FastJsonRedisSerializer<T> implements RedisSerializer<T> {
@Override
public T deserialize(byte[] bytes) throws SerializationException {
if (bytes == null || bytes.length <= 0) {
if (bytes == null || bytes.length == 0) {
return null;
}
String str = new String(bytes, DEFAULT_CHARSET);
@@ -1,13 +0,0 @@
package com.mzaxd.bps.constant;
/**
* @author Mzaxd
* @since 2023-02-05 11:38
*/
public class OsConstant {
/**
* 操作系统为Linux
*/
public static final String LINUX = "linux";
}
@@ -1,22 +0,0 @@
package com.mzaxd.bps.constant;
/**
* @author root
*/
public class RabbitMqConstant {
/**
* RabbitMQ的队列主题名称
*/
public static final String DYNAMIC_DATA_TOPIC = "DynamicDataTopic";
/**
* RabbitMQ的direct交换机名称
*/
public static final String DYNAMIC_DATA_EXCHANGE = "DynamicDataExchange";
/**
* RabbitMQ的direct交换机和队列绑定的匹配键 DirectRouting
*/
public static final String DYNAMIC_DATA_ROUTING = "DynamicDataRouting";
}
@@ -8,36 +8,21 @@ public class RedisConstant {
/**
* Redis Key
*
* @author mzaxd
* @date 2/7/23 12:59 PM
* @param null
*/
public static final String DYNAMIC_DATA = "dynamicData:";
/**
* Redis Key
*
* @author mzaxd
* @date 2/7/23 12:59 PM
* @param null
*/
public static final String NOTIFY_CONTAINER_IDS = "notify:containerIds";
/**
* Redis Key
*
* @author mzaxd
* @date 2/7/23 12:59 PM
* @param null
*/
public static final String NOTIFY_HOST_IDS = "notify:hostIds";
/**
* Redis Key
*
* @author mzaxd
* @date 2/7/23 12:59 PM
* @param null
*/
public static final String NOTIFY_VM_IDS = "notify:vmIds";
}
@@ -5,61 +5,6 @@ package com.mzaxd.bps.constant;
*/
public class SystemConstant {
/**
* 宿主机id等于0表示没有宿主机,即物理机
*/
public static final Integer PHYSICAL_MACHINE = 0;
/**
* 主机在线
*/
public static final Integer HOST_MACHINE_STATE_ONLINE = 0;
/**
* 主机离线
*/
public static final Integer HOST_MACHINE_STATE_OFFLINE = 1;
/**
* 主机睡眠
*/
public static final Integer HOST_MACHINE_STATE_SLEEP = 2;
/**
* 主机状态未知
*/
public static final Integer HOST_MACHINE_STATE_UNKNOWN = 3;
/**
* 物理机 host_machine_id 是 0
*/
public static final Long HOST_MACHINE_ID_HOST = 0L;
/**
* 成功id
*/
public static final Integer SUCCESS_CODE = 200;
/**
* 容器正在运行
*/
public static final Integer CONTAINER_STATE_RUNNING = 0;
/**
* 容器停止
*/
public static final Integer CONTAINER_STATE_EXITED = 1;
/**
* 容器暂停
*/
public static final Integer CONTAINER_STATE_PAUSED = 2;
/**
* 容器状态未知
*/
public static final Integer CONTAINER_STATE_UNKNOWN = 3;
/**
* 正常状态(非第一次使用) 通用常量
*/
@@ -70,36 +15,6 @@ public class SystemConstant {
*/
public static final String LOG_USER = "用户";
/**
* 提醒方式-不提醒
*/
public static final Integer NOTIFY_NO = 0;
/**
* 提醒方式-浏览器
*/
public static final Integer NOTIFY_BROWSER = 1;
/**
* 提醒方式-邮件
*/
public static final Integer NOTIFY_EMAIL = 2;
/**
* 提醒方式-浏览器和邮件
*/
public static final Integer NOTIFY_BROWSER_EMAIL = 3;
/**
* 通知类型 掉线
*/
public static final Integer OFFLINE_NOTIFICATION = 0;
/**
* 通知类型 统计
*/
public static final Integer STATISTICS_NOTIFICATION = 1;
/**
* 未处理的通知
*/
@@ -110,36 +25,6 @@ public class SystemConstant {
*/
public static final Integer NOTIFICATION_AFFIRM = 1;
/**
* 前端页面通知提醒页面对应的tab
*/
public static final Integer FRONTEND_NOTIFICATION_NOT_AFFIRM = 0;
/**
* 前端页面通知提醒页面对应的tab
*/
public static final Integer FRONTEND_NOTIFICATION_AFFIRM = 1;
/**
* 前端页面通知提醒页面对应的tab
*/
public static final Integer FRONTEND_NOTIFICATION_ALL = 2;
/**
* 前端页面通知提醒页面对应的tab
*/
public static final Integer FRONTEND_NOTIFICATION_TYPE_OFFLINE = 3;
/**
* 前端页面通知提醒页面对应的tab
*/
public static final Integer FRONTEND_NOTIFICATION_TYPE_STATISTICS = 4;
/**
* 通知实例类型 无
*/
public static final Integer INSTANCETYPE_NONE = 0;
/**
* 通知实例类型 物理机
*/
@@ -5,41 +5,6 @@ package com.mzaxd.bps.constant;
*/
public class UrlConstant {
/**
* isTrueUrl判断地址是否有效的链接
*/
public static final String DETECTOR_IS_TRUE_URL = "/isTrueUrl";
/**
* 获取远程主机信息链接
*/
public static final String DETECTOR_GET_INFO = "/getInfo";
/**
* 获取远程主机信息链接
*/
public static final String DETECTOR_GET_DISK_INFO = "/getDiskInfo";
/**
* 获取远程主机信息链接
*/
public static final String DETECTOR_GET_NETWORK_IF_INFO = "/getNetworkIfInfo";
/**
* 获取探测器uuid
*/
public static final String DETECTOR_GET_DETECTOR_ID = "/getDetectorID";
/**
* 通知探测器开始发送动态数据
*/
public static final String DETECTOR_START_SEND_DYNAMIC_DATA = "/startSendDynamicDataFromMq";
/**
* 通知探测器停止发送动态数据
*/
public static final String DETECTOR_STOP_SEND_DYNAMIC_DATA = "/stopSendDynamicDataFromMq";
/**
* 协议
*/
@@ -10,7 +10,6 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author ThinkBook
@@ -53,7 +52,7 @@ public class OtherController {
if (searchItems != null) {
List<SearchItem> filteredItems = searchItems.stream()
.filter(item -> item.getTitle().contains(str))
.collect(Collectors.toList());
.toList();
if (!filteredItems.isEmpty()) {
result.addAll(filteredItems);
} else {