| 1234567891011121314151617181920212223242526 |
- """
- 管理员模型
- """
- from sqlalchemy import Column, Integer, String, DateTime, SmallInteger
- from sqlalchemy.orm import relationship
- from app.database import Base
- class Admin(Base):
- """管理员表"""
- __tablename__ = "admins"
-
- id = Column(Integer, primary_key=True, index=True, comment="主键ID")
- username = Column(String(50), unique=True, nullable=False, index=True, comment="管理员用户名")
- password = Column(String(255), nullable=False, comment="密码(加密)")
- real_name = Column(String(50), comment="真实姓名")
- email = Column(String(100), comment="邮箱")
- role = Column(String(20), default="admin", index=True, comment="角色")
- last_login_time = Column(DateTime, comment="最后登录时间")
- last_login_ip = Column(String(50), comment="最后登录IP")
- status = Column(SmallInteger, default=1, index=True, comment="状态:1-正常,0-禁用")
- created_at = Column(DateTime, comment="创建时间")
- updated_at = Column(DateTime, comment="更新时间")
-
- # 关系
- operation_logs = relationship("OperationLog", back_populates="admin")
|