diff --git a/mock/mock_templates/__init__.py b/mock/mock_templates/__init__.py index e85028a..7a810b7 100644 --- a/mock/mock_templates/__init__.py +++ b/mock/mock_templates/__init__.py @@ -1,4 +1,5 @@ __all__ = ['get_cinema_info_tmp', 'report_ticket_tmp', 'report_film_schedule_tmp', - 'upload_screen_seat_info_tmp'] + 'upload_screen_seat_info_tmp', + 'get_screen_info_tmp'] diff --git a/mock/mock_templates/get_screen_info_tmp.py b/mock/mock_templates/get_screen_info_tmp.py new file mode 100644 index 0000000..179e487 --- /dev/null +++ b/mock/mock_templates/get_screen_info_tmp.py @@ -0,0 +1,45 @@ +import pymysql +from pymysql.cursors import DictCursor + + +def get(cinema_data): + db_config = { + 'host': cinema_data.ip, + 'user': cinema_data.db_user, + 'password': cinema_data.db_pwd, + 'database': 'cine', + 'connect_timeout': 5, + } + + db_conn = pymysql.Connect(**db_config) + db_cursor = db_conn.cursor(cursor=DictCursor) + # cinema_info + cinema_info_sql_str = 'SELECT * FROM cinema_info;' + db_cursor.execute(cinema_info_sql_str) + cinema_info_data = db_cursor.fetchone() + # cinema_set + cinema_set_sql_str = 'SELECT * FROM cinema_set;' + db_cursor.execute(cinema_set_sql_str) + cinema_set_data = db_cursor.fetchone() + # cinema_hall_info + cinema_hall_info_sql_str = 'SELECT * FROM cinema_hall_info;' + db_cursor.execute(cinema_hall_info_sql_str) + cinema_hall_info_data = db_cursor.fetchall() + hall_num = len(cinema_hall_info_data) + db_conn.close() + mock_data = {'message': '操作成功', + 'data': { + 'cinemaChainName': cinema_info_data['cinema_chain_name'], + 'manager': cinema_info_data['cinema_manager'], + 'screens': hall_num, + 'managerTel': cinema_info_data['cinema_telephone'], + 'cinemaName': cinema_set_data['cinema_platform_name'], + 'cinemaCode': cinema_set_data['cinema_num'], # 适配字段 + 'cinemaLevel': cinema_info_data['cinema_level'], + 'businessStatus': '12', # 定义字段 + 'officialName': cinema_info_data['official_name'], + 'fax': cinema_info_data['cinema_fax'] + }, + 'code': '200', + 'status': 'success'} + return mock_data diff --git a/mock/urls.py b/mock/urls.py index c361703..773102e 100644 --- a/mock/urls.py +++ b/mock/urls.py @@ -24,4 +24,5 @@ urlpatterns = [ path('report/uploadScreenSeatInfo', upload_screen_seat_info), path('report/downloadFilmInfo', download_film_info), path('data/getCinemaInfo', get_cinema_info), + path('data/getScreenInfo', get_screen_info), ] diff --git a/mock/utils/mock_service.py b/mock/utils/mock_service.py index 101a876..3e453ca 100644 --- a/mock/utils/mock_service.py +++ b/mock/utils/mock_service.py @@ -21,6 +21,9 @@ def mock(_ip, _api, *args, **kwargs): if _api == 'getCinemaInfo': mock_data = get_cinema_info_tmp.get(cinema_obj) return JsonResponse(mock_data, json_dumps_params={'ensure_ascii': False}) + if _api == 'getScreenInfo': + mock_data = get_screen_info_tmp.get(cinema_obj) + return JsonResponse(mock_data, json_dumps_params={'ensure_ascii': False}) def bypass(_r): diff --git a/mock/views.py b/mock/views.py index 6060c8f..51f2c90 100644 --- a/mock/views.py +++ b/mock/views.py @@ -64,9 +64,17 @@ def get_cinema_info(request): return mock_service.mock(ip, 'getCinemaInfo') else: return mock_service.bypass(request) -# 3、影厅信息下载接口 GET /data/getScreenInfo +# 3、影厅信息下载接口 GET /data/getScreenInfo +def get_screen_info(request): + ip = request.META.get('REMOTE_ADDR') + mock_service_switch = ZZMockModel.objects.filter(ip=ip).first() + if mock_service_switch.getScreenInfo is True: + return mock_service.mock(ip, 'getScreenInfo') + else: + return mock_service.bypass(request) + # 超时票务审批 # 1、超时票务受理情况查询接口 GET /data/getOvertimeTicketStatus #