feat: 初始化仓库
This commit is contained in:
59
models/common.py
Normal file
59
models/common.py
Normal file
@@ -0,0 +1,59 @@
|
||||
# _*_ coding : UTF-8 _*_
|
||||
# @Time : 2025/01/18 02:43
|
||||
# @UpdateTime : 2025/01/18 02:43
|
||||
# @Author : sonder
|
||||
# @File : common.py
|
||||
# @Software : PyCharm
|
||||
# @Comment : 本程序
|
||||
|
||||
from tortoise import fields, models
|
||||
|
||||
|
||||
class BaseModel(models.Model):
|
||||
"""
|
||||
抽象模型,用于定义数据表的公共字段。
|
||||
"""
|
||||
|
||||
id = fields.UUIDField(pk=True, description="主键", autoincrement=True)
|
||||
"""
|
||||
自增 UUID,作为主键。
|
||||
- 使用 UUIDField 生成唯一标识符。
|
||||
"""
|
||||
|
||||
del_flag = fields.SmallIntField(default=1, description="删除标志 1存在 0删除")
|
||||
"""
|
||||
删除标志。
|
||||
- 1 代表存在,0 代表删除。
|
||||
- 默认为 1。
|
||||
"""
|
||||
|
||||
create_by = fields.CharField(max_length=255, default='', description="创建者")
|
||||
"""
|
||||
创建者。
|
||||
- 默认为空字符串。
|
||||
"""
|
||||
|
||||
create_time = fields.DatetimeField(auto_now_add=True, description="创建时间", null=True)
|
||||
"""
|
||||
创建时间。
|
||||
- 自动设置为当前时间。
|
||||
- 允许为空(null=True)。
|
||||
"""
|
||||
|
||||
update_by = fields.CharField(max_length=255, default='', description="更新者")
|
||||
"""
|
||||
更新者。
|
||||
- 默认为空字符串。
|
||||
"""
|
||||
|
||||
update_time = fields.DatetimeField(auto_now=True, description="更新时间", null=True)
|
||||
"""
|
||||
更新时间。
|
||||
- 自动更新为当前时间。
|
||||
- 允许为空(null=True)。
|
||||
"""
|
||||
|
||||
class Meta:
|
||||
abstract = True # 标记为抽象类,不会创建对应的数据库表
|
||||
ordering = ["-create_time"] # 默认按创建时间倒序排序
|
||||
indexes = ("del_flag",) # 为 del_flag 字段创建索引
|
||||
Reference in New Issue
Block a user