mirror of
https://gitcode.com/ageerle/ruoyi-ai.git
synced 2026-04-16 13:23:42 +00:00
feat: fix代码生成类型问题
This commit is contained in:
@@ -195,16 +195,6 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||||||
table.put("sub", false);
|
table.put("sub", false);
|
||||||
table.put("tree", false);
|
table.put("tree", false);
|
||||||
|
|
||||||
// 添加isSuperColumn方法
|
|
||||||
table.put("isSuperColumn", new Object() {
|
|
||||||
public boolean isSuperColumn(String javaField) {
|
|
||||||
// 定义超类字段(BaseEntity中的字段)
|
|
||||||
return "createBy".equals(javaField) || "createTime".equals(javaField)
|
|
||||||
|| "updateBy".equals(javaField) || "updateTime".equals(javaField)
|
|
||||||
|| "remark".equals(javaField) || "tenantId".equals(javaField);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
context.put("table", table);
|
context.put("table", table);
|
||||||
|
|
||||||
// 处理字段信息
|
// 处理字段信息
|
||||||
@@ -294,7 +284,8 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||||||
case "LocalDateTime" -> importList.add("java.time.LocalDateTime");
|
case "LocalDateTime" -> importList.add("java.time.LocalDateTime");
|
||||||
case "LocalDate" -> importList.add("java.time.LocalDate");
|
case "LocalDate" -> importList.add("java.time.LocalDate");
|
||||||
case "LocalTime" -> importList.add("java.time.LocalTime");
|
case "LocalTime" -> importList.add("java.time.LocalTime");
|
||||||
default -> {}
|
default -> {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,16 +404,17 @@ public class GenTableServiceImpl implements IGenTableService {
|
|||||||
return "String";
|
return "String";
|
||||||
}
|
}
|
||||||
String type = dbType.toLowerCase();
|
String type = dbType.toLowerCase();
|
||||||
if (type.contains("int") || type.contains("tinyint") || type.contains("smallint")) {
|
if (StrUtil.equalsAny(type, "int", "tinyint")) {
|
||||||
return "Integer";
|
return "Integer";
|
||||||
} else if (type.contains("bigint")) {
|
} else if (StrUtil.equalsAny(type, "bigint")) {
|
||||||
return "Long";
|
return "Long";
|
||||||
} else if (type.contains("decimal") || type.contains("numeric") || type.contains("float") || type.contains(
|
} else if (StrUtil.equalsAny(type, "decimal", "numeric", "float", "double")) {
|
||||||
"double")) {
|
|
||||||
return "BigDecimal";
|
return "BigDecimal";
|
||||||
} else if (type.contains("date") || type.contains("time")) {
|
} else if (StrUtil.equalsAny(type, "date")) {
|
||||||
return "Date";
|
return "LocalDate";
|
||||||
} else if (type.contains("bit") || type.contains("boolean")) {
|
} else if (StrUtil.equalsAny(type, "datetime", "timestamp")) {
|
||||||
|
return "LocalDateTime";
|
||||||
|
} else if (StrUtil.equalsAny(type, "bit", "boolean")) {
|
||||||
return "Boolean";
|
return "Boolean";
|
||||||
} else {
|
} else {
|
||||||
return "String";
|
return "String";
|
||||||
|
|||||||
@@ -211,7 +211,6 @@ public class SchemaFieldServiceImpl implements SchemaFieldService {
|
|||||||
result.put("tableName", schema.getTableName());
|
result.put("tableName", schema.getTableName());
|
||||||
result.put("tableComment", schema.getComment());
|
result.put("tableComment", schema.getComment());
|
||||||
result.put("className", toCamelCase(schema.getTableName(), true));
|
result.put("className", toCamelCase(schema.getTableName(), true));
|
||||||
// result.put("className", StrUtil.toCamelCase(schema.getTableName()));
|
|
||||||
result.put("tableCamelName", StrUtil.toCamelCase(schema.getTableName()));
|
result.put("tableCamelName", StrUtil.toCamelCase(schema.getTableName()));
|
||||||
result.put("functionName", schema.getName());
|
result.put("functionName", schema.getName());
|
||||||
result.put("schemaName", schema.getName());
|
result.put("schemaName", schema.getName());
|
||||||
@@ -363,16 +362,15 @@ public class SchemaFieldServiceImpl implements SchemaFieldService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String type = dbType.toLowerCase();
|
String type = dbType.toLowerCase();
|
||||||
if (type.contains("int") || type.contains("tinyint") || type.contains("smallint")) {
|
if (StrUtil.equalsAny(type, "int", "tinyint", "smallint")) {
|
||||||
return "Integer";
|
return "Integer";
|
||||||
} else if (type.contains("bigint")) {
|
} else if (StrUtil.equalsAny(type, "bigint")) {
|
||||||
return "Long";
|
return "Long";
|
||||||
} else if (type.contains("decimal") || type.contains("numeric") || type.contains("float") || type.contains(
|
} else if (StrUtil.equalsAny(type, "decimal", "numeric", "float", "double")) {
|
||||||
"double")) {
|
|
||||||
return "BigDecimal";
|
return "BigDecimal";
|
||||||
} else if (type.contains("date") || type.contains("time")) {
|
} else if (StrUtil.equalsAny(type, "date", "datetime","timestamp")) {
|
||||||
return "Date";
|
return "Date";
|
||||||
} else if (type.contains("bit") || type.contains("boolean")) {
|
} else if (StrUtil.equalsAny(type, "bit", "boolean")) {
|
||||||
return "Boolean";
|
return "Boolean";
|
||||||
} else {
|
} else {
|
||||||
return "String";
|
return "String";
|
||||||
|
|||||||
@@ -25,11 +25,11 @@ import org.ruoyi.common.core.validate.EditGroup;
|
|||||||
public class ${ClassName}Bo implements Serializable {
|
public class ${ClassName}Bo implements Serializable {
|
||||||
|
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if(!$table.isSuperColumn($column.javaField) && ($column.isPk || $column.query || $column.insert || $column.edit))
|
#if($column.isPk || $column.query || $column.insert || $column.edit|| $column.required)
|
||||||
/**
|
/**
|
||||||
* $column.columnComment
|
* $column.columnComment
|
||||||
*/
|
*/
|
||||||
#if($column.insert && $column.edit)
|
#if(($column.insert && $column.edit) || $column.required)
|
||||||
#set($Group="AddGroup.class, EditGroup.class")
|
#set($Group="AddGroup.class, EditGroup.class")
|
||||||
#elseif($column.insert)
|
#elseif($column.insert)
|
||||||
#set($Group="AddGroup.class")
|
#set($Group="AddGroup.class")
|
||||||
|
|||||||
@@ -1,38 +1,20 @@
|
|||||||
package ${packageName}.domain;
|
package ${packageName}.domain;
|
||||||
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.javaField=='tenantId')
|
|
||||||
#set($IsTenant=1)
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
#if($IsTenant==1)
|
|
||||||
import core.tenant.common.org.ruoyi.TenantEntity;
|
|
||||||
#else
|
|
||||||
#end
|
|
||||||
import com.baomidou.mybatisplus.annotation.*;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
#foreach ($import in $importList)
|
#foreach ($import in $importList)
|
||||||
import ${import};
|
import ${import};
|
||||||
#end
|
#end
|
||||||
|
|
||||||
import org.ruoyi.core.domain.BaseEntity;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ${functionName}对象 ${tableName}
|
* ${functionName}对象 ${tableName}
|
||||||
*
|
*
|
||||||
* @author ${author}
|
* @author ${author}
|
||||||
* @date ${datetime}
|
* @date ${datetime}
|
||||||
*/
|
*/
|
||||||
#if($IsTenant==1)
|
|
||||||
#set($Entity="TenantEntity")
|
|
||||||
#else
|
|
||||||
#set($Entity="BaseEntity")
|
|
||||||
#end
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@TableName("${tableName}")
|
@TableName("${tableName}")
|
||||||
public class ${ClassName} extends ${Entity} {
|
public class ${ClassName} implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
|
|||||||
Reference in New Issue
Block a user