fix(添加测试接口)

master
031026 2024-05-15 22:43:03 +08:00
parent c584b3995c
commit 36e6dc32f5
11 changed files with 227 additions and 19 deletions

View File

@ -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>

View File

@ -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;
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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;
}
}

View File

@ -20,6 +20,7 @@
<module>muyu-common-system</module>
<module>muyu-common-cache</module>
<module>muyu-common-method</module>
<module>muyu-common-data-standard</module>
</modules>
<artifactId>muyu-common</artifactId>

View File

@ -35,14 +35,9 @@ public class DataSourceClinetRunner implements ApplicationRunner {
TableDataInfo<DataSource> data = list.getData();
List<DataSource> rows = data.getRows();
for (DataSource row : rows) {
MysqlPool mysqlPool = new MysqlPool(MysqlPoolConfig.buildConfig(row));
mysqlPool.init();
Connection connection = mysqlPool.creatConnection();
log.info(connection);
mysqlPool.reaplase(connection);
rows.stream().forEach(dataSource -> {
log.info("dataSource:{}",dataSource);
}
log.info(rows.size());
});
}
}

View File

@ -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,>
}

View File

@ -4,10 +4,7 @@ import com.muyu.common.core.domain.Result;
import com.muyu.data.source.domain.Asset;
import com.muyu.data.source.service.AssetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@ -25,8 +22,8 @@ public class AssetController {
@Autowired
private AssetService assetService;
@GetMapping("/assetsList")
public Result<List<Asset>> assetsList(){
return assetService.assetsList();
@PostMapping("/assetsList")
public Result<List<Asset>> assetsList(@RequestBody String tableName){
return assetService.assetsList(tableName);
}
}

View File

@ -14,7 +14,7 @@ import java.util.List;
* @createTime: 2024/5/14 10:32
*/
public interface AssetService extends IService<Asset> {
Result<List<Asset>> assetsList();
Result<List<Asset>> assetsList(String tableName);
}

View File

@ -27,10 +27,18 @@ public class AssetServiceImpl extends ServiceImpl<AssetMapper, Asset>
@Override
public Result<List<Asset>> assetsList() {
System.out.println(assetMapper.selectList(null));
public Result<List<Asset>> assetsList(String tableName) {
System.out.println(assetMapper.selectList(
new LambdaQueryWrapper<Asset>(){{
eq(Asset::getTableName,tableName);
}}
));
return Result.success(
assetMapper.selectList(null)
assetMapper.selectList(
new LambdaQueryWrapper<Asset>(){{
eq(Asset::getTableName,tableName);
}}
)
);
}
}