提交缺失的文件

main
RogerWork 7 months ago
parent ae7d0897eb
commit 9e1acfae20
  1. 19
      dspt_api/util/api/cinema_plays_increment.py
  2. 2
      dspt_api/util/general/handle_redis.py
  3. 4
      dspt_api/util/suggest_params.py
  4. BIN
      reqirement.txt

@ -0,0 +1,19 @@
from dspt_api.util.general.handle_redis import get_data_from_redis
import datetime
class ApiCinemaPlaysIncrement:
def __init__(self, **kwargs):
self.member_type = kwargs.get('member_type')
self.api = kwargs.get('api')
self.ip = kwargs.get('ip')
def get_suggestion(self):
# start
request_api = {'name': '3.1.6 获取放映计划列表(增量)', 'path': 'cinema/plays-increment'}
redis_key_api = f'dspt_api_{self.ip}_{self.member_type}_{request_api["path"]}'
result, redis_data = get_data_from_redis(redis_key_api)
# 生成默认值
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}]

@ -22,7 +22,7 @@ def get_data_from_redis(redis_key):
print('xml-response', resp) print('xml-response', resp)
resp_result = resp['root']['status'] resp_result = resp['root']['status']
if str(resp_result) == '1': if str(resp_result) == '1':
resp_data = resp['root']['data']['item'] resp_data = resp['root']['data'].get('item', resp['root']['data'])
if str(resp_result) != '1': if str(resp_result) != '1':
return False, '请检查接口返回值或手动输入参数:' return False, '请检查接口返回值或手动输入参数:'
if len(resp_data) == 0: if len(resp_data) == 0:

@ -1,4 +1,5 @@
from dspt_api.util.api.cinema_hall_seats import ApiCinemaHallSeats from dspt_api.util.api.cinema_hall_seats import ApiCinemaHallSeats
from dspt_api.util.api.cinema_plays_increment import ApiCinemaPlaysIncrement
# 通过api来匹配不同的接口文件获取推荐 # 通过api来匹配不同的接口文件获取推荐
@ -9,4 +10,7 @@ def suggest_params(member_type, api, ip):
if api == 'cinema/hall-seats' and member_type == 'nonmember': if api == 'cinema/hall-seats' and member_type == 'nonmember':
print('cinema/hall-seats') print('cinema/hall-seats')
params = ApiCinemaHallSeats(**data).get_suggestion() params = ApiCinemaHallSeats(**data).get_suggestion()
if api == 'cinema/plays-increment' and member_type == 'nonmember':
print('cinema/plays-increment')
params = ApiCinemaPlaysIncrement(**data).get_suggestion()
return params return params

Binary file not shown.
Loading…
Cancel
Save