admin.py 1.1 KB

1234567891011121314151617181920212223242526
  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="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. created_at = Column(DateTime, comment="创建时间")
  20. updated_at = Column(DateTime, comment="更新时间")
  21. # 关系
  22. operation_logs = relationship("OperationLog", back_populates="admin")