资产展示修改后台优化
parent
757f91bc3b
commit
6dca1e8e6a
|
@ -1,5 +1,6 @@
|
||||||
package com.muyu.common.domain;
|
package com.muyu.common.domain;
|
||||||
|
|
||||||
|
import com.muyu.common.domain.enums.DataType;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
@ -27,7 +28,7 @@ public class DataValue {
|
||||||
private String label;
|
private String label;
|
||||||
|
|
||||||
//类型
|
//类型
|
||||||
private String type;
|
private DataType type;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 值
|
* 值
|
||||||
|
|
|
@ -9,9 +9,11 @@ import java.util.Date;
|
||||||
* @Project:cloud-etl-property
|
* @Project:cloud-etl-property
|
||||||
* @name:DataType
|
* @name:DataType
|
||||||
* @Date:2024/8/29 21:33
|
* @Date:2024/8/29 21:33
|
||||||
|
*
|
||||||
|
* 定义一个枚举,用于映射数据库类型到Java类型
|
||||||
*/
|
*/
|
||||||
public enum DataType {
|
public enum DataType {
|
||||||
|
// 定义各种数据库类型到Java类型的映射
|
||||||
VARCHAR("varchar",String.class,"String"),
|
VARCHAR("varchar",String.class,"String"),
|
||||||
BIGINT("bigint", Long.class,"Long"),
|
BIGINT("bigint", Long.class,"Long"),
|
||||||
INT("int", Integer.class,"Integer"),
|
INT("int", Integer.class,"Integer"),
|
||||||
|
@ -20,15 +22,31 @@ public enum DataType {
|
||||||
TEXT("text", String.class,"String"),
|
TEXT("text", String.class,"String"),
|
||||||
DOUBLE("double", Double.class,"Double");
|
DOUBLE("double", Double.class,"Double");
|
||||||
|
|
||||||
|
|
||||||
|
// 数据库源类型
|
||||||
private final String sourceType;
|
private final String sourceType;
|
||||||
|
// 映射到的Java类类型
|
||||||
private final Class<?> targetType;
|
private final Class<?> targetType;
|
||||||
|
// Java类型的字符串表示
|
||||||
private final String javaType;
|
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()) {
|
for (DataType dataType : DataType.values()) {
|
||||||
if (dataType.sourceType.equalsIgnoreCase(type)){
|
if (dataType.sourceType.equalsIgnoreCase(type)){
|
||||||
return dataType.targetType;
|
return dataType.targetType;
|
||||||
|
@ -37,8 +55,16 @@ public enum DataType {
|
||||||
return String.class;
|
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()) {
|
for (DataType dataType : DataType.values()) {
|
||||||
if (dataType.sourceType.equalsIgnoreCase(type)){
|
if (dataType.sourceType.equalsIgnoreCase(type)){
|
||||||
return dataType.javaType;
|
return dataType.javaType;
|
||||||
|
|
|
@ -384,7 +384,7 @@ public class DataRunNameServiceImpl implements DataRunNameService {
|
||||||
.key(metaData.getColumnName(i))
|
.key(metaData.getColumnName(i))
|
||||||
.label(remarks)
|
.label(remarks)
|
||||||
.value(resultSet.getObject(i, DataType.convertType(columnTypeName)))
|
.value(resultSet.getObject(i, DataType.convertType(columnTypeName)))
|
||||||
.type(DataType.convertTypeString(columnTypeName))
|
.type(DataType.findBySqlType(columnTypeName))
|
||||||
.build();
|
.build();
|
||||||
list.add(build);
|
list.add(build);
|
||||||
map.put(i, build);
|
map.put(i, build);
|
||||||
|
@ -392,8 +392,8 @@ public class DataRunNameServiceImpl implements DataRunNameService {
|
||||||
DataValue build = DataValue.builder()
|
DataValue build = DataValue.builder()
|
||||||
.key(metaData.getColumnName(i))
|
.key(metaData.getColumnName(i))
|
||||||
.label(map.get(i).getLabel())
|
.label(map.get(i).getLabel())
|
||||||
.value(resultSet.getObject(i, DataType.convertType((String) map.get(i).getValue())))
|
.value(resultSet.getObject(i, map.get(i).getType().getTargetType()))
|
||||||
.type(DataType.convertTypeString(map.get(i).getType()))
|
.type(map.get(i).getType())
|
||||||
.build();
|
.build();
|
||||||
list.add(build);
|
list.add(build);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue