ruleclass.py 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # File : ruleclass.py
  4. # Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------
  5. # Date : 2022/9/6
  6. from base.database import db
  7. from datetime import datetime
  8. class RuleClass(db.Model):
  9. __tablename__ = 'rule_class'
  10. id = db.Column(db.Integer, primary_key=True, autoincrement=True)
  11. name = db.Column(db.String(20), unique=True)
  12. class_name = db.Column(db.String(255))
  13. class_url = db.Column(db.String(255))
  14. cookie = db.Column(db.String(255))
  15. state = db.Column(db.Integer, default=1)
  16. order = db.Column(db.Integer, default=0)
  17. create_date = db.Column(db.DateTime, index=True, default=datetime.now)
  18. write_date = db.Column(db.DateTime, index=True, default=datetime.now,onupdate=datetime.now)
  19. def __repr__(self):
  20. return "<RuleClass(name='%s', class_name='%s', class_url='%s',cookie='%s')>" % (
  21. self.name, self.class_name, self.class_url, self.cookie)
  22. @classmethod
  23. def hasItem(self, key):
  24. exists = db.session.query(self).filter(self.name == key).scalar() is not None
  25. if exists:
  26. return True
  27. else:
  28. return False