117 lines
5.0 KiB
Python
117 lines
5.0 KiB
Python
import uuid
|
||
from tortoise import fields
|
||
from tortoise.models import Model
|
||
|
||
|
||
class Shop(Model):
|
||
"""
|
||
店铺模型
|
||
|
||
字段:
|
||
id (UUIDField): 主键,默认使用 UUID 生成
|
||
province (CharField): 省份,最大长度 255
|
||
city (CharField): 城市,最大长度 255
|
||
street (CharField): 街道,最大长度 255
|
||
shop_name (CharField): 店铺名称,最大长度 255
|
||
shop_number (CharField): 店铺号码,最大长度 255, nullable 为 True
|
||
"""
|
||
id = fields.UUIDField(pk=True, default=uuid.uuid4, description="ID")
|
||
province = fields.CharField(max_length=255, null=True, index=True, description="省份")
|
||
city = fields.CharField(max_length=255, index=True, description="城市")
|
||
street = fields.CharField(max_length=255, index=True, description="街道")
|
||
shop_name = fields.CharField(max_length=255, index=True, description="店铺名称")
|
||
shop_number = fields.CharField(max_length=255, null=True, description="店铺号码")
|
||
create_time = fields.DatetimeField(auto_now_add=True, index=True, description='创建时间')
|
||
update_time = fields.DatetimeField(auto_now=True, description='更新时间')
|
||
|
||
|
||
class Meta:
|
||
table = "shop"
|
||
table_description = "店铺表"
|
||
ordering = ["create_time"]
|
||
indexes = [
|
||
("province", "city", "street"),
|
||
]
|
||
def __repr__(self):
|
||
return f"<Shop(id={self.id}, province={self.province}, city={self.city}, street={self.street}, shop_name={self.shop_name})>"
|
||
|
||
__str__ = __repr__
|
||
|
||
class Food(Model):
|
||
"""
|
||
食物模型
|
||
|
||
字段:
|
||
id (UUIDField): 主键,默认使用 UUID 生成
|
||
name (CharField): 食物名称,最大长度 255
|
||
"""
|
||
id = fields.UUIDField(pk=True, default=uuid.uuid4, description="ID")
|
||
name = fields.CharField(max_length=255, index=True, description="食物名称")
|
||
create_time = fields.DatetimeField(auto_now_add=True, index=True, description='创建时间')
|
||
update_time = fields.DatetimeField(auto_now=True, description='更新时间')
|
||
|
||
|
||
class Meta:
|
||
table = "food"
|
||
table_description = "食物表"
|
||
ordering = ["create_time"]
|
||
indexes = [
|
||
("name",),
|
||
]
|
||
def __repr__(self):
|
||
return f"<Food(id={self.id}, name={self.name})>"
|
||
|
||
__str__ = __repr__
|
||
|
||
|
||
class Info(Model):
|
||
"""
|
||
信息模型(孩子与家长字段)
|
||
|
||
字段:
|
||
id (UUIDField): 主键,默认使用 UUID 生成
|
||
child_full_name (CharField): 孩子全名,最大长度 255
|
||
parent_full_name (CharField): 家长全名,最大长度 255
|
||
child_birthday (CharField): 孩子生日(原始字符串),最大长度 32
|
||
address_str (CharField): 街道地址,最大长度 255
|
||
city_name (CharField): 城市,最大长度 255
|
||
parent_phone (CharField): 家长电话,最大长度 64
|
||
postcode (CharField): 邮编,最大长度 20
|
||
province (CharField): 省/州全称,最大长度 255
|
||
status (BooleanField): 状态,默认值 False
|
||
email (CharField): 邮箱,最大长度 255, nullable 为 True
|
||
text (TextField): 文本内容, nullable 为 True
|
||
|
||
"""
|
||
id = fields.UUIDField(pk=True, default=uuid.uuid4, description="ID")
|
||
child_full_name = fields.CharField(max_length=255, index=True, description="孩子全名")
|
||
parent_full_name = fields.CharField(max_length=255, index=True, description="家长全名")
|
||
child_birthday = fields.CharField(max_length=32, description="孩子生日")
|
||
address_str = fields.CharField(max_length=255, index=True, description="街道地址")
|
||
city_name = fields.CharField(max_length=255, index=True, description="城市")
|
||
parent_phone = fields.CharField(max_length=64, description="家长电话")
|
||
postcode = fields.CharField(max_length=20, index=True, description="邮编")
|
||
province = fields.CharField(max_length=255, index=True, description="省/州全称")
|
||
status = fields.BooleanField(default=False, description="状态")
|
||
# 邮件内容
|
||
email = fields.CharField(max_length=255, unique=True, index=True, description="邮箱")
|
||
email_content = fields.TextField(null=True, description="邮件内容")
|
||
text = fields.TextField(null=True, description="文本内容")
|
||
create_time = fields.DatetimeField(auto_now_add=True, index=True, description='创建时间')
|
||
update_time = fields.DatetimeField(auto_now=True, description='更新时间')
|
||
|
||
|
||
class Meta:
|
||
table = "info"
|
||
table_description = "信息表"
|
||
ordering = ["create_time"]
|
||
indexes = [
|
||
("city_name", "postcode", "province"),
|
||
("child_full_name", "parent_full_name"),
|
||
]
|
||
|
||
def __repr__(self):
|
||
return f"<Info(id={self.id}, child_full_name={self.child_full_name}, parent_full_name={self.parent_full_name}, child_birthday={self.child_birthday}, address_str={self.address_str}, city_name={self.city_name}, parent_phone={self.parent_phone}, postcode={self.postcode}, province={self.province})>"
|
||
|
||
__str__ = __repr__
|