guzhi/app/models/user.py

44 lines
2.4 KiB
Python

from tortoise import fields
from app.schemas.menus import MenuType
from .base import BaseModel, TimestampMixin
from .enums import MethodType
class AppUser(BaseModel, TimestampMixin):
username = fields.CharField(max_length=20, unique=True, null=True, description="用户名称", index=True)
alias = fields.CharField(max_length=30, null=True, description="姓名", index=True)
email = fields.CharField(max_length=255, unique=True, null=True, description="邮箱", index=True)
phone = fields.CharField(max_length=20, unique=True, description="手机号", index=True)
password = fields.CharField(max_length=128, description="密码")
company_name = fields.CharField(max_length=100, null=True, description="公司名称", index=True)
company_address = fields.CharField(max_length=255, null=True, description="公司地址")
company_contact = fields.CharField(max_length=50, null=True, description="公司联系人")
company_phone = fields.CharField(max_length=20, null=True, description="公司电话")
company_email = fields.CharField(max_length=100, null=True, description="公司邮箱")
is_active = fields.BooleanField(default=True, description="是否激活", index=True)
last_login = fields.DatetimeField(null=True, description="最后登录时间", index=True)
remaining_quota = fields.IntField(default=0, description="剩余估值次数", index=True)
notes = fields.CharField(max_length=256, null=True, description="备注")
is_deleted = fields.BooleanField(default=False, description="是否已注销", index=True)
deleted_at = fields.DatetimeField(null=True, description="注销时间", index=True)
class Meta:
table = "app_user"
table_description = "用户表"
class AppUserQuotaLog(BaseModel, TimestampMixin):
app_user_id = fields.IntField(description="App用户ID", index=True)
operator_id = fields.IntField(description="操作人ID", index=True)
operator_name = fields.CharField(max_length=64, description="操作人")
before_count = fields.IntField(description="变更前次数")
after_count = fields.IntField(description="变更后次数")
op_type = fields.CharField(max_length=32, description="操作类型")
remark = fields.CharField(max_length=256, null=True, description="备注")
class Meta:
table = "app_user_quota_log"
table_description = "App用户估值次数操作日志"