perf: 优化消息已读

This commit is contained in:
kuaifan
2022-09-18 21:20:24 +08:00
parent 2693cf17ea
commit 4bef2f5287
2 changed files with 36 additions and 13 deletions

View File

@@ -484,6 +484,36 @@ class DialogController extends AbstractController
return Base::retSuccess('success', $msg);
}
/**
* @api {get} api/dialog/msg/read 11. 标记已读
*
* @apiDescription 需要token身份
* @apiVersion 1.0.0
* @apiGroup dialog
* @apiName msg__read
*
* @apiParam {Number} id 消息ID
*
* @apiSuccess {Number} ret 返回状态码1正确、0错误
* @apiSuccess {String} msg 返回信息(错误描述)
* @apiSuccess {Object} data 返回数据
*/
public function msg__read()
{
$user = User::auth();
//
$id = Request::input('id');
$ids = Base::arrayRetainInt(is_array($id) ? $id : Base::explodeInt($id));
//
WebSocketDialogMsg::whereIn('id', $ids)->chunkById(20, function($list) use ($user) {
/** @var WebSocketDialogMsg $item */
foreach ($list as $item) {
$item->readSuccess($user->userid);
}
});
return Base::retSuccess('success');
}
/**
* @api {get} api/dialog/msg/unread 11. 获取未读消息数量
*