0.0.3
This commit is contained in:
116
back/apis/country/models.py
Normal file
116
back/apis/country/models.py
Normal file
@@ -0,0 +1,116 @@
|
||||
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, 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 生成
|
||||
first_name (CharField): 名,最大长度 255
|
||||
last_name (CharField): 姓,最大长度 255
|
||||
birthday (CharField): 生日(原始字符串),最大长度 32
|
||||
current_address (CharField): 街道地址,最大长度 255
|
||||
city (CharField): 城市,最大长度 255
|
||||
phone (CharField): 电话,最大长度 64
|
||||
postal_code (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")
|
||||
first_name = fields.CharField(max_length=255, index=True, description="名")
|
||||
last_name = fields.CharField(max_length=255, index=True, description="姓")
|
||||
birthday = fields.CharField(max_length=32, description="生日")
|
||||
current_address = fields.CharField(max_length=255, index=True, description="街道地址")
|
||||
city = fields.CharField(max_length=255, index=True, description="城市")
|
||||
phone = fields.CharField(max_length=64, description="电话")
|
||||
postal_code = 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", "postal_code", "province"),
|
||||
("first_name", "last_name"),
|
||||
]
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Info(id={self.id}, firstname={self.firstname}, lastname={self.lastname}, full_name={self.full_name}, birthday={self.birthday}, street_address={self.street_address}, city={self.city}, phone={self.phone}, zip_code={self.zip_code}, state_fullname={self.state_fullname})>"
|
||||
|
||||
__str__ = __repr__
|
||||
Reference in New Issue
Block a user