first updata

This commit is contained in:
2024-02-26 18:17:15 +08:00
commit 1ec018ca90
162 changed files with 123649 additions and 0 deletions
View File
Binary file not shown.
Binary file not shown.
+32
View File
@@ -0,0 +1,32 @@
from server.models import CooperationMindLog
import ast
from server.serializers import CooperationMindLogSerializer
class CooperationMindLogLib(object):
"""
操作日志
"""
def save_log(self, json_msg):
"""
保存操作日志
"""
if self.should_handle(json_msg):
# 避免json解析失败
json_msg = json_msg.replace(',null]', ']')
print(json_msg)
json_msg_dict = ast.literal_eval(json_msg)
log = CooperationMindLog(
coop_mind_id=json_msg_dict.get('coop_mind_id'),
log_uuid=json_msg_dict.get('log_uuid'),
log_content=json_msg,
client_uuid=json_msg_dict.get('client_uuid')
)
log.save()
return CooperationMindLogSerializer(log).data
return None
def should_handle(self, json_msg):
return 'coop_mind_id' in json_msg and 'select_node' not in json_msg
+18
View File
@@ -0,0 +1,18 @@
def get_context():
if QrContext.instance is None:
QrContext.instance = QrContext()
return QrContext.instance
class QrContext():
instance = None
all_obj = {}
def get(self, key):
return self.all_obj.get(key)
def add(self, key, v):
self.all_obj.update({key: v})
def remove(self, key):
del self.all_obj[key]