* @Link https://gitee.com/xmo/MineAdmin */ declare(strict_types=1); namespace Builder\Aspect; use Hyperf\Di\Annotation\Aspect; use Hyperf\Di\Aop\AbstractAspect; use Hyperf\Di\Aop\ProceedingJoinPoint; use Hyperf\Di\Exception\Exception; use Psr\Container\ContainerExceptionInterface; use Psr\Container\NotFoundExceptionInterface; use Builder\BaseModel; use Builder\BaseRequest; /** * Class UpdateAspect * @package Builder\Aspect */ #[Aspect] class UpdateAspect extends AbstractAspect { public array $classes = [ 'Builder\BaseModel::update' ]; /** * @param ProceedingJoinPoint $proceedingJoinPoint * @return mixed * @throws Exception * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ public function process(ProceedingJoinPoint $proceedingJoinPoint) { $instance = $proceedingJoinPoint->getInstance(); // 更新更改人 if ($instance instanceof BaseModel && in_array('updated_by', $instance->getFillable()) && config('mineadmin.data_scope_enabled') && container()->get(BaseRequest::class)->getHeaderLine('authorization') ) { try { $instance->updated_by = user()->getId(); } catch (\Throwable $e) {} } return $proceedingJoinPoint->process(); } }