优化更新

This commit is contained in:
2026-09-13 17:33:13 +08:00
parent 8be23a62a3
commit 7f758cc6e9
97 changed files with 2333 additions and 3595 deletions
@@ -106,7 +106,7 @@ Jinja2 模板文件,分为后端模板(7 个)和前端模板(ui/ 6 个 +
## 使用限制
:::warning 使用前提
1. **数据库要求**:代码生成器基于 MySQL 的 `information_schema` 查询表结构,仅支持 MySQL 数据库。
1. **数据库要求**:代码生成器基于 MySQL 的 `information_schema` 查询表结构,仅支持 MySQL 数据库。其他数据库(PostgreSQL、Oracle、SQL Server 等)需手动创建模块。
2. **表结构要求**:不支持复合主键、外键关联等复杂表结构,建议使用单主键(自增 id)的标准业务表。
3. **环境要求**:需确保 Django 环境已初始化、MySQL 和 Redis 服务正常运行。
:::
@@ -162,7 +162,7 @@ public/templates/
修改 `public/templates/models.py.tpl`:
```jinja2
```jinja
{% if f.type == 'CharField' %}
{{ f.name }} = models.CharField(
max_length={{ f.max_length or 255 }},
@@ -177,7 +177,7 @@ public/templates/
修改 `public/templates/services.py.tpl`,在添加方法中添加自定义校验:
```jinja2
```jinja
def add_{{ app_name }}(request):
# ... 原有代码 ...
# 自定义校验:检查名称是否重复
@@ -190,7 +190,7 @@ def add_{{ app_name }}(request):
修改 `public/templates/ui/columns.ts.tpl`:
```jinja2
```jinja
{% for f in list_fields %}
{
label: '{{ f.label }}',
@@ -208,7 +208,7 @@ def add_{{ app_name }}(request):
在 `public/templates/` 下新建 `test.py.tpl`:
```jinja2
```jinja
# tests/test_{{ app_name }}.py
from django.test import TestCase
from application.{{ app_name }}.models import {{ model_class_name }}
@@ -247,7 +247,7 @@ backend_templates = [
## Jinja2 语法速查
```jinja2
```jinja
{# 注释 #}
{# 变量输出 #}