pp
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from server.models import CooperationMindLog
|
||||
import ast
|
||||
from server.serializers import CooperationMindLogSerializer
|
||||
|
||||
|
||||
class CooperationMindLogLib(object):
|
||||
@@ -24,8 +25,7 @@ class CooperationMindLogLib(object):
|
||||
client_id=json_msg_dict.get('client_id')
|
||||
)
|
||||
log.save()
|
||||
json_msg_dict.update({'log_id': log.id})
|
||||
return json_msg_dict
|
||||
return CooperationMindLogSerializer(log).data
|
||||
return None
|
||||
|
||||
def should_handle(self, json_msg):
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ class JsMindLogView(APIView):
|
||||
param = request.GET
|
||||
coop_mind_id = param.get('coop_mind_id')
|
||||
cooperation_mind_log_id = param.get('cooperation_mind_log_id')
|
||||
query_set = CooperationMindLog.objects.filter(coop_mind_id=coop_mind_id, id__gte=cooperation_mind_log_id)
|
||||
query_set = CooperationMindLog.objects.filter(coop_mind_id=coop_mind_id, id__gt=cooperation_mind_log_id)
|
||||
log_list = CooperationMindLogSerializer(query_set, many=True)
|
||||
return build_response(data=log_list.data)
|
||||
|
||||
|
||||
@@ -100,9 +100,14 @@
|
||||
},
|
||||
// 获得一次日志
|
||||
fetch_log: function () {
|
||||
const me = this
|
||||
Jm.util.ajax.get(`${this.coop_api_url}?coop_mind_id=${this.coop_mind_id}&cooperation_mind_log_id=${this.coop_mind_log_id}`, function (resp) {
|
||||
console.log(resp)
|
||||
// _handle_msg_inner
|
||||
//
|
||||
const resp_data_array = resp.data
|
||||
console.log(resp_data_array)
|
||||
resp_data_array.forEach(item => {
|
||||
me._handle_msg_inner(item)
|
||||
})
|
||||
})
|
||||
},
|
||||
// 清理定时任务
|
||||
@@ -135,8 +140,14 @@
|
||||
},
|
||||
// 处理消息广告方法
|
||||
_handle_msg_inner(msg_json) {
|
||||
|
||||
// 校验 client_id
|
||||
const client_id = msg_json.client_id
|
||||
const log_id = msg_json.log_id
|
||||
if (!client_id) {
|
||||
return
|
||||
}
|
||||
const log_content = JSON.parse(msg_json.log_content)
|
||||
const log_id = msg_json.id
|
||||
if (log_id > this.coop_mind_log_id) {
|
||||
this.coop_mind_log_last_id = this.coop_mind_log_id
|
||||
this.coop_mind_log_id = log_id
|
||||
@@ -146,8 +157,8 @@
|
||||
if (client_id === this.client_id) {
|
||||
console.log('self msg')
|
||||
} else {
|
||||
const evt = msg_json.evt
|
||||
const data_array = msg_json.data
|
||||
const evt = log_content.evt
|
||||
const data_array = log_content.data
|
||||
// console.log(msg_json)
|
||||
if ('add_node' === evt) {
|
||||
this._jm.add_node(data_array[0], data_array[1], data_array[2], null, true)
|
||||
|
||||
Reference in New Issue
Block a user