🐛 修改前端代码生成逻辑

This commit is contained in:
bunny 2025-07-22 21:29:10 +08:00
parent 755e5fa5e5
commit 6bf116b500
1 changed files with 21 additions and 3 deletions

View File

@ -74,9 +74,27 @@ public class MySqlDialect implements DatabaseDialect {
columnType = StringUtils.uncapitalize(columnType);
return switch (columnType) {
case "double", "int", "long", "integer", "float", "decimal" -> "number";
case "localDateTime", "date" -> "string";
default -> columnType;
case "double", "int", "long", "integer", "float", "decimal",
"short", "byte", "bigInteger", "bigDecimal" -> "number";
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; // 默认返回原始类型
}
};
}