From 2c9d66e2a753958904128522aa8f9f8988322ace Mon Sep 17 00:00:00 2001 From: zhangtao <9480807882@qq.com> Date: Thu, 27 Nov 2025 00:17:42 +0800 Subject: [PATCH] =?UTF-8?q?refactor(module=5Fgenerator):=20=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E4=BD=BF=E7=94=A8column=5Fname=E6=9B=BF=E6=8D=A2pytho?= =?UTF-8?q?n=5Ffield=E5=AD=97=E6=AE=B5=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改模板文件中的字段引用,从python_field改为column_name以保持命名一致性 --- .../gencode/templates/ts/api.ts.j2 | 12 ++-- .../gencode/templates/vue/index.vue.j2 | 68 +++++++++---------- 2 files changed, 40 insertions(+), 40 deletions(-) diff --git a/backend/app/api/v1/module_generator/gencode/templates/ts/api.ts.j2 b/backend/app/api/v1/module_generator/gencode/templates/ts/api.ts.j2 index 54f3cffa..06ce9411 100644 --- a/backend/app/api/v1/module_generator/gencode/templates/ts/api.ts.j2 +++ b/backend/app/api/v1/module_generator/gencode/templates/ts/api.ts.j2 @@ -107,12 +107,12 @@ export interface {{ class_name }}PageQuery extends PageQuery { end_time?: string; } -// 列表查询结果 +// 列表展示项 export interface {{ class_name }}Table { index?: number; {% for column in columns %} - {{ column.python_field }}?: {{ - 'boolean' if ('status' in (column.python_field|lower)) or (column.html_type == 'radio') + {{ column.column_name }}?: {{ + 'boolean' if ('status' in (column.column_name|lower)) or (column.html_type == 'radio') else 'number' if column.is_pk == 1 else 'string' }}; @@ -123,9 +123,9 @@ export interface {{ class_name }}Table { // 新增/修改/详情表单参数 export interface {{ class_name }}Form { {% for column in columns %} - {% if (column.is_insert == 1 or column.is_edit == 1) and column.python_field not in ['creatorId', 'createdAt', 'updatedAt'] %} - {{ column.python_field }}?: {{ - 'boolean' if ('status' in (column.python_field|lower)) or (column.html_type == 'radio') + {% if (column.is_insert == 1 or column.is_edit == 1) and column.column_name not in ['creator_id', 'created_at', 'updated_at'] %} + {{ column.column_name }}?: {{ + 'boolean' if ('status' in (column.column_name|lower)) or (column.html_type == 'radio') else 'number' if column.is_pk == 1 else 'string' }}; diff --git a/backend/app/api/v1/module_generator/gencode/templates/vue/index.vue.j2 b/backend/app/api/v1/module_generator/gencode/templates/vue/index.vue.j2 index eeb43bf5..16e233b8 100644 --- a/backend/app/api/v1/module_generator/gencode/templates/vue/index.vue.j2 +++ b/backend/app/api/v1/module_generator/gencode/templates/vue/index.vue.j2 @@ -10,24 +10,24 @@ {% set parentheseIndex = column_comment.find("(") %} {% set comment = column_comment[:parentheseIndex] if parentheseIndex != -1 else column_comment %} {% if column.html_type == "input" %} - - + + {% elif (column.html_type == "select" or column.html_type == "radio") and dict_type != "" %} - - + + {% elif (column.html_type == "select" or column.html_type == "radio") and dict_type %} - - + + {% elif column.html_type == "datetime" and column.query_type != "BETWEEN" %} - - + + {% endif %} {% endif %} @@ -155,7 +155,7 @@ {% for column in columns %} - {% set python_field = column.python_field %} + {% set python_field = column.column_name %} {% set column_comment = column.column_comment if column.column_comment else '' %} {% set parentheseIndex = column_comment.find("(") %} {% set comment = column_comment[:parentheseIndex] if parentheseIndex != -1 else column_comment %} @@ -194,7 +194,7 @@