|
|
|
@ -21,7 +21,6 @@ from dspt_api.serializers import EcChannelSerializer, EcEnvSerializer, EcApiSeri |
|
|
|
|
from dspt_api.util.suggest_params import suggest_params |
|
|
|
|
from dspt_api.util.general.handle_xml_resp import HandleXmlResp |
|
|
|
|
from dspt_api.util.general.format_xml import format_xml |
|
|
|
|
import chardet |
|
|
|
|
|
|
|
|
|
# Create your views here. |
|
|
|
|
class EcChannelViewSet(viewsets.ModelViewSet): |
|
|
|
@ -184,7 +183,6 @@ def send_request(request): |
|
|
|
|
web_req = json.loads(request.body) |
|
|
|
|
api = web_req.get('api') |
|
|
|
|
redis_key_api = f'dspt_api_{user_ip}_{member_type}_{api}' |
|
|
|
|
# redis_key_user_data = f'dspt_api_{user_ip}_{api}_data' |
|
|
|
|
|
|
|
|
|
# 发送请求 |
|
|
|
|
req, sig = handle_request(request) |
|
|
|
@ -218,7 +216,6 @@ def send_request(request): |
|
|
|
|
} |
|
|
|
|
print(data) |
|
|
|
|
redis_conn.set(redis_key_api, json.dumps(data), 10 * 60 * 60) |
|
|
|
|
# redis_conn.delete(redis_key_user_data) |
|
|
|
|
# 插入数据 |
|
|
|
|
db_data = { |
|
|
|
|
'ip': user_ip, |
|
|
|
@ -247,19 +244,21 @@ def set_user_select_data(request): |
|
|
|
|
req = json.loads(request.body) |
|
|
|
|
api = req.get('api') |
|
|
|
|
member_type = req.get('member_type') |
|
|
|
|
resp_format = req.get('format') |
|
|
|
|
resp_format = 'xml' if req.get('format') == 'html' else req.get('format') |
|
|
|
|
user_data = req.get('user_data') |
|
|
|
|
user_ip = request.META.get('REMOTE_ADDR') |
|
|
|
|
# 初始化redis |
|
|
|
|
redis_conn = get_redis_connection() |
|
|
|
|
redis_key_user_data = f'dspt_api_{user_ip}_{member_type}_{api}_user_data' |
|
|
|
|
print('user_data', user_data) |
|
|
|
|
# 记录用户选择 |
|
|
|
|
data = { |
|
|
|
|
'api': api, |
|
|
|
|
'member_type': member_type, |
|
|
|
|
'format': resp_format, |
|
|
|
|
'user_data': user_data, |
|
|
|
|
'user_data': [json.loads(user_data)], |
|
|
|
|
} |
|
|
|
|
print('set_user_select_data', data) |
|
|
|
|
if redis_conn.exists(redis_key_user_data): |
|
|
|
|
redis_conn.delete(redis_key_user_data) |
|
|
|
|
if redis_conn.set(redis_key_user_data, json.dumps(data), 10 * 60 * 60): |
|
|
|
|