🐛 修改前端代码生成逻辑
This commit is contained in:
parent
755e5fa5e5
commit
6bf116b500
|
@ -74,9 +74,27 @@ public class MySqlDialect implements DatabaseDialect {
|
||||||
columnType = StringUtils.uncapitalize(columnType);
|
columnType = StringUtils.uncapitalize(columnType);
|
||||||
|
|
||||||
return switch (columnType) {
|
return switch (columnType) {
|
||||||
case "double", "int", "long", "integer", "float", "decimal" -> "number";
|
case "double", "int", "long", "integer", "float", "decimal",
|
||||||
case "localDateTime", "date" -> "string";
|
"short", "byte", "bigInteger", "bigDecimal" -> "number";
|
||||||
default -> columnType;
|
case "boolean" -> "boolean";
|
||||||
|
case "char", "character", "string", "localDateTime",
|
||||||
|
"date", "localDate", "instant" -> "string";
|
||||||
|
case "list", "set" -> "array";
|
||||||
|
case "map" -> "record";
|
||||||
|
case "void" -> "void";
|
||||||
|
default -> {
|
||||||
|
// 处理泛型或自定义类型
|
||||||
|
String subString = columnType.substring(columnType.indexOf("<") + 1, columnType.lastIndexOf(">"));
|
||||||
|
|
||||||
|
if (columnType.startsWith("list<") || columnType.startsWith("set<")) {
|
||||||
|
yield "Array<" + convertToJavaScriptType(subString) + ">";
|
||||||
|
} else if (columnType.startsWith("map<")) {
|
||||||
|
String[] parts = subString.split(",");
|
||||||
|
yield "Record<" + convertToJavaScriptType(parts[0].trim()) + "," +
|
||||||
|
convertToJavaScriptType(parts[1].trim()) + ">";
|
||||||
|
}
|
||||||
|
yield columnType; // 默认返回原始类型
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue