fix(添加测试接口)
parent
c584b3995c
commit
36e6dc32f5
|
@ -0,0 +1,28 @@
|
||||||
|
<?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">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>muyu-common</artifactId>
|
||||||
|
<version>3.6.3</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>muyu-common-data-standard</artifactId>
|
||||||
|
<description>muyu-common-data-standard数据标准包</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.compiler.source>17</maven.compiler.source>
|
||||||
|
<maven.compiler.target>17</maven.compiler.target>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!--项目核心包-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.muyu</groupId>
|
||||||
|
<artifactId>muyu-common-core</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.muyu.common.data.standard.model;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: DongZeLiang
|
||||||
|
* @date: 2024/5/5
|
||||||
|
* @Description: 数据模型
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class DataModel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据键
|
||||||
|
*/
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据值
|
||||||
|
*/
|
||||||
|
private Object value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 源标准-枚举
|
||||||
|
*/
|
||||||
|
private String sourceType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理标准-枚举
|
||||||
|
*/
|
||||||
|
private String processType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理类型
|
||||||
|
*/
|
||||||
|
private Class<?> processClass;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.muyu.common.data.standard.model;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: DongZeLiang
|
||||||
|
* @date: 2024/5/5
|
||||||
|
* @Description: 一页
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class DataSetModel {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 集合
|
||||||
|
*/
|
||||||
|
private RecordModel[] dataSetModelArr = null;
|
||||||
|
|
||||||
|
private int setLength ;
|
||||||
|
|
||||||
|
public static DataSetModel build(int dataSetModelLength){
|
||||||
|
return build(new RecordModel[dataSetModelLength]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DataSetModel build(RecordModel[] dataSerModel){
|
||||||
|
return DataSetModel.builder()
|
||||||
|
.dataSetModelArr(dataSerModel)
|
||||||
|
.setLength(dataSerModel.length)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
package com.muyu.common.data.standard.model;
|
||||||
|
|
||||||
|
import com.muyu.common.data.standard.utils.EtlUtils;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: DongZeLiang
|
||||||
|
* @date: 2024/5/5
|
||||||
|
* @Description: 记录模型
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class RecordModel {
|
||||||
|
/**
|
||||||
|
* 制定主键2
|
||||||
|
*/
|
||||||
|
private String[] keys ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键数据
|
||||||
|
*/
|
||||||
|
private DataModel[] keyForValue;
|
||||||
|
/**
|
||||||
|
* 单条记录
|
||||||
|
*/
|
||||||
|
private DataModel[] dataModelArr = null;
|
||||||
|
|
||||||
|
private int recordLength;
|
||||||
|
public static RecordModel build(int dataModelLength,String[] keys){
|
||||||
|
return build(new DataModel[dataModelLength],keys);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RecordModel build(DataModel[] dataModelArr, String[] keys){
|
||||||
|
return RecordModel.builder()
|
||||||
|
.dataModelArr(dataModelArr)
|
||||||
|
.recordLength(dataModelArr.length)
|
||||||
|
.keys(keys)
|
||||||
|
.keyForValue(
|
||||||
|
Arrays.stream(dataModelArr)
|
||||||
|
.filter(dataModel -> EtlUtils.valAsArr(keys,dataModel.getKey()))
|
||||||
|
.toArray(value -> new DataModel[0])
|
||||||
|
)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.muyu.common.data.standard.utils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Etl工具类
|
||||||
|
*
|
||||||
|
* @ClassName EtlUtils
|
||||||
|
* @Author AnNan.Wang
|
||||||
|
* @Date 2024/5/15 17:10
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public class EtlUtils {
|
||||||
|
/**
|
||||||
|
* 判断key是否在数值当中
|
||||||
|
* @param keys key数值
|
||||||
|
* @param key key值
|
||||||
|
* @return 是否存在
|
||||||
|
*/
|
||||||
|
public static boolean valAsArr(String[] keys,String key){
|
||||||
|
for (String _key : keys) {
|
||||||
|
if (_key.equals(key)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,6 +20,7 @@
|
||||||
<module>muyu-common-system</module>
|
<module>muyu-common-system</module>
|
||||||
<module>muyu-common-cache</module>
|
<module>muyu-common-cache</module>
|
||||||
<module>muyu-common-method</module>
|
<module>muyu-common-method</module>
|
||||||
|
<module>muyu-common-data-standard</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<artifactId>muyu-common</artifactId>
|
<artifactId>muyu-common</artifactId>
|
||||||
|
|
|
@ -35,14 +35,9 @@ public class DataSourceClinetRunner implements ApplicationRunner {
|
||||||
TableDataInfo<DataSource> data = list.getData();
|
TableDataInfo<DataSource> data = list.getData();
|
||||||
List<DataSource> rows = data.getRows();
|
List<DataSource> rows = data.getRows();
|
||||||
|
|
||||||
for (DataSource row : rows) {
|
rows.stream().forEach(dataSource -> {
|
||||||
MysqlPool mysqlPool = new MysqlPool(MysqlPoolConfig.buildConfig(row));
|
log.info("dataSource:{}",dataSource);
|
||||||
mysqlPool.init();
|
|
||||||
Connection connection = mysqlPool.creatConnection();
|
|
||||||
log.info(connection);
|
|
||||||
mysqlPool.reaplase(connection);
|
|
||||||
|
|
||||||
}
|
});
|
||||||
log.info(rows.size());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.muyu.source.clinet.connection.pool;
|
||||||
|
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 连接池上下文
|
||||||
|
*
|
||||||
|
* @ClassName ConnectionPoolContext
|
||||||
|
* @Author AnNan.Wang
|
||||||
|
* @Date 2024/5/15 18:45
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
public class ConnectionPoolContext {
|
||||||
|
// private final static ConcurrentHashMap<String,>
|
||||||
|
}
|
|
@ -4,10 +4,7 @@ import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.data.source.domain.Asset;
|
import com.muyu.data.source.domain.Asset;
|
||||||
import com.muyu.data.source.service.AssetService;
|
import com.muyu.data.source.service.AssetService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -25,8 +22,8 @@ public class AssetController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private AssetService assetService;
|
private AssetService assetService;
|
||||||
|
|
||||||
@GetMapping("/assetsList")
|
@PostMapping("/assetsList")
|
||||||
public Result<List<Asset>> assetsList(){
|
public Result<List<Asset>> assetsList(@RequestBody String tableName){
|
||||||
return assetService.assetsList();
|
return assetService.assetsList(tableName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ import java.util.List;
|
||||||
* @createTime: 2024/5/14 10:32
|
* @createTime: 2024/5/14 10:32
|
||||||
*/
|
*/
|
||||||
public interface AssetService extends IService<Asset> {
|
public interface AssetService extends IService<Asset> {
|
||||||
Result<List<Asset>> assetsList();
|
Result<List<Asset>> assetsList(String tableName);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,10 +27,18 @@ public class AssetServiceImpl extends ServiceImpl<AssetMapper, Asset>
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<List<Asset>> assetsList() {
|
public Result<List<Asset>> assetsList(String tableName) {
|
||||||
System.out.println(assetMapper.selectList(null));
|
System.out.println(assetMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<Asset>(){{
|
||||||
|
eq(Asset::getTableName,tableName);
|
||||||
|
}}
|
||||||
|
));
|
||||||
return Result.success(
|
return Result.success(
|
||||||
assetMapper.selectList(null)
|
assetMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<Asset>(){{
|
||||||
|
eq(Asset::getTableName,tableName);
|
||||||
|
}}
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue