refactor: 统一搜索接口,移除 dialog/msg/search

- 前端 DialogWrapper.vue 改用 search/message 接口
  - 删除 DialogController::msg__search 方法
  - search/message 已完全覆盖原接口功能
This commit is contained in:
kuaifan 2026-01-03 13:04:40 +00:00
parent ec0db3a76c
commit 7a21a2d800
2 changed files with 2 additions and 55 deletions

View File

@ -685,60 +685,6 @@ class DialogController extends AbstractController
return Base::retSuccess('success', compact('data'));
}
/**
* @api {get} api/dialog/msg/search 搜索消息
*
* @apiDescription 需要token身份
* @apiVersion 1.0.0
* @apiGroup dialog
* @apiName msg__search
*
* @apiParam {String} key 搜索关键词
* @apiParam {Number} [dialog_id] 对话ID存在则搜索消息在对话的位置
* @apiParam {Number} [take] 搜索数量
* - dialog_id > 0, 默认:200,最大:200
* - dialog_id <= 0, 默认:20,最大:50
*
* @apiSuccess {Number} ret 返回状态码1正确、0错误
* @apiSuccess {String} msg 返回信息(错误描述)
* @apiSuccess {Object} data 返回数据
*/
public function msg__search()
{
$user = User::auth();
//
$key = trim(Request::input('key'));
$dialogId = intval(Request::input('dialog_id'));
//
if (empty($key)) {
return Base::retError('关键词不能为空');
}
//
if ($dialogId > 0) {
// 搜索位置
WebSocketDialog::checkDialog($dialogId);
//
$data = WebSocketDialogMsg::whereDialogId($dialogId)
->where('key', 'LIKE', "%{$key}%")
->take(Base::getPaginate(200, 200, 'take'))
->pluck('id');
return Base::retSuccess('success', compact('data'));
} else {
// 搜索消息
$list = [];
$searchResults = ManticoreMsg::searchDialogs($user->userid, $key, 0, Base::getPaginate(50, 20, 'take'));
if ($searchResults) {
foreach ($searchResults as $item) {
if ($dialog = WebSocketDialog::find($item['id'])) {
$dialog = array_merge($dialog->toArray(), $item);
$list[] = WebSocketDialog::synthesizeData($dialog, $user->userid);
}
}
}
return Base::retSuccess('success', ['data' => $list]);
}
}
/**
* @api {get} api/dialog/msg/one 获取单条消息
*

View File

@ -1316,10 +1316,11 @@ export default {
this.searchResult = []
this.searchLocation = 0
this.$store.dispatch("call", {
url: 'dialog/msg/search',
url: 'search/message',
data: {
dialog_id: this.dialogId,
key,
mode: 'position',
},
}).then(({data}) => {
if (this.searchKey !== key) {