mirror of
https://gitee.com/ctexthuang/hyperf_rbac_framework_server_ctexthuang.git
synced 2025-12-25 18:17:49 +08:00
first commit
This commit is contained in:
51
app/Command/GenClass/RepositoryGenCommand.php
Normal file
51
app/Command/GenClass/RepositoryGenCommand.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Command\GenClass;
|
||||
|
||||
use Hyperf\Command\Command as HyperfCommand;
|
||||
use Hyperf\Command\Annotation\Command;
|
||||
use Hyperf\Devtool\Generator\GeneratorCommand;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
#[Command]
|
||||
class RepositoryGenCommand extends GeneratorCommand
|
||||
{
|
||||
/**
|
||||
* @param ContainerInterface $container
|
||||
*/
|
||||
public function __construct(protected ContainerInterface $container)
|
||||
{
|
||||
parent::__construct('gen:repository');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function configure(): void
|
||||
{
|
||||
parent::configure();
|
||||
$this->setDescription('Create a new repository class');
|
||||
|
||||
$this->setHelp('php bin/hyperf.php gen:repository fileRepository');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 stubs
|
||||
* @return string
|
||||
*/
|
||||
protected function getStub(): string
|
||||
{
|
||||
return __DIR__ . '/stubs/repository.stub';
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取默认命名空间
|
||||
* @return string
|
||||
*/
|
||||
protected function getDefaultNamespace(): string
|
||||
{
|
||||
return 'App\\Repository';
|
||||
}
|
||||
}
|
||||
50
app/Command/GenClass/ServiceGenCommand.php
Normal file
50
app/Command/GenClass/ServiceGenCommand.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Command\GenClass;
|
||||
|
||||
use Hyperf\Command\Annotation\Command;
|
||||
use Hyperf\Devtool\Generator\GeneratorCommand;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
#[Command]
|
||||
class ServiceGenCommand extends GeneratorCommand
|
||||
{
|
||||
/**
|
||||
* @param ContainerInterface $container
|
||||
*/
|
||||
public function __construct(protected ContainerInterface $container)
|
||||
{
|
||||
parent::__construct('gen:service');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
*/
|
||||
public function configure(): void
|
||||
{
|
||||
parent::configure();
|
||||
$this->setDescription('Create a new service class');
|
||||
|
||||
$this->setHelp('php bin/hyperf.php gen:service /folder/fileService');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 stubs
|
||||
* @return string
|
||||
*/
|
||||
protected function getStub(): string
|
||||
{
|
||||
return __DIR__ . '/stubs/service.stub';
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取默认命名空间
|
||||
* @return string
|
||||
*/
|
||||
protected function getDefaultNamespace(): string
|
||||
{
|
||||
return 'App\\Service';
|
||||
}
|
||||
}
|
||||
16
app/Command/GenClass/stubs/repository.stub
Normal file
16
app/Command/GenClass/stubs/repository.stub
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* This service file is part of item.
|
||||
*
|
||||
* @author ctexthuang
|
||||
* @contact ctexthuang@qq.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace %NAMESPACE%;
|
||||
|
||||
final class %CLASS% extends BaseRepository
|
||||
{
|
||||
public function __construct(protected readonly xxx $model) {}
|
||||
}
|
||||
19
app/Command/GenClass/stubs/service.stub
Normal file
19
app/Command/GenClass/stubs/service.stub
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* This service file is part of item.
|
||||
*
|
||||
* @author ctexthuang
|
||||
* @contact ctexthuang@qq.com
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace %NAMESPACE%;
|
||||
|
||||
class %CLASS% extends
|
||||
{
|
||||
public function handle()
|
||||
{
|
||||
//todo Write logic
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user