hyperf-view/app/System/Controller/Monitor/OnlineUserMonitorController...

51 lines
1.6 KiB
PHP

<?php
declare(strict_types = 1);
namespace App\System\Controller\Monitor;
use App\System\Service\SystemUserService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\GetMapping;
use Hyperf\HttpServer\Annotation\PostMapping;
use Builder\Annotation\Auth;
use Builder\Annotation\Permission;
use Builder\BaseController;
/**
* 在线用户监控
* Class OnlineUserMonitorController
* @package App\System\Controller\Monitor
*/
#[Controller(prefix: "system/onlineUser"), Auth]
class OnlineUserMonitorController extends BaseController
{
#[Inject]
protected SystemUserService $service;
/**
* 获取在线用户列表
* @return \Psr\Http\Message\ResponseInterface
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
*/
#[GetMapping("index"), Permission("system:onlineUser, system:onlineUser:index")]
public function getPageList(): \Psr\Http\Message\ResponseInterface
{
return $this->success($this->service->getOnlineUserPageList($this->request->all()));
}
/**
* 强退用户
* @return \Psr\Http\Message\ResponseInterface
* @throws \Psr\Container\ContainerExceptionInterface
* @throws \Psr\Container\NotFoundExceptionInterface
* @throws \Psr\SimpleCache\InvalidArgumentException
*/
#[PostMapping("kick"), Permission("system:onlineUser:kick")]
public function kickUser(): \Psr\Http\Message\ResponseInterface
{
return $this->service->kickUser((string) $this->request->input('id')) ?
$this->success() : $this->error();
}
}