diff --git a/logs/dingxin.log b/logs/dingxin.log index 0fddf2f..a8ac3dc 100644 --- a/logs/dingxin.log +++ b/logs/dingxin.log @@ -2737,3 +2737,33 @@ INFO 2023-12-21 15:16:16,941 autoreload 668 Watching for file changes with StatR INFO 2023-12-21 15:17:03,542 basehttp 212 "POST /report/reportTicket HTTP/1.1" 200 75 INFO 2023-12-21 15:17:09,530 autoreload 266 D:\Code\Work\Python\dingxin_toolbox_drf\mock\views.py changed, reloading. INFO 2023-12-21 15:17:10,490 autoreload 668 Watching for file changes with StatReloader +INFO 2023-12-21 16:02:19,014 basehttp 212 "POST /report/reportTicket HTTP/1.1" 200 75 +INFO 2023-12-21 16:05:07,439 basehttp 212 "POST /report/reportTicket HTTP/1.1" 200 75 +INFO 2023-12-21 16:21:05,331 basehttp 212 "POST /report/reportTicket HTTP/1.1" 200 75 +INFO 2023-12-21 16:21:59,100 basehttp 212 "POST /report/reportTicket HTTP/1.1" 200 75 +INFO 2023-12-21 16:51:58,054 basehttp 212 "POST /report/reportTicket HTTP/1.1" 200 75 +INFO 2023-12-21 16:55:30,019 autoreload 266 D:\Code\Work\Python\dingxin_toolbox_drf\mock\views.py changed, reloading. +INFO 2023-12-21 16:55:31,173 autoreload 668 Watching for file changes with StatReloader +INFO 2023-12-21 17:02:03,632 basehttp 212 "POST /report/reportTicket HTTP/1.1" 200 75 +INFO 2023-12-21 17:22:29,687 basehttp 212 "POST /report/reportTicket HTTP/1.1" 200 75 +INFO 2023-12-21 17:24:10,133 basehttp 212 "POST /report/reportTicket HTTP/1.1" 200 75 +INFO 2023-12-21 17:24:48,411 basehttp 212 "POST /report/reportTicket HTTP/1.1" 200 75 +INFO 2023-12-21 17:25:26,945 basehttp 212 "POST /report/reportTicket HTTP/1.1" 200 75 +INFO 2023-12-21 17:26:35,456 basehttp 212 "POST /report/reportTicket HTTP/1.1" 200 75 +INFO 2023-12-21 17:38:39,443 basehttp 212 "POST /report/reportTicket HTTP/1.1" 200 75 +INFO 2023-12-21 17:40:34,006 autoreload 266 D:\Code\Work\Python\dingxin_toolbox_drf\mock\utils\mock_service.py changed, reloading. +INFO 2023-12-21 17:40:34,992 autoreload 668 Watching for file changes with StatReloader +INFO 2023-12-21 17:43:15,582 autoreload 266 D:\Code\Work\Python\dingxin_toolbox_drf\mock\mock_templates\report_film_schedule_tmp.py changed, reloading. +INFO 2023-12-21 17:43:16,614 autoreload 668 Watching for file changes with StatReloader +INFO 2023-12-21 17:46:19,828 autoreload 266 D:\Code\Work\Python\dingxin_toolbox_drf\mock\urls.py changed, reloading. +INFO 2023-12-21 17:46:20,796 autoreload 668 Watching for file changes with StatReloader +INFO 2023-12-21 17:49:13,932 autoreload 266 D:\Code\Work\Python\dingxin_toolbox_drf\mock\mock_templates\__init__.py changed, reloading. +INFO 2023-12-21 17:49:14,906 autoreload 668 Watching for file changes with StatReloader +INFO 2023-12-21 17:51:35,471 autoreload 266 D:\Code\Work\Python\dingxin_toolbox_drf\mock\views.py changed, reloading. +INFO 2023-12-21 17:51:36,396 autoreload 668 Watching for file changes with StatReloader +INFO 2023-12-21 17:51:47,291 autoreload 266 D:\Code\Work\Python\dingxin_toolbox_drf\mock\views.py changed, reloading. +INFO 2023-12-21 17:51:48,413 autoreload 668 Watching for file changes with StatReloader +INFO 2023-12-21 17:52:03,683 autoreload 266 D:\Code\Work\Python\dingxin_toolbox_drf\mock\views.py changed, reloading. +INFO 2023-12-21 17:52:04,709 autoreload 668 Watching for file changes with StatReloader +INFO 2023-12-21 17:53:22,622 autoreload 266 D:\Code\Work\Python\dingxin_toolbox_drf\mock\urls.py changed, reloading. +INFO 2023-12-21 17:53:23,514 autoreload 668 Watching for file changes with StatReloader diff --git a/mock/mock_templates/__init__.py b/mock/mock_templates/__init__.py index e72163f..e85028a 100644 --- a/mock/mock_templates/__init__.py +++ b/mock/mock_templates/__init__.py @@ -1,2 +1,4 @@ __all__ = ['get_cinema_info_tmp', - 'report_ticket_tmp'] + 'report_ticket_tmp', + 'report_film_schedule_tmp', + 'upload_screen_seat_info_tmp'] diff --git a/mock/mock_templates/report_film_schedule_tmp.py b/mock/mock_templates/report_film_schedule_tmp.py new file mode 100644 index 0000000..5244edf --- /dev/null +++ b/mock/mock_templates/report_film_schedule_tmp.py @@ -0,0 +1,3 @@ +def get(): + mock_data = {'message': '操作成功', 'data': None, 'code': '200', 'status': 'success'} + return mock_data diff --git a/mock/mock_templates/upload_screen_seat_info_tmp.py b/mock/mock_templates/upload_screen_seat_info_tmp.py new file mode 100644 index 0000000..5244edf --- /dev/null +++ b/mock/mock_templates/upload_screen_seat_info_tmp.py @@ -0,0 +1,3 @@ +def get(): + mock_data = {'message': '操作成功', 'data': None, 'code': '200', 'status': 'success'} + return mock_data diff --git a/mock/urls.py b/mock/urls.py index 4545cb0..c361703 100644 --- a/mock/urls.py +++ b/mock/urls.py @@ -20,5 +20,8 @@ from mock.views import * urlpatterns = [ path('report/reportTicket', report_ticket), + path('report/reportFilmSchedule', report_film_schedule), + path('report/uploadScreenSeatInfo', upload_screen_seat_info), + path('report/downloadFilmInfo', download_film_info), path('data/getCinemaInfo', get_cinema_info), ] diff --git a/mock/utils/mock_service.py b/mock/utils/mock_service.py index 0edd141..101a876 100644 --- a/mock/utils/mock_service.py +++ b/mock/utils/mock_service.py @@ -9,17 +9,24 @@ ZZ_URL = 'https://zzcs.yinghezhong.com' def mock(_ip, _api, *args, **kwargs): print('mock') cinema_obj = Cinema.objects.filter(ip=_ip).first() - if _api == 'getCinemaInfo': - mock_data = get_cinema_info_tmp.get(cinema_obj) - return JsonResponse(mock_data, json_dumps_params={'ensure_ascii': False}) if _api == 'reportTicket': mock_data = report_ticket_tmp.get() return JsonResponse(mock_data, json_dumps_params={'ensure_ascii': False}) + if _api == 'reportFilmSchedule': + mock_data = report_film_schedule_tmp.get() + return JsonResponse(mock_data, json_dumps_params={'ensure_ascii': False}) + if _api == 'uploadScreenSeatInfo': + mock_data = upload_screen_seat_info_tmp.get() + return JsonResponse(mock_data, json_dumps_params={'ensure_ascii': False}) + if _api == 'getCinemaInfo': + mock_data = get_cinema_info_tmp.get(cinema_obj) + return JsonResponse(mock_data, json_dumps_params={'ensure_ascii': False}) + def bypass(_r): print('bypass') - print(_r.method, _r.path) # GET /data/getCinemaInfo - print(_r.GET) # + print(_r.method, _r.path) + print(_r.GET) print(_r.POST) if _r.method == 'GET': req_url = ZZ_URL + _r.path diff --git a/mock/views.py b/mock/views.py index 194df53..6060c8f 100644 --- a/mock/views.py +++ b/mock/views.py @@ -15,17 +15,47 @@ def report_ticket(request): ip = request.META.get('REMOTE_ADDR') mock_service_switch = ZZMockModel.objects.filter(ip=ip).first() if mock_service_switch.reportTicket is True: + mock_service.bypass(request) return mock_service.mock(ip, 'reportTicket') else: return mock_service.bypass(request) # 2、排片数据上报接口 POST /report/reportFilmSchedule +@csrf_exempt +def report_film_schedule(request): + ip = request.META.get('REMOTE_ADDR') + mock_service_switch = ZZMockModel.objects.filter(ip=ip).first() + if mock_service_switch.reportFilmSchedule is True: + mock_service.bypass(request) + return mock_service.mock(ip, 'reportFilmSchedule') + else: + return mock_service.bypass(request) + + # 3、座位信息上报接口 POST /report/uploadScreenSeatInfo +@csrf_exempt +def upload_screen_seat_info(request): + ip = request.META.get('REMOTE_ADDR') + mock_service_switch = ZZMockModel.objects.filter(ip=ip).first() + if mock_service_switch.uploadScreenSeatInfo is True: + mock_service.bypass(request) + return mock_service.mock(ip, 'uploadScreenSeatInfo') + else: + return mock_service.bypass(request) # 数据下载 # 1、影片信息下载接口 GET /data/downloadFilmInfo +def download_film_info(request): + ip = request.META.get('REMOTE_ADDR') + mock_service_switch = ZZMockModel.objects.filter(ip=ip).first() + if mock_service_switch.downloadFilmInfo is True: + return mock_service.mock(ip, 'downloadFilmInfo') + else: + return mock_service.bypass(request) + + # 2、影院信息下载接口 GET /data/getCinemaInfo def get_cinema_info(request): ip = request.META.get('REMOTE_ADDR')