module(); $controller = $request->controller(); $action = $request->action(); $route = $request->route(); $data = [ 'method' => $request->method(), 'admin_id' => $adminId, 'admin_name' => $adminName, 'path' => SystemMenus::getAuthName($action, $controller, $module, $route), 'page' => SystemMenus::getVisitName($action, $controller, $module, $route) ?: '未知', 'ip' => $request->ip(), 'type' => $type ]; return self::set($data); } /** * 手动添加管理员当前页面访问记录 * @param array $adminInfo * @param string $page 页面名称 * @return object */ public static function setCurrentVisit($adminInfo, $page) { $request = Request::instance(); $module = $request->module(); $controller = $request->controller(); $action = $request->action(); $route = $request->route(); $data = [ 'method' => $request->method(), 'admin_id' => $adminInfo['id'], 'path' => SystemMenus::getAuthName($action, $controller, $module, $route), 'page' => $page, 'ip' => $request->ip() ]; return self::set($data); } /** * 获取管理员访问记录 * */ public static function systemPage($where = array()) { $model = new self; $model = $model->alias('l'); if ($where['pages'] !== '') $model = $model->where('l.page', 'LIKE', "%$where[pages]%"); if ($where['admin_id'] != '') $adminIds = $where['admin_id']; else $adminIds = SystemAdmin::where('level', '>=', $where['level'])->column('id'); $model = $model->where('l.admin_id', 'IN', $adminIds); if ($where['data'] !== '') { list($startTime, $endTime) = explode(' - ', $where['data']); $model = $model->where('l.add_time', '>', strtotime($startTime)); $model = $model->where('l.add_time', '<', strtotime($endTime)); } $model->where('l.type', 'system'); $model = $model->order('l.id desc'); return self::page($model, $where); } /** * 删除超过90天的日志 */ public static function deleteLog() { $model = new self; $model->where('add_time', '<', time() - 7776000); $model->delete(); } }