addJmsfDemo.py 1.38 KB
# -*- coding: utf-8 -*-

# @Time    : 2021/7/27 16:36
# @Author  : Ljq
# @File    : jmsf.py
# @Software: PyCharm

"""
三种接口定义方式
"""

import json
from commons.scripts import dealContentType as dct
from commons import common
from commons.MySession import my

# 使用def的方式直接定义
def get_carType(host="",**kwargs):
    url = host + "/jmsf-web/api/jmsf/query/listCarType"
    data = {"businessCode":"jmsf"}
    headers = dct.jsonCode()
    data=dict(data,**kwargs)
    res = my.useHeadersRequests(method="POST",url=url,data=json.dumps(data),headers=headers)
    return res



# 使用类的方式将参数聚合
class get_carTypeClass(object):
    def __init__(self,host):
        self.method = "post"
        self.url = host + "/jmsf-web/api/jmsf/query/listCarType"
        self.data = {"businessCode": "jmsf"}
        self.headers = dct.jsonCode()

# 使用类的方式将参数聚合
class get_carTypeClassB(object):
    url = "http://test.gateway.diligrp.com:8285/jmsf-web/api/jmsf/query/listCarType"
    method = "post"
    data = {"businessCode": "jmsf"}
    headers = dct.jsonCode()

    def __init__(self):
        self.url = get_carTypeClassB.url.replace("http://test.", common.get_global_config("global_data", "environment", "en"))
        # self.header = get_carTypeClassB.headers
        # self.method = get_carTypeClassB.method
        # self.data = get_carTypeClassB.data