三方接口处理问题

This commit is contained in:
曹前明 2022-10-03 14:13:58 +08:00
parent f7b8186e55
commit 574254f7bc
2 changed files with 2 additions and 4 deletions

View File

@ -82,6 +82,7 @@ class DhClient:
timeout=timeout, files=files, verify=False)
# if settings.DEBUG:
# print_roundtrip(r)
ret = r.text
if r.status_code == 200:
ret = r.json()
if ret['code'] not in ['0', '100', '00000', '1000', 0, 100, 1000]:
@ -95,8 +96,6 @@ class DhClient:
return 'fail', err_detail
# self.handle_log(result='success', response=ret) # 成功的日志就不记录了
return 'success', ret['data'] if 'data' in ret else None
else:
ret = r.text
self.handle_log(result='error', response=ret)
if raise_exception:
raise APIException(**DH_REQUEST_ERROR)

View File

@ -78,6 +78,7 @@ class SpClient:
timeout=timeout, files=files, verify=False)
# if settings.DEBUG:
# print_roundtrip(r)
ret = r.text
if r.status_code == 200:
ret = r.json()
if 'code' in ret and ret['code'] not in ['0', '100', '00000', '1000', 0, 100, 1000]:
@ -89,8 +90,6 @@ class SpClient:
return 'fail', err_detail
# self.handle_log(result='success', response=ret)
return 'success', ret
else:
ret = r.text
self.handle_log(result='error', response=ret)
if raise_exception:
raise APIException(**SP_REQUEST_ERROR)