..
This commit is contained in:
@@ -7,6 +7,10 @@ namespace Aether;
|
||||
use Aether\Contract\TreeableInterface;
|
||||
use Aether\Exception\BusinessException;
|
||||
use Hyperf\Database\Model\Builder;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Hyperf\Logger\LoggerFactory;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use ReflectionClass;
|
||||
use Throwable;
|
||||
|
||||
/**
|
||||
@@ -14,10 +18,20 @@ use Throwable;
|
||||
*/
|
||||
abstract class AetherCrudService extends AetherService implements AetherCrudInterface
|
||||
{
|
||||
#[Inject]
|
||||
protected LoggerFactory $loggerFactory;
|
||||
|
||||
protected LoggerInterface $logger;
|
||||
|
||||
protected array $search = [];
|
||||
|
||||
protected array $ignoreSearchFields = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->logger = $this->loggerFactory->get($this->getLoggerName());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用列表查询(支持分页和树形结构).
|
||||
*/
|
||||
@@ -71,7 +85,7 @@ abstract class AetherCrudService extends AetherService implements AetherCrudInte
|
||||
*/
|
||||
public function detail(int $id): object
|
||||
{
|
||||
var_dump('detail');
|
||||
$this->logger->info('获取资源详情', ['id' => $id]);
|
||||
return $this->getModel()->findOrFailById($id);
|
||||
}
|
||||
|
||||
@@ -248,6 +262,14 @@ abstract class AetherCrudService extends AetherService implements AetherCrudInte
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取日志名称.
|
||||
*/
|
||||
protected function getLoggerName(): string
|
||||
{
|
||||
return strtolower((new ReflectionClass($this))->getShortName());
|
||||
}
|
||||
|
||||
protected function getSearch(): array
|
||||
{
|
||||
return $this->search;
|
||||
|
||||
Reference in New Issue
Block a user