addJmsfDemo.py
1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# -*- 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