Initial commit all
parent
af4d04276d
commit
10ec801de3
bocloud.ams.booter
src/main
java/com/bocloud/ams/booter
controller
association
listener
bocloud.ams.entity
src/main/java/com/bocloud/ams
annotation
entity
config
model
|
@ -0,0 +1,10 @@
|
|||
*/target/*
|
||||
*/.settings/*
|
||||
*.classpath
|
||||
*.project
|
||||
*.prefs
|
||||
*.class
|
||||
*.iml
|
||||
/.idea/*
|
||||
*/.svn/*
|
||||
/target/
|
|
@ -0,0 +1,157 @@
|
|||
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>bocloud.ams</artifactId>
|
||||
<groupId>com.bocloud</groupId>
|
||||
<version>6.5.0-LTS-SZ</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>bocloud.ams.booter</artifactId>
|
||||
<version>${bocloud.booter.version}</version>
|
||||
<dependencies>
|
||||
<!--spring boot -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- Bocloud相关配置 -->
|
||||
<dependency>
|
||||
<groupId>com.bocloud</groupId>
|
||||
<artifactId>bocloud.ams.service</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.freedom</groupId>
|
||||
<artifactId>megatron.microservice</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-test</artifactId>
|
||||
<version>2.3.5.RELEASE</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<version>5.2.10.RELEASE</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!--for spring boot 3-->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>2.0.7</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<configuration>
|
||||
<parameters>true</parameters>
|
||||
<source>21</source>
|
||||
<target>21</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>com.bocloud.ams.booter.Application</mainClass>
|
||||
<addClasspath>true</addClasspath>
|
||||
<useUniqueVersions>false</useUniqueVersions>
|
||||
<classpathPrefix>libs/</classpathPrefix>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>3.6.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<type>jar</type>
|
||||
<includeTypes>jar</includeTypes>
|
||||
<includeScope>runtime</includeScope>
|
||||
<outputDirectory>${project.build.directory}/libs</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>bocloud.booter.tomcat</id>
|
||||
<properties>
|
||||
<bocloud.booter.version>6.5.0-LTS-SZ</bocloud.booter.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>bocloud.booter.tongweb</id>
|
||||
<properties>
|
||||
<bocloud.booter.version>6.5.0-LTS-SZ-TONGWEB</bocloud.booter.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.tongweb</groupId>
|
||||
<artifactId>tongweb-embed</artifactId>
|
||||
<version>7.0.E.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.tongweb.springboot</groupId>
|
||||
<artifactId>tongweb-spring-boot-starter</artifactId>
|
||||
<version>2.x.0.RELEASE</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
|
@ -0,0 +1,24 @@
|
|||
package com.bocloud.ams.booter;
|
||||
|
||||
import org.springframework.amqp.rabbit.annotation.EnableRabbit;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
/**
|
||||
* CMDB服务启动类
|
||||
*
|
||||
* @author DMW
|
||||
*/
|
||||
@SpringBootApplication
|
||||
@EnableRabbit
|
||||
@EnableDiscoveryClient
|
||||
@EnableScheduling
|
||||
@ComponentScan(value = {"com.bocloud", "com.megatron"})
|
||||
public class Application {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,145 @@
|
|||
package com.bocloud.ams.booter.config;
|
||||
|
||||
import com.bocloud.ams.booter.listener.TaskResultListener;
|
||||
import com.megatron.common.utils.MapTools;
|
||||
import org.springframework.amqp.core.*;
|
||||
import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory;
|
||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||
import org.springframework.amqp.rabbit.core.RabbitAdmin;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.amqp.rabbit.listener.RabbitListenerContainerFactory;
|
||||
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
|
||||
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
|
||||
import org.springframework.amqp.support.converter.MessageConverter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.boot.autoconfigure.amqp.SimpleRabbitListenerContainerFactoryConfigurer;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "spring.rabbitmq")
|
||||
public class RabbitMQConfiguration {
|
||||
private Map<String, Object> arguments = MapTools.simpleMap("x-ha-policy", "all");
|
||||
@Autowired
|
||||
private ConnectionFactory connectionFactory;
|
||||
|
||||
/**
|
||||
* 声明审计日志队列
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public Queue declareLogQueue() {
|
||||
return new Queue("bocloud.log.queue", true, false, false, arguments);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 声明默认的交换
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public DirectExchange deafultExchange() {
|
||||
return new DirectExchange("bocloud.direct.exchange", true, true, arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定日志队列
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public Binding bindingLogQueue() {
|
||||
return BindingBuilder.bind(declareLogQueue()).to(deafultExchange()).withQueueName();
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定CMDB任务队列
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public Binding bindingCmdbQueue() {
|
||||
return BindingBuilder.bind(declareTaskResultQueue()).to(deafultExchange()).withQueueName();
|
||||
}
|
||||
|
||||
/**
|
||||
* 声明任务执行队列
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public Queue declareTaskResultQueue() {
|
||||
return new Queue("cmdb.task.result.queue", true, false, false, arguments);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MessageConverter messageConverter() {
|
||||
return new Jackson2JsonMessageConverter();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public RabbitTemplate amqpTemplate() {
|
||||
RabbitTemplate amqpTemplate = new RabbitTemplate(connectionFactory);
|
||||
amqpTemplate.setMessageConverter(messageConverter());
|
||||
amqpTemplate.setExchange(deafultExchange().getName());
|
||||
return amqpTemplate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置手动消费确认
|
||||
*
|
||||
* @param connectionFactory
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public RabbitListenerContainerFactory<?> rabbitListenerContainerFactory(ConnectionFactory connectionFactory) {
|
||||
SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
|
||||
factory.setConnectionFactory(connectionFactory);
|
||||
factory.setMessageConverter(new Jackson2JsonMessageConverter());
|
||||
factory.setAcknowledgeMode(AcknowledgeMode.MANUAL);
|
||||
return factory;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public SimpleMessageListenerContainer autoJobCompletedListener(TaskResultListener taskResultListener) {
|
||||
SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(connectionFactory);
|
||||
container.setQueues(declareTaskResultQueue());
|
||||
// 设置确认模式自动确认
|
||||
container.setAcknowledgeMode(AcknowledgeMode.AUTO);
|
||||
container.setMessageListener(taskResultListener);
|
||||
return container;
|
||||
}
|
||||
|
||||
@Bean("customContainerFactory")
|
||||
public SimpleRabbitListenerContainerFactory containerFactory(SimpleRabbitListenerContainerFactoryConfigurer configurer, ConnectionFactory connectionFactory) {
|
||||
SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
|
||||
//设置线程数
|
||||
factory.setConcurrentConsumers(10);
|
||||
//最大线程数
|
||||
factory.setMaxConcurrentConsumers(10);
|
||||
configurer.configure(factory, connectionFactory);
|
||||
return factory;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public RabbitAdmin rabbitAdmin() {
|
||||
RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory);
|
||||
return rabbitAdmin;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Scope(ConfigurableBeanFactory.SCOPE_PROTOTYPE)
|
||||
public AmqpAdmin amqpAdmin() {
|
||||
AmqpAdmin amqpAdmin = new RabbitAdmin(connectionFactory);
|
||||
return amqpAdmin;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.bocloud.ams.booter.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Contact;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
|
||||
@Configuration
|
||||
public class SwaggerConfiguration {
|
||||
|
||||
@Bean
|
||||
public OpenAPI openAPI() {
|
||||
Contact contact = new Contact().name("未伟").email("weiwei@beyondcent.com").url("http://www.bocloud.com/");
|
||||
Info info = new Info().title("CMDB服务API接口文档").description("CMDB服务API接口文档")
|
||||
.termsOfService("http://www.bocloud.com/").contact(contact).version("1.0");
|
||||
return new OpenAPI().info(info);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package com.bocloud.ams.booter.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.bocloud.cmp.boot.config.PagerArgumentResolver;
|
||||
import com.bocloud.cmp.boot.interceptor.AccessInterceptor;
|
||||
import com.bocloud.cmp.boot.interceptor.LogInterceptor;
|
||||
import com.megatron.framework.core.InterceptorBridge;
|
||||
import com.megatron.framework.core.config.InterceptorConfiguration;
|
||||
import com.megatron.framework.core.domain.InterceptorEntity;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 拦截器配置类
|
||||
*
|
||||
* @author dmw
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class WebInterceptorConfiguration implements InterceptorConfiguration {
|
||||
|
||||
private static final String[] ACCESS_EXCLUDES = new String[] {"/status", "/status/db", "/status/**",
|
||||
"/v1/status/**", "/login", "/sso", "/v1/logview", "/v1/logzip", "/v1/config/**", "/v1/plugins/**", "/*/*.css",
|
||||
"/*/*.js", "/*/*.png", "/*/*.jpg", "/*/*.jpeg", "/*.html", "/*/*.html", "/swagger-resources/**", "/favicon.ico",
|
||||
"/webjars/**", "/v3/**", "/swagger-ui.html/**", "**/api-docs", "/error", "/favicon.ico"};
|
||||
private static final String[] LOG_EXCLUDES = new String[] {"/*/*.css", "/*/*.js", "/*/*.png", "/*/*.jpg",
|
||||
"/*/*.jpeg", "/*.html", "/*/*.html", "/swagger-resources/**", "/favicon.ico", "/webjars/**", "/v3/**",
|
||||
"/swagger-ui.html/**", "**/api-docs", "/error", "/favicon.ico"};
|
||||
private static final String[] INCLUDES = new String[] {"/**"};
|
||||
private final LogInterceptor logInterceptor;
|
||||
private final AccessInterceptor accessInterceptor;
|
||||
|
||||
@Autowired
|
||||
public WebInterceptorConfiguration(AccessInterceptor accessInterceptor, LogInterceptor logInterceptor) {
|
||||
this.logInterceptor = logInterceptor;
|
||||
this.accessInterceptor = accessInterceptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InterceptorBridge buildBridge() {
|
||||
log.info("start to build interceptors...");
|
||||
InterceptorBridge bridge = new InterceptorBridge();
|
||||
InterceptorEntity accessEntity = InterceptorEntity.builder().interceptor(accessInterceptor).includes(INCLUDES)
|
||||
.excludes(ACCESS_EXCLUDES).order(0).build();
|
||||
InterceptorEntity auditLogEntity = InterceptorEntity.builder().interceptor(logInterceptor).includes(INCLUDES)
|
||||
.excludes(LOG_EXCLUDES).order(1).build();
|
||||
List<InterceptorEntity> interceptors = new ArrayList<>();
|
||||
interceptors.add(accessEntity);
|
||||
interceptors.add(auditLogEntity);
|
||||
bridge.setInterceptors(interceptors);
|
||||
bridge.setResolvers(Collections.singletonList(new PagerArgumentResolver()));
|
||||
bridge.setMessageConverters(new ArrayList<>(0));
|
||||
log.info("build interceptors success!!!");
|
||||
return bridge;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
package com.bocloud.ams.booter.controller.association;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.bocloud.ams.entity.association.AutoRelationRule;
|
||||
import com.bocloud.ams.entity.association.AutoRelationRuleItem;
|
||||
import com.bocloud.ams.service.association.AutoRelationRuleService;
|
||||
import com.megatron.common.model.GeneralResult;
|
||||
import com.megatron.common.model.GridBean;
|
||||
import com.megatron.common.model.Pager;
|
||||
import com.megatron.common.model.RequestContext;
|
||||
import com.megatron.common.utils.Common;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1/rule")
|
||||
@Tag(name = "关联规则管理")
|
||||
public class AutoRelationRuleController {
|
||||
|
||||
@Autowired
|
||||
private AutoRelationRuleService autoRelationRuleService;
|
||||
|
||||
/**
|
||||
* 关联规则展示
|
||||
*
|
||||
* @param pager
|
||||
* @return
|
||||
*/
|
||||
@Operation(tags = {"CMC"}, summary = "关联规则列表")
|
||||
@GetMapping
|
||||
public GeneralResult<GridBean<AutoRelationRule>> list(Pager pager) {
|
||||
return autoRelationRuleService.list(pager);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增关联规则
|
||||
*
|
||||
* @param rule
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@Operation(tags = {"CMC"}, summary = "关联规则新增")
|
||||
@PostMapping
|
||||
public GeneralResult<Void> save(@RequestBody AutoRelationRule rule,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return autoRelationRuleService.save(rule, context.getTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新关联规则
|
||||
*
|
||||
* @param id
|
||||
* @param rule
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@Operation(tags = {"CMC"}, summary = "关联规则修改")
|
||||
@PutMapping(value = "/{id}")
|
||||
public GeneralResult<Void> modify(@PathVariable(value = Common.ID) Long id, @RequestBody AutoRelationRule rule,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return autoRelationRuleService.modify(id, rule, context.getTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联规则详情
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Operation(tags = {"CMC"}, summary = "关联规则详情")
|
||||
@GetMapping(value = "/{id}")
|
||||
public GeneralResult<AutoRelationRule> detail(@PathVariable(value = Common.ID) Long id) {
|
||||
return autoRelationRuleService.detail(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联规则明细详情
|
||||
*
|
||||
* @param itemId
|
||||
* @return
|
||||
*/
|
||||
@Operation(tags = {"CMC"}, summary = "关联规则明细详情")
|
||||
@GetMapping(value = "/{id}/items/{itemId}")
|
||||
public GeneralResult<AutoRelationRuleItem> itemDetail(@PathVariable("itemId") Long itemId) {
|
||||
return autoRelationRuleService.itemDetail(itemId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除关联规则
|
||||
*
|
||||
* @param id
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@Operation(tags = {"CMC"}, summary = "关联规则删除")
|
||||
@DeleteMapping(value = "/{id}")
|
||||
public GeneralResult<Void> remove(@PathVariable(value = Common.ID) Long id,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return autoRelationRuleService.remove(id, context.getTarget());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package com.bocloud.ams.booter.controller.audit;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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 com.bocloud.ams.entity.audit.OperationalAudit;
|
||||
import com.bocloud.ams.entity.audit.OperationalAuditBak;
|
||||
import com.bocloud.ams.service.audit.OperationalAuditService;
|
||||
import com.megatron.common.model.GeneralResult;
|
||||
import com.megatron.common.model.GridBean;
|
||||
import com.megatron.common.model.Pager;
|
||||
import com.megatron.common.utils.Common;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1/operational/audit")
|
||||
@Tag(name = "操作审计管理")
|
||||
public class OperationalAuditController {
|
||||
|
||||
@Autowired
|
||||
private OperationalAuditService operationalAuditService;
|
||||
|
||||
/**
|
||||
* 资源变更记录
|
||||
*
|
||||
* @param pager
|
||||
* @return
|
||||
*/
|
||||
@Operation(tags = {"CMC"}, summary = "操作审计列表")
|
||||
@GetMapping
|
||||
public GeneralResult<GridBean<OperationalAudit>> operationalAudit(Pager pager) {
|
||||
return operationalAuditService.list(pager);
|
||||
}
|
||||
|
||||
/**
|
||||
* 资源变更记录详情
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Operation(tags = {"CMC"}, summary = "操作审计详情")
|
||||
@GetMapping(value = "/{id}")
|
||||
public GeneralResult<OperationalAudit> operationalAudit(@PathVariable(value = Common.ID) Long id) {
|
||||
return operationalAuditService.deatil(id);
|
||||
}
|
||||
|
||||
@Operation(tags = {"CMC"}, summary = "操作审计备份列表")
|
||||
@GetMapping(value = "/bak")
|
||||
public GeneralResult<GridBean<OperationalAuditBak>> operationalAuditBak(Pager pager) {
|
||||
return operationalAuditService.bakList(pager);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package com.bocloud.ams.booter.controller.collection;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.bocloud.ams.entity.collection.CollectionHistory;
|
||||
import com.bocloud.ams.entity.model.CollectionHistoryModel;
|
||||
import com.bocloud.ams.service.collection.CollectionHistoryService;
|
||||
import com.megatron.common.model.GeneralResult;
|
||||
import com.megatron.common.model.GridBean;
|
||||
import com.megatron.common.model.Pager;
|
||||
import com.megatron.common.model.RequestContext;
|
||||
import com.megatron.common.utils.Common;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1/collection/history")
|
||||
@Tag(name = "采集历史管理")
|
||||
public class CollectionHistoryController {
|
||||
|
||||
@Autowired
|
||||
private CollectionHistoryService collectionHistoryService;
|
||||
|
||||
@Operation(tags = {"CMC"}, summary = "实例采集历史列表")
|
||||
@GetMapping("/instances")
|
||||
public GeneralResult<GridBean<Map<String, Object>>> list(Pager pager,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return collectionHistoryService.instances(pager, context.getTarget());
|
||||
}
|
||||
|
||||
@Operation(tags = {"CMC"}, summary = "采集历史列表")
|
||||
@GetMapping
|
||||
public GeneralResult<GridBean<CollectionHistory>> history(Pager pager) {
|
||||
return collectionHistoryService.list(pager);
|
||||
}
|
||||
|
||||
@Operation(tags = {"CMC"}, summary = "采集历史新增")
|
||||
@PostMapping
|
||||
public GeneralResult<Void> save(@RequestBody CollectionHistory history,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return collectionHistoryService.create(history);
|
||||
}
|
||||
|
||||
@PutMapping(value = "/{id}")
|
||||
@Operation(tags = {"CMC"}, summary = "采集历史修改")
|
||||
public GeneralResult<Void> modify(@RequestBody CollectionHistory history,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return collectionHistoryService.modify(history);
|
||||
}
|
||||
|
||||
@PutMapping(value = "/batch")
|
||||
@Operation(tags = {"CMC"}, summary = "采集历史批量新增")
|
||||
public GeneralResult<String> batchModify(@RequestBody CollectionHistoryModel historyModel,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return collectionHistoryService.batchModify(historyModel, context.getTarget());
|
||||
}
|
||||
|
||||
@Operation(tags = {"CMC"}, summary = "采集历史备份列表")
|
||||
@GetMapping("/backup")
|
||||
public GeneralResult<GridBean<CollectionHistory>> backupHistory(Pager pager) {
|
||||
return collectionHistoryService.backupHistory(pager);
|
||||
}
|
||||
|
||||
@Operation(tags = {"CMC"}, summary = "实例采集历史备份列表")
|
||||
@GetMapping("/backup/instances")
|
||||
public GeneralResult<GridBean<Map<String, Object>>> backupList(Pager pager,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return collectionHistoryService.backupList(pager, context.getTarget());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.bocloud.ams.booter.controller.collection;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.bocloud.ams.entity.collection.CollectionHistoryItem;
|
||||
import com.bocloud.ams.service.collection.CollectionHistoryItemService;
|
||||
import com.megatron.common.model.GeneralResult;
|
||||
import com.megatron.common.model.GridBean;
|
||||
import com.megatron.common.model.Pager;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1/collection/history/item")
|
||||
@Tag(name = "采集历史条目管理")
|
||||
public class CollectionHistoryItemController {
|
||||
|
||||
@Autowired
|
||||
private CollectionHistoryItemService collectionHistoryItemService;
|
||||
|
||||
@Operation(tags = {"CMC"}, summary = "采集历史条目列表")
|
||||
@GetMapping
|
||||
public GeneralResult<GridBean<CollectionHistoryItem>> historyItems(Pager pager) {
|
||||
return collectionHistoryItemService.list(pager);
|
||||
}
|
||||
|
||||
@Operation(tags = {"CMC"}, summary = "实例采集历史条目备份列表")
|
||||
@GetMapping("/backup")
|
||||
public GeneralResult<GridBean<CollectionHistoryItem>> backupHistoryItems(Pager pager) {
|
||||
return collectionHistoryItemService.backupHistoryItems(pager);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,161 @@
|
|||
package com.bocloud.ams.booter.controller.collection;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PatchMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.bocloud.ams.entity.collection.CollectionTask;
|
||||
import com.bocloud.ams.entity.model.OperateParam;
|
||||
import com.bocloud.ams.service.collection.CollectionTaskService;
|
||||
import com.megatron.common.model.GeneralResult;
|
||||
import com.megatron.common.model.GridBean;
|
||||
import com.megatron.common.model.Pager;
|
||||
import com.megatron.common.model.RequestContext;
|
||||
import com.megatron.common.utils.Common;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1/collection/tasks")
|
||||
@Tag(name = "采集任务管理")
|
||||
public class CollectionTaskController implements ApplicationListener<ApplicationReadyEvent> {
|
||||
|
||||
@Autowired
|
||||
private CollectionTaskService collectionTaskService;
|
||||
|
||||
/**
|
||||
* 启动作业
|
||||
*
|
||||
* @param id
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@PatchMapping(value = "/{id}/start")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "采集任务执行")
|
||||
public GeneralResult<Long> start(@PathVariable(value = Common.ID) Long id,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return collectionTaskService.start(id, context);
|
||||
}
|
||||
|
||||
/**
|
||||
* 采集任务列表
|
||||
*
|
||||
* @param pager
|
||||
* @return
|
||||
*/
|
||||
@Operation(tags = {"CMC"}, summary = "采集任务列表")
|
||||
@GetMapping
|
||||
public GeneralResult<GridBean<CollectionTask>> list(Pager pager) {
|
||||
return collectionTaskService.list(pager);
|
||||
}
|
||||
|
||||
/**
|
||||
* 采集任务创建
|
||||
*
|
||||
* @param task
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@PostMapping
|
||||
@Operation(tags = {"CMC"}, summary = "采集任务创建")
|
||||
public GeneralResult<CollectionTask> create(@RequestBody CollectionTask task,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return collectionTaskService.save(task, context);
|
||||
}
|
||||
|
||||
/**
|
||||
* 采集任务修改
|
||||
*
|
||||
* @param bean
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@PutMapping(value = "/{id}")
|
||||
@Operation(tags = {"CMC"}, summary = "采集任务修改")
|
||||
public GeneralResult<CollectionTask> modify(@RequestBody CollectionTask bean,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return collectionTaskService.modify(bean, context);
|
||||
}
|
||||
|
||||
/**
|
||||
* 采集任务类型变更->由定时任务变更为常规任务
|
||||
*
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@PatchMapping(value = "/{id}")
|
||||
@Operation(tags = {"CMC"}, summary = "采集任务定时任务转为常规任务")
|
||||
public GeneralResult<CollectionTask> modifyType(@PathVariable(value = Common.ID) Long id,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return collectionTaskService.modifyType(id, context);
|
||||
}
|
||||
|
||||
/**
|
||||
* 采集任务删除
|
||||
*
|
||||
* @param id
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping(value = "/{id}")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "采集任务删除")
|
||||
public GeneralResult<Void> remove(@PathVariable(value = Common.ID) Long id,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return collectionTaskService.remove(id, context.getTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* 采集任务详情
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/{id}")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "采集任务详情")
|
||||
public GeneralResult<CollectionTask> detail(@PathVariable(value = Common.ID) Long id) {
|
||||
return collectionTaskService.detail(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 采集定时任务操作-启动/暂停
|
||||
*
|
||||
* @param operateParam
|
||||
* @param requestContext
|
||||
* @return
|
||||
*/
|
||||
@PatchMapping(value = "/{id}/schedule")
|
||||
@Operation(summary = "采集任务定时任务操作-启动/暂停")
|
||||
public GeneralResult<Void> operate(@RequestBody OperateParam operateParam, @PathVariable(value = Common.ID) Long id,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext requestContext) {
|
||||
return collectionTaskService.operate(operateParam, id, requestContext.getTarget());
|
||||
}
|
||||
|
||||
@GetMapping(value = "/{id}/schedule")
|
||||
@Operation(tags = {"CMC"}, summary = "采集任务为定时采集添加任务(主服务有效)")
|
||||
public GeneralResult<String> addScheduleIfLeader(@PathVariable(Common.ID) Long id,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext requestContext) {
|
||||
return collectionTaskService.addScheduleIfLeader(id);
|
||||
}
|
||||
|
||||
@DeleteMapping(value = "/{id}/schedule")
|
||||
@Operation(tags = {"CMC"}, summary = "采集任务为定时采集删除任务(主服务有效)")
|
||||
public GeneralResult<String> removeScheduleIfLeader(@PathVariable(Common.ID) Long id) {
|
||||
return collectionTaskService.removeScheduleIfLeader(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationReadyEvent event) {
|
||||
collectionTaskService.onApplicationReadyEvent();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package com.bocloud.ams.booter.controller.collection;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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 com.bocloud.ams.entity.collection.CollectionTaskInstance;
|
||||
import com.bocloud.ams.service.collection.CollectionTaskInstanceService;
|
||||
import com.megatron.common.model.GeneralResult;
|
||||
import com.megatron.common.model.GridBean;
|
||||
import com.megatron.common.model.Pager;
|
||||
import com.megatron.common.utils.Common;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1/collection/tasks/instances")
|
||||
@Tag(name = "采集任务实例管理")
|
||||
public class CollectionTaskInstanceController {
|
||||
|
||||
@Autowired
|
||||
private CollectionTaskInstanceService collectionTaskInstanceService;
|
||||
|
||||
/**
|
||||
* 采集任务实例列表
|
||||
*
|
||||
* @param pager
|
||||
* @return
|
||||
*/
|
||||
@Operation(tags = {"CMC"}, summary = "采集任务实例列表")
|
||||
@GetMapping
|
||||
public GeneralResult<GridBean<CollectionTaskInstance>> list(Pager pager) {
|
||||
return collectionTaskInstanceService.list(pager);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/{id}")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "采集任务实例详情")
|
||||
public GeneralResult<CollectionTaskInstance> detail(@PathVariable(value = Common.ID) Long id) {
|
||||
return collectionTaskInstanceService.detail(id);
|
||||
}
|
||||
|
||||
@Operation(tags = {"CMC"}, summary = "采集任务实例备份列表")
|
||||
@GetMapping("/backup")
|
||||
public GeneralResult<GridBean<CollectionTaskInstance>> bakList(Pager pager) {
|
||||
return collectionTaskInstanceService.bakList(pager);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/{name}/{id}")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "采集任务实例备份详情")
|
||||
public GeneralResult<CollectionTaskInstance> bakDetail(@PathVariable(value = Common.ID) Long id,
|
||||
@PathVariable(value = Common.NAME) String name) {
|
||||
return collectionTaskInstanceService.bakDetail(id, name);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,113 @@
|
|||
package com.bocloud.ams.booter.controller.collection;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.bocloud.ams.entity.collection.CollectionComponent;
|
||||
import com.bocloud.ams.entity.collection.CollectionTemplate;
|
||||
import com.bocloud.ams.service.collection.CollectionTemplateService;
|
||||
import com.megatron.common.model.GeneralResult;
|
||||
import com.megatron.common.model.GridBean;
|
||||
import com.megatron.common.model.Pager;
|
||||
import com.megatron.common.model.RequestContext;
|
||||
import com.megatron.common.utils.Common;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1/collection/templates")
|
||||
@Tag(name = "采集插件管理")
|
||||
public class CollectionTemplateController {
|
||||
|
||||
@Autowired
|
||||
private CollectionTemplateService collectionTemplateService;
|
||||
|
||||
/**
|
||||
* 采集模板组件列表
|
||||
*
|
||||
* @param pager
|
||||
* @return
|
||||
*/
|
||||
@Operation(tags = {"CMC"}, summary = "采集插件组件列表")
|
||||
@GetMapping(value = "/components")
|
||||
public GeneralResult<GridBean<CollectionComponent>> components(Pager pager) {
|
||||
return collectionTemplateService.components(pager);
|
||||
}
|
||||
|
||||
/**
|
||||
* 采集插件列表
|
||||
*
|
||||
* @param pager
|
||||
* @return
|
||||
*/
|
||||
@Operation(tags = {"CMC"}, summary = "采集插件列表")
|
||||
@GetMapping
|
||||
public GeneralResult<GridBean<CollectionTemplate>> list(Pager pager) {
|
||||
return collectionTemplateService.list(pager);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增采集插件
|
||||
*
|
||||
* @param template
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@Operation(tags = {"CMC"}, summary = "采集插件新增")
|
||||
@PostMapping
|
||||
public GeneralResult<CollectionTemplate> save(@RequestBody CollectionTemplate template,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
template.setCreatorId(context.getTarget());
|
||||
return collectionTemplateService.save(template, context.getTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* 采集插件修改
|
||||
*
|
||||
* @param template
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@PutMapping(value = "/{id}")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "采集插件修改")
|
||||
public GeneralResult<CollectionTemplate> modify(@RequestBody CollectionTemplate template,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
template.setMenderId(context.getTarget());
|
||||
return collectionTemplateService.modify(template, context.getTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* 采集插件删除
|
||||
*
|
||||
* @param id
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping(value = "/{id}")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "采集插件删除")
|
||||
public GeneralResult<Void> remove(@PathVariable(value = Common.ID) Long id,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return collectionTemplateService.remove(id, context.getTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* 采集插件详情
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/{id}")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "采集插件详情")
|
||||
public GeneralResult<CollectionTemplate> detail(@PathVariable(value = Common.ID) Long id) {
|
||||
return collectionTemplateService.detail(id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,75 @@
|
|||
package com.bocloud.ams.booter.controller.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.bocloud.ams.entity.config.CmdbConfig;
|
||||
import com.bocloud.ams.service.config.CmdbConfigService;
|
||||
import com.megatron.common.model.GeneralResult;
|
||||
import com.megatron.common.model.RequestContext;
|
||||
import com.megatron.common.model.Result;
|
||||
import com.megatron.common.utils.Common;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1/cmdb/configs")
|
||||
@Tag(name = "配置中心配置管理")
|
||||
public class CmdbConfigController {
|
||||
|
||||
@Autowired
|
||||
private CmdbConfigService cmdbConfigService;
|
||||
|
||||
/**
|
||||
* 更新CMDB配置
|
||||
*
|
||||
* @param configs
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@PutMapping
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "配置中心配置修改")
|
||||
public Result modify(@RequestBody List<CmdbConfig> configs, @Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return cmdbConfigService.batchUpdate(configs, context);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询CMDB配置
|
||||
*
|
||||
* @param category
|
||||
* @param codes
|
||||
* @return
|
||||
*/
|
||||
@GetMapping
|
||||
@Operation(summary = "配置中心配置批量查询")
|
||||
public GeneralResult<Map<String, String>> getByCodes(
|
||||
@RequestParam(value = "category", required = false) String category,
|
||||
@RequestParam(value = "codes", required = false) ArrayList<String> codes) {
|
||||
return cmdbConfigService.listConfigs(category, codes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询CMDB配置类型树
|
||||
*
|
||||
* @param category
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/tree")
|
||||
@Operation(summary = "配置中心配置类型树")
|
||||
public GeneralResult<JSONArray> listCategoryTree(@RequestParam(value = "category") String category) {
|
||||
return cmdbConfigService.listCategoryTree(category);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,89 @@
|
|||
package com.bocloud.ams.booter.controller.instance;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.bocloud.ams.entity.instance.InstanceAuthority;
|
||||
import com.bocloud.ams.service.instance.InstanceAuthorityService;
|
||||
import com.megatron.common.model.GeneralResult;
|
||||
import com.megatron.common.model.GridBean;
|
||||
import com.megatron.common.model.Pager;
|
||||
import com.megatron.common.model.RequestContext;
|
||||
import com.megatron.common.utils.Common;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1/instances/authority")
|
||||
@Tag(name = "实例权限管理")
|
||||
public class InstanceAuthoryController {
|
||||
|
||||
@Autowired
|
||||
private InstanceAuthorityService instanceAuthorityService;
|
||||
|
||||
/**
|
||||
* 实例权限列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(tags = {"CMC"}, summary = "实例权限列表")
|
||||
@GetMapping
|
||||
public GeneralResult<GridBean<InstanceAuthority>> list(Pager pager) {
|
||||
return instanceAuthorityService.list(pager);
|
||||
}
|
||||
|
||||
/***
|
||||
* 新增实例权限
|
||||
*
|
||||
* @param authority
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@Operation(tags = {"CMC"}, summary = "实例权限新增")
|
||||
@PostMapping
|
||||
public GeneralResult<Void> save(@RequestBody InstanceAuthority authority,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return instanceAuthorityService.create(authority, context.getTarget());
|
||||
}
|
||||
|
||||
@Operation(tags = {"CMC"}, summary = "实例权限修改")
|
||||
@PutMapping(value = "/{id}")
|
||||
public GeneralResult<Void> modify(@RequestBody InstanceAuthority authority,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return instanceAuthorityService.modify(authority, context.getTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除实例权限
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(tags = {"CMC"}, summary = "实例权限删除")
|
||||
@DeleteMapping(value = "/{id}")
|
||||
public GeneralResult<Void> remove(@PathVariable(value = Common.ID) Long id,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return instanceAuthorityService.remove(id, context.getTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除实例权限
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(tags = {"CMC"}, summary = "实例权限批量删除")
|
||||
@DeleteMapping(value = "/byrole")
|
||||
public GeneralResult<Void> removeByRole(@RequestBody InstanceAuthority authority,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return instanceAuthorityService.removeByRole(authority, context.getTarget());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,226 @@
|
|||
package com.bocloud.ams.booter.controller.instance;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.bocloud.ams.entity.instance.Instance;
|
||||
import com.bocloud.ams.entity.model.InstanceBean;
|
||||
import com.bocloud.ams.entity.model.InstanceTopo;
|
||||
import com.bocloud.ams.service.instance.InstanceService;
|
||||
import com.megatron.common.model.GeneralResult;
|
||||
import com.megatron.common.model.Pager;
|
||||
import com.megatron.common.model.RequestContext;
|
||||
import com.megatron.common.utils.Common;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/v1/instances")
|
||||
@Tag(name = "实例管理")
|
||||
public class InstanceController {
|
||||
|
||||
@Autowired
|
||||
private InstanceService instanceService;
|
||||
|
||||
@Operation(tags = {"CMC"}, summary = "实例列表")
|
||||
@GetMapping
|
||||
public GeneralResult<List<Map<String, Object>>> list(Pager pager,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return instanceService.list(pager, context.getTarget());
|
||||
}
|
||||
|
||||
/***
|
||||
* 新增实例
|
||||
*
|
||||
* @param instance
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@Operation(tags = {"CMC"}, summary = "实例新增")
|
||||
@PostMapping
|
||||
public GeneralResult save(@RequestBody JSONObject instance, @Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return instanceService.create(instance, context.getTarget(), true);
|
||||
}
|
||||
|
||||
/***
|
||||
* 更新实例
|
||||
*
|
||||
* @param instance
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@Operation(tags = {"CMC"}, summary = "实例修改")
|
||||
@PutMapping(value = "/{id}")
|
||||
public GeneralResult modify(@RequestBody JSONObject instance, @Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return instanceService.modify(instance, context.getTarget());
|
||||
}
|
||||
|
||||
/***
|
||||
* 批量更新实例
|
||||
*
|
||||
* @param instance
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@Operation(tags = {"CMC"}, summary = "实例批量更新")
|
||||
@PutMapping(value = "/batch")
|
||||
public GeneralResult<Void> batchModify(@RequestBody InstanceBean instance,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return instanceService.batchModify(instance, context.getTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除实例
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Operation(tags = {"CMC"}, summary = "实例删除")
|
||||
@DeleteMapping(value = "/{id}")
|
||||
public GeneralResult<Void> remove(@PathVariable(value = Common.ID) Long id,
|
||||
@RequestParam(value = "moduleCode") String moduleCode, @Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return instanceService.remove(id, moduleCode, context.getTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除实例
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(tags = {"CMC"}, summary = "实例批量删除")
|
||||
@DeleteMapping(value = "/batch")
|
||||
public GeneralResult<Void> batchRemove(@RequestBody InstanceBean model,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return instanceService.batchRemove(model, context.getTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* 实例查询明细
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Operation(tags = {"CMC"}, summary = "实例详情")
|
||||
@GetMapping(value = "/{id}")
|
||||
public GeneralResult<Instance> detail(@PathVariable(value = Common.ID) Long id,
|
||||
@RequestParam(value = "moduleCode") String moduleCode) {
|
||||
return instanceService.detail(id, moduleCode);
|
||||
}
|
||||
|
||||
@Operation(summary = "实例导出")
|
||||
@GetMapping(value = "/export")
|
||||
public void export(@RequestParam(value = "moduleId") Long moduleId,
|
||||
@RequestParam(value = "moduleCode") String moduleCode, @RequestParam(value = "type") String type,
|
||||
HttpServletRequest request, HttpServletResponse response, @Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
@SuppressWarnings("unchecked")
|
||||
GeneralResult GeneralResult = instanceService.export(moduleId, moduleCode, type, context.getTarget());
|
||||
if (GeneralResult.isSuccess()) {
|
||||
String content = null;
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> result =
|
||||
JSONObject.parseObject(JSONObject.toJSONString(GeneralResult.getData()), HashMap.class);
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
String fileName = result.get("fileName").toString();
|
||||
final String userAgent = request.getHeader("user-agent").toLowerCase();
|
||||
if (userAgent.contains("trident") || userAgent.contains("edge")) {
|
||||
fileName = URLEncoder.encode(fileName, "UTF-8");
|
||||
} else {
|
||||
fileName = new String(fileName.getBytes("utf-8"), "iso-8859-1");
|
||||
}
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setHeader("Content-Disposition", "attachment;fileName=" + fileName);
|
||||
OutputStream outputStream = response.getOutputStream();
|
||||
content = (String)result.get("data");
|
||||
|
||||
if (content != null) {
|
||||
byte[] bytes = Base64.getDecoder().decode(content);
|
||||
outputStream.write(bytes);
|
||||
outputStream.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("导出实例数据失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Operation(summary = "实例模板下载")
|
||||
@GetMapping(value = "/download")
|
||||
public void download(@RequestParam(value = "moduleId") Long moduleId,
|
||||
@RequestParam(value = "moduleCode") String moduleCode, @RequestParam(value = "type") String type,
|
||||
HttpServletRequest request, HttpServletResponse response, @Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
@SuppressWarnings("unchecked")
|
||||
GeneralResult GeneralResult = instanceService.download(moduleId, moduleCode, type, context.getTarget());
|
||||
if (GeneralResult.isSuccess()) {
|
||||
String content = null;
|
||||
try {
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> result =
|
||||
JSONObject.parseObject(JSONObject.toJSONString(GeneralResult.getData()), HashMap.class);
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
String fileName = result.get("fileName").toString();
|
||||
final String userAgent = request.getHeader("user-agent").toLowerCase();
|
||||
if (userAgent.contains("trident") || userAgent.contains("edge")) {
|
||||
fileName = URLEncoder.encode(fileName, "UTF-8");
|
||||
} else {
|
||||
fileName = new String(fileName.getBytes("utf-8"), "iso-8859-1");
|
||||
}
|
||||
response.setCharacterEncoding("utf-8");
|
||||
response.setHeader("Content-Disposition", "attachment;fileName=" + fileName);
|
||||
OutputStream outputStream = response.getOutputStream();
|
||||
content = (String)result.get("data");
|
||||
|
||||
if (content != null) {
|
||||
byte[] bytes = Base64.getDecoder().decode(content);
|
||||
outputStream.write(bytes);
|
||||
outputStream.close();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("下载实例模板失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "实例导入")
|
||||
@PostMapping(value = "/upload")
|
||||
public GeneralResult upload(@RequestParam(value = "moduleId") Long moduleId,
|
||||
@RequestParam(value = "moduleCode") String moduleCode,
|
||||
@RequestParam(value = "file", required = false) MultipartFile file, HttpServletRequest request,
|
||||
HttpServletResponse response, @Value(Common.REQ_CONTEXT) RequestContext context) throws IOException {
|
||||
return instanceService.upload(moduleId, moduleCode, file, context);
|
||||
}
|
||||
|
||||
@Operation(summary = "实例拓扑")
|
||||
@GetMapping(value = "/{id}/topo")
|
||||
public GeneralResult<InstanceTopo> topo(@PathVariable(value = Common.ID) Long id,
|
||||
@RequestParam(value = "relationCategoryId") Long relationCategoryId,
|
||||
@RequestParam(value = "moduleId") Long moduleId, @Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return instanceService.topo(id, relationCategoryId, moduleId, context.getTarget());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.bocloud.ams.booter.controller.instance;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.bocloud.ams.entity.instance.InstanceHistory;
|
||||
import com.bocloud.ams.service.instance.InstanceHistoryService;
|
||||
import com.megatron.common.model.GeneralResult;
|
||||
import com.megatron.common.model.GridBean;
|
||||
import com.megatron.common.model.Pager;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1/instances/history")
|
||||
@Tag(name = "实例变更记录管理")
|
||||
public class InstanceHistoryController {
|
||||
|
||||
@Autowired
|
||||
private InstanceHistoryService instanceHistoryService;
|
||||
|
||||
/**
|
||||
* 模型实例变更记录
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@Operation(tags = {"CMC"}, summary = "实例变更记录列表")
|
||||
@GetMapping
|
||||
public GeneralResult<GridBean<InstanceHistory>> history(Pager pager) {
|
||||
return instanceHistoryService.list(pager);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
|
||||
package com.bocloud.ams.booter.controller.instance;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.bocloud.ams.entity.instance.Instance;
|
||||
import com.bocloud.ams.entity.instance.InstanceRelation;
|
||||
import com.bocloud.ams.service.instance.InstanceAutoRelationService;
|
||||
import com.bocloud.ams.service.instance.InstanceRelationService;
|
||||
import com.megatron.common.model.GeneralResult;
|
||||
import com.megatron.common.model.RequestContext;
|
||||
import com.megatron.common.utils.Common;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value = "/v1/instances/relations")
|
||||
@Tag(name = "实例关系管理")
|
||||
public class InstanceRelationController {
|
||||
|
||||
@Autowired
|
||||
private InstanceRelationService instanceRelationService;
|
||||
|
||||
@Autowired
|
||||
private InstanceAutoRelationService instanceAutoRelationService;
|
||||
|
||||
/***
|
||||
* 新增实例关系
|
||||
*
|
||||
* @param relation
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@Operation(tags = {"CMC"}, summary = "实例关系关联")
|
||||
@PostMapping
|
||||
public GeneralResult<Void> save(@RequestBody InstanceRelation relation,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return instanceRelationService.create(relation, context);
|
||||
}
|
||||
|
||||
/***
|
||||
* 删除实例关系
|
||||
*
|
||||
* @param id
|
||||
* @param relationCategoryCode
|
||||
* @param currentInstanceId
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@Operation(tags = {"CMC"}, summary = "实例关系取消关联")
|
||||
@DeleteMapping(value = "/{id}")
|
||||
public GeneralResult<Void> remove(@PathVariable(value = Common.ID) Long id,
|
||||
@RequestParam(value = "relationCategoryCode") String relationCategoryCode,
|
||||
@RequestParam(value = "currentModuleId") Long currentModuleId,
|
||||
@RequestParam(value = "currentInstanceId") Long currentInstanceId,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return instanceRelationService.remove(id, relationCategoryCode, currentModuleId, currentInstanceId, context);
|
||||
}
|
||||
|
||||
@Operation(tags = {"CMC"}, summary = "实例关系实例数据自动关联")
|
||||
@PostMapping(value = "/auto/relation")
|
||||
public GeneralResult<Void> instanceAutoRelation(@RequestBody Instance instance,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return instanceAutoRelationService.instanceAutoRelation(instance, context.getTarget());
|
||||
}
|
||||
|
||||
@Operation(tags = {"CMC"}, summary = "实例关系全量数据自动关联")
|
||||
@GetMapping(value = "/auto/relation/all")
|
||||
public GeneralResult<Void> moduleAutoRelation() {
|
||||
return instanceAutoRelationService.autoRelation();
|
||||
}
|
||||
|
||||
@Operation(tags = {"CMC"}, summary = "实例关系模型数据自动关联")
|
||||
@GetMapping(value = "/auto/relation/{id}/module")
|
||||
public GeneralResult<Void> moduleAutoRelationByModuleId(@PathVariable(value = Common.ID) Long id) {
|
||||
return instanceAutoRelationService.autoRelationByModuleId(id);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package com.bocloud.ams.booter.controller.instance;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.bocloud.ams.entity.instance.InstanceRelationHistoryRecord;
|
||||
import com.bocloud.ams.entity.model.InstanceRelationHistoryPreflightModel;
|
||||
import com.bocloud.ams.service.instance.InstanceRelationHistoryRecordService;
|
||||
import com.megatron.common.model.GeneralResult;
|
||||
import com.megatron.common.model.GridBean;
|
||||
import com.megatron.common.model.Pager;
|
||||
import com.megatron.common.model.RequestContext;
|
||||
import com.megatron.common.utils.Common;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1/instances/relations/history")
|
||||
@Tag(name = "关联历史管理")
|
||||
public class InstanceRelationHistoryRecordController {
|
||||
|
||||
@Autowired
|
||||
private InstanceRelationHistoryRecordService instanceRelationHistoryRecordService;
|
||||
|
||||
/**
|
||||
* 关联历史列表
|
||||
*
|
||||
* @param pager
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@GetMapping
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "关联历史列表")
|
||||
public GeneralResult<GridBean<InstanceRelationHistoryRecord>> list(Pager pager,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return instanceRelationHistoryRecordService.list(pager);
|
||||
}
|
||||
|
||||
@PutMapping("/{id}/preflight")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "关联历史预检")
|
||||
public GeneralResult<InstanceRelationHistoryPreflightModel> preflight(@PathVariable(value = Common.ID) Long id,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return instanceRelationHistoryRecordService.preflight(id, context);
|
||||
|
||||
}
|
||||
|
||||
@PutMapping("/{id}/reconcile")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "关联历史调和")
|
||||
public GeneralResult reconcile(@PathVariable(value = Common.ID) Long id,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return instanceRelationHistoryRecordService.reconcile(id, context);
|
||||
|
||||
}
|
||||
|
||||
@PutMapping("/{id}/cancel")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "关联历史取消调和")
|
||||
public GeneralResult cancel(@PathVariable(value = Common.ID) Long id,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return instanceRelationHistoryRecordService.cancel(id, context);
|
||||
|
||||
}
|
||||
|
||||
@Operation(tags = {"CMC"}, summary = "关联历史批量取消调和")
|
||||
@PutMapping(value = "/batch/cancel")
|
||||
public GeneralResult<Void> batchCancel(@RequestBody List<Long> ids,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return instanceRelationHistoryRecordService.batchCancel(ids, context);
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,192 @@
|
|||
package com.bocloud.ams.booter.controller.module;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.bocloud.ams.entity.association.AutoRelationRule;
|
||||
import com.bocloud.ams.entity.model.PropertyModel;
|
||||
import com.bocloud.ams.entity.module.CiModule;
|
||||
import com.bocloud.ams.entity.module.Property;
|
||||
import com.bocloud.ams.entity.module.RelationCategory;
|
||||
import com.bocloud.ams.service.association.AutoRelationRuleService;
|
||||
import com.bocloud.ams.service.module.ModuleService;
|
||||
import com.bocloud.ams.service.module.RelationCategoryService;
|
||||
import com.megatron.common.model.GeneralResult;
|
||||
import com.megatron.common.model.GridBean;
|
||||
import com.megatron.common.model.Pager;
|
||||
import com.megatron.common.model.RequestContext;
|
||||
import com.megatron.common.utils.Common;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1/module")
|
||||
@Tag(name = "模型管理")
|
||||
public class ModuleController {
|
||||
|
||||
@Autowired
|
||||
private ModuleService moduleService;
|
||||
@Autowired
|
||||
private RelationCategoryService relationCategoryService;
|
||||
@Autowired
|
||||
private AutoRelationRuleService autoRelationRuleService;
|
||||
|
||||
/**
|
||||
* 查询属性池记录
|
||||
*
|
||||
* @param pager
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/collections")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "模型列表")
|
||||
public GeneralResult<GridBean<CiModule>> getModelList(Pager pager,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return moduleService.getModelList(pager);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询模型集合
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping
|
||||
@Operation(tags = {"CMC"}, summary = "模型列表(全部)")
|
||||
public GeneralResult<List<CiModule>> list() {
|
||||
return moduleService.list();
|
||||
}
|
||||
|
||||
/**
|
||||
* 模型查询明细
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/{id}")
|
||||
@Operation(tags = {"CMC"}, summary = "模型详情")
|
||||
public GeneralResult<CiModule> detail(@PathVariable(value = Common.ID) Long id) {
|
||||
return moduleService.detail(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增模型
|
||||
*
|
||||
* @param module
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@PostMapping
|
||||
@Operation(tags = {"CMC"}, summary = "模型新增")
|
||||
public GeneralResult<Void> save(@RequestBody CiModule module, @Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return moduleService.save(module, context.getTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新模型
|
||||
*
|
||||
* @param module
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@PutMapping(value = "/{id}")
|
||||
@Operation(tags = {"CMC"}, summary = "模型修改")
|
||||
public GeneralResult<Void> modify(@RequestBody CiModule module, @Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return moduleService.modify(module, context.getTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除模型
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping(value = "/{id}")
|
||||
@Operation(tags = {"CMC"}, summary = "模型删除")
|
||||
public GeneralResult<Void> remove(@PathVariable(value = Common.ID) Long id,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return moduleService.remove(id, context.getTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据模型Id查询关联分组
|
||||
*
|
||||
* @param id
|
||||
* 模型id
|
||||
* @Description: 根据模型Id查询关联分组
|
||||
* @Author majiali
|
||||
* @CreateTime 2022/6/15 16:07
|
||||
*/
|
||||
@GetMapping(value = "/{id}/relation/category")
|
||||
@Operation(tags = {"CMC"}, summary = "模型关联分组查询")
|
||||
public GeneralResult<List<RelationCategory>> listRelationCategory(@PathVariable(value = Common.ID) Long id) {
|
||||
return relationCategoryService.listByModuleId(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据模型id和关联分组id查询关联规则
|
||||
*
|
||||
* @param id
|
||||
* @param relationCategoryId
|
||||
* @return
|
||||
*/
|
||||
@Operation(tags = {"CMC"}, summary = "模型关联分组关联规则查询")
|
||||
@GetMapping(value = "/{id}/relation/rule")
|
||||
public GeneralResult<List<AutoRelationRule>> list(@PathVariable(value = Common.ID) Long id,
|
||||
@RequestParam(value = "relationCategoryId") Long relationCategoryId) {
|
||||
return autoRelationRuleService.list(id, relationCategoryId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看模型属性
|
||||
*
|
||||
* @param id
|
||||
* @return 查看模型属性
|
||||
*/
|
||||
@GetMapping(value = "/{id}/properties")
|
||||
@Operation(summary = "模型属性查询")
|
||||
public GeneralResult<PropertyModel> property(@PathVariable(value = Common.ID) Long id) {
|
||||
return moduleService.property(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询模型属性集合
|
||||
*
|
||||
* @param moduleId
|
||||
* @param pager
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/{moduleId}/list")
|
||||
@Operation(summary = "模型属性列表")
|
||||
public GeneralResult<GridBean<Property>> propertyList(@PathVariable(value = "moduleId") Long moduleId,
|
||||
Pager pager) {
|
||||
return moduleService.propertyList(moduleId, pager);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑模型属性
|
||||
*
|
||||
* @param model
|
||||
* @param id
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@PutMapping(value = "/{id}/properties")
|
||||
@Operation(summary = "模型属性修改")
|
||||
public GeneralResult<Void> modifyProperty(@RequestBody PropertyModel model,
|
||||
@PathVariable(value = Common.ID) Long id, @Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return moduleService.modifyProperty(model, id, context);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,159 @@
|
|||
package com.bocloud.ams.booter.controller.module;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.bocloud.ams.entity.module.ModuleGroup;
|
||||
import com.bocloud.ams.service.module.ModuleGroupService;
|
||||
import com.megatron.common.model.GeneralResult;
|
||||
import com.megatron.common.model.RequestContext;
|
||||
import com.megatron.common.utils.Common;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@Tag(name = "模型分组管理")
|
||||
@RestController
|
||||
@RequestMapping("/v1/module/group")
|
||||
public class ModuleGroupController {
|
||||
@Autowired
|
||||
private ModuleGroupService moduleGroupService;
|
||||
|
||||
/**
|
||||
* 模型分组采集结构查询
|
||||
*
|
||||
* @param category
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/collections")
|
||||
@Operation(tags = {"CMC"}, summary = "模型分组采集结构查询")
|
||||
public GeneralResult<List<ModuleGroup>> collections(@RequestParam(value = "category") String category,
|
||||
@RequestParam(value = "moduleName", required = false) String moduleName) {
|
||||
return moduleGroupService.collections(category, moduleName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 模型分组根节点结构查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/roots")
|
||||
@Operation(tags = {"CMC"}, summary = "模型分组根节点结构查询")
|
||||
public GeneralResult<List<ModuleGroup>> queryRoot() {
|
||||
return moduleGroupService.queryRoot();
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前根节点的子分组查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping
|
||||
@Operation(tags = {"CMC"}, summary = "模型分组所有分组节点查询")
|
||||
public GeneralResult<List<ModuleGroup>> queryRootChildren() {
|
||||
return moduleGroupService.queryRootChildren();
|
||||
}
|
||||
|
||||
/**
|
||||
* 模型分组子级数据(下级节点和模型数据)查询
|
||||
*
|
||||
* @param groupId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/{groupId}/children")
|
||||
@Operation(tags = {"CMC"}, summary = "模型分组子级数据(下级节点和模型数据)查询")
|
||||
public GeneralResult<ModuleGroup> queryChildren(@PathVariable(value = "groupId") Long groupId,
|
||||
@RequestParam(value = "menu", required = false) String menu,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return moduleGroupService.queryChildren(groupId, menu, context);
|
||||
}
|
||||
|
||||
/**
|
||||
* 模型分组查询明细
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/{id}")
|
||||
@Operation(tags = {"CMC"}, summary = "模型分组详情")
|
||||
public GeneralResult<ModuleGroup> detail(@PathVariable(value = Common.ID) Long id) {
|
||||
return moduleGroupService.detail(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增模型分组
|
||||
*
|
||||
* @param group
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@PostMapping
|
||||
@Operation(tags = {"CMC"}, summary = "模型分组新增")
|
||||
public GeneralResult<Void> save(@RequestBody ModuleGroup group, @Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return moduleGroupService.save(group, context.getTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新模型分组
|
||||
*
|
||||
* @param group
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@PutMapping
|
||||
@Operation(tags = {"CMC"}, summary = "模型分组修改")
|
||||
public GeneralResult<Void> modify(@RequestBody ModuleGroup group,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return moduleGroupService.modify(group, context.getTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除模型分组
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping(value = "/{id}")
|
||||
@Operation(tags = {"CMC"}, summary = "模型分组删除")
|
||||
public GeneralResult<Void> remove(@PathVariable(value = Common.ID) Long id,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return moduleGroupService.remove(id, context.getTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* 新查询模型分组
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/list")
|
||||
@Operation(tags = {"CMC"}, summary = "模型分组查询")
|
||||
public GeneralResult<List<ModuleGroup>> querylist() {
|
||||
return moduleGroupService.querylist();
|
||||
}
|
||||
|
||||
/**
|
||||
* 模型分组子级及父级数据(下级节点和模型数据)查询
|
||||
*
|
||||
* @param groupId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/{groupId}/root/children")
|
||||
@Operation(tags = {"CMC"}, summary = "模型分组子级及父级数据(下级节点和模型数据)查询")
|
||||
public GeneralResult<List<ModuleGroup>> queryRootChildren(@PathVariable(value = "groupId") Long groupId,
|
||||
@RequestParam(value = "menu", required = false) String menu,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return moduleGroupService.queryRootChildren(groupId, menu, context);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,192 @@
|
|||
package com.bocloud.ams.booter.controller.module;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.bocloud.ams.entity.model.ModuleTopo;
|
||||
import com.bocloud.ams.entity.module.CiModule;
|
||||
import com.bocloud.ams.entity.module.ModuleRelation;
|
||||
import com.bocloud.ams.service.module.ModuleRelationService;
|
||||
import com.megatron.common.model.GeneralResult;
|
||||
import com.megatron.common.model.Pager;
|
||||
import com.megatron.common.model.RequestContext;
|
||||
import com.megatron.common.utils.Common;
|
||||
import com.megatron.common.utils.ResultTools;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@Tag(name = "模型关系管理")
|
||||
@RestController
|
||||
@RequestMapping("/v1/module/relation")
|
||||
public class ModuleRelationController {
|
||||
|
||||
@Autowired
|
||||
private ModuleRelationService moduleRelationService;
|
||||
|
||||
@GetMapping(value = "/relevancy")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "根据拓扑,模型数据查询模型关系")
|
||||
public GeneralResult<ModuleRelation> relevancy(@RequestParam("relationCategoryId") Long relationCategoryId,
|
||||
@RequestParam("sourceId") Long sourceId, @RequestParam("targetId") Long targetId) {
|
||||
return moduleRelationService.relevancy(relationCategoryId, sourceId, targetId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询模型关系记录
|
||||
*
|
||||
* @param moduleId
|
||||
* @param relationCategoryId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/topo")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "根据模型ID和关联类型分组查询模型关系拓扑")
|
||||
public GeneralResult<ModuleTopo> list(@RequestParam("moduleId") Long moduleId,
|
||||
@RequestParam("relationCategoryId") Long relationCategoryId) {
|
||||
if (null == moduleId || 0 == moduleId || null == relationCategoryId || 0 == relationCategoryId) {
|
||||
return ResultTools.formatErrResult();
|
||||
} else {
|
||||
return moduleRelationService.list(moduleId, relationCategoryId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询模型关系记录
|
||||
*
|
||||
* @param relationCategoryId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/{relationCategoryId}/topo")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "根据关联类型分组ID查询模型拓扑")
|
||||
public GeneralResult<ModuleTopo> listAll(@PathVariable(value = "relationCategoryId") Long relationCategoryId) {
|
||||
|
||||
if (null == relationCategoryId || 0 == relationCategoryId) {
|
||||
return ResultTools.formatErrResult();
|
||||
}
|
||||
|
||||
return moduleRelationService.listByCategoryId(relationCategoryId);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询模型关系记录
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/{id}")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "模型关系详情")
|
||||
public GeneralResult detail(@PathVariable(value = Common.ID) Long id) {
|
||||
|
||||
if (null == id || 0 == id) {
|
||||
return ResultTools.formatErrResult();
|
||||
}
|
||||
|
||||
return moduleRelationService.detail(id);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增模型关系
|
||||
*
|
||||
* @param record
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@PostMapping
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "模型关系新增")
|
||||
public GeneralResult<Void> save(@RequestBody ModuleRelation record,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
|
||||
if (!paramsCheck(record)) {
|
||||
return new GeneralResult<>(false, "参数异常");
|
||||
}
|
||||
return moduleRelationService.create(record, context.getTarget());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改模型关系
|
||||
*
|
||||
* @param record
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
|
||||
@PutMapping(value = "/{id}")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "模型关系修改")
|
||||
public GeneralResult modify(@RequestBody ModuleRelation record, @PathVariable(value = Common.ID) Long id,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
|
||||
if (!paramsCheck(record)) {
|
||||
return new GeneralResult<>(false, "参数异常");
|
||||
}
|
||||
record.setId(id);
|
||||
return moduleRelationService.modify(record, context.getTarget());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除模型关系
|
||||
*
|
||||
* @param id
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "模型关系删除")
|
||||
public GeneralResult remove(@PathVariable(value = Common.ID) Long id,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return moduleRelationService.remove(id, context.getTarget());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联类型分组id查询模型集合
|
||||
*
|
||||
* @param relationCategoryId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/{relationCategoryId}/module")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "关联类型分组id查询模型集合")
|
||||
public GeneralResult<List<CiModule>> moduleList(@PathVariable(value = "relationCategoryId") Long relationCategoryId) {
|
||||
return moduleRelationService.moduleList(relationCategoryId);
|
||||
}
|
||||
|
||||
private boolean paramsCheck(ModuleRelation record) {
|
||||
// 参数校验
|
||||
if (null == record || null == record.getSourceId() || 0 == record.getSourceId() || null == record.getTargetId()
|
||||
|| 0 == record.getTargetId() || null == record.getRelationCategoryId()
|
||||
|| 0 == record.getRelationCategoryId() || null == record.getRelationId() || 0 == record.getRelationId()) {
|
||||
return false;
|
||||
}
|
||||
if (StringUtils.isEmpty(record.getRule())) {
|
||||
return false;
|
||||
}
|
||||
String type = record.getRule();
|
||||
String[] types = type.split("-");
|
||||
record.setSourceType(types[0]);
|
||||
record.setTargetType(types[1]);
|
||||
return true;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/instances")
|
||||
@Operation(tags = {"CMC"}, summary = "模型关系实例列表")
|
||||
public GeneralResult instances(Pager pager, @Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return moduleRelationService.instances(pager, context.getTarget());
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.bocloud.ams.booter.controller.module;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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 com.bocloud.ams.entity.module.Property;
|
||||
import com.bocloud.ams.service.module.PropertyService;
|
||||
import com.megatron.common.model.GeneralResult;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1/property")
|
||||
@Tag(name = "模型属性管理")
|
||||
public class PropertyController {
|
||||
|
||||
@Autowired
|
||||
private PropertyService propertyService;
|
||||
|
||||
/**
|
||||
* 查询属性详情
|
||||
*
|
||||
* @param propertyId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/{propertyId}")
|
||||
@Operation(summary = "模型属性详情")
|
||||
public GeneralResult<Property> propertyDetail(@PathVariable(value = "propertyId") Long propertyId) {
|
||||
return propertyService.detail(propertyId);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
package com.bocloud.ams.booter.controller.module;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.bocloud.ams.entity.module.PropertyPool;
|
||||
import com.bocloud.ams.service.module.PropertyPoolService;
|
||||
import com.bocloud.ams.service.utils.PropertyConstant;
|
||||
import com.megatron.common.model.GeneralResult;
|
||||
import com.megatron.common.model.GridBean;
|
||||
import com.megatron.common.model.Pager;
|
||||
import com.megatron.common.model.RequestContext;
|
||||
import com.megatron.common.utils.Common;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@Tag(name = "属性池管理")
|
||||
@RestController
|
||||
@RequestMapping("/v1/property/pool")
|
||||
public class PropertyPoolController {
|
||||
|
||||
@Autowired
|
||||
private PropertyPoolService propertyPoolService;
|
||||
|
||||
/**
|
||||
* 查询属性池记录
|
||||
*
|
||||
* @param pager
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@GetMapping
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "属性池列表")
|
||||
public GeneralResult<GridBean<PropertyPool>> list(Pager pager, @Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return propertyPoolService.list(pager);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增属性池
|
||||
*
|
||||
* @param record
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@PostMapping
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "属性池新增")
|
||||
public GeneralResult<Void> save(@RequestBody PropertyPool record,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
|
||||
if (!paramsCheck(record)) {
|
||||
return new GeneralResult<>(false, "参数异常");
|
||||
}
|
||||
return propertyPoolService.create(record, context.getTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改属性池
|
||||
*
|
||||
* @param record
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@PutMapping(value = "/{id}")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "属性池修改" )
|
||||
public GeneralResult modify(@RequestBody PropertyPool record, @PathVariable(value = Common.ID) Long id,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
|
||||
if (!paramsCheck(record)) {
|
||||
return new GeneralResult<>(false, "参数异常");
|
||||
}
|
||||
|
||||
record.setId(id);
|
||||
return propertyPoolService.modify(record, context.getTarget());
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除属性池
|
||||
*
|
||||
* @param id
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping("/{id}")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary = "属性池删除")
|
||||
public GeneralResult remove(@PathVariable(value = Common.ID) Long id,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return propertyPoolService.remove(id, context.getTarget());
|
||||
|
||||
}
|
||||
|
||||
private boolean paramsCheck(PropertyPool record) {
|
||||
// 参数校验
|
||||
if (null == record || StringUtils.isEmpty(record.getName()) || StringUtils.isEmpty(record.getCode())
|
||||
|| StringUtils.isEmpty(record.getType())) {
|
||||
return false;
|
||||
}
|
||||
// 下拉选择类型中,属性池配置项必须有值
|
||||
if (PropertyConstant.PropertyType.SINGLESELECT.equals(record.getType())
|
||||
|| PropertyConstant.PropertyType.MULTISELECT.equals(record.getType())
|
||||
|| PropertyConstant.PropertyType.RADIO.equals(record.getType())
|
||||
|| PropertyConstant.PropertyType.CHECKBOX.equals(record.getType())) {
|
||||
if (CollectionUtils.isEmpty(record.getItemList())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (PropertyConstant.PropertyType.MULTILINETABLE.equals(record.getType())
|
||||
|| PropertyConstant.PropertyType.SINGLELINETABLE.equals(record.getType())) {
|
||||
|
||||
if (PropertyConstant.TABLE_TYPE_ONE.equals(record.getTableType())) {
|
||||
if (null == record.getLinkModuleId() || 0 == record.getLinkModuleId()
|
||||
|| StringUtils.isEmpty(record.getPropertyIds())) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (CollectionUtils.isEmpty(record.getItemList())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.bocloud.ams.booter.controller.module;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.bocloud.ams.entity.module.RegularExpression;
|
||||
import com.bocloud.ams.service.module.RegularExpressionService;
|
||||
import com.megatron.common.model.GeneralResult;
|
||||
import com.megatron.common.utils.Common;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@Tag(name = "正则表达式管理")
|
||||
@RestController
|
||||
@RequestMapping("/v1/regexps")
|
||||
public class RegularExpressionController {
|
||||
|
||||
@Autowired
|
||||
private RegularExpressionService regularExpressionService;
|
||||
|
||||
/**
|
||||
* 查询所有的正则表达式
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping
|
||||
@Operation(tags = {"CMC"}, summary ="正则表达式列表")
|
||||
public GeneralResult<List<RegularExpression>> list(@RequestParam(value = Common.TYPE) String type) {
|
||||
return regularExpressionService.list(type);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,132 @@
|
|||
package com.bocloud.ams.booter.controller.module;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.bocloud.ams.entity.module.ModuleRelation;
|
||||
import com.bocloud.ams.entity.module.RelationCategory;
|
||||
import com.bocloud.ams.service.module.RelationCategoryService;
|
||||
import com.megatron.common.model.GeneralResult;
|
||||
import com.megatron.common.model.GridBean;
|
||||
import com.megatron.common.model.Pager;
|
||||
import com.megatron.common.model.RequestContext;
|
||||
import com.megatron.common.utils.Common;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@Tag(name = "关联类型分组管理")
|
||||
@RestController
|
||||
@RequestMapping("/v1/relation/category")
|
||||
public class RelationCategoryController {
|
||||
|
||||
@Autowired
|
||||
private RelationCategoryService relationCategoryService;
|
||||
|
||||
/**
|
||||
* 查询关联类型分组记录
|
||||
*
|
||||
* @param pager
|
||||
* @return
|
||||
*/
|
||||
@GetMapping
|
||||
@Operation(tags = {"CMC", "CSC"}, summary ="关联类型分组列表")
|
||||
public GeneralResult<GridBean<RelationCategory>> list(Pager pager) {
|
||||
return relationCategoryService.list(pager);
|
||||
}
|
||||
|
||||
@GetMapping("/all")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary ="关联类型分组列表(所有)")
|
||||
public GeneralResult<List<RelationCategory>> listAll(Pager pager) {
|
||||
return relationCategoryService.listAll(pager.getParams(), pager.getSorter());
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增关联类型分组
|
||||
*
|
||||
* @param record
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@PostMapping
|
||||
@Operation(tags = {"CMC", "CSC"}, summary ="关联类型分组新增")
|
||||
public GeneralResult<Void> save(@RequestBody RelationCategory record,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
|
||||
if (!paramsCheck(record)) {
|
||||
return new GeneralResult<>(false, "参数异常");
|
||||
}
|
||||
try {
|
||||
return relationCategoryService.create(record, context.getTarget());
|
||||
} catch (Exception e) {
|
||||
return new GeneralResult<>(false, "关联类型分组新增失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改关联类型分组
|
||||
*
|
||||
* @param record
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@PutMapping(value = "/{id}")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary ="关联类型分组修改")
|
||||
public GeneralResult modify(@RequestBody RelationCategory record, @PathVariable(value = Common.ID) Long id,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
|
||||
if (!paramsCheck(record)) {
|
||||
return new GeneralResult<>(false, "参数异常");
|
||||
}
|
||||
record.setId(id);
|
||||
|
||||
return relationCategoryService.modify(record, context.getTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除关联类型分组
|
||||
*
|
||||
* @param id
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping("/{id}")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary ="关联类型分组删除")
|
||||
public GeneralResult remove(@PathVariable(value = Common.ID) Long id,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
try {
|
||||
return relationCategoryService.remove(id, context.getTarget());
|
||||
} catch (Exception e) {
|
||||
return new GeneralResult<>(false, "关联类型分组删除失败");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean paramsCheck(RelationCategory record) {
|
||||
// 参数校验
|
||||
if (null == record || StringUtils.isEmpty(record.getName()) || StringUtils.isEmpty(record.getCode())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/{id}/module/relations")
|
||||
@Operation(tags = {"CMC"}, summary ="关联类型分组模型关系查询")
|
||||
public GeneralResult<List<ModuleRelation>> moduleRelationList(@PathVariable(value = Common.ID) Long id,
|
||||
@RequestParam(value = "moduleId") Long moduleId) {
|
||||
return relationCategoryService.moduleRelationList(id, moduleId);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,105 @@
|
|||
package com.bocloud.ams.booter.controller.module;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.bocloud.ams.entity.module.Relation;
|
||||
import com.bocloud.ams.service.module.RelationService;
|
||||
import com.megatron.common.model.GeneralResult;
|
||||
import com.megatron.common.model.GridBean;
|
||||
import com.megatron.common.model.Pager;
|
||||
import com.megatron.common.model.RequestContext;
|
||||
import com.megatron.common.utils.Common;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
|
||||
@Tag(name = "关联类型管理")
|
||||
@RestController
|
||||
@RequestMapping("/v1/relation")
|
||||
public class RelationController {
|
||||
|
||||
@Autowired
|
||||
private RelationService relationService;
|
||||
|
||||
/**
|
||||
* 查询关联类型记录
|
||||
*
|
||||
* @param pager
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@GetMapping
|
||||
@Operation(tags = {"CMC", "CSC"}, summary ="关联类型列表")
|
||||
public GeneralResult<GridBean<Relation>> list(Pager pager, @Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return relationService.list(pager);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增关联类型
|
||||
*
|
||||
* @param record
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@PostMapping
|
||||
@Operation(tags = {"CMC", "CSC"}, summary ="关联类型新增")
|
||||
public GeneralResult<Void> save(@RequestBody Relation record, @Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
|
||||
if (!paramsCheck(record)) {
|
||||
return new GeneralResult<>(false, "参数异常");
|
||||
}
|
||||
return relationService.create(record, context.getTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改关联类型
|
||||
*
|
||||
* @param record
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@PutMapping(value = "/{id}")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary ="关联类型修改")
|
||||
public GeneralResult modify(@RequestBody Relation record, @PathVariable(value = Common.ID) Long id,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
|
||||
if (!paramsCheck(record)) {
|
||||
return new GeneralResult<>(false, "参数异常");
|
||||
}
|
||||
record.setId(id);
|
||||
return relationService.modify(record, context.getTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除关联类型
|
||||
*
|
||||
* @param id
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping("/{id}")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary ="关联类型删除")
|
||||
public GeneralResult remove(@PathVariable(value = Common.ID) Long id,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return relationService.remove(id, context.getTarget());
|
||||
}
|
||||
|
||||
private boolean paramsCheck(Relation record) {
|
||||
// 参数校验
|
||||
if (null == record || StringUtils.isEmpty(record.getName()) || StringUtils.isEmpty(record.getCode())
|
||||
|| null == record.getCategoryId() || 0L == record.getCategoryId()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,237 @@
|
|||
package com.bocloud.ams.booter.controller.module;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.bocloud.ams.entity.model.ColumnAndSearchItemModel;
|
||||
import com.bocloud.ams.entity.model.InstanceTopo;
|
||||
import com.bocloud.ams.entity.model.PathModel;
|
||||
import com.bocloud.ams.entity.model.ResponseInstanceTopologyModel;
|
||||
import com.bocloud.ams.entity.module.TopologyConfig;
|
||||
import com.bocloud.ams.service.module.TopologyConfigService;
|
||||
import com.megatron.common.model.GeneralResult;
|
||||
import com.megatron.common.model.GridBean;
|
||||
import com.megatron.common.model.Pager;
|
||||
import com.megatron.common.model.RequestContext;
|
||||
import com.megatron.common.utils.Common;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
@Tag(name = "实例拓扑管理")
|
||||
@RestController
|
||||
@RequestMapping("/v1/instance/topology")
|
||||
public class TopologyConfigController {
|
||||
|
||||
@Autowired
|
||||
private TopologyConfigService topologyConfigService;
|
||||
|
||||
/**
|
||||
* 拓扑实例列表
|
||||
*
|
||||
* @param pager
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@GetMapping
|
||||
@Operation(tags = {"CMC", "CSC"}, summary ="实例拓扑列表")
|
||||
public GeneralResult<GridBean<TopologyConfig>> list(Pager pager,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return topologyConfigService.list(pager);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增模型
|
||||
*
|
||||
* @param config
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@PostMapping
|
||||
@Operation(tags = {"CMC"}, summary ="实例拓扑新增")
|
||||
public GeneralResult<Void> save(@RequestBody TopologyConfig config,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return topologyConfigService.save(config, context.getTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新实例图谱
|
||||
*
|
||||
* @param config
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
@PutMapping
|
||||
@Operation(tags = {"CMC"}, summary ="实例拓扑修改")
|
||||
public GeneralResult<Void> modify(@RequestBody TopologyConfig config,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return topologyConfigService.modify(config, context.getTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除拓扑实例
|
||||
*
|
||||
* @param id
|
||||
* @param context
|
||||
* @return
|
||||
*/
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
@Operation(tags = {"CMC", "CSC"}, summary ="拓扑实例删除")
|
||||
public GeneralResult<Void> remove(@PathVariable(value = Common.ID) Long id,
|
||||
@Value(Common.REQ_CONTEXT) RequestContext context) {
|
||||
return topologyConfigService.remove(id, context.getTarget());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询实例拓扑详情
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/{id}")
|
||||
@Operation(summary = "实例拓扑详情")
|
||||
public GeneralResult<TopologyConfig> detail(@PathVariable(value = "id") Long id) {
|
||||
return topologyConfigService.detail(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据起始模型查询最大拓扑层级
|
||||
*
|
||||
* @param categoryId
|
||||
* @param startModuleId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/max/level")
|
||||
@Operation(summary = "根据起始模型查询最大拓扑层级")
|
||||
public GeneralResult<Integer> maxLevel(@RequestParam("categoryId") Long categoryId,
|
||||
@RequestParam("startModuleId") Long startModuleId) {
|
||||
return topologyConfigService.maxLevel(categoryId, startModuleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取拓扑路径
|
||||
*
|
||||
* @param categoryId
|
||||
* @param startModuleId
|
||||
* @param topologyLevel
|
||||
* @param ignoreModuleId
|
||||
* @param wayModuleId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/path")
|
||||
@Operation(summary = "获取拓扑路径")
|
||||
public GeneralResult<List<PathModel>> topologyPath(@RequestParam("categoryId") Long categoryId,
|
||||
@RequestParam("startModuleId") Long startModuleId, @RequestParam("topologyLevel") Integer topologyLevel,
|
||||
@RequestParam(value = "ignoreModuleId", required = false) String ignoreModuleId,
|
||||
@RequestParam(value = "wayModuleId", required = false) String wayModuleId) {
|
||||
return topologyConfigService.topologyPath(categoryId, startModuleId, topologyLevel, ignoreModuleId,
|
||||
wayModuleId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取查询项以及列表项
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/{id}/dynamic/item")
|
||||
@Operation(summary = "获取查询项以及列表项")
|
||||
public GeneralResult<ColumnAndSearchItemModel> searchItemList(@PathVariable(value = "id") Long id) {
|
||||
return topologyConfigService.searchItemList(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询资源列表
|
||||
*
|
||||
* @param pager
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/resource")
|
||||
@Operation(summary = "查询资源列表")
|
||||
public GeneralResult<GridBean<Map<String, Object>>> resourcelist(Pager pager) {
|
||||
return topologyConfigService.resourcelist(pager);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据实例拓扑id查询对应起始模型的实例集合
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/{id}/startmodule/instance")
|
||||
@Operation(summary = "根据实例拓扑id查询对应起始模型的实例集合")
|
||||
public GeneralResult<List<ResponseInstanceTopologyModel>>
|
||||
startModuleInstanceList(@PathVariable(value = "id") Long id) {
|
||||
return topologyConfigService.startModuleInstanceList(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 实例拓扑-资源列表导出
|
||||
*
|
||||
* @param id
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/{id}/export")
|
||||
@Operation(summary = "实例拓扑资源列表导出")
|
||||
public GeneralResult<Void> download(@PathVariable Long id, HttpServletResponse response) {
|
||||
return topologyConfigService.download(id, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 实例拓扑-全局拓扑
|
||||
*
|
||||
* @param id
|
||||
* @param instanceId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/topo")
|
||||
@Operation(summary = "全局拓扑")
|
||||
public GeneralResult<InstanceTopo> topoList(@RequestParam(value = "id") Long id,
|
||||
@RequestParam(value = "instanceId") Long instanceId) {
|
||||
return topologyConfigService.topoList(id, instanceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 实例资源拓扑
|
||||
*
|
||||
* @param id
|
||||
* @param instanceId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/topo/instances/{instanceId}")
|
||||
@Operation(summary = "实例资源拓扑")
|
||||
public GeneralResult<InstanceTopo> topology(@RequestParam(value = "id") Long id,
|
||||
@PathVariable Long instanceId) {
|
||||
return topologyConfigService.topology(id, instanceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 实例拓扑-根据实例id查找下一层级实例拓扑
|
||||
*
|
||||
* @param id
|
||||
* @param instanceId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/next/topo")
|
||||
@Operation(summary = "根据实例id查找下一层级实例拓扑")
|
||||
public GeneralResult<InstanceTopo> nextTopoList(@RequestParam(value = "id") Long id,
|
||||
@RequestParam(value = "moduleId") Long moduleId, @RequestParam(value = "instanceId") Long instanceId) {
|
||||
return topologyConfigService.nextTopoList(id, moduleId, instanceId);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package com.bocloud.ams.booter.listener;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.bocloud.ams.entity.collection.CollectionTaskInstance;
|
||||
import com.bocloud.ams.entity.enums.CollectionEnum;
|
||||
import com.bocloud.ams.entity.enums.Status;
|
||||
import com.bocloud.ams.entity.model.TaskInstanceBean;
|
||||
import com.bocloud.ams.service.collection.CollectionTaskInstanceService;
|
||||
import com.bocloud.ams.service.utils.CollectionHistoryHelper;
|
||||
import com.bocloud.ams.task.model.JobResult;
|
||||
import com.megatron.common.model.GeneralResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.core.MessageListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author liuyuanyuan
|
||||
* @Date 2022/6/14 0014 18:31
|
||||
* @Description:采集任务结果监听
|
||||
*/
|
||||
@Slf4j
|
||||
@Component("taskResultListener")
|
||||
public class TaskResultListener implements MessageListener {
|
||||
@Autowired
|
||||
private CollectionTaskInstanceService cmdbCollectionTaskInstanceService;
|
||||
@Autowired
|
||||
private CollectionHistoryHelper historyHelper;
|
||||
|
||||
private void processDebugLog(String format, Object... objects) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(format, objects);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMessage(Message message) {
|
||||
try {
|
||||
String content = new String(message.getBody(), Charset.forName("UTF-8"));
|
||||
processDebugLog("get bocloud message:{}", content);
|
||||
if (StringUtils.isBlank(content)) {
|
||||
// 消息没有内容,直接确认收到 淹没处理
|
||||
return;
|
||||
}
|
||||
JobResult jobResult = JSONObject.parseObject(content, JobResult.class);
|
||||
if (null == jobResult) {
|
||||
// 消息参数格式错误,直接确认收到淹没处理
|
||||
return;
|
||||
}
|
||||
log.info("收到任务执行消息{}", content);
|
||||
//查询任务数据
|
||||
GeneralResult<CollectionTaskInstance> instanceResult = cmdbCollectionTaskInstanceService.queryByTaskId(jobResult.getJob().getTaskId());
|
||||
if (instanceResult.isFailed()) {
|
||||
log.info("任务数据不存在,taskId{}", jobResult.getJob().getTaskId());
|
||||
return;
|
||||
}
|
||||
CollectionTaskInstance instance = instanceResult.getData();
|
||||
TaskInstanceBean instanceBean = new TaskInstanceBean();
|
||||
instanceBean.setOutput(jobResult.getMsg());
|
||||
instanceBean.setId(instance.getId());
|
||||
instanceBean.setGmtModify(new Date());
|
||||
instanceBean.setCollectionFinish(new Date());
|
||||
BigDecimal start = new BigDecimal(instance.getGmtStart().getTime());
|
||||
BigDecimal end = new BigDecimal(instanceBean.getCollectionFinish().getTime());
|
||||
instanceBean.setCollectionTime(Math.abs(end.subtract(start).divide(new BigDecimal(1000), 3, RoundingMode.HALF_UP).doubleValue()));
|
||||
if (jobResult.isSuccess()) {
|
||||
instanceBean.setStatus(Status.Inst.RUNNING.name());
|
||||
instanceBean.setCollectionStatus(Status.Inst.SUCCESS.name());
|
||||
} else {
|
||||
instanceBean.setCollectionStatus(Status.Inst.FAILED.name());
|
||||
instanceBean.setStatus(CollectionEnum.Status.ERROR.name());
|
||||
instanceBean.setGmtFinish(new Date());
|
||||
}
|
||||
cmdbCollectionTaskInstanceService.modify(instanceBean, instance.getCreatorId());
|
||||
log.info("采集任务:{}已完成!开始时间:{},结束时间:{},总耗时:{}", jobResult.getJob().getTaskId(), start, end, instanceBean.getCollectionTime());
|
||||
if (jobResult.isSuccess()) {
|
||||
GeneralResult result = historyHelper.history(instance.getId(), instance.getCode(), jobResult.getMsg(), instance.getCreatorId());
|
||||
if (result.isFailed()) {
|
||||
cmdbCollectionTaskInstanceService.updateStatus(instance.getId(), CollectionEnum.Status.ERROR.name());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Get error message:{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,373 @@
|
|||
package com.bocloud.ams.booter.scheduler;
|
||||
|
||||
import com.bocloud.ams.entity.TableLog;
|
||||
import com.bocloud.ams.entity.collection.CollectionHistory;
|
||||
import com.bocloud.ams.entity.collection.CollectionHistoryBak;
|
||||
import com.bocloud.ams.entity.collection.CollectionHistoryItem;
|
||||
import com.bocloud.ams.entity.collection.CollectionHistoryItemBak;
|
||||
import com.bocloud.ams.entity.collection.CollectionTaskInstance;
|
||||
import com.bocloud.ams.entity.collection.CollectionTaskInstanceBak;
|
||||
import com.bocloud.ams.entity.config.CmdbConfig;
|
||||
import com.bocloud.ams.entity.enums.Status;
|
||||
import com.bocloud.ams.repository.TableLogRepository;
|
||||
import com.bocloud.ams.repository.collection.CollectionHistoryBakRepository;
|
||||
import com.bocloud.ams.repository.collection.CollectionHistoryItemBakRepository;
|
||||
import com.bocloud.ams.repository.collection.CollectionHistoryItemRepository;
|
||||
import com.bocloud.ams.repository.collection.CollectionHistoryRepository;
|
||||
import com.bocloud.ams.repository.collection.CollectionTaskInstanceBakRepository;
|
||||
import com.bocloud.ams.repository.collection.CollectionTaskInstanceRepository;
|
||||
import com.bocloud.ams.repository.config.CmdbConfigRepository;
|
||||
import com.bocloud.ams.repository.utils.CmdbUtils;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.megatron.common.model.GeneralResult;
|
||||
import com.megatron.common.model.Param;
|
||||
import com.megatron.common.model.Sign;
|
||||
import com.megatron.common.utils.ListTool;
|
||||
import com.megatron.common.utils.MapTools;
|
||||
import com.megatron.framework.core.CurrentService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author huliwei
|
||||
* @date 2023/4/24
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CollectionTaskInstanceBakScheduler {
|
||||
|
||||
private static final String CMDB_COLLECTION_TASK_INSTANCE_BAK_ = "ci_collection_task_instance_bak_";
|
||||
private static final String CMDB_COLLECTION_HISTORY_BAK_ = "ci_collection_history_bak_";
|
||||
private static final String CMDB_COLLECTION_HISTORY_ITEM_BAK_ = "ci_collection_history_item_bak_";
|
||||
|
||||
private static final String CMDB_COLLECTION_TASK_INSTANCE_BAK = "ci_collection_task_instance_bak";
|
||||
private static final String CMDB_COLLECTION_HISTORY_BAK = "ci_collection_history_bak";
|
||||
private static final String CMDB_COLLECTION_HISTORY_ITEM_BAK = "ci_collection_history_item_bak";
|
||||
|
||||
@Autowired
|
||||
private CurrentService service;
|
||||
@Autowired
|
||||
private CollectionTaskInstanceRepository collectionTaskInstanceRepository;
|
||||
@Autowired
|
||||
private CollectionHistoryRepository collectionHistoryRepository;
|
||||
@Autowired
|
||||
private CollectionHistoryItemRepository collectionHistoryItemRepository;
|
||||
@Autowired
|
||||
private CmdbConfigRepository cmdbConfigRepository;
|
||||
@Autowired
|
||||
private TableLogRepository tableLogRepository;
|
||||
@Autowired
|
||||
private CollectionTaskInstanceBakRepository collectionTaskInstanceBakRepository;
|
||||
@Autowired
|
||||
private CollectionHistoryBakRepository collectionHistoryBakRepository;
|
||||
@Autowired
|
||||
private CollectionHistoryItemBakRepository collectionHistoryItemBakRepository;
|
||||
|
||||
|
||||
//每月第一天的0时1分开始创建当月的备份表
|
||||
@Scheduled(cron = "${collection.task.instance.create-table:0 1 0 1 * ? }")
|
||||
private void createTable() {
|
||||
try {
|
||||
//ci_collection_history_bak_202304
|
||||
String tableNameTaskInstanceBak = CMDB_COLLECTION_TASK_INSTANCE_BAK_ + this.getTableSuffix(LocalDateTime.now());
|
||||
String tableNameHistoryBak = CMDB_COLLECTION_HISTORY_BAK_ + this.getTableSuffix(LocalDateTime.now());
|
||||
String tableNameHistoryItemBak = CMDB_COLLECTION_HISTORY_ITEM_BAK_ + this.getTableSuffix(LocalDateTime.now());
|
||||
this.createCollectionTaskInstanceBakTable(tableNameTaskInstanceBak);
|
||||
this.createCollectionHistoryBakTable(tableNameHistoryBak);
|
||||
this.createCollectionHistoryItemBakTable(tableNameHistoryItemBak);
|
||||
} catch (Exception e) {
|
||||
log.error("定时创建库表失败", e);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Scheduled(cron = "${collection.task.instance.bakup:0 0 4 * * ?}")
|
||||
private void instanceDataBak() {
|
||||
if (!service.isLeader()) {
|
||||
return;
|
||||
}
|
||||
log.info("开始备份任务数据");
|
||||
List<CollectionTaskInstance> instances = null;
|
||||
int stepSize = 200;
|
||||
try {
|
||||
CmdbConfig switchConfig = cmdbConfigRepository.queryByCode("CmdbCollectionTaskInstanceDataBakSwitch");
|
||||
if (null == switchConfig || StringUtils.isEmpty(switchConfig.getValue()) || !switchConfig.getValue().equalsIgnoreCase("true")) {
|
||||
log.info("备份任务未开启");
|
||||
return;
|
||||
}
|
||||
Integer days = null;
|
||||
CmdbConfig config = cmdbConfigRepository.queryByCode("CmdbCollectionTaskInstanceDataBakDaysAgo");
|
||||
if (null != config && StringUtils.isNotEmpty(config.getValue())) {
|
||||
days = Integer.valueOf(config.getValue());
|
||||
}
|
||||
days = null == days ? 90 : days;
|
||||
LocalDate localDate = LocalDate.now().minusDays(days);
|
||||
LocalDateTime localDateTime = LocalDateTime.of(localDate, LocalTime.MIN);
|
||||
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
String formatTime = dateTimeFormatter.format(localDateTime);
|
||||
log.info("备份{}之前的数据", formatTime);
|
||||
List<Param> params = Lists.newArrayList();
|
||||
params.add(new Param(MapTools.simpleMap("gmtCreate", formatTime), Sign.LET));
|
||||
instances = this.collectionTaskInstanceRepository.list(params);
|
||||
} catch (Exception e) {
|
||||
log.error("查询任务实例失败", e);
|
||||
return;
|
||||
}
|
||||
if (ListTool.isEmpty(instances)) {
|
||||
log.info("结束备份任务数据,没有查询到需要备份的数据");
|
||||
return;
|
||||
}
|
||||
int size = instances.size();
|
||||
log.info("备份任务数{},每批任务数{}", size, stepSize);
|
||||
if (size > stepSize) {
|
||||
int num = size % stepSize == 0 ? size / stepSize : size / stepSize + 1;
|
||||
for (int i = 0; i < num; i++) {
|
||||
log.info("备份第{}批数据", i + 1);
|
||||
if (i + 1 == num) {
|
||||
batchBak(instances.subList(i * stepSize, size));
|
||||
} else {
|
||||
batchBak(instances.subList(i * stepSize, (i + 1) * stepSize));
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
batchBak(instances);
|
||||
}
|
||||
log.info("结束备份任务数据");
|
||||
}
|
||||
|
||||
private void batchBak(List<CollectionTaskInstance> instances) {
|
||||
try {
|
||||
//根据年和月分组
|
||||
Map<String, List<CollectionTaskInstance>> map = new HashMap<>();
|
||||
for (CollectionTaskInstance instance : instances) {
|
||||
LocalDateTime localDateTime = LocalDateTime.ofInstant(instance.getGmtCreate().toInstant(), ZoneId.systemDefault());
|
||||
String tableSuffix = this.getTableSuffix(localDateTime);
|
||||
if (map.containsKey(tableSuffix)) {
|
||||
List<CollectionTaskInstance> taskInstanceList = map.get(tableSuffix);
|
||||
taskInstanceList.add(instance);
|
||||
} else {
|
||||
List<CollectionTaskInstance> taskInstances = new ArrayList<>();
|
||||
taskInstances.add(instance);
|
||||
map.put(tableSuffix, taskInstances);
|
||||
}
|
||||
}
|
||||
for (String tableSuffix : map.keySet()) {
|
||||
//备份ci_collection_task_instance
|
||||
List<CollectionTaskInstance> taskInstances = map.get(tableSuffix);
|
||||
List<Long> instanceIds = taskInstances.stream().map(CollectionTaskInstance::getId).collect(Collectors.toList());
|
||||
List<CollectionTaskInstanceBak> instanceBaks = Lists.newArrayList();
|
||||
for (CollectionTaskInstance instance : instances) {
|
||||
CollectionTaskInstanceBak bak = new CollectionTaskInstanceBak();
|
||||
BeanUtils.copyProperties(instance, bak);
|
||||
instanceBaks.add(bak);
|
||||
}
|
||||
if (!instanceBaks.isEmpty()) {
|
||||
String tableName = CMDB_COLLECTION_TASK_INSTANCE_BAK_ + tableSuffix;
|
||||
GeneralResult<Void> taskInstanceBakTable = this.createCollectionTaskInstanceBakTable(tableName);
|
||||
if (taskInstanceBakTable.isSuccess()) {
|
||||
this.batchSaveCollectionTaskInstanceBak(instanceBaks, tableName);
|
||||
collectionTaskInstanceRepository.delete(instanceIds);
|
||||
}
|
||||
}
|
||||
//备份ci_collection_history
|
||||
List<CollectionHistory> collectionHistories = collectionHistoryRepository.listByInstances(instanceIds);
|
||||
List<Long> historyIds = collectionHistories.stream().map(CollectionHistory::getId).collect(Collectors.toList());
|
||||
List<CollectionHistoryBak> collectionHistoryBaks = Lists.newArrayList();
|
||||
for (CollectionHistory collectionHistory : collectionHistories) {
|
||||
CollectionHistoryBak collectionHistoryBak = new CollectionHistoryBak();
|
||||
BeanUtils.copyProperties(collectionHistory, collectionHistoryBak);
|
||||
collectionHistoryBaks.add(collectionHistoryBak);
|
||||
}
|
||||
if (!collectionHistoryBaks.isEmpty()) {
|
||||
String tableName = CMDB_COLLECTION_HISTORY_BAK_ + tableSuffix;
|
||||
GeneralResult<Void> collectionHistoryBakTable = this.createCollectionHistoryBakTable(tableName);
|
||||
if (collectionHistoryBakTable.isSuccess()) {
|
||||
this.batchSaveCollectionHistoryBak(collectionHistoryBaks, tableName);
|
||||
collectionHistoryRepository.deleteByInstanceIds(instanceIds);
|
||||
}
|
||||
}
|
||||
//备份ci_collection_history_item
|
||||
if (!ListTool.isEmpty(historyIds)) {
|
||||
List<CollectionHistoryItem> collectionHistoryItems = collectionHistoryItemRepository.listByHistoryIds(historyIds);
|
||||
List<CollectionHistoryItemBak> collectionHistoryItemBaks = Lists.newArrayList();
|
||||
for (CollectionHistoryItem relation : collectionHistoryItems) {
|
||||
CollectionHistoryItemBak collectionHistoryItemBak = new CollectionHistoryItemBak();
|
||||
BeanUtils.copyProperties(relation, collectionHistoryItemBak);
|
||||
collectionHistoryItemBaks.add(collectionHistoryItemBak);
|
||||
}
|
||||
if (!collectionHistoryItemBaks.isEmpty()) {
|
||||
String tableName = CMDB_COLLECTION_HISTORY_ITEM_BAK_ + tableSuffix;
|
||||
GeneralResult<Void> collectionHistoryItemBakTable = this.createCollectionHistoryItemBakTable(tableName);
|
||||
if (collectionHistoryItemBakTable.isSuccess()) {
|
||||
this.batchSaveCollectionHistoryItemBak(collectionHistoryItemBaks, tableName);
|
||||
collectionHistoryItemRepository.deleteByHistoryIds(historyIds);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("任务备份异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量保存
|
||||
*
|
||||
* @param collectionTaskInstanceBaks 需要保存的数据
|
||||
* @param tableName 备份表名称
|
||||
*/
|
||||
private void batchSaveCollectionTaskInstanceBak(List<CollectionTaskInstanceBak> collectionTaskInstanceBaks, String tableName) {
|
||||
synchronized (CollectionTaskInstanceBak.class) {
|
||||
CmdbUtils.changeTableAnnotationValue(CollectionTaskInstanceBak.class, tableName);
|
||||
collectionTaskInstanceBakRepository.batchSave(collectionTaskInstanceBaks, collectionTaskInstanceBaks.size(), false);
|
||||
//还原操作
|
||||
CmdbUtils.changeTableAnnotationValue(CollectionTaskInstanceBak.class, CMDB_COLLECTION_TASK_INSTANCE_BAK);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量保存
|
||||
*
|
||||
* @param collectionHistoryBaks 需要保存的数据
|
||||
* @param tableName 备份表名称
|
||||
*/
|
||||
private void batchSaveCollectionHistoryBak(List<CollectionHistoryBak> collectionHistoryBaks, String tableName) {
|
||||
synchronized (CollectionHistoryBak.class) {
|
||||
CmdbUtils.changeTableAnnotationValue(CollectionHistoryBak.class, tableName);
|
||||
collectionHistoryBakRepository.batchSave(collectionHistoryBaks, collectionHistoryBaks.size(), false);
|
||||
//还原操作
|
||||
CmdbUtils.changeTableAnnotationValue(CollectionHistoryBak.class, CMDB_COLLECTION_HISTORY_BAK);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量保存
|
||||
*
|
||||
* @param collectionHistoryItemBaks 需要保存的数据
|
||||
* @param tableName 备份表名称
|
||||
*/
|
||||
private void batchSaveCollectionHistoryItemBak(List<CollectionHistoryItemBak> collectionHistoryItemBaks, String tableName) {
|
||||
synchronized (CollectionHistoryItemBak.class) {
|
||||
CmdbUtils.changeTableAnnotationValue(CollectionHistoryItemBak.class, tableName);
|
||||
collectionHistoryItemBakRepository.batchSave(collectionHistoryItemBaks, collectionHistoryItemBaks.size(), false);
|
||||
//还原操作
|
||||
CmdbUtils.changeTableAnnotationValue(CollectionHistoryItemBak.class, CMDB_COLLECTION_HISTORY_ITEM_BAK);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态创建表
|
||||
*
|
||||
* @param tableName 需要创建的表名称
|
||||
* @return
|
||||
*/
|
||||
private GeneralResult<Void> createCollectionTaskInstanceBakTable(String tableName) {
|
||||
synchronized (CollectionTaskInstanceBak.class) {
|
||||
String templateTable = CMDB_COLLECTION_TASK_INSTANCE_BAK;
|
||||
try {
|
||||
if (collectionTaskInstanceBakRepository.countTable(tableName) <= 0) {
|
||||
collectionTaskInstanceBakRepository.createTable(tableName, new CollectionTaskInstanceBak());
|
||||
this.saveTableLog(tableName, templateTable, Status.Inst.SUCCESS.name());
|
||||
}
|
||||
return new GeneralResult<>(true, "创建成功");
|
||||
} catch (Exception e) {
|
||||
this.saveTableLog(tableName, templateTable, Status.Inst.FAILED.name());
|
||||
log.error("create ci_collection_task_instance_bak table error:", e);
|
||||
return new GeneralResult<>(false, "创建失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态创建表
|
||||
*
|
||||
* @param tableName 需要创建的表名称
|
||||
* @return
|
||||
*/
|
||||
private GeneralResult<Void> createCollectionHistoryBakTable(String tableName) {
|
||||
synchronized (CollectionHistoryBak.class) {
|
||||
String templateTable = CMDB_COLLECTION_HISTORY_BAK;
|
||||
try {
|
||||
if (collectionHistoryBakRepository.countTable(tableName) <= 0) {
|
||||
collectionHistoryBakRepository.createTable(tableName, new CollectionHistoryBak());
|
||||
this.saveTableLog(tableName, templateTable, Status.Inst.SUCCESS.name());
|
||||
}
|
||||
return new GeneralResult<>(true, "创建成功");
|
||||
} catch (Exception e) {
|
||||
this.saveTableLog(tableName, templateTable, Status.Inst.FAILED.name());
|
||||
log.error("create ci_collection_history_bak table error:", e);
|
||||
return new GeneralResult<>(false, "创建失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 动态创建表
|
||||
*
|
||||
* @param tableName 需要创建的表名称
|
||||
* @return
|
||||
*/
|
||||
private GeneralResult<Void> createCollectionHistoryItemBakTable(String tableName) {
|
||||
synchronized (CollectionHistoryItemBak.class) {
|
||||
String templateTable = CMDB_COLLECTION_HISTORY_ITEM_BAK;
|
||||
try {
|
||||
if (collectionHistoryItemBakRepository.countTable(tableName) <= 0) {
|
||||
collectionHistoryItemBakRepository.createTable(tableName, new CollectionHistoryItemBak());
|
||||
this.saveTableLog(tableName, templateTable, Status.Inst.SUCCESS.name());
|
||||
}
|
||||
return new GeneralResult<>(true, "创建成功");
|
||||
} catch (Exception e) {
|
||||
this.saveTableLog(tableName, templateTable, Status.Inst.FAILED.name());
|
||||
log.error("create ci_collection_history_item_bak table error:", e);
|
||||
return new GeneralResult<>(false, "创建失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void saveTableLog(String tableName, String templateTableName, String status) {
|
||||
TableLog tableLog = new TableLog();
|
||||
tableLog.setName(tableName);
|
||||
tableLog.setCode("BACKUP");
|
||||
tableLog.setStatus(status);
|
||||
tableLog.setTemplateTable(templateTableName);
|
||||
tableLog.setGmtCreate(new Date());
|
||||
tableLog.setDeleted(false);
|
||||
tableLogRepository.save(tableLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取动态表的后缀
|
||||
*
|
||||
* @param localDate
|
||||
* @return
|
||||
*/
|
||||
private String getTableSuffix(LocalDateTime localDate) {
|
||||
//2023
|
||||
int year = localDate.getYear();
|
||||
//4
|
||||
int month = localDate.getMonth().getValue();
|
||||
String months = String.valueOf(month).length() > 1 ? String.valueOf(month) : "0" + month;
|
||||
//202304
|
||||
String suffix = year + months;
|
||||
return suffix;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.bocloud.ams.booter.scheduler;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.megatron.framework.core.CurrentService;
|
||||
import com.megatron.framework.lock.AutoCloseLock;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import com.bocloud.ams.service.instance.InstanceAutoRelationService;
|
||||
import com.megatron.framework.lock.LockFactory;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* @Description: 模型实例关系定时任务
|
||||
* @Title: ModuleInstanceRelationScheduler
|
||||
* @Author: majiali
|
||||
* @CreateTime: 2022/6/9 15:53
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ModuleInstanceRelationScheduler {
|
||||
|
||||
@Autowired
|
||||
private InstanceAutoRelationService instanceAutoRelationService;
|
||||
@Autowired
|
||||
private CurrentService service;
|
||||
@Autowired
|
||||
private LockFactory lockFactory;
|
||||
|
||||
@Scheduled(cron = "${module.instance.relation.schedule:0 0 2 * * ?}") // 每天凌晨两点执行
|
||||
private void autoRelation() {
|
||||
if (!service.isLeader()) {
|
||||
log.info("当前服务不是主服务,不执行定时任务");
|
||||
return;
|
||||
}
|
||||
log.info("开始定时处理模型实例关系");
|
||||
String path = ModuleInstanceRelationScheduler.class.getSimpleName() + "_autoRelation";
|
||||
try (AutoCloseLock lock = lockFactory.getACLock(path)) {
|
||||
Assert.isTrue(lock.acquire(10, TimeUnit.SECONDS), "请求超时");
|
||||
instanceAutoRelationService.autoRelation();
|
||||
} catch (Exception e) {
|
||||
log.error("Auto relation scheduler fail:", e);
|
||||
}
|
||||
log.info("结束定时处理模型实例关系");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,231 @@
|
|||
package com.bocloud.ams.booter.scheduler;
|
||||
|
||||
|
||||
import com.alibaba.excel.util.DateUtils;
|
||||
import com.bocloud.ams.entity.config.CmdbConfig;
|
||||
import com.bocloud.ams.entity.TableLog;
|
||||
import com.bocloud.ams.entity.audit.OperationalAudit;
|
||||
import com.bocloud.ams.entity.audit.OperationalAuditBak;
|
||||
import com.bocloud.ams.entity.enums.Status;
|
||||
import com.bocloud.ams.repository.config.CmdbConfigRepository;
|
||||
import com.bocloud.ams.repository.TableLogRepository;
|
||||
import com.bocloud.ams.repository.audit.OperationalAuditBakRepository;
|
||||
import com.bocloud.ams.repository.audit.OperationalAuditRepository;
|
||||
import com.bocloud.ams.repository.utils.CmdbUtils;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.megatron.common.model.GeneralResult;
|
||||
import com.megatron.common.model.Param;
|
||||
import com.megatron.common.model.Sign;
|
||||
import com.megatron.common.utils.ListTool;
|
||||
import com.megatron.common.utils.MapTools;
|
||||
import com.megatron.framework.core.CurrentService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class OperationalAuditBakScheduler {
|
||||
|
||||
@Autowired
|
||||
private CurrentService service;
|
||||
@Autowired
|
||||
private OperationalAuditRepository operationalAuditRepository;
|
||||
|
||||
|
||||
@Autowired
|
||||
private OperationalAuditBakRepository operationalAuditBakRepository;
|
||||
@Autowired
|
||||
private TableLogRepository tableLogRepository;
|
||||
|
||||
@Autowired
|
||||
private CmdbConfigRepository cmdbConfigRepository;
|
||||
|
||||
//每月第一天的0时1分开始创建当月的备份表
|
||||
@Scheduled(cron = "${operational.audit.create-table:0 1 0 1 * ? }")
|
||||
private void createTable() {
|
||||
try {
|
||||
if (!service.isLeader()) {
|
||||
return;
|
||||
}
|
||||
CmdbConfig switchConfig = cmdbConfigRepository.queryByCode("CmdbOperationalAuditDataBakSwitch");
|
||||
if (null == switchConfig || StringUtils.isEmpty(switchConfig.getValue()) || !switchConfig.getValue().equalsIgnoreCase("true")) {
|
||||
log.info("备份操作审计未开启");
|
||||
return;
|
||||
}
|
||||
String time = DateUtils.format(new Date(), "yyyyMM");
|
||||
//ci_operational_audit_bak_202304
|
||||
String tableNameTaskNodeBak = CmdbUtils.CMDB_OPERATIONAL_AUDIT_BAK + time;
|
||||
createOperationalAuditBakTable(tableNameTaskNodeBak);
|
||||
} catch (Exception e) {
|
||||
log.error("定时创建库表失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
private GeneralResult<Void> createOperationalAuditBakTable(String tableName) {
|
||||
String status = Status.Inst.SUCCESS.name();
|
||||
try {
|
||||
if (operationalAuditBakRepository.countTable(tableName) > 0) {
|
||||
log.warn("创建表空间{}失败,表空间已经存在", tableName);
|
||||
return new GeneralResult<>(false, "创建失败");
|
||||
}
|
||||
operationalAuditBakRepository.createTable(tableName, new OperationalAuditBak());
|
||||
return new GeneralResult<>(true, "创建成功");
|
||||
} catch (Exception e) {
|
||||
status = Status.Inst.FAILED.name();
|
||||
log.error("create OperationalAuditBak table error:", e);
|
||||
return new GeneralResult<>(false, "创建失败");
|
||||
} finally {
|
||||
TableLog tableLog = new TableLog();
|
||||
tableLog.setCode("BACKUP");
|
||||
tableLog.setStatus(status);
|
||||
tableLog.setName(tableName);
|
||||
tableLog.setTemplateTable(CmdbUtils.CMDB_OPERATIONAL_AUDIT_BAK);
|
||||
tableLog.setGmtCreate(new Date());
|
||||
tableLog.setDeleted(false);
|
||||
tableLogRepository.save(tableLog);
|
||||
}
|
||||
}
|
||||
|
||||
@Scheduled(cron = "${operational.audit.bakup:0 0 4 * * ?}")
|
||||
public void operationalAuditDataBak() {
|
||||
if (!service.isLeader()) {
|
||||
return;
|
||||
}
|
||||
log.info("开始备份操作审计数据");
|
||||
List<OperationalAudit> instances = null;
|
||||
List<Param> params = Lists.newArrayList();
|
||||
try {
|
||||
CmdbConfig switchConfig = cmdbConfigRepository.queryByCode("CmdbOperationalAuditDataBakSwitch");
|
||||
if (null == switchConfig || StringUtils.isEmpty(switchConfig.getValue()) || !switchConfig.getValue().equalsIgnoreCase("true")) {
|
||||
log.info("备份操作审计未开启");
|
||||
return;
|
||||
}
|
||||
Integer days = 90;
|
||||
CmdbConfig config = cmdbConfigRepository.queryByCode("CmdbOperationalAuditDataBakDaysAgo");
|
||||
if (null != config && StringUtils.isNotEmpty(config.getValue())) {
|
||||
days = Integer.valueOf(config.getValue());
|
||||
}
|
||||
days = null == days ? 90 : days;
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.add(Calendar.DAY_OF_MONTH, -days);
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String time = formatter.format(calendar.getTime());
|
||||
log.info("备份{}之前的数据", time);
|
||||
params.add(new Param(MapTools.simpleMap("gmtCreate", time), Sign.LT));
|
||||
//查询备份数据的备份表后缀
|
||||
instances = this.operationalAuditRepository.listTime(params);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("查询操作审计失败", e);
|
||||
return;
|
||||
}
|
||||
if (ListTool.isEmpty(instances)) {
|
||||
log.info("结束备份操作审计数据,没有查询到需要备份的数据");
|
||||
return;
|
||||
}
|
||||
//按照时间分组
|
||||
Map<String, List<OperationalAudit>> map = new HashMap<>();
|
||||
for (OperationalAudit audit : instances) {
|
||||
String key = audit.getDateStr().replace("-", "");
|
||||
String tableName = CmdbUtils.CMDB_OPERATIONAL_AUDIT_BAK + key;
|
||||
GeneralResult result = chargeTableExist(tableName);
|
||||
if (result.isSuccess()) {
|
||||
batchesBak(audit.getDateStr(), tableName,params);
|
||||
}
|
||||
}
|
||||
|
||||
log.info("结束备份操作审计数据");
|
||||
}
|
||||
|
||||
private GeneralResult<Void> chargeTableExist(String tableName) {
|
||||
String status = Status.Inst.SUCCESS.name();
|
||||
try {
|
||||
if (operationalAuditBakRepository.countTable(tableName) > 0) {
|
||||
return new GeneralResult<>(true, "表已经存在");
|
||||
}
|
||||
operationalAuditBakRepository.createTable(tableName, new OperationalAuditBak());
|
||||
return new GeneralResult<>(true, "创建成功");
|
||||
} catch (Exception e) {
|
||||
status = Status.Inst.FAILED.name();
|
||||
log.error("create OperationalAuditBak table error:", e);
|
||||
return new GeneralResult<>(false, "创建失败");
|
||||
} finally {
|
||||
TableLog tableLog = new TableLog();
|
||||
tableLog.setCode("BACKUP");
|
||||
tableLog.setName(tableName);
|
||||
tableLog.setStatus(status);
|
||||
tableLog.setTemplateTable("ci_operational_audit");
|
||||
tableLog.setGmtCreate(new Date());
|
||||
tableLog.setDeleted(false);
|
||||
tableLogRepository.save(tableLog);
|
||||
}
|
||||
}
|
||||
|
||||
private void batchesBak(String dateStr, String tableName,List<Param> params) {
|
||||
try {
|
||||
List<Param> newParams = Lists.newArrayList();
|
||||
newParams.addAll(params);
|
||||
newParams.add(new Param(MapTools.simpleMap("dateStr", dateStr), Sign.LK));
|
||||
while (true) {
|
||||
List<OperationalAudit> instances = operationalAuditRepository.list(newParams, 1000);
|
||||
if (ListTool.isEmpty(instances)) {
|
||||
log.info("结束备份任务数据,没有查询到需要备份的数据");
|
||||
break;
|
||||
}
|
||||
int stepSize = 100;
|
||||
int size = instances.size();
|
||||
log.info("备份操作审计数{},每批操作审计数{}", size, stepSize);
|
||||
if (size > stepSize) {
|
||||
int num = size % stepSize == 0 ? size / stepSize : size / stepSize + 1;
|
||||
for (int i = 0; i < num; i++) {
|
||||
log.info("备份第{}批数据", i + 1);
|
||||
if (i + 1 == num) {
|
||||
batchBak(instances.subList(i * stepSize, size), tableName);
|
||||
} else {
|
||||
batchBak(instances.subList(i * stepSize, (i + 1) * stepSize), tableName);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
batchBak(instances, tableName);
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("备份操作审计异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
private void batchBak(List<OperationalAudit> instances, String tableName) {
|
||||
try {
|
||||
List<Long> ids = instances.stream().map(OperationalAudit::getId).collect(Collectors.toList());
|
||||
List<OperationalAuditBak> instanceBaks = Lists.newArrayList();
|
||||
for (OperationalAudit instance : instances) {
|
||||
OperationalAuditBak bak = new OperationalAuditBak();
|
||||
BeanUtils.copyProperties(instance, bak);
|
||||
instanceBaks.add(bak);
|
||||
}
|
||||
if (!instanceBaks.isEmpty()) {
|
||||
operationalAuditBakRepository.batchSaveOperationalAuditBak(instanceBaks, tableName, instanceBaks.size());
|
||||
}
|
||||
//删除原表数据
|
||||
operationalAuditRepository.delete(ids);
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("操作审计备份异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.bocloud.ams.booter.syslog;
|
||||
|
||||
import ch.qos.logback.classic.net.SyslogAppender;
|
||||
import ch.qos.logback.core.net.SyslogOutputStream;
|
||||
|
||||
import java.net.SocketException;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
public class SysLogAppenderTcpAndUdp extends SyslogAppender {
|
||||
|
||||
@Override
|
||||
public SyslogOutputStream createOutputStream() throws SocketException, UnknownHostException {
|
||||
return new SyslogOutputStreamTcpAndUdp(getSyslogHost(), getPort());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.bocloud.ams.booter.syslog;
|
||||
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
import ch.qos.logback.core.pattern.CompositeConverter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SysLogLevelConvertor extends CompositeConverter<ILoggingEvent> {
|
||||
|
||||
private static final Map<String, String> MAP = new HashMap<>() {{
|
||||
this.put("DEBUG", "7");
|
||||
this.put("INFO", "6");
|
||||
this.put("WARN", "4");
|
||||
this.put("ERROR", "3");
|
||||
}};
|
||||
|
||||
@Override
|
||||
protected String transform(ILoggingEvent iLoggingEvent, String s) {
|
||||
return MAP.getOrDefault(iLoggingEvent.getLevel().toString(), iLoggingEvent.getLevel().toString());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package com.bocloud.ams.booter.syslog;
|
||||
|
||||
import ch.qos.logback.core.net.SyslogOutputStream;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketException;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
public class SyslogOutputStreamTcpAndUdp extends SyslogOutputStream {
|
||||
|
||||
private static final int MAX_LEN_TCP = 1024;
|
||||
|
||||
private InetAddress addressTcp;
|
||||
private Socket socketTcp;
|
||||
private ByteArrayOutputStream baosTcp = new ByteArrayOutputStream();
|
||||
final private int portTcp;
|
||||
|
||||
public SyslogOutputStreamTcpAndUdp(String syslogHost, int port) throws SocketException, UnknownHostException {
|
||||
super(syslogHost, port);
|
||||
this.addressTcp = InetAddress.getByName(syslogHost);
|
||||
this.portTcp = port;
|
||||
try {
|
||||
this.socketTcp = new Socket(addressTcp, portTcp);
|
||||
} catch (IOException e) {
|
||||
throw new SocketException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] byteArray, int offset, int len) throws IOException {
|
||||
super.write(byteArray, offset, len);
|
||||
baosTcp.write(byteArray, offset, len);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
super.flush();
|
||||
|
||||
byte[] bytes = baosTcp.toByteArray();
|
||||
|
||||
// clean up for next round
|
||||
if (baosTcp.size() > MAX_LEN_TCP) {
|
||||
baosTcp = new ByteArrayOutputStream();
|
||||
} else {
|
||||
baosTcp.reset();
|
||||
}
|
||||
|
||||
// after a failure, it can happen that bytes.length is zero
|
||||
// in that case, there is no point in sending out an empty message/
|
||||
if (bytes.length == 0) {
|
||||
return;
|
||||
}
|
||||
if (this.socketTcp != null) {
|
||||
socketTcp.getOutputStream().write(bytes);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
super.close();
|
||||
addressTcp = null;
|
||||
try {
|
||||
socketTcp.close();
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
server:
|
||||
port: '18081'
|
||||
|
||||
spring:
|
||||
application:
|
||||
name: ams
|
||||
thread:
|
||||
core:
|
||||
pool:
|
||||
size: 1000
|
||||
max:
|
||||
pool:
|
||||
size: 1000
|
||||
queue:
|
||||
capacity: 2000
|
||||
upload:
|
||||
path: /home/cmp
|
||||
cloud:
|
||||
zookeeper:
|
||||
connect-string: 10.20.12.65:2181
|
||||
home: /bocloud/cmp/product
|
||||
auth:
|
||||
username: bocloud
|
||||
password: AES@CoU6oY/zuAoBbu6cdgOKlA==
|
||||
config:
|
||||
enabled: false
|
||||
discovery:
|
||||
register: true
|
||||
enable: true
|
||||
instance-host: 10.20.12.65
|
||||
instance-port: ${server.port}
|
||||
root: ${spring.cloud.zookeeper.home}/services
|
||||
conn:
|
||||
timeout: '50000'
|
||||
session:
|
||||
timeout: '50000'
|
||||
datasource:
|
||||
druid:
|
||||
dialect: mysql
|
||||
url: jdbc:mysql://10.20.12.65:3306/ams?characterEncoding=utf8&useSSL=false
|
||||
username: cmp
|
||||
password: Gy2VghUgWHszx8gLFT4etT9ZVOukJi73KoG1q3Oz/DAz5h2mFVVunjcyaaKT9tMPsBgoWBFRmrYbhgqJqT/Q8A==
|
||||
initialSize: '2'
|
||||
maxActive: '30'
|
||||
minIdle: '2'
|
||||
maxWait: '60000'
|
||||
poolPreparedStatements: 'true'
|
||||
maxOpenPreparedStatements: '20'
|
||||
maxPoolPreparedStatementPerConnectionSize: '20'
|
||||
validationQuery: select 1
|
||||
validationQueryTimeout: '1'
|
||||
testOnBorrow: 'true'
|
||||
testOnReturn: 'true'
|
||||
testWhileIdle: 'true'
|
||||
remove-abandoned: 'true'
|
||||
remove-abandoned-timeout: '60'
|
||||
log-abandoned: 'true'
|
||||
timeBetweenEvictionRunsMillis: '10000'
|
||||
minEvictableIdleTimeMillis: '30001'
|
||||
asyncCloseConnectionEnable: 'true'
|
||||
filters: config,stat,wall,log4j
|
||||
publicKey: MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJfVJOpXYGy8aBCk3zEoKKQDTVCCvJwhhithfY/I5PUvzFBAYygunmuCtUhzPUZ+1RJQds0Q4fu07m5mr5kv5ocCAwEAAQ==
|
||||
connectionProperties: config.decrypt=true;config.decrypt.key=MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAJfVJOpXYGy8aBCk3zEoKKQDTVCCvJwhhithfY/I5PUvzFBAYygunmuCtUhzPUZ+1RJQds0Q4fu07m5mr5kv5ocCAwEAAQ==;druid.stat.mergeSql=true;druid.stat.slowSqlMillis=5000
|
||||
use-global-data-source-stat: 'true'
|
||||
rabbitmq:
|
||||
host: 10.20.12.65
|
||||
port: 5672
|
||||
username: admin
|
||||
password: AES@CoU6oY/zuAoBbu6cdgOKlA==
|
||||
virtual-host: cmp
|
||||
dynamic: 'true'
|
||||
banner:
|
||||
charset: UTF-8
|
||||
freemarker:
|
||||
checkTemplateLocation: 'false'
|
||||
redis:
|
||||
# standalone
|
||||
host: 10.20.12.65
|
||||
port: 6379
|
||||
timeout: 60000ms
|
||||
password: AES@CoU6oY/zuAoBbu6cdgOKlA==
|
||||
lettuce:
|
||||
pool:
|
||||
max-active: '1024'
|
||||
max-idle: '16'
|
||||
min-idle: '4'
|
||||
max-wait: -1ms
|
||||
servlet:
|
||||
multipart:
|
||||
max-file-size: 2MB
|
||||
max-request-size: 20MB
|
||||
main:
|
||||
allow-circular-references: true
|
||||
logging:
|
||||
config: classpath:logback-spring.xml
|
||||
dir: /log/services
|
||||
level:
|
||||
root: info
|
||||
com:
|
||||
bocloud: info
|
||||
file:
|
||||
max-size: 100MB
|
||||
max-history: '30'
|
||||
total-size-cap: 2GB
|
||||
collection:
|
||||
task:
|
||||
instance:
|
||||
bakup: 0 0 4 * * ?
|
||||
create-table: 0 1 0 1 * ?
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
██████ ██ ██████ ████ ████ ███████ ██ ████ ████ ████████
|
||||
░█░░░░██ ██ ██ ░██ ██░░░░██░██░██ ██░██░██░░░░██ ████ ░██░██ ██░██ ██░░░░░░
|
||||
░█ ░██ █████ ░░██ ██ ██████ ███████ ░██ ██ ░░ ░██░░██ ██ ░██░██ ░██ ██░░██ ░██░░██ ██ ░██░██
|
||||
░██████ ██░░░██ ░░███ ██░░░░██░░██░░░██ ██████░██ ░██ ░░███ ░██░███████ ██ ░░██ ░██ ░░███ ░██░█████████
|
||||
░█░░░░ ██░███████ ░██ ░██ ░██ ░██ ░██ ██░░░██░██ ░██ ░░█ ░██░██░░░░ ██████████░██ ░░█ ░██░░░░░░░░██
|
||||
░█ ░██░██░░░░ ██ ░██ ░██ ░██ ░██░██ ░██░░██ ██░██ ░ ░██░██ ░██░░░░░░██░██ ░ ░██ ░██
|
||||
░███████ ░░██████ ██ ░░██████ ███ ░██░░██████ ░░██████ ░██ ░██░██ ░██ ░██░██ ░██ ████████
|
||||
░░░░░░░ ░░░░░░ ░░ ░░░░░░ ░░░ ░░ ░░░░░░ ░░░░░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░ ░░░░░░░░
|
|
@ -0,0 +1,73 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<!-- 读取application.properties中的配置 -->
|
||||
<springProperty scope="context" name="service.name" source="spring.application.name"/>
|
||||
<springProperty scope="context" name="logging.dir" source="logging.dir"/>
|
||||
<springProperty scope="context" name="logging.file.total-size-cap" source="logging.file.total-size-cap"/>
|
||||
<springProperty scope="context" name="logging.file.max-size" source="logging.file.max-size"/>
|
||||
<springProperty scope="context" name="logging.file.max-history" source="logging.file.max-history"/>
|
||||
<springProperty scope="context" name="logging.level.com.bocloud" source="logging.level.com.bocloud"/>
|
||||
<springProperty scope="context" name="logging.level.root" source="logging.level.root"/>
|
||||
<springProperty scope="context" name="logging.syslog.host" source="logging.syslog.host"/>
|
||||
<springProperty scope="context" name="logging.syslog.port" source="logging.syslog.port"/>
|
||||
<springProperty scope="context" name="logging.syslog.facility" source="logging.syslog.facility"/>
|
||||
<springProperty scope="context" name="logging.syslog.level" source="logging.syslog.level"/>
|
||||
|
||||
<conversionRule conversionWord="ilevel" converterClass="com.bocloud.ams.booter.syslog.SysLogLevelConvertor"/>
|
||||
|
||||
<property name="local_log_pattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %highlight(%-5level) [%thread] [%X{REQUEST_ID}] %cyan(%logger{32}):%L - %msg%n"/>
|
||||
<property name="sys_log_pattern" value="{"level":"%ilevel{%level}","log_level":"%level","time":"%d{yyyy-MM-dd HH:mm:ss.SSS}","thread":"%thread","class":"%logger{36}.%M:%line","message":"%msg"}%n"/>
|
||||
|
||||
<!-- 默认的控制台日志输出,一般生产环境都是后台启动,这个没太大作用 -->
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<layout class="ch.qos.logback.classic.PatternLayout">
|
||||
<pattern>${local_log_pattern}</pattern>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!-- 配置文件轮转 -->
|
||||
<appender name="LOG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<File>${logging.dir}/${service.name}.log</File>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<FileNamePattern>${logging.dir}/history/${service.name}.%d{yyyy-MM-dd}.%i.log.gz
|
||||
</FileNamePattern>
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<maxFileSize>${logging.file.max-size}</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
<MaxHistory>${logging.file.max-history}</MaxHistory>
|
||||
<totalSizeCap>${logging.file.total-size-cap}</totalSizeCap>
|
||||
</rollingPolicy>
|
||||
<layout class="ch.qos.logback.classic.PatternLayout">
|
||||
<pattern>${local_log_pattern}</pattern>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!--syslog -->
|
||||
<appender name="SYSLOG" class="com.bocloud.ams.booter.syslog.SysLogAppenderTcpAndUdp">
|
||||
<syslogHost>${logging.syslog.host}</syslogHost> <!-- Syslog 服务器的地址 -->
|
||||
<port>${logging.syslog.port}</port> <!-- Syslog 服务器的端口号 -->
|
||||
<facility>${logging.syslog.facility}</facility> <!-- Syslog 设备标识 -->
|
||||
<suffixPattern>${sys_log_pattern}</suffixPattern>
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>${logging.syslog.level}</level>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<root level="${logging.level.root}">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="LOG_FILE"/>
|
||||
<appender-ref ref="SYSLOG"/>
|
||||
</root>
|
||||
|
||||
<logger name="com.bocloud" level="${logging.level.com.bocloud}" additivity="false">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="LOG_FILE"/>
|
||||
<appender-ref ref="SYSLOG"/>
|
||||
</logger>
|
||||
|
||||
<logger name="com.alibaba.druid.pool.DruidAbstractDataSource" level="error" additivity="false">
|
||||
<appender-ref ref="CONSOLE"/>
|
||||
<appender-ref ref="LOG_FILE"/>
|
||||
<appender-ref ref="SYSLOG"/>
|
||||
</logger>
|
||||
</configuration>
|
|
@ -0,0 +1,10 @@
|
|||
*/target/*
|
||||
*/.settings/*
|
||||
*.classpath
|
||||
*.project
|
||||
*.prefs
|
||||
*.class
|
||||
*.iml
|
||||
/.idea/*
|
||||
*/.svn/*
|
||||
/target/
|
|
@ -0,0 +1,18 @@
|
|||
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>bocloud.ams</artifactId>
|
||||
<groupId>com.bocloud</groupId>
|
||||
<version>6.5.0-LTS-SZ</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>bocloud.ams.entity</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.freedom</groupId>
|
||||
<artifactId>megatron.database</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -0,0 +1,14 @@
|
|||
package com.bocloud.ams.annotation;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* @author huliwei
|
||||
* @date 2023/4/21
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD})
|
||||
@Inherited
|
||||
public @interface ColumnType {
|
||||
String value() default "";
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.bocloud.ams.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @ClassName: Role
|
||||
* @Description 角色
|
||||
* @Author yangzhenrong
|
||||
* @Date 2022/5/24 14:00
|
||||
* @Version 1.0
|
||||
**/
|
||||
@Data
|
||||
public class Role {
|
||||
private Long id;
|
||||
private String name;
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.bocloud.ams.entity;
|
||||
|
||||
import com.megatron.entity.annotations.Column;
|
||||
import com.megatron.entity.annotations.PK;
|
||||
import com.megatron.entity.annotations.Table;
|
||||
import com.megatron.entity.bean.GenericEntity;
|
||||
import com.megatron.entity.meta.PKStrategy;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author majiali
|
||||
* @date 2023/4/20
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Table("ci_table_log")
|
||||
public class TableLog extends GenericEntity {
|
||||
// ID
|
||||
@PK(value = PKStrategy.AUTO)
|
||||
private Long id;
|
||||
// 编码
|
||||
@Column("code")
|
||||
private String code;
|
||||
|
||||
@Column("template_table")
|
||||
private String templateTable;
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package com.bocloud.ams.entity.association;
|
||||
|
||||
|
||||
import com.megatron.entity.annotations.Column;
|
||||
import com.megatron.entity.annotations.IgnoreAll;
|
||||
import com.megatron.entity.annotations.PK;
|
||||
import com.megatron.entity.annotations.Table;
|
||||
import com.megatron.entity.bean.GenericEntity;
|
||||
import com.megatron.entity.meta.PKStrategy;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author liuyuanyuan
|
||||
* @Date 2022/5/9 0009 16:27
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
@Table("ci_auto_relation_rule")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class AutoRelationRule extends GenericEntity {
|
||||
@PK(value = PKStrategy.AUTO)
|
||||
private Long id;
|
||||
@Column(value = "module_relation_id")
|
||||
private Long moduleRelationId;
|
||||
@Column(value = "relation_category_id")
|
||||
private Long relationCategoryId;
|
||||
@Column(value = "source_module_id")
|
||||
private Long sourceModuleId;
|
||||
@Column(value = "target_module_id")
|
||||
private Long targetModuleId;
|
||||
@IgnoreAll
|
||||
private List<AutoRelationRuleItem> items;
|
||||
@IgnoreAll
|
||||
private String sourceModuleName;
|
||||
@IgnoreAll
|
||||
private String targetModuleName;
|
||||
@IgnoreAll
|
||||
private String cmdbRelationCategoryName;
|
||||
@IgnoreAll
|
||||
private String cmdbRelationName;
|
||||
@IgnoreAll
|
||||
private String creator;
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package com.bocloud.ams.entity.association;
|
||||
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.megatron.common.utils.DateDeserializer;
|
||||
import com.megatron.common.utils.DateSerializer;
|
||||
import com.megatron.entity.annotations.*;
|
||||
import com.megatron.entity.bean.Generic;
|
||||
import com.megatron.entity.meta.PKStrategy;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author liuyuanyuan
|
||||
* @Date 2022/5/9 0009 16:31
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
@Table("ci_auto_relation_rule_item")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class AutoRelationRuleItem extends Generic {
|
||||
@PK(value = PKStrategy.AUTO)
|
||||
private Long id;
|
||||
@Column(value = "relation_rule_id")
|
||||
private Long relationRuleId;
|
||||
@Column(value = "source_field")
|
||||
private Long sourceField;
|
||||
@Column(value = "target_field")
|
||||
private Long targetField;
|
||||
@Column(value = "is_deleted")
|
||||
private Boolean deleted;
|
||||
@Column(value = "remark")
|
||||
private String remark;
|
||||
@IgnoreUpdate
|
||||
@Column(value = "gmt_create", nullable = false)
|
||||
@JsonSerialize(using = DateSerializer.class)
|
||||
@JsonDeserialize(using = DateDeserializer.class)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date gmtCreate;
|
||||
@Column("gmt_modify")
|
||||
@JsonSerialize(using = DateSerializer.class)
|
||||
@JsonDeserialize(using = DateDeserializer.class)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date gmtModify;
|
||||
@IgnoreUpdate
|
||||
@Column("creator_id")
|
||||
private Long creatorId;
|
||||
@Column("mender_id")
|
||||
private Long menderId;
|
||||
@IgnoreAll
|
||||
private List<AutoRelationRuleItemValue> values;
|
||||
@IgnoreAll
|
||||
private String sourceFieldName;
|
||||
@IgnoreAll
|
||||
private String targetFieldName;
|
||||
@IgnoreAll
|
||||
private String sourceFieldType;
|
||||
@IgnoreAll
|
||||
private String targetFieldType;
|
||||
@IgnoreAll
|
||||
private String sourceFieldCode;
|
||||
@IgnoreAll
|
||||
private String targetFieldCode;
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
package com.bocloud.ams.entity.association;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.megatron.common.utils.DateDeserializer;
|
||||
import com.megatron.common.utils.DateSerializer;
|
||||
import com.megatron.entity.annotations.*;
|
||||
import com.megatron.entity.bean.Generic;
|
||||
import com.megatron.entity.meta.PKStrategy;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author liuyuanyuan
|
||||
* @Date 2022/5/11 0011 18:59
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
@Table("ci_auto_relation_rule_item_value")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class AutoRelationRuleItemValue extends Generic {
|
||||
@PK(value = PKStrategy.AUTO)
|
||||
private Long id;
|
||||
@Column(value = "relation_rule_id")
|
||||
private Long relationRuleId;
|
||||
@Column(value = "item_id")
|
||||
private Long itemId;
|
||||
@Column(value = "source_module_id")
|
||||
private Long isSourceId;
|
||||
@Column(value = "target_module_id")
|
||||
private Long isTargetId;
|
||||
@Column(value = "source_property_id")
|
||||
private Long sourceValue;
|
||||
@Column(value = "target_property_id")
|
||||
private Long targetValue;
|
||||
@Column(value = "is_deleted")
|
||||
private Boolean deleted;
|
||||
@Column(value = "remark")
|
||||
private String remark;
|
||||
@IgnoreUpdate
|
||||
@Column(value = "gmt_create", nullable = false)
|
||||
@JsonSerialize(using = DateSerializer.class)
|
||||
@JsonDeserialize(using = DateDeserializer.class)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date gmtCreate;
|
||||
@Column("gmt_modify")
|
||||
@JsonSerialize(using = DateSerializer.class)
|
||||
@JsonDeserialize(using = DateDeserializer.class)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date gmtModify;
|
||||
@IgnoreUpdate
|
||||
@Column("creator_id")
|
||||
private Long creatorId;
|
||||
@Column("mender_id")
|
||||
private Long menderId;
|
||||
|
||||
/**
|
||||
* 规则结构项code
|
||||
*/
|
||||
@IgnoreAll
|
||||
private String sourceFieldCode;
|
||||
@IgnoreAll
|
||||
private String targetFieldCode;
|
||||
|
||||
@IgnoreAll
|
||||
private String sourceFieldName;
|
||||
@IgnoreAll
|
||||
private String targetFieldName;
|
||||
|
||||
@IgnoreAll
|
||||
private String sourceFieldType;
|
||||
@IgnoreAll
|
||||
private String targetFieldType;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package com.bocloud.ams.entity.audit;
|
||||
|
||||
|
||||
import com.megatron.entity.annotations.Column;
|
||||
import com.megatron.entity.annotations.IgnoreAll;
|
||||
import com.megatron.entity.annotations.PK;
|
||||
import com.megatron.entity.annotations.Table;
|
||||
import com.megatron.entity.bean.GenericEntity;
|
||||
import com.megatron.entity.meta.PKStrategy;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @Author liuyuanyuan
|
||||
* @Date 2022/5/23 0023 17:47
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
@Table("ci_operational_audit")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class OperationalAudit extends GenericEntity {
|
||||
@PK(value = PKStrategy.AUTO)
|
||||
private Long id;
|
||||
|
||||
@Column("type_code")
|
||||
private String typeCode;
|
||||
|
||||
/**
|
||||
* 操作类型
|
||||
*/
|
||||
@Column("type")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 变更前
|
||||
*/
|
||||
@Column("oa_before")
|
||||
private String oaBefore;
|
||||
|
||||
/**
|
||||
* 变更后
|
||||
*/
|
||||
@Column("oa_after")
|
||||
private String oaAfter;
|
||||
|
||||
@Column("module_code")
|
||||
private String moduleCode;
|
||||
|
||||
@Column("instance_id")
|
||||
private Long instanceId;
|
||||
|
||||
@Column("operator")
|
||||
private String operator;
|
||||
|
||||
@IgnoreAll
|
||||
private String dateStr;
|
||||
|
||||
}
|
|
@ -0,0 +1,110 @@
|
|||
package com.bocloud.ams.entity.audit;
|
||||
|
||||
|
||||
import com.bocloud.ams.annotation.ColumnType;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.megatron.common.utils.DateDeserializer;
|
||||
import com.megatron.common.utils.DateSerializer;
|
||||
import com.megatron.entity.annotations.Column;
|
||||
import com.megatron.entity.annotations.IgnoreUpdate;
|
||||
import com.megatron.entity.annotations.PK;
|
||||
import com.megatron.entity.annotations.Table;
|
||||
import com.megatron.entity.bean.Generic;
|
||||
import com.megatron.entity.bean.GenericEntity;
|
||||
import com.megatron.entity.meta.PKStrategy;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author majiali
|
||||
* @Date 2023/4/240023 17:47
|
||||
* @Description:
|
||||
*/
|
||||
|
||||
@Data
|
||||
@Table("ci_operational_audit_bak")
|
||||
public class OperationalAuditBak extends Generic {
|
||||
@PK(value = PKStrategy.SELF)
|
||||
private Long id;
|
||||
|
||||
@Column(value = "type_code",length=100)
|
||||
private String typeCode;
|
||||
|
||||
/**
|
||||
* 操作类型
|
||||
*/
|
||||
@Column(value = "type",length=100)
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 变更前
|
||||
*/
|
||||
@ColumnType(value = "text")
|
||||
@Column(value = "oa_before")
|
||||
private String oaBefore;
|
||||
|
||||
/**
|
||||
* 变更后
|
||||
*/
|
||||
@ColumnType(value = "text")
|
||||
@Column(value = "oa_after")
|
||||
private String oaAfter;
|
||||
|
||||
@Column(value = "module_code",length=100)
|
||||
private String moduleCode;
|
||||
|
||||
@Column(value = "instance_id")
|
||||
private Long instanceId;
|
||||
|
||||
@Column(value = "operator",length=500)
|
||||
private String operator;
|
||||
|
||||
@IgnoreUpdate
|
||||
@Column(
|
||||
value = "gmt_create",
|
||||
nullable = false
|
||||
)
|
||||
@JsonSerialize(
|
||||
using = DateSerializer.class
|
||||
)
|
||||
@JsonDeserialize(
|
||||
using = DateDeserializer.class
|
||||
)
|
||||
@DateTimeFormat(
|
||||
pattern = "yyyy-MM-dd HH:mm:ss"
|
||||
)
|
||||
private Date gmtCreate;
|
||||
@Column("gmt_modify")
|
||||
@JsonSerialize(
|
||||
using = DateSerializer.class
|
||||
)
|
||||
@JsonDeserialize(
|
||||
using = DateDeserializer.class
|
||||
)
|
||||
@DateTimeFormat(
|
||||
pattern = "yyyy-MM-dd HH:mm:ss"
|
||||
)
|
||||
private Date gmtModify;
|
||||
@IgnoreUpdate
|
||||
@Column("creator_id")
|
||||
private Long creatorId;
|
||||
@Column("owner_id")
|
||||
private Long ownerId;
|
||||
@Column("mender_id")
|
||||
private Long menderId;
|
||||
@Column(value = "name",length = 100)
|
||||
private String name;
|
||||
@Column(value = "status",length = 16)
|
||||
private String status;
|
||||
@Column("is_deleted")
|
||||
private Boolean deleted;
|
||||
@Column(value = "props",length = 1000)
|
||||
private String props;
|
||||
@Column(value = "remark",length = 1000)
|
||||
private String remark;
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package com.bocloud.ams.entity.collection;
|
||||
|
||||
|
||||
import com.megatron.entity.annotations.Column;
|
||||
import com.megatron.entity.annotations.IgnoreAll;
|
||||
import com.megatron.entity.annotations.PK;
|
||||
import com.megatron.entity.annotations.Table;
|
||||
import com.megatron.entity.bean.GenericEntity;
|
||||
import com.megatron.entity.meta.PKStrategy;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @Author liuyuanyuan
|
||||
* @Date 2022/6/7 0007 13:39
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
@Table("ci_collection_component")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CollectionComponent extends GenericEntity {
|
||||
@PK(value = PKStrategy.AUTO)
|
||||
private Long id;
|
||||
@Column("template_id")
|
||||
private Long templateId;
|
||||
@Column("type")
|
||||
private String type;
|
||||
@Column("title")
|
||||
private String title;
|
||||
@Column("input_form")
|
||||
private String inputForm;
|
||||
@Column("parameter_type")
|
||||
private String parameterType;
|
||||
@Column("module_id")
|
||||
private Long moduleId;
|
||||
@Column("module_code")
|
||||
private String moduleCode;
|
||||
@Column("property_id")
|
||||
private Long propertyId;
|
||||
@Column("property_code")
|
||||
private String propertyCode;
|
||||
@IgnoreAll
|
||||
private String creator;
|
||||
@IgnoreAll
|
||||
private String moduleName;
|
||||
@IgnoreAll
|
||||
private String propertyName;
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
package com.bocloud.ams.entity.collection;
|
||||
|
||||
|
||||
import com.megatron.common.utils.DateSerializer;
|
||||
import com.megatron.entity.annotations.Column;
|
||||
import com.megatron.entity.annotations.IgnoreAll;
|
||||
import com.megatron.entity.annotations.PK;
|
||||
import com.megatron.entity.annotations.Table;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.megatron.entity.bean.Generic;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: CollectionHistory
|
||||
* @Description 采集记录
|
||||
* @Author yangzhenrong
|
||||
* @Date 2022/6/15 19:57
|
||||
* @Version 1.0
|
||||
**/
|
||||
@Data
|
||||
@Table("ci_collection_history")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CollectionHistory extends Generic {
|
||||
@PK
|
||||
private Long id;
|
||||
@Column(value = "module_id")
|
||||
private Long moduleId;
|
||||
@Column(value = "instance_id")
|
||||
private Long instanceId;
|
||||
@Column(value = "instance_uuid")
|
||||
private String instanceUuid;
|
||||
@Column(value = "task_instance_id", nullable = false)
|
||||
private Long taskInstanceId;
|
||||
@Column(value = "type", length = 64, nullable = false)
|
||||
private String type;//取值范围:ADD、EDIT
|
||||
@Column(value = "status", length = 64, nullable = false)
|
||||
private String status;//取值范围:SUCCESS、FAILED、RECONCILED未调和
|
||||
@Column(value = "output")
|
||||
private String output;//原始输出
|
||||
@Column(value = "operator", length = 128, nullable = false)
|
||||
private String operator;
|
||||
@Column(value = "gmt_create", length = 64, nullable = false)
|
||||
@JsonSerialize(using = DateSerializer.class)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date gmtCreate;
|
||||
@Column(value = "reason")
|
||||
private String reason;//原因
|
||||
@IgnoreAll
|
||||
private List<CollectionHistoryItem> historyItems;
|
||||
@IgnoreAll
|
||||
private String tableName;
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.bocloud.ams.entity.collection;
|
||||
|
||||
import com.bocloud.ams.annotation.ColumnType;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.megatron.common.utils.DateSerializer;
|
||||
import com.megatron.entity.annotations.Column;
|
||||
import com.megatron.entity.annotations.IgnoreAll;
|
||||
import com.megatron.entity.annotations.PK;
|
||||
import com.megatron.entity.annotations.Table;
|
||||
import com.megatron.entity.bean.Generic;
|
||||
import com.megatron.entity.meta.PKStrategy;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author huliwei
|
||||
* @date 2023/4/25
|
||||
*/
|
||||
@Data
|
||||
@Table("ci_collection_history_bak")
|
||||
public class CollectionHistoryBak extends Generic {
|
||||
|
||||
@PK(value = PKStrategy.SELF)
|
||||
private Long id;
|
||||
@Column(value = "module_id")
|
||||
private Long moduleId;
|
||||
@Column(value = "instance_id")
|
||||
private Long instanceId;
|
||||
@Column(value = "instance_uuid",length = 256)
|
||||
private String instanceUuid;
|
||||
@Column(value = "task_instance_id", nullable = false)
|
||||
private Long taskInstanceId;
|
||||
@Column(value = "type", length = 64, nullable = false)
|
||||
private String type;//取值范围:ADD、EDIT
|
||||
@Column(value = "status", length = 64)
|
||||
private String status;//取值范围:SUCCESS、FAILED、RECONCILED未调和
|
||||
@ColumnType(value = "longtext")
|
||||
@Column(value = "output")
|
||||
private String output;//原始输出
|
||||
@Column(value = "operator", length = 128, nullable = false)
|
||||
private String operator;
|
||||
@Column(value = "gmt_create", length = 64, nullable = false)
|
||||
@JsonSerialize(using = DateSerializer.class)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date gmtCreate;
|
||||
@Column(value = "reason",length = 2048)
|
||||
private String reason;//原因
|
||||
@IgnoreAll
|
||||
private List<CollectionHistoryItem> historyItems;
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
package com.bocloud.ams.entity.collection;
|
||||
|
||||
|
||||
|
||||
import com.megatron.entity.annotations.Column;
|
||||
import com.megatron.entity.annotations.IgnoreAll;
|
||||
import com.megatron.entity.annotations.PK;
|
||||
import com.megatron.entity.annotations.Table;
|
||||
import com.megatron.entity.bean.Generic;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @ClassName: CollectionHistory
|
||||
* @Description 采集记录详情
|
||||
* @Author yangzhenrong
|
||||
* @Date 2022/6/15 19:57
|
||||
* @Version 1.0
|
||||
**/
|
||||
@Data
|
||||
@Table("ci_collection_history_item")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CollectionHistoryItem extends Generic {
|
||||
@PK
|
||||
private Long id;
|
||||
@Column(value = "history_id", nullable = false)
|
||||
private Long historyId;
|
||||
@Column(value = "property_id", nullable = false)
|
||||
private Long propertyId;
|
||||
@Column(value = "property_code", length = 256, nullable = false)
|
||||
private String propertyCode;
|
||||
@Column(value = "before_value", length = 2056)
|
||||
private String beforeValue;
|
||||
@Column(value = "after_value", length = 2056)
|
||||
private String afterValue;
|
||||
@IgnoreAll
|
||||
private String propertyName;
|
||||
@IgnoreAll
|
||||
private String tableName;
|
||||
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.bocloud.ams.entity.collection;
|
||||
|
||||
import com.megatron.entity.annotations.Column;
|
||||
import com.megatron.entity.annotations.IgnoreAll;
|
||||
import com.megatron.entity.annotations.PK;
|
||||
import com.megatron.entity.annotations.Table;
|
||||
import com.megatron.entity.bean.Generic;
|
||||
import com.megatron.entity.meta.PKStrategy;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author huliwei
|
||||
* @date 2023/4/25
|
||||
*/
|
||||
@Data
|
||||
@Table("ci_collection_history_item_bak")
|
||||
public class CollectionHistoryItemBak extends Generic {
|
||||
|
||||
@PK(value = PKStrategy.SELF)
|
||||
private Long id;
|
||||
@Column(value = "history_id", nullable = false)
|
||||
private Long historyId;
|
||||
@Column(value = "property_id", nullable = false)
|
||||
private Long propertyId;
|
||||
@Column(value = "property_code", length = 256, nullable = false)
|
||||
private String propertyCode;
|
||||
@Column(value = "before_value", length = 2056)
|
||||
private String beforeValue;
|
||||
@Column(value = "after_value", length = 2056)
|
||||
private String afterValue;
|
||||
@IgnoreAll
|
||||
private String propertyName;
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.bocloud.ams.entity.collection;
|
||||
|
||||
import com.megatron.entity.annotations.Column;
|
||||
import com.megatron.entity.annotations.IgnoreAll;
|
||||
import com.megatron.entity.annotations.PK;
|
||||
import com.megatron.entity.annotations.Table;
|
||||
import com.megatron.entity.bean.GenericEntity;
|
||||
import com.megatron.entity.meta.PKStrategy;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @Author liuyuanyuan
|
||||
* @Date 2022/6/8 0008 17:03
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
@Table("ci_collection_task")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CollectionTask extends GenericEntity {
|
||||
@PK(value = PKStrategy.AUTO)
|
||||
private Long id;
|
||||
@Column("uuid")
|
||||
private String uuid;
|
||||
@Column("type")
|
||||
private String type;
|
||||
@Column("graph")
|
||||
private Object graph;
|
||||
@Column("cron")
|
||||
private String cron;
|
||||
@Column("module_id")
|
||||
private Long moduleId;
|
||||
@Column("template_id")
|
||||
private Long templateId;
|
||||
@Column("reconcile")
|
||||
private Boolean reconcile = false;
|
||||
@Column("auto_relation")
|
||||
private Boolean autoRelation = false;
|
||||
@IgnoreAll
|
||||
private String creator;
|
||||
@IgnoreAll
|
||||
private String mender;
|
||||
@IgnoreAll
|
||||
private String templateName;
|
||||
@IgnoreAll
|
||||
private String moduleName;
|
||||
}
|
|
@ -0,0 +1,142 @@
|
|||
package com.bocloud.ams.entity.collection;
|
||||
|
||||
|
||||
import com.megatron.common.utils.DateSerializer;
|
||||
import com.megatron.entity.annotations.Column;
|
||||
import com.megatron.entity.annotations.IgnoreAll;
|
||||
import com.megatron.entity.annotations.PK;
|
||||
import com.megatron.entity.annotations.Table;
|
||||
import com.megatron.entity.bean.GenericEntity;
|
||||
import com.megatron.entity.meta.PKStrategy;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author liuyuanyuan
|
||||
* @Date 2022/6/10 0010 16:11
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("ci_collection_task_instance")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CollectionTaskInstance extends GenericEntity {
|
||||
@PK(value = PKStrategy.AUTO)
|
||||
private Long id;
|
||||
@Column("uuid")
|
||||
private String uuid;
|
||||
/**
|
||||
* 任务类型
|
||||
*/
|
||||
@Column("type")
|
||||
private String type;
|
||||
@Column("code")
|
||||
private String code;
|
||||
@Column("graph")
|
||||
private Object graph;
|
||||
@Column("cron")
|
||||
private String cron;
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@Column("gmt_start")
|
||||
@JsonSerialize(using = DateSerializer.class)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss:SSS")
|
||||
private Date gmtStart;
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@Column("gmt_finish")
|
||||
@JsonSerialize(using = DateSerializer.class)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss:SSS")
|
||||
private Date gmtFinish;
|
||||
|
||||
/**
|
||||
* 总耗时
|
||||
*/
|
||||
@Column("finish_time")
|
||||
private Long finishTime;
|
||||
|
||||
/**
|
||||
* 任务ID
|
||||
*/
|
||||
@Column("task_id")
|
||||
private Long taskId;
|
||||
/**
|
||||
* 超时时间
|
||||
*/
|
||||
@Column("timeout")
|
||||
private Long timeout;
|
||||
|
||||
/**
|
||||
* 耗时
|
||||
*/
|
||||
@Column("cost")
|
||||
private Double cost;
|
||||
|
||||
/**
|
||||
* 输入参数
|
||||
*/
|
||||
@Column("input")
|
||||
private String input;
|
||||
|
||||
/**
|
||||
* 输出参数
|
||||
*/
|
||||
@Column("output")
|
||||
private String output;
|
||||
|
||||
/**
|
||||
* 采集结束时间
|
||||
*/
|
||||
@Column("collection_finish")
|
||||
@JsonSerialize(using = DateSerializer.class)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date collectionFinish;
|
||||
|
||||
/**
|
||||
* 采集总耗时
|
||||
*/
|
||||
@Column("collection_time")
|
||||
private Double collectionTime;
|
||||
|
||||
/**
|
||||
* 采集状态
|
||||
*/
|
||||
@Column("collection_status")
|
||||
private String collectionStatus;
|
||||
|
||||
@IgnoreAll
|
||||
private List<Object> successes;
|
||||
@IgnoreAll
|
||||
private List<Object> failures;
|
||||
@IgnoreAll
|
||||
private Long moduleId;
|
||||
@IgnoreAll
|
||||
private String moduleCode;
|
||||
@IgnoreAll
|
||||
private String creator;
|
||||
@IgnoreAll
|
||||
private String tableName;
|
||||
|
||||
public CollectionTaskInstance(Long creatorId, Long ownerId, Long menderId, String name, String status, String remark,
|
||||
String type, String cron, String collectionStatus) {
|
||||
this.setName(name);
|
||||
this.setStatus(status);
|
||||
this.setRemark(remark);
|
||||
this.type = type;
|
||||
this.cron = cron;
|
||||
this.setCreatorId(creatorId);
|
||||
this.setOwnerId(ownerId);
|
||||
this.setMenderId(menderId);
|
||||
this.collectionStatus = collectionStatus;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,160 @@
|
|||
package com.bocloud.ams.entity.collection;
|
||||
|
||||
import com.bocloud.ams.annotation.ColumnType;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.megatron.common.utils.DateDeserializer;
|
||||
import com.megatron.common.utils.DateSerializer;
|
||||
import com.megatron.entity.annotations.*;
|
||||
import com.megatron.entity.bean.Generic;
|
||||
import com.megatron.entity.meta.PKStrategy;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author huliwei
|
||||
* @date 2023/4/24
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("ci_collection_task_instance_bak")
|
||||
public class CollectionTaskInstanceBak extends Generic {
|
||||
@PK(value = PKStrategy.SELF)
|
||||
private Long id;
|
||||
@Column(value = "uuid",length = 64)
|
||||
private String uuid;
|
||||
/**
|
||||
* 任务类型
|
||||
*/
|
||||
@Column(value = "type",length = 64)
|
||||
private String type;
|
||||
@Column(value = "code",length = 64)
|
||||
private String code;
|
||||
@ColumnType(value = "longtext")
|
||||
@Column("graph")
|
||||
private String graph;
|
||||
@Column(value = "cron",length = 64)
|
||||
private String cron;
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@Column("gmt_start")
|
||||
@JsonSerialize(using = DateSerializer.class)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss:SSS")
|
||||
private Date gmtStart;
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@Column("gmt_finish")
|
||||
@JsonSerialize(using = DateSerializer.class)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss:SSS")
|
||||
private Date gmtFinish;
|
||||
|
||||
/**
|
||||
* 总耗时
|
||||
*/
|
||||
@Column("finish_time")
|
||||
private Long finishTime;
|
||||
|
||||
/**
|
||||
* 任务ID
|
||||
*/
|
||||
@Column("task_id")
|
||||
private Long taskId;
|
||||
/**
|
||||
* 超时时间
|
||||
*/
|
||||
@Column("timeout")
|
||||
private Long timeout;
|
||||
|
||||
/**
|
||||
* 耗时
|
||||
*/
|
||||
@ColumnType(value = "double")
|
||||
@Column("cost")
|
||||
private Double cost;
|
||||
|
||||
/**
|
||||
* 输入参数
|
||||
*/
|
||||
@ColumnType(value = "text")
|
||||
@Column("input")
|
||||
private String input;
|
||||
|
||||
/**
|
||||
* 输出参数
|
||||
*/
|
||||
@ColumnType(value = "longtext")
|
||||
@Column("output")
|
||||
private String output;
|
||||
|
||||
/**
|
||||
* 采集结束时间
|
||||
*/
|
||||
@Column("collection_finish")
|
||||
@JsonSerialize(using = DateSerializer.class)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date collectionFinish;
|
||||
|
||||
/**
|
||||
* 采集总耗时
|
||||
*/
|
||||
@ColumnType(value = "double")
|
||||
@Column("collection_time")
|
||||
private Double collectionTime;
|
||||
|
||||
/**
|
||||
* 采集状态
|
||||
*/
|
||||
@Column(value = "collection_status",length = 64)
|
||||
private String collectionStatus;
|
||||
|
||||
@IgnoreUpdate
|
||||
@Column(
|
||||
value = "gmt_create",
|
||||
nullable = false
|
||||
)
|
||||
@JsonSerialize(
|
||||
using = DateSerializer.class
|
||||
)
|
||||
@JsonDeserialize(
|
||||
using = DateDeserializer.class
|
||||
)
|
||||
@DateTimeFormat(
|
||||
pattern = "yyyy-MM-dd HH:mm:ss"
|
||||
)
|
||||
private Date gmtCreate;
|
||||
@Column("gmt_modify")
|
||||
@JsonSerialize(
|
||||
using = DateSerializer.class
|
||||
)
|
||||
@JsonDeserialize(
|
||||
using = DateDeserializer.class
|
||||
)
|
||||
@DateTimeFormat(
|
||||
pattern = "yyyy-MM-dd HH:mm:ss"
|
||||
)
|
||||
private Date gmtModify;
|
||||
@IgnoreUpdate
|
||||
@Column(value = "creator_id",nullable = false)
|
||||
private Long creatorId;
|
||||
@Column("owner_id")
|
||||
private Long ownerId;
|
||||
@Column("mender_id")
|
||||
private Long menderId;
|
||||
@Column(value = "name" , length = 256)
|
||||
private String name;
|
||||
@Column(value = "status" ,length = 16)
|
||||
private String status;
|
||||
@Column(value = "is_deleted",length = 1,nullable = false)
|
||||
private Boolean deleted;
|
||||
@Column(value = "props",length = 1024)
|
||||
private String props;
|
||||
@Column(value = "remark",length = 512)
|
||||
private String remark;
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.bocloud.ams.entity.collection;
|
||||
|
||||
import com.megatron.entity.annotations.Column;
|
||||
import com.megatron.entity.annotations.IgnoreAll;
|
||||
import com.megatron.entity.annotations.PK;
|
||||
import com.megatron.entity.annotations.Table;
|
||||
import com.megatron.entity.bean.GenericEntity;
|
||||
import com.megatron.entity.meta.PKStrategy;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author liuyuanyuan
|
||||
* @Date 2022/6/7 0007 11:10
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
@Table("ci_collection_template")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CollectionTemplate extends GenericEntity {
|
||||
@PK(value = PKStrategy.AUTO)
|
||||
private Long id;
|
||||
@Column("module_id")
|
||||
private Long moduleId;
|
||||
@Column("graph")
|
||||
private Object graph;
|
||||
@Column("collection_type")
|
||||
private String collectionType;
|
||||
@IgnoreAll
|
||||
private List<CollectionComponent> components;
|
||||
@IgnoreAll
|
||||
private String creator;
|
||||
@IgnoreAll
|
||||
private String moduleName;
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
package com.bocloud.ams.entity.config;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.megatron.common.utils.DateSerializer;
|
||||
import com.megatron.entity.annotations.Column;
|
||||
import com.megatron.entity.annotations.IgnoreUpdate;
|
||||
import com.megatron.entity.annotations.PK;
|
||||
import com.megatron.entity.annotations.Table;
|
||||
import com.megatron.entity.bean.Generic;
|
||||
import com.megatron.entity.meta.PKStrategy;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author majiali
|
||||
* @date 2023/4/20
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Table("ci_cmdb_config")
|
||||
public class CmdbConfig extends Generic {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@PK(value = PKStrategy.AUTO)
|
||||
private Long id;
|
||||
/**
|
||||
* 配置编码
|
||||
*/
|
||||
@Column("code")
|
||||
private String code;
|
||||
/**
|
||||
* 配置名称
|
||||
*/
|
||||
@Column("name")
|
||||
private String name;
|
||||
/**
|
||||
* 配置值
|
||||
*/
|
||||
@Column("value")
|
||||
private String value;
|
||||
/**
|
||||
* 配置注释
|
||||
*/
|
||||
@Column("remark")
|
||||
private String remark;
|
||||
/**
|
||||
* 配置分类
|
||||
*/
|
||||
@Column("category")
|
||||
private String category;
|
||||
|
||||
/**
|
||||
* 配置子类
|
||||
*/
|
||||
@Column("subclass")
|
||||
private String subclass;
|
||||
/**
|
||||
* 配置类型(TEXT、SELECTICON、PASSWORD)
|
||||
*/
|
||||
@Column("type")
|
||||
private String type;
|
||||
/**
|
||||
* 配置json串
|
||||
*/
|
||||
@Column("config")
|
||||
private String config;
|
||||
/**
|
||||
* 创建人id
|
||||
*/
|
||||
@Column("creator_id")
|
||||
private Long creatorId;
|
||||
/**
|
||||
* 修改人Id
|
||||
*/
|
||||
@Column("mender_id")
|
||||
private Long menderId;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column("gmt_create")
|
||||
@IgnoreUpdate
|
||||
@JsonSerialize(using = DateSerializer.class)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date gmtCreate;
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@Column("gmt_modify")
|
||||
@JsonSerialize(using = DateSerializer.class)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date gmtModify;
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.bocloud.ams.entity.enums;
|
||||
|
||||
/**
|
||||
* 申请状态
|
||||
*
|
||||
* @author dmw
|
||||
*
|
||||
*/
|
||||
public enum ApplyStatus {
|
||||
|
||||
/**
|
||||
* 新创建
|
||||
*/
|
||||
CREATED,
|
||||
/**
|
||||
* 未申请
|
||||
*/
|
||||
UNAPPLY,
|
||||
/**
|
||||
* 审批中
|
||||
*/
|
||||
APPROVING,
|
||||
/**
|
||||
* 已通过
|
||||
*/
|
||||
APPROVED,
|
||||
/**
|
||||
* 已拒绝
|
||||
*/
|
||||
REFUSED,
|
||||
/**
|
||||
* 编排中
|
||||
*/
|
||||
DEVELOPING,
|
||||
|
||||
}
|
|
@ -0,0 +1,220 @@
|
|||
package com.bocloud.ams.entity.enums;
|
||||
|
||||
|
||||
import com.megatron.common.model.GeneralResult;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* @Author liuyuanyuan
|
||||
* @Date 2022/6/7 0007 13:42
|
||||
* @Description:
|
||||
*/
|
||||
public class CollectionEnum {
|
||||
|
||||
public enum Task {
|
||||
/**
|
||||
* 定时任务
|
||||
*/
|
||||
SCHEDULED("scheduled"),
|
||||
/**
|
||||
* 标准任务
|
||||
*/
|
||||
STANDARD("standard"),
|
||||
/**
|
||||
* 临时任务
|
||||
*/
|
||||
TEMPORARY("temporary"),
|
||||
/**
|
||||
* 任务模板
|
||||
*/
|
||||
TEMPLATE("template");
|
||||
|
||||
public static GeneralResult<Task> hasValue(String value) {
|
||||
if (StringUtils.isEmpty(value)) {
|
||||
return new GeneralResult<>(false, "参数为空!");
|
||||
}
|
||||
Task[] tasks = Task.values();
|
||||
for (Task task : tasks) {
|
||||
if (task.name().equalsIgnoreCase(value)) {
|
||||
return new GeneralResult<Task>(true, task, "success");
|
||||
}
|
||||
}
|
||||
return new GeneralResult<>(false, "数值不存在!");
|
||||
}
|
||||
|
||||
private String value;
|
||||
|
||||
Task(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务执行状态
|
||||
*/
|
||||
public enum Status {
|
||||
/**
|
||||
* 创建
|
||||
*/
|
||||
CREATED,
|
||||
/**
|
||||
* 运行中
|
||||
*/
|
||||
RUNNING,
|
||||
/**
|
||||
* 已暂停
|
||||
*/
|
||||
SUSPENDED,
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
SUCCESS,
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
ERROR
|
||||
}
|
||||
|
||||
public enum workerCode {
|
||||
//脚本
|
||||
SCRIPT("task.maintain.script"),
|
||||
//数据库
|
||||
DATABASE("task.maintain.database"),
|
||||
//接口
|
||||
METHOD("task.maintain.method");
|
||||
|
||||
private final String value;
|
||||
|
||||
workerCode(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public enum collectionType {
|
||||
//脚本
|
||||
SCRIPT("script"),
|
||||
//数据库
|
||||
DATABASE("database"),
|
||||
//接口
|
||||
METHOD("method");
|
||||
|
||||
private final String value;
|
||||
|
||||
collectionType(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public enum parameter {
|
||||
//输入参数
|
||||
INPUT("input"),
|
||||
//目标输入参数
|
||||
INPUT_TARGET("input_target"),
|
||||
//输出参数
|
||||
OUTPUT("output"),
|
||||
//对照参数
|
||||
CONTRAST("contrast");
|
||||
|
||||
private final String value;
|
||||
|
||||
parameter(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public enum inputForm {
|
||||
//输入形式
|
||||
MANUAL("manual");
|
||||
private final String value;
|
||||
|
||||
inputForm(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public enum parameterType {
|
||||
//cmdb实例
|
||||
CMDB_INSTANCE("cmdb_instance"),
|
||||
//单行文本
|
||||
TEXT("text"),
|
||||
//加密数据
|
||||
ENCRYPT_DATA("encrypt_data"),
|
||||
//整数
|
||||
INTEGER("integer");
|
||||
|
||||
private final String value;
|
||||
|
||||
parameterType(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public enum historyType {
|
||||
ADD("实例新增"),
|
||||
EDIT("实例变更"),
|
||||
NOUPDATE("无需更新"),
|
||||
NOTCOLLECTED("未采集");
|
||||
private final String value;
|
||||
|
||||
historyType(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public enum historyStatus {
|
||||
SUCCESS("执行成功"),
|
||||
FAILED("执行失败"),
|
||||
RECONCILED("未调和");
|
||||
private final String value;
|
||||
|
||||
historyStatus(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public enum historyOperate {
|
||||
CANCEL("取消"),
|
||||
UPDATE("更新");
|
||||
private final String value;
|
||||
|
||||
historyOperate(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,66 @@
|
|||
package com.bocloud.ams.entity.enums;
|
||||
|
||||
|
||||
public class InstanceEnum {
|
||||
|
||||
public enum type {
|
||||
ALL_UPDATE,//全部更新
|
||||
CLEAN_DATA//清空数据
|
||||
}
|
||||
|
||||
public enum catalog {
|
||||
INSTANCE("实例"),
|
||||
RELATION("关联关系");
|
||||
|
||||
private String value;
|
||||
|
||||
catalog(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public enum category {
|
||||
CREATE("新增"),
|
||||
MODIFY("编辑"),
|
||||
DEL("删除"),
|
||||
BATCH_MODIFY("批量编辑"),
|
||||
BATCH_DELETE("批量删除");
|
||||
|
||||
private String value;
|
||||
|
||||
category(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
public enum authority {
|
||||
ACCESS("ACCESS", "实例访问"),
|
||||
EDIT("EDIT", "实例编辑"),
|
||||
DEL("DEL", "实例删除"),
|
||||
AUTH_MANAGE("AUTH_MANAGE", "实例权限管理");
|
||||
|
||||
private String value;
|
||||
private String name;
|
||||
|
||||
authority(String value, String name) {
|
||||
this.value = value;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package com.bocloud.ams.entity.enums;
|
||||
|
||||
/**
|
||||
* 审计日志操作类型
|
||||
*/
|
||||
public enum OperationalAuditType {
|
||||
//新增
|
||||
ADD("ADD", "新增"),
|
||||
//修改
|
||||
MODIFY("MODIFY", "修改"),
|
||||
//批量修改
|
||||
BATCH_MODIFY("BATCH_MODIFY", "批量修改"),
|
||||
//删除
|
||||
DELETE("DEL", "删除"),
|
||||
//批量删除
|
||||
BATCH_DELETE("BATCH_DELETE", "批量删除"),
|
||||
//分配
|
||||
ALLOCATION("ALLOCATION", "分配"),
|
||||
//转移
|
||||
TRANSFER("TRANSFER", "转移"),
|
||||
//关联
|
||||
RELATION("RELATION", "关联"),
|
||||
//取消关联
|
||||
ASSOCIATION("ASSOCIATION", "取消关联");
|
||||
|
||||
private String type;
|
||||
private String typeDesc;
|
||||
|
||||
OperationalAuditType(String type, String typeDesc) {
|
||||
this.type = type;
|
||||
this.typeDesc = typeDesc;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getTypeDesc() {
|
||||
return typeDesc;
|
||||
}
|
||||
|
||||
public void setTypeDesc(String typeDesc) {
|
||||
this.typeDesc = typeDesc;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package com.bocloud.ams.entity.enums;
|
||||
|
||||
/**
|
||||
* 属性类型
|
||||
*
|
||||
* @author tangcq
|
||||
*/
|
||||
public enum PropertyType {
|
||||
/**
|
||||
* 单行文本
|
||||
*/
|
||||
TEXTFIELD,
|
||||
/**
|
||||
* 文本框
|
||||
*/
|
||||
TEXTAREA,
|
||||
/**
|
||||
* 下来菜单
|
||||
*/
|
||||
SELECT,
|
||||
/**
|
||||
* 单选
|
||||
*/
|
||||
RADIO,
|
||||
/**
|
||||
* 多选
|
||||
*/
|
||||
CHECKBOX,
|
||||
/**
|
||||
* 引用
|
||||
*/
|
||||
QUOTE,
|
||||
/**
|
||||
* 日期
|
||||
*/
|
||||
DATE,
|
||||
/**
|
||||
* 日期+时间
|
||||
*/
|
||||
TIME,
|
||||
/**
|
||||
* 加密
|
||||
*/
|
||||
TEXTENCRYPT,
|
||||
/**
|
||||
* 整数
|
||||
*/
|
||||
INTEGER,
|
||||
/**
|
||||
* 小数
|
||||
*/
|
||||
FLOAT,
|
||||
/**
|
||||
* 表格
|
||||
*/
|
||||
TABLE,
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
package com.bocloud.ams.entity.enums;
|
||||
|
||||
/**
|
||||
* 状态枚举类
|
||||
*
|
||||
* @author dmw
|
||||
*
|
||||
*/
|
||||
public class Status {
|
||||
|
||||
/**
|
||||
* 任务状态
|
||||
*
|
||||
* @author dmw
|
||||
*
|
||||
*/
|
||||
public static enum Task {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务实例状态
|
||||
*
|
||||
* @author dmw
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @author weiwei
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @author weiwei
|
||||
*
|
||||
*/
|
||||
public static enum Inst {
|
||||
/**
|
||||
* 新创建
|
||||
*/
|
||||
CREATED,
|
||||
/**
|
||||
* 等待中
|
||||
*/
|
||||
WAITTING,
|
||||
/**
|
||||
* 运行中
|
||||
*/
|
||||
RUNNING,
|
||||
/**
|
||||
* 已暂停
|
||||
*/
|
||||
SUSPENDED,
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
SUCCESS,
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
FAILED,
|
||||
/**
|
||||
* 异常
|
||||
*/
|
||||
EXCEPTION,
|
||||
/**
|
||||
* 取消中
|
||||
*/
|
||||
CANCELING,
|
||||
/**
|
||||
* 已取消
|
||||
*/
|
||||
CANCELED,
|
||||
/**
|
||||
* 申请中
|
||||
*/
|
||||
APPROVING,
|
||||
/**
|
||||
* 已结束
|
||||
*/
|
||||
END;
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务节点状态
|
||||
*
|
||||
* @author dmw
|
||||
*
|
||||
*/
|
||||
public static enum Node {
|
||||
/**
|
||||
* 不可执行
|
||||
*/
|
||||
NOREADY,
|
||||
/**
|
||||
* 可执行
|
||||
*/
|
||||
READY,
|
||||
/**
|
||||
* 运行中
|
||||
*/
|
||||
RUNNING,
|
||||
/**
|
||||
* 成功
|
||||
*/
|
||||
SUCCESS,
|
||||
/**
|
||||
* 失败
|
||||
*/
|
||||
FAILED,
|
||||
/**
|
||||
* 异常
|
||||
*/
|
||||
EXCEPTION,
|
||||
/**
|
||||
* 已暂停
|
||||
*/
|
||||
SUSPENDED,
|
||||
/**
|
||||
* 已跳过
|
||||
*/
|
||||
SKIPPED,
|
||||
/**
|
||||
* 已取消
|
||||
*/
|
||||
CANCELED;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.bocloud.ams.entity.instance;
|
||||
|
||||
import com.megatron.entity.annotations.Column;
|
||||
import com.megatron.entity.annotations.IgnoreAll;
|
||||
import com.megatron.entity.annotations.PK;
|
||||
import com.megatron.entity.annotations.Table;
|
||||
import com.megatron.entity.bean.GenericEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: CmdbInstance
|
||||
* @Description
|
||||
* @Author yangzhenrong
|
||||
* @Date 2022/5/11 14:45
|
||||
* @Version 1.0
|
||||
**/
|
||||
@Data
|
||||
@Table("ci_instance")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class Instance extends GenericEntity {
|
||||
|
||||
@PK
|
||||
private Long id;
|
||||
@Column(value = "uuid", length = 256, nullable = false)
|
||||
private String uuid;
|
||||
@Column(value = "module_id", nullable = false)
|
||||
private Long moduleId;
|
||||
@Column(value = "module_code", length = 128, nullable = false)
|
||||
private String moduleCode;
|
||||
@IgnoreAll
|
||||
private List<InstanceValue> instanceValues;
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.bocloud.ams.entity.instance;
|
||||
|
||||
|
||||
import com.megatron.entity.annotations.Column;
|
||||
import com.megatron.entity.annotations.IgnoreAll;
|
||||
import com.megatron.entity.annotations.PK;
|
||||
import com.megatron.entity.annotations.Table;
|
||||
import com.megatron.entity.bean.GenericEntity;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: CmdbInstanceAuthority
|
||||
* @Description
|
||||
* @Author yangzhenrong
|
||||
* @Date 2022/5/23 18:10
|
||||
* @Version 1.0
|
||||
**/
|
||||
@Data
|
||||
@Table("ci_instance_authority")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class InstanceAuthority extends GenericEntity {
|
||||
@PK
|
||||
private Long id;
|
||||
@Column(value = "module_id", nullable = false)
|
||||
private Long moduleId;
|
||||
@Column(value = "instance_id", nullable = false)
|
||||
private Long instanceId;
|
||||
@Column(value = "role_id", nullable = false)
|
||||
private Long roleId;
|
||||
@Column(value = "user_id")
|
||||
private Long userId;
|
||||
@Column(value = "auths", length = 512, nullable = false)
|
||||
private String auths;
|
||||
@IgnoreAll
|
||||
private Boolean isOverwrite;
|
||||
@IgnoreAll
|
||||
private List<Long> instanceIds;
|
||||
@IgnoreAll
|
||||
private String roleName;
|
||||
@IgnoreAll
|
||||
private String authNames;
|
||||
@IgnoreAll
|
||||
private String userName;
|
||||
@IgnoreAll
|
||||
private String userIds;
|
||||
|
||||
public InstanceAuthority() {
|
||||
|
||||
}
|
||||
|
||||
public InstanceAuthority(Long moduleId, Long instanceId, Long roleId, Long userId, String auths) {
|
||||
this.moduleId = moduleId;
|
||||
this.instanceId = instanceId;
|
||||
this.roleId = roleId;
|
||||
this.userId = userId;
|
||||
this.auths = auths;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package com.bocloud.ams.entity.instance;
|
||||
|
||||
|
||||
import com.megatron.common.utils.DateSerializer;
|
||||
import com.megatron.entity.annotations.Column;
|
||||
import com.megatron.entity.annotations.PK;
|
||||
import com.megatron.entity.annotations.Table;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.megatron.entity.bean.Generic;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @ClassName: CmdbInstanceHistory
|
||||
* @Description 实例操作记录
|
||||
* @Author yangzhenrong
|
||||
* @Date 2022/5/16 15:49
|
||||
* @Version 1.0
|
||||
**/
|
||||
@Data
|
||||
@Table("ci_instance_history")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class InstanceHistory extends Generic {
|
||||
@PK
|
||||
private Long id;
|
||||
@Column(value = "module_id", nullable = false)
|
||||
private Long moduleId;
|
||||
@Column(value = "instance_id", nullable = false)
|
||||
private Long instanceId;
|
||||
@Column(value = "catalog", length = 64, nullable = false)
|
||||
private String catalog;//取值范围:INSTANCE、RELATION
|
||||
@Column(value = "category", length = 64, nullable = false)
|
||||
private String category;//取值范围:CREATE、MODIFY、REMOVE
|
||||
@Column(value = "content", length = 1024, nullable = false)
|
||||
private String content;
|
||||
@Column(value = "operator", length = 128, nullable = false)
|
||||
private String operator;
|
||||
@Column(value = "gmt_create", length = 64, nullable = false)
|
||||
@JsonSerialize(using = DateSerializer.class)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date gmtCreate;
|
||||
|
||||
public InstanceHistory() {
|
||||
|
||||
}
|
||||
|
||||
public InstanceHistory(Long moduleId, Long instanceId, String catalog, String category, String content, String operator, Date gmtCreate) {
|
||||
this.moduleId = moduleId;
|
||||
this.instanceId = instanceId;
|
||||
this.catalog = catalog;
|
||||
this.category = category;
|
||||
this.content = content;
|
||||
this.operator = operator;
|
||||
this.gmtCreate = gmtCreate;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package com.bocloud.ams.entity.instance;
|
||||
|
||||
import com.megatron.entity.annotations.Column;
|
||||
import com.megatron.entity.annotations.IgnoreAll;
|
||||
import com.megatron.entity.annotations.PK;
|
||||
import com.megatron.entity.annotations.Table;
|
||||
import com.megatron.entity.bean.GenericEntity;
|
||||
import com.megatron.entity.meta.PKStrategy;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author liuyuanyuan
|
||||
* @Date 2022/5/16 0016 14:09
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
@Table("ci_instance_relation")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class InstanceRelation extends GenericEntity {
|
||||
@PK(value = PKStrategy.AUTO)
|
||||
private Long id;
|
||||
@Column(value = "relation_category_id", nullable = false)
|
||||
private Long relationCategoryId;
|
||||
@Column(value = "relation_category_code", nullable = false, length = 256)
|
||||
private String relationCategoryCode;
|
||||
@Column(value = "module_relation_id", nullable = false)
|
||||
private Long moduleRelationId;
|
||||
@Column(value = "module_relation_name", length = 256)
|
||||
private String moduleRelationName;
|
||||
@Column(value = "source_module_id", nullable = false)
|
||||
private Long sourceModuleId;
|
||||
@Column(value = "source_module_code", nullable = false, length = 256)
|
||||
private String sourceModuleCode;
|
||||
@Column(value = "source_instance_id", nullable = false)
|
||||
private Long sourceInstanceId;
|
||||
@Column(value = "source_instance_name", length = 256)
|
||||
private String sourceInstanceName;
|
||||
@Column(value = "target_module_id", nullable = false)
|
||||
private Long targetModuleId;
|
||||
@Column(value = "target_module_code", nullable = false, length = 256)
|
||||
private String targetModuleCode;
|
||||
@Column(value = "target_instance_id", nullable = false)
|
||||
private Long targetInstanceId;
|
||||
@Column(value = "target_instance_name", length = 256)
|
||||
private String targetInstanceName;
|
||||
/**
|
||||
* 关联方式: 手动-MANUAL 自动-AUTO
|
||||
*/
|
||||
@Column(value = "way", length = 32)
|
||||
private String way;
|
||||
@IgnoreAll
|
||||
private String sourceType;
|
||||
@IgnoreAll
|
||||
private String targetType;
|
||||
@IgnoreAll
|
||||
private Long relationId;
|
||||
@IgnoreAll
|
||||
private String relationName;
|
||||
@IgnoreAll
|
||||
private List<InstanceRelation> cmdbInstanceRelations;
|
||||
|
||||
/**
|
||||
* 实例之间的关系 与 模型定义之间的关系 是否一致
|
||||
* false 是一致 ; true 是相反
|
||||
*/
|
||||
@IgnoreAll
|
||||
private Boolean isReversed = false;
|
||||
@IgnoreAll
|
||||
private String type;
|
||||
@IgnoreAll
|
||||
private Long currentModuleId;
|
||||
/**
|
||||
* 手动关系,标记当前操作的实例
|
||||
*/
|
||||
@IgnoreAll
|
||||
private Long currentInstanceId;
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
package com.bocloud.ams.entity.instance;
|
||||
|
||||
|
||||
|
||||
import com.megatron.common.utils.DateDeserializer;
|
||||
import com.megatron.common.utils.DateSerializer;
|
||||
import com.megatron.entity.annotations.Column;
|
||||
import com.megatron.entity.annotations.IgnoreAll;
|
||||
import com.megatron.entity.annotations.PK;
|
||||
import com.megatron.entity.annotations.Table;
|
||||
import com.megatron.entity.bean.GenericEntity;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @ClassName: CmdbInstanceRelationHistoryRecord
|
||||
* @Description 历史关系变更历史记录
|
||||
* @Author majiali
|
||||
* @Date 2022/6/8 15:49
|
||||
* @Version 1.0
|
||||
**/
|
||||
@Data
|
||||
@Table("ci_instance_relation_history_record")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class InstanceRelationHistoryRecord extends GenericEntity {
|
||||
@PK
|
||||
private Long id;
|
||||
@Column("module_id")
|
||||
private Long moduleId;
|
||||
@Column("instance_id")
|
||||
private Long instanceId;
|
||||
/**
|
||||
* 操作类型: 取消关联 cancel 关联 relation
|
||||
*/
|
||||
@Column("type")
|
||||
private String type;
|
||||
/**
|
||||
* 关联方式: 手动-MANUAL 自动-AUTO
|
||||
*/
|
||||
@Column("way")
|
||||
private String way;
|
||||
/**
|
||||
* 当前资源是否是源模型实例 1:是 0:否
|
||||
*/
|
||||
@Column("is_source")
|
||||
private Boolean isSource;
|
||||
@Column("module_relation_id")
|
||||
private Long moduleRelationId;
|
||||
@Column("relation_category_id")
|
||||
private Long relationCategoryId;
|
||||
@Column("auto_relation_rule_id")
|
||||
private Long autoRelationRuleId;
|
||||
@Column("alter_before")
|
||||
private String alterBefore;
|
||||
@Column("alter_after")
|
||||
private String alterAfter;
|
||||
@Column("reason")
|
||||
private String reason;
|
||||
@Column("relation_instance_id")
|
||||
private Long relationInstanceId;
|
||||
|
||||
@Column("exec_time")
|
||||
@JsonSerialize(
|
||||
using = DateSerializer.class
|
||||
)
|
||||
@JsonDeserialize(
|
||||
using = DateDeserializer.class
|
||||
)
|
||||
@DateTimeFormat(
|
||||
pattern = "yyyy-MM-dd HH:mm:ss"
|
||||
)
|
||||
private Date execTime;
|
||||
@Column("exec_id")
|
||||
private Long execId;
|
||||
@IgnoreAll
|
||||
private String executor;
|
||||
@IgnoreAll
|
||||
private String creator;
|
||||
@IgnoreAll
|
||||
private String moduleRelationName;
|
||||
@IgnoreAll
|
||||
private String relationCategoryName;
|
||||
@IgnoreAll
|
||||
private String moduleCode;
|
||||
@IgnoreAll
|
||||
private String moduleName;
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.bocloud.ams.entity.instance;
|
||||
|
||||
import com.bocloud.ams.entity.module.Property;
|
||||
import com.megatron.entity.annotations.Column;
|
||||
import com.megatron.entity.annotations.IgnoreAll;
|
||||
import com.megatron.entity.annotations.PK;
|
||||
import com.megatron.entity.annotations.Table;
|
||||
import com.megatron.entity.bean.GenericEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @ClassName: CmdbInstanceValue
|
||||
* @Description
|
||||
* @Author yangzhenrong
|
||||
* @Date 2022/5/11 14:51
|
||||
* @Version 1.0
|
||||
**/
|
||||
@Data
|
||||
@Table("ci_instance_value")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class InstanceValue extends GenericEntity {
|
||||
@PK
|
||||
private Long id;
|
||||
@Column(value = "instance_id", nullable = false)
|
||||
private Long instanceId;
|
||||
@Column(value = "property_id", nullable = false)
|
||||
private Long propertyId;
|
||||
@Column(value = "property_value", length = 2056)
|
||||
private String propertyValue;
|
||||
@Column(value = "property_code", length = 256, nullable = false)
|
||||
private String propertyCode;
|
||||
@IgnoreAll
|
||||
private String uuid;
|
||||
@IgnoreAll
|
||||
private Long moduleId;
|
||||
@IgnoreAll
|
||||
private Property property;
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.bocloud.ams.entity.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CollectionHistoryModel {
|
||||
private List<Long> ids;
|
||||
private String action;
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.bocloud.ams.entity.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 胡立伟
|
||||
* @program: bocloud.ams
|
||||
* @description: 实例拓扑中资源列表的搜索项以及列表的列名
|
||||
* @date 2022/5/18 18:08
|
||||
*/
|
||||
@Data
|
||||
public class ColumnAndSearchItemModel {
|
||||
/**
|
||||
* 搜索项
|
||||
*/
|
||||
private List<SearchConfigModel> searchConfigs;
|
||||
/**
|
||||
* 列表字段
|
||||
*/
|
||||
private List<ColumnModel> columns;
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.bocloud.ams.entity.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author 胡立伟
|
||||
* @program: bocloud.ams
|
||||
* @description: { label: '应用系统名称', value: 'name' }
|
||||
* @date 2022/5/19 11:07
|
||||
*/
|
||||
@Data
|
||||
public class ColumnModel {
|
||||
/**
|
||||
* 列表名称name
|
||||
*/
|
||||
private String label;
|
||||
/**
|
||||
* 列表key
|
||||
*/
|
||||
private String prop;
|
||||
|
||||
public ColumnModel(String label, String prop) {
|
||||
super();
|
||||
this.label = label;
|
||||
this.prop = prop;
|
||||
}
|
||||
|
||||
public ColumnModel() {
|
||||
super();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.bocloud.ams.entity.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName: CmdbInstanceModel
|
||||
* @Description
|
||||
* @Author yangzhenrong
|
||||
* @Date 2022/5/24 17:08
|
||||
* @Version 1.0
|
||||
**/
|
||||
@Data
|
||||
public class InstanceBean {
|
||||
private Long moduleId;
|
||||
private String moduleCode;
|
||||
private String propertyCode;
|
||||
private Object propertyValue;
|
||||
private List<Long> ids;
|
||||
private String type;//批量编辑:全部更新、清空数据
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.bocloud.ams.entity.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author 胡立伟
|
||||
* @program: bocloud.ams
|
||||
* @description:
|
||||
* @date 2022/5/26 17:32
|
||||
*/
|
||||
@Data
|
||||
public class InstanceLink {
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long relationCategoryId;
|
||||
|
||||
private String relationCategoryCode;
|
||||
|
||||
private Long relationId;
|
||||
|
||||
private String relationName;
|
||||
|
||||
private Long sourceModuleId;
|
||||
|
||||
private String sourceModuleCode;
|
||||
|
||||
private Long sourceInstanceId;
|
||||
|
||||
private String sourceInstanceName;
|
||||
|
||||
private Long targetModuleId;
|
||||
|
||||
private String targetModuleCode;
|
||||
|
||||
private Long targetInstanceId;
|
||||
|
||||
private String targetInstanceName;
|
||||
|
||||
private String sourceType;
|
||||
|
||||
private String targetType;
|
||||
|
||||
private String type;
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.bocloud.ams.entity.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author 胡立伟
|
||||
* @program: bocloud.ams
|
||||
* @description:
|
||||
* @date 2022/6/1 19:35
|
||||
*/
|
||||
@Data
|
||||
public class InstanceModel {
|
||||
|
||||
private Long moduleId;
|
||||
|
||||
private String moduleCode;
|
||||
|
||||
/**
|
||||
* 实例关系数据-源实例id
|
||||
*/
|
||||
private Long instanceId;
|
||||
|
||||
/**
|
||||
* 实例关系数据-源实例name
|
||||
*/
|
||||
private String instanceName;
|
||||
|
||||
private String iconImage;
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.bocloud.ams.entity.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author 胡立伟
|
||||
* @program: bocloud.ams
|
||||
* @description:
|
||||
* @date 2022/6/1 17:08
|
||||
*/
|
||||
@Data
|
||||
public class InstanceNodeModel {
|
||||
|
||||
private Long sourceModuleId;
|
||||
|
||||
private Long targetModuleId;
|
||||
|
||||
/**
|
||||
* 实例关系数据-源实例id
|
||||
*/
|
||||
private Long sourceInstanceId;
|
||||
/**
|
||||
* 实例关系数据-目的实例id
|
||||
*/
|
||||
private Long targetInstanceId;
|
||||
|
||||
/**
|
||||
* 实例关系数据-源实例name
|
||||
*/
|
||||
private String sourceInstanceName;
|
||||
/**
|
||||
* 实例关系数据-目的实例name
|
||||
*/
|
||||
private String targetInstanceName;
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.bocloud.ams.entity.model;
|
||||
|
||||
import com.bocloud.ams.entity.instance.InstanceRelation;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 关联历史调和记录详细信息(props信息)
|
||||
* @Author majiali
|
||||
* @CreateTime 2022/6/8 14:33
|
||||
*/
|
||||
@Data
|
||||
public class InstanceRelationHistoryAlterModel {
|
||||
|
||||
/**
|
||||
* @Description: 变更后
|
||||
* @param null
|
||||
* @Author majiali
|
||||
* @CreateTime 2022/6/17 18:27
|
||||
*/
|
||||
private InstanceRelation after;
|
||||
/**
|
||||
* @Description: 变更前
|
||||
* @param null
|
||||
* @Author majiali
|
||||
* @CreateTime 2022/6/17 18:27
|
||||
*/
|
||||
private List<InstanceRelation> before;
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.bocloud.ams.entity.model;
|
||||
|
||||
import com.bocloud.ams.entity.instance.InstanceRelationHistoryRecord;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 关联历史预检结果
|
||||
* @Author majiali
|
||||
* @CreateTime 2022/6/8 14:33
|
||||
*/
|
||||
@Data
|
||||
public class InstanceRelationHistoryPreflightModel {
|
||||
|
||||
/**
|
||||
* 预检结果类型 SUCCESS:成功-可以更新覆盖 FAILED:失败-数据矛盾,视作失败处理 RECONCILED:调和-historyRecordList中数据单选
|
||||
*/
|
||||
private String status;
|
||||
|
||||
private List<InstanceRelationHistoryRecord> historyRecordList;
|
||||
|
||||
private String sourceType;
|
||||
|
||||
private String targetType;
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.bocloud.ams.entity.model;
|
||||
|
||||
import com.bocloud.ams.entity.instance.InstanceRelation;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 胡立伟
|
||||
* @program: bocloud.ams
|
||||
* @description:
|
||||
* @date 2022/6/2 14:07
|
||||
*/
|
||||
@Data
|
||||
public class InstanceRelationModel {
|
||||
private Long id;
|
||||
private Long relationCategoryId;
|
||||
private String relationCategoryCode;
|
||||
private Long relationId;
|
||||
private String relationName;
|
||||
private Long sourceModuleId;
|
||||
private String sourceModuleCode;
|
||||
private Long sourceInstanceId;
|
||||
private String sourceInstanceName;
|
||||
private Long targetModuleId;
|
||||
private String targetModuleCode;
|
||||
private Long targetInstanceId;
|
||||
private String targetInstanceName;
|
||||
private List<InstanceRelation> cmdbInstanceRelations;
|
||||
|
||||
/**
|
||||
* 实例之间的关系 与 模型定义之间的关系 是否一致
|
||||
* false 是一致 ; true 是相反
|
||||
*/
|
||||
private Boolean isReversed = false;
|
||||
private String type;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.bocloud.ams.entity.model;
|
||||
|
||||
import com.bocloud.ams.entity.instance.InstanceRelation;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 胡立伟
|
||||
* @program: bocloud.ams
|
||||
* @description:
|
||||
* @date 2022/5/26 17:30
|
||||
*/
|
||||
@Data
|
||||
public class InstanceTopo {
|
||||
List<InstanceModel> nodes;
|
||||
List<InstanceRelationModel> links;
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
package com.bocloud.ams.entity.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @Author majiali
|
||||
* @CreateTime 2022/5/12 13:41
|
||||
*/
|
||||
@Data
|
||||
public class ModuleLink {
|
||||
|
||||
private Long source;
|
||||
private Long target;
|
||||
private String type;
|
||||
private Long relationId;
|
||||
private String relationName;
|
||||
/**
|
||||
* 关联类型code
|
||||
*/
|
||||
private String relationCode;
|
||||
/**
|
||||
* 拓扑关系ID
|
||||
*/
|
||||
private Long relationCategoryId;
|
||||
|
||||
/**
|
||||
* 是否是反向规则
|
||||
*/
|
||||
private Boolean isReversed = false;
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.bocloud.ams.entity.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.bocloud.ams.entity.module.CiModule;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: 模型拓扑数据
|
||||
* @Title: CmdbModuleTopo
|
||||
* @Author: majiali
|
||||
* @CreateTime: 2022/5/13 15:43
|
||||
*/
|
||||
@Data
|
||||
public class ModuleTopo {
|
||||
List<CiModule> nodes;
|
||||
List<ModuleLink> links;
|
||||
|
||||
public ModuleTopo() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ModuleTopo(List<CiModule> nodes, List<ModuleLink> links) {
|
||||
super();
|
||||
this.nodes = nodes;
|
||||
this.links = links;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,128 @@
|
|||
package com.bocloud.ams.entity.model;
|
||||
|
||||
|
||||
import com.megatron.common.model.RequestContext;
|
||||
|
||||
/**
|
||||
* 通知消息体
|
||||
*
|
||||
* @author liuyuanyuan
|
||||
* @since 2022年5月27日
|
||||
*/
|
||||
public class NotifyMessage {
|
||||
|
||||
private String subject;
|
||||
private String content;
|
||||
private String emailContent;
|
||||
private RequestContext context;
|
||||
|
||||
public String getEmailContent() {
|
||||
return emailContent;
|
||||
}
|
||||
|
||||
public void setEmailContent(String emailContent) {
|
||||
this.emailContent = emailContent;
|
||||
}
|
||||
|
||||
private boolean sendMsg;
|
||||
private boolean sendEmail;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public NotifyMessage() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @param subject
|
||||
* @param content
|
||||
* @param sendMsg
|
||||
* @param sendEmail
|
||||
*/
|
||||
public NotifyMessage(RequestContext context, String subject, String content, boolean sendMsg, boolean sendEmail) {
|
||||
super();
|
||||
this.context = context;
|
||||
this.subject = subject;
|
||||
this.content = content;
|
||||
this.sendMsg = sendMsg;
|
||||
this.sendEmail = sendEmail;
|
||||
}
|
||||
|
||||
public NotifyMessage(RequestContext context, String subject, String content, String emailContent, boolean sendMsg,
|
||||
boolean sendEmail) {
|
||||
super();
|
||||
this.context = context;
|
||||
this.subject = subject;
|
||||
this.content = content;
|
||||
this.emailContent = emailContent;
|
||||
this.sendMsg = sendMsg;
|
||||
this.sendEmail = sendEmail;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the subject
|
||||
*/
|
||||
public String getSubject() {
|
||||
return subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param subject the subject to set
|
||||
*/
|
||||
public void setSubject(String subject) {
|
||||
this.subject = subject;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the content
|
||||
*/
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param content the content to set
|
||||
*/
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sendMsg
|
||||
*/
|
||||
public boolean isSendMsg() {
|
||||
return sendMsg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sendMsg the sendMsg to set
|
||||
*/
|
||||
public void setSendMsg(boolean sendMsg) {
|
||||
this.sendMsg = sendMsg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the sendEmail
|
||||
*/
|
||||
public boolean isSendEmail() {
|
||||
return sendEmail;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sendEmail the sendEmail to set
|
||||
*/
|
||||
public void setSendEmail(boolean sendEmail) {
|
||||
this.sendEmail = sendEmail;
|
||||
}
|
||||
|
||||
public RequestContext getContext() {
|
||||
return context;
|
||||
}
|
||||
|
||||
public void setContext(RequestContext context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.bocloud.ams.entity.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author 胡立伟
|
||||
* @program: bocloud.ams
|
||||
* @description:
|
||||
* @date 2022/6/17 10:22
|
||||
*/
|
||||
@Data
|
||||
public class OperateParam {
|
||||
private Long id;
|
||||
private String action;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.bocloud.ams.entity.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author 胡立伟
|
||||
* @program: bocloud.ams
|
||||
* @description:
|
||||
* @date 2022/5/27 14:37
|
||||
*/
|
||||
@Data
|
||||
public class PathModel {
|
||||
/**
|
||||
* 有各个节点名称组成的字符串
|
||||
*/
|
||||
private String topologyPathName;
|
||||
/**
|
||||
* 有各个节点中id组成的字符串
|
||||
*/
|
||||
private String topologyPath;
|
||||
/**
|
||||
* 这个拓扑路径对于起始模型是正向的还是反向的
|
||||
*/
|
||||
private Boolean pathDirection;
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.bocloud.ams.entity.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.bocloud.ams.entity.module.Property;
|
||||
import com.bocloud.ams.entity.module.PropertyGroup;
|
||||
import com.megatron.entity.annotations.IgnoreAll;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author 胡立伟
|
||||
* @program: bocloud.ams
|
||||
* @description:
|
||||
* @date 2022/5/9 17:47
|
||||
*/
|
||||
@Data
|
||||
public class PropertyModel {
|
||||
@IgnoreAll
|
||||
private Long moduleId;
|
||||
@IgnoreAll
|
||||
private List<PropertyGroup> groups;
|
||||
@IgnoreAll
|
||||
private List<Property> properties;
|
||||
|
||||
public PropertyModel(Long moduleId, List<PropertyGroup> groups, List<Property> properties) {
|
||||
super();
|
||||
this.moduleId = moduleId;
|
||||
this.groups = groups;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
public PropertyModel() {
|
||||
super();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.bocloud.ams.entity.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 胡立伟
|
||||
* @program: bocloud.ams
|
||||
* @description:
|
||||
* @date 2022/5/23 15:36
|
||||
*/
|
||||
@Data
|
||||
public class RequestInstanceTopologyModel {
|
||||
private Long categoryId;
|
||||
private Long startModuleId;
|
||||
private Integer topologyLevel;
|
||||
private List<Long> ignoreModuleId;
|
||||
private List<Long> wayModuleId;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.bocloud.ams.entity.model;
|
||||
|
||||
import com.megatron.entity.annotations.Column;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author 胡立伟
|
||||
* @program: bocloud.ams
|
||||
* @description:
|
||||
* @date 2022/5/23 17:23
|
||||
*/
|
||||
@Data
|
||||
public class ResponseInstanceTopologyModel {
|
||||
private Long categoryId;
|
||||
private Long startModuleId;
|
||||
private String startModuleCode;
|
||||
private String startModuleName;
|
||||
private Long instanceId;
|
||||
private String instanceName;
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.bocloud.ams.entity.model;
|
||||
|
||||
public class Role {
|
||||
|
||||
private Long id; // ID
|
||||
private Long tenantId; // 租户ID
|
||||
private boolean checked;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
public void setTenantId(Long tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
|
||||
public boolean isChecked() {
|
||||
return checked;
|
||||
}
|
||||
|
||||
public void setChecked(boolean checked) {
|
||||
this.checked = checked;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package com.bocloud.ams.entity.model;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author 胡立伟
|
||||
* @program: bocloud.ams
|
||||
* @description: { label: '应用系统名称', value: 'name', type: 'Select', data: [{ name: '', id: '' }] }
|
||||
* @date 2022/5/19 11:06
|
||||
*/
|
||||
@Data
|
||||
public class SearchConfigModel {
|
||||
/**
|
||||
* 模型id
|
||||
*/
|
||||
private Long moduleId;
|
||||
/**
|
||||
* 搜索项名称
|
||||
*/
|
||||
private String label;
|
||||
/**
|
||||
* 搜索项key
|
||||
*/
|
||||
private String value;
|
||||
/**
|
||||
* 搜索框类型
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 搜索项的下来框数据[{ name: '', id: '' }]
|
||||
*/
|
||||
private List<Map<String, Object>> data;
|
||||
|
||||
public SearchConfigModel() {
|
||||
super();
|
||||
}
|
||||
|
||||
public SearchConfigModel(Long moduleId, String label, String value, String type) {
|
||||
super();
|
||||
this.moduleId = moduleId;
|
||||
this.label = label;
|
||||
this.value = value;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.bocloud.ams.entity.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class StartModeParams {
|
||||
|
||||
@JsonProperty("start_mode")
|
||||
private String startMode;
|
||||
|
||||
public String getStartMode() {
|
||||
return startMode;
|
||||
}
|
||||
|
||||
public void setStartMode(String startMode) {
|
||||
this.startMode = startMode;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.bocloud.ams.entity.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author liuyuanyuan
|
||||
* @Date 2022/6/8 0008 18:04
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class TaskBean {
|
||||
private Long id;
|
||||
private String name;
|
||||
private String remark;
|
||||
private String graph;
|
||||
private String code;
|
||||
private String cron;
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.bocloud.ams.entity.model;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author liuyuanyuan
|
||||
* @Date 2022/6/7 0007 15:05
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class TaskGraph {
|
||||
private String content;
|
||||
private String collectionType;
|
||||
private Long timeout;
|
||||
private String category;
|
||||
private String target;
|
||||
private String params;
|
||||
private String jdbcUrl;
|
||||
private String database;
|
||||
private String username;
|
||||
private String password;
|
||||
private String method;
|
||||
private String format;
|
||||
private String url;
|
||||
private String headers;
|
||||
private String body;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return JSONObject.toJSONString(this);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.bocloud.ams.entity.model;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.megatron.common.utils.DateSerializer;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author liuyuanyuan
|
||||
* @Date 2022/6/13 0013 21:00
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class TaskInstanceBean {
|
||||
private Long id;
|
||||
private String output;
|
||||
private String status;
|
||||
|
||||
@JsonSerialize(using = DateSerializer.class)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date gmtModify;
|
||||
|
||||
@JsonSerialize(using = DateSerializer.class)
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss:SSS")
|
||||
private Date collectionFinish;
|
||||
|
||||
private Double collectionTime;
|
||||
private String collectionStatus;
|
||||
private Date gmtFinish;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.bocloud.ams.entity.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author liuyuanyuan
|
||||
* @Date 2022/6/7 0007 15:08
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
public class TaskNode {
|
||||
private String name;
|
||||
private String code;
|
||||
private String config;
|
||||
private String input;
|
||||
private String control;
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.bocloud.ams.entity.model;
|
||||
|
||||
public class TaskTransferParams {
|
||||
|
||||
private String cron;
|
||||
|
||||
private Boolean isNew;
|
||||
|
||||
public String getCron() {
|
||||
return cron;
|
||||
}
|
||||
|
||||
public void setCron(String cron) {
|
||||
this.cron = cron;
|
||||
}
|
||||
|
||||
public Boolean getIsNew() {
|
||||
return isNew;
|
||||
}
|
||||
|
||||
public void setNew(Boolean aNew) {
|
||||
this.isNew = aNew;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.bocloud.ams.entity.module;
|
||||
|
||||
import com.megatron.entity.annotations.Column;
|
||||
import com.megatron.entity.annotations.IgnoreAll;
|
||||
import com.megatron.entity.annotations.PK;
|
||||
import com.megatron.entity.annotations.Table;
|
||||
import com.megatron.entity.bean.GenericEntity;
|
||||
import com.megatron.entity.meta.PKStrategy;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @Author 胡立伟
|
||||
* @Date 2022/4/29 0029 16:31
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
@Table("ci_module")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CiModule extends GenericEntity {
|
||||
@PK(value = PKStrategy.AUTO)
|
||||
private Long id;
|
||||
@Column("module_group_id")
|
||||
private Long groupId;
|
||||
@Column("code")
|
||||
private String code;
|
||||
@Column("name_space")
|
||||
private String nameSpace;
|
||||
@Column("icon_image")
|
||||
private String iconImage;
|
||||
@Column("is_disabled")
|
||||
private Boolean disabled;
|
||||
@Column("is_reserved")
|
||||
private Boolean reserved;
|
||||
@IgnoreAll
|
||||
private int instanceNum;
|
||||
//当前模型所属分组的父分组id
|
||||
@IgnoreAll
|
||||
private Long parentGroupId;
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package com.bocloud.ams.entity.module;
|
||||
|
||||
import com.megatron.entity.annotations.Column;
|
||||
import com.megatron.entity.annotations.IgnoreAll;
|
||||
import com.megatron.entity.annotations.PK;
|
||||
import com.megatron.entity.annotations.Table;
|
||||
import com.megatron.entity.bean.GenericEntity;
|
||||
import com.megatron.entity.meta.PKStrategy;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author liuyuanyuan
|
||||
* @Date 2022/4/29 0029 14:57
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
@Table("ci_module_group")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ModuleGroup extends GenericEntity {
|
||||
@PK(value = PKStrategy.AUTO)
|
||||
private Long id;
|
||||
@Column("parent_id")
|
||||
private Long parentId;
|
||||
@Column("code")
|
||||
private String code;
|
||||
@Column("name_space")
|
||||
private String nameSpace;
|
||||
@IgnoreAll
|
||||
private List<CiModule> modules;
|
||||
@IgnoreAll
|
||||
private List<ModuleGroup> childrenGroups;
|
||||
@IgnoreAll
|
||||
private Boolean existNextData;
|
||||
/**
|
||||
* 当前分组中模型个数
|
||||
*/
|
||||
@IgnoreAll
|
||||
private Integer count;
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package com.bocloud.ams.entity.module;
|
||||
|
||||
import com.bocloud.ams.entity.association.AutoRelationRuleItem;
|
||||
import com.megatron.entity.annotations.Column;
|
||||
import com.megatron.entity.annotations.IgnoreAll;
|
||||
import com.megatron.entity.annotations.PK;
|
||||
import com.megatron.entity.annotations.Table;
|
||||
import com.megatron.entity.bean.GenericEntity;
|
||||
import com.megatron.entity.meta.PKStrategy;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author liuyuanyuan
|
||||
* @Date 2022/5/6 0006 20:42
|
||||
* @Description:
|
||||
*/
|
||||
@Data
|
||||
@Table("ci_module_relation")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ModuleRelation extends GenericEntity {
|
||||
@PK(value = PKStrategy.AUTO)
|
||||
private Long id;
|
||||
@Column("source_id")
|
||||
private Long sourceId;
|
||||
@Column("source_type")
|
||||
private String sourceType;
|
||||
@Column("source_code")
|
||||
private String sourceCode;
|
||||
@Column("target_type")
|
||||
private String targetType;
|
||||
@Column("relation_id")
|
||||
private Long relationId;
|
||||
@Column("target_id")
|
||||
private Long targetId;
|
||||
@Column("target_code")
|
||||
private String targetCode;
|
||||
/**
|
||||
* @Description: 关联类型分组id
|
||||
*/
|
||||
@Column("relation_category_id")
|
||||
private Long relationCategoryId;
|
||||
|
||||
@Column("relation_category_code")
|
||||
private String relationCategoryCode;
|
||||
|
||||
@IgnoreAll
|
||||
private String relationName;
|
||||
@IgnoreAll
|
||||
private String relationCategoryName;
|
||||
/**
|
||||
* 关联类型code
|
||||
*/
|
||||
@IgnoreAll
|
||||
private String relationCode;
|
||||
|
||||
@IgnoreAll
|
||||
private Boolean isReversed = false;
|
||||
|
||||
@IgnoreAll
|
||||
private List<AutoRelationRuleItem> ruleItemList;
|
||||
|
||||
@IgnoreAll
|
||||
private List<ModuleRelation> cmdbModuleRelationList;
|
||||
|
||||
@IgnoreAll
|
||||
private String sourceName;
|
||||
|
||||
@IgnoreAll
|
||||
private String targetName;
|
||||
|
||||
@IgnoreAll
|
||||
private String relationReverseName;
|
||||
|
||||
@IgnoreAll
|
||||
private String rule;
|
||||
|
||||
@IgnoreAll
|
||||
private Long moduleId;
|
||||
|
||||
@IgnoreAll
|
||||
private String iconImage;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue