admin.py 1.2 KB

123456789101112131415161718192021222324252627
  1. """
  2. 管理员模型
  3. """
  4. from sqlalchemy import Column, Integer, String, DateTime, SmallInteger
  5. from sqlalchemy.orm import relationship
  6. from app.database import Base
  7. class Admin(Base):
  8. """管理员表"""
  9. __tablename__ = "admins"
  10. id = Column(Integer, primary_key=True, index=True, comment="主键ID")
  11. username = Column(String(50), unique=True, nullable=False, index=True, comment="管理员用户名")
  12. password = Column(String(255), nullable=False, comment="密码(加密)")
  13. real_name = Column(String(50), comment="真实姓名")
  14. email = Column(String(100), comment="邮箱")
  15. role = Column(String(20), default="super_admin", index=True, comment="角色")
  16. last_login_time = Column(DateTime, comment="最后登录时间")
  17. last_login_ip = Column(String(50), comment="最后登录IP")
  18. status = Column(SmallInteger, default=1, index=True, comment="状态:1-正常,0-禁用")
  19. is_deleted = Column(SmallInteger, default=0, index=True, comment="是否删除:0-否,1-是")
  20. created_at = Column(DateTime, comment="创建时间")
  21. updated_at = Column(DateTime, comment="更新时间")
  22. # 关系
  23. operation_logs = relationship("OperationLog", back_populates="admin")