添加启动mock的逻辑

main
RogerWork 11 months ago
parent b4e22e3f07
commit 087f20dc10
  1. 18
      mock/migrations/0003_rename_auditsessioncode_zzmockmodel_auditshowid.py
  2. 16
      mock/views.py

@ -0,0 +1,18 @@
# Generated by Django 4.2.7 on 2023-12-22 10:06
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('mock', '0002_zzmockmodel_auditsessioncode_zzmockmodel_auditstatus'),
]
operations = [
migrations.RenameField(
model_name='zzmockmodel',
old_name='auditSessionCode',
new_name='auditShowId',
),
]

@ -171,16 +171,32 @@ def get_local_ip():
return ip
# {
# 'reportTicket': '',
# 'reportFilmSchedule': '',
# 'uploadScreenSeatInfo': '',
# 'downloadFilmInfo': '',
# 'getCinemaInfo': '',
# 'getScreenInfo': '',
# 'getOvertimeTicketStatus': '',
# 'validError': '',
# 'auditShowId': '',
# 'auditStatus': ''
# }
# 启动mock
def enable_mock(request):
ip = request.query_params.dict().get('ip')
mock_config = request.query_params.dict().get('mock_config')
server_ip = get_local_ip()
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':
db_result = db(ip, UPDATE_ZZ_PLATFORM_HOST_SQL, (f'http://{server_ip}:8000',))
if db_result['result'] > 0:
ZZMockModel.objects.filter(ip=ip).update(**mock_config)
return JsonResponse({'status': 'success'})
if current_host == f'http://{server_ip}:8000':
ZZMockModel.objects.filter(ip=ip).update(**mock_config)
return JsonResponse({'status': 'success'})
return JsonResponse({'status': 'fail'})

Loading…
Cancel
Save