|
|
@ -16,6 +16,8 @@ from mock.mock_templates import * |
|
|
|
from mock.cinema_sql import * |
|
|
|
from mock.cinema_sql import * |
|
|
|
|
|
|
|
|
|
|
|
ZZ_URL = 'https://zzcs.yinghezhong.com' |
|
|
|
ZZ_URL = 'https://zzcs.yinghezhong.com' |
|
|
|
|
|
|
|
mock_config = dict() |
|
|
|
|
|
|
|
json_data = dict() |
|
|
|
|
|
|
|
|
|
|
|
# 用于将前端的接口名转换成后端的 |
|
|
|
# 用于将前端的接口名转换成后端的 |
|
|
|
api_dict = { |
|
|
|
api_dict = { |
|
|
@ -38,7 +40,8 @@ def report_ticket(request): |
|
|
|
ip = request.META.get('REMOTE_ADDR') |
|
|
|
ip = request.META.get('REMOTE_ADDR') |
|
|
|
mock_service_switch = ZZMockModel.objects.filter(ip=ip).first() |
|
|
|
mock_service_switch = ZZMockModel.objects.filter(ip=ip).first() |
|
|
|
if mock_service_switch.reportTicket is True: |
|
|
|
if mock_service_switch.reportTicket is True: |
|
|
|
mock_service.bypass(request) |
|
|
|
if customer_json := json_data.get('reportTicket'): |
|
|
|
|
|
|
|
return customer_json |
|
|
|
return mock_service.mock(ip, 'reportTicket') |
|
|
|
return mock_service.mock(ip, 'reportTicket') |
|
|
|
else: |
|
|
|
else: |
|
|
|
return mock_service.bypass(request) |
|
|
|
return mock_service.bypass(request) |
|
|
@ -50,7 +53,8 @@ def report_film_schedule(request): |
|
|
|
ip = request.META.get('REMOTE_ADDR') |
|
|
|
ip = request.META.get('REMOTE_ADDR') |
|
|
|
mock_service_switch = ZZMockModel.objects.filter(ip=ip).first() |
|
|
|
mock_service_switch = ZZMockModel.objects.filter(ip=ip).first() |
|
|
|
if mock_service_switch.reportFilmSchedule is True: |
|
|
|
if mock_service_switch.reportFilmSchedule is True: |
|
|
|
mock_service.bypass(request) |
|
|
|
if customer_json := json_data.get('reportFilmSchedule'): |
|
|
|
|
|
|
|
return customer_json |
|
|
|
return mock_service.mock(ip, 'reportFilmSchedule') |
|
|
|
return mock_service.mock(ip, 'reportFilmSchedule') |
|
|
|
else: |
|
|
|
else: |
|
|
|
return mock_service.bypass(request) |
|
|
|
return mock_service.bypass(request) |
|
|
@ -62,7 +66,8 @@ def upload_screen_seat_info(request): |
|
|
|
ip = request.META.get('REMOTE_ADDR') |
|
|
|
ip = request.META.get('REMOTE_ADDR') |
|
|
|
mock_service_switch = ZZMockModel.objects.filter(ip=ip).first() |
|
|
|
mock_service_switch = ZZMockModel.objects.filter(ip=ip).first() |
|
|
|
if mock_service_switch.uploadScreenSeatInfo is True: |
|
|
|
if mock_service_switch.uploadScreenSeatInfo is True: |
|
|
|
mock_service.bypass(request) |
|
|
|
if customer_json := json_data.get('uploadScreenSeatInfo'): |
|
|
|
|
|
|
|
return customer_json |
|
|
|
return mock_service.mock(ip, 'uploadScreenSeatInfo') |
|
|
|
return mock_service.mock(ip, 'uploadScreenSeatInfo') |
|
|
|
else: |
|
|
|
else: |
|
|
|
return mock_service.bypass(request) |
|
|
|
return mock_service.bypass(request) |
|
|
@ -74,6 +79,8 @@ def download_film_info(request): |
|
|
|
ip = request.META.get('REMOTE_ADDR') |
|
|
|
ip = request.META.get('REMOTE_ADDR') |
|
|
|
mock_service_switch = ZZMockModel.objects.filter(ip=ip).first() |
|
|
|
mock_service_switch = ZZMockModel.objects.filter(ip=ip).first() |
|
|
|
if mock_service_switch.downloadFilmInfo is True: |
|
|
|
if mock_service_switch.downloadFilmInfo is True: |
|
|
|
|
|
|
|
if customer_json := json_data.get('downloadFilmInfo'): |
|
|
|
|
|
|
|
return customer_json |
|
|
|
return mock_service.mock(ip, 'downloadFilmInfo') |
|
|
|
return mock_service.mock(ip, 'downloadFilmInfo') |
|
|
|
else: |
|
|
|
else: |
|
|
|
return mock_service.bypass(request) |
|
|
|
return mock_service.bypass(request) |
|
|
@ -84,6 +91,8 @@ def get_cinema_info(request): |
|
|
|
ip = request.META.get('REMOTE_ADDR') |
|
|
|
ip = request.META.get('REMOTE_ADDR') |
|
|
|
mock_service_switch = ZZMockModel.objects.filter(ip=ip).first() |
|
|
|
mock_service_switch = ZZMockModel.objects.filter(ip=ip).first() |
|
|
|
if mock_service_switch.getCinemaInfo is True: |
|
|
|
if mock_service_switch.getCinemaInfo is True: |
|
|
|
|
|
|
|
if customer_json := json_data.get('getCinemaInfo'): |
|
|
|
|
|
|
|
return customer_json |
|
|
|
return mock_service.mock(ip, 'getCinemaInfo') |
|
|
|
return mock_service.mock(ip, 'getCinemaInfo') |
|
|
|
else: |
|
|
|
else: |
|
|
|
return mock_service.bypass(request) |
|
|
|
return mock_service.bypass(request) |
|
|
@ -94,6 +103,8 @@ def get_screen_info(request): |
|
|
|
ip = request.META.get('REMOTE_ADDR') |
|
|
|
ip = request.META.get('REMOTE_ADDR') |
|
|
|
mock_service_switch = ZZMockModel.objects.filter(ip=ip).first() |
|
|
|
mock_service_switch = ZZMockModel.objects.filter(ip=ip).first() |
|
|
|
if mock_service_switch.getScreenInfo is True: |
|
|
|
if mock_service_switch.getScreenInfo is True: |
|
|
|
|
|
|
|
if customer_json := json_data.get('getScreenInfo'): |
|
|
|
|
|
|
|
return customer_json |
|
|
|
return mock_service.mock(ip, 'getScreenInfo') |
|
|
|
return mock_service.mock(ip, 'getScreenInfo') |
|
|
|
else: |
|
|
|
else: |
|
|
|
return mock_service.bypass(request) |
|
|
|
return mock_service.bypass(request) |
|
|
@ -106,8 +117,8 @@ def get_overtime_ticket_status(request): |
|
|
|
ip = request.META.get('REMOTE_ADDR') |
|
|
|
ip = request.META.get('REMOTE_ADDR') |
|
|
|
mock_service_switch = ZZMockModel.objects.filter(ip=ip).first() |
|
|
|
mock_service_switch = ZZMockModel.objects.filter(ip=ip).first() |
|
|
|
if mock_service_switch.getOvertimeTicketStatus is True: |
|
|
|
if mock_service_switch.getOvertimeTicketStatus is True: |
|
|
|
r = mock_service.mock(ip, 'getOvertimeTicketStatus', request=request) |
|
|
|
if customer_json := json_data.get('getOvertimeTicketStatus'): |
|
|
|
print('r', r) |
|
|
|
return customer_json |
|
|
|
return mock_service.mock(ip, 'getOvertimeTicketStatus', request=request) |
|
|
|
return mock_service.mock(ip, 'getOvertimeTicketStatus', request=request) |
|
|
|
else: |
|
|
|
else: |
|
|
|
return mock_service.bypass(request) |
|
|
|
return mock_service.bypass(request) |
|
|
@ -119,6 +130,8 @@ def valid_error(request): |
|
|
|
ip = request.META.get('REMOTE_ADDR') |
|
|
|
ip = request.META.get('REMOTE_ADDR') |
|
|
|
mock_service_switch = ZZMockModel.objects.filter(ip=ip).first() |
|
|
|
mock_service_switch = ZZMockModel.objects.filter(ip=ip).first() |
|
|
|
if mock_service_switch.validError is True: |
|
|
|
if mock_service_switch.validError is True: |
|
|
|
|
|
|
|
if customer_json := json_data.get('validError'): |
|
|
|
|
|
|
|
return customer_json |
|
|
|
return mock_service.mock(ip, 'validError') |
|
|
|
return mock_service.mock(ip, 'validError') |
|
|
|
else: |
|
|
|
else: |
|
|
|
return mock_service.bypass(request) |
|
|
|
return mock_service.bypass(request) |
|
|
@ -228,11 +241,15 @@ def set_overtime_config(request): |
|
|
|
@csrf_exempt |
|
|
|
@csrf_exempt |
|
|
|
def enable_mock(request): |
|
|
|
def enable_mock(request): |
|
|
|
ip = request.GET.get('ip') |
|
|
|
ip = request.GET.get('ip') |
|
|
|
req_mock_config = json.loads(request.body)['mock_config'] |
|
|
|
req = json.loads(request.body) |
|
|
|
mock_config = dict() |
|
|
|
req_mock_config = req['mock_config'] |
|
|
|
|
|
|
|
req_json_data = req['json_data'] |
|
|
|
for k, v in req_mock_config.items(): |
|
|
|
for k, v in req_mock_config.items(): |
|
|
|
mock_config[api_dict[k]] = v |
|
|
|
mock_config[api_dict[k]] = v |
|
|
|
|
|
|
|
for k, v in req_json_data.items(): |
|
|
|
|
|
|
|
json_data[api_dict[k]] = v |
|
|
|
print(mock_config) |
|
|
|
print(mock_config) |
|
|
|
|
|
|
|
print(json_data) |
|
|
|
server_ip = get_local_ip() |
|
|
|
server_ip = get_local_ip() |
|
|
|
current_host = db(ip, GET_ZZ_PLATFORM_HOST_SQL)['data'][0]['cinema_common_info_val'] |
|
|
|
current_host = db(ip, GET_ZZ_PLATFORM_HOST_SQL)['data'][0]['cinema_common_info_val'] |
|
|
|
if current_host == 'https://zzcs.yinghezhong.com' or current_host == 'https://dy.yinghezhong.com': |
|
|
|
if current_host == 'https://zzcs.yinghezhong.com' or current_host == 'https://dy.yinghezhong.com': |
|
|
|