feat(generate): 优化代码生成逻辑

- 新增公共字段配置,统一处理常见字段的生成规则
- 修复模板中的一些错误,如变量名、函数名等
- 优化代码结构,提高可读性和可维护性
This commit is contained in:
2025-07-01 23:40:43 +08:00
parent bd13f1cfdc
commit 1c316594f5
10 changed files with 568 additions and 175 deletions

View File

@@ -71,6 +71,7 @@ class Generate:
"Dict[str, Any]": "Record<string, any>",
"Any": "any",
}
common_column = ["id", "del_flag", "create_by", "update_by", "create_time", "update_time"]
"""组织数据,供 Jinja2 渲染"""
return {
"author": table_info.get('author', ""),
@@ -86,6 +87,7 @@ class Generate:
"python_name": col["python_name"],
"field_type": cls.convert_mysql_type(col["column_type"])[0],
"max_length": cls.convert_mysql_type(col["column_type"])[1],
"is_common": col["python_name"] in common_column,
"is_nullable": not col["is_required"],
"is_unique": col.get("is_unique", False),
"default": col.get("default", None),