parent
b25e499da7
commit
888452e7a1
13 changed files with 201 additions and 33 deletions
@ -0,0 +1,29 @@ |
|||||||
|
from dspt_api.util.general.handle_redis import get_data_from_redis |
||||||
|
import random |
||||||
|
|
||||||
|
|
||||||
|
class ApiSeatLock: |
||||||
|
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): |
||||||
|
# # play_id |
||||||
|
# request_api_play = {'name': '3.1.5 获取放映计划列表', 'path': 'cinema/plays'} |
||||||
|
# redis_key_api_play = f'dspt_api_{self.ip}_{self.member_type}_{request_api_play["path"]}' |
||||||
|
# result_play, _format_play, redis_data_play = get_data_from_redis(redis_key_api_play) |
||||||
|
# # seat_id |
||||||
|
# request_api_seat = {'name': '3.1.8 获取某场次座位状态', 'path': 'play/seat-status'} |
||||||
|
# redis_key_api_seat = f'dspt_api_{self.ip}_{self.member_type}_{request_api_seat["path"]}' |
||||||
|
# result_seat, _format_seat, redis_data_seat = get_data_from_redis(redis_key_api_seat) |
||||||
|
# if result: |
||||||
|
# play_data = random.choice(redis_data) |
||||||
|
# play_id = play_data['id'] |
||||||
|
# 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, 'result': True}] |
||||||
|
|
||||||
|
|
@ -0,0 +1,21 @@ |
|||||||
|
import random |
||||||
|
import json |
||||||
|
import time |
||||||
|
|
||||||
|
from django_redis import get_redis_connection |
||||||
|
|
||||||
|
def random_params(_user_info, _handle_data): |
||||||
|
print('_user_info', _user_info) |
||||||
|
print('_handle_data', _handle_data) |
||||||
|
redis_key_api = f'dspt_api_{_user_info["user_ip"]}_{_user_info["member_type"]}_{_user_info["api"]}_random' |
||||||
|
redis_conn = get_redis_connection() |
||||||
|
if redis_conn.get(redis_key_api): |
||||||
|
redis_conn.delete(redis_key_api) |
||||||
|
data = { |
||||||
|
'api': _user_info["api"], |
||||||
|
'member_type': _user_info["member_type"], |
||||||
|
'format': _user_info["format"], |
||||||
|
'timestamp': int(time.time()*1000), |
||||||
|
'user_data': [random.choice(_handle_data['res']['data'])], |
||||||
|
} |
||||||
|
redis_conn.set(redis_key_api, json.dumps(data)) |
Loading…
Reference in new issue