Commit d48a0fea by yuwei

项目初始化

parent 4b7521e7
...@@ -2,10 +2,6 @@ package cn.datax.common.core; ...@@ -2,10 +2,6 @@ package cn.datax.common.core;
public interface RedisConstant { public interface RedisConstant {
String FACTORY_SOURCE_KEY = "data:factory:sources";
String FACTORY_SET_KEY = "data:factory:sets";
String MARKET_API_KEY = "data:market:apis"; String MARKET_API_KEY = "data:market:apis";
String MARKET_API_MASK_KEY = "data:market:api:masks"; String MARKET_API_MASK_KEY = "data:market:api:masks";
...@@ -13,4 +9,12 @@ public interface RedisConstant { ...@@ -13,4 +9,12 @@ public interface RedisConstant {
String SYSTEM_DICT_KEY = "data:system:dicts"; String SYSTEM_DICT_KEY = "data:system:dicts";
String SYSTEM_CONFIG_KEY = "data:system:configs"; String SYSTEM_CONFIG_KEY = "data:system:configs";
String METADATA_SOURCE_KEY = "data:metadata:sources";
String METADATA_TABLE_KEY = "data:metadata:tables";
String METADATA_COLUMN_KEY = "data:metadata:columns";
String VISUAL_SET_KEY = "data:visual:sets";
} }
...@@ -24,10 +24,5 @@ ...@@ -24,10 +24,5 @@
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId> <artifactId>commons-pool2</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson</artifactId>
<version>${redisson.version}</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
package cn.datax.common.redis.config;
import cn.datax.common.redis.service.impl.RedissonLocker;
import cn.datax.common.redis.utils.LockUtil;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.redisson.config.SingleServerConfig;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
public class RedissonConfig {
@Value("${spring.redis.database}")
private int database;
@Value("${spring.redis.host}")
private String host;
@Value("${spring.redis.port}")
private String port;
@Value("${spring.redis.password}")
private String password;
/**
* RedissonClient,单机模式
*
* @return
*/
@Bean(destroyMethod = "shutdown")
public RedissonClient redissonClient() {
Config config = new Config();
SingleServerConfig singleServerConfig = config.useSingleServer();
singleServerConfig.setAddress("redis://" + host + ":" + port);
singleServerConfig.setDatabase(database);
if (password != null && !"".equals(password)) {
singleServerConfig.setPassword(password);
}
return Redisson.create(config);
}
@Bean
public RedissonLocker redissonLocker(RedissonClient redissonClient) {
RedissonLocker locker = new RedissonLocker(redissonClient);
// 设置LockUtil的锁处理对象
LockUtil.setLocker(locker);
return locker;
}
}
package cn.datax.common.redis.service;
import java.util.concurrent.TimeUnit;
/**
* 锁接口
*/
public interface Locker {
/**
* 获取锁,如果锁不可用,则当前线程处于休眠状态,直到获得锁为止。
*
* @param lockKey
*/
void lock(String lockKey);
/**
* 释放锁
*
* @param lockKey
*/
void unlock(String lockKey);
/**
* 获取锁,如果锁不可用,则当前线程处于休眠状态,直到获得锁为止。如果获取到锁后,执行结束后解锁或达到超时时间后会自动释放锁
*
* @param lockKey
* @param timeout
*/
void lock(String lockKey, int timeout);
/**
* 获取锁,如果锁不可用,则当前线程处于休眠状态,直到获得锁为止。如果获取到锁后,执行结束后解锁或达到超时时间后会自动释放锁
*
* @param lockKey
* @param unit
* @param timeout
*/
void lock(String lockKey, TimeUnit unit, int timeout);
/**
* 尝试获取锁,获取到立即返回true,未获取到立即返回false
*
* @param lockKey
* @return
*/
boolean tryLock(String lockKey);
/**
* 尝试获取锁,在等待时间内获取到锁则返回true,否则返回false,如果获取到锁,则要么执行完后程序释放锁,
* 要么在给定的超时时间leaseTime后释放锁
*
* @param lockKey
* @param waitTime
* @param leaseTime
* @param unit
* @return
*/
boolean tryLock(String lockKey, long waitTime, long leaseTime, TimeUnit unit) throws InterruptedException;
/**
* 锁是否被任意一个线程锁持有
*
* @param lockKey
* @return
*/
boolean isLocked(String lockKey);
}
package cn.datax.common.redis.service.impl;
import cn.datax.common.redis.service.Locker;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import java.util.concurrent.TimeUnit;
/**
* 基于Redisson的分布式锁
*/
public class RedissonLocker implements Locker {
private RedissonClient redissonClient;
public RedissonLocker(RedissonClient redissonClient) {
super();
this.redissonClient = redissonClient;
}
@Override
public void lock(String lockKey) {
RLock lock = redissonClient.getLock(lockKey);
lock.lock();
}
@Override
public void unlock(String lockKey) {
RLock lock = redissonClient.getLock(lockKey);
lock.unlock();
}
@Override
public void lock(String lockKey, int leaseTime) {
RLock lock = redissonClient.getLock(lockKey);
lock.lock(leaseTime, TimeUnit.SECONDS);
}
@Override
public void lock(String lockKey, TimeUnit unit, int timeout) {
RLock lock = redissonClient.getLock(lockKey);
lock.lock(timeout, unit);
}
public void setRedissonClient(RedissonClient redissonClient) {
this.redissonClient = redissonClient;
}
@Override
public boolean tryLock(String lockKey) {
RLock lock = redissonClient.getLock(lockKey);
return lock.tryLock();
}
@Override
public boolean tryLock(String lockKey, long waitTime, long leaseTime, TimeUnit unit) throws InterruptedException {
RLock lock = redissonClient.getLock(lockKey);
return lock.tryLock(waitTime, leaseTime, unit);
}
@Override
public boolean isLocked(String lockKey) {
RLock lock = redissonClient.getLock(lockKey);
return lock.isLocked();
}
}
package cn.datax.common.redis.utils;
import cn.datax.common.redis.service.Locker;
import java.util.concurrent.TimeUnit;
/**
* redis分布式锁工具类
*/
public final class LockUtil {
private static Locker locker;
/**
* 设置工具类使用的locker
*
* @param locker
*/
public static void setLocker(Locker locker) {
LockUtil.locker = locker;
}
/**
* 获取锁
*
* @param lockKey
*/
public static void lock(String lockKey) {
locker.lock(lockKey);
}
/**
* 释放锁
*
* @param lockKey
*/
public static void unlock(String lockKey) {
locker.unlock(lockKey);
}
/**
* 获取锁,超时释放
*
* @param lockKey
* @param timeout
*/
public static void lock(String lockKey, int timeout) {
locker.lock(lockKey, timeout);
}
/**
* 获取锁,超时释放,指定时间单位
*
* @param lockKey
* @param unit
* @param timeout
*/
public static void lock(String lockKey, TimeUnit unit, int timeout) {
locker.lock(lockKey, unit, timeout);
}
/**
* 尝试获取锁,获取到立即返回true,获取失败立即返回false
*
* @param lockKey
* @return
*/
public static boolean tryLock(String lockKey) {
return locker.tryLock(lockKey);
}
/**
* 尝试获取锁,在给定的waitTime时间内尝试,获取到返回true,获取失败返回false,获取到后再给定的leaseTime时间超时释放
*
* @param lockKey
* @param waitTime
* @param leaseTime
* @param unit
* @return
* @throws InterruptedException
*/
public static boolean tryLock(String lockKey, long waitTime, long leaseTime, TimeUnit unit) throws InterruptedException {
return locker.tryLock(lockKey, waitTime, leaseTime, unit);
}
/**
* 锁释放被任意一个线程持有
*
* @param lockKey
* @return
*/
public static boolean isLocked(String lockKey) {
return locker.isLocked(lockKey);
}
}
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
cn.datax.common.redis.config.RedisConfig,\ cn.datax.common.redis.config.RedisConfig,\
cn.datax.common.redis.config.RedissonConfig,\
cn.datax.common.redis.aspectj.RedisCacheAspect cn.datax.common.redis.aspectj.RedisCacheAspect
...@@ -50,6 +50,7 @@ security: ...@@ -50,6 +50,7 @@ security:
# Swagger界面内容配置 # Swagger界面内容配置
swagger: swagger:
enable: true
title: API接口文档 title: API接口文档
description: Api Documentation description: Api Documentation
version: 1.0.0 version: 1.0.0
......
...@@ -55,6 +55,7 @@ security: ...@@ -55,6 +55,7 @@ security:
# Swagger界面内容配置 # Swagger界面内容配置
swagger: swagger:
enable: true
title: API接口文档 title: API接口文档
description: Api Documentation description: Api Documentation
version: 1.0.0 version: 1.0.0
......
...@@ -50,6 +50,7 @@ security: ...@@ -50,6 +50,7 @@ security:
# Swagger界面内容配置 # Swagger界面内容配置
swagger: swagger:
enable: true
title: API接口文档 title: API接口文档
description: Api Documentation description: Api Documentation
version: 1.0.0 version: 1.0.0
......
...@@ -55,6 +55,7 @@ security: ...@@ -55,6 +55,7 @@ security:
# Swagger界面内容配置 # Swagger界面内容配置
swagger: swagger:
enable: true
title: API接口文档 title: API接口文档
description: Api Documentation description: Api Documentation
version: 1.0.0 version: 1.0.0
......
...@@ -50,6 +50,7 @@ security: ...@@ -50,6 +50,7 @@ security:
# Swagger界面内容配置 # Swagger界面内容配置
swagger: swagger:
enable: true
title: API接口文档 title: API接口文档
description: Api Documentation description: Api Documentation
version: 1.0.0 version: 1.0.0
......
...@@ -50,6 +50,7 @@ security: ...@@ -50,6 +50,7 @@ security:
# Swagger界面内容配置 # Swagger界面内容配置
swagger: swagger:
enable: true
title: API接口文档 title: API接口文档
description: Api Documentation description: Api Documentation
version: 1.0.0 version: 1.0.0
......
...@@ -62,6 +62,7 @@ security: ...@@ -62,6 +62,7 @@ security:
# Swagger界面内容配置 # Swagger界面内容配置
swagger: swagger:
enable: true
title: API接口文档 title: API接口文档
description: Api Documentation description: Api Documentation
version: 1.0.0 version: 1.0.0
......
...@@ -51,6 +51,7 @@ security: ...@@ -51,6 +51,7 @@ security:
# Swagger界面内容配置 # Swagger界面内容配置
swagger: swagger:
enable: true
title: API接口文档 title: API接口文档
description: Api Documentation description: Api Documentation
version: 1.0.0 version: 1.0.0
......
...@@ -82,6 +82,7 @@ security: ...@@ -82,6 +82,7 @@ security:
# Swagger界面内容配置 # Swagger界面内容配置
swagger: swagger:
enable: true
title: API接口文档 title: API接口文档
description: Api Documentation description: Api Documentation
version: 1.0.0 version: 1.0.0
......
...@@ -50,6 +50,7 @@ security: ...@@ -50,6 +50,7 @@ security:
# Swagger界面内容配置 # Swagger界面内容配置
swagger: swagger:
enable: true
title: API接口文档 title: API接口文档
description: Api Documentation description: Api Documentation
version: 1.0.0 version: 1.0.0
......
...@@ -23,19 +23,30 @@ ...@@ -23,19 +23,30 @@
<artifactId>spring-cloud-starter-gateway</artifactId> <artifactId>spring-cloud-starter-gateway</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-ui</artifactId>
<version>${knife4j.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId> <groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId> <artifactId>springfox-swagger2</artifactId>
<version>${swagger2.version}</version> <version>${springfox.version}</version>
<exclusions>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.springfox</groupId> <groupId>io.swagger</groupId>
<artifactId>springfox-bean-validators</artifactId> <artifactId>swagger-models</artifactId>
<version>${swagger2.version}</version> <version>${swagger.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.springfox</groupId> <groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId> <artifactId>springfox-bean-validators</artifactId>
<version>${swagger2.version}</version> <version>${springfox.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.datax</groupId> <groupId>cn.datax</groupId>
......
...@@ -15,7 +15,7 @@ import java.util.List; ...@@ -15,7 +15,7 @@ import java.util.List;
@Component @Component
@Primary @Primary
@AllArgsConstructor @AllArgsConstructor
public class SwaggerProvider implements SwaggerResourcesProvider { public class SwaggerResourceConfig implements SwaggerResourcesProvider {
public static final String API_URI = "/v2/api-docs"; public static final String API_URI = "/v2/api-docs";
private final RouteLocator routeLocator; private final RouteLocator routeLocator;
...@@ -33,7 +33,8 @@ public class SwaggerProvider implements SwaggerResourcesProvider { ...@@ -33,7 +33,8 @@ public class SwaggerProvider implements SwaggerResourcesProvider {
routeDefinition.getPredicates().stream() routeDefinition.getPredicates().stream()
.filter(predicateDefinition -> ("Path").equalsIgnoreCase(predicateDefinition.getName())) .filter(predicateDefinition -> ("Path").equalsIgnoreCase(predicateDefinition.getName()))
.filter(predicateDefinition -> !"datax-auth".equalsIgnoreCase(routeDefinition.getId()) || .filter(predicateDefinition -> !"datax-auth".equalsIgnoreCase(routeDefinition.getId()) ||
!"datax-service-data-api-call".equalsIgnoreCase(routeDefinition.getId())) !"datax-service-data-api-mapping".equalsIgnoreCase(routeDefinition.getId()) ||
!"datax-service-data-console".equalsIgnoreCase(routeDefinition.getId()))
.forEach(predicateDefinition -> resources.add(swaggerResource(routeDefinition.getId(), .forEach(predicateDefinition -> resources.add(swaggerResource(routeDefinition.getId(),
predicateDefinition.getArgs().get(NameUtils.GENERATED_NAME_PREFIX + "0") predicateDefinition.getArgs().get(NameUtils.GENERATED_NAME_PREFIX + "0")
.replace("/**", API_URI)))); .replace("/**", API_URI))));
......
package cn.datax.gateway.filter; package cn.datax.gateway.filter;
import cn.datax.gateway.config.SwaggerProvider;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.cloud.gateway.filter.GatewayFilter; import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory; import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
...@@ -10,17 +9,20 @@ import org.springframework.web.server.ServerWebExchange; ...@@ -10,17 +9,20 @@ import org.springframework.web.server.ServerWebExchange;
@Component @Component
public class SwaggerHeaderFilter extends AbstractGatewayFilterFactory { public class SwaggerHeaderFilter extends AbstractGatewayFilterFactory {
private static final String HEADER_NAME = "X-Forwarded-Prefix"; private static final String HEADER_NAME = "X-Forwarded-Prefix";
private static final String URI = "/v2/api-docs";
@Override @Override
public GatewayFilter apply(Object config) { public GatewayFilter apply(Object config) {
return (exchange, chain) -> { return (exchange, chain) -> {
ServerHttpRequest request = exchange.getRequest(); ServerHttpRequest request = exchange.getRequest();
String path = request.getURI().getPath(); String path = request.getURI().getPath();
if (!StringUtils.endsWithIgnoreCase(path, SwaggerProvider.API_URI)) { if (!StringUtils.endsWithIgnoreCase(path,URI )) {
return chain.filter(exchange); return chain.filter(exchange);
} }
String basePath = path.substring(0, path.lastIndexOf(SwaggerProvider.API_URI)); String basePath = path.substring(0, path.lastIndexOf(URI));
ServerHttpRequest newRequest = request.mutate().header(HEADER_NAME, basePath).build(); ServerHttpRequest newRequest = request.mutate().header(HEADER_NAME, basePath).build();
ServerWebExchange newExchange = exchange.mutate().request(newRequest).build(); ServerWebExchange newExchange = exchange.mutate().request(newRequest).build();
return chain.filter(newExchange); return chain.filter(newExchange);
......
...@@ -4,7 +4,6 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -4,7 +4,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
import springfox.documentation.swagger.web.*; import springfox.documentation.swagger.web.*;
...@@ -12,13 +11,14 @@ import springfox.documentation.swagger.web.*; ...@@ -12,13 +11,14 @@ import springfox.documentation.swagger.web.*;
import java.util.Optional; import java.util.Optional;
@RestController @RestController
@RequestMapping("/swagger-resources")
public class SwaggerHandler { public class SwaggerHandler {
@Autowired(required = false) @Autowired(required = false)
private SecurityConfiguration securityConfiguration; private SecurityConfiguration securityConfiguration;
@Autowired(required = false) @Autowired(required = false)
private UiConfiguration uiConfiguration; private UiConfiguration uiConfiguration;
private final SwaggerResourcesProvider swaggerResources; private final SwaggerResourcesProvider swaggerResources;
@Autowired @Autowired
...@@ -27,19 +27,19 @@ public class SwaggerHandler { ...@@ -27,19 +27,19 @@ public class SwaggerHandler {
} }
@GetMapping("/configuration/security") @GetMapping("/swagger-resources/configuration/security")
public Mono<ResponseEntity<SecurityConfiguration>> securityConfiguration() { public Mono<ResponseEntity<SecurityConfiguration>> securityConfiguration() {
return Mono.just(new ResponseEntity<>( return Mono.just(new ResponseEntity<>(
Optional.ofNullable(securityConfiguration).orElse(SecurityConfigurationBuilder.builder().build()), HttpStatus.OK)); Optional.ofNullable(securityConfiguration).orElse(SecurityConfigurationBuilder.builder().build()), HttpStatus.OK));
} }
@GetMapping("/configuration/ui") @GetMapping("/swagger-resources/configuration/ui")
public Mono<ResponseEntity<UiConfiguration>> uiConfiguration() { public Mono<ResponseEntity<UiConfiguration>> uiConfiguration() {
return Mono.just(new ResponseEntity<>( return Mono.just(new ResponseEntity<>(
Optional.ofNullable(uiConfiguration).orElse(UiConfigurationBuilder.builder().build()), HttpStatus.OK)); Optional.ofNullable(uiConfiguration).orElse(UiConfigurationBuilder.builder().build()), HttpStatus.OK));
} }
@GetMapping("") @GetMapping("/swagger-resources")
public Mono<ResponseEntity> swaggerResources() { public Mono<ResponseEntity> swaggerResources() {
return Mono.just((new ResponseEntity<>(swaggerResources.get(), HttpStatus.OK))); return Mono.just((new ResponseEntity<>(swaggerResources.get(), HttpStatus.OK)));
} }
......
...@@ -13,20 +13,25 @@ ...@@ -13,20 +13,25 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>io.springfox</groupId> <groupId>com.github.xiaoymin</groupId>
<artifactId>springfox-swagger2</artifactId> <artifactId>knife4j-micro-spring-boot-starter</artifactId>
<version>${swagger2.version}</version> <version>${knife4j.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-bean-validators</artifactId>
<version>${swagger2.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger2.version}</version>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-swagger2</artifactId>-->
<!-- <version>${swagger2.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-bean-validators</artifactId>-->
<!-- <version>${swagger2.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-swagger-ui</artifactId>-->
<!-- <version>${swagger2.version}</version>-->
<!-- </dependency>-->
<!--feign 依赖--> <!--feign 依赖-->
<dependency> <dependency>
<groupId>io.github.openfeign</groupId> <groupId>io.github.openfeign</groupId>
......
package cn.datax.service.codegen.config; package cn.datax.service.codegen.config;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
import springfox.documentation.builders.*; import springfox.documentation.builders.*;
import springfox.documentation.schema.ModelRef; import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.*; import springfox.documentation.service.*;
...@@ -20,6 +23,8 @@ import java.util.List; ...@@ -20,6 +23,8 @@ import java.util.List;
@ConditionalOnProperty(prefix = "swagger", name = "enable", havingValue = "true") @ConditionalOnProperty(prefix = "swagger", name = "enable", havingValue = "true")
@EnableConfigurationProperties(SwaggerProperties.class) @EnableConfigurationProperties(SwaggerProperties.class)
@EnableSwagger2 @EnableSwagger2
@EnableKnife4j
@Import(BeanValidatorPluginsConfiguration.class)
public class SwaggerConfig { public class SwaggerConfig {
@Autowired @Autowired
......
package cn.datax.service.data.market.api.mapping.config; package cn.datax.service.data.market.api.mapping.config;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
import springfox.documentation.builders.*; import springfox.documentation.builders.*;
import springfox.documentation.schema.ModelRef; import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.*; import springfox.documentation.service.*;
...@@ -20,6 +23,8 @@ import java.util.List; ...@@ -20,6 +23,8 @@ import java.util.List;
@ConditionalOnProperty(prefix = "swagger", name = "enable", havingValue = "true") @ConditionalOnProperty(prefix = "swagger", name = "enable", havingValue = "true")
@EnableConfigurationProperties(SwaggerProperties.class) @EnableConfigurationProperties(SwaggerProperties.class)
@EnableSwagger2 @EnableSwagger2
@EnableKnife4j
@Import(BeanValidatorPluginsConfiguration.class)
public class SwaggerConfig { public class SwaggerConfig {
@Autowired @Autowired
......
...@@ -13,20 +13,25 @@ ...@@ -13,20 +13,25 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>io.springfox</groupId> <groupId>com.github.xiaoymin</groupId>
<artifactId>springfox-swagger2</artifactId> <artifactId>knife4j-micro-spring-boot-starter</artifactId>
<version>${swagger2.version}</version> <version>${knife4j.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-bean-validators</artifactId>
<version>${swagger2.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger2.version}</version>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-swagger2</artifactId>-->
<!-- <version>${swagger2.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-bean-validators</artifactId>-->
<!-- <version>${swagger2.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-swagger-ui</artifactId>-->
<!-- <version>${swagger2.version}</version>-->
<!-- </dependency>-->
<!--feign 依赖--> <!--feign 依赖-->
<dependency> <dependency>
<groupId>io.github.openfeign</groupId> <groupId>io.github.openfeign</groupId>
......
package cn.datax.service.data.market.config; package cn.datax.service.data.market.config;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
import springfox.documentation.builders.*; import springfox.documentation.builders.*;
import springfox.documentation.schema.ModelRef; import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.*; import springfox.documentation.service.*;
...@@ -20,6 +23,8 @@ import java.util.List; ...@@ -20,6 +23,8 @@ import java.util.List;
@ConditionalOnProperty(prefix = "swagger", name = "enable", havingValue = "true") @ConditionalOnProperty(prefix = "swagger", name = "enable", havingValue = "true")
@EnableConfigurationProperties(SwaggerProperties.class) @EnableConfigurationProperties(SwaggerProperties.class)
@EnableSwagger2 @EnableSwagger2
@EnableKnife4j
@Import(BeanValidatorPluginsConfiguration.class)
public class SwaggerConfig { public class SwaggerConfig {
@Autowired @Autowired
......
...@@ -13,20 +13,25 @@ ...@@ -13,20 +13,25 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>io.springfox</groupId> <groupId>com.github.xiaoymin</groupId>
<artifactId>springfox-swagger2</artifactId> <artifactId>knife4j-micro-spring-boot-starter</artifactId>
<version>${swagger2.version}</version> <version>${knife4j.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-bean-validators</artifactId>
<version>${swagger2.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger2.version}</version>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-swagger2</artifactId>-->
<!-- <version>${swagger2.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-bean-validators</artifactId>-->
<!-- <version>${swagger2.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-swagger-ui</artifactId>-->
<!-- <version>${swagger2.version}</version>-->
<!-- </dependency>-->
<!--feign 依赖--> <!--feign 依赖-->
<dependency> <dependency>
<groupId>io.github.openfeign</groupId> <groupId>io.github.openfeign</groupId>
......
package cn.datax.service.data.metadata.api.enums;
public enum DataLevel {
DATABASE("database", 1),
TABLE("table", 2),
COLUMN("column", 3);
private final String key;
private final Integer level;
DataLevel(String key, Integer level) {
this.key = key;
this.level = level;
}
public String getKey() {
return key;
}
public Integer getLevel() {
return level;
}
public static DataLevel getLevel(String key) {
for (DataLevel type : DataLevel.values()) {
if (type.key.equals(key)) {
return type;
}
}
return DATABASE;
}
}
...@@ -12,7 +12,7 @@ public class MetadataTreeVo implements Serializable { ...@@ -12,7 +12,7 @@ public class MetadataTreeVo implements Serializable {
private String id; private String id;
/** /**
* 数据类型 database、table、column * 数据层级 database、table、column
*/ */
private String type; private String type;
private String label; private String label;
......
package cn.datax.service.data.metadata.console.config; package cn.datax.service.data.metadata.console.config;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
import springfox.documentation.builders.*; import springfox.documentation.builders.*;
import springfox.documentation.schema.ModelRef; import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.*; import springfox.documentation.service.*;
...@@ -20,6 +23,8 @@ import java.util.List; ...@@ -20,6 +23,8 @@ import java.util.List;
@ConditionalOnProperty(prefix = "swagger", name = "enable", havingValue = "true") @ConditionalOnProperty(prefix = "swagger", name = "enable", havingValue = "true")
@EnableConfigurationProperties(SwaggerProperties.class) @EnableConfigurationProperties(SwaggerProperties.class)
@EnableSwagger2 @EnableSwagger2
@EnableKnife4j
@Import(BeanValidatorPluginsConfiguration.class)
public class SwaggerConfig { public class SwaggerConfig {
@Autowired @Autowired
......
package cn.datax.service.data.metadata.config; package cn.datax.service.data.metadata.config;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
import springfox.documentation.builders.*; import springfox.documentation.builders.*;
import springfox.documentation.schema.ModelRef; import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.*; import springfox.documentation.service.*;
...@@ -20,6 +23,8 @@ import java.util.List; ...@@ -20,6 +23,8 @@ import java.util.List;
@ConditionalOnProperty(prefix = "swagger", name = "enable", havingValue = "true") @ConditionalOnProperty(prefix = "swagger", name = "enable", havingValue = "true")
@EnableConfigurationProperties(SwaggerProperties.class) @EnableConfigurationProperties(SwaggerProperties.class)
@EnableSwagger2 @EnableSwagger2
@EnableKnife4j
@Import(BeanValidatorPluginsConfiguration.class)
public class SwaggerConfig { public class SwaggerConfig {
@Autowired @Autowired
......
...@@ -150,12 +150,15 @@ public class MetadataColumnController extends BaseController { ...@@ -150,12 +150,15 @@ public class MetadataColumnController extends BaseController {
} }
/** /**
* 获取结构树 * 获取层级树
* @param level 层级database、table、column
* @return * @return
*/ */
@GetMapping("/tree") @ApiOperation(value = "获取层级树", notes = "根据url的层级来获取树对象")
public R getDataMetadataTree() { @ApiImplicitParam(name = "level", value = "层级", required = true, dataType = "String", paramType = "path")
List<MetadataTreeVo> list = metadataColumnService.getDataMetadataTree(); @GetMapping("/tree/{level}")
public R getDataMetadataTree(@PathVariable String level) {
List<MetadataTreeVo> list = metadataColumnService.getDataMetadataTree(level);
return R.ok().setData(list); return R.ok().setData(list);
} }
} }
...@@ -27,5 +27,5 @@ public interface MetadataColumnService extends BaseService<MetadataColumnEntity> ...@@ -27,5 +27,5 @@ public interface MetadataColumnService extends BaseService<MetadataColumnEntity>
void deleteMetadataColumnBatch(List<String> ids); void deleteMetadataColumnBatch(List<String> ids);
List<MetadataTreeVo> getDataMetadataTree(); List<MetadataTreeVo> getDataMetadataTree(String level);
} }
...@@ -4,6 +4,8 @@ import cn.datax.common.core.DataConstant; ...@@ -4,6 +4,8 @@ import cn.datax.common.core.DataConstant;
import cn.datax.service.data.metadata.api.dto.MetadataColumnDto; import cn.datax.service.data.metadata.api.dto.MetadataColumnDto;
import cn.datax.service.data.metadata.api.entity.MetadataColumnEntity; import cn.datax.service.data.metadata.api.entity.MetadataColumnEntity;
import cn.datax.service.data.metadata.api.entity.MetadataSourceEntity; import cn.datax.service.data.metadata.api.entity.MetadataSourceEntity;
import cn.datax.service.data.metadata.api.entity.MetadataTableEntity;
import cn.datax.service.data.metadata.api.enums.DataLevel;
import cn.datax.service.data.metadata.api.vo.MetadataTreeVo; import cn.datax.service.data.metadata.api.vo.MetadataTreeVo;
import cn.datax.service.data.metadata.dao.MetadataSourceDao; import cn.datax.service.data.metadata.dao.MetadataSourceDao;
import cn.datax.service.data.metadata.dao.MetadataTableDao; import cn.datax.service.data.metadata.dao.MetadataTableDao;
...@@ -11,9 +13,7 @@ import cn.datax.service.data.metadata.service.MetadataColumnService; ...@@ -11,9 +13,7 @@ import cn.datax.service.data.metadata.service.MetadataColumnService;
import cn.datax.service.data.metadata.mapstruct.MetadataColumnMapper; import cn.datax.service.data.metadata.mapstruct.MetadataColumnMapper;
import cn.datax.service.data.metadata.dao.MetadataColumnDao; import cn.datax.service.data.metadata.dao.MetadataColumnDao;
import cn.datax.common.base.BaseServiceImpl; import cn.datax.common.base.BaseServiceImpl;
import cn.datax.service.system.api.entity.UserRoleEntity; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -21,6 +21,8 @@ import org.springframework.transaction.annotation.Propagation; ...@@ -21,6 +21,8 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/** /**
* <p> * <p>
...@@ -81,14 +83,48 @@ public class MetadataColumnServiceImpl extends BaseServiceImpl<MetadataColumnDao ...@@ -81,14 +83,48 @@ public class MetadataColumnServiceImpl extends BaseServiceImpl<MetadataColumnDao
} }
@Override @Override
public List<MetadataTreeVo> getDataMetadataTree() { public List<MetadataTreeVo> getDataMetadataTree(String level) {
// 参考分布式锁
// https://blog.csdn.net/qq_32099833/article/details/103848016
// metadataSourceDao.selectList(Wrappers.<MetadataSourceEntity>lambdaQuery()
// .eq(MetadataSourceEntity::getStatus, DataConstant.EnableState.ENABLE.getKey()));
List<MetadataSourceEntity> sourceList = metadataSourceDao.selectList(Wrappers.emptyWrapper()); List<MetadataSourceEntity> sourceList = metadataSourceDao.selectList(Wrappers.emptyWrapper());
// 参考递归 List<MetadataTableEntity> tableList = metadataTableDao.selectList(Wrappers.emptyWrapper());
// https://blog.csdn.net/qq_19244927/article/details/106481777 List<MetadataColumnEntity> columnList = metadataColumnDao.selectList(Wrappers.emptyWrapper());
return null; List<MetadataTreeVo> list = sourceList.stream().filter(s -> DataConstant.EnableState.ENABLE.getKey().equals(s.getStatus()))
.map(m -> {
MetadataTreeVo tree = new MetadataTreeVo();
tree.setId(m.getId());
tree.setType(DataLevel.DATABASE.getKey());
tree.setLabel(m.getSourceName());
if (DataLevel.getLevel(level).getLevel() >= DataLevel.TABLE.getLevel()) {
tree.setChildren(getTableChildrens(m.getId(), level, tableList, columnList));
}
return tree;
}).collect(Collectors.toList());
return list;
}
private List<MetadataTreeVo> getTableChildrens(String id, String level, List<MetadataTableEntity> tableList, List<MetadataColumnEntity> columnList) {
List<MetadataTreeVo> children = tableList.stream().filter(m -> Objects.equals(id, m.getSourceId()))
.map(m -> {
MetadataTreeVo tree = new MetadataTreeVo();
tree.setId(m.getId());
tree.setType(DataLevel.TABLE.getKey());
tree.setLabel(StrUtil.isBlank(m.getTableComment()) ? m.getTableName() : m.getTableComment());
if (DataLevel.getLevel(level).getLevel() >= DataLevel.COLUMN.getLevel()) {
tree.setChildren(getColumnChildrens(m.getId(), columnList));
}
return tree;
}).collect(Collectors.toList());
return children;
}
private List<MetadataTreeVo> getColumnChildrens(String id, List<MetadataColumnEntity> columnList) {
List<MetadataTreeVo> children = columnList.stream().filter(m -> Objects.equals(id, m.getTableId()))
.map(m -> {
MetadataTreeVo tree = new MetadataTreeVo();
tree.setId(m.getId());
tree.setType(DataLevel.TABLE.getKey());
tree.setLabel(StrUtil.isBlank(m.getColumnComment()) ? m.getColumnName() : m.getColumnComment());
return tree;
}).collect(Collectors.toList());
return children;
} }
} }
...@@ -13,20 +13,25 @@ ...@@ -13,20 +13,25 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>io.springfox</groupId> <groupId>com.github.xiaoymin</groupId>
<artifactId>springfox-swagger2</artifactId> <artifactId>knife4j-micro-spring-boot-starter</artifactId>
<version>${swagger2.version}</version> <version>${knife4j.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-bean-validators</artifactId>
<version>${swagger2.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger2.version}</version>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-swagger2</artifactId>-->
<!-- <version>${swagger2.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-bean-validators</artifactId>-->
<!-- <version>${swagger2.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-swagger-ui</artifactId>-->
<!-- <version>${swagger2.version}</version>-->
<!-- </dependency>-->
<!--feign 依赖--> <!--feign 依赖-->
<dependency> <dependency>
<groupId>io.github.openfeign</groupId> <groupId>io.github.openfeign</groupId>
......
package cn.datax.service.data.visual.config; package cn.datax.service.data.visual.config;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
import springfox.documentation.builders.*; import springfox.documentation.builders.*;
import springfox.documentation.schema.ModelRef; import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.*; import springfox.documentation.service.*;
...@@ -20,6 +23,8 @@ import java.util.List; ...@@ -20,6 +23,8 @@ import java.util.List;
@ConditionalOnProperty(prefix = "swagger", name = "enable", havingValue = "true") @ConditionalOnProperty(prefix = "swagger", name = "enable", havingValue = "true")
@EnableConfigurationProperties(SwaggerProperties.class) @EnableConfigurationProperties(SwaggerProperties.class)
@EnableSwagger2 @EnableSwagger2
@EnableKnife4j
@Import(BeanValidatorPluginsConfiguration.class)
public class SwaggerConfig { public class SwaggerConfig {
@Autowired @Autowired
......
...@@ -13,20 +13,25 @@ ...@@ -13,20 +13,25 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>io.springfox</groupId> <groupId>com.github.xiaoymin</groupId>
<artifactId>springfox-swagger2</artifactId> <artifactId>knife4j-micro-spring-boot-starter</artifactId>
<version>${swagger2.version}</version> <version>${knife4j.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-bean-validators</artifactId>
<version>${swagger2.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger2.version}</version>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-swagger2</artifactId>-->
<!-- <version>${swagger2.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-bean-validators</artifactId>-->
<!-- <version>${swagger2.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-swagger-ui</artifactId>-->
<!-- <version>${swagger2.version}</version>-->
<!-- </dependency>-->
<!--feign 依赖--> <!--feign 依赖-->
<dependency> <dependency>
<groupId>io.github.openfeign</groupId> <groupId>io.github.openfeign</groupId>
......
package cn.datax.service.email.config; package cn.datax.service.email.config;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
import springfox.documentation.builders.*; import springfox.documentation.builders.*;
import springfox.documentation.schema.ModelRef; import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.*; import springfox.documentation.service.*;
...@@ -20,6 +23,8 @@ import java.util.List; ...@@ -20,6 +23,8 @@ import java.util.List;
@ConditionalOnProperty(prefix = "swagger", name = "enable", havingValue = "true") @ConditionalOnProperty(prefix = "swagger", name = "enable", havingValue = "true")
@EnableConfigurationProperties(SwaggerProperties.class) @EnableConfigurationProperties(SwaggerProperties.class)
@EnableSwagger2 @EnableSwagger2
@EnableKnife4j
@Import(BeanValidatorPluginsConfiguration.class)
public class SwaggerConfig { public class SwaggerConfig {
@Autowired @Autowired
......
...@@ -13,20 +13,25 @@ ...@@ -13,20 +13,25 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>io.springfox</groupId> <groupId>com.github.xiaoymin</groupId>
<artifactId>springfox-swagger2</artifactId> <artifactId>knife4j-micro-spring-boot-starter</artifactId>
<version>${swagger2.version}</version> <version>${knife4j.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-bean-validators</artifactId>
<version>${swagger2.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger2.version}</version>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-swagger2</artifactId>-->
<!-- <version>${swagger2.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-bean-validators</artifactId>-->
<!-- <version>${swagger2.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-swagger-ui</artifactId>-->
<!-- <version>${swagger2.version}</version>-->
<!-- </dependency>-->
<!--feign 依赖--> <!--feign 依赖-->
<dependency> <dependency>
<groupId>io.github.openfeign</groupId> <groupId>io.github.openfeign</groupId>
......
package cn.datax.service.file.config; package cn.datax.service.file.config;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
import springfox.documentation.builders.*; import springfox.documentation.builders.*;
import springfox.documentation.schema.ModelRef; import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.*; import springfox.documentation.service.*;
...@@ -20,6 +23,8 @@ import java.util.List; ...@@ -20,6 +23,8 @@ import java.util.List;
@ConditionalOnProperty(prefix = "swagger", name = "enable", havingValue = "true") @ConditionalOnProperty(prefix = "swagger", name = "enable", havingValue = "true")
@EnableConfigurationProperties(SwaggerProperties.class) @EnableConfigurationProperties(SwaggerProperties.class)
@EnableSwagger2 @EnableSwagger2
@EnableKnife4j
@Import(BeanValidatorPluginsConfiguration.class)
public class SwaggerConfig { public class SwaggerConfig {
@Autowired @Autowired
......
...@@ -13,20 +13,25 @@ ...@@ -13,20 +13,25 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>io.springfox</groupId> <groupId>com.github.xiaoymin</groupId>
<artifactId>springfox-swagger2</artifactId> <artifactId>knife4j-micro-spring-boot-starter</artifactId>
<version>${swagger2.version}</version> <version>${knife4j.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-bean-validators</artifactId>
<version>${swagger2.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger2.version}</version>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-swagger2</artifactId>-->
<!-- <version>${swagger2.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-bean-validators</artifactId>-->
<!-- <version>${swagger2.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-swagger-ui</artifactId>-->
<!-- <version>${swagger2.version}</version>-->
<!-- </dependency>-->
<!--feign 依赖--> <!--feign 依赖-->
<dependency> <dependency>
<groupId>io.github.openfeign</groupId> <groupId>io.github.openfeign</groupId>
......
package cn.datax.service.quartz.config; package cn.datax.service.quartz.config;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
import springfox.documentation.builders.*; import springfox.documentation.builders.*;
import springfox.documentation.schema.ModelRef; import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.*; import springfox.documentation.service.*;
...@@ -20,6 +23,8 @@ import java.util.List; ...@@ -20,6 +23,8 @@ import java.util.List;
@ConditionalOnProperty(prefix = "swagger", name = "enable", havingValue = "true") @ConditionalOnProperty(prefix = "swagger", name = "enable", havingValue = "true")
@EnableConfigurationProperties(SwaggerProperties.class) @EnableConfigurationProperties(SwaggerProperties.class)
@EnableSwagger2 @EnableSwagger2
@EnableKnife4j
@Import(BeanValidatorPluginsConfiguration.class)
public class SwaggerConfig { public class SwaggerConfig {
@Autowired @Autowired
......
...@@ -13,20 +13,25 @@ ...@@ -13,20 +13,25 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>io.springfox</groupId> <groupId>com.github.xiaoymin</groupId>
<artifactId>springfox-swagger2</artifactId> <artifactId>knife4j-micro-spring-boot-starter</artifactId>
<version>${swagger2.version}</version> <version>${knife4j.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-bean-validators</artifactId>
<version>${swagger2.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger2.version}</version>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-swagger2</artifactId>-->
<!-- <version>${swagger2.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-bean-validators</artifactId>-->
<!-- <version>${swagger2.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.springfox</groupId>-->
<!-- <artifactId>springfox-swagger-ui</artifactId>-->
<!-- <version>${swagger2.version}</version>-->
<!-- </dependency>-->
<!--feign 依赖--> <!--feign 依赖-->
<dependency> <dependency>
<groupId>io.github.openfeign</groupId> <groupId>io.github.openfeign</groupId>
......
package cn.datax.service.system.config; package cn.datax.service.system.config;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
import springfox.documentation.builders.*; import springfox.documentation.builders.*;
import springfox.documentation.schema.ModelRef; import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.*; import springfox.documentation.service.*;
...@@ -20,6 +23,8 @@ import java.util.List; ...@@ -20,6 +23,8 @@ import java.util.List;
@ConditionalOnProperty(prefix = "swagger", name = "enable", havingValue = "true") @ConditionalOnProperty(prefix = "swagger", name = "enable", havingValue = "true")
@EnableConfigurationProperties(SwaggerProperties.class) @EnableConfigurationProperties(SwaggerProperties.class)
@EnableSwagger2 @EnableSwagger2
@EnableKnife4j
@Import(BeanValidatorPluginsConfiguration.class)
public class SwaggerConfig { public class SwaggerConfig {
@Autowired @Autowired
......
...@@ -52,3 +52,10 @@ export function updateDataColumn (data) { ...@@ -52,3 +52,10 @@ export function updateDataColumn (data) {
data: data data: data
}) })
} }
export function getDataMetadataTree (level) {
return request({
url: '/data/metadata/columns/tree/' + level,
method: 'get'
})
}
...@@ -9,23 +9,21 @@ ...@@ -9,23 +9,21 @@
</el-button-group> </el-button-group>
</div> </div>
<div :style="classCardbody"> <div :style="classCardbody">
<el-steps :active="active" finish-status="success" align-center> <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-step title="数据源信息"></el-step> <el-form-item label="源数据表主键" prop="objectId">
<el-step title="连接信息"></el-step> <el-input v-model="form.objectId" placeholder="请输入源数据表主键" />
</el-steps>
<el-form ref="form" :model="form" :rules="rules" label-width="80px" v-if="active == 1">
<el-form-item label="数据源类型" prop="dbType">
<el-select v-model="form.dbType">
<el-option
v-for="item in dbTypeOptions"
:key="item.id"
:label="item.itemValue"
:value="item.itemText"
></el-option>
</el-select>
</el-form-item> </el-form-item>
<el-form-item label="数据源名称" prop="sourceName"> <el-form-item label="源数据表的字段名" prop="fieldName">
<el-input v-model="form.sourceName" placeholder="请输入数据源名称" /> <el-input v-model="form.fieldName" placeholder="请输入源数据表的字段名" />
</el-form-item>
<el-form-item label="原来的值" prop="fieldOldValue">
<el-input v-model="form.fieldOldValue" placeholder="请输入原来的值" />
</el-form-item>
<el-form-item label="最新的值" prop="fieldNewValue">
<el-input v-model="form.fieldNewValue" placeholder="请输入最新的值" />
</el-form-item>
<el-form-item label="版本号" prop="version">
<el-input v-model="form.version" placeholder="请输入版本号" />
</el-form-item> </el-form-item>
<el-form-item label="状态" prop="status"> <el-form-item label="状态" prop="status">
<el-radio-group v-model="form.status"> <el-radio-group v-model="form.status">
...@@ -40,38 +38,13 @@ ...@@ -40,38 +38,13 @@
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" /> <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-form ref="form2" :model="form2" :rules="rules2" label-width="80px" v-if="active == 2">
<el-form-item label="主机" prop="host">
<el-input v-model="form2.host" placeholder="请输入主机" />
</el-form-item>
<el-form-item label="端口" prop="port">
<el-input v-model="form2.port" placeholder="请输入端口" />
</el-form-item>
<el-form-item label="服务名" prop="sid" v-if="form.dbType === '3' || form.dbType === '4'">
<el-input v-model="form2.sid" placeholder="请输入服务名" />
</el-form-item>
<el-form-item label="数据库" prop="dbName" v-if="form.dbType !== '3' && form.dbType !== '4'">
<el-input v-model="form2.dbName" placeholder="请输入数据库" />
</el-form-item>
<el-form-item label="用户名" prop="username">
<el-input v-model="form2.username" placeholder="请输入用户名" />
</el-form-item>
<el-form-item label="密码" prop="password">
<el-input v-model="form2.password" placeholder="请输入密码" />
</el-form-item>
<el-form-item>
<el-button size="mini" type="primary" @click="handleCheckConnection">连通性检测</el-button>
</el-form-item>
</el-form>
<el-button style="margin-top: 12px;" @click="handleNextStep" v-if="active == 1">下一步</el-button>
<el-button style="margin-top: 12px;" @click="handleLastStep" v-if="active == 2">上一步</el-button>
</div> </div>
</el-card> </el-card>
</div> </div>
</template> </template>
<script> <script>
import { addDataSource, checkConnection } from '@/api/metadata/datasource' import { addChangeRecord } from '@/api/metadata/changerecord'
export default { export default {
name: 'ChangeRecordAdd', name: 'ChangeRecordAdd',
...@@ -104,58 +77,30 @@ export default { ...@@ -104,58 +77,30 @@ export default {
loadingText: '保存', loadingText: '保存',
isDisabled: false isDisabled: false
}, },
active: 1,
// 表单参数 // 表单参数
form: { form: {
id: undefined, status: '1'
dbType: undefined,
themeId: undefined,
sourceName: undefined,
dbSchema: {},
status: '1',
remark: undefined
}, },
// 表单校验 // 表单校验
rules: { rules: {
dbType: [ objectId: [
{ required: true, message: '数据源类型不能为空', trigger: 'change' } { required: true, message: '源数据表主键不能为空', trigger: 'blur' }
],
sourceName: [
{ required: true, message: '数据源名称不能为空', trigger: 'blur' }
]
},
form2: {
host: undefined,
port: undefined,
dbName: undefined,
username: undefined,
password: undefined,
sid: undefined
},
rules2: {
host: [
{ required: true, message: '主机不能为空', trigger: 'blur' }
], ],
port: [ fieldName: [
{ required: true, message: '端口不能为空', trigger: 'blur' } { required: true, message: '数据表的字段名不能为空', trigger: 'blur' }
], ],
sid: [ fieldOldValue: [
{ required: true, message: '服务名不能为空', trigger: 'blur' } { required: true, message: '原来的值不能为空', trigger: 'blur' }
], ],
dbName: [ fieldNewValue: [
{ required: true, message: '数据库不能为空', trigger: 'blur' } { required: true, message: '最新的值不能为空', trigger: 'blur' }
], ],
username: [ version: [
{ required: true, message: '用户名不能为空', trigger: 'blur' } { required: true, message: '版本号不能为空', trigger: 'blur' }
],
password: [
{ required: true, message: '密码不能为空', trigger: 'blur' }
] ]
}, },
// 状态数据字典 // 状态数据字典
statusOptions: [], statusOptions: []
// 数据源类型数据字典
dbTypeOptions: []
} }
}, },
created () { created () {
...@@ -164,50 +109,19 @@ export default { ...@@ -164,50 +109,19 @@ export default {
this.statusOptions = response.data this.statusOptions = response.data
} }
}) })
this.getDicts('data_db_type').then(response => {
if (response.success) {
this.dbTypeOptions = response.data
}
})
}, },
methods: { methods: {
showCard () { showCard () {
this.$emit('showCard', this.showOptions) this.$emit('showCard', this.showOptions)
}, },
/** 步骤条下一步 */
handleNextStep () {
this.$refs['form'].validate(valid => {
if (valid) {
this.active++
}
})
},
/** 步骤条上一步 */
handleLastStep () {
this.active--
},
/** 检测数据库连通性 */
handleCheckConnection () {
this.$refs['form2'].validate(valid => {
if (valid) {
this.form.dbSchema = this.form2
checkConnection(this.form).then(response => {
if (response.success) {
this.$message.success('连接成功')
}
})
}
})
},
/** 提交按钮 */ /** 提交按钮 */
submitForm: function () { submitForm: function () {
this.$refs['form2'].validate(valid => { this.$refs['form'].validate(valid => {
if (valid) { if (valid) {
this.form.dbSchema = this.form2
this.loadingOptions.loading = true this.loadingOptions.loading = true
this.loadingOptions.loadingText = '保存中...' this.loadingOptions.loadingText = '保存中...'
this.loadingOptions.isDisabled = true this.loadingOptions.isDisabled = true
addDataSource(this.form).then(response => { addChangeRecord(this.form).then(response => {
if (response.success) { if (response.success) {
this.$message.success('保存成功') this.$message.success('保存成功')
setTimeout(() => { setTimeout(() => {
......
...@@ -4,30 +4,25 @@ ...@@ -4,30 +4,25 @@
<div slot="header" class="clearfix"> <div slot="header" class="clearfix">
<span>{{ title }}</span> <span>{{ title }}</span>
<el-button-group style="float: right;"> <el-button-group style="float: right;">
<el-button size="mini" icon="el-icon-coin" type="primary" round @click="handleSync">元数据同步</el-button>
<el-button size="mini" icon="el-icon-coin" type="primary" round @click="handleWord">数据库文档</el-button>
<el-button size="mini" icon="el-icon-coin" type="primary" round @click="handleCheckConnection" v-if="active == 2">连通性检测</el-button>
<el-button size="mini" icon="el-icon-back" round @click="showCard">返回</el-button> <el-button size="mini" icon="el-icon-back" round @click="showCard">返回</el-button>
</el-button-group> </el-button-group>
</div> </div>
<div :style="classCardbody"> <div :style="classCardbody">
<el-steps :active="active" finish-status="success" align-center> <el-form ref="form" :model="form" label-width="80px" disabled>
<el-step title="数据源信息"></el-step> <el-form-item label="源数据表主键" prop="objectId">
<el-step title="连接信息"></el-step> <el-input v-model="form.objectId" />
</el-steps>
<el-form ref="form" :model="form" label-width="80px" v-if="active == 1" disabled>
<el-form-item label="数据源类型" prop="dbType">
<el-select v-model="form.dbType">
<el-option
v-for="item in dbTypeOptions"
:key="item.id"
:label="item.itemValue"
:value="item.itemText"
></el-option>
</el-select>
</el-form-item> </el-form-item>
<el-form-item label="数据源名称" prop="sourceName"> <el-form-item label="源数据表的字段名" prop="fieldName">
<el-input v-model="form.sourceName" placeholder="请输入数据源名称" /> <el-input v-model="form.fieldName" />
</el-form-item>
<el-form-item label="原来的值" prop="fieldOldValue">
<el-input v-model="form.fieldOldValue" />
</el-form-item>
<el-form-item label="最新的值" prop="fieldNewValue">
<el-input v-model="form.fieldNewValue" />
</el-form-item>
<el-form-item label="版本号" prop="version">
<el-input v-model="form.version" />
</el-form-item> </el-form-item>
<el-form-item label="状态" prop="status"> <el-form-item label="状态" prop="status">
<el-radio-group v-model="form.status"> <el-radio-group v-model="form.status">
...@@ -39,38 +34,16 @@ ...@@ -39,38 +34,16 @@
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item label="备注" prop="remark"> <el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" /> <el-input v-model="form.remark" type="textarea" />
</el-form-item>
</el-form>
<el-form ref="form2" :model="form2" label-width="80px" v-if="active == 2" disabled>
<el-form-item label="主机" prop="host">
<el-input v-model="form2.host" placeholder="请输入主机" />
</el-form-item>
<el-form-item label="端口" prop="port">
<el-input v-model="form2.port" placeholder="请输入端口" />
</el-form-item>
<el-form-item label="服务名" prop="sid" v-if="form.dbType === '3' || form.dbType === '4'">
<el-input v-model="form2.sid" placeholder="请输入服务名" />
</el-form-item>
<el-form-item label="数据库" prop="dbName" v-if="form.dbType !== '3' || form.dbType !== '4'">
<el-input v-model="form2.dbName" placeholder="请输入数据库" />
</el-form-item>
<el-form-item label="用户名" prop="username">
<el-input v-model="form2.username" placeholder="请输入用户名" />
</el-form-item>
<el-form-item label="密码" prop="password">
<el-input v-model="form2.password" placeholder="请输入密码" />
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-button style="margin-top: 12px;" @click="handleNextStep" v-if="active == 1">下一步</el-button>
<el-button style="margin-top: 12px;" @click="handleLastStep" v-if="active == 2">上一步</el-button>
</div> </div>
</el-card> </el-card>
</div> </div>
</template> </template>
<script> <script>
import { getDataSource, checkConnection, sync, word } from '@/api/metadata/datasource' import { getChangeRecord } from '@/api/metadata/changerecord'
export default { export default {
name: 'ChangeRecordDetail', name: 'ChangeRecordDetail',
...@@ -97,14 +70,10 @@ export default { ...@@ -97,14 +70,10 @@ export default {
showEdit: false, showEdit: false,
showDetail: false showDetail: false
}, },
active: 1,
// 表单参数 // 表单参数
form: {}, form: {},
form2: {},
// 状态数据字典 // 状态数据字典
statusOptions: [], statusOptions: []
// 数据源类型数据字典
dbTypeOptions: []
} }
}, },
created () { created () {
...@@ -114,75 +83,19 @@ export default { ...@@ -114,75 +83,19 @@ export default {
this.statusOptions = response.data this.statusOptions = response.data
} }
}) })
this.getDicts('data_db_type').then(response => {
if (response.success) {
this.dbTypeOptions = response.data
}
})
}, },
mounted () { mounted () {
this.getDataSource(this.data.id) this.getChangeRecord(this.data.id)
}, },
methods: { methods: {
showCard () { showCard () {
this.$emit('showCard', this.showOptions) this.$emit('showCard', this.showOptions)
}, },
/** 获取详情 */ /** 获取详情 */
getDataSource: function (id) { getChangeRecord: function (id) {
getDataSource(id).then(response => { getChangeRecord(id).then(response => {
if (response.success) { if (response.success) {
this.form = response.data this.form = response.data
this.form2 = this.form.dbSchema
}
})
},
/** 步骤条下一步 */
handleNextStep () {
this.$refs['form'].validate(valid => {
if (valid) {
this.active++
}
})
},
/** 步骤条上一步 */
handleLastStep () {
this.active--
},
/** 检测数据库连通性 */
handleCheckConnection () {
checkConnection(this.form).then(response => {
if (response.success) {
this.$message.success('连接成功')
}
})
},
/** 元数据同步 */
handleSync () {
sync(this.data.id).then(response => {
if (response.success) {
this.$message.success('元数据正在后台同步中,请到元数据管理中查看结果')
}
})
},
/** 数据库文档 */
handleWord () {
word(this.data.id).then(response => {
const blob = new Blob([response])
const fileName = '数据库设计文档.doc'
if ('download' in document.createElement('a')) {
// 非IE下载
const elink = document.createElement('a')
elink.download = fileName
elink.style.display = 'none'
elink.href = URL.createObjectURL(blob)
document.body.appendChild(elink)
elink.click()
URL.revokeObjectURL(elink.href)
// 释放URL 对象
document.body.removeChild(elink)
} else {
// IE10+下载
navigator.msSaveBlob(blob, fileName)
} }
}) })
} }
......
...@@ -9,23 +9,21 @@ ...@@ -9,23 +9,21 @@
</el-button-group> </el-button-group>
</div> </div>
<div :style="classCardbody"> <div :style="classCardbody">
<el-steps :active="active" finish-status="success" align-center> <el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-step title="数据源信息"></el-step> <el-form-item label="源数据表主键" prop="objectId">
<el-step title="连接信息"></el-step> <el-input v-model="form.objectId" placeholder="请输入源数据表主键" />
</el-steps>
<el-form ref="form" :model="form" :rules="rules" label-width="80px" v-if="active == 1">
<el-form-item label="数据源类型" prop="dbType">
<el-select v-model="form.dbType">
<el-option
v-for="item in dbTypeOptions"
:key="item.id"
:label="item.itemValue"
:value="item.itemText"
></el-option>
</el-select>
</el-form-item> </el-form-item>
<el-form-item label="数据源名称" prop="sourceName"> <el-form-item label="源数据表的字段名" prop="fieldName">
<el-input v-model="form.sourceName" placeholder="请输入数据源名称" /> <el-input v-model="form.fieldName" placeholder="请输入源数据表的字段名" />
</el-form-item>
<el-form-item label="原来的值" prop="fieldOldValue">
<el-input v-model="form.fieldOldValue" placeholder="请输入原来的值" />
</el-form-item>
<el-form-item label="最新的值" prop="fieldNewValue">
<el-input v-model="form.fieldNewValue" placeholder="请输入最新的值" />
</el-form-item>
<el-form-item label="版本号" prop="version">
<el-input v-model="form.version" placeholder="请输入版本号" />
</el-form-item> </el-form-item>
<el-form-item label="状态" prop="status"> <el-form-item label="状态" prop="status">
<el-radio-group v-model="form.status"> <el-radio-group v-model="form.status">
...@@ -40,38 +38,13 @@ ...@@ -40,38 +38,13 @@
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" /> <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-form ref="form2" :model="form2" :rules="rules2" label-width="80px" v-if="active == 2">
<el-form-item label="主机" prop="host">
<el-input v-model="form2.host" placeholder="请输入主机" />
</el-form-item>
<el-form-item label="端口" prop="port">
<el-input v-model="form2.port" placeholder="请输入端口" />
</el-form-item>
<el-form-item label="服务名" prop="sid" v-if="form.dbType === '3' || form.dbType === '4'">
<el-input v-model="form2.sid" placeholder="请输入服务名" />
</el-form-item>
<el-form-item label="数据库" prop="dbName" v-if="form.dbType !== '3' && form.dbType !== '4'">
<el-input v-model="form2.dbName" placeholder="请输入数据库" />
</el-form-item>
<el-form-item label="用户名" prop="username">
<el-input v-model="form2.username" placeholder="请输入用户名" />
</el-form-item>
<el-form-item label="密码" prop="password">
<el-input v-model="form2.password" placeholder="请输入密码" />
</el-form-item>
<el-form-item>
<el-button size="mini" type="primary" @click="handleCheckConnection">连通性检测</el-button>
</el-form-item>
</el-form>
<el-button style="margin-top: 12px;" @click="handleNextStep" v-if="active == 1">下一步</el-button>
<el-button style="margin-top: 12px;" @click="handleLastStep" v-if="active == 2">上一步</el-button>
</div> </div>
</el-card> </el-card>
</div> </div>
</template> </template>
<script> <script>
import { getDataSource, updateDataSource, checkConnection } from '@/api/metadata/datasource' import { getChangeRecord, updateChangeRecord } from '@/api/metadata/changerecord'
export default { export default {
name: 'ChangeRecordEdit', name: 'ChangeRecordEdit',
...@@ -104,43 +77,28 @@ export default { ...@@ -104,43 +77,28 @@ export default {
loadingText: '保存', loadingText: '保存',
isDisabled: false isDisabled: false
}, },
active: 1,
// 表单参数 // 表单参数
form: {}, form: {},
// 表单校验 // 表单校验
rules: { rules: {
dbType: [ objectId: [
{ required: true, message: '数据源类型不能为空', trigger: 'change' } { required: true, message: '源数据表主键不能为空', trigger: 'blur' }
],
sourceName: [
{ required: true, message: '数据源名称不能为空', trigger: 'blur' }
]
},
form2: {},
rules2: {
host: [
{ required: true, message: '主机不能为空', trigger: 'blur' }
], ],
port: [ fieldName: [
{ required: true, message: '端口不能为空', trigger: 'blur' } { required: true, message: '数据表的字段名不能为空', trigger: 'blur' }
], ],
sid: [ fieldOldValue: [
{ required: true, message: '服务名不能为空', trigger: 'blur' } { required: true, message: '原来的值不能为空', trigger: 'blur' }
], ],
dbName: [ fieldNewValue: [
{ required: true, message: '数据库不能为空', trigger: 'blur' } { required: true, message: '最新的值不能为空', trigger: 'blur' }
], ],
username: [ version: [
{ required: true, message: '用户名不能为空', trigger: 'blur' } { required: true, message: '版本号不能为空', trigger: 'blur' }
],
password: [
{ required: true, message: '密码不能为空', trigger: 'blur' }
] ]
}, },
// 状态数据字典 // 状态数据字典
statusOptions: [], statusOptions: []
// 数据源类型数据字典
dbTypeOptions: []
} }
}, },
created () { created () {
...@@ -150,50 +108,19 @@ export default { ...@@ -150,50 +108,19 @@ export default {
this.statusOptions = response.data this.statusOptions = response.data
} }
}) })
this.getDicts('data_db_type').then(response => {
if (response.success) {
this.dbTypeOptions = response.data
}
})
}, },
mounted () { mounted () {
this.getDataSource(this.data.id) this.getChangeRecord(this.data.id)
}, },
methods: { methods: {
showCard () { showCard () {
this.$emit('showCard', this.showOptions) this.$emit('showCard', this.showOptions)
}, },
/** 获取详情 */ /** 获取详情 */
getDataSource: function (id) { getChangeRecord: function (id) {
getDataSource(id).then(response => { getChangeRecord(id).then(response => {
if (response.success) { if (response.success) {
this.form = response.data this.form = response.data
this.form2 = this.form.dbSchema
}
})
},
/** 步骤条下一步 */
handleNextStep () {
this.$refs['form'].validate(valid => {
if (valid) {
this.active++
}
})
},
/** 步骤条上一步 */
handleLastStep () {
this.active--
},
/** 检测数据库连通性 */
handleCheckConnection () {
this.$refs['form2'].validate(valid => {
if (valid) {
this.form.dbSchema = this.form2
checkConnection(this.form).then(response => {
if (response.success) {
this.$message.success('连接成功')
}
})
} }
}) })
}, },
...@@ -201,11 +128,10 @@ export default { ...@@ -201,11 +128,10 @@ export default {
submitForm: function () { submitForm: function () {
this.$refs['form2'].validate(valid => { this.$refs['form2'].validate(valid => {
if (valid) { if (valid) {
this.form.dbSchema = this.form2
this.loadingOptions.loading = true this.loadingOptions.loading = true
this.loadingOptions.loadingText = '保存中...' this.loadingOptions.loadingText = '保存中...'
this.loadingOptions.isDisabled = true this.loadingOptions.isDisabled = true
updateDataSource(this.form).then(response => { updateChangeRecord(this.form).then(response => {
if (response.success) { if (response.success) {
this.$message.success('保存成功') this.$message.success('保存成功')
setTimeout(() => { setTimeout(() => {
......
...@@ -2,10 +2,10 @@ ...@@ -2,10 +2,10 @@
<div> <div>
<el-card class="box-card" shadow="always"> <el-card class="box-card" shadow="always">
<el-form :model="queryParams" ref="queryForm" :inline="true"> <el-form :model="queryParams" ref="queryForm" :inline="true">
<el-form-item label="数据源名称" prop="sourceName"> <el-form-item label="字段名称" prop="fieldName">
<el-input <el-input
v-model="queryParams.sourceName" v-model="queryParams.fieldName"
placeholder="请输入数据源名称" placeholder="请输入字段名称"
clearable clearable
size="small" size="small"
@keyup.enter.native="handleQuery" @keyup.enter.native="handleQuery"
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
<el-table <el-table
v-loading="loading" v-loading="loading"
:data="dataSourceList" :data="changeRecordList"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
border border
tooltip-effect="dark" tooltip-effect="dark"
...@@ -158,7 +158,7 @@ ...@@ -158,7 +158,7 @@
</template> </template>
<script> <script>
import { pageDataSource, delDataSource, delDataSources } from '@/api/metadata/datasource' import { pageChangeRecord, delChangeRecord, delChangeRecords } from '@/api/metadata/changerecord'
export default { export default {
name: 'ChangeRecordList', name: 'ChangeRecordList',
...@@ -183,7 +183,11 @@ export default { ...@@ -183,7 +183,11 @@ export default {
multiple: true, multiple: true,
// 表格头 // 表格头
tableColumns: [ tableColumns: [
{ prop: 'sourceName', label: '数据源名称', show: true }, { prop: 'objectId', label: '源数据表主键', show: true },
{ prop: 'fieldName', label: '源数据表的字段名', show: true },
{ prop: 'fieldOldValue', label: '原来的值', show: true },
{ prop: 'fieldNewValue', label: '最新的值', show: true },
{ prop: 'version', label: '版本号', show: true },
{ {
prop: 'status', prop: 'status',
label: '状态', label: '状态',
...@@ -197,15 +201,15 @@ export default { ...@@ -197,15 +201,15 @@ export default {
tableSize: 'medium', tableSize: 'medium',
// 状态数据字典 // 状态数据字典
statusOptions: [], statusOptions: [],
// 数据源表格数据 // 表格数据
dataSourceList: [], changeRecordList: [],
// 总数据条数 // 总数据条数
total: 0, total: 0,
// 查询参数 // 查询参数
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 20, pageSize: 20,
sourceName: '' fieldName: ''
} }
} }
}, },
...@@ -224,11 +228,11 @@ export default { ...@@ -224,11 +228,11 @@ export default {
/** 查询数据源列表 */ /** 查询数据源列表 */
getList () { getList () {
this.loading = true this.loading = true
pageDataSource(this.queryParams).then(response => { pageChangeRecord(this.queryParams).then(response => {
this.loading = false this.loading = false
if (response.success) { if (response.success) {
const { data } = response const { data } = response
this.dataSourceList = data.data this.changeRecordList = data.data
this.total = data.total this.total = data.total
} }
}) })
...@@ -302,7 +306,7 @@ export default { ...@@ -302,7 +306,7 @@ export default {
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
delDataSource(row.id) delChangeRecord(row.id)
}).then(() => { }).then(() => {
this.$message.success('删除成功') this.$message.success('删除成功')
this.getList() this.getList()
......
<template>
<div>
<el-card class="box-card" shadow="always">
<div slot="header" class="clearfix">
<span>{{ title }}</span>
<el-button-group style="float: right;">
<el-button size="mini" icon="el-icon-back" round @click="showCard">返回</el-button>
</el-button-group>
</div>
<div :style="classCardbody">
<el-form ref="form" :model="form" label-width="80px" disabled>
<el-form-item label="字段名称" prop="columnName">
<el-input v-model="form.columnName" />
</el-form-item>
<el-form-item label="字段注释" prop="columnComment">
<el-input v-model="form.columnComment" />
</el-form-item>
<el-form-item label="是否主键" prop="columnKey">
<el-input v-model="form.columnKey" />
</el-form-item>
<el-form-item label="是否允许为空" prop="columnNullable">
<el-input v-model="form.columnNullable" />
</el-form-item>
<el-form-item label="数据类型" prop="dataType">
<el-input v-model="form.dataType" />
</el-form-item>
<el-form-item label="数据长度" prop="dataLength">
<el-input v-model="form.dataLength" />
</el-form-item>
<el-form-item label="数据精度" prop="dataPrecision">
<el-input v-model="form.dataPrecision" />
</el-form-item>
<el-form-item label="数据小数位" prop="dataScale">
<el-input v-model="form.dataScale" />
</el-form-item>
<el-form-item label="数据默认值" prop="dataDefault">
<el-input v-model="form.dataDefault" />
</el-form-item>
</el-form>
</div>
</el-card>
</div>
</template>
<script>
import { getDataColumn } from '@/api/metadata/datacolumn'
export default {
name: 'DataColumnDetail',
props: {
data: {
type: Object,
default: function () {
return {}
}
}
},
data () {
return {
classCardbody: {
overflow: 'auto',
height: document.body.offsetHeight - 240 + 'px'
},
title: '元数据详情',
// 展示切换
showOptions: {
data: {},
showList: true,
showDetail: false
},
// 表单参数
form: {}
}
},
created () {
console.log('id:' + this.data.id)
},
mounted () {
this.getDataColumn(this.data.id)
},
methods: {
showCard () {
this.$emit('showCard', this.showOptions)
},
/** 获取详情 */
getDataColumn: function (id) {
getDataColumn(id).then(response => {
if (response.success) {
this.form = response.data
}
})
}
}
}
</script>
<style lang="scss" scoped>
</style>
<template>
<div>
<el-row :gutter="20">
<el-col :span="4">
<el-card class="box-card" shadow="always">
<el-tree
:data="treeOptions"
default-expand-all
ref="tree"
node-key="id"
empty-text="加载中,请稍后"
:props="defaultProps"
@node-click="handleNodeClick"
></el-tree>
</el-card>
</el-col>
<el-col :span="20">
<el-card class="box-card" shadow="always">
<el-form :model="queryParams" ref="queryForm" :inline="true">
<el-form-item label="字段名称" prop="columnName">
<el-input
v-model="queryParams.columnName"
placeholder="请输入字段名称"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row type="flex" justify="space-between">
<el-col :span="12">
<el-button-group>
<el-button
type="info"
icon="el-icon-view"
size="mini"
:disabled="single"
@click="handleDetail"
>详情</el-button>
</el-button-group>
</el-col>
<el-col :span="12">
<div class="right-toolbar">
<el-tooltip content="密度" effect="dark" placement="top">
<el-dropdown trigger="click" @command="handleCommand">
<el-button circle size="mini">
<svg-icon class-name="size-icon" icon-class="colum-height" />
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item command="medium">正常</el-dropdown-item>
<el-dropdown-item command="small">中等</el-dropdown-item>
<el-dropdown-item command="mini">紧凑</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</el-tooltip>
<el-tooltip content="刷新" effect="dark" placement="top">
<el-button circle size="mini" @click="handleRefresh">
<svg-icon class-name="size-icon" icon-class="shuaxin" />
</el-button>
</el-tooltip>
<el-tooltip content="列设置" effect="dark" placement="top">
<el-popover placement="bottom" width="100" trigger="click">
<el-checkbox-group
v-model="checkedTableColumns"
@change="handleCheckedColsChange"
>
<el-checkbox
v-for="(item, index) in tableColumns"
:key="index"
:label="item.prop"
>{{ item.label }}</el-checkbox>
</el-checkbox-group>
<span slot="reference">
<el-button circle size="mini">
<svg-icon class-name="size-icon" icon-class="shezhi" />
</el-button>
</span>
</el-popover>
</el-tooltip>
</div>
</el-col>
</el-row>
<el-table
v-loading="loading"
:data="columnList"
@selection-change="handleSelectionChange"
border
tooltip-effect="dark"
:size="tableSize"
:height="tableHeight"
style="width: 100%;margin: 15px 0;"
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="序号" width="55" align="center">
<template slot-scope="scope">
<span>{{ scope.$index + 1 }}</span>
</template>
</el-table-column>
<template v-for="(item, index) in tableColumns">
<el-table-column
v-if="item.show"
:prop="item.prop"
:label="item.label"
:key="index"
:formatter="item.formatter"
align="center"
show-overflow-tooltip
/>
</template>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-popover
placement="left"
trigger="click">
<el-button
size="mini"
type="text"
icon="el-icon-view"
@click="handleDetail(scope.row)"
>详情</el-button>
<el-button slot="reference">操作</el-button>
</el-popover>
</template>
</el-table-column>
</el-table>
<el-pagination
:page-sizes="[10, 20, 50, 100]"
layout="total, sizes, prev, pager, next, jumper"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page.sync="queryParams.pageNum"
:page-size.sync="queryParams.pageSize"
:total="total"
></el-pagination>
</el-card>
</el-col>
</el-row>
</div>
</template>
<script>
import { pageDataColumn, getDataMetadataTree } from '@/api/metadata/datacolumn'
export default {
name: 'DataColumnList',
data () {
return {
tableHeight: document.body.offsetHeight - 340 + 'px',
// 展示切换
showOptions: {
data: {},
showList: true,
showDetail: false
},
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 表格头
tableColumns: [
{ prop: 'columnName', label: '字段名称', show: true },
{ prop: 'columnComment', label: '字段注释', show: true },
{ prop: 'columnKey', label: '是否主键', show: true, formatter: this.keyFormatter },
{ prop: 'columnNullable', label: '是否允许为空', show: true, formatter: this.nullableFormatter },
{ prop: 'dataType', label: '数据类型', show: true },
{ prop: 'dataLength', label: '数据长度', show: true },
{ prop: 'dataPrecision', label: '数据精度', show: true },
{ prop: 'dataScale', label: '数据小数位', show: true },
{ prop: 'dataDefault', label: '数据默认值', show: true }
],
// 默认选择中表格头
checkedTableColumns: [],
tableSize: 'medium',
// 表格数据
columnList: [],
// 总数据条数
total: 0,
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 20,
columnName: '',
sourceId: '',
tableId: ''
},
// 左侧树
treeOptions: [],
defaultProps: {
children: 'children',
label: 'label'
}
}
},
created () {
this.getList()
this.getTree()
},
mounted () {
this.initCols()
},
methods: {
/** 查询列表 */
getList () {
this.loading = true
pageDataColumn(this.queryParams).then(response => {
this.loading = false
if (response.success) {
const { data } = response
this.columnList = data.data
this.total = data.total
}
})
},
/** 查询树结构 */
getTree () {
let level = 'table'
getDataMetadataTree(level).then(response => {
if (response.success) {
const { data } = response
this.treeOptions = data
}
})
},
initCols () {
this.checkedTableColumns = this.tableColumns.map(col => col.prop)
},
handleCheckedColsChange (val) {
this.tableColumns.forEach(col => {
if (!this.checkedTableColumns.includes(col.prop)) {
col.show = false
} else {
col.show = true
}
})
},
handleCommand (command) {
this.tableSize = command
},
/** 搜索按钮操作 */
handleQuery () {
this.queryParams.pageNum = 1
this.getList()
},
/** 重置按钮操作 */
resetQuery () {
this.$refs['queryForm'].resetFields()
this.handleQuery()
},
/** 刷新列表 */
handleRefresh () {
this.getList()
},
/** 多选框选中数据 */
handleSelectionChange (selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length !== 1
this.multiple = !selection.length
},
/** 详情按钮操作 */
handleDetail (row) {
this.showOptions.data.id = row.id || this.ids[0]
this.showOptions.showList = false
this.showOptions.showDetail = true
this.$emit('showCard', this.showOptions)
},
handleSizeChange (val) {
console.log(`每页 ${val} 条`)
this.queryParams.pageNum = 1
this.queryParams.pageSize = val
this.getList()
},
handleCurrentChange (val) {
console.log(`当前页: ${val}`)
this.queryParams.pageNum = val
this.getList()
},
/** 节点单击事件 */
handleNodeClick (data) {
if ('database' === data.type) {
this.queryParams.sourceId = data.id
} else if ('table' === data.type) {
this.queryParams.tableId = data.id
}
this.getList()
},
keyFormatter (row, column, cellValue, index) {
if (cellValue === '1') {
return 'Y'
} else {
return 'N'
}
},
nullableFormatter (row, column, cellValue, index) {
if (cellValue === '1') {
return 'Y'
} else {
return 'N'
}
}
}
}
</script>
<style lang="scss" scoped>
.right-toolbar {
float: right;
}
</style>
<template> <template>
<div class="app-container"> <div class="app-container">
DataColumn <transition name="el-zoom-in-center">
<data-column-list v-if="options.showList" @showCard="showCard"></data-column-list>
</transition>
<transition name="el-zoom-in-bottom">
<data-column-detail v-if="options.showDetail" :data="options.data" @showCard="showCard"></data-column-detail>
</transition>
</div> </div>
</template> </template>
<script> <script>
import DataColumnList from './DataColumnList'
import DataColumnDetail from './DataColumnDetail'
export default { export default {
name: 'DataColumn' name: 'DataColumn',
components: { DataColumnList, DataColumnDetail },
data () {
return {
options: {
data: {},
showList: true,
showDetail: false
}
}
},
methods: {
showCard (data) {
Object.assign(this.options, data)
}
}
} }
</script> </script>
......
<template>
<div class="app-container">
DataMap
</div>
</template>
<script>
export default {
name: 'DataMap'
}
</script>
<style lang="scss" scoped>
</style>
...@@ -42,7 +42,9 @@ ...@@ -42,7 +42,9 @@
<commons.codec.version>1.13</commons.codec.version> <commons.codec.version>1.13</commons.codec.version>
<commons.beanutils.version>1.9.4</commons.beanutils.version> <commons.beanutils.version>1.9.4</commons.beanutils.version>
<common-pool.version>2.7.0</common-pool.version> <common-pool.version>2.7.0</common-pool.version>
<swagger2.version>2.9.2</swagger2.version> <knife4j.version>2.0.4</knife4j.version>
<swagger.version>1.6.2</swagger.version>
<springfox.version>2.9.2</springfox.version>
<mapstruct.version>1.3.1.Final</mapstruct.version> <mapstruct.version>1.3.1.Final</mapstruct.version>
<aliyun-sdk-oss.version>3.6.0</aliyun-sdk-oss.version> <aliyun-sdk-oss.version>3.6.0</aliyun-sdk-oss.version>
<qiniu-java-sdk.version>7.2.25</qiniu-java-sdk.version> <qiniu-java-sdk.version>7.2.25</qiniu-java-sdk.version>
...@@ -53,7 +55,7 @@ ...@@ -53,7 +55,7 @@
<sqlserver.version>8.2.1.jre8</sqlserver.version> <sqlserver.version>8.2.1.jre8</sqlserver.version>
<zxing.version>3.4.0</zxing.version> <zxing.version>3.4.0</zxing.version>
<aspose.version>20.3</aspose.version> <aspose.version>20.3</aspose.version>
<redisson.version>3.12.5</redisson.version> <redisson.version>3.13.3</redisson.version>
<jasperreports.version>6.12.2</jasperreports.version> <jasperreports.version>6.12.2</jasperreports.version>
<mybatis-spring.version>2.1.2</mybatis-spring.version> <mybatis-spring.version>2.1.2</mybatis-spring.version>
<bitwalker.version>1.21</bitwalker.version> <bitwalker.version>1.21</bitwalker.version>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment