71 lines
2.3 KiB
PHP
71 lines
2.3 KiB
PHP
<?php
|
|
|
|
namespace app\index\controller\ye4s;
|
|
|
|
use app\common\controller\Frontend;
|
|
use think\Config;
|
|
|
|
class Pick extends Frontend
|
|
{
|
|
|
|
protected $noNeedLogin = '';
|
|
protected $noNeedRight = '*';
|
|
protected $layout = 'default';
|
|
|
|
public function _initialize()
|
|
{
|
|
parent::_initialize();
|
|
$auth = $this->auth;
|
|
|
|
if (!Config::get('fastadmin.usercenter')) {
|
|
$this->error(__('User center already closed'), '/');
|
|
}
|
|
}
|
|
public function index()
|
|
{
|
|
$this->request->filter(['strip_tags', 'trim']);
|
|
if ($this->request->isAjax()) {
|
|
if ($this->request->request('keyField')) {
|
|
return $this->selectpage();
|
|
}
|
|
$childrenGroupIds = $this->childrenGroupIds;
|
|
$groupName = AuthGroup::where('id', 'in', $childrenGroupIds)
|
|
->column('id,name');
|
|
$authGroupList = AuthGroupAccess::where('group_id', 'in', $childrenGroupIds)
|
|
->field('uid,group_id')
|
|
->select();
|
|
|
|
$adminGroupName = [];
|
|
foreach ($authGroupList as $k => $v) {
|
|
if (isset($groupName[$v['group_id']])) {
|
|
$adminGroupName[$v['uid']][$v['group_id']] = $groupName[$v['group_id']];
|
|
}
|
|
}
|
|
$groups = $this->auth->getGroups();
|
|
foreach ($groups as $m => $n) {
|
|
$adminGroupName[$this->auth->id][$n['id']] = $n['name'];
|
|
}
|
|
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
|
|
|
$list = $this->model
|
|
->where($where)
|
|
->where('id', 'in', $this->childrenAdminIds)
|
|
->field(['password', 'salt', 'token'], true)
|
|
->order($sort, $order)
|
|
->paginate($limit);
|
|
|
|
foreach ($list as $k => &$v) {
|
|
$groups = isset($adminGroupName[$v['id']]) ? $adminGroupName[$v['id']] : [];
|
|
$v['groups'] = implode(',', array_keys($groups));
|
|
$v['groups_text'] = implode(',', array_values($groups));
|
|
}
|
|
unset($v);
|
|
$result = array("total" => $list->total(), "rows" => $list->items());
|
|
|
|
return json($result);
|
|
}
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
}
|