fastapi ResponseModel

from pydantic import BaseModel


class ResponseModel(BaseModel):
    code: int = 200
    msg: str = ""
    success: bool = True
    data: dict = None


class TaskResponseModel(ResponseModel):
    data: dict = {
        "code": 200,
        "msg": "",
        "success": True,
        "data": {
            "id": "94701f0a-9e03-4ae7-9bd4-b1e25ba7f042",
            "status": "finish",
            "visited_links": [
                "https://www.topkeemedia.com.hk/our-service"
            ],
            "other_links": [],
            "result": {
                "https://www.topkeemedia.com.hk/our-service": {
                    "data": "d7f5d45d-bcee-4717-9a78-b7834603cbc4.txt",
                    "child": {}
                }
            }
        }
    }


class TasksResponseModel(ResponseModel):
    data: dict = {
        "code": 200,
        "msg": "",
        "success": True,
        "data": {
            "0d8fd570-4d12-4b34-b7c7-57634998eae4": {
                "id": "0d8fd570-4d12-4b34-b7c7-57634998eae4",
                "status": "finish",
                "visited_links": [
                    "https://www.topkeemedia.com.hk/our-service"
                ],
                "other_links": [],
                "result": {
                    "https://www.topkeemedia.com.hk/our-service": {
                        "data": "299d4607-405c-4397-9a2d-c35a31907485.txt",
                        "child": {}
                    }
                }
            },
            "bc6f82d2-0d7e-4802-b01b-cb1c8533d026": {
                "id": "bc6f82d2-0d7e-4802-b01b-cb1c8533d026",
                "status": "finish",
                "visited_links": [
                    "https://www.topkeemedia.com.hk/our-service"
                ],
                "other_links": [],
                "result": {
                    "https://www.topkeemedia.com.hk/our-service": {
                        "data": "35ab678e-c32c-46fb-a4f2-698e5c5078d1.txt",
                        "child": {}
                    }
                }
            }
        }
    }
posted @ 2023-06-13 12:48  bitterteaer  阅读(15)  评论(0编辑  收藏  举报