Noodles初版提交
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
# Project exclude paths
|
||||
/Noodles-Detector/target/
|
||||
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
@@ -0,0 +1,166 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.7.8</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.mzaxd</groupId>
|
||||
<artifactId>Noodles</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>Noodles</name>
|
||||
<description>Noodles</description>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<!--redis依赖-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<!--lombok-->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.security</groupId>
|
||||
<artifactId>spring-security-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!--fastjson依赖-->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.33</version>
|
||||
</dependency>
|
||||
<!--jwt依赖-->
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
<version>0.9.0</version>
|
||||
</dependency>
|
||||
<!--mybatisPlus依赖-->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.4.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>1.4.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>2.9.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>2.9.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.12.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-websocket</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.oshi</groupId>
|
||||
<artifactId>oshi-core</artifactId>
|
||||
<version>5.6.1</version>
|
||||
</dependency>
|
||||
<!--AOP-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.lionsoul/ip2region -->
|
||||
<dependency>
|
||||
<groupId>org.lionsoul</groupId>
|
||||
<artifactId>ip2region</artifactId>
|
||||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
<!--工具类-->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.3.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>mail</artifactId>
|
||||
<version>1.4.7</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.alibaba/easyexcel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>easyexcel</artifactId>
|
||||
<version>3.2.1</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/com.jcraft/jsch -->
|
||||
<dependency>
|
||||
<groupId>com.jcraft</groupId>
|
||||
<artifactId>jsch</artifactId>
|
||||
<version>0.1.55</version>
|
||||
</dependency>
|
||||
<!--ssh2依赖-->
|
||||
<dependency>
|
||||
<groupId>ch.ethz.ganymed</groupId>
|
||||
<artifactId>ganymed-ssh2</artifactId>
|
||||
<version>262</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.mzaxd.noodles;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
@MapperScan("com.mzaxd.noodles.mapper")
|
||||
public class NoodlesApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(NoodlesApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.mzaxd.noodles.annotation;
|
||||
|
||||
import com.mzaxd.noodles.enums.OperationEnum;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 操作日志注解
|
||||
* @author 13439
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface SysLog {
|
||||
OperationEnum operation();
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.mzaxd.noodles.aspect;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.mzaxd.noodles.annotation.SysLog;
|
||||
import com.mzaxd.noodles.domain.entity.AuditLog;
|
||||
import com.mzaxd.noodles.enums.OperationEnum;
|
||||
import com.mzaxd.noodles.service.AuditLogService;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.Method;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
*/
|
||||
@Component
|
||||
@Aspect
|
||||
public class SysLogAspect {
|
||||
|
||||
@Resource
|
||||
private AuditLogService auditLogService;
|
||||
|
||||
@Pointcut("@annotation(com.mzaxd.noodles.annotation.SysLog)")
|
||||
public void logPointCut() {
|
||||
|
||||
}
|
||||
|
||||
//方法执行前后都操作
|
||||
@Around("logPointCut()")
|
||||
public Object around(ProceedingJoinPoint point) throws Throwable {
|
||||
//执行方法
|
||||
Object result = point.proceed();
|
||||
//保存日志
|
||||
saveSysLog(point);
|
||||
return result;
|
||||
}
|
||||
|
||||
private void saveSysLog(ProceedingJoinPoint joinPoint) {
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
|
||||
AuditLog log = new AuditLog();
|
||||
SysLog syslog = method.getAnnotation(SysLog.class);
|
||||
if (syslog != null) {
|
||||
//注解上的描述
|
||||
log.setOperation(syslog.operation().getOperation());
|
||||
log.setOperationType(syslog.operation().getOperationType());
|
||||
}
|
||||
|
||||
//请求的参数
|
||||
Object[] args = joinPoint.getArgs();
|
||||
try {
|
||||
String params = JSON.toJSONString(args);
|
||||
log.setParam(params);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
//保存系统日志
|
||||
auditLogService.save(log);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.mzaxd.noodles.config;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.parser.ParserConfig;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
import com.fasterxml.jackson.databind.type.TypeFactory;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.data.redis.serializer.SerializationException;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
* Redis使用FastJson序列化
|
||||
*
|
||||
* @author sg
|
||||
*/
|
||||
public class FastJsonRedisSerializer<T> implements RedisSerializer<T> {
|
||||
|
||||
public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
|
||||
|
||||
private Class<T> clazz;
|
||||
|
||||
static {
|
||||
ParserConfig.getGlobalInstance().setAutoTypeSupport(true);
|
||||
}
|
||||
|
||||
public FastJsonRedisSerializer(Class<T> clazz) {
|
||||
super();
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] serialize(T t) throws SerializationException {
|
||||
if (t == null) {
|
||||
return new byte[0];
|
||||
}
|
||||
return JSON.toJSONString(t, SerializerFeature.WriteClassName).getBytes(DEFAULT_CHARSET);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T deserialize(byte[] bytes) throws SerializationException {
|
||||
if (bytes == null || bytes.length <= 0) {
|
||||
return null;
|
||||
}
|
||||
String str = new String(bytes, DEFAULT_CHARSET);
|
||||
|
||||
return JSON.parseObject(str, clazz);
|
||||
}
|
||||
|
||||
|
||||
protected JavaType getJavaType(Class<?> clazz) {
|
||||
return TypeFactory.defaultInstance().constructType(clazz);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.mzaxd.noodles.config;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
|
||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
@Configuration
|
||||
public class MyBatisPlusConfig {
|
||||
/**
|
||||
* 新版
|
||||
*/
|
||||
@Bean
|
||||
public MybatisPlusInterceptor mybatisPlusInterceptor() {
|
||||
MybatisPlusInterceptor mybatisPlusInterceptor = new MybatisPlusInterceptor();
|
||||
//分页插件
|
||||
mybatisPlusInterceptor.addInnerInterceptor(new PaginationInnerInterceptor());
|
||||
//乐观锁插件
|
||||
mybatisPlusInterceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
|
||||
return mybatisPlusInterceptor;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.mzaxd.noodles.config;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.mzaxd.noodles.constant.RabbitMqConstant;
|
||||
import org.springframework.amqp.core.Binding;
|
||||
import org.springframework.amqp.core.BindingBuilder;
|
||||
import org.springframework.amqp.core.DirectExchange;
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
||||
import org.springframework.amqp.support.converter.MessageConverter;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* @author Mzaxd
|
||||
* @since 2023-02-06 12:51
|
||||
*/
|
||||
@Configuration
|
||||
public class RabbitMqConfig {
|
||||
|
||||
@Bean
|
||||
public Queue rabbitmqDemoDirectQueue() {
|
||||
/**
|
||||
* 1、name: 队列名称
|
||||
* 2、durable: 是否持久化
|
||||
* 3、exclusive: 是否独享、排外的。如果设置为true,定义为排他队列。则只有创建者可以使用此队列。也就是private私有的。
|
||||
* 4、autoDelete: 是否自动删除。也就是临时队列。当最后一个消费者断开连接后,会自动删除。
|
||||
* */
|
||||
return new Queue(RabbitMqConstant.DYNAMIC_DATA_TOPIC, true, false, false);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public DirectExchange rabbitmqDemoDirectExchange() {
|
||||
//Direct交换机
|
||||
return new DirectExchange(RabbitMqConstant.DYNAMIC_DATA_EXCHANGE, true, false);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public Binding bindDirect() {
|
||||
//链式写法,绑定交换机和队列,并设置匹配键
|
||||
return BindingBuilder
|
||||
//绑定队列
|
||||
.bind(rabbitmqDemoDirectQueue())
|
||||
//到交换机
|
||||
.to(rabbitmqDemoDirectExchange())
|
||||
//并设置匹配键
|
||||
.with(RabbitMqConstant.DYNAMIC_DATA_ROUTING);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MessageConverter jsonMessageConverter(ObjectMapper objectMapper) {
|
||||
return new Jackson2JsonMessageConverter(objectMapper);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.mzaxd.noodles.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
@Configuration
|
||||
public class RedisConfig {
|
||||
|
||||
@Bean
|
||||
@SuppressWarnings(value = {"unchecked", "rawtypes"})
|
||||
public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
|
||||
RedisTemplate<Object, Object> template = new RedisTemplate<>();
|
||||
template.setConnectionFactory(connectionFactory);
|
||||
|
||||
FastJsonRedisSerializer serializer = new FastJsonRedisSerializer(Object.class);
|
||||
|
||||
// 使用StringRedisSerializer来序列化和反序列化redis的key值
|
||||
template.setKeySerializer(new StringRedisSerializer());
|
||||
template.setValueSerializer(serializer);
|
||||
|
||||
// Hash的key也采用StringRedisSerializer的序列化方式
|
||||
template.setHashKeySerializer(new StringRedisSerializer());
|
||||
template.setHashValueSerializer(serializer);
|
||||
|
||||
template.afterPropertiesSet();
|
||||
return template;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.mzaxd.noodles.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
@Configuration
|
||||
public class RestTemplateConfig {
|
||||
|
||||
@Bean
|
||||
public RestTemplate restTemplate(ClientHttpRequestFactory factory){
|
||||
return new RestTemplate(factory);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHttpRequestFactory simpleClientHttpRequestFactory(){
|
||||
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
|
||||
//单位为ms
|
||||
factory.setReadTimeout(5000);
|
||||
//单位为ms
|
||||
factory.setConnectTimeout(5000);
|
||||
return factory;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.mzaxd.noodles.config;
|
||||
|
||||
import com.mzaxd.noodles.filter.JwtAuthenticationTokenFilter;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.WebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.config.http.SessionCreationPolicy;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.security.web.AuthenticationEntryPoint;
|
||||
import org.springframework.security.web.access.AccessDeniedHandler;
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
@Configuration
|
||||
public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Bean
|
||||
public PasswordEncoder passwordEncoder(){
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
@Resource
|
||||
private JwtAuthenticationTokenFilter jwtAuthenticationTokenFilter;
|
||||
|
||||
@Resource
|
||||
private AuthenticationEntryPoint authenticationEntryPoint;
|
||||
|
||||
@Resource
|
||||
private AccessDeniedHandler accessDeniedHandler;
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity http) throws Exception {
|
||||
http
|
||||
//关闭csrf
|
||||
.csrf().disable()
|
||||
//不通过Session获取SecurityContext
|
||||
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
|
||||
.and()
|
||||
.authorizeRequests()
|
||||
// 对于登录接口 允许匿名访问
|
||||
.antMatchers("/auth/login").permitAll()
|
||||
.antMatchers("/ws/**").permitAll()
|
||||
.antMatchers("/system/isFirstUse").permitAll()
|
||||
// 除上面外的所有请求全部需要鉴权认证
|
||||
.anyRequest().authenticated();
|
||||
|
||||
http.exceptionHandling()
|
||||
.authenticationEntryPoint(authenticationEntryPoint)
|
||||
.accessDeniedHandler(accessDeniedHandler);
|
||||
|
||||
|
||||
http.logout().disable();
|
||||
|
||||
http.addFilterBefore(jwtAuthenticationTokenFilter, UsernamePasswordAuthenticationFilter.class);
|
||||
//允许跨域
|
||||
http.cors();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Bean
|
||||
public AuthenticationManager authenticationManagerBean() throws Exception {
|
||||
return super.authenticationManagerBean();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.mzaxd.noodles.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.Contact;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
@Configuration
|
||||
public class SwaggerConfig {
|
||||
@Bean
|
||||
public Docket customDocket() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("com.mzaxd.controller"))
|
||||
.build();
|
||||
}
|
||||
private ApiInfo apiInfo() {
|
||||
Contact contact = new Contact("一个人的团队", "http://www.my.com", "my@my.com");
|
||||
return new ApiInfoBuilder()
|
||||
.title("文档标题")
|
||||
.description("文档描述")
|
||||
.contact(contact) // 联系方式
|
||||
.version("1.0.0") // 版本
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.mzaxd.noodles.config;
|
||||
|
||||
import com.alibaba.fastjson.serializer.SerializeConfig;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.alibaba.fastjson.serializer.ToStringSerializer;
|
||||
import com.alibaba.fastjson.support.config.FastJsonConfig;
|
||||
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Mzaxd
|
||||
*/
|
||||
@Configuration
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
// 设置允许跨域的路径
|
||||
registry.addMapping("/**")
|
||||
// 设置允许跨域请求的域名
|
||||
.allowedOriginPatterns("*")
|
||||
// 是否允许cookie
|
||||
.allowCredentials(true)
|
||||
// 设置允许的请求方式
|
||||
.allowedMethods("GET", "POST", "DELETE", "PUT")
|
||||
// 设置允许的header属性
|
||||
.allowedHeaders("*")
|
||||
// 跨域允许时间
|
||||
.maxAge(3600);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public HttpMessageConverter fastJsonHttpMessageConverters() {
|
||||
//1.需要定义一个Convert转换消息的对象
|
||||
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
|
||||
FastJsonConfig fastJsonConfig = new FastJsonConfig();
|
||||
fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat);
|
||||
fastJsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
SerializeConfig.globalInstance.put(Long.class, ToStringSerializer.instance);
|
||||
|
||||
fastJsonConfig.setSerializeConfig(SerializeConfig.globalInstance);
|
||||
fastConverter.setFastJsonConfig(fastJsonConfig);
|
||||
HttpMessageConverter<?> converter = fastConverter;
|
||||
return converter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
||||
converters.add(fastJsonHttpMessageConverters());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.mzaxd.noodles.config;
|
||||
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.web.servlet.ServletContextInitializer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
|
||||
import org.springframework.web.util.WebAppRootListener;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
/**
|
||||
* @author Mzaxd
|
||||
* @since 2023-02-05 15:35
|
||||
*/
|
||||
@Configuration
|
||||
@ComponentScan
|
||||
@EnableAutoConfiguration
|
||||
public class WebSocketConfig implements ServletContextInitializer {
|
||||
|
||||
@Bean
|
||||
public ServerEndpointExporter serverEndpointExporter() {
|
||||
return new ServerEndpointExporter();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStartup(ServletContext servletContext) throws ServletException {
|
||||
servletContext.addListener(WebAppRootListener.class);
|
||||
servletContext.setInitParameter("org.apache.tomcat.websocket.textBufferSize","52428800");
|
||||
servletContext.setInitParameter("org.apache.tomcat.websocket.binaryBufferSize","52428800");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.mzaxd.noodles.constant;
|
||||
|
||||
/**
|
||||
* @author Mzaxd
|
||||
* @since 2023-02-05 11:38
|
||||
*/
|
||||
public class OsConstant {
|
||||
|
||||
/**
|
||||
* 操作系统为Linux
|
||||
*/
|
||||
public static final String LINUX = "linux";
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.mzaxd.noodles.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";
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.mzaxd.noodles.constant;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
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";
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
package com.mzaxd.noodles.constant;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* 正常状态(非第一次使用) 通用常量
|
||||
*/
|
||||
public static final Integer NORMAL_STATE = 1;
|
||||
|
||||
/**
|
||||
* 日志类型为用户
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* 未处理的通知
|
||||
*/
|
||||
public static final Integer NOTIFICATION_NOT_AFFIRM = 0;
|
||||
|
||||
/**
|
||||
* 已处理的通知
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
* 通知实例类型 物理机
|
||||
*/
|
||||
public static final Integer INSTANCETYPE_HOST = 1;
|
||||
|
||||
/**
|
||||
* 通知实例类型 虚拟机
|
||||
*/
|
||||
public static final Integer INSTANCETYPE_VM = 2;
|
||||
|
||||
/**
|
||||
* 通知实例类型 容器
|
||||
*/
|
||||
public static final Integer INSTANCETYPE_CONTAINER = 3;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.mzaxd.noodles.constant;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
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";
|
||||
|
||||
/**
|
||||
* 协议
|
||||
*/
|
||||
public static final String PROTOCOL = "protocol";
|
||||
|
||||
/**
|
||||
* ip
|
||||
*/
|
||||
public static final String IP = "IP";
|
||||
|
||||
/**
|
||||
* 端口号
|
||||
*/
|
||||
public static final String PORT = "port";
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.mzaxd.noodles.controller;
|
||||
|
||||
import com.mzaxd.noodles.annotation.SysLog;
|
||||
import com.mzaxd.noodles.domain.ResponseResult;
|
||||
import com.mzaxd.noodles.domain.entity.User;
|
||||
import com.mzaxd.noodles.enums.OperationEnum;
|
||||
import com.mzaxd.noodles.service.LoginService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/auth")
|
||||
public class AuthController {
|
||||
|
||||
@Resource
|
||||
private LoginService loginService;
|
||||
|
||||
@PostMapping("/login")
|
||||
public ResponseResult login(@RequestBody User user) {
|
||||
return loginService.login(user);
|
||||
}
|
||||
|
||||
@SysLog(operation = OperationEnum.USER_FIRST_USE)
|
||||
@PostMapping("/updateAccount")
|
||||
public ResponseResult updateAccount(@RequestBody User user) {
|
||||
return loginService.updateAccount(user);
|
||||
}
|
||||
|
||||
@PostMapping("/logout")
|
||||
public ResponseResult logout() {
|
||||
return loginService.logout();
|
||||
}
|
||||
|
||||
@GetMapping("/deleteAccount")
|
||||
public ResponseResult deleteAccount() {
|
||||
return loginService.deleteAccount();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.mzaxd.noodles.controller;
|
||||
|
||||
import com.mzaxd.noodles.annotation.SysLog;
|
||||
import com.mzaxd.noodles.domain.ResponseResult;
|
||||
import com.mzaxd.noodles.domain.vo.ContainerVo;
|
||||
import com.mzaxd.noodles.enums.OperationEnum;
|
||||
import com.mzaxd.noodles.service.ContainerService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/container")
|
||||
public class ContainerController {
|
||||
|
||||
@Resource
|
||||
private ContainerService containerService;
|
||||
|
||||
@GetMapping("/containerList/summaryStatistics")
|
||||
public ResponseResult containerListSummaryStatistics() {
|
||||
return containerService.containerListSummaryStatistics();
|
||||
}
|
||||
|
||||
@GetMapping("/containerList")
|
||||
public ResponseResult containerListWithCondition(
|
||||
@RequestParam(value = "q", required = false) String nameLike,
|
||||
@RequestParam(value = "selectedHost", required = false) List<Integer> selectedHost,
|
||||
@RequestParam(value = "selectedStatus", required = false) List<Integer> selectedStatus,
|
||||
@RequestParam("perPage") Integer perPage,
|
||||
@RequestParam("currentPage") Integer currentPage) {
|
||||
return containerService.containerListWithCondition(nameLike, selectedHost, selectedStatus, perPage, currentPage);
|
||||
}
|
||||
|
||||
@GetMapping("/allHost")
|
||||
public ResponseResult hostDrawer() {
|
||||
return containerService.getAllHost();
|
||||
}
|
||||
|
||||
@SysLog(operation = OperationEnum.CONTAINER_DELETE)
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseResult deleteContainer(@PathVariable("id") Integer id) {
|
||||
return containerService.deleteContainerById(id);
|
||||
}
|
||||
|
||||
@SysLog(operation = OperationEnum.CONTAINER_ADD)
|
||||
@PostMapping("/addContainer")
|
||||
public ResponseResult addContainer(@RequestBody Map<String, ContainerVo> container) {
|
||||
return containerService.addContainer(container.get("container"));
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseResult getContainer(@PathVariable("id") Integer id) {
|
||||
return containerService.getContainer(id);
|
||||
}
|
||||
@SysLog(operation = OperationEnum.CONTAINER_UPDATE)
|
||||
@PostMapping("/updateContainer")
|
||||
public ResponseResult updateVm(@RequestBody Map<String, ContainerVo> container) {
|
||||
return containerService.updateContainer(container.get("container"));
|
||||
}
|
||||
|
||||
@GetMapping("/allContainer")
|
||||
public ResponseResult allContainer() {
|
||||
return containerService.getAllContainer();
|
||||
}
|
||||
|
||||
@GetMapping("/associatedContainers")
|
||||
public ResponseResult getAssociatedContainers(
|
||||
@RequestParam("hostId") Integer hostId,
|
||||
@RequestParam("perPage") Integer perPage,
|
||||
@RequestParam("currentPage") Integer currentPage) {
|
||||
return containerService.getAssociatedContainers(hostId, perPage, currentPage);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.mzaxd.noodles.controller;
|
||||
|
||||
import com.mzaxd.noodles.domain.ResponseResult;
|
||||
import com.mzaxd.noodles.service.DashboardService;
|
||||
import com.mzaxd.noodles.service.EveryDayDataService;
|
||||
import com.mzaxd.noodles.service.HostDetectorService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/dashboard")
|
||||
public class DashboardController {
|
||||
|
||||
@Resource
|
||||
private HostDetectorService detectorService;
|
||||
|
||||
@Resource
|
||||
private EveryDayDataService everyDayDataService;
|
||||
|
||||
@Resource
|
||||
private DashboardService dashboardService;
|
||||
|
||||
@GetMapping("/getMemInfo")
|
||||
public ResponseResult getMemInfo() {
|
||||
return detectorService.getMemInfo();
|
||||
}
|
||||
|
||||
@GetMapping("/getAuditLogCountYesterday")
|
||||
public ResponseResult getAuditLogCountYesterday() {
|
||||
return everyDayDataService.getAuditLogCountYesterday();
|
||||
}
|
||||
|
||||
@GetMapping("/getInstancesHistory")
|
||||
public ResponseResult getInstancesHistory() {
|
||||
return everyDayDataService.getInstancesHistory();
|
||||
}
|
||||
|
||||
@GetMapping("/getInstancesRealTimeData")
|
||||
public ResponseResult getInstancesRealTimeData() {
|
||||
return dashboardService.getInstancesRealTimeData();
|
||||
}
|
||||
|
||||
@GetMapping("/getRecentConsoleList")
|
||||
public ResponseResult getRecentConsoleList() {
|
||||
return dashboardService.getRecentConsoleList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.mzaxd.noodles.controller;
|
||||
|
||||
|
||||
import com.mzaxd.noodles.constant.UrlConstant;
|
||||
import com.mzaxd.noodles.domain.ResponseResult;
|
||||
import com.mzaxd.noodles.service.HostDetectorService;
|
||||
import com.mzaxd.noodles.util.UrlUtil;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/detector")
|
||||
public class DetectorController {
|
||||
|
||||
@Resource
|
||||
private HostDetectorService hostDetectorService;
|
||||
|
||||
@GetMapping("/isValidUrl/{protocol}/{ip}/{port}")
|
||||
public ResponseResult isValidUrl(@PathVariable String protocol,@PathVariable String ip, @PathVariable String port) {
|
||||
return hostDetectorService.isValidUrl(protocol,ip,port);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package com.mzaxd.noodles.controller;
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.mzaxd.noodles.annotation.SysLog;
|
||||
import com.mzaxd.noodles.domain.ResponseResult;
|
||||
import com.mzaxd.noodles.domain.entity.HostMachine;
|
||||
import com.mzaxd.noodles.domain.vo.HostVo;
|
||||
import com.mzaxd.noodles.domain.vo.VmVo;
|
||||
import com.mzaxd.noodles.enums.AppHttpCodeEnum;
|
||||
import com.mzaxd.noodles.enums.OperationEnum;
|
||||
import com.mzaxd.noodles.service.HostMachineService;
|
||||
import com.mzaxd.noodles.util.WebUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/host")
|
||||
public class HostController {
|
||||
|
||||
@Resource
|
||||
private HostMachineService hostMachineService;
|
||||
|
||||
@GetMapping("/drawer")
|
||||
public ResponseResult hostDrawer() {
|
||||
return hostMachineService.getHostDrawer();
|
||||
}
|
||||
|
||||
@GetMapping("/vmList")
|
||||
public ResponseResult vmListWithCondition(
|
||||
@RequestParam(value = "q", required = false) String nameLike,
|
||||
@RequestParam(value = "selectedKernel", required = false) List<Integer> selectedKernel,
|
||||
@RequestParam(value = "selectedHost", required = false) List<Integer> selectedHost,
|
||||
@RequestParam(value = "selectedStatus", required = false) List<Integer> selectedStatus,
|
||||
@RequestParam("perPage") Integer perPage,
|
||||
@RequestParam("currentPage") Integer currentPage) {
|
||||
return hostMachineService.vmListWithCondition(nameLike, selectedKernel, selectedHost, selectedStatus, perPage, currentPage);
|
||||
}
|
||||
|
||||
@GetMapping("/vmList/summaryStatistics")
|
||||
public ResponseResult vmListSummaryStatistics() {
|
||||
return hostMachineService.vmListSummaryStatistics();
|
||||
}
|
||||
|
||||
@SysLog(operation = OperationEnum.VM_ADD)
|
||||
@PostMapping("/addVm")
|
||||
public ResponseResult addVm(@RequestBody Map<String, VmVo> vmVo) {
|
||||
return hostMachineService.addVm(vmVo.get("vm"));
|
||||
}
|
||||
|
||||
@SysLog(operation = OperationEnum.VM_UPDATE)
|
||||
@PostMapping("/updateVm")
|
||||
public ResponseResult updateVm(@RequestBody Map<String, VmVo> vmVo) {
|
||||
return hostMachineService.updateVm(vmVo.get("vm"));
|
||||
}
|
||||
|
||||
@SysLog(operation = OperationEnum.VM_DELETE)
|
||||
@DeleteMapping("/deleteVm/{id}")
|
||||
public ResponseResult deleteVm(@PathVariable("id") Integer id) {
|
||||
return hostMachineService.deleteVmById(id);
|
||||
}
|
||||
|
||||
@SysLog(operation = OperationEnum.HOST_DELETE)
|
||||
@DeleteMapping("/deleteHost/{id}")
|
||||
public ResponseResult deleteHost(@PathVariable("id") Integer id) {
|
||||
return hostMachineService.deleteHostById(id);
|
||||
}
|
||||
|
||||
@GetMapping("/vm/{id}")
|
||||
public ResponseResult<VmVo> getVmById(@PathVariable("id") Integer id) {
|
||||
return hostMachineService.getVmById(id);
|
||||
}
|
||||
|
||||
@SysLog(operation = OperationEnum.HOST_UPDATE)
|
||||
@PostMapping("/updateHost")
|
||||
public ResponseResult updateHost(@RequestBody Map<String, HostVo> hostVo) {
|
||||
return hostMachineService.updateHost(hostVo.get("host"));
|
||||
}
|
||||
|
||||
@GetMapping("/host/{id}")
|
||||
public ResponseResult<HostVo> getHostById(@PathVariable("id") Integer id) {
|
||||
return hostMachineService.getHostById(id);
|
||||
}
|
||||
|
||||
@GetMapping("/hostList")
|
||||
public ResponseResult vmListWithCondition(
|
||||
@RequestParam(value = "q", required = false) String nameLike,
|
||||
@RequestParam(value = "selectedStatus", required = false) List<Integer> selectedStatus,
|
||||
@RequestParam("perPage") Integer perPage,
|
||||
@RequestParam("currentPage") Integer currentPage) {
|
||||
return hostMachineService.hostListWithCondition(nameLike, selectedStatus, perPage, currentPage);
|
||||
}
|
||||
|
||||
@SysLog(operation = OperationEnum.HOST_ADD)
|
||||
@PostMapping("/addHost")
|
||||
public ResponseResult addHost(@RequestBody Map<String, HostVo> hostVo) {
|
||||
return hostMachineService.addHost(hostVo.get("host"));
|
||||
}
|
||||
|
||||
@GetMapping("/hostDetail/{id}")
|
||||
public ResponseResult getHostDetail(@PathVariable("id") Integer id) {
|
||||
return hostMachineService.getHostDetail(id);
|
||||
}
|
||||
|
||||
@GetMapping("/associatedVms")
|
||||
public ResponseResult getAssociatedVms(
|
||||
@RequestParam("hostId") Integer hostId,
|
||||
@RequestParam("perPage") Integer perPage,
|
||||
@RequestParam("currentPage") Integer currentPage) {
|
||||
return hostMachineService.getAssociatedVms(hostId, perPage, currentPage);
|
||||
}
|
||||
|
||||
@GetMapping("/associatedDisks/{id}")
|
||||
public ResponseResult getAssociatedDisks(@PathVariable("id") Integer id){
|
||||
return hostMachineService.getAssociatedDisks(id);
|
||||
}
|
||||
|
||||
@GetMapping("/associatedNetworkIfs/{id}")
|
||||
public ResponseResult getAssociatedNetworkIfs(@PathVariable("id") Integer id) {
|
||||
return hostMachineService.getAssociatedNetworkIfs(id);
|
||||
}
|
||||
|
||||
@GetMapping("/startSendDynamicData/{id}")
|
||||
public ResponseResult startSendDynamicData(@PathVariable("id") Integer hostId) {
|
||||
return hostMachineService.startSendDynamicData(hostId);
|
||||
}
|
||||
|
||||
@GetMapping("/stopSendDynamicData/{id}")
|
||||
public ResponseResult stopSendDynamicData(@PathVariable("id") Integer hostId) {
|
||||
return hostMachineService.stopSendDynamicData(hostId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.mzaxd.noodles.controller;
|
||||
|
||||
import com.mzaxd.noodles.domain.ResponseResult;
|
||||
import com.mzaxd.noodles.service.AuditLogService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/auditLog")
|
||||
public class LogController {
|
||||
|
||||
@Resource
|
||||
private AuditLogService auditLogService;
|
||||
|
||||
@GetMapping("/logList")
|
||||
public ResponseResult getLogList(@RequestParam("perPage") Integer perPage,
|
||||
@RequestParam("currentPage") Integer currentPage) {
|
||||
return auditLogService.getLogList(perPage, currentPage);
|
||||
}
|
||||
|
||||
@GetMapping("/getParam/{id}")
|
||||
public ResponseResult getParam(@PathVariable("id") Integer id) {
|
||||
return auditLogService.getParam(id);
|
||||
}
|
||||
|
||||
@GetMapping("/userLog")
|
||||
public ResponseResult getUserLog() {
|
||||
return auditLogService.getUserLog();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.mzaxd.noodles.controller;
|
||||
|
||||
import com.mzaxd.noodles.annotation.SysLog;
|
||||
import com.mzaxd.noodles.domain.ResponseResult;
|
||||
import com.mzaxd.noodles.enums.OperationEnum;
|
||||
import com.mzaxd.noodles.service.NotificationService;
|
||||
import io.swagger.models.auth.In;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/notification")
|
||||
public class NotificationController {
|
||||
|
||||
@Resource
|
||||
private NotificationService notificationService;
|
||||
|
||||
@GetMapping("/notificationList")
|
||||
public ResponseResult getNotificationList(
|
||||
@RequestParam(value = "tab", required = false) Integer tab,
|
||||
@RequestParam("perPage") Integer perPage,
|
||||
@RequestParam("currentPage") Integer currentPage) {
|
||||
return notificationService.getNotificationList(tab, perPage, currentPage);
|
||||
}
|
||||
|
||||
@SysLog(operation = OperationEnum.NOTIFICATION_AFFIRM)
|
||||
@PutMapping("/{id}")
|
||||
public ResponseResult affirmNotification(@PathVariable("id") Long id) {
|
||||
return notificationService.affirmNotification(id);
|
||||
}
|
||||
|
||||
@GetMapping("/count")
|
||||
public ResponseResult getNotificationCount() {
|
||||
return notificationService.getNotificationCount();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.mzaxd.noodles.controller;
|
||||
|
||||
import com.mzaxd.noodles.annotation.SysLog;
|
||||
import com.mzaxd.noodles.domain.ResponseResult;
|
||||
import com.mzaxd.noodles.domain.vo.SaveOrUpdateServirVo;
|
||||
import com.mzaxd.noodles.enums.OperationEnum;
|
||||
import com.mzaxd.noodles.service.ServirService;
|
||||
import com.mzaxd.noodles.service.TagService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/servir")
|
||||
public class ServirController {
|
||||
|
||||
@Resource
|
||||
private TagService tagService;
|
||||
|
||||
@Resource
|
||||
private ServirService servirService;
|
||||
|
||||
|
||||
@GetMapping("/tags")
|
||||
public ResponseResult getAllTag() {
|
||||
return tagService.getAllTag();
|
||||
}
|
||||
|
||||
@GetMapping("/servirList")
|
||||
public ResponseResult servirListWithCondition(
|
||||
@RequestParam(value = "q", required = false) String nameLike,
|
||||
@RequestParam(value = "selectedTags", required = false) List<Integer> selectedTags,
|
||||
@RequestParam("perPage") Integer perPage,
|
||||
@RequestParam("currentPage") Integer currentPage) {
|
||||
return servirService.servirListWithCondition(nameLike, selectedTags, perPage, currentPage);
|
||||
}
|
||||
|
||||
@SysLog(operation = OperationEnum.SERVIR_ADD)
|
||||
@PostMapping("/addServir")
|
||||
public ResponseResult addServir(@RequestBody Map<String,SaveOrUpdateServirVo> saveOrUpdateServirVoMap) {
|
||||
return servirService.addServir(saveOrUpdateServirVoMap.get("servir"));
|
||||
}
|
||||
@SysLog(operation = OperationEnum.SERVIR_UPDATE)
|
||||
@PostMapping("/updateServir")
|
||||
public ResponseResult updateServir(@RequestBody Map<String,SaveOrUpdateServirVo> saveOrUpdateServirVoMap) {
|
||||
return servirService.updateServir(saveOrUpdateServirVoMap.get("servir"));
|
||||
}
|
||||
|
||||
@SysLog(operation = OperationEnum.SERVIR_DELETE)
|
||||
@DeleteMapping("/deleteServir/{id}")
|
||||
public ResponseResult deleteServir(@PathVariable("id") Integer id) {
|
||||
return servirService.deleteServirById(id);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseResult getServirDataById(@PathVariable("id") Integer id) {
|
||||
return servirService.getServirById(id);
|
||||
}
|
||||
|
||||
@GetMapping("/getRemark/{id}")
|
||||
public ResponseResult getRemarkById(@PathVariable("id") Integer id) {
|
||||
return servirService.getRemarkById(id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.mzaxd.noodles.controller;
|
||||
|
||||
import com.mzaxd.noodles.domain.ResponseResult;
|
||||
import com.mzaxd.noodles.domain.vo.SmtpVo;
|
||||
import com.mzaxd.noodles.domain.vo.SystemVo;
|
||||
import com.mzaxd.noodles.domain.vo.TerminalVo;
|
||||
import com.mzaxd.noodles.service.SystemSettingService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/setting")
|
||||
public class SettingController {
|
||||
|
||||
@Resource
|
||||
private SystemSettingService systemSettingService;
|
||||
|
||||
@GetMapping("/smtp")
|
||||
public ResponseResult getSmtpSetting() {
|
||||
return systemSettingService.getSmtpSetting();
|
||||
}
|
||||
|
||||
@PostMapping("/smtp")
|
||||
public ResponseResult saveSmtpSetting(@RequestBody SmtpVo smtpVo) {
|
||||
return systemSettingService.saveSmtpSetting(smtpVo);
|
||||
}
|
||||
@GetMapping("/terminal")
|
||||
public ResponseResult getTerminalSetting() {
|
||||
return systemSettingService.getTerminalSetting();
|
||||
}
|
||||
|
||||
@PostMapping("/terminal")
|
||||
public ResponseResult saveTerminalSetting(@RequestBody TerminalVo terminalVo) {
|
||||
return systemSettingService.saveTerminalSetting(terminalVo);
|
||||
}
|
||||
|
||||
@GetMapping("/system")
|
||||
public ResponseResult getSystemSetting() {
|
||||
return systemSettingService.getSystemSetting();
|
||||
}
|
||||
|
||||
@PostMapping("/system")
|
||||
public ResponseResult saveSystemSetting(@RequestBody SystemVo systemVo) {
|
||||
return systemSettingService.saveSystemSetting(systemVo);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.mzaxd.noodles.controller;
|
||||
|
||||
import com.mzaxd.noodles.annotation.SysLog;
|
||||
import com.mzaxd.noodles.domain.ResponseResult;
|
||||
import com.mzaxd.noodles.enums.OperationEnum;
|
||||
import com.mzaxd.noodles.service.SshLinkService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sshLink")
|
||||
public class SshLinkController {
|
||||
|
||||
@Resource
|
||||
private SshLinkService sshLinkService;
|
||||
|
||||
@SysLog(operation = OperationEnum.CONSOLE_CONNECT)
|
||||
@GetMapping("/getInstanceInfo/{sshId}")
|
||||
public ResponseResult getInstanceInfo(@PathVariable("sshId") Long sshId) {
|
||||
return sshLinkService.getInstanceInfo(sshId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.mzaxd.noodles.controller;
|
||||
|
||||
import com.mzaxd.noodles.domain.ResponseResult;
|
||||
import com.mzaxd.noodles.service.UserService;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/system")
|
||||
public class SystemController {
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@RequestMapping("/isFirstUse")
|
||||
private ResponseResult isFirstUse() {
|
||||
return userService.isFirstUse();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.mzaxd.noodles.controller;
|
||||
|
||||
import com.mzaxd.noodles.domain.ResponseResult;
|
||||
import com.mzaxd.noodles.service.TagService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/tag")
|
||||
public class TagController {
|
||||
|
||||
@Resource
|
||||
private TagService tagService;
|
||||
|
||||
@GetMapping("/allTag")
|
||||
public ResponseResult getAllTag() {
|
||||
return tagService.getAllTag();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.mzaxd.noodles.controller;
|
||||
|
||||
import com.mzaxd.noodles.annotation.SysLog;
|
||||
import com.mzaxd.noodles.domain.ResponseResult;
|
||||
import com.mzaxd.noodles.domain.entity.User;
|
||||
import com.mzaxd.noodles.domain.vo.UserInfoVo;
|
||||
import com.mzaxd.noodles.enums.OperationEnum;
|
||||
import com.mzaxd.noodles.service.UserService;
|
||||
import com.mzaxd.noodles.util.IpUtil;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
public class UserController {
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
@GetMapping("/userInfo")
|
||||
public ResponseResult userInfo() {
|
||||
return userService.userInfo();
|
||||
}
|
||||
|
||||
@PutMapping("/userInfo")
|
||||
public ResponseResult updateUserInfo(@RequestBody User user) {
|
||||
return userService.updateUserInfo(user);
|
||||
}
|
||||
|
||||
@GetMapping("/profileHeader/{id}")
|
||||
public ResponseResult profileHeader(@PathVariable("id") Integer id, HttpServletRequest request) {
|
||||
String ipAddr = IpUtil.getIpAddr(request);
|
||||
return userService.getProfileHeader(id, ipAddr);
|
||||
}
|
||||
|
||||
@GetMapping("/profile")
|
||||
public ResponseResult profile() {
|
||||
return userService.getProfile();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseResult getUserInfo(@PathVariable("id") Integer id) {
|
||||
return userService.getUserInfo(id);
|
||||
}
|
||||
|
||||
@SysLog(operation = OperationEnum.USER_UPDATE_PASSWORD)
|
||||
@PostMapping("/changePassword")
|
||||
public ResponseResult changePassword(@RequestBody Map<String, String> map) {
|
||||
return userService.changePassword(map.get("password"));
|
||||
}
|
||||
|
||||
@SysLog(operation = OperationEnum.USER_UPDATE_USERINFO)
|
||||
@PostMapping("/updateUserInfo")
|
||||
public ResponseResult updateUserInfo(@RequestBody Map<String, UserInfoVo> map) {
|
||||
return userService.updateUserInfo(map.get("user"));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
package com.mzaxd.noodles.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.mzaxd.noodles.enums.AppHttpCodeEnum;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Mzaxd
|
||||
*/
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ResponseResult<T> implements Serializable {
|
||||
private Integer code;
|
||||
private String msg;
|
||||
private T data;
|
||||
|
||||
public ResponseResult() {
|
||||
this.code = AppHttpCodeEnum.SUCCESS.getCode();
|
||||
this.msg = AppHttpCodeEnum.SUCCESS.getMsg();
|
||||
}
|
||||
|
||||
public ResponseResult(Integer code, T data) {
|
||||
this.code = code;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public ResponseResult(Integer code, String msg, T data) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public ResponseResult(Integer code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public static ResponseResult errorResult(int code, String msg) {
|
||||
ResponseResult result = new ResponseResult();
|
||||
return result.error(code, msg);
|
||||
}
|
||||
public static ResponseResult okResult() {
|
||||
ResponseResult result = new ResponseResult();
|
||||
return result;
|
||||
}
|
||||
public static ResponseResult okResult(int code, String msg) {
|
||||
ResponseResult result = new ResponseResult();
|
||||
return result.ok(code, null, msg);
|
||||
}
|
||||
public static ResponseResult okResult(String msg, Object data) {
|
||||
ResponseResult result = setAppHttpCodeEnum(AppHttpCodeEnum.SUCCESS);
|
||||
result.setMsg(msg);
|
||||
if(data!=null) {
|
||||
result.setData(data);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ResponseResult okResult(Object data) {
|
||||
ResponseResult result = setAppHttpCodeEnum(AppHttpCodeEnum.SUCCESS, AppHttpCodeEnum.SUCCESS.getMsg());
|
||||
if(data!=null) {
|
||||
result.setData(data);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static ResponseResult errorResult(AppHttpCodeEnum enums){
|
||||
return setAppHttpCodeEnum(enums,enums.getMsg());
|
||||
}
|
||||
|
||||
public static ResponseResult errorResult(AppHttpCodeEnum enums, String msg){
|
||||
return setAppHttpCodeEnum(enums,msg);
|
||||
}
|
||||
|
||||
public static ResponseResult setAppHttpCodeEnum(AppHttpCodeEnum enums){
|
||||
return okResult(enums.getCode(),enums.getMsg());
|
||||
}
|
||||
|
||||
private static ResponseResult setAppHttpCodeEnum(AppHttpCodeEnum enums, String msg){
|
||||
return okResult(enums.getCode(),msg);
|
||||
}
|
||||
|
||||
public ResponseResult<?> error(Integer code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResponseResult<?> ok(Integer code, T data) {
|
||||
this.code = code;
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResponseResult<?> ok(Integer code, T data, String msg) {
|
||||
this.code = code;
|
||||
this.data = data;
|
||||
this.msg = msg;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ResponseResult<?> ok(T data) {
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.mzaxd.noodles.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 13439
|
||||
* @TableName audit_log
|
||||
*/
|
||||
@TableName(value ="audit_log")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(of = "param")
|
||||
public class AuditLog implements Serializable {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 操作
|
||||
*/
|
||||
private String operation;
|
||||
|
||||
/**
|
||||
* 操作类型(用户/容器/虚拟机/物理机/服务/系统)
|
||||
*/
|
||||
private String operationType;
|
||||
|
||||
/**
|
||||
* 请求参数
|
||||
*/
|
||||
private String param;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Long createBy;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package com.mzaxd.noodles.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 13439
|
||||
* @TableName container
|
||||
*/
|
||||
@TableName(value ="container")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class Container implements Serializable {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 图像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 镜像名
|
||||
*/
|
||||
private String imageName;
|
||||
|
||||
/**
|
||||
* WebUi URL
|
||||
*/
|
||||
private String webUi;
|
||||
|
||||
/**
|
||||
* 宿主机id
|
||||
*/
|
||||
private Long hostMachineId;
|
||||
|
||||
/**
|
||||
* ssh连接信息表id
|
||||
*/
|
||||
private Long sshId;
|
||||
|
||||
/**
|
||||
* 状态(0运行 1停止 2暂停 3未知)
|
||||
*/
|
||||
private Integer containerState;
|
||||
|
||||
/**
|
||||
* 提醒方式(0不提醒 1浏览器 2邮件 3浏览器&邮件)
|
||||
*/
|
||||
private Integer notify;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新人id
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表未删除,1代表已删除)
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
/**
|
||||
* 容器编号
|
||||
*/
|
||||
private String containerId;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
package com.mzaxd.noodles.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 13439
|
||||
* @TableName every_data
|
||||
*/
|
||||
@TableName(value ="everyday_data")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class EveryDayData implements Serializable {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 主机总数
|
||||
*/
|
||||
private Integer hostCount;
|
||||
|
||||
/**
|
||||
* 主机在线数量
|
||||
*/
|
||||
private Integer hostOnlineCount;
|
||||
|
||||
/**
|
||||
* 主机离线数量
|
||||
*/
|
||||
private Integer hostOfflineCount;
|
||||
|
||||
/**
|
||||
* 主机状态未知数量
|
||||
*/
|
||||
private Integer hostUnknownCount;
|
||||
|
||||
/**
|
||||
* 虚拟机总数
|
||||
*/
|
||||
private Integer vmCount;
|
||||
|
||||
/**
|
||||
* 虚拟机在线数量
|
||||
*/
|
||||
private Integer vmOnlineCount;
|
||||
|
||||
/**
|
||||
* 虚拟机离线数量
|
||||
*/
|
||||
private Integer vmOfflineCount;
|
||||
|
||||
/**
|
||||
* 虚拟机状态未知数量
|
||||
*/
|
||||
private Integer vmUnknownCount;
|
||||
|
||||
/**
|
||||
* 容器总数
|
||||
*/
|
||||
private Integer containerCount;
|
||||
|
||||
/**
|
||||
* 容器在线数量
|
||||
*/
|
||||
private Integer containerOnlineCount;
|
||||
|
||||
/**
|
||||
* 容器离线数量
|
||||
*/
|
||||
private Integer containerOfflineCount;
|
||||
|
||||
/**
|
||||
* 容器状态未知数量
|
||||
*/
|
||||
private Integer containerUnknownCount;
|
||||
|
||||
/**
|
||||
* 服务总数
|
||||
*/
|
||||
private Integer servirCount;
|
||||
|
||||
/**
|
||||
* 操作数
|
||||
*/
|
||||
private Integer auditCount;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.mzaxd.noodles.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author root
|
||||
* @TableName host_detector
|
||||
*/
|
||||
@TableName(value ="host_detector")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class HostDetector implements Serializable {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 物理机id
|
||||
*/
|
||||
private Long hostMachineId;
|
||||
|
||||
/**
|
||||
* 探测器uuid(和机器一一绑定)
|
||||
*/
|
||||
private String detectorUuid;
|
||||
|
||||
/**
|
||||
* 探测器地址
|
||||
*/
|
||||
private String detectorIpAddress;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新人id
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表未删除,1代表已删除)
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.mzaxd.noodles.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 13439
|
||||
* @TableName host_machine
|
||||
*/
|
||||
@TableName(value ="host_machine")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class HostMachine implements Serializable {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 图像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* ssh连接信息表id
|
||||
*/
|
||||
private Long sshId;
|
||||
|
||||
/**
|
||||
* 操作系统id
|
||||
*/
|
||||
private Long osId;
|
||||
|
||||
/**
|
||||
* 管理ip地址
|
||||
*/
|
||||
private String manageIp;
|
||||
|
||||
/**
|
||||
* 宿主机id(0代表物理机没有宿主机)
|
||||
*/
|
||||
private Long hostMachineId;
|
||||
|
||||
/**
|
||||
* 核心线程数
|
||||
*/
|
||||
private Long threads;
|
||||
|
||||
/**
|
||||
* 内存
|
||||
*/
|
||||
private Long memory;
|
||||
|
||||
/**
|
||||
* 状态(0在线 1离线 2睡眠 3未知)
|
||||
*/
|
||||
private Integer hostMachineState;
|
||||
|
||||
/**
|
||||
* 提醒方式(0不提醒 1浏览器 2邮件 3浏览器&邮件)
|
||||
*/
|
||||
private Integer notify;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新人id
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表未删除,1代表已删除)
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.mzaxd.noodles.domain.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.security.core.GrantedAuthority;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class LoginUser implements UserDetails {
|
||||
|
||||
private User user;
|
||||
|
||||
@Override
|
||||
public Collection<? extends GrantedAuthority> getAuthorities() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPassword() {
|
||||
return user.getPassword();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsername() {
|
||||
return user.getEmail();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccountNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccountNonLocked() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCredentialsNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.mzaxd.noodles.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @TableName notification
|
||||
*/
|
||||
@TableName(value ="notification")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class Notification implements Serializable {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 通知标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 通知内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 通知类型(0代表掉线通知,1代表统计通知)
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 可能关联的实例的类型(0代表无 1代表host 2代表vm 3代表container)
|
||||
*/
|
||||
private Integer instanceType;
|
||||
|
||||
/**
|
||||
* 可能关联的实例id
|
||||
*/
|
||||
private Long instanceId;
|
||||
|
||||
/**
|
||||
* 提醒发送方式(0不提醒 1浏览器 1邮件 3代表两者)
|
||||
*/
|
||||
private Integer sendType;
|
||||
|
||||
/**
|
||||
* 用户是否确认(0代表未确认 1代表已确认)
|
||||
*/
|
||||
private Integer affirm;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表未删除,1代表已删除)
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.mzaxd.noodles.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author root
|
||||
* @TableName os
|
||||
*/
|
||||
@TableName(value ="os")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class Os implements Serializable {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 1代表Linux 2代表WindowsNT 3代表FreeBSD
|
||||
*/
|
||||
private Integer kernel;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建人id(0表示由系统创建)
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新人id
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表未删除,1代表已删除)
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.mzaxd.noodles.domain.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 13439
|
||||
* @TableName servir
|
||||
*/
|
||||
@TableName(value ="servir")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class Servir implements Serializable {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 图像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新人id
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表未删除,1代表已删除)
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.mzaxd.noodles.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 13439
|
||||
* @TableName servir_container
|
||||
*/
|
||||
@TableName(value ="servir_container")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ServirContainer implements Serializable {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 服务id
|
||||
*/
|
||||
private Long servirId;
|
||||
|
||||
/**
|
||||
* 容器id
|
||||
*/
|
||||
private Long containerId;
|
||||
|
||||
/**
|
||||
* 描述(关联方式)
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新人id
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表未删除,1代表已删除)
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.mzaxd.noodles.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 13439
|
||||
* @TableName servir_host
|
||||
*/
|
||||
@TableName(value ="servir_host")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class ServirHost implements Serializable {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 服务id
|
||||
*/
|
||||
private Long servirId;
|
||||
|
||||
/**
|
||||
* 服务器id(物理机、虚拟机都可以)
|
||||
*/
|
||||
private Long hostId;
|
||||
|
||||
/**
|
||||
* 描述(关联方式)
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新人id
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表未删除,1代表已删除)
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.mzaxd.noodles.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 13439
|
||||
* @TableName servir_tag
|
||||
*/
|
||||
@TableName(value ="servir_tag")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ServirTag implements Serializable {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 服务id
|
||||
*/
|
||||
private Long servirId;
|
||||
|
||||
/**
|
||||
* 标签id
|
||||
*/
|
||||
private Long tagId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新人id
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表未删除,1代表已删除)
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.mzaxd.noodles.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 13439
|
||||
* @TableName ssh_link
|
||||
*/
|
||||
@TableName(value ="ssh_link")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class SshLink implements Serializable {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 账号
|
||||
*/
|
||||
private String host;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 端口号
|
||||
*/
|
||||
private Integer port;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 控制台类型(bash/sh)
|
||||
*/
|
||||
private String consoleType;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新人id
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表未删除,1代表已删除)
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.mzaxd.noodles.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
*
|
||||
* @TableName system_setting
|
||||
*/
|
||||
@TableName(value ="system_setting")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SystemSetting implements Serializable {
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 过期时间(1、3、7、30)
|
||||
*/
|
||||
private Integer logExpire;
|
||||
|
||||
/**
|
||||
* 检查实例状态间隔(秒)
|
||||
*/
|
||||
private Integer checkInstanceStatePeriod;
|
||||
|
||||
/**
|
||||
* ch/en
|
||||
*/
|
||||
private String defaultLang;
|
||||
|
||||
/**
|
||||
* 发送邮箱
|
||||
*/
|
||||
private String serverEmail;
|
||||
|
||||
/**
|
||||
* 邮箱密码
|
||||
*/
|
||||
private String emailPass;
|
||||
|
||||
/**
|
||||
* 接收邮箱
|
||||
*/
|
||||
private String notificationEmail;
|
||||
|
||||
/**
|
||||
* 控制台渲染类型
|
||||
*/
|
||||
private String rendererType;
|
||||
|
||||
/**
|
||||
* 字体大小
|
||||
*/
|
||||
private Integer fontSize;
|
||||
|
||||
/**
|
||||
* 光标是否闪烁(0关1开)
|
||||
*/
|
||||
private Integer cursorBlink;
|
||||
|
||||
/**
|
||||
* 字体颜色
|
||||
*/
|
||||
private String foreground;
|
||||
|
||||
/**
|
||||
* 背景色
|
||||
*/
|
||||
private String background;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.mzaxd.noodles.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author 13439
|
||||
* @TableName tag
|
||||
*/
|
||||
@TableName(value ="tag")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class Tag implements Serializable {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新人id
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表未删除,1代表已删除)
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.mzaxd.noodles.domain.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author root
|
||||
* @TableName user
|
||||
*/
|
||||
@TableName(value ="user")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class User implements Serializable {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 账号状态(0代表未登陆过 1代表已经登录果)
|
||||
*/
|
||||
private Integer userState;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建人id(0表示由系统创建)
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 更新人id
|
||||
*/
|
||||
@TableField(fill = FieldFill.UPDATE)
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表未删除,1代表已删除)
|
||||
*/
|
||||
private Integer delFlag;
|
||||
|
||||
@TableField(exist = false)
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.mzaxd.noodles.domain.message;
|
||||
|
||||
import com.mzaxd.noodledetector.util.Arith;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author Mzaxd
|
||||
* @since 2023-02-05 10:49
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Cpu {
|
||||
|
||||
/**
|
||||
* CPU型号
|
||||
*/
|
||||
private String cpuName;
|
||||
|
||||
/**
|
||||
* CPU路数
|
||||
*/
|
||||
private int physicalPackageCount;
|
||||
|
||||
/**
|
||||
* 核心数
|
||||
*/
|
||||
private int physicalProcessorCount;
|
||||
|
||||
/**
|
||||
* 线程数
|
||||
*/
|
||||
private int logicalProcessorCount;
|
||||
|
||||
/**
|
||||
* CPU主频
|
||||
*/
|
||||
private long maxFreq;
|
||||
|
||||
/**
|
||||
* CPU Load
|
||||
*/
|
||||
private double cpuLoad;
|
||||
|
||||
/**
|
||||
* CPU总的使用率
|
||||
*/
|
||||
private double total;
|
||||
|
||||
/**
|
||||
* CPU系统使用率
|
||||
*/
|
||||
private double sys;
|
||||
|
||||
/**
|
||||
* CPU用户使用率
|
||||
*/
|
||||
private double used;
|
||||
|
||||
/**
|
||||
* CPU当前等待率
|
||||
*/
|
||||
private double wait;
|
||||
|
||||
/**
|
||||
* CPU当前空闲率
|
||||
*/
|
||||
private double free;
|
||||
|
||||
public double getCpuLoad()
|
||||
{
|
||||
return Double.parseDouble(String.format("%.1f", cpuLoad));
|
||||
}
|
||||
|
||||
public double getTotal()
|
||||
{
|
||||
return Arith.round(Arith.mul(total, 100), 2);
|
||||
}
|
||||
|
||||
public double getSys()
|
||||
{
|
||||
return Arith.round(Arith.mul(sys / total, 100), 2);
|
||||
}
|
||||
|
||||
public double getUsed()
|
||||
{
|
||||
return Arith.round(Arith.mul(used / total, 100), 2);
|
||||
}
|
||||
|
||||
public double getWait()
|
||||
{
|
||||
return Arith.round(Arith.mul(wait / total, 100), 2);
|
||||
}
|
||||
|
||||
public double getFree()
|
||||
{
|
||||
return Arith.round(Arith.mul(free / total, 100), 2);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.mzaxd.noodles.domain.message;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @author Mzaxd
|
||||
* @since 2023-02-05 18:49
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class DynamicData {
|
||||
|
||||
/**
|
||||
* 探测器id
|
||||
*/
|
||||
private String detectorId;
|
||||
|
||||
/**
|
||||
* CPU Load
|
||||
*/
|
||||
private double cpuLoad;
|
||||
|
||||
/**
|
||||
* CPU总的使用率
|
||||
*/
|
||||
private double cpuTotal;
|
||||
|
||||
/**
|
||||
* CPU系统使用率
|
||||
*/
|
||||
private double cpuSys;
|
||||
|
||||
/**
|
||||
* CPU用户使用率
|
||||
*/
|
||||
private double cpuUser;
|
||||
|
||||
/**
|
||||
* CPU当前等待率
|
||||
*/
|
||||
private double cpuWait;
|
||||
|
||||
/**
|
||||
* CPU当前空闲率
|
||||
*/
|
||||
private double cpuFree;
|
||||
|
||||
/**
|
||||
* 已用内存
|
||||
*/
|
||||
private double memUsed;
|
||||
|
||||
/**
|
||||
* 剩余内存
|
||||
*/
|
||||
private double memFree;
|
||||
|
||||
/**
|
||||
* 上行速度
|
||||
*/
|
||||
private String txPercent;
|
||||
|
||||
/**
|
||||
* 下行速度
|
||||
*/
|
||||
private String rxPercent;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.mzaxd.noodles.domain.message;
|
||||
|
||||
/**
|
||||
* @author Mzaxd
|
||||
* @since 2023-02-05 10:50
|
||||
*/
|
||||
|
||||
import com.mzaxd.noodledetector.util.Arith;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 內存相关信息
|
||||
*
|
||||
* @author huasheng
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Mem
|
||||
{
|
||||
/**
|
||||
* 内存总量
|
||||
*/
|
||||
private double total;
|
||||
|
||||
/**
|
||||
* 已用内存
|
||||
*/
|
||||
private double used;
|
||||
|
||||
/**
|
||||
* 剩余内存
|
||||
*/
|
||||
private double free;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.mzaxd.noodles.domain.message;
|
||||
|
||||
/**
|
||||
* @author Mzaxd
|
||||
* @since 2023-02-05 10:52
|
||||
*/
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 网速相关信息
|
||||
*
|
||||
* @author huasheng
|
||||
*/
|
||||
@Data
|
||||
public class NetWork {
|
||||
|
||||
/**
|
||||
* 主机ip
|
||||
*/
|
||||
private String hostAddress;
|
||||
|
||||
/**
|
||||
* hostName
|
||||
*/
|
||||
private String hostName;
|
||||
|
||||
/**
|
||||
* domainName
|
||||
*/
|
||||
private String domainName;
|
||||
|
||||
/**
|
||||
* dnsServers
|
||||
*/
|
||||
private List<String> dnsServers;
|
||||
|
||||
/**
|
||||
* ipv4DefaultGateway
|
||||
*/
|
||||
private String ipv4DefaultGateway;
|
||||
|
||||
/**
|
||||
* ipv6DefaultGateway
|
||||
*/
|
||||
private String ipv6DefaultGateway;
|
||||
|
||||
/**
|
||||
* 上行速度
|
||||
*/
|
||||
private String txPercent;
|
||||
|
||||
/**
|
||||
* 下行速度
|
||||
*/
|
||||
private String rxPercent;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.mzaxd.noodles.domain.message;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author Mzaxd
|
||||
* @since 2023-02-05 13:29
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Os {
|
||||
|
||||
/**
|
||||
* 系统名
|
||||
*/
|
||||
private String osName;
|
||||
|
||||
/**
|
||||
* 启动时间
|
||||
*/
|
||||
private String booted;
|
||||
|
||||
/**
|
||||
* 正常运行时间
|
||||
*/
|
||||
private String uptime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.mzaxd.noodles.domain.message;
|
||||
|
||||
/**
|
||||
* @author Mzaxd
|
||||
* @since 2023-02-05 10:48
|
||||
*/
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import oshi.hardware.NetworkIF;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 服务器相关信息
|
||||
*
|
||||
* @author huasheng
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Server {
|
||||
|
||||
private static final int OSHI_WAIT_SECOND = 1000;
|
||||
/**
|
||||
* 网速测速时间2s
|
||||
*/
|
||||
private static final int SLEEP_TIME = 2 * 1000;
|
||||
|
||||
/**
|
||||
* 探测器id
|
||||
*/
|
||||
private String detectorId;
|
||||
|
||||
/**
|
||||
* Os相关信息
|
||||
*/
|
||||
private com.mzaxd.noodles.domain.message.Os os = new Os();
|
||||
|
||||
/**
|
||||
* CPU相关信息
|
||||
*/
|
||||
private Cpu cpu = new Cpu();
|
||||
|
||||
/**
|
||||
* 內存相关信息
|
||||
*/
|
||||
private Mem mem = new Mem();
|
||||
|
||||
/**
|
||||
* 服务器相关信息
|
||||
*/
|
||||
private Sys sys = new Sys();
|
||||
|
||||
/**
|
||||
* 磁盘相关信息
|
||||
*/
|
||||
private List<SysFile> sysFiles = new LinkedList<SysFile>();
|
||||
|
||||
/**
|
||||
* 网络相关信息
|
||||
*/
|
||||
private NetWork netWork = new NetWork();
|
||||
|
||||
/**
|
||||
* 网络接口相关信息
|
||||
*/
|
||||
private List<NetworkIF> netWorkIf = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.mzaxd.noodles.domain.message;
|
||||
|
||||
/**
|
||||
* @author Mzaxd
|
||||
* @since 2023-02-05 10:51
|
||||
*/
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 系统相关信息
|
||||
*
|
||||
* @author huasheng
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Sys
|
||||
{
|
||||
/**
|
||||
* manufacturer
|
||||
*/
|
||||
private String manufacturer;
|
||||
|
||||
/**
|
||||
* model
|
||||
*/
|
||||
private String model;
|
||||
|
||||
/**
|
||||
* serialNumber
|
||||
*/
|
||||
private String serialNumber;
|
||||
|
||||
/**
|
||||
* uuid
|
||||
*/
|
||||
private String uuid;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.mzaxd.noodles.domain.message;
|
||||
|
||||
/**
|
||||
* @author Mzaxd
|
||||
* @since 2023-02-05 10:51
|
||||
*/
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 系统文件相关信息
|
||||
*
|
||||
* @author huasheng
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SysFile
|
||||
{
|
||||
/**
|
||||
* 盘符路径
|
||||
*/
|
||||
private String dirName;
|
||||
|
||||
/**
|
||||
* 盘符类型
|
||||
*/
|
||||
private String sysTypeName;
|
||||
|
||||
/**
|
||||
* 文件类型
|
||||
*/
|
||||
private String typeName;
|
||||
|
||||
/**
|
||||
* 总大小
|
||||
*/
|
||||
private String total;
|
||||
|
||||
/**
|
||||
* 剩余大小
|
||||
*/
|
||||
private String free;
|
||||
|
||||
/**
|
||||
* 已经使用量
|
||||
*/
|
||||
private String used;
|
||||
|
||||
/**
|
||||
* 资源的使用率
|
||||
*/
|
||||
private double usage;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.mzaxd.noodles.domain.ssh;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
*/
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SshMessage {
|
||||
|
||||
private String op;
|
||||
|
||||
private Integer cols;
|
||||
|
||||
private Integer rows;
|
||||
|
||||
private String data;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
package com.mzaxd.noodles.domain.ssh;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.EnumUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.mzaxd.noodles.util.StringUtil;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ProjectName SshModel
|
||||
* @author Administrator
|
||||
* @version 1.0.0
|
||||
* @Description SshModel实体类
|
||||
* @createTime 2022/5/2 0002 15:29
|
||||
*/
|
||||
public class SshModel {
|
||||
|
||||
private String name;
|
||||
private String host;
|
||||
private Integer port;
|
||||
private String user;
|
||||
private String password;
|
||||
/**
|
||||
* 编码格式
|
||||
*/
|
||||
private String charset;
|
||||
|
||||
/**
|
||||
* 文件目录
|
||||
*/
|
||||
private String fileDirs;
|
||||
|
||||
/**
|
||||
* ssh 私钥
|
||||
*/
|
||||
private String privateKey;
|
||||
|
||||
private String connectType;
|
||||
|
||||
/**
|
||||
* 不允许执行的命令
|
||||
*/
|
||||
private String notAllowedCommand;
|
||||
|
||||
/**
|
||||
* 允许编辑的后缀文件
|
||||
*/
|
||||
private String allowEditSuffix;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getNotAllowedCommand() {
|
||||
return notAllowedCommand;
|
||||
}
|
||||
|
||||
public void setNotAllowedCommand(String notAllowedCommand) {
|
||||
this.notAllowedCommand = notAllowedCommand;
|
||||
}
|
||||
|
||||
public ConnectType connectType() {
|
||||
return EnumUtil.fromString(ConnectType.class, this.connectType, ConnectType.PASS);
|
||||
}
|
||||
|
||||
public String getConnectType() {
|
||||
return connectType;
|
||||
}
|
||||
|
||||
public void setConnectType(String connectType) {
|
||||
this.connectType = connectType;
|
||||
}
|
||||
|
||||
public String getPrivateKey() {
|
||||
return privateKey;
|
||||
}
|
||||
|
||||
public void setPrivateKey(String privateKey) {
|
||||
this.privateKey = privateKey;
|
||||
}
|
||||
|
||||
public String getFileDirs() {
|
||||
return fileDirs;
|
||||
}
|
||||
|
||||
public void setFileDirs(String fileDirs) {
|
||||
this.fileDirs = fileDirs;
|
||||
}
|
||||
|
||||
public List<String> fileDirs() {
|
||||
return StringUtil.jsonConvertArray(this.fileDirs, String.class);
|
||||
}
|
||||
|
||||
public void fileDirs(List<String> fileDirs) {
|
||||
if (fileDirs != null) {
|
||||
for (int i = fileDirs.size() - 1; i >= 0; i--) {
|
||||
String s = fileDirs.get(i);
|
||||
fileDirs.set(i, FileUtil.normalize(s));
|
||||
}
|
||||
this.fileDirs = JSONArray.toJSONString(fileDirs);
|
||||
} else {
|
||||
this.fileDirs = null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public Integer getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(Integer port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getUser() {
|
||||
return user;
|
||||
}
|
||||
|
||||
public void setUser(String user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getCharset() {
|
||||
return charset;
|
||||
}
|
||||
|
||||
public void setCharset(String charset) {
|
||||
this.charset = charset;
|
||||
}
|
||||
|
||||
public Charset getCharsetT() {
|
||||
Charset charset;
|
||||
try {
|
||||
charset = Charset.forName(this.getCharset());
|
||||
} catch (Exception e) {
|
||||
charset = CharsetUtil.CHARSET_UTF_8;
|
||||
}
|
||||
return charset;
|
||||
}
|
||||
|
||||
public List<String> allowEditSuffix() {
|
||||
return StringUtil.jsonConvertArray(this.allowEditSuffix, String.class);
|
||||
}
|
||||
|
||||
public void allowEditSuffix(List<String> allowEditSuffix) {
|
||||
if (allowEditSuffix == null) {
|
||||
this.allowEditSuffix = null;
|
||||
} else {
|
||||
this.allowEditSuffix = JSONArray.toJSONString(allowEditSuffix);
|
||||
}
|
||||
}
|
||||
|
||||
public String getAllowEditSuffix() {
|
||||
return allowEditSuffix;
|
||||
}
|
||||
|
||||
public void setAllowEditSuffix(String allowEditSuffix) {
|
||||
this.allowEditSuffix = allowEditSuffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查是否包含禁止命令
|
||||
*
|
||||
* @param sshItem 实体
|
||||
* @param inputItem 输入的命令
|
||||
* @return false 存在禁止输入的命令
|
||||
*/
|
||||
public static boolean checkInputItem(SshModel sshItem, String inputItem) {
|
||||
// 检查禁止执行的命令
|
||||
String notAllowedCommand = StrUtil.emptyToDefault(sshItem.getNotAllowedCommand(), StrUtil.EMPTY).toLowerCase();
|
||||
if (StrUtil.isEmpty(notAllowedCommand)) {
|
||||
return true;
|
||||
}
|
||||
List<String> split = Arrays.asList(StrUtil.split(notAllowedCommand, StrUtil.COMMA));
|
||||
inputItem = inputItem.toLowerCase();
|
||||
List<String> commands = Arrays.asList(StrUtil.split(inputItem, StrUtil.CR));
|
||||
commands.addAll(Arrays.asList(StrUtil.split(inputItem, "&")));
|
||||
for (String s : split) {
|
||||
//
|
||||
boolean anyMatch = commands.stream().anyMatch(item -> StrUtil.startWithAny(item, s + StrUtil.SPACE, ("&" + s + StrUtil.SPACE), StrUtil.SPACE + s + StrUtil.SPACE));
|
||||
if (anyMatch) {
|
||||
return false;
|
||||
}
|
||||
//
|
||||
anyMatch = commands.stream().anyMatch(item -> StrUtil.equals(item, s));
|
||||
if (anyMatch) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public enum ConnectType {
|
||||
/**
|
||||
* 账号密码
|
||||
*/
|
||||
PASS,
|
||||
/**
|
||||
* 密钥
|
||||
*/
|
||||
PUBKEY
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.mzaxd.noodles.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AccountVo {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 账号
|
||||
*/
|
||||
private String account;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 0代表管理员 1代表非管理员
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.mzaxd.noodles.domain.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AuditLogListVo {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 操作
|
||||
*/
|
||||
private String operation;
|
||||
|
||||
/**
|
||||
* 操作类型(用户/容器/虚拟机/物理机/服务/系统)
|
||||
*/
|
||||
private String operationType;
|
||||
|
||||
/**
|
||||
* 请求参数
|
||||
*/
|
||||
private String param;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 操作人信息
|
||||
*/
|
||||
private UserInfoVo user;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.mzaxd.noodles.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ContainerSelectVo {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 图像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
package com.mzaxd.noodles.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class ContainerVo {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 图像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 镜像名
|
||||
*/
|
||||
private String imageName;
|
||||
|
||||
/**
|
||||
* WebUi URL
|
||||
*/
|
||||
private String webUi;
|
||||
|
||||
/**
|
||||
* 宿主机id
|
||||
*/
|
||||
private Long hostMachineId;
|
||||
|
||||
/**
|
||||
* 宿主机信息
|
||||
*/
|
||||
private HostMachineVo hostMachine;
|
||||
|
||||
/**
|
||||
* 状态(0在线 1离线 2孤立镜像)
|
||||
*/
|
||||
private Integer containerState;
|
||||
|
||||
/**
|
||||
* 容器编号
|
||||
*/
|
||||
private String containerId;
|
||||
|
||||
/**
|
||||
* 状态(0不提醒 1浏览器 2邮件 3浏览器&邮件)
|
||||
*/
|
||||
private Integer notify;
|
||||
|
||||
/**
|
||||
* SSH Id
|
||||
*/
|
||||
private Long sshId;
|
||||
|
||||
/**
|
||||
* 控制台类型
|
||||
*/
|
||||
private String sshType;
|
||||
|
||||
/**
|
||||
* SSH连接地址
|
||||
*/
|
||||
private String sshHost;
|
||||
|
||||
/**
|
||||
* SSH连接地址端口号
|
||||
*/
|
||||
private Integer sshPort;
|
||||
|
||||
/**
|
||||
* SSH连接用户
|
||||
*/
|
||||
private String sshUser;
|
||||
|
||||
/**
|
||||
* SSH连接密码
|
||||
*/
|
||||
private String sshPwd;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.mzaxd.noodles.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class HostMachineDrawerVo {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 图像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.mzaxd.noodles.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class HostMachineListVo {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 图像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 状态(0在线 1离线 2睡眠)
|
||||
*/
|
||||
private Integer hostMachineState;
|
||||
|
||||
/**
|
||||
* 探测器地址
|
||||
*/
|
||||
private String detectorIpAddress;
|
||||
|
||||
/**
|
||||
* 操作系统id
|
||||
*/
|
||||
private Long osId;
|
||||
|
||||
/**
|
||||
* 操作系统Vo
|
||||
*/
|
||||
private OsVo os;
|
||||
|
||||
/**
|
||||
* 操作系统id
|
||||
*/
|
||||
private Long sshId;
|
||||
|
||||
/**
|
||||
* 操作系统Vo
|
||||
*/
|
||||
private SshLinkVo sshLink;
|
||||
|
||||
/**
|
||||
* 核心线程数
|
||||
*/
|
||||
private Long threads;
|
||||
|
||||
/**
|
||||
* 内存
|
||||
*/
|
||||
private Long memory;
|
||||
|
||||
/**
|
||||
* 管理ip地址
|
||||
*/
|
||||
private String manageIp;
|
||||
|
||||
/**
|
||||
* 状态(0不提醒 1浏览器 2邮件 3浏览器&邮件)
|
||||
*/
|
||||
private Integer notify;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.mzaxd.noodles.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class HostMachineVo {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 图像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.mzaxd.noodles.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class HostPanelVo {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 图像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 管理ip地址
|
||||
*/
|
||||
private String manageIp;
|
||||
|
||||
/**
|
||||
* 协议
|
||||
*/
|
||||
private String protocol;
|
||||
|
||||
/**
|
||||
* ip地址
|
||||
*/
|
||||
private String ip;
|
||||
|
||||
/**
|
||||
* 端口
|
||||
*/
|
||||
private String port;
|
||||
|
||||
/**
|
||||
* 1代表Linux 2代表WindowsNT 3代表FreeBSD
|
||||
*/
|
||||
private Integer osKernel;
|
||||
|
||||
/**
|
||||
* 状态(0不提醒 1浏览器 2邮件 3浏览器&邮件)
|
||||
*/
|
||||
private Integer notify;
|
||||
|
||||
/**
|
||||
* 状态(0在线 1离线 2睡眠)
|
||||
*/
|
||||
private Integer hostMachineState;
|
||||
|
||||
/**
|
||||
* 虚拟机数量
|
||||
*/
|
||||
private Integer vmCount;
|
||||
|
||||
/**
|
||||
* 容器数量
|
||||
*/
|
||||
private Integer containerCount;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.mzaxd.noodles.domain.vo;
|
||||
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class HostVo {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 图像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 管理ip地址
|
||||
*/
|
||||
private String manageIp;
|
||||
|
||||
/**
|
||||
* 协议
|
||||
*/
|
||||
private String protocol;
|
||||
|
||||
/**
|
||||
* ip地址
|
||||
*/
|
||||
private String ip;
|
||||
|
||||
/**
|
||||
* 端口
|
||||
*/
|
||||
private String port;
|
||||
|
||||
/**
|
||||
* 1代表Linux 2代表WindowsNT 3代表FreeBSD
|
||||
*/
|
||||
private Integer osKernel;
|
||||
|
||||
/**
|
||||
* 状态(0不提醒 1浏览器 2邮件 3浏览器&邮件)
|
||||
*/
|
||||
private Integer notify;
|
||||
|
||||
/**
|
||||
* 操作系统id
|
||||
*/
|
||||
private Long sshId;
|
||||
|
||||
/**
|
||||
* SSH连接地址
|
||||
*/
|
||||
private String sshHost;
|
||||
|
||||
/**
|
||||
* SSH连接地址端口号
|
||||
*/
|
||||
private Integer sshPort;
|
||||
|
||||
/**
|
||||
* SSH连接用户
|
||||
*/
|
||||
private String sshUser;
|
||||
|
||||
/**
|
||||
* SSH连接密码
|
||||
*/
|
||||
private String sshPwd;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
package com.mzaxd.noodles.domain.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
*/
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class NotificationListVo {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 通知标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 通知内容
|
||||
*/
|
||||
private String content;
|
||||
|
||||
/**
|
||||
* 通知类型(0代表掉线通知,1代表统计通知)
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 可能关联的实例的类型(0代表无 1代表host 2代表vm 3代表container)
|
||||
*/
|
||||
private Integer instanceType;
|
||||
|
||||
/**
|
||||
* 可能关联的实例id
|
||||
*/
|
||||
private Long instanceId;
|
||||
|
||||
/**
|
||||
* 提醒发送方式(0不提醒 1浏览器 1邮件 3代表两者)
|
||||
*/
|
||||
private Integer sendType;
|
||||
|
||||
/**
|
||||
* 用户是否确认(0代表未确认 1代表已确认)
|
||||
*/
|
||||
private Integer affirm;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 关联的实例名称
|
||||
*/
|
||||
private String instanceName;
|
||||
|
||||
/**
|
||||
* 关联的实例图标
|
||||
*/
|
||||
private String instanceAvatar;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.mzaxd.noodles.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class OsVo {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 1代表Linux 2代表WindowsNT 3代表FreeBSD
|
||||
*/
|
||||
private Integer kernel;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.mzaxd.noodles.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ProfileHeaderVo {
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 登录地点
|
||||
*/
|
||||
private String location;
|
||||
|
||||
/**
|
||||
* 账号创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.mzaxd.noodles.domain.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ProfileVo {
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 总服务数
|
||||
*/
|
||||
private Integer servirNumber;
|
||||
|
||||
/**
|
||||
* 总物理机数
|
||||
*/
|
||||
private Integer hostNumber;
|
||||
|
||||
/**
|
||||
* 总虚拟机数
|
||||
*/
|
||||
private Integer vmNumber;
|
||||
|
||||
/**
|
||||
* 总容器数
|
||||
*/
|
||||
private Integer containerNumber;
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.mzaxd.noodles.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class RecentConsoleListVo {
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 图像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* ssh连接信息表id
|
||||
*/
|
||||
private Long sshId;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.mzaxd.noodles.domain.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SaveOrUpdateServirVo {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 图像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 容器id
|
||||
*/
|
||||
private List<Integer> containerIds;
|
||||
|
||||
/**
|
||||
* 主机id
|
||||
*/
|
||||
private List<Integer> hostIds;
|
||||
|
||||
/**
|
||||
* 标签id
|
||||
*/
|
||||
private List<Integer> tagIds;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.mzaxd.noodles.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ServirContainerVo {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 图像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* WebUi URL
|
||||
*/
|
||||
private String webUi;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.mzaxd.noodles.domain.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ServirHostVo {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 图像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 管理ip地址
|
||||
*/
|
||||
private String manageIp;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.mzaxd.noodles.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class ServirListVo {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 图像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 所有关联的host
|
||||
*/
|
||||
private List<ServirHostVo> hosts;
|
||||
|
||||
/**
|
||||
* 所有关联的容器
|
||||
*/
|
||||
private List<ServirContainerVo> containers;
|
||||
|
||||
/**
|
||||
* 所有标签
|
||||
*/
|
||||
private List<TagVo> tags;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.mzaxd.noodles.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SmtpVo {
|
||||
/**
|
||||
* 发送邮箱
|
||||
*/
|
||||
private String serverEmail;
|
||||
|
||||
/**
|
||||
* 邮箱密码
|
||||
*/
|
||||
private String emailPass;
|
||||
|
||||
/**
|
||||
* 接收邮箱
|
||||
*/
|
||||
private String notificationEmail;
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.mzaxd.noodles.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
*/
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SshLinkVo {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 账号
|
||||
*/
|
||||
private String host;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 端口号
|
||||
*/
|
||||
private Integer port;
|
||||
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 控制台类型(bash/sh)
|
||||
*/
|
||||
private String consoleType;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.mzaxd.noodles.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class SystemVo {
|
||||
|
||||
/**
|
||||
* 过期时间(1、3、7、30)
|
||||
*/
|
||||
private Integer logExpire;
|
||||
|
||||
/**
|
||||
* 检查实例状态间隔(秒)
|
||||
*/
|
||||
private Integer checkInstanceStatePeriod;
|
||||
|
||||
/**
|
||||
* ch/en
|
||||
*/
|
||||
private String defaultLang;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.mzaxd.noodles.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class TagVo {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.mzaxd.noodles.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class TerminalVo {
|
||||
|
||||
/**
|
||||
* 控制台渲染类型
|
||||
*/
|
||||
private String rendererType;
|
||||
|
||||
/**
|
||||
* 字体大小
|
||||
*/
|
||||
private Integer fontSize;
|
||||
|
||||
/**
|
||||
* 光标是否闪烁(0关1开)
|
||||
*/
|
||||
private Integer cursorBlink;
|
||||
|
||||
/**
|
||||
* 字体颜色
|
||||
*/
|
||||
private String foreground;
|
||||
|
||||
/**
|
||||
* 背景色
|
||||
*/
|
||||
private String background;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.mzaxd.noodles.domain.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
@Data
|
||||
public class UserInfoVo {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 昵称
|
||||
*/
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.mzaxd.noodles.domain.vo;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class VirtualMachineListVo {
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 图像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 控制台id
|
||||
*/
|
||||
private Long sshId;
|
||||
|
||||
/**
|
||||
* 操作系统id
|
||||
*/
|
||||
private Long osId;
|
||||
|
||||
/**
|
||||
* 操作系统Vo
|
||||
*/
|
||||
private OsVo os;
|
||||
|
||||
/**
|
||||
* 管理ip地址
|
||||
*/
|
||||
private String manageIp;
|
||||
|
||||
/**
|
||||
* 核心线程数
|
||||
*/
|
||||
private Long threads;
|
||||
|
||||
/**
|
||||
* 内存
|
||||
*/
|
||||
private Long memory;
|
||||
|
||||
/**
|
||||
* 状态(0在线 1离线 2睡眠)
|
||||
*/
|
||||
private Integer hostMachineState;
|
||||
|
||||
/**
|
||||
* 状态(0不提醒 1浏览器 2邮件 3浏览器&邮件)
|
||||
*/
|
||||
private Integer notify;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package com.mzaxd.noodles.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class VmVo {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 图像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 宿主机id(0代表物理机没有宿主机)
|
||||
*/
|
||||
private Long hostMachineId;
|
||||
|
||||
/**
|
||||
* 核心线程数
|
||||
*/
|
||||
private Long threads;
|
||||
|
||||
/**
|
||||
* 内存
|
||||
*/
|
||||
private Long memory;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String osName;
|
||||
|
||||
/**
|
||||
* 管理ip地址
|
||||
*/
|
||||
private String manageIp;
|
||||
|
||||
/**
|
||||
* 1代表Linux 2代表WindowsNT 3代表FreeBSD
|
||||
*/
|
||||
private Integer osKernel;
|
||||
|
||||
/**
|
||||
* 状态(0不提醒 1浏览器 2邮件 3浏览器&邮件)
|
||||
*/
|
||||
private Integer notify;
|
||||
|
||||
/**
|
||||
* SSH连接地址
|
||||
*/
|
||||
private String sshHost;
|
||||
|
||||
/**
|
||||
* SSH连接地址端口号
|
||||
*/
|
||||
private Integer sshPort;
|
||||
|
||||
/**
|
||||
* SSH连接用户
|
||||
*/
|
||||
private String sshUser;
|
||||
|
||||
/**
|
||||
* SSH连接密码
|
||||
*/
|
||||
private String sshPwd;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.mzaxd.noodles.enums;
|
||||
|
||||
/**
|
||||
* @author Mzaxd
|
||||
*/
|
||||
|
||||
public enum AppHttpCodeEnum {
|
||||
/**
|
||||
* 操作成功通用返回信息
|
||||
*/
|
||||
SUCCESS(200, "操作成功"),
|
||||
|
||||
NEED_LOGIN(401, "需要登录后操作"),
|
||||
|
||||
NO_OPERATOR_AUTH(403, "无权限操作"),
|
||||
|
||||
SYSTEM_ERROR(500, "出现错误"),
|
||||
|
||||
EMAIL_EXIST(503, "邮箱已存在"),
|
||||
|
||||
LOGIN_ERROR(505, "邮箱或密码错误"),
|
||||
|
||||
CONTENT_NOT_NULL(506, "评论不能为空"),
|
||||
|
||||
FILE_TYPE_ERROR(507, "文件类型错误,请上传png文件"),
|
||||
|
||||
USERNAME_NOT_NULL(508, "用户名不能为空"),
|
||||
|
||||
PASSWORD_NOT_NULL(509, "密码不能为空"),
|
||||
|
||||
NICKNAME_NOT_NULL(510, "昵称不能为空"),
|
||||
|
||||
EMAIL_NOT_NULL(511, "邮箱不能为空"),
|
||||
|
||||
NICKNAME_EXIST(512, "昵称已存在"),
|
||||
|
||||
EXIST_ASSOCIATION_CONTAINER(513, "操作失败,存在关联的容器"),
|
||||
|
||||
PORT_INVALID(514, "无效端口"),
|
||||
|
||||
EXIST_ASSOCIATION_VM(513, "操作失败,存在关联的虚拟机");
|
||||
|
||||
|
||||
/**
|
||||
* 统一响应码
|
||||
*/
|
||||
final int code;
|
||||
/**
|
||||
* 响应信息
|
||||
*/
|
||||
final String msg;
|
||||
|
||||
AppHttpCodeEnum(int code, String errorMessage) {
|
||||
this.code = code;
|
||||
this.msg = errorMessage;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package com.mzaxd.noodles.enums;
|
||||
|
||||
/**
|
||||
* 操作日志-操作类型
|
||||
*
|
||||
* @author 13439
|
||||
*/
|
||||
|
||||
public enum OperationEnum {
|
||||
|
||||
/**
|
||||
* 新增物理机
|
||||
*/
|
||||
HOST_ADD("新增物理机", "物理机"),
|
||||
|
||||
/**
|
||||
* 修改物理机
|
||||
*/
|
||||
HOST_UPDATE("修改物理机", "物理机"),
|
||||
|
||||
/**
|
||||
* 删除物理机
|
||||
*/
|
||||
HOST_DELETE("删除物理机", "物理机"),
|
||||
|
||||
/**
|
||||
* 新增虚拟机
|
||||
*/
|
||||
VM_ADD("新增虚拟机", "虚拟机"),
|
||||
|
||||
/**
|
||||
* 修改虚拟机
|
||||
*/
|
||||
VM_UPDATE("修改虚拟机", "虚拟机"),
|
||||
|
||||
/**
|
||||
* 删除虚拟机
|
||||
*/
|
||||
VM_DELETE("删除虚拟机", "虚拟机"),
|
||||
|
||||
/**
|
||||
* 新增容器
|
||||
*/
|
||||
CONTAINER_ADD("新增容器", "容器"),
|
||||
|
||||
/**
|
||||
* 修改容器
|
||||
*/
|
||||
CONTAINER_UPDATE("修改容器", "容器"),
|
||||
|
||||
/**
|
||||
* 删除容器
|
||||
*/
|
||||
CONTAINER_DELETE("删除容器", "容器"),
|
||||
|
||||
/**
|
||||
* 新增服务
|
||||
*/
|
||||
SERVIR_ADD("新增容器", "服务"),
|
||||
|
||||
/**
|
||||
* 修改服务
|
||||
*/
|
||||
SERVIR_UPDATE("修改容器", "服务"),
|
||||
|
||||
/**
|
||||
* 删除服务
|
||||
*/
|
||||
SERVIR_DELETE("删除容器", "服务"),
|
||||
|
||||
/**
|
||||
* 第一次登录
|
||||
*/
|
||||
USER_FIRST_USE("第一次登录", "用户"),
|
||||
|
||||
/**
|
||||
* 更改账号信息
|
||||
*/
|
||||
USER_UPDATE_USERINFO("更改账号信息", "用户"),
|
||||
|
||||
/**
|
||||
* 更改邮箱账号
|
||||
*/
|
||||
USER_UPDATE_EMAIL("更改邮箱账号", "用户"),
|
||||
|
||||
/**
|
||||
* 更改密码
|
||||
*/
|
||||
USER_UPDATE_PASSWORD("更改密码", "用户"),
|
||||
|
||||
/**
|
||||
* 确认提醒
|
||||
*/
|
||||
NOTIFICATION_AFFIRM("确认提醒", "提醒"),
|
||||
|
||||
/**
|
||||
* 确认提醒
|
||||
*/
|
||||
CONSOLE_CONNECT("连接控制台", "控制台"),
|
||||
|
||||
/**
|
||||
* 默认操作
|
||||
*/
|
||||
DEFAULT("默认操作", "默认操作类型");
|
||||
|
||||
final String operation;
|
||||
final String operationType;
|
||||
|
||||
OperationEnum(String operation, String operationType) {
|
||||
this.operation = operation;
|
||||
this.operationType = operationType;
|
||||
}
|
||||
|
||||
public String getOperation() {
|
||||
return operation;
|
||||
}
|
||||
|
||||
public String getOperationType() {
|
||||
return operationType;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.mzaxd.noodles.exception;
|
||||
|
||||
import com.mzaxd.noodles.enums.AppHttpCodeEnum;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author mzaxd
|
||||
* @date 11/27/22 3:19 AM
|
||||
*/
|
||||
|
||||
public class SystemException extends RuntimeException{
|
||||
|
||||
private final int code;
|
||||
|
||||
private final String msg;
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public SystemException(AppHttpCodeEnum httpCodeEnum) {
|
||||
super(httpCodeEnum.getMsg());
|
||||
this.code = httpCodeEnum.getCode();
|
||||
this.msg = httpCodeEnum.getMsg();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.mzaxd.noodles.filter;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.mzaxd.noodles.domain.ResponseResult;
|
||||
import com.mzaxd.noodles.domain.entity.LoginUser;
|
||||
import com.mzaxd.noodles.enums.AppHttpCodeEnum;
|
||||
import com.mzaxd.noodles.util.JwtUtil;
|
||||
import com.mzaxd.noodles.util.RedisCache;
|
||||
import com.mzaxd.noodles.util.WebUtils;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
@Component
|
||||
public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
|
||||
|
||||
@Resource
|
||||
private RedisCache redisCache;
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
|
||||
//获取请求头中的token
|
||||
String token = request.getHeader("token");
|
||||
if (!StringUtils.hasText(token)) {
|
||||
// 说明该接口不需要登录 直接放行
|
||||
filterChain.doFilter(request, response);
|
||||
return;
|
||||
}
|
||||
//解析获取userId
|
||||
Claims claims;
|
||||
try {
|
||||
claims = JwtUtil.parseJWT(token);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
//token超时 token非法
|
||||
//响应告诉前端需要重新登录
|
||||
ResponseResult result = ResponseResult.errorResult(AppHttpCodeEnum.NEED_LOGIN);
|
||||
WebUtils.renderString(response, JSON.toJSONString(result));
|
||||
return;
|
||||
}
|
||||
String userId = claims.getSubject();
|
||||
//从redis中获取用户信息
|
||||
LoginUser loginUser = redisCache.getCacheObject("login:" + userId);
|
||||
//如果redis中没有用户信息
|
||||
if (Objects.isNull(loginUser)) {
|
||||
//说明登录过期 需要重新登录
|
||||
ResponseResult result = ResponseResult.errorResult(AppHttpCodeEnum.NEED_LOGIN);
|
||||
WebUtils.renderString(response, JSON.toJSONString(result));
|
||||
return;
|
||||
}
|
||||
//存入SecurityContextHolder
|
||||
UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(loginUser, null, null);
|
||||
SecurityContextHolder.getContext().setAuthentication(authenticationToken);
|
||||
//放行
|
||||
filterChain.doFilter(request, response);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.mzaxd.noodles.handler;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.mzaxd.noodles.domain.ResponseResult;
|
||||
import com.mzaxd.noodles.enums.AppHttpCodeEnum;
|
||||
import com.mzaxd.noodles.util.WebUtils;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
import org.springframework.security.web.access.AccessDeniedHandler;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
@Component
|
||||
public class AccessDeniedHandlerImpl implements AccessDeniedHandler {
|
||||
@Override
|
||||
public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException accessDeniedException) throws ServletException {
|
||||
accessDeniedException.printStackTrace();
|
||||
ResponseResult result = ResponseResult.errorResult(AppHttpCodeEnum.NO_OPERATOR_AUTH);
|
||||
//响应给前端
|
||||
WebUtils.renderString(response, JSON.toJSONString(result));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.mzaxd.noodles.handler;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.mzaxd.noodles.domain.ResponseResult;
|
||||
import com.mzaxd.noodles.enums.AppHttpCodeEnum;
|
||||
import com.mzaxd.noodles.util.WebUtils;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.authentication.InsufficientAuthenticationException;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.web.AuthenticationEntryPoint;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
@Component
|
||||
public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint {
|
||||
|
||||
@Override
|
||||
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authException) {
|
||||
authException.printStackTrace();
|
||||
//InsufficientAuthenticationException
|
||||
//BadCredentialsException
|
||||
ResponseResult result;
|
||||
if (authException instanceof BadCredentialsException) {
|
||||
result = ResponseResult.errorResult(AppHttpCodeEnum.LOGIN_ERROR.getCode(), authException.getMessage());
|
||||
} else if (authException instanceof InsufficientAuthenticationException) {
|
||||
result = ResponseResult.errorResult(AppHttpCodeEnum.NEED_LOGIN);
|
||||
} else {
|
||||
result = ResponseResult.errorResult(AppHttpCodeEnum.SYSTEM_ERROR.getCode(), "认证或授权失败");
|
||||
}
|
||||
//响应给前端
|
||||
WebUtils.renderString(response, JSON.toJSONString(result));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.mzaxd.noodles.handler;
|
||||
|
||||
import com.mzaxd.noodles.domain.ResponseResult;
|
||||
import com.mzaxd.noodles.enums.AppHttpCodeEnum;
|
||||
import com.mzaxd.noodles.exception.SystemException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
@Slf4j
|
||||
public class GlobalExceptionHandler {
|
||||
|
||||
@ExceptionHandler(SystemException.class)
|
||||
public ResponseResult systemExceptionHandler(SystemException e) {
|
||||
//打印异常信息
|
||||
log.error("出现了异常! {}", e);
|
||||
//从异常对象中获取提示信息封装返回
|
||||
return ResponseResult.errorResult(e.getCode(), e.getMsg());
|
||||
}
|
||||
|
||||
@ExceptionHandler(Exception.class)
|
||||
public ResponseResult exceptionHandler(Exception e) {
|
||||
//打印异常信息
|
||||
log.error("出现了异常! {}", e);
|
||||
//从异常对象中获取提示信息封装返回
|
||||
return ResponseResult.errorResult(AppHttpCodeEnum.SYSTEM_ERROR, e.getMessage());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.mzaxd.noodles.handler;
|
||||
|
||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||
import com.mzaxd.noodles.util.SecurityUtils;
|
||||
import org.apache.ibatis.reflection.MetaObject;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
@Component
|
||||
public class MyMetaObjectHandler implements MetaObjectHandler {
|
||||
@Override
|
||||
public void insertFill(MetaObject metaObject) {
|
||||
Long userId;
|
||||
try {
|
||||
userId = SecurityUtils.getUserId();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
//表示是自己创建
|
||||
userId = -1L;
|
||||
}
|
||||
this.setFieldValByName("createTime", new Date(), metaObject);
|
||||
this.setFieldValByName("createBy",userId , metaObject);
|
||||
this.setFieldValByName("updateTime", new Date(), metaObject);
|
||||
this.setFieldValByName("updateBy", userId, metaObject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateFill(MetaObject metaObject) {
|
||||
Long userId;
|
||||
try {
|
||||
userId = SecurityUtils.getUserId();
|
||||
} catch (Exception e) {
|
||||
//表示是自己创建
|
||||
userId = -1L;
|
||||
}
|
||||
this.setFieldValByName("updateTime", new Date(), metaObject);
|
||||
this.setFieldValByName("updateBy", userId, metaObject);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,171 @@
|
||||
package com.mzaxd.noodles.job;
|
||||
|
||||
import cn.hutool.http.HttpException;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.mzaxd.noodles.constant.RedisConstant;
|
||||
import com.mzaxd.noodles.constant.SystemConstant;
|
||||
import com.mzaxd.noodles.constant.UrlConstant;
|
||||
import com.mzaxd.noodles.domain.entity.Container;
|
||||
import com.mzaxd.noodles.domain.entity.HostDetector;
|
||||
import com.mzaxd.noodles.domain.entity.HostMachine;
|
||||
import com.mzaxd.noodles.service.*;
|
||||
import com.mzaxd.noodles.util.RedisCache;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 检测所有实例的在线状态
|
||||
* @author 13439
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CheckInstancesStatus{
|
||||
|
||||
@Resource
|
||||
private ContainerService containerService;
|
||||
|
||||
@Resource
|
||||
private HostMachineService hostMachineService;
|
||||
|
||||
@Resource
|
||||
private HostDetectorService hostDetectorService;
|
||||
|
||||
@Resource
|
||||
private NotificationService notificationService;
|
||||
|
||||
@Resource
|
||||
private RedisCache redisCache;
|
||||
|
||||
/**
|
||||
* 检查实例状态并且发送对应的提醒
|
||||
*/
|
||||
@Scheduled(cron = "* 0/10 * * * ?")
|
||||
public void checkInstancesStatus() {
|
||||
//检测容器在线状态
|
||||
List<Container> containers = containerService.list();
|
||||
containers.forEach(container -> {
|
||||
try {
|
||||
if (!StringUtils.hasText(container.getWebUi())) {
|
||||
container.setContainerState(SystemConstant.CONTAINER_STATE_UNKNOWN);
|
||||
return;
|
||||
}
|
||||
HttpRequest.get(container.getWebUi()).setConnectionTimeout(1000).execute(true);
|
||||
log.info("[实例状态检测]:与{}建立连接成功", container.getName());
|
||||
container.setContainerState(SystemConstant.CONTAINER_STATE_RUNNING);
|
||||
} catch (Exception exception) {
|
||||
log.info("[实例状态检测]:与{}建立连接失败,状态转为离线", container.getName());
|
||||
container.setContainerState(SystemConstant.CONTAINER_STATE_EXITED);
|
||||
//判断Redis里面有没有 如果有就不需要提醒 如果没有就提醒
|
||||
Set<String> set = redisCache.getCacheSet(RedisConstant.NOTIFY_CONTAINER_IDS);
|
||||
if (Objects.nonNull(set)){
|
||||
//如果redis里面有 说明已经发送过了未check的通知 所以不需要发送 直接返回
|
||||
if (set.contains(container.getId().toString())) {
|
||||
return;
|
||||
} else {
|
||||
//根据实例对应的提醒方式进行提醒
|
||||
if (container.getNotify().equals(SystemConstant.NOTIFY_NO)) {
|
||||
return;
|
||||
} else {
|
||||
notificationService.sendContainerOfflineNotification(container.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
//存入redis
|
||||
set.add(container.getId().toString());
|
||||
redisCache.setCacheSet(RedisConstant.NOTIFY_CONTAINER_IDS, set);
|
||||
}
|
||||
});
|
||||
containerService.saveOrUpdateBatch(containers);
|
||||
|
||||
//检测虚拟机在线状态
|
||||
LambdaQueryWrapper<HostMachine> vmWrapper = new LambdaQueryWrapper<>();
|
||||
vmWrapper.ne(HostMachine::getHostMachineId, SystemConstant.HOST_MACHINE_ID_HOST);
|
||||
List<HostMachine> vms = hostMachineService.list(vmWrapper);
|
||||
vms.forEach(vm -> {
|
||||
try {
|
||||
if (!StringUtils.hasText(vm.getManageIp())) {
|
||||
vm.setHostMachineState(SystemConstant.HOST_MACHINE_STATE_UNKNOWN);
|
||||
return;
|
||||
}
|
||||
HttpRequest.get(vm.getManageIp()).setConnectionTimeout(1000).execute(true);
|
||||
log.info("[实例状态检测]:与{}建立连接成功", vm.getName());
|
||||
vm.setHostMachineState(SystemConstant.HOST_MACHINE_STATE_ONLINE);
|
||||
} catch (Exception exception) {
|
||||
log.info("[实例状态检测]:与{}建立连接失败,状态转为离线", vm.getName());
|
||||
vm.setHostMachineState(SystemConstant.HOST_MACHINE_STATE_OFFLINE);
|
||||
//判断Redis里面有没有 如果有就不需要提醒 如果没有就提醒
|
||||
Set<String> set = redisCache.getCacheSet(RedisConstant.NOTIFY_VM_IDS);
|
||||
if (Objects.nonNull(set)){
|
||||
//如果redis里面有 说明已经发送过了未check的通知 所以不需要发送 直接返回
|
||||
if (set.contains(vm.getId().toString())) {
|
||||
return;
|
||||
} else {
|
||||
//根据实例对应的提醒方式进行提醒
|
||||
if (vm.getNotify().equals(SystemConstant.NOTIFY_NO)) {
|
||||
return;
|
||||
} else {
|
||||
notificationService.sendVmOfflineNotification(vm.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
//存入redis
|
||||
set.add(vm.getId().toString());
|
||||
redisCache.setCacheSet(RedisConstant.NOTIFY_VM_IDS, set);
|
||||
}
|
||||
});
|
||||
hostMachineService.saveOrUpdateBatch(vms);
|
||||
|
||||
//检测物理机在线状态(检测物理机要用探测器的isTureUrl接口)
|
||||
LambdaQueryWrapper<HostDetector> detectorWrapper = new LambdaQueryWrapper<>();
|
||||
List<HostDetector> hostDetectors = hostDetectorService.list(detectorWrapper);
|
||||
List<HostMachine> hostMachines = new ArrayList<>();
|
||||
hostDetectors.forEach(detector -> {
|
||||
try {
|
||||
HttpRequest.get(detector.getDetectorIpAddress() + UrlConstant.DETECTOR_IS_TRUE_URL).setConnectionTimeout(1000).execute(true);
|
||||
HostMachine hostMachine = hostMachineService.getById(detector.getHostMachineId());
|
||||
if (Objects.nonNull(hostMachine)) {
|
||||
hostMachine.setHostMachineState(SystemConstant.HOST_MACHINE_STATE_ONLINE);
|
||||
hostMachines.add(hostMachine);
|
||||
}
|
||||
} catch (HttpException exception) {
|
||||
HostMachine hostMachine = hostMachineService.getById(detector.getHostMachineId());
|
||||
if (Objects.nonNull(hostMachine)) {
|
||||
hostMachine.setHostMachineState(SystemConstant.HOST_MACHINE_STATE_OFFLINE);
|
||||
hostMachines.add(hostMachine);
|
||||
}
|
||||
//判断Redis里面有没有 如果有就不需要提醒 如果没有就提醒
|
||||
Set<String> set = redisCache.getCacheSet(RedisConstant.NOTIFY_HOST_IDS);
|
||||
if (Objects.nonNull(set)){
|
||||
//如果redis里面有 说明已经发送过了未check的通知 所以不需要发送 直接返回
|
||||
if (set.contains(hostMachine.getId().toString())) {
|
||||
return;
|
||||
} else {
|
||||
//根据实例对应的提醒方式进行提醒
|
||||
if (hostMachine.getNotify().equals(SystemConstant.NOTIFY_NO)) {
|
||||
return;
|
||||
} else {
|
||||
notificationService.sendHostOfflineNotification(hostMachine.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
//存入redis
|
||||
set.add(hostMachine.getId().toString());
|
||||
redisCache.setCacheSet(RedisConstant.NOTIFY_HOST_IDS, set);
|
||||
}
|
||||
});
|
||||
hostMachineService.saveOrUpdateBatch(hostMachines);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.mzaxd.noodles.job;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.mzaxd.noodles.constant.SystemConstant;
|
||||
import com.mzaxd.noodles.domain.entity.AuditLog;
|
||||
import com.mzaxd.noodles.domain.entity.Container;
|
||||
import com.mzaxd.noodles.domain.entity.EveryDayData;
|
||||
import com.mzaxd.noodles.domain.entity.HostMachine;
|
||||
import com.mzaxd.noodles.service.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class EveryDayDataCollect {
|
||||
|
||||
@Resource
|
||||
private HostMachineService hostMachineService;
|
||||
|
||||
@Resource
|
||||
private ContainerService containerService;
|
||||
|
||||
@Resource
|
||||
private ServirService servirService;
|
||||
|
||||
@Resource
|
||||
private AuditLogService auditLogService;
|
||||
|
||||
@Resource
|
||||
private EveryDayDataService everyDayDataService;
|
||||
|
||||
/**
|
||||
* 每天晚上收集今日数据
|
||||
*/
|
||||
@Scheduled(cron = "0 59 23 * * ?")
|
||||
public void everyDayDataCollect() {
|
||||
EveryDayData everyDayData = new EveryDayData();
|
||||
LambdaQueryWrapper<AuditLog> auditLogWrapper = new LambdaQueryWrapper<>();
|
||||
Map<String, Integer> hostStateInfo = hostMachineService.getHostStateInfo();
|
||||
Map<String, Integer> vmStateInfo = hostMachineService.getVmStateInfo();
|
||||
Map<String, Integer> containerStateInfo = containerService.getContainerStateInfo();
|
||||
//设置主机总数
|
||||
everyDayData.setHostCount(hostStateInfo.get("hostCount"));
|
||||
//设置主机在线总数
|
||||
everyDayData.setHostOnlineCount(hostStateInfo.get("hostOnlineCount"));
|
||||
//设置主机离线总数
|
||||
everyDayData.setHostOfflineCount(hostStateInfo.get("hostOfflineCount"));
|
||||
//设置主机未知总数
|
||||
everyDayData.setHostUnknownCount(hostStateInfo.get("hostUnknownCount"));
|
||||
//设置虚拟机总数
|
||||
everyDayData.setVmCount(vmStateInfo.get("vmCount"));
|
||||
//设置虚拟机在线总数
|
||||
everyDayData.setVmOnlineCount(vmStateInfo.get("vmOnlineCount"));
|
||||
//设置虚拟机离线总数
|
||||
everyDayData.setVmOfflineCount(vmStateInfo.get("vmOfflineCount"));
|
||||
//设置虚拟机未知总数
|
||||
everyDayData.setVmUnknownCount(vmStateInfo.get("vmUnknownCount"));
|
||||
//设置容器总数
|
||||
everyDayData.setContainerCount(containerStateInfo.get("containerCount"));
|
||||
//设置容器在线总数
|
||||
everyDayData.setContainerOnlineCount(containerStateInfo.get("containerOnlineCount"));
|
||||
//设置容器离线总数
|
||||
everyDayData.setContainerOfflineCount(containerStateInfo.get("containerOfflineCount"));
|
||||
//设置容器未知总数
|
||||
everyDayData.setContainerUnknownCount(containerStateInfo.get("containerUnknownCount"));
|
||||
//设置服务总数
|
||||
everyDayData.setServirCount(servirService.count());
|
||||
//设置操作总数
|
||||
auditLogWrapper.ge(AuditLog::getCreateTime, DateUtil.beginOfDay(DateUtil.date()));
|
||||
auditLogWrapper.lt(AuditLog::getCreateTime, DateUtil.endOfDay(DateUtil.date()));
|
||||
everyDayData.setAuditCount(auditLogService.count(auditLogWrapper));
|
||||
everyDayDataService.save(everyDayData);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.mzaxd.noodles.listener;
|
||||
|
||||
import com.mzaxd.noodles.constant.RabbitMqConstant;
|
||||
import com.mzaxd.noodles.constant.RedisConstant;
|
||||
import com.mzaxd.noodles.domain.message.DynamicData;
|
||||
import com.mzaxd.noodles.util.RedisCache;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.annotation.Queue;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.messaging.handler.annotation.Payload;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RabbitListener(queuesToDeclare = @Queue(RabbitMqConstant.DYNAMIC_DATA_TOPIC))
|
||||
public class RabbitDynamicDataConsumer {
|
||||
|
||||
@Resource
|
||||
private RedisCache redisCache;
|
||||
|
||||
@RabbitHandler
|
||||
public void process(@Payload DynamicData dynamicData) {
|
||||
log.info("开始消费动态数据消息");
|
||||
//将Redis中旧的数据删除
|
||||
redisCache.deleteObject(RedisConstant.DYNAMIC_DATA + dynamicData.getDetectorId());
|
||||
//将新的动态数据存入Redis
|
||||
redisCache.setCacheObject(RedisConstant.DYNAMIC_DATA + dynamicData.getDetectorId(), dynamicData);
|
||||
log.info("更新Redis中动态数据成功");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.mzaxd.noodles.mapper;
|
||||
|
||||
import com.mzaxd.noodles.domain.entity.AuditLog;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
* @description 针对表【audit_log】的数据库操作Mapper
|
||||
* @createDate 2023-02-13 12:19:26
|
||||
* @Entity com.mzaxd.noodles.domain.entity.AuditLog
|
||||
*/
|
||||
public interface AuditLogMapper extends BaseMapper<AuditLog> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.mzaxd.noodles.mapper;
|
||||
|
||||
import com.mzaxd.noodles.domain.entity.Container;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
* @description 针对表【container】的数据库操作Mapper
|
||||
* @createDate 2023-02-02 06:26:00
|
||||
* @Entity com.mzaxd.noodles.domain.entity.Container
|
||||
*/
|
||||
public interface ContainerMapper extends BaseMapper<Container> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.mzaxd.noodles.mapper;
|
||||
|
||||
import com.mzaxd.noodles.domain.entity.EveryDayData;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author 13439
|
||||
* @description 针对表【every_data】的数据库操作Mapper
|
||||
* @createDate 2023-02-21 12:52:12
|
||||
* @Entity com.mzaxd.noodles.domain.entity.EveryDayData
|
||||
*/
|
||||
public interface EveryDayDataMapper extends BaseMapper<EveryDayData> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.mzaxd.noodles.mapper;
|
||||
|
||||
import com.mzaxd.noodles.domain.entity.HostDetector;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @author root
|
||||
* @description 针对表【host_detector】的数据库操作Mapper
|
||||
* @createDate 2023-02-05 13:18:46
|
||||
* @Entity com.mzaxd.noodles.domain.entity.HostDetector
|
||||
*/
|
||||
public interface HostDetectorMapper extends BaseMapper<HostDetector> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user