| 123456789101112131415161718192021222324252627 |
- """
- 用户模型
- """
- from datetime import datetime
- from sqlalchemy import Column, Integer, String, DateTime, Boolean, Text, Date
- from app.database import Base
- from app.utils.timezone import beijing_now_naive
- class User(Base):
- """用户表"""
- __tablename__ = "users"
-
- id = Column(Integer, primary_key=True, autoincrement=True, comment="主键ID")
- username = Column(String(100), unique=True, nullable=False, comment="用户名")
- password = Column(String(255), nullable=False, comment="密码(bcrypt加密)")
- email = Column(String(255), nullable=True, comment="邮箱")
- machine_code = Column(String(255), nullable=True, comment="机器码(MD5)")
- card_id = Column(Integer, nullable=True, comment="当前卡密ID")
- expire_time = Column(DateTime, nullable=True, comment="到期时间")
- status = Column(Boolean, default=True, comment="状态: 1-正常, 0-禁用")
- is_deleted = Column(Boolean, default=False, comment="是否删除: 0-否, 1-是")
- created_at = Column(DateTime, default=beijing_now_naive, comment="创建时间")
- updated_at = Column(DateTime, default=beijing_now_naive, onupdate=beijing_now_naive, comment="更新时间")
-
- def __repr__(self):
- return f"<User(id={self.id}, username='{self.username}')>"
|