cls.py 866 B

123456789101112131415161718192021222324252627282930
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. # File : CLS.py
  4. # Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------
  5. # Date : 2022/9/6
  6. from flask import Blueprint
  7. from controllers.classes import getClasses,getClassInfo
  8. from base.R import R
  9. from utils.log import logger
  10. from base.database import db
  11. from models.ruleclass import RuleClass
  12. cls = Blueprint("cls", __name__)
  13. @cls.route('/get/<cls>')
  14. def getClassInfoApi(cls):
  15. info = getClassInfo(cls)
  16. return R.ok(info)
  17. @cls.route('/clear/<cls>')
  18. def clearClassApi(cls):
  19. logger.info(f'开始查询{cls}的分类详情')
  20. res = db.session.query(RuleClass).filter(RuleClass.name == cls)
  21. if res:
  22. res.delete()
  23. db.session.commit()
  24. return R.success(f'已清除{cls}的分类缓存')
  25. else:
  26. return R.failed(f'数据库不存在{cls}的分类缓存')