Commit 13e2747c by HlQ

[add] 运维监测实体类、service、mapper 提交

1 parent 512e3099
Showing 52 changed files with 735 additions and 142 deletions
package vion.controller; package vion.controller.monitor;
import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import vion.dto.AgentDTO; import vion.dto.AgentDTO;
import vion.model.RAgentService; import vion.model.monitor.RAgentService;
import vion.model.ServiceInfo; import vion.model.monitor.ServiceInfo;
import vion.service.IAgentService; import vion.service.monitor.IAgentService;
import vion.vo.AgentVO; import vion.vo.AgentVO;
import java.util.List; import java.util.List;
......
package vion.controller; package vion.controller.monitor;
import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.dromara.hutool.core.data.id.IdUtil; import org.dromara.hutool.core.data.id.IdUtil;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import vion.model.ServiceInfo; import vion.model.monitor.ServiceInfo;
import vion.service.IServiceInfoService; import vion.service.monitor.IServiceInfoService;
/** /**
* 服务 * 服务
......
package vion.controller; package vion.controller.monitor;
import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import vion.model.Upgrade; import vion.model.monitor.Upgrade;
import vion.service.IUpgradeService; import vion.service.monitor.IUpgradeService;
/** /**
* 升级包管理 * 升级包管理
......
...@@ -2,11 +2,11 @@ package vion.controller.mqtt; ...@@ -2,11 +2,11 @@ package vion.controller.mqtt;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import vion.model.Agent; import vion.model.monitor.Agent;
import vion.model.ServerInfo; import vion.model.monitor.AgentRecord;
import vion.model.ServiceRecord; import vion.model.monitor.ServiceRecord;
import vion.model.Upgrade; import vion.model.monitor.Upgrade;
import vion.service.IAgentService; import vion.service.monitor.IAgentService;
import java.util.List; import java.util.List;
...@@ -32,8 +32,8 @@ public class MonitorController { ...@@ -32,8 +32,8 @@ public class MonitorController {
} }
@PostMapping("/server") @PostMapping("/server")
public String recServerInfo(@RequestBody ServerInfo serverInfo) { public String recServerInfo(@RequestBody AgentRecord agentRecord) {
return agentService.recServerInfo(serverInfo); return agentService.recAgentRecord(agentRecord);
} }
@PostMapping("/service") @PostMapping("/service")
......
...@@ -9,7 +9,7 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -9,7 +9,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import vion.dto.MqttAuthDTO; import vion.dto.MqttAuthDTO;
import vion.service.IAgentService; import vion.service.monitor.IAgentService;
/** /**
* 与 mqtt server 交互调用的接口 * 与 mqtt server 交互调用的接口
......
package vion.mapper; package vion.mapper.monitor;
import com.github.yulichang.base.MPJBaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import vion.model.Agent; import vion.model.monitor.Agent;
/** /**
* @author vion * @author vion
......
package vion.mapper; package vion.mapper.monitor;
import com.github.yulichang.base.MPJBaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import vion.model.ServerInfo; import vion.model.monitor.AgentRecord;
/** /**
* @author vion * @author vion
* @date 2024/10/21 * @date 2024/10/31
*/ */
public interface ServerMapper extends MPJBaseMapper<ServerInfo> { public interface AgentRecordMapper extends MPJBaseMapper<AgentRecord> {
} }
\ No newline at end of file \ No newline at end of file
package vion.mapper.monitor;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import vion.model.monitor.Event;
/**
* @author vion
* @date 2024/10/31
*/
public interface EventMapper extends BaseMapper<Event> {
}
\ No newline at end of file \ No newline at end of file
package vion.mapper.monitor;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import vion.model.monitor.EventRecord;
/**
* @author vion
* @date 2024/10/31
*/
public interface EventRecordMapper extends BaseMapper<EventRecord> {
}
\ No newline at end of file \ No newline at end of file
package vion.mapper.monitor;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import vion.model.monitor.MAccount;
/**
* @author vion
* @date 2024/10/31
*/
public interface MAccountMapper extends BaseMapper<MAccount> {
}
\ No newline at end of file \ No newline at end of file
package vion.mapper.monitor;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import vion.model.monitor.Mall;
/**
* @author vion
* @date 2024/10/31
*/
public interface MallMapper extends BaseMapper<Mall> {
}
\ No newline at end of file \ No newline at end of file
package vion.mapper.monitor;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import vion.model.monitor.RAgentEvent;
/**
* @author vion
* @date 2024/10/31
*/
public interface RAgentEventMapper extends BaseMapper<RAgentEvent> {
}
\ No newline at end of file \ No newline at end of file
package vion.mapper; package vion.mapper.monitor;
import com.github.yulichang.base.MPJBaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import vion.model.RAgentService; import vion.model.monitor.RAgentService;
/** /**
* @author vion * @author vion
......
package vion.mapper; package vion.mapper.monitor;
import com.github.yulichang.base.MPJBaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import vion.model.ServiceInfo; import vion.model.monitor.ServiceInfo;
/** /**
* @author vion * @author vion
......
package vion.mapper; package vion.mapper.monitor;
import com.github.yulichang.base.MPJBaseMapper; import com.github.yulichang.base.MPJBaseMapper;
import vion.model.ServiceRecord; import vion.model.monitor.ServiceRecord;
/** /**
* @author vion * @author vion
......
package vion.mapper; package vion.mapper.monitor;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import vion.model.Upgrade; import vion.model.monitor.Upgrade;
/** /**
* @author vion * @author vion
......
package vion.model; package vion.model;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.github.linpeilie.annotations.AutoMapper; import io.github.linpeilie.annotations.AutoMapper;
import io.github.linpeilie.annotations.AutoMappers; import io.github.linpeilie.annotations.AutoMappers;
import lombok.Getter; import lombok.Getter;
...@@ -88,9 +85,9 @@ public class RContractTeam { ...@@ -88,9 +85,9 @@ public class RContractTeam {
@TableField(value = "remark") @TableField(value = "remark")
private String remark; private String remark;
@TableField(value = "create_time") @TableField(value = "create_time", fill = FieldFill.INSERT)
private LocalDateTime createTime; private LocalDateTime createTime;
@TableField(value = "update_time") @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateTime; private LocalDateTime updateTime;
} }
\ No newline at end of file \ No newline at end of file
package vion.model; package vion.model.monitor;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import io.github.linpeilie.annotations.AutoMapper; import io.github.linpeilie.annotations.AutoMapper;
...@@ -32,12 +32,6 @@ public class Agent { ...@@ -32,12 +32,6 @@ public class Agent {
private String uid; private String uid;
/** /**
* agent 版本号
*/
@TableField(value = "version")
private String version;
/**
* 用户名 * 用户名
*/ */
@TableField(value = "username") @TableField(value = "username")
...@@ -62,6 +56,18 @@ public class Agent { ...@@ -62,6 +56,18 @@ public class Agent {
private String alias; private String alias;
/** /**
* agent类型 1:store,2:mall
*/
@TableField(value = "type")
private Short type;
/**
* agent 版本号
*/
@TableField(value = "version")
private String version;
/**
* 主机名 * 主机名
*/ */
@TableField(value = "hostname", condition = SqlCondition.LIKE) @TableField(value = "hostname", condition = SqlCondition.LIKE)
...@@ -86,6 +92,30 @@ public class Agent { ...@@ -86,6 +92,30 @@ public class Agent {
private String addr; private String addr;
/** /**
* 操作系统
*/
@TableField(value = "os")
private String os;
/**
* 系统信息
*/
@TableField(value = "system_info")
private String systemInfo;
/**
* 时区
*/
@TableField(value = "time_zone")
private String timeZone;
/**
* 授权到期时间
*/
@TableField(value = "license_date")
private String licenseDate;
/**
* 0:离线 1:在线 * 0:离线 1:在线
*/ */
@TableField(value = "status") @TableField(value = "status")
......
package vion.model; package vion.model.monitor;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import lombok.Getter; import lombok.Getter;
...@@ -8,32 +8,44 @@ import vion.config.mp.JsonbTypeHandler; ...@@ -8,32 +8,44 @@ import vion.config.mp.JsonbTypeHandler;
import java.time.LocalDateTime; import java.time.LocalDateTime;
/** /**
* 服务器信息 * agent服务器监测记录
*/ */
@Getter @Getter
@Setter @Setter
@TableName(value = "m_server") @TableName(value = "m_agent_record")
public class ServerInfo { public class AgentRecord {
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private Long id; private Long id;
/** /**
* 唯一id * agent uid
*/ */
@TableField(value = "uid") @TableField(value = "agent_uid")
private String uid; private String agentUid;
/** /**
* 授权到期日期 * cpu信息
*/ */
@TableField(value = "license_date") @TableField(value = "cpu_info", typeHandler = JsonbTypeHandler.class)
private String licenseDate; private Object cpuInfo;
/** /**
* 操作系统 * 内存信息
*/ */
@TableField(value = "os") @TableField(value = "memory_info", typeHandler = JsonbTypeHandler.class)
private String os; private Object memoryInfo;
/**
* 磁盘信息
*/
@TableField(value = "disk_info", typeHandler = JsonbTypeHandler.class)
private Object diskInfo;
/**
* 网络流量
*/
@TableField(value = "network_info", typeHandler = JsonbTypeHandler.class)
private Object networkInfo;
/** /**
* 启动时间 * 启动时间
...@@ -46,31 +58,18 @@ public class ServerInfo { ...@@ -46,31 +58,18 @@ public class ServerInfo {
/** /**
* 运行时间 * 运行时间
*/ */
@TableField(value = "uptime") @TableField(value = "up_time")
private String uptime; private String upTime;
/** /**
* 时区 * 时区
*/ */
@TableField(value = "\"offset\"") @TableField(value = "time_zone")
private String offset; private String timeZone;
/**
* 磁盘信息
*/
@TableField(value = "disk_info", typeHandler = JsonbTypeHandler.class)
private Object diskInfo;
/**
* 内存信息
*/
@TableField(value = "memory_info", typeHandler = JsonbTypeHandler.class)
private Object memoryInfo;
@TableField(value = "create_time", fill = FieldFill.INSERT) @TableField(value = "create_time", fill = FieldFill.INSERT)
private LocalDateTime createTime; private LocalDateTime createTime;
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateTime; private LocalDateTime updateTime;
} }
\ No newline at end of file \ No newline at end of file
package vion.model.monitor;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
/**
* 监测事件
*/
@Getter
@Setter
@TableName(value = "m_event")
public class Event {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* 唯一标识
*/
@TableField(value = "\"uid\"")
private String uid;
/**
* 事件名称
*/
@TableField(value = "\"name\"")
private String name;
/**
* 事件类型
*/
@TableField(value = "event_type")
private String eventType;
/**
* 来源 1:系统 2:设备 3:平台
*/
@TableField(value = "\"source\"")
private Short source;
/**
* 监测时间
*/
@TableField(value = "cron")
private String cron;
/**
* 默认阈值,可为空
*/
@TableField(value = "threshold")
private String threshold;
/**
* 对比周期
*/
@TableField(value = "contrast_period")
private String contrastPeriod;
/**
* 规则
*/
@TableField(value = "\"rule\"")
private Object rule;
/**
* 备注
*/
@TableField(value = "remark")
private String remark;
/**
* 创建人
*/
@TableField(value = "create_by")
private String createBy;
/**
* 修改人
*/
@TableField(value = "update_by")
private String updateBy;
@TableField(value = "create_time", fill = FieldFill.INSERT)
private LocalDateTime createTime;
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateTime;
}
\ No newline at end of file \ No newline at end of file
package vion.model.monitor;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Getter;
import lombok.Setter;
import vion.config.mp.JsonbTypeHandler;
import java.time.LocalDateTime;
/**
* 事件监测记录
*/
@Getter
@Setter
@TableName(value = "m_event_record")
public class EventRecord {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* agent uid
*/
@TableField(value = "agent_uid")
private String agentUid;
/**
* 所属集团uid
*/
@TableField(value = "account_uid")
private String accountUid;
/**
* mall unid
*/
@TableField(value = "mall_uid")
private String mallUid;
/**
* 事件唯一ID
*/
@TableField(value = "event_uid")
private String eventUid;
/**
* 事件类型
*/
@TableField(value = "event_type")
private String eventType;
/**
* 阈值
*/
@TableField(value = "threshold")
private String threshold;
/**
* 事件状态 0:异常 1:正常 -1:未知
*/
@TableField(value = "\"status\"")
private Short status;
/**
* 设备上报数据
*/
@TableField(value = "\"data\"", typeHandler = JsonbTypeHandler.class)
private Object data;
@TableField(value = "create_time", fill = FieldFill.INSERT)
private LocalDateTime createTime;
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateTime;
}
\ No newline at end of file \ No newline at end of file
package vion.model.monitor;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
/**
* 项目集团信息
*/
@Getter
@Setter
@TableName(value = "m_account")
public class MAccount {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* agent uid
*/
@TableField(value = "agent_uid")
private String agentUid;
/**
* agent类型 1:store,2:mall
*/
@TableField(value = "agent_type")
private Short agentType;
/**
* 集团uid
*/
@TableField(value = "\"uid\"")
private String uid;
/**
* 集团名称
*/
@TableField(value = "\"name\"")
private String name;
/**
* 备注
*/
@TableField(value = "remark")
private String remark;
@TableField(value = "create_time", fill = FieldFill.INSERT)
private LocalDateTime createTime;
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateTime;
}
\ No newline at end of file \ No newline at end of file
package vion.model.monitor;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDateTime;
/**
* 项目mall信息
*/
@Getter
@Setter
@TableName(value = "m_mall")
public class Mall {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* agent uid
*/
@TableField(value = "agent_uid")
private String agentUid;
/**
* agent类型 1:store,2:mall
*/
@TableField(value = "agent_type")
private Short agentType;
/**
* 所属集团uid
*/
@TableField(value = "account_uid")
private String accountUid;
/**
* mall unid
*/
@TableField(value = "mall_uid")
private String mallUid;
/**
* mall名称
*/
@TableField(value = "\"name\"")
private String name;
/**
* mall营业状态
*/
@TableField(value = "\"status\"")
private Boolean status;
/**
* 时区
*/
@TableField(value = "time_zone")
private String timeZone;
/**
* 备注
*/
@TableField(value = "remark")
private String remark;
@TableField(value = "create_time", fill = FieldFill.INSERT)
private LocalDateTime createTime;
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateTime;
}
\ No newline at end of file \ No newline at end of file
package vion.model.monitor;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalDate;
import java.time.LocalDateTime;
/**
* 项目监测关联
*/
@Getter
@Setter
@TableName(value = "mr_agent_event")
public class RAgentEvent {
@TableId(value = "id", type = IdType.AUTO)
private Long id;
/**
* agent uid
*/
@TableField(value = "agent_uid")
private String agentUid;
/**
* 所属集团uid
*/
@TableField(value = "account_uid")
private String accountUid;
/**
* mall unid
*/
@TableField(value = "mall_uid")
private String mallUid;
/**
* 事件唯一ID
*/
@TableField(value = "event_uid")
private String eventUid;
/**
* 事件类型
*/
@TableField(value = "event_type")
private String eventType;
/**
* 监测时间
*/
@TableField(value = "cron")
private String cron;
/**
* 默认阈值,可为空
*/
@TableField(value = "threshold")
private String threshold;
/**
* 开关 0:关 1:开
*/
@TableField(value = "control_switch")
private Short controlSwitch;
/**
* 过期时间,为空则永不过期
*/
@TableField(value = "expire")
private LocalDate expire;
/**
* 事件建立者
*/
@TableField(value = "create_by")
private String createBy;
/**
* 事件更新者
*/
@TableField(value = "udpate_by")
private String udpateBy;
@TableField(value = "create_time", fill = FieldFill.INSERT)
private LocalDateTime createTime;
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateTime;
}
\ No newline at end of file \ No newline at end of file
package vion.model; package vion.model.monitor;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import lombok.Getter; import lombok.Getter;
......
package vion.model; package vion.model.monitor;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
......
package vion.model; package vion.model.monitor;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import lombok.Getter; import lombok.Getter;
......
package vion.model; package vion.model.monitor;
import com.baomidou.mybatisplus.annotation.*; import com.baomidou.mybatisplus.annotation.*;
import lombok.Getter; import lombok.Getter;
......
package vion.service;
import com.github.yulichang.base.MPJBaseService;
import vion.model.ServerInfo;
/**
* @author vion
* @date 2024/10/21
*/
public interface IServerService extends MPJBaseService<ServerInfo> {
}
\ No newline at end of file \ No newline at end of file
package vion.service.impl; package vion.service.impl.monitor;
import com.github.yulichang.base.MPJBaseServiceImpl; import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import vion.mapper.ServerMapper; import vion.mapper.monitor.AgentRecordMapper;
import vion.model.ServerInfo; import vion.model.monitor.AgentRecord;
import vion.service.IServerService; import vion.service.monitor.IAgentRecordService;
/** /**
* @author vion * @author vion
* @date 2024/10/21 * @date 2024/10/31
*/ */
@Service @Service
public class ServerServiceImpl extends MPJBaseServiceImpl<ServerMapper, ServerInfo> implements IServerService { public class AgentRecordServiceImpl extends MPJBaseServiceImpl<AgentRecordMapper, AgentRecord> implements IAgentRecordService {
} }
package vion.service.impl; package vion.service.impl.monitor;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
...@@ -22,9 +22,9 @@ import org.springframework.stereotype.Service; ...@@ -22,9 +22,9 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import vion.dto.AgentDTO; import vion.dto.AgentDTO;
import vion.dto.MqttAuthDTO; import vion.dto.MqttAuthDTO;
import vion.mapper.AgentMapper; import vion.mapper.monitor.AgentMapper;
import vion.model.*; import vion.model.monitor.*;
import vion.service.*; import vion.service.monitor.*;
import vion.utils.JsonUtil; import vion.utils.JsonUtil;
import vion.vo.AgentVO; import vion.vo.AgentVO;
...@@ -41,7 +41,7 @@ import java.util.stream.Collectors; ...@@ -41,7 +41,7 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor @RequiredArgsConstructor
public class AgentServiceImpl extends MPJBaseServiceImpl<AgentMapper, Agent> implements IAgentService { public class AgentServiceImpl extends MPJBaseServiceImpl<AgentMapper, Agent> implements IAgentService {
private final IServerService serverService; private final IAgentRecordService agentRecordService;
private final IServiceInfoService serviceInfoService; private final IServiceInfoService serviceInfoService;
private final IServiceRecordService serviceRecordService; private final IServiceRecordService serviceRecordService;
private final IRAgentServiceService rAgentServiceService; private final IRAgentServiceService rAgentServiceService;
...@@ -53,8 +53,8 @@ public class AgentServiceImpl extends MPJBaseServiceImpl<AgentMapper, Agent> imp ...@@ -53,8 +53,8 @@ public class AgentServiceImpl extends MPJBaseServiceImpl<AgentMapper, Agent> imp
public Page<AgentVO> list(AgentDTO dto) { public Page<AgentVO> list(AgentDTO dto) {
var wrapper = new MPJLambdaWrapper<>(converter.convert(dto, Agent.class)) var wrapper = new MPJLambdaWrapper<>(converter.convert(dto, Agent.class))
.selectAll(Agent.class) .selectAll(Agent.class)
.selectAssociation(ServerInfo.class, AgentVO::getServerInfo) .selectAssociation(AgentRecord.class, AgentVO::getAgentRecord)
.leftJoin(ServerInfo.class, ServerInfo::getUid, Agent::getUid) .leftJoin(AgentRecord.class, AgentRecord::getAgentUid, Agent::getUid)
.orderByAsc(Agent::getCreateTime); .orderByAsc(Agent::getCreateTime);
var agentVOPage = this.selectJoinListPage(Page.of(dto.getPageNum(), dto.getPageSize()), AgentVO.class, wrapper); var agentVOPage = this.selectJoinListPage(Page.of(dto.getPageNum(), dto.getPageSize()), AgentVO.class, wrapper);
Opt.ofEmptyAble(agentVOPage.getRecords()) Opt.ofEmptyAble(agentVOPage.getRecords())
...@@ -197,14 +197,9 @@ public class AgentServiceImpl extends MPJBaseServiceImpl<AgentMapper, Agent> imp ...@@ -197,14 +197,9 @@ public class AgentServiceImpl extends MPJBaseServiceImpl<AgentMapper, Agent> imp
} }
@Override @Override
public String recServerInfo(ServerInfo serverInfo) { public String recAgentRecord(AgentRecord agentRecord) {
serverInfo.setBootTime(TimeUtil.of(serverInfo.getBootTimestamp() * 1000)); agentRecord.setBootTime(TimeUtil.of(agentRecord.getBootTimestamp() * 1000));
var one = serverService.lambdaQuery().eq(ServerInfo::getUid, serverInfo.getUid()).oneOpt(); return agentRecordService.save(agentRecord) ? "success" : "error";
if (one.isPresent()) {
return serverService.lambdaUpdate().eq(ServerInfo::getUid, serverInfo.getUid()).update(serverInfo) ? "success" : "error";
} else {
return serverService.save(serverInfo) ? "success" : "error";
}
} }
@Override @Override
...@@ -231,7 +226,7 @@ public class AgentServiceImpl extends MPJBaseServiceImpl<AgentMapper, Agent> imp ...@@ -231,7 +226,7 @@ public class AgentServiceImpl extends MPJBaseServiceImpl<AgentMapper, Agent> imp
.eq(Agent::getPassword, password) .eq(Agent::getPassword, password)
.oneOpt(); .oneOpt();
if (agent.isEmpty()) { if (agent.isEmpty()) {
log.info("Agent 认证失败: {}", dto.getClientid()); log.info("Agent 认证失败: {}", dto.getClientid());
return JsonUtil.createObj().put("result", "deny"); return JsonUtil.createObj().put("result", "deny");
} }
var obj = JsonUtil.createObj(); var obj = JsonUtil.createObj();
......
package vion.service.impl.monitor;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import vion.mapper.monitor.EventRecordMapper;
import vion.model.monitor.EventRecord;
import vion.service.monitor.IEventRecordService;
/**
* @author vion
* @date 2024/10/31
*/
@Service
public class EventRecordServiceImpl extends ServiceImpl<EventRecordMapper, EventRecord> implements IEventRecordService {
}
package vion.service.impl.monitor;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import vion.mapper.monitor.EventMapper;
import vion.model.monitor.Event;
import vion.service.monitor.IEventService;
/**
* @author vion
* @date 2024/10/31
*/
@Service
public class EventServiceImpl extends ServiceImpl<EventMapper, Event> implements IEventService {
}
package vion.service.impl.monitor;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import vion.mapper.monitor.MAccountMapper;
import vion.model.monitor.MAccount;
import vion.service.monitor.IMAccountService;
/**
* @author vion
* @date 2024/10/31
*/
@Service
public class MAccountServiceImpl extends ServiceImpl<MAccountMapper, MAccount> implements IMAccountService {
}
package vion.service.impl.monitor;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import vion.mapper.monitor.MallMapper;
import vion.model.monitor.Mall;
import vion.service.monitor.IMallService;
/**
* @author vion
* @date 2024/10/31
*/
@Service
public class MallServiceImpl extends ServiceImpl<MallMapper, Mall> implements IMallService {
}
package vion.service.impl.monitor;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import vion.mapper.monitor.RAgentEventMapper;
import vion.model.monitor.RAgentEvent;
import vion.service.monitor.IRAgentEventService;
/**
* @author vion
* @date 2024/10/31
*/
@Service
public class RAgentEventServiceImpl extends ServiceImpl<RAgentEventMapper, RAgentEvent> implements IRAgentEventService {
}
package vion.service.impl; package vion.service.impl.monitor;
import com.github.yulichang.base.MPJBaseServiceImpl; import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import vion.mapper.RAgentServiceMapper; import vion.mapper.monitor.RAgentServiceMapper;
import vion.model.RAgentService; import vion.model.monitor.RAgentService;
import vion.service.IRAgentServiceService; import vion.service.monitor.IRAgentServiceService;
/** /**
* @author vion * @author vion
* @date 2024/10/22 * @date 2024/10/22
......
package vion.service.impl; package vion.service.impl.monitor;
import com.github.yulichang.base.MPJBaseServiceImpl; import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import vion.mapper.ServiceInfoMapper; import vion.mapper.monitor.ServiceInfoMapper;
import vion.model.ServiceInfo; import vion.model.monitor.ServiceInfo;
import vion.service.IServiceInfoService; import vion.service.monitor.IServiceInfoService;
/** /**
* @author vion * @author vion
......
package vion.service.impl; package vion.service.impl.monitor;
import com.github.yulichang.base.MPJBaseServiceImpl; import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import vion.mapper.ServiceRecordMapper; import vion.mapper.monitor.ServiceRecordMapper;
import vion.model.ServiceRecord; import vion.model.monitor.ServiceRecord;
import vion.service.IServiceRecordService; import vion.service.monitor.IServiceRecordService;
/** /**
* @author vion * @author vion
* @date 2024/10/23 * @date 2024/10/23
......
package vion.service.impl; package vion.service.impl.monitor;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.dromara.hutool.core.io.ManifestUtil; import org.dromara.hutool.core.io.ManifestUtil;
...@@ -9,9 +9,9 @@ import org.dromara.hutool.core.lang.Opt; ...@@ -9,9 +9,9 @@ import org.dromara.hutool.core.lang.Opt;
import org.dromara.hutool.crypto.SecureUtil; import org.dromara.hutool.crypto.SecureUtil;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import vion.mapper.UpgradeMapper; import vion.mapper.monitor.UpgradeMapper;
import vion.model.Upgrade; import vion.model.monitor.Upgrade;
import vion.service.IUpgradeService; import vion.service.monitor.IUpgradeService;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
......
package vion.service.monitor;
import com.baomidou.mybatisplus.extension.service.IService;
import vion.model.monitor.AgentRecord;
/**
* @author vion
* @date 2024/10/31
*/
public interface IAgentRecordService extends IService<AgentRecord>{
}
package vion.service; package vion.service.monitor;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
...@@ -7,7 +7,7 @@ import com.github.yulichang.base.MPJBaseService; ...@@ -7,7 +7,7 @@ import com.github.yulichang.base.MPJBaseService;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import vion.dto.AgentDTO; import vion.dto.AgentDTO;
import vion.dto.MqttAuthDTO; import vion.dto.MqttAuthDTO;
import vion.model.*; import vion.model.monitor.*;
import vion.vo.AgentVO; import vion.vo.AgentVO;
import java.util.List; import java.util.List;
...@@ -39,7 +39,7 @@ public interface IAgentService extends MPJBaseService<Agent> { ...@@ -39,7 +39,7 @@ public interface IAgentService extends MPJBaseService<Agent> {
Upgrade getUpgradeInfo(Short type); Upgrade getUpgradeInfo(Short type);
String recServerInfo(ServerInfo serverInfo); String recAgentRecord(AgentRecord agentRecord);
String recServiceInfo(List<ServiceRecord> recList); String recServiceInfo(List<ServiceRecord> recList);
// endregion // endregion
......
package vion.service.monitor;
import com.baomidou.mybatisplus.extension.service.IService;
import vion.model.monitor.EventRecord;
/**
* @author vion
* @date 2024/10/31
*/
public interface IEventRecordService extends IService<EventRecord>{
}
package vion.service.monitor;
import com.baomidou.mybatisplus.extension.service.IService;
import vion.model.monitor.Event;
/**
* @author vion
* @date 2024/10/31
*/
public interface IEventService extends IService<Event>{
}
package vion.service.monitor;
import com.baomidou.mybatisplus.extension.service.IService;
import vion.model.monitor.MAccount;
/**
* @author vion
* @date 2024/10/31
*/
public interface IMAccountService extends IService<MAccount>{
}
package vion.service.monitor;
import com.baomidou.mybatisplus.extension.service.IService;
import vion.model.monitor.Mall;
/**
* @author vion
* @date 2024/10/31
*/
public interface IMallService extends IService<Mall>{
}
package vion.service.monitor;
import com.baomidou.mybatisplus.extension.service.IService;
import vion.model.monitor.RAgentEvent;
/**
* @author vion
* @date 2024/10/31
*/
public interface IRAgentEventService extends IService<RAgentEvent>{
}
package vion.service; package vion.service.monitor;
import com.github.yulichang.base.MPJBaseService; import com.github.yulichang.base.MPJBaseService;
import vion.model.RAgentService; import vion.model.monitor.RAgentService;
/** /**
* @author vion * @author vion
* @date 2024/10/22 * @date 2024/10/22
......
package vion.service; package vion.service.monitor;
import com.github.yulichang.base.MPJBaseService; import com.github.yulichang.base.MPJBaseService;
import vion.model.ServiceInfo; import vion.model.monitor.ServiceInfo;
/** /**
* @author vion * @author vion
......
package vion.service; package vion.service.monitor;
import com.github.yulichang.base.MPJBaseService; import com.github.yulichang.base.MPJBaseService;
import vion.model.ServiceRecord; import vion.model.monitor.ServiceRecord;
/** /**
* @author vion * @author vion
* @date 2024/10/23 * @date 2024/10/23
......
package vion.service; package vion.service.monitor;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import vion.model.Upgrade; import vion.model.monitor.Upgrade;
/** /**
* @author vion * @author vion
......
...@@ -2,7 +2,7 @@ package vion.vo; ...@@ -2,7 +2,7 @@ package vion.vo;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import vion.model.ServerInfo; import vion.model.monitor.AgentRecord;
import java.time.LocalDateTime; import java.time.LocalDateTime;
...@@ -74,7 +74,7 @@ public class AgentVO { ...@@ -74,7 +74,7 @@ public class AgentVO {
private LocalDateTime updateTime; private LocalDateTime updateTime;
private ServerInfo serverInfo; private AgentRecord agentRecord;
/** /**
* 异常的服务名称 * 异常的服务名称
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!