table_vacuate_detail.py 1.6 KB
# author:        4N
# createtime:    2021/1/27
# email:         nheweijun@sina.com


from ..models import Table,TableVacuate,Task
from app.util.component.ApiTemplate import ApiTemplate
from app.util.component.VacuateConf import VacuateConf


import copy
class Api(ApiTemplate):
    api_name = "抽稀Detail"
    def process(self):

        res = {}
        try:
            res["data"] = []
            table_guids = self.para.get("table_guids")

            for table_guid in table_guids.split(","):

                detail = {"table_guid":table_guid}
                table: Table = Table.query.filter_by(guid=table_guid).one_or_none()
                if table:
                    tvs = TableVacuate.query.filter_by(table_guid=table_guid).all()
                    detail["table_name"] = table.name
                    detail["vacuate_count"] = len(tvs)
                    detail["table_vacuate"] = [{"name":tv.name,"pixel_distance":tv.pixel_distance,"connectstr":tv.connectstr} for tv in tvs]

                res["data"].append(detail)
            res["result"] = True
        except Exception as e:
            raise e
        return res

    api_doc = {
        "tags": ["管理接口"],
        "parameters": [
            {"name": "table_guids",
             "in": "formData",
             "type": "string",
             "description": "表guid", "required": "true"},
        ],
        "responses": {
            200: {
                "schema": {
                    "properties": {
                    }
                }
            }
        }
    }