17 lines
565 B
Python
17 lines
565 B
Python
|
|
# -*- coding: utf-8 -*-
|
|||
|
|
# @Time : 2024/11/14 下午4:04
|
|||
|
|
# @Author : 河瞬
|
|||
|
|
# @FileName: category.py
|
|||
|
|
# @Software: PyCharm
|
|||
|
|
from tortoise.models import Model
|
|||
|
|
from tortoise import fields
|
|||
|
|
|
|||
|
|
|
|||
|
|
class Category(Model):
|
|||
|
|
id = fields.IntField(primary_key=True)
|
|||
|
|
name = fields.TextField()
|
|||
|
|
description = fields.TextField()
|
|||
|
|
# 这个类别是有分层类似树状结构的,所以需要一个field来表示父类和子类
|
|||
|
|
parent = fields.ForeignKeyField("models.Category", related_name="children", null=True)
|
|||
|
|
children = fields.ReverseRelation["Category"]
|