mirror of
https://gitee.com/ctexthuang/hyperf_rbac_framework_server_ctexthuang.git
synced 2025-12-25 14:25:40 +08:00
feat : admin user finish
This commit is contained in:
@@ -4,9 +4,11 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\Admin;
|
||||
|
||||
use App\Annotation\Permission;
|
||||
use App\Annotation\ResponseFormat;
|
||||
use App\Middleware\Token\AdminTokenMiddleware;
|
||||
use App\Service\Admin\AdminUser\UserService;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Hyperf\HttpServer\Annotation\Controller;
|
||||
use Hyperf\HttpServer\Annotation\Middleware;
|
||||
use Hyperf\HttpServer\Annotation\RequestMapping;
|
||||
@@ -18,13 +20,19 @@ use Hyperf\Validation\Annotation\Scene;
|
||||
#[Middleware(AdminTokenMiddleware::class)]
|
||||
class AdminUserController
|
||||
{
|
||||
/**
|
||||
* @var UserService
|
||||
*/
|
||||
#[Inject]
|
||||
protected UserService $service;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
#[RequestMapping(path: "getInfo", methods: "GET")]
|
||||
public function getInfo(): array
|
||||
{
|
||||
return (new UserService)->handle();
|
||||
return $this->service->handle();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,6 +41,85 @@ class AdminUserController
|
||||
#[RequestMapping(path: "logout", methods: "POST")]
|
||||
public function logout(): array
|
||||
{
|
||||
return (new UserService)->logout();
|
||||
return $this->service->logout();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
#[RequestMapping(path: "list", methods: "GET")]
|
||||
#[Permission(code: 'permission:user:index')]
|
||||
public function pageList(): array
|
||||
{
|
||||
return $this->service->list();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
#[RequestMapping(path: "", methods: "PUT")]
|
||||
#[Permission(code: 'permission:user:update')]
|
||||
public function updateInfo(): array
|
||||
{
|
||||
return $this->service->updateInfo();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
#[RequestMapping(path: "password", methods: "PUT")]
|
||||
#[Permission(code: 'permission:user:password')]
|
||||
public function resetPassword(): array
|
||||
{
|
||||
return $this->service->resetPassword();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
#[RequestMapping(path: "", methods: "POST")]
|
||||
#[Permission(code: 'permission:user:save')]
|
||||
public function createAdminUser(): array
|
||||
{
|
||||
return $this->service->createUser();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
#[RequestMapping(path: "", methods: "DELETE")]
|
||||
#[Permission(code: 'permission:user:delete')]
|
||||
public function deleteAdminUser(): array
|
||||
{
|
||||
return $this->service->deleteUser();
|
||||
}
|
||||
|
||||
#[RequestMapping(path: "{userId}", methods: "PUT")]
|
||||
#[Permission(code: 'permission:user:update')]
|
||||
public function saveInfo(int $userId): array
|
||||
{
|
||||
return $this->service->saveUser($userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $userId
|
||||
* @return array
|
||||
*/
|
||||
#[RequestMapping(path: "{userId}/roles", methods: "GET")]
|
||||
#[Permission(code: 'permission:user:getRole')]
|
||||
public function getAdminUserRole(int $userId): array
|
||||
{
|
||||
return $this->service->getUserRole($userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $userId
|
||||
* @return array
|
||||
*/
|
||||
#[RequestMapping(path: "{userId}/roles", methods: "PUT")]
|
||||
#[Permission(code: 'permission:user:setRole')]
|
||||
public function batchGrantRolesForAdminUser(int $userId): array
|
||||
{
|
||||
return $this->service->batchGrantRoleForUser($userId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user