• flak


    from fastapi import FastAPI
    from pydantic import BaseModel
    import uvicorn
    import json
    import queryBasicInfo

    with open('./cookies.json', 'r', encoding='utf8')as ck:
    dict_cookie = json.load(ck)
    cookieA = dict_cookie['cookieA']
    cookieB = dict_cookie['cookieB']
    queryA = queryBasicInfo.query(kwargs={'cookie': cookieA})
    queryB = queryBasicInfo.query(kwargs={'cookie': cookieB})


    class Person(BaseModel):
    searchCon: str


    class BasicInfoModel(BaseModel):
    codeName: str
    codeValue: int
    pageNumber: int
    pageSize: int
    aae140: str


    class PersonNewInsured(BaseModel):
    pass


    codeModel = {
    'ac01': 'local.basicinfo.person.ac01',
    'ac01_codename': 'pcode',
    'ac01_aae140': '',

    'ac01_all': 'local.basicinfo.person.ac01',
    'ac01_all_codename': 'unitcode',
    'ac01_all_aae140': '',

    'ac02': 'local.basicinfo.person.ac02',
    'ac02_codename': 'pcode',
    'ac02_aae140': '',

    'ac02_all': 'local.basicinfo.person.ac02',
    'ac02_all_codename': 'unitcode',
    'ac02_all_aae140': '',

    'ab01': 'local.query.ab01QueryDs',
    'ab01_codename': 'aab001',
    'ab01_aae140': '',

    'ab02': 'local.query.ab02QueryDs',
    'ab02_codename': 'aab001',
    'ab02_aae140': '',

    'ab14': 'local.query.ab14DwsjQueryDs',
    'ab14_codename': 'aab001',
    'ab14_aae140': '',

    'ac43': 'local.query.ac43sj',
    'ac43_codename': 'pcode',
    'ac43_aae140': ''

    }

    app = FastAPI()


    @app.get("/siapi")
    async def main():
    return {"detail": "siapi success"}


    # 人员信息查询接口(身份证、姓名)
    @app.post("/siapi/queryPerson")
    async def queryInfo(params: Person):
    print("basicInfoModel:{}".format(params.dict()))
    data = queryA.queryPerson(params.searchCon)
    print("data len:{}".format(len(data)))
    return data


    # 单位、人员 基本信息、险种信息、实缴信息 查询接口
    @app.post("/siapi/queryBasicInfo")
    async def queryBasicInfo(basicInfoModel: BasicInfoModel):
    print("basicInfoModel:{}".format(basicInfoModel.dict()))
    if basicInfoModel.codeName in ('ac01','ac01_all', 'ac02', 'ac02_all', 'ab01', 'ab02', 'ab14','ac43'):
    params = {
    'pageNumber': basicInfoModel.pageNumber,
    'pageSize': basicInfoModel.pageSize,
    'codeFun': codeModel[basicInfoModel.codeName],
    'codeName': codeModel['{}_codename'.format(basicInfoModel.codeName)],
    'codeValue': basicInfoModel.codeValue,
    'aae140': codeModel['{}_aae140'.format(basicInfoModel.codeName)],
    }

    if basicInfoModel.codeName == 'ab14':
    if basicInfoModel.aae140 in ('11', '12', '18', '21', '31', '33', '38', '41', '51', ''):
    if basicInfoModel.aae140 != '':
    params['aae140'] = ""","aae140": ["{}", "12"]""".format(basicInfoModel.aae140)
    else:
    data = {"detail": "aae140错误"}
    return data

    if basicInfoModel.codeName == 'ac43':
    if basicInfoModel.aae140 in ('11', '12', '18', '21', '31', '33', '38', '41', '51', ''):
    if basicInfoModel.aae140 != '':
    params['aae140'] = ""","aae140": ["{}", "12"], "type": [1, 12], "who": ["2", 12]""".format(basicInfoModel.aae140)
    else:
    params['aae140'] = ""","type": [1, 12], "who": ["2", 12]"""
    else:
    data = {"detail": "aae140错误"}
    return data

    data = queryB.queryBasicInfo(params)
    else:
    data = {"detail": "codeName错误"}
    if 'rowData' in data.keys():
    print("data len:{}".format(len(data['rowData'])))
    else:
    print("data:{}".format(data))
    return data


    if __name__ == '__main__':
    uvicorn.run(app=app, host="0.0.0.0", port=8081, workers=1)

  • 相关阅读:
    立 Flag
    ASP.NET Core 3.0 一个 jwt 的轻量角色/用户、单个API控制的授权认证库
    C# Xamarin 数据绑定入门基础
    C# HttpClient 请求认证、数据传输笔记
    【PHP篇】输出方法
    【PHP篇】变量与常量
    C语言小笔记
    树莓派GPIO口的使用
    树莓派连接不上WiFi
    OLED屏幕详细使用(CC2530 & 51)
  • 原文地址:https://www.cnblogs.com/zzl0916/p/13937783.html
Copyright © 2020-2023  润新知