Files
im/plugin/admin/app/controller/FriendController.php
T
2026-03-01 21:05:19 +08:00

60 lines
1.6 KiB
PHP
Executable File

<?php
namespace plugin\admin\app\controller;
use app\model\User;
use plugin\admin\app\controller\Crud;
use support\exception\BusinessException;
use support\Request;
use support\Response;
use Throwable;
/**
* 用户宣传
*/
class FriendController extends OpenimBase
{
protected $relationSearch = [];
/**
* 构造函数
* @return void
*/
function __construct()
{
$this->model = new User();
$statusList = $this->model->getStatusList();
$this->assign("statusList", $statusList);
$this->assignconfig("statusList", $statusList);
}
function select(Request $request): Response
{
$res = $this->getSdk()->friend->getFriendList(Input('userID'), 1, 5000);
$userIDs = [];
foreach ($res['friendsInfo'] as $key => $value) {
$userIDs[] = $value['friendUser']['userID'];
}
//$_users = \app\model\User::whereIn('userID', $userIDs)->column('*','userID');
[$where, $format, $limit, $field, $order] = $this->selectInput($request);
$where['userId'] = ['symbol'=>'in', 'value1'=>$userIDs];
$query = $this->doSelect($where, $field, $order);
return $this->doFormat($query, $format, $limit);
$list = [];
foreach ($res['friendsInfo'] as $key => $value) {
$item = array_merge($value['friendUser'], $_users[$value['friendUser']['userID']] ?? [],$value['friendUser']);
unset($item['friendUser']);
$list[] =$item;
}
return json([
"code" => 0,
"count" => $res['total'],
"data" => $list,
"msg" => "ok"
]);
}
}