diff --git a/backend/app/plugin/module_generator/gencode/templates/python/model.py.j2 b/backend/app/plugin/module_generator/gencode/templates/python/model.py.j2 index c6b075d0..7f535c65 100644 --- a/backend/app/plugin/module_generator/gencode/templates/python/model.py.j2 +++ b/backend/app/plugin/module_generator/gencode/templates/python/model.py.j2 @@ -18,7 +18,7 @@ class {{ class_name }}Model(ModelMixin, UserMixin): {% if not is_sub_entity %} {% for column in columns %} - {% if column.column_name not in ['id', 'uuid', 'status', 'description', 'created_time', 'updated_time', 'created_id', 'updated_id'] %} + {% if column.column_name not in ['id', 'uuid', 'status', 'description', 'created_time', 'updated_time', 'created_id', 'updated_id', 'is_deleted', 'deleted_time', 'deleted_id'] %} {% set sqlalchemy_type = column|get_sqlalchemy_type %} {{ column.column_name }}: Mapped[{{ column.python_type }} | None] = mapped_column({{ sqlalchemy_type }}, {% if column.is_pk %}primary_key=True, {% endif %}{% if column.is_increment %}autoincrement=True, {% endif %}{% if (not column.is_nullable) or column.is_pk %}nullable=False{% else %}nullable=True{% endif %}, comment='{{ column.column_comment }}') {% endif %} @@ -29,7 +29,7 @@ class {{ class_name }}Model(ModelMixin, UserMixin): {% endif %} {% else %} {% for column in columns %} - {% if column.column_name not in ['id', 'uuid', 'status', 'description', 'created_time', 'updated_time', 'created_id', 'updated_id'] %} + {% if column.column_name not in ['id', 'uuid', 'status', 'description', 'created_time', 'updated_time', 'created_id', 'updated_id', 'is_deleted', 'deleted_time', 'deleted_id'] %} {% set sqlalchemy_type = column|get_sqlalchemy_type %} {% if column.column_name == sub_table_fk_name %} {{ column.column_name }}: Mapped[{{ column.python_type }} | None] = mapped_column({{ sqlalchemy_type }}, ForeignKey('{{ parent_table_name }}.{{ parent_pk_column_name }}', ondelete='CASCADE'), {% if column.is_pk %}primary_key=True, {% endif %}{% if column.is_increment %}autoincrement=True, {% endif %}{% if (not column.is_nullable) or column.is_pk %}nullable=False{% else %}nullable=True{% endif %}, comment='{{ column.column_comment }}') diff --git a/backend/app/plugin/module_generator/gencode/templates/python/schema.py.j2 b/backend/app/plugin/module_generator/gencode/templates/python/schema.py.j2 index 581300a4..dff37f54 100644 --- a/backend/app/plugin/module_generator/gencode/templates/python/schema.py.j2 +++ b/backend/app/plugin/module_generator/gencode/templates/python/schema.py.j2 @@ -17,7 +17,7 @@ class {{ class_name }}CreateSchema(BaseModel): {{ function_name }}新增模型 """ {% for column in columns %} - {% if column.column_name not in ['uuid', 'created_time', 'updated_time', 'created_id', 'updated_id'] and column.column_name != pk_column_name %} + {% if column.column_name not in ['uuid', 'created_time', 'updated_time', 'created_id', 'updated_id', 'is_deleted', 'deleted_time', 'deleted_id'] and column.column_name != pk_column_name %} {% if column.column_name == 'status' %} {{ column.column_name }}: {{ column.python_type }} = Field(default="0", description='{{ column.column_comment }}') {% elif column.column_name == 'description' %} diff --git a/frontend/src/views/module_generator/gencode/utils/createTableVisualPresets.ts b/frontend/src/views/module_generator/gencode/utils/createTableVisualPresets.ts index 47047c64..8be69df7 100644 --- a/frontend/src/views/module_generator/gencode/utils/createTableVisualPresets.ts +++ b/frontend/src/views/module_generator/gencode/utils/createTableVisualPresets.ts @@ -34,6 +34,9 @@ function mixinMysql(): ColDef[] { }, { name: "created_id", type: "int", nullable: true, isPk: false, comment: "创建人ID" }, { name: "updated_id", type: "int", nullable: true, isPk: false, comment: "更新人ID" }, + { name: "is_deleted", type: "tinyint(1)", nullable: false, isPk: false, comment: "是否已删除(0:未删除 1:已删除)" }, + { name: "deleted_time", type: "datetime", nullable: true, isPk: false, comment: "删除时间" }, + { name: "deleted_id", type: "int", nullable: true, isPk: false, comment: "删除人ID" }, ]; } @@ -63,6 +66,9 @@ function mixinPostgres(): ColDef[] { }, { name: "created_id", type: "integer", nullable: true, isPk: false, comment: "创建人ID" }, { name: "updated_id", type: "integer", nullable: true, isPk: false, comment: "更新人ID" }, + { name: "is_deleted", type: "boolean", nullable: false, isPk: false, comment: "是否已删除(0:未删除 1:已删除)" }, + { name: "deleted_time", type: "timestamp without time zone", nullable: true, isPk: false, comment: "删除时间" }, + { name: "deleted_id", type: "integer", nullable: true, isPk: false, comment: "删除人ID" }, ]; }