121 lines
3.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# _*_ coding : UTF-8 _*_
# @Time : 2025/01/18 03:21
# @UpdateTime : 2025/01/18 03:21
# @Author : sonder
# @File : department.py
# @Software : PyCharm
# @Comment : 本程序
from tortoise import fields
from models.common import BaseModel
class Department(BaseModel):
"""
部门表模型。
"""
name = fields.CharField(
max_length=100,
description="部门名称",
source_field="name" # 映射到数据库字段 name
)
"""
部门名称。
- 最大长度为 100 个字符。
- 映射到数据库字段 name。
"""
parent_id = fields.CharField(
max_length=36,
default="",
null=True,
description="父部门ID",
source_field="parent_id" # 映射到数据库字段 parent_id
)
"""
父部门ID。
- 用于表示部门的层级关系。
- 默认为空字符串,表示顶级部门。
- 映射到数据库字段 parent_id。
"""
sort = fields.IntField(
default=0,
description="排序权重0最高",
source_field="sort" # 映射到数据库字段 sort
)
"""
排序权重。
- 用于部门列表的排序,值越小越靠前。
- 默认为 0。
- 映射到数据库字段 sort。
"""
phone = fields.CharField(
max_length=30,
null=True,
description="部门电话",
source_field="phone" # 映射到数据库字段 phone
)
"""
部门电话。
- 最大长度为 30 个字符。
- 允许为空。
- 映射到数据库字段 phone。
"""
principal = fields.CharField(
max_length=64,
description="部门负责人",
source_field="principal" # 映射到数据库字段 principal
)
"""
部门负责人。
- 最大长度为 64 个字符。
- 映射到数据库字段 principal。
"""
email = fields.CharField(
max_length=128,
null=True,
description="部门邮箱",
source_field="email" # 映射到数据库字段 email
)
"""
部门邮箱。
- 最大长度为 128 个字符。
- 允许为空。
- 映射到数据库字段 email。
"""
status = fields.SmallIntField(
default=1,
description="状态0正常 1停用",
source_field="status" # 映射到数据库字段 status
)
"""
状态。
- 1 表示正常0 表示停用。
- 默认为 1。
- 映射到数据库字段 status。
"""
remark = fields.CharField(
max_length=255,
null=True,
description="备注信息",
source_field="remark" # 映射到数据库字段 remark
)
"""
备注信息。
- 最大长度为 255 个字符。
- 允许为空。
- 映射到数据库字段 remark。
"""
class Meta:
table = "department" # 数据库表名
table_description = "部门表" # 表描述
ordering = ["sort", "-create_time"] # 默认按排序权重和创建时间排序