mirror of
https://gitee.com/ctexthuang/hyperf_rbac_framework_server_ctexthuang.git
synced 2025-12-25 11:22:10 +08:00
fix : update path And request
This commit is contained in:
@@ -4,18 +4,18 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Aspect;
|
||||
|
||||
use App\Common\Repository\AdminUserRepository;
|
||||
use App\Common\Trait\ClientIpTrait;
|
||||
use App\Common\Trait\ClientOsTrait;
|
||||
use App\Lib\Log\Logger;
|
||||
use App\Model\AdminUserLoginLog;
|
||||
use App\Repository\AdminUserRepository;
|
||||
use App\Service\Admin\Login\LoginService;
|
||||
use App\Trait\ClientIpTrait;
|
||||
use App\Trait\ClientOsTrait;
|
||||
use Hyperf\Coroutine\Coroutine;
|
||||
use Hyperf\Di\Annotation\Aspect;
|
||||
use Hyperf\Di\Aop\AbstractAspect;
|
||||
use Hyperf\Di\Aop\ProceedingJoinPoint;
|
||||
use Hyperf\Di\Exception\Exception;
|
||||
use Hyperf\HttpServer\Contract\RequestInterface;
|
||||
use Hyperf\Di\Aop\ProceedingJoinPoint;
|
||||
use Throwable;
|
||||
|
||||
#[Aspect]
|
||||
|
||||
@@ -4,20 +4,18 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Aspect;
|
||||
|
||||
use App\Common\Trait\AdminUserTrait;
|
||||
use App\Common\Trait\ClientIpTrait;
|
||||
use App\Lib\Log\Logger;
|
||||
use App\Lib\Return\AdminReturn;
|
||||
use App\Model\AdminUser;
|
||||
use App\Model\AdminUserOperationLog;
|
||||
use App\Service\Admin\Login\LoginService;
|
||||
use App\Trait\AdminUserTrait;
|
||||
use App\Trait\ClientIpTrait;
|
||||
use Hyperf\Context\Context;
|
||||
use Hyperf\Coroutine\Coroutine;
|
||||
use Hyperf\Di\Annotation\Aspect;
|
||||
use Hyperf\Di\Aop\AbstractAspect;
|
||||
use Hyperf\HttpServer\Contract\RequestInterface;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Hyperf\Di\Aop\ProceedingJoinPoint;
|
||||
use Hyperf\HttpServer\Contract\RequestInterface;
|
||||
|
||||
#[Aspect]
|
||||
class AdminReturnLogAspect extends AbstractAspect
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Interface;
|
||||
namespace App\Common\Interface;
|
||||
|
||||
use Lcobucci\JWT\UnencryptedToken;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Interface;
|
||||
namespace App\Common\Interface;
|
||||
|
||||
use Lcobucci\JWT\UnencryptedToken;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
namespace App\Common\Repository;
|
||||
|
||||
use App\Constants\Model\AdminUser\AdminMenuStatusCode;
|
||||
use App\Model\AdminMenu;
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
namespace App\Common\Repository;
|
||||
|
||||
use App\Model\AdminRole;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
namespace App\Common\Repository;
|
||||
|
||||
use App\Model\AdminUserLoginLog;
|
||||
use Hyperf\Collection\Arr;
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
namespace App\Common\Repository;
|
||||
|
||||
use App\Model\AdminUserOperationLog;
|
||||
|
||||
@@ -8,13 +8,11 @@
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Repository;
|
||||
namespace App\Common\Repository;
|
||||
|
||||
use App\Model\AdminUser;
|
||||
use Hyperf\Collection\Arr;
|
||||
use Hyperf\Database\Concerns\BuildsQueries;
|
||||
use Hyperf\Database\Model\Builder;
|
||||
use Hyperf\Database\Model\Model;
|
||||
|
||||
/**
|
||||
* Class AdminUserRepository
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository;
|
||||
namespace App\Common\Repository;
|
||||
|
||||
use App\Repository\Traits\BootTrait;
|
||||
use App\Repository\Traits\RepositoryOrderByTrait;
|
||||
use App\Common\Repository\Traits\BootTrait;
|
||||
use App\Common\Repository\Traits\RepositoryOrderByTrait;
|
||||
use Hyperf\Collection\Collection;
|
||||
use Hyperf\Contract\LengthAwarePaginatorInterface;
|
||||
use Hyperf\Database\Model\Builder;
|
||||
@@ -13,7 +13,7 @@ use Hyperf\Paginator\AbstractPaginator;
|
||||
|
||||
/**
|
||||
* @template T of Model
|
||||
* @property T $model
|
||||
* @property Model $model
|
||||
*/
|
||||
abstract class BaseRepository
|
||||
{
|
||||
@@ -67,7 +67,7 @@ abstract class BaseRepository
|
||||
}
|
||||
|
||||
/**
|
||||
* @return T
|
||||
* @return Model
|
||||
*/
|
||||
public function create(array $data): mixed
|
||||
{
|
||||
@@ -81,7 +81,7 @@ abstract class BaseRepository
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|T
|
||||
* @return null|Model
|
||||
*/
|
||||
public function saveById(mixed $id, array $data): mixed
|
||||
{
|
||||
@@ -105,7 +105,7 @@ abstract class BaseRepository
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|T
|
||||
* @return null|Model
|
||||
*/
|
||||
public function findById(mixed $id): mixed
|
||||
{
|
||||
@@ -118,7 +118,7 @@ abstract class BaseRepository
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|T
|
||||
* @return null|Model
|
||||
*/
|
||||
public function findByFilter(array $params): mixed
|
||||
{
|
||||
@@ -142,7 +142,7 @@ abstract class BaseRepository
|
||||
}
|
||||
|
||||
/**
|
||||
* @return T
|
||||
* @return Model
|
||||
*/
|
||||
public function getModel(): Model
|
||||
{
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository\Traits;
|
||||
namespace App\Common\Repository\Traits;
|
||||
|
||||
use function Hyperf\Support\class_basename;
|
||||
use function Hyperf\Support\class_uses_recursive;
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repository\Traits;
|
||||
namespace App\Common\Repository\Traits;
|
||||
|
||||
use Hyperf\Database\Model\Builder;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Trait;
|
||||
namespace App\Common\Trait;
|
||||
|
||||
use App\Cache\Redis\RedisCache;
|
||||
use App\Cache\Redis\RedisKey;
|
||||
use App\Common\Repository\AdminUserRepository;
|
||||
use App\Model\AdminUser;
|
||||
use App\Repository\AdminUserRepository;
|
||||
use Hyperf\Context\Context;
|
||||
use Hyperf\Database\Model\Model;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Trait;
|
||||
namespace App\Common\Trait;
|
||||
|
||||
use App\Constants\Common\ClientIpRequestConstant;
|
||||
use App\Exception\ErrException;
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Trait;
|
||||
namespace App\Common\Trait;
|
||||
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Hyperf\HttpServer\Contract\RequestInterface;
|
||||
47
app/Common/Trait/HttpMethodTrait.php
Normal file
47
app/Common/Trait/HttpMethodTrait.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace App\Common\Trait;
|
||||
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Hyperf\HttpServer\Contract\RequestInterface;
|
||||
|
||||
trait HttpMethodTrait
|
||||
{
|
||||
/**
|
||||
* @var RequestInterface
|
||||
*/
|
||||
#[Inject]
|
||||
protected readonly RequestInterface $request;
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isCreate(): bool
|
||||
{
|
||||
return $this->request->isMethod('POST');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isUpdate(): bool
|
||||
{
|
||||
return $this->request->isMethod('PATCH') || $this->request->isMethod('PUT');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isDelete(): bool
|
||||
{
|
||||
return $this->request->isMethod('DELETE');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isSearch(): bool
|
||||
{
|
||||
return $this->request->isMethod('GET');
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace App\Trait;
|
||||
namespace App\Common\Trait;
|
||||
|
||||
trait ParserRouterTrait
|
||||
{
|
||||
@@ -9,11 +9,13 @@ use App\Annotation\ResponseFormat;
|
||||
use App\Controller\AbstractController;
|
||||
use App\Middleware\Admin\AdminTokenMiddleware;
|
||||
use App\Middleware\Admin\PermissionMiddleware;
|
||||
use App\Request\Admin\AdminMenuRequest;
|
||||
use App\Service\Admin\AdminUser\MenuService;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Hyperf\HttpServer\Annotation\Controller;
|
||||
use Hyperf\HttpServer\Annotation\Middleware;
|
||||
use Hyperf\HttpServer\Annotation\RequestMapping;
|
||||
use Hyperf\Validation\Annotation\Scene;
|
||||
|
||||
|
||||
#[Controller(prefix: "admin/menu")]
|
||||
@@ -39,22 +41,26 @@ class AdminMenuController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AdminMenuRequest $request
|
||||
* @return array
|
||||
*/
|
||||
#[RequestMapping(path: "", methods: "POST")]
|
||||
#[Permission(code: 'permission:menu:create')]
|
||||
public function createMenu(): array
|
||||
#[Scene(scene: "create")]
|
||||
public function createMenu(AdminMenuRequest $request): array
|
||||
{
|
||||
return $this->service->create();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param AdminMenuRequest $request
|
||||
* @return array
|
||||
*/
|
||||
#[RequestMapping(path: "{id}", methods: "PUT")]
|
||||
#[Permission(code: 'permission:menu:save')]
|
||||
public function updateMenu(int $id): array
|
||||
#[Scene(scene: "update")]
|
||||
public function updateMenu(int $id, AdminMenuRequest $request): array
|
||||
{
|
||||
return $this->service->update($id);
|
||||
}
|
||||
|
||||
@@ -9,11 +9,13 @@ use App\Annotation\ResponseFormat;
|
||||
use App\Controller\AbstractController;
|
||||
use App\Middleware\Admin\AdminTokenMiddleware;
|
||||
use App\Middleware\Admin\PermissionMiddleware;
|
||||
use App\Request\Admin\AdminRoleRequest;
|
||||
use App\Service\Admin\AdminUser\RoleService;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Hyperf\HttpServer\Annotation\Controller;
|
||||
use Hyperf\HttpServer\Annotation\Middleware;
|
||||
use Hyperf\HttpServer\Annotation\RequestMapping;
|
||||
use Hyperf\Validation\Annotation\Scene;
|
||||
|
||||
|
||||
#[Controller(prefix: "admin/role")]
|
||||
@@ -39,22 +41,26 @@ class AdminRoleController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AdminRoleRequest $request
|
||||
* @return array
|
||||
*/
|
||||
#[RequestMapping(path: "", methods: "POST")]
|
||||
#[Permission(code: 'permission:role:save')]
|
||||
public function createRole(): array
|
||||
#[Scene(scene: "create")]
|
||||
public function createRole(AdminRoleRequest $request): array
|
||||
{
|
||||
return $this->service->create();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param AdminRoleRequest $request
|
||||
* @return array
|
||||
*/
|
||||
#[RequestMapping(path: "{id}", methods: "PUT")]
|
||||
#[Permission(code: 'permission:role:update')]
|
||||
public function updateRole(int $id): array
|
||||
#[Scene(scene: "create")]
|
||||
public function updateRole(int $id, AdminRoleRequest $request): array
|
||||
{
|
||||
return $this->service->update($id);
|
||||
}
|
||||
@@ -82,11 +88,13 @@ class AdminRoleController extends AbstractController
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @param AdminRoleRequest $request
|
||||
* @return array
|
||||
*/
|
||||
#[RequestMapping(path: "{id}/permission", methods: "PUT")]
|
||||
#[Permission(code: 'permission:role:setMenu')]
|
||||
public function batchGrantPermissionByRole(int $id): array
|
||||
#[Scene(scene: "batch_grant_permission")]
|
||||
public function batchGrantPermissionByRole(int $id,AdminRoleRequest $request): array
|
||||
{
|
||||
return $this->service->setRole($id);
|
||||
}
|
||||
|
||||
@@ -9,11 +9,13 @@ use App\Annotation\ResponseFormat;
|
||||
use App\Controller\AbstractController;
|
||||
use App\Middleware\Admin\AdminTokenMiddleware;
|
||||
use App\Middleware\Admin\PermissionMiddleware;
|
||||
use App\Request\Admin\AdminUserRequest;
|
||||
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;
|
||||
use Hyperf\Validation\Annotation\Scene;
|
||||
|
||||
|
||||
#[Controller(prefix: "admin/adminUser")]
|
||||
@@ -57,11 +59,13 @@ class AdminUserController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AdminUserRequest $request
|
||||
* @return array
|
||||
*/
|
||||
#[RequestMapping(path: "", methods: "PUT")]
|
||||
#[Permission(code: 'permission:user:update')]
|
||||
public function updateInfo(): array
|
||||
#[Scene(scene: "update")]
|
||||
public function updateInfo(AdminUserRequest $request): array
|
||||
{
|
||||
return $this->service->updateInfo();
|
||||
}
|
||||
@@ -77,11 +81,13 @@ class AdminUserController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AdminUserRequest $request
|
||||
* @return array
|
||||
*/
|
||||
#[RequestMapping(path: "", methods: "POST")]
|
||||
#[Permission(code: 'permission:user:save')]
|
||||
public function createAdminUser(): array
|
||||
#[Scene(scene: "create")]
|
||||
public function createAdminUser(AdminUserRequest $request): array
|
||||
{
|
||||
return $this->service->createUser();
|
||||
}
|
||||
@@ -98,7 +104,8 @@ class AdminUserController extends AbstractController
|
||||
|
||||
#[RequestMapping(path: "{userId}", methods: "PUT")]
|
||||
#[Permission(code: 'permission:user:update')]
|
||||
public function saveInfo(int $userId): array
|
||||
#[Scene(scene: "update")]
|
||||
public function saveInfo(int $userId,AdminUserRequest $request): array
|
||||
{
|
||||
return $this->service->saveUser($userId);
|
||||
}
|
||||
@@ -116,11 +123,13 @@ class AdminUserController extends AbstractController
|
||||
|
||||
/**
|
||||
* @param int $userId
|
||||
* @param AdminUserRequest $request
|
||||
* @return array
|
||||
*/
|
||||
#[RequestMapping(path: "{userId}/roles", methods: "PUT")]
|
||||
#[Permission(code: 'permission:user:setRole')]
|
||||
public function batchGrantRolesForAdminUser(int $userId): array
|
||||
#[Scene(scene: "batch_grant_role")]
|
||||
public function batchGrantRolesForAdminUser(int $userId,AdminUserRequest $request): array
|
||||
{
|
||||
return $this->service->batchGrantRoleForUser($userId);
|
||||
}
|
||||
|
||||
@@ -8,11 +8,13 @@ use App\Annotation\Permission;
|
||||
use App\Annotation\ResponseFormat;
|
||||
use App\Controller\AbstractController;
|
||||
use App\Middleware\Admin\AdminTokenMiddleware;
|
||||
use App\Request\Admin\PermissionRequest;
|
||||
use App\Service\Admin\AdminUser\PermissionService;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Hyperf\HttpServer\Annotation\Controller;
|
||||
use Hyperf\HttpServer\Annotation\Middleware;
|
||||
use Hyperf\HttpServer\Annotation\RequestMapping;
|
||||
use Hyperf\Validation\Annotation\Scene;
|
||||
|
||||
#[Controller(prefix: "admin/permission")]
|
||||
#[ResponseFormat('admin')]
|
||||
@@ -44,10 +46,12 @@ class PermissionController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PermissionRequest $request
|
||||
* @return array
|
||||
*/
|
||||
#[RequestMapping(path: "update", methods: "POST")]
|
||||
public function update(): array
|
||||
#[Scene(scene: "update")]
|
||||
public function update(PermissionRequest $request): array
|
||||
{
|
||||
return $this->service->update();
|
||||
}
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Lib\Jwt;
|
||||
|
||||
use App\Constants\ResultCode;
|
||||
use App\Exception\ErrException;
|
||||
use App\Interface\JwtInterface;
|
||||
use App\Common\Interface\JwtInterface;
|
||||
use Carbon\Carbon;
|
||||
use Hyperf\Cache\CacheManager;
|
||||
use Hyperf\Cache\Driver\DriverInterface;
|
||||
@@ -18,7 +16,6 @@ use Lcobucci\JWT\UnencryptedToken;
|
||||
use Lcobucci\JWT\Validation\Constraint;
|
||||
use Lcobucci\JWT\Validation\Constraint\SignedWith;
|
||||
use Lcobucci\JWT\Validation\Constraint\StrictValidAt;
|
||||
use Lcobucci\JWT\Validation\RequiredConstraintsViolated;
|
||||
use Psr\SimpleCache\InvalidArgumentException;
|
||||
|
||||
abstract class AbstractJwt implements JwtInterface
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
namespace App\Lib\Jwt;
|
||||
|
||||
use App\Interface\JwtInterface;
|
||||
use App\Common\Interface\JwtInterface;
|
||||
|
||||
final class Jwt extends AbstractJwt implements JwtInterface {}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\Lib\Jwt;
|
||||
|
||||
use App\Interface\JwtInterface;
|
||||
use App\Common\Interface\JwtInterface;
|
||||
use Hyperf\Collection\Arr;
|
||||
use Hyperf\Contract\ConfigInterface;
|
||||
use function Hyperf\Support\make;
|
||||
|
||||
@@ -4,9 +4,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Middleware\Admin;
|
||||
|
||||
use App\Common\Interface\JwtInterface;
|
||||
use App\Constants\ResultCode;
|
||||
use App\Exception\ErrException;
|
||||
use App\Interface\JwtInterface;
|
||||
use App\Middleware\Token\AbstractTokenMiddleware;
|
||||
use Lcobucci\JWT\Token\RegisteredClaims;
|
||||
use Lcobucci\JWT\UnencryptedToken;
|
||||
|
||||
@@ -5,21 +5,21 @@ declare(strict_types=1);
|
||||
namespace App\Middleware\Admin;
|
||||
|
||||
use App\Annotation\Permission;
|
||||
use App\Common\Trait\AdminUserTrait;
|
||||
use App\Common\Trait\ParserRouterTrait;
|
||||
use App\Constants\AdminCode;
|
||||
use App\Constants\Model\AdminUser\AdminUserStatusCode;
|
||||
use App\Exception\ErrException;
|
||||
use App\Lib\Jwt\RequestScopedTokenTrait;
|
||||
use App\Model\AdminUser;
|
||||
use App\Trait\AdminUserTrait;
|
||||
use App\Trait\ParserRouterTrait;
|
||||
use Hyperf\Collection\Arr;
|
||||
use Hyperf\Di\Annotation\AnnotationCollector;
|
||||
use Hyperf\HttpServer\Router\Dispatched;
|
||||
use Lcobucci\JWT\Token\RegisteredClaims;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Server\MiddlewareInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\MiddlewareInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
|
||||
class PermissionMiddleware implements MiddlewareInterface
|
||||
|
||||
@@ -4,9 +4,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Middleware\Admin;
|
||||
|
||||
use App\Common\Interface\JwtInterface;
|
||||
use App\Constants\ResultCode;
|
||||
use App\Exception\ErrException;
|
||||
use App\Interface\JwtInterface;
|
||||
use App\Middleware\Token\AbstractTokenMiddleware;
|
||||
use Lcobucci\JWT\Token\RegisteredClaims;
|
||||
use Lcobucci\JWT\UnencryptedToken;
|
||||
|
||||
@@ -4,10 +4,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Middleware\Token;
|
||||
|
||||
use App\Common\Interface\CheckTokenInterface;
|
||||
use App\Common\Interface\JwtInterface;
|
||||
use App\Constants\ResultCode;
|
||||
use App\Exception\ErrException;
|
||||
use App\Interface\CheckTokenInterface;
|
||||
use App\Interface\JwtInterface;
|
||||
use App\Lib\Jwt\JwtFactory;
|
||||
use Hyperf\Collection\Arr;
|
||||
use Hyperf\Stringable\Str;
|
||||
|
||||
114
app/Request/Admin/AdminMenuRequest.php
Normal file
114
app/Request/Admin/AdminMenuRequest.php
Normal file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Request\Admin;
|
||||
|
||||
use Hyperf\Validation\Request\FormRequest;
|
||||
|
||||
class AdminMenuRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'parent_id' => 'sometimes|integer',
|
||||
'name' => 'required|string|max:255',
|
||||
'path' => 'sometimes|string|max:255',
|
||||
'component' => 'sometimes|string|max:255',
|
||||
'redirect' => 'sometimes|string|max:255',
|
||||
'status' => 'sometimes|integer',
|
||||
'sort' => 'sometimes|integer',
|
||||
'remark' => 'sometimes|string|max:255',
|
||||
'meta.title' => 'required|string|max:255',
|
||||
'meta.i18n' => 'sometimes|string|max:255',
|
||||
'meta.badge' => 'sometimes|string|max:255',
|
||||
'meta.link' => 'sometimes|string|max:255',
|
||||
'meta.icon' => 'sometimes|string|max:255',
|
||||
'meta.affix' => 'sometimes|boolean',
|
||||
'meta.hidden' => 'sometimes|boolean',
|
||||
'meta.type' => 'sometimes|string|max:255',
|
||||
'meta.cache' => 'sometimes|boolean',
|
||||
'meta.breadcrumbEnable' => 'sometimes|boolean',
|
||||
'meta.copyright' => 'sometimes|boolean',
|
||||
'meta.componentPath' => 'sometimes|string|max:64',
|
||||
'meta.componentSuffix' => 'sometimes|string|max:4',
|
||||
'meta.activeName' => 'sometimes|string|max:255',
|
||||
'btnPermission' => 'sometimes|array',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return parent::messages();
|
||||
}
|
||||
|
||||
/**
|
||||
* @var array|array[]
|
||||
*/
|
||||
protected array $scenes = [
|
||||
'update' => [
|
||||
'parent_id',
|
||||
'name',
|
||||
'path',
|
||||
'component',
|
||||
'redirect',
|
||||
'status',
|
||||
'sort',
|
||||
'remark',
|
||||
'meta.title',
|
||||
'meta.i18n',
|
||||
'meta.badge',
|
||||
'meta.link',
|
||||
'meta.icon',
|
||||
'meta.affix',
|
||||
'meta.hidden',
|
||||
'meta.type',
|
||||
'meta.cache',
|
||||
'meta.breadcrumbEnable',
|
||||
'meta.copyright',
|
||||
'meta.componentPath',
|
||||
'meta.componentSuffix',
|
||||
'meta.activeName',
|
||||
'btnPermission',
|
||||
],
|
||||
'create' => [
|
||||
'parent_id',
|
||||
'name',
|
||||
'path',
|
||||
'component',
|
||||
'redirect',
|
||||
'status',
|
||||
'sort',
|
||||
'remark',
|
||||
'meta.title',
|
||||
'meta.i18n',
|
||||
'meta.badge',
|
||||
'meta.link',
|
||||
'meta.icon',
|
||||
'meta.affix',
|
||||
'meta.hidden',
|
||||
'meta.type',
|
||||
'meta.cache',
|
||||
'meta.breadcrumbEnable',
|
||||
'meta.copyright',
|
||||
'meta.componentPath',
|
||||
'meta.componentSuffix',
|
||||
'meta.activeName',
|
||||
'btnPermission',
|
||||
],
|
||||
];
|
||||
}
|
||||
79
app/Request/Admin/AdminRoleRequest.php
Normal file
79
app/Request/Admin/AdminRoleRequest.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Request\Admin;
|
||||
|
||||
use App\Common\Trait\HttpMethodTrait;
|
||||
use Hyperf\Validation\Request\FormRequest;
|
||||
|
||||
class AdminRoleRequest extends FormRequest
|
||||
{
|
||||
use HttpMethodTrait;
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$rules = [
|
||||
'name' => 'required|string|max:60',
|
||||
'code' => [
|
||||
'required',
|
||||
'string',
|
||||
'max:60',
|
||||
'regex:/^[a-zA-Z0-9_]+$/',
|
||||
],
|
||||
'status' => 'sometimes|integer|in:1,2',
|
||||
'sort' => 'required|integer',
|
||||
'remark' => 'nullable|string|max:255',
|
||||
'permissions' => 'sometimes|array',
|
||||
'permissions.*' => 'string|exists:menu,name',
|
||||
];
|
||||
if ($this->isCreate()) {
|
||||
$rules['code'][] = 'unique:role,code';
|
||||
}
|
||||
if ($this->isUpdate()) {
|
||||
$rules['code'][] = 'unique:role,code,' . $this->route('id');
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return parent::messages();
|
||||
}
|
||||
|
||||
protected array $scenes = [
|
||||
'update' => [
|
||||
'code',
|
||||
'name',
|
||||
'status',
|
||||
'sort',
|
||||
'remark',
|
||||
],
|
||||
'create' => [
|
||||
'code',
|
||||
'name',
|
||||
'status',
|
||||
'sort',
|
||||
'remark',
|
||||
],
|
||||
'batch_grant_permission' => [
|
||||
'permissions',
|
||||
'permissions.*',
|
||||
]
|
||||
];
|
||||
}
|
||||
81
app/Request/Admin/AdminUserRequest.php
Normal file
81
app/Request/Admin/AdminUserRequest.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Request\Admin;
|
||||
|
||||
use Hyperf\Validation\Request\FormRequest;
|
||||
|
||||
class AdminUserRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'username' => 'required|string|max:20',
|
||||
'user_type' => 'required|integer',
|
||||
'nickname' => ['required', 'string', 'max:60', 'regex:/^[^\s]+$/'],
|
||||
'phone' => 'sometimes|string|max:12',
|
||||
'email' => 'sometimes|string|max:60|email:rfc,dns',
|
||||
'avatar' => 'sometimes|string|max:255|url',
|
||||
'signed' => 'sometimes|string|max:255',
|
||||
'status' => 'sometimes|integer',
|
||||
'backend_setting' => 'sometimes|array|max:255',
|
||||
'remark' => 'sometimes|string|max:255',
|
||||
'password' => 'sometimes|string|min:6|max:20',
|
||||
'role_codes' => 'required|array',
|
||||
'role_codes.*' => 'string|exists:role,code',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return parent::messages();
|
||||
}
|
||||
|
||||
protected array $scenes = [
|
||||
'update' => [
|
||||
'username',
|
||||
'user_type',
|
||||
'nickname',
|
||||
'phone',
|
||||
'email',
|
||||
'avatar',
|
||||
'signed',
|
||||
'status',
|
||||
'backend_setting',
|
||||
'remark',
|
||||
'password',
|
||||
],
|
||||
'create' => [
|
||||
'username',
|
||||
'user_type',
|
||||
'nickname',
|
||||
'phone',
|
||||
'email',
|
||||
'avatar',
|
||||
'signed',
|
||||
'status',
|
||||
'backend_setting',
|
||||
'remark',
|
||||
'password',
|
||||
],
|
||||
'batch_grant_role' => [
|
||||
'role_codes',
|
||||
'role_codes.*',
|
||||
]
|
||||
];
|
||||
}
|
||||
@@ -22,7 +22,20 @@ class LoginRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
|
||||
'username' => 'required|string|exists:admin_user,username',
|
||||
'password' => 'required|string'
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return parent::messages();
|
||||
}
|
||||
|
||||
protected array $scenes = [
|
||||
'login' => ['username', 'password'],
|
||||
];
|
||||
}
|
||||
|
||||
57
app/Request/Admin/PermissionRequest.php
Normal file
57
app/Request/Admin/PermissionRequest.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Request\Admin;
|
||||
|
||||
use Hyperf\Validation\Request\FormRequest;
|
||||
|
||||
class PermissionRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'nickname' => 'sometimes|string|max:255',
|
||||
'new_password' => 'sometimes|confirmed|string|min:8',
|
||||
'new_password_confirmation' => 'sometimes|string|min:8',
|
||||
'old_password' => ['sometimes', 'string'],
|
||||
'avatar' => 'sometimes|string|max:255',
|
||||
'signed' => 'sometimes|string|max:255',
|
||||
'backend_setting' => 'sometimes|array',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function messages(): array
|
||||
{
|
||||
return parent::messages();
|
||||
}
|
||||
|
||||
/**
|
||||
* @var array|array[]
|
||||
*/
|
||||
protected array $scenes = [
|
||||
'update' => [
|
||||
'nickname',
|
||||
'new_password',
|
||||
'new_password_confirmation',
|
||||
'old_password',
|
||||
'avatar',
|
||||
'signed',
|
||||
'backend_setting',
|
||||
],
|
||||
];
|
||||
}
|
||||
@@ -10,9 +10,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Admin\AdminUser;
|
||||
|
||||
use App\Common\Repository\AdminMenuRepository;
|
||||
use App\Exception\ErrException;
|
||||
use App\Model\AdminMenu;
|
||||
use App\Repository\AdminMenuRepository;
|
||||
use App\Service\Admin\BaseAdminService;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
|
||||
|
||||
@@ -10,14 +10,14 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Admin\AdminUser;
|
||||
|
||||
use App\Common\Repository\AdminMenuRepository;
|
||||
use App\Common\Repository\AdminRoleRepository;
|
||||
use App\Common\Trait\AdminUserTrait;
|
||||
use App\Constants\Model\AdminUser\AdminMenuStatusCode;
|
||||
use App\Constants\Model\AdminUser\AdminRoleStatusCode;
|
||||
use App\Constants\ResultCode;
|
||||
use App\Exception\ErrException;
|
||||
use App\Repository\AdminMenuRepository;
|
||||
use App\Repository\AdminRoleRepository;
|
||||
use App\Service\Admin\BaseAdminService;
|
||||
use App\Trait\AdminUserTrait;
|
||||
use Hyperf\Collection\Arr;
|
||||
|
||||
class PermissionService extends BaseAdminService
|
||||
|
||||
@@ -10,10 +10,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Admin\AdminUser;
|
||||
|
||||
use App\Common\Repository\AdminMenuRepository;
|
||||
use App\Common\Repository\AdminRoleRepository;
|
||||
use App\Exception\ErrException;
|
||||
use App\Model\AdminMenu;
|
||||
use App\Repository\AdminMenuRepository;
|
||||
use App\Repository\AdminRoleRepository;
|
||||
use App\Service\Admin\BaseAdminService;
|
||||
use Hyperf\Collection\Arr;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
|
||||
@@ -12,17 +12,15 @@ namespace App\Service\Admin\AdminUser;
|
||||
|
||||
use App\Cache\Redis\Lua\RateLimit;
|
||||
use App\Cache\Redis\RedisCache;
|
||||
use App\Common\Repository\AdminRoleRepository;
|
||||
use App\Common\Repository\AdminUserRepository;
|
||||
use App\Common\Trait\AdminUserTrait;
|
||||
use App\Exception\ErrException;
|
||||
use App\Lib\Jwt\RequestScopedTokenTrait;
|
||||
use App\Model\AdminRole;
|
||||
use App\Repository\AdminRoleRepository;
|
||||
use App\Repository\AdminUserRepository;
|
||||
use App\Service\Admin\BaseAdminService;
|
||||
use App\Service\BaseTokenService;
|
||||
use App\Trait\AdminUserTrait;
|
||||
use Hyperf\Collection\Arr;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Lcobucci\JWT\Token\RegisteredClaims;
|
||||
|
||||
class UserService extends BaseAdminService
|
||||
{
|
||||
|
||||
@@ -10,8 +10,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Admin\Log;
|
||||
|
||||
use App\Common\Repository\AdminUserLoginLogRepository;
|
||||
use App\Exception\ErrException;
|
||||
use App\Repository\AdminUserLoginLogRepository;
|
||||
use App\Service\Admin\BaseAdminService;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Admin\Log;
|
||||
|
||||
use App\Common\Repository\AdminUserOperationLogRepository;
|
||||
use App\Exception\ErrException;
|
||||
use App\Repository\AdminUserOperationLogRepository;
|
||||
use App\Service\Admin\BaseAdminService;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
|
||||
|
||||
@@ -10,9 +10,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service\Admin\Login;
|
||||
|
||||
use App\Common\Repository\AdminUserRepository;
|
||||
use App\Constants\Model\AdminUser\AdminUserStatusCode;
|
||||
use App\Exception\ErrException;
|
||||
use App\Repository\AdminUserRepository;
|
||||
use App\Service\Admin\BaseAdminService;
|
||||
use App\Service\BaseTokenService;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
|
||||
@@ -10,13 +10,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Common\Interface\CheckTokenInterface;
|
||||
use App\Common\Interface\JwtInterface;
|
||||
use App\Exception\ErrException;
|
||||
use App\Interface\CheckTokenInterface;
|
||||
use App\Lib\Jwt\JwtFactory;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Lcobucci\JWT\Token\RegisteredClaims;
|
||||
use Lcobucci\JWT\UnencryptedToken;
|
||||
use App\Interface\JwtInterface;
|
||||
use function Hyperf\Support\value;
|
||||
|
||||
final class BaseTokenService implements CheckTokenInterface
|
||||
|
||||
@@ -11,5 +11,5 @@ declare(strict_types=1);
|
||||
*/
|
||||
return [
|
||||
Hyperf\Database\Schema\Blueprint::class => App\Common\Macros\BlueprintMacros::class,
|
||||
App\Interface\CheckTokenInterface::class => App\Service\BaseTokenService::class,
|
||||
\App\Common\Interface\CheckTokenInterface::class => App\Service\BaseTokenService::class,
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user