diff --git a/dspt_api/util/api/cinema_goods_pic.py b/dspt_api/util/api/cinema_goods_pic.py index cd3b4cb..2817626 100644 --- a/dspt_api/util/api/cinema_goods_pic.py +++ b/dspt_api/util/api/cinema_goods_pic.py @@ -19,10 +19,10 @@ class ApiCinemaGoodsPic(object): goods = random.choice(goods_list) goods_id = goods['id'] goods_type = goods['type'] - return [{'param': 'goods_id', 'value': goods_id, 'is_checked': True}, - {'param': 'type', 'value': goods_type, 'is_checked': True}] + return [{'param': 'goods_id', 'value': goods_id, 'is_checked': True, 'result': True}, + {'param': 'type', 'value': goods_type, 'is_checked': True, 'result': True}] else: # 返回推荐参数应该包含参数名,参数值,和是否勾选的状态 return [ - {'param': 'goods_id', 'value': redis_data + request_api["name"], 'is_checked': True}, - {'param': 'type', 'value': redis_data + request_api["name"], 'is_checked': True}] + {'param': 'goods_id', 'value': redis_data + request_api["name"], 'is_checked': True, 'result': False}, + {'param': 'type', 'value': redis_data + request_api["name"], 'is_checked': True, 'result': False}] diff --git a/dspt_api/util/api/cinema_hall_seats.py b/dspt_api/util/api/cinema_hall_seats.py index 6e2826f..45d52c0 100644 --- a/dspt_api/util/api/cinema_hall_seats.py +++ b/dspt_api/util/api/cinema_hall_seats.py @@ -16,10 +16,10 @@ class ApiCinemaHallSeats: if result: hall_data = random.choice(redis_data) hall_id = hall_data['id'] - return [{'param': 'hall_id', 'value': hall_id, 'is_checked': True}] + return [{'param': 'hall_id', 'value': hall_id, 'is_checked': True, 'result': True}] else: # 返回推荐参数应该包含参数名,参数值,和是否勾选的状态 return [ - {'param': 'hall_id', 'value': redis_data + request_api["name"], 'is_checked': True}] + {'param': 'hall_id', 'value': redis_data + request_api["name"], 'is_checked': True, 'result': False}] diff --git a/dspt_api/util/api/cinema_plays_increment.py b/dspt_api/util/api/cinema_plays_increment.py index 7f05786..c991c20 100644 --- a/dspt_api/util/api/cinema_plays_increment.py +++ b/dspt_api/util/api/cinema_plays_increment.py @@ -16,4 +16,4 @@ class ApiCinemaPlaysIncrement: # 生成默认值 start = redis_data['nextSyncStartTime'] if result else datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d') + ' 06:00:00' - return [{'param': 'start', 'value': start, 'is_checked': True}] + return [{'param': 'start', 'value': start, 'is_checked': True, 'result': True}] diff --git a/dspt_api/util/api/play_info.py b/dspt_api/util/api/play_info.py index ca7347a..551b7ff 100644 --- a/dspt_api/util/api/play_info.py +++ b/dspt_api/util/api/play_info.py @@ -17,10 +17,10 @@ class ApiPlayInfo: if result: play_data = random.choice(redis_data) play_id = play_data['id'] - return [{'param': 'play_id', 'value': play_id, 'is_checked': True}] + return [{'param': 'play_id', 'value': play_id, 'is_checked': True, 'result': True}] else: # 返回推荐参数应该包含参数名,参数值,和是否勾选的状态 return [ - {'param': 'play_id', 'value': redis_data + request_api["name"], 'is_checked': True}] + {'param': 'play_id', 'value': redis_data + request_api["name"], 'is_checked': True, 'result': True}] diff --git a/dspt_api/util/api/play_period_changed_seats.py b/dspt_api/util/api/play_period_changed_seats.py index 44b55e5..e294bed 100644 --- a/dspt_api/util/api/play_period_changed_seats.py +++ b/dspt_api/util/api/play_period_changed_seats.py @@ -18,10 +18,10 @@ class ApiPlayPeriodChangedSeats: play_data = random.choice(redis_data) play_id = play_data['id'] start = datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d') + ' 06:00:00' - return [{'param': 'play_id', 'value': play_id, 'is_checked': True}, - {'param': 'start', 'value': start, 'is_checked': True}] + return [{'param': 'play_id', 'value': play_id, 'is_checked': True, 'result': True}, + {'param': 'start', 'value': start, 'is_checked': True, 'result': True}] else: # 返回推荐参数应该包含参数名,参数值,和是否勾选的状态 return [ - {'param': 'play_id', 'value': redis_data + request_api["name"], 'is_checked': True}, - {'param': 'start', 'value': redis_data + request_api["name"], 'is_checked': True}] + {'param': 'play_id', 'value': redis_data + request_api["name"], 'is_checked': True, 'result': True}, + {'param': 'start', 'value': redis_data + request_api["name"], 'is_checked': True, 'result': True}] diff --git a/dspt_api/util/api/play_seat_overview.py b/dspt_api/util/api/play_seat_overview.py index 566b3b3..68da602 100644 --- a/dspt_api/util/api/play_seat_overview.py +++ b/dspt_api/util/api/play_seat_overview.py @@ -20,4 +20,4 @@ class ApiPlaySeatOverview: else: # 返回推荐参数应该包含参数名,参数值,和是否勾选的状态 return [ - {'param': 'play_id', 'value': redis_data + request_api["name"], 'is_checked': True}] + {'param': 'play_id', 'value': redis_data + request_api["name"], 'is_checked': True, 'result': True}] diff --git a/dspt_api/util/api/play_seat_status.py b/dspt_api/util/api/play_seat_status.py index 388b525..cd70e3e 100644 --- a/dspt_api/util/api/play_seat_status.py +++ b/dspt_api/util/api/play_seat_status.py @@ -17,10 +17,10 @@ class ApiPlaySeatStatus: play_data = random.choice(redis_data) play_id = play_data['id'] play_update_time = play_data['cineUpdateTime'] - return [{'param': 'play_id', 'value': play_id, 'is_checked': True}, - {'param': 'play_update_time', 'value': play_update_time, 'is_checked': True}] + return [{'param': 'play_id', 'value': play_id, 'is_checked': True, 'result': True}, + {'param': 'play_update_time', 'value': play_update_time, 'is_checked': True, 'result': True}] else: # 返回推荐参数应该包含参数名,参数值,和是否勾选的状态 return [ - {'param': 'play_id', 'value': redis_data + request_api["name"], 'is_checked': True}, - {'param': 'play_update_time', 'value': redis_data + request_api["name"], 'is_checked': True}] + {'param': 'play_id', 'value': redis_data + request_api["name"], 'is_checked': True, 'result': True}, + {'param': 'play_update_time', 'value': redis_data + request_api["name"], 'is_checked': True, 'result': True}] diff --git a/dspt_api/util/general/handle_redis.py b/dspt_api/util/general/handle_redis.py index b9613a3..21876c4 100644 --- a/dspt_api/util/general/handle_redis.py +++ b/dspt_api/util/general/handle_redis.py @@ -7,11 +7,13 @@ import xmltodict def get_data_from_redis(redis_key): # 初始化redis redis_conn = get_redis_connection() + # 如果有用户数据则处理用户数据 if redis_conn.exists(redis_key + '_user_data'): redis_data = json.loads(redis_conn.get(redis_key + '_user_data')) user_data = redis_data['user_data'] print('user_data', json.dumps(user_data)) return True, redis_data['format'], user_data + # 没有用户数据时,随机选择数据 if redis_conn.exists(redis_key): redis_data = json.loads(redis_conn.get(redis_key)) resp_data = [] diff --git a/update/utils/git_util.py b/update/utils/git_util.py index a54a67b..48c3fce 100644 --- a/update/utils/git_util.py +++ b/update/utils/git_util.py @@ -1,4 +1,6 @@ from git import Repo + +from dspt_api.util.insert_api_to_db import db_conn, db_cursor from update.models import Release import os import shutil @@ -29,6 +31,7 @@ class GitUtil: 'user': settings.CONFIG[ENV]['DB']['USER'], 'password': settings.CONFIG[ENV]['DB']['PASSWORD'], 'port': 3309, + 'database': self.db_name, 'connect_timeout': 5, } @@ -110,6 +113,27 @@ class GitUtil: r = os.system(cmd) print('cine.sql写入结果', r) + def del_func_view(self): + cmd_list = [ + f'DROP FUNCTION IF EXISTS `{self.db_name}`.`GetCostAverage`;', + f'DROP FUNCTION IF EXISTS `{self.db_name}`.`GetGoodsCount`;', + f'DROP FUNCTION IF EXISTS `{self.db_name}`.`GetSumIn`;', + f'DROP FUNCTION IF EXISTS `{self.db_name}`.`GetCostFifo`;', + f'DROP FUNCTION IF EXISTS `{self.db_name}`.`GetSumOut`;', + f'DROP FUNCTION IF EXISTS `{self.db_name}`.`GetCost`;', + f'DROP FUNCTION IF EXISTS `{self.db_name}`.`GetGoodsPrice`;', + f'DROP FUNCTION IF EXISTS `{self.db_name}`.`GetCostMobile`;', + f'DROP VIEW IF EXISTS `{self.db_name}`.`retail_inventory_list`;' + ] + _db_conn = pymysql.connect(**self.db_config) + _db_cursor = db_conn.cursor() + _db_cursor.execute() + for cmd in cmd_list: + _db_cursor.execute(cmd) + _db_conn.commit() + _db_cursor.close() + _db_conn.close() + # 获取数据库名称 def get_db_name(self, _release=''): if _release == '':