Files
fastapi-best-architecture/backend/plugin/code_generator/templates/python/schema.jinja
T
Wu Clan fc34c98f0a Update the code generator to plugin (#578)
* Update the code generator to plugin

* Fix get all tables return type
2025-04-17 11:06:43 +08:00

36 lines
1.0 KiB
Django/Jinja

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from datetime import datetime
from pydantic import ConfigDict, Field
from backend.common.schema import SchemaBase
class {{ schema_name }}SchemaBase(SchemaBase):
"""{{ table_simple_name_zh }}基础模型"""
{% for model in models %}
{{ model.name }}: {% if model.nullable %}{{ model.pd_type }} | None = Field(None, description='{{ model.comment }}'){% else %}{{ model.pd_type }} = Field(description='{{ model.comment }}'){% endif %}
{% endfor %}
class Create{{ schema_name }}Param({{ schema_name }}SchemaBase):
"""创建{{ table_simple_name_zh }}参数"""
class Update{{ schema_name }}Param({{ schema_name }}SchemaBase):
"""更新{{ table_simple_name_zh }}参数"""
class Get{{ schema_name }}Detail({{ schema_name }}SchemaBase):
"""{{ table_simple_name_zh }}详情"""
model_config = ConfigDict(from_attributes=True)
id: int
{% if default_datetime_column %}
created_time: datetime
updated_time: datetime | None = None
{% endif %}