some_basic.py
4.87 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import os
import sys,time
import json
from commons import common as com
from commons.MySession import sy1
class get_basic_data(object):
url_listCarType = "http://test.gateway.diligrp.com:8285/jmsf-web/api/jmsf/query/listCarType"
url_cusCategory= "http://test.gateway.diligrp.com:8285/assets-service/api/cusCategory/getTree"
url_userApi= "http://test.gateway.diligrp.com:8285/dili-uap/userApi/listByExample.api"
url_prove_type= "http://test.gateway.diligrp.com:8285/jmsf-web/api/jmsf/query/listCodeByPid?pid=prove_type"
url_tradeType= "http://test.gateway.diligrp.com:8285/assets-service/api/tradeType/query"
url_goods_tag= "http://test.gateway.diligrp.com:8285/jmsf-web/api/jmsf/query/listCodeByPid?pid=goods_tag"
url_dep= "http://test.gateway.diligrp.com:8285/jmsf-web/api/jmsf/query/dep?keyword="
url_address= "http://test.gateway.diligrp.com:8285/jmsf-web/api/jmsf/query/address"
header = {
"UAP_accessToken": "demo",
"UAP_refreshToken": "demo",
"UAP_firmId": "9",
"Content-Type": "application/json",
"Content-Length": "23"}
body_listCarType = {"businessCode":"jmsf"}
body_cusCategory = {"marketId":9,"state":1}
body_userApi = {"firmCode":"sy","departmentId":58,"keyword":""}
body_tradeType = {"pageNum":100,"pageSize":100,"marketId":9}
body_address = {"province":"四川省","city":"成都市","area":None}
def __init__(self,market):
self.market=market
self.url_listCarType = get_basic_data.url_listCarType.replace("http://test.", com.get_global_config("global_data", "environment", "en"))
self.url_cusCategory = get_basic_data.url_cusCategory.replace("http://test.", com.get_global_config("global_data", "environment", "en"))
self.url_userApi = get_basic_data.url_userApi.replace("http://test.", com.get_global_config("global_data", "environment", "en"))
self.url_prove_type = get_basic_data.url_prove_type.replace("http://test.", com.get_global_config("global_data", "environment", "en"))
self.url_tradeType = get_basic_data.url_tradeType.replace("http://test.", com.get_global_config("global_data", "environment", "en"))
self.url_goods_tag = get_basic_data.url_goods_tag.replace("http://test.", com.get_global_config("global_data", "environment", "en"))
self.url_dep = get_basic_data.url_dep.replace("http://test.", com.get_global_config("global_data", "environment", "en"))
self.url_address = get_basic_data.url_address.replace("http://test.", com.get_global_config("global_data", "environment", "en"))
self.header = get_basic_data.header
self.header["UAP_accessToken"] = self.market.cookies["UAP_accessToken"]
self.header["UAP_refreshToken"] = self.market.cookies["UAP_refreshToken"]
self.header["UAP_firmId"] = self.market.cookies["UAP_firmId"]
def car_list(self):
"车型"
h=self.header.copy()
re = self.market.post(url=self.url_listCarType, headers=h,json=self.body_listCarType)
# print(re.json())
return re.json()
def cusCategory(self):
"商品"
h=self.header.copy()
re = self.market.post(url=self.url_cusCategory, headers=h,json=self.body_cusCategory)
# print(re.json())
return re.json()
def userApi(self):
"用户"
h=self.header.copy()
re = self.market.post(url=self.url_userApi, headers=h,json=self.body_userApi)
# print(re.json())
return re.json()
def prove_type(self):
"证明类型"
h=self.header.copy()
h.pop("Content-Type")
h.pop("Content-Length")
re = self.market.get(url=self.url_prove_type, headers=h)
# print(re.json())
return re.json()
def tradeType(self):
"交易类型"
h=self.header.copy()
re = self.market.post(url=self.url_tradeType, headers=h,json=self.body_tradeType)
# print(re.json())
return re.json()
def goods_tag(self):
"货物标签"
h=self.header.copy()
h.pop("Content-Type")
h.pop("Content-Length")
re = self.market.get(url=self.url_goods_tag, headers=h)
# print(re.json())
return re.json()
def dep(self):
"部门"
h=self.header.copy()
h.pop("Content-Type")
h.pop("Content-Length")
re = self.market.get(url=self.url_dep, headers=h)
# print(re.json())
return re.json()
def address(self):
"产地"
h=self.header.copy()
re = self.market.post(url=self.url_address, headers=h,json=self.body_address)
# print(re.json())
return re.json()
# a=get_basic_data(sy1)
# a.write_file(a.car_list())
# a.write_file("sy","car_list",a.car_list())
# a.read_file()
# a.car_list()
# a.cusCategory()
# a.userApi()
# a.prove_type()
# a.tradeType()
# a.goods_tag()
# a.dep()
# a.address()