mirror of
https://github.com/kuaifan/dootask.git
synced 2026-02-23 17:30:33 +00:00
perf: 优化接龙接口,加上事务锁
This commit is contained in:
parent
f6b006b000
commit
b254fd5ce2
@ -2180,9 +2180,10 @@ class DialogController extends AbstractController
|
||||
return Base::retError('内容最大不能超过200000字');
|
||||
}
|
||||
//
|
||||
$userid = $user->userid;
|
||||
return AbstractModel::transaction(function () use ($user, $uuid, $dialog_id, $list, $text) {
|
||||
if ($uuid) {
|
||||
$dialogMsg = WebSocketDialogMsg::whereDialogId($dialog_id)
|
||||
->lockForUpdate()
|
||||
->whereType('word-chain')
|
||||
->orderByDesc('created_at')
|
||||
->where('msg', 'like', "%$uuid%")
|
||||
@ -2196,6 +2197,8 @@ class DialogController extends AbstractController
|
||||
return $result;
|
||||
}, []);
|
||||
$list = array_reverse(array_values($list));
|
||||
} else {
|
||||
$uuid = Base::generatePassword(36);
|
||||
}
|
||||
//
|
||||
usort($list, function ($a, $b) {
|
||||
@ -2205,10 +2208,11 @@ class DialogController extends AbstractController
|
||||
$msgData = [
|
||||
'text' => $text,
|
||||
'list' => $list,
|
||||
'userid' => $userid,
|
||||
'uuid' => $uuid ?: Base::generatePassword(36),
|
||||
'userid' => $user->userid,
|
||||
'uuid' => $uuid,
|
||||
];
|
||||
return WebSocketDialogMsg::sendMsg(null, $dialog_id, 'word-chain', $msgData, $user->userid);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user