mirror of https://gitee.com/karson/fastadmin.git
147 lines
3.7 KiB
PHP
147 lines
3.7 KiB
PHP
<?php
|
|
|
|
namespace app\admin\controller\auth;
|
|
|
|
use app\common\controller\Backend;
|
|
use fast\Tree;
|
|
|
|
/**
|
|
* 管理员日志
|
|
*
|
|
* @icon fa fa-users
|
|
* @remark 管理员可以查看自己所拥有的权限的管理员日志
|
|
*/
|
|
class Adminlog extends Backend
|
|
{
|
|
|
|
protected $model = null;
|
|
//当前登录管理员所有子节点组别
|
|
protected $childrenIds = [];
|
|
|
|
public function _initialize()
|
|
{
|
|
parent::_initialize();
|
|
$this->model = model('AdminLog');
|
|
|
|
$groups = $this->auth->getGroups();
|
|
|
|
// 取出所有分组
|
|
$grouplist = model('AuthGroup')->all(['status' => 'normal']);
|
|
$objlist = [];
|
|
foreach ($groups as $K => $v)
|
|
{
|
|
// 取出包含自己的所有子节点
|
|
$childrenlist = Tree::instance()->init($grouplist)->getChildren($v['id'], TRUE);
|
|
$obj = Tree::instance()->init($childrenlist)->getTreeArray($v['pid']);
|
|
$objlist = array_merge($objlist, Tree::instance()->getTreeList($obj));
|
|
}
|
|
$groupdata = [];
|
|
foreach ($objlist as $k => $v)
|
|
{
|
|
$groupdata[$v['id']] = $v['name'];
|
|
}
|
|
$this->childrenIds = array_keys($groupdata);
|
|
$this->view->assign('groupdata', $groupdata);
|
|
}
|
|
|
|
/**
|
|
* 查看
|
|
*/
|
|
public function index()
|
|
{
|
|
if ($this->request->isAjax())
|
|
{
|
|
$childrenAdminIds = model('AuthGroupAccess')
|
|
->field('uid')
|
|
->where('group_id', 'in', $this->childrenIds)
|
|
->column('uid');
|
|
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
|
$total = $this->model
|
|
->where($where)
|
|
->where('admin_id', 'in', $childrenAdminIds)
|
|
->order($sort, $order)
|
|
->count();
|
|
|
|
$list = $this->model
|
|
->where($where)
|
|
->where('admin_id', 'in', $childrenAdminIds)
|
|
->order($sort, $order)
|
|
->limit($offset, $limit)
|
|
->select();
|
|
$result = array("total" => $total, "rows" => $list);
|
|
|
|
return json($result);
|
|
}
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
/**
|
|
* 详情
|
|
*/
|
|
public function detail($ids)
|
|
{
|
|
$row = $this->model->get(['id' => $ids]);
|
|
if (!$row)
|
|
$this->error(__('No Results were found'));
|
|
$this->view->assign("row", $row->toArray());
|
|
return $this->view->fetch();
|
|
}
|
|
|
|
/**
|
|
* 添加
|
|
* @internal
|
|
*/
|
|
public function add()
|
|
{
|
|
$this->error();
|
|
}
|
|
|
|
/**
|
|
* 编辑
|
|
* @internal
|
|
*/
|
|
public function edit($ids = NULL)
|
|
{
|
|
$this->error();
|
|
}
|
|
|
|
/**
|
|
* 删除
|
|
*/
|
|
public function del($ids = "")
|
|
{
|
|
if ($ids)
|
|
{
|
|
$childrenGroupIds = $this->childrenIds;
|
|
$adminList = $this->model->where('id', 'in', $ids)->where('admin_id', 'in', function($query) use($childrenGroupIds) {
|
|
$query->name('auth_group_access')->field('uid');
|
|
})->select();
|
|
if ($adminList)
|
|
{
|
|
$deleteIds = [];
|
|
foreach ($adminList as $k => $v)
|
|
{
|
|
$deleteIds[] = $v->id;
|
|
}
|
|
if ($deleteIds)
|
|
{
|
|
$this->model->destroy($deleteIds);
|
|
$this->success();
|
|
}
|
|
}
|
|
}
|
|
$this->error();
|
|
}
|
|
|
|
/**
|
|
* 批量更新
|
|
* @internal
|
|
*/
|
|
public function multi($ids = "")
|
|
{
|
|
// 管理员禁止批量操作
|
|
$this->error();
|
|
}
|
|
|
|
}
|