sys_log.py 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. from datetime import datetime
  2. from sqlalchemy import BigInteger, Column, DateTime, Index, Integer, String
  3. from domain.models.base_model import BaseModel
  4. class SysLoginLogModel(BaseModel):
  5. """
  6. 系统访问记录
  7. """
  8. __tablename__ = "sys_login_log"
  9. username = Column(String(50), nullable=True, default="", comment="用户账号")
  10. ipaddr = Column(String(128), nullable=True, default="", comment="登录IP地址")
  11. login_location = Column(String(255), nullable=True, default="", comment="登录地点")
  12. browser = Column(String(50), nullable=True, default="", comment="浏览器类型")
  13. os = Column(String(50), nullable=True, default="", comment="操作系统")
  14. status = Column(
  15. Integer, nullable=False, default=0, comment="登录状态(0成功 1失败)"
  16. )
  17. msg = Column(String(255), nullable=True, default="", comment="提示消息")
  18. login_time = Column(
  19. DateTime, nullable=True, default=datetime.now(), comment="访问时间"
  20. )
  21. idx_sys_login_log_s = Index("idx_sys_login_log_s", "status")
  22. idx_sys_login_log_lt = Index("idx_sys_login_log_lt", "login_time")
  23. class SysOperLogModel(BaseModel):
  24. """
  25. 操作日志记录
  26. """
  27. __tablename__ = "sys_oper_log"
  28. title = Column(String(50), nullable=True, default="", comment="模块标题")
  29. business_type = Column(
  30. Integer, default=0, comment="业务类型(0其它 1新增 2修改 3删除)"
  31. )
  32. method = Column(String(100), nullable=True, default="", comment="方法名称")
  33. request_method = Column(String(10), nullable=True, default="", comment="请求方式")
  34. operator_type = Column(
  35. Integer, default=0, comment="操作类别(0其它 1后台用户 2手机端用户)"
  36. )
  37. oper_name = Column(String(50), nullable=True, default="", comment="操作人员")
  38. dept_id = Column(String(50), nullable=True, default="", comment="部门ID")
  39. dept_name = Column(String(50), nullable=True, default="", comment="部门名称")
  40. oper_url = Column(String(255), nullable=True, default="", comment="请求URL")
  41. oper_ip = Column(String(128), nullable=True, default="", comment="主机地址")
  42. oper_location = Column(String(255), nullable=True, default="", comment="操作地点")
  43. oper_param = Column(String(2000), nullable=True, default="", comment="请求参数")
  44. json_result = Column(String(2000), nullable=True, default="", comment="返回参数")
  45. status = Column(Integer, default=0, comment="操作状态(0正常 1异常)")
  46. error_msg = Column(String(2000), nullable=True, default="", comment="错误消息")
  47. oper_time = Column(
  48. DateTime, nullable=True, default=datetime.now(), comment="操作时间"
  49. )
  50. cost_time = Column(BigInteger, default=0, comment="消耗时间")
  51. idx_sys_oper_log_bt = Index("idx_sys_oper_log_bt", "business_type")
  52. idx_sys_oper_log_s = Index("idx_sys_oper_log_s", "status")
  53. idx_sys_oper_log_ot = Index("idx_sys_oper_log_ot", "oper_time")