some_basic.py 4.87 KB
#!/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()