资产展示修改后台优化

master
Yueng 2024-09-06 15:29:13 +08:00
parent 757f91bc3b
commit 6dca1e8e6a
3 changed files with 36 additions and 9 deletions

View File

@ -1,5 +1,6 @@
package com.muyu.common.domain;
import com.muyu.common.domain.enums.DataType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@ -27,7 +28,7 @@ public class DataValue {
private String label;
//类型
private String type;
private DataType type;
/**
*

View File

@ -9,9 +9,11 @@ import java.util.Date;
* @Projectcloud-etl-property
* @nameDataType
* @Date2024/8/29 21:33
*
* Java
*/
public enum DataType {
// 定义各种数据库类型到Java类型的映射
VARCHAR("varchar",String.class,"String"),
BIGINT("bigint", Long.class,"Long"),
INT("int", Integer.class,"Integer"),
@ -20,15 +22,31 @@ public enum DataType {
TEXT("text", String.class,"String"),
DOUBLE("double", Double.class,"Double");
// 数据库源类型
private final String sourceType;
// 映射到的Java类类型
private final Class<?> targetType;
// Java类型的字符串表示
private final String javaType;
public static Class convertType(String type){
public String getSourceType() {
return sourceType;
}
public Class<?> getTargetType() {
return targetType;
}
public String getJavaType() {
return javaType;
}
public static Class convertType(String type){
for (DataType dataType : DataType.values()) {
if (dataType.sourceType.equalsIgnoreCase(type)){
return dataType.targetType;
@ -37,8 +55,16 @@ public enum DataType {
return String.class;
}
public static String convertTypeString(String type){
public static DataType findBySqlType(String sqlType){
for (DataType dataType : DataType.values()) {
if (dataType.getSourceType().equalsIgnoreCase(sqlType)){
return dataType;
}
}
return VARCHAR;
}
public static String convertTypeString(String type){
for (DataType dataType : DataType.values()) {
if (dataType.sourceType.equalsIgnoreCase(type)){
return dataType.javaType;

View File

@ -384,7 +384,7 @@ public class DataRunNameServiceImpl implements DataRunNameService {
.key(metaData.getColumnName(i))
.label(remarks)
.value(resultSet.getObject(i, DataType.convertType(columnTypeName)))
.type(DataType.convertTypeString(columnTypeName))
.type(DataType.findBySqlType(columnTypeName))
.build();
list.add(build);
map.put(i, build);
@ -392,8 +392,8 @@ public class DataRunNameServiceImpl implements DataRunNameService {
DataValue build = DataValue.builder()
.key(metaData.getColumnName(i))
.label(map.get(i).getLabel())
.value(resultSet.getObject(i, DataType.convertType((String) map.get(i).getValue())))
.type(DataType.convertTypeString(map.get(i).getType()))
.value(resultSet.getObject(i, map.get(i).getType().getTargetType()))
.type(map.get(i).getType())
.build();
list.add(build);
}