service_state.py 1.2 KB
# coding=utf-8
#author:        4N
#createtime:    2021/9/14
#email:         nheweijun@sina.com




from app.util.component.ApiTemplate import ApiTemplate
from app.models import Service,db
class Api(ApiTemplate):
    api_name = "修改服务状态"
    def process(self):
        res = {}
        try:
            guid = self.para.get("guid")
            state = int(self.para.get("state"))
            Service.query.filter_by(guid=guid).update({"state":state})

            # 清理缓存,拒绝服务

            db.session.commit()
            res["result"] = True
        except Exception as e:
            raise e
        return res


    api_doc = {
        "tags": ["服务接口"],
        "parameters": [
            {"name": "guid",
             "in": "formData",
             "type": "string",
             "description": "guid"},
            {"name": "state",
             "in": "formData",
             "type": "int",
             "description": "state"},
        ],
        "responses": {
            200: {
                "schema": {
                    "properties": {
                    }
                }
            }
        }
    }