From db3cc7cd3c6b1a9b0bf991c7dd7a2da88df4839e Mon Sep 17 00:00:00 2001 From: RogerWork Date: Thu, 22 Aug 2024 10:10:22 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=B8=BA=E5=89=8D=E7=AB=AF=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0reload=E7=9A=84=E5=88=A4=E6=96=AD=E4=BE=9D=E6=8D=AE?= =?UTF-8?q?=EF=BC=8C=20=E8=BF=94=E5=9B=9E=E7=9A=84=E6=8E=A8=E8=8D=90?= =?UTF-8?q?=E5=AD=97=E6=AE=B5=E5=A2=9E=E5=8A=A0result=202.=20=E5=86=99?= =?UTF-8?q?=E5=85=A5cine=E5=BA=93=E6=98=AF=E5=88=A0=E9=99=A4=E6=89=80?= =?UTF-8?q?=E6=9C=89=E7=9A=84function=E5=92=8Cview=EF=BC=8C=E6=96=B9?= =?UTF-8?q?=E4=BE=BF=E5=AF=B9=E6=AF=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dspt_api/util/api/cinema_goods_pic.py | 8 +++---- dspt_api/util/api/cinema_hall_seats.py | 4 ++-- dspt_api/util/api/cinema_plays_increment.py | 2 +- dspt_api/util/api/play_info.py | 4 ++-- .../util/api/play_period_changed_seats.py | 8 +++---- dspt_api/util/api/play_seat_overview.py | 2 +- dspt_api/util/api/play_seat_status.py | 8 +++---- dspt_api/util/general/handle_redis.py | 2 ++ update/utils/git_util.py | 24 +++++++++++++++++++ 9 files changed, 44 insertions(+), 18 deletions(-) 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 == '':