消息列表

This commit is contained in:
wong
2025-09-24 14:09:09 +08:00
parent 3c89d312c6
commit a9680d2464
2 changed files with 45 additions and 2 deletions

View File

@@ -28,6 +28,7 @@ Route::group('v1/', function () {
Route::group('message/', function () {
Route::get('list', 'app\chukebao\controller\MessageController@getList'); // 获取好友列表
Route::get('readMessage', 'app\chukebao\controller\MessageController@readMessage'); // 读取消息
Route::get('details', 'app\chukebao\controller\MessageController@details'); // 消息详情
});
//AI相关

View File

@@ -97,11 +97,53 @@ class MessageController extends BaseController
}
Db::table('s2_wechat_message')->where($where)->update(['isRead' => 1]);
return ResponseHelper::success([]);
}
public function details(){
$wechatFriendId = $this->request->param('wechatFriendId', '');
$wechatChatroomId = $this->request->param('wechatChatroomId', '');
$wechatAccountId = $this->request->param('wechatAccountId', '');
$page = $this->request->param('page', 1);
$limit = $this->request->param('limit', 10);
$from = $this->request->param('From', '');
$to = $this->request->param('To', '');
$olderData = $this->request->param('olderData', false);
$accountId = $this->getUserInfo('s2_accountId');
if (empty($accountId)){
return ResponseHelper::error('请先登录');
}
if (empty($wechatChatroomId) && empty($wechatFriendId)){
return ResponseHelper::error('参数缺失');
}
$where = [];
if (!empty($wechatChatroomId)){
$where[] = ['wechatChatroomId','=',$wechatChatroomId];
}
if (!empty($wechatFriendId)){
$where[] = ['wechatFriendId','=',$wechatFriendId];
}
if (!empty($From) && !empty($To)){
$where[] = ['wechatTime','between',[$from,$to]];
}
$list = Db::table('s2_wechat_message')->where($where)->page($page,$limit)->order('id DESC')->select();
$total = Db::table('s2_wechat_message')->where($where)->count();
foreach ($list as $k=>&$v){
$v['wechatTime'] = !empty($v['wechatTime']) ? date('Y-m-d H:i:s',$v['wechatTime']) : '';
}
return ResponseHelper::success(['total'=>$total,'list'=>$list]);
}