51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Aspect\Admin;
|
|
|
|
use App\Exception\ErrException;
|
|
use App\Service\Admin\Login\LoginService;
|
|
use Hyperf\Di\Annotation\Aspect;
|
|
use Hyperf\Di\Aop\AbstractAspect;
|
|
use Hyperf\Di\Aop\ProceedingJoinPoint;
|
|
use Hyperf\Di\Exception\Exception;
|
|
|
|
#[Aspect]
|
|
class AdminLoginLogAspect extends AbstractAspect
|
|
{
|
|
/**
|
|
* 需要切入的类
|
|
* @var array|\class-string[]
|
|
*/
|
|
public array $classes = [
|
|
LoginService::class,
|
|
];
|
|
|
|
/**
|
|
* 需要切入的注解
|
|
* @var array
|
|
*/
|
|
public array $annotations = [
|
|
// SomeAnnotation::class,
|
|
];
|
|
|
|
/**
|
|
* 切入后处理逻辑
|
|
* @param ProceedingJoinPoint $proceedingJoinPoint
|
|
* @return mixed
|
|
* @throws Exception
|
|
*/
|
|
public function process(ProceedingJoinPoint $proceedingJoinPoint): mixed
|
|
{
|
|
try {
|
|
// 在调用前进行处理
|
|
$result = $proceedingJoinPoint->process();
|
|
// 在调用后进行处理
|
|
//todo 登录日志是否需要
|
|
|
|
return $result;
|
|
} catch (ErrException $e) {
|
|
// var_dump($e->getMessage());
|
|
throw new ErrException($e->getMessage());
|
|
}
|
|
}
|
|
} |