zoukankan      html  css  js  c++  java
  • 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)

  • 相关阅读:
    【Mesh R-CNN】论文翻译(原理部分)
    关于栈的学习记录
    css入门笔记
    前端学习之html基础知识归纳
    navigator url无法跳转跳转问题
    新手小白学会vim脚本配置
    Linux下实现两个变量之间传参
    [Apache Doris] Apache Doris 架构及代码目录解读
    [编程总结] 开源系统平台化建设思路
    论文阅读|PointRend: Image Segmentation as Rendering
  • 原文地址:https://www.cnblogs.com/zzl0916/p/13937783.html
Copyright © 2011-2022 走看看