分组及好友列表优化
This commit is contained in:
@@ -14,13 +14,30 @@ class WechatChatroomController extends BaseController
|
||||
public function getList(){
|
||||
$page = $this->request->param('page', 1);
|
||||
$limit = $this->request->param('limit', 10);
|
||||
$keyword = $this->request->param('keyword', '');
|
||||
$groupIds = $this->request->param('groupIds', '');
|
||||
$accountId = $this->getUserInfo('s2_accountId');
|
||||
if (empty($accountId)){
|
||||
return ResponseHelper::error('请先登录');
|
||||
}
|
||||
$query = Db::table('s2_wechat_chatroom')
|
||||
->where(['accountId' => $accountId,'isDeleted' => 0])
|
||||
->order('id desc');
|
||||
->where(['accountId' => $accountId,'isDeleted' => 0]);
|
||||
|
||||
// 关键字搜索:群昵称、微信号(这里使用chatroomId作为群标识)
|
||||
if ($keyword !== '' && $keyword !== null) {
|
||||
$query->where(function ($q) use ($keyword) {
|
||||
$like = '%' . $keyword . '%';
|
||||
$q->whereLike('nickname', $like)
|
||||
->whereOr('conRemark', 'like', $like);
|
||||
});
|
||||
}
|
||||
|
||||
// 分组筛选:groupIds(单个分组ID)
|
||||
if ($groupIds !== '' && $groupIds !== null) {
|
||||
$query->where('groupIds', $groupIds);
|
||||
}
|
||||
|
||||
$query->order('id desc');
|
||||
$total = $query->count();
|
||||
$list = $query->page($page, $limit)->select();
|
||||
|
||||
|
||||
@@ -13,13 +13,32 @@ class WechatFriendController extends BaseController
|
||||
{
|
||||
$page = $this->request->param('page', 1);
|
||||
$limit = $this->request->param('limit', 10);
|
||||
$keyword = $this->request->param('keyword', '');
|
||||
$groupIds = $this->request->param('groupIds', '');
|
||||
$accountId = $this->getUserInfo('s2_accountId');
|
||||
if (empty($accountId)) {
|
||||
return ResponseHelper::error('请先登录');
|
||||
}
|
||||
$query = Db::table('s2_wechat_friend')
|
||||
->where(['accountId' => $accountId, 'isDeleted' => 0])
|
||||
->order('id desc');
|
||||
->where(['accountId' => $accountId, 'isDeleted' => 0]);
|
||||
|
||||
// 关键字搜索:昵称、备注、微信号
|
||||
if ($keyword !== '' && $keyword !== null) {
|
||||
$query->where(function ($q) use ($keyword) {
|
||||
$like = '%' . $keyword . '%';
|
||||
$q->whereLike('nickname', $like)
|
||||
->whereOr('conRemark', 'like', $like)
|
||||
->whereOr('alias', 'like', $like)
|
||||
->whereOr('wechatId', 'like', $like);
|
||||
});
|
||||
}
|
||||
|
||||
// 分组筛选:groupIds(单个分组ID)
|
||||
if ($groupIds !== '' && $groupIds !== null) {
|
||||
$query->where('groupIds', $groupIds);
|
||||
}
|
||||
|
||||
$query->order('id desc');
|
||||
$total = $query->count();
|
||||
$list = $query->page($page, $limit)->select();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user