Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
meibuyu-rpc
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
without authentication
meibuyu-rpc
Commits
fdb55ef9
Commit
fdb55ef9
authored
Apr 22, 2021
by
王源
🎧
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化mm生成命令代码
parent
800a0248
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
92 additions
and
159 deletions
+92
-159
MakeModelCommand.php
src/Command/MakeModelCommand.php
+77
-135
controller.stub
src/Command/stubs/controller.stub
+1
-0
migration.stub
src/Command/stubs/migration.stub
+6
-4
repository.stub
src/Command/stubs/repository.stub
+6
-15
repositoryInterface.stub
src/Command/stubs/repositoryInterface.stub
+1
-1
validator.stub
src/Command/stubs/validator.stub
+1
-4
No files found.
src/Command/MakeModelCommand.php
View file @
fdb55ef9
This diff is collapsed.
Click to expand it.
src/Command/stubs/controller.stub
View file @
fdb55ef9
...
...
@@ -21,6 +21,7 @@ use Meibuyu\Micro\Annotation\Perm;
*/
class
%
ModelClass
%
Controller
extends
AbstractController
{
/**
* @Inject()
* @var %ModelClass%Repository
...
...
src/Command/stubs/migration.stub
View file @
fdb55ef9
...
...
@@ -7,20 +7,21 @@
* Description:
*/
use
Hyperf\Database\Schema\Schema
;
use
Hyperf\Database\Schema\Blueprint
;
use
Hyperf\Database\Migrations\Migration
;
use
Hyperf\Database\Schema\Blueprint
;
use
Hyperf\Database\Schema\Schema
;
use
Hyperf\DbConnection\Db
;
class
%
ClassName
%
extends
Migration
{
/**
* Run the migrations.
*/
public
function
up
()
:
void
{
Schema
::
disableForeignKeyConstraints
();
Schema
::
create
(
'%table
n
ame%'
,
function
(
Blueprint
$table
)
{
Schema
::
create
(
'%table
N
ame%'
,
function
(
Blueprint
$table
)
{
%
attributes
%
});
%
tableComment
%
...
...
@@ -33,7 +34,8 @@ class %ClassName% extends Migration
public
function
down
()
:
void
{
Schema
::
disableForeignKeyConstraints
();
Schema
::
dropIfExists
(
'%table
n
ame%'
);
Schema
::
dropIfExists
(
'%table
N
ame%'
);
Schema
::
enableForeignKeyConstraints
();
}
}
src/Command/stubs/repository.stub
View file @
fdb55ef9
...
...
@@ -25,19 +25,11 @@ use Meibuyu\Micro\Repository\Eloquent\BaseRepository;
class
%
ModelClass
%
RepositoryEloquent
extends
BaseRepository
implements
%
ModelClass
%
Repository
{
/**
* %ModelClass% 模型
* @return mixed
*/
public
function
model
()
{
return
%
ModelClass
%::
class
;
}
/**
* 数据校验器
* @return mixed
*/
public
function
validator
()
{
return
%
ModelClass
%
Validator
::
class
;
...
...
@@ -47,7 +39,7 @@ class %ModelClass%RepositoryEloquent extends BaseRepository implements %ModelCla
* 获取数据列表
* @return array
*/
public
function
list
()
:
array
public
function
list
()
{
$pageSize
=
(
int
)
$this
->
request
->
input
(
'page_size'
,
DEFAULT_PAGE_SIZE
);
%
list
%
...
...
@@ -58,7 +50,7 @@ class %ModelClass%RepositoryEloquent extends BaseRepository implements %ModelCla
* @param $id
* @return array
*/
public
function
show
(
$id
)
:
array
public
function
show
(
$id
)
{
%
show
%
}
...
...
@@ -68,7 +60,7 @@ class %ModelClass%RepositoryEloquent extends BaseRepository implements %ModelCla
* @param array $attributes
* @return bool
*/
public
function
create
(
array
$attributes
)
:
bool
public
function
create
(
array
$attributes
)
{
Db
::
transaction
(
function
()
use
(
$attributes
)
{
%
create
%
...
...
@@ -82,7 +74,7 @@ class %ModelClass%RepositoryEloquent extends BaseRepository implements %ModelCla
* @param $id
* @return bool
*/
public
function
update
(
array
$attributes
,
$id
)
:
bool
public
function
update
(
array
$attributes
,
$id
)
{
Db
::
transaction
(
function
()
use
(
$attributes
,
$id
)
{
%
update
%
...
...
@@ -96,10 +88,9 @@ class %ModelClass%RepositoryEloquent extends BaseRepository implements %ModelCla
* @return bool
* @throws HttpResponseException
*/
public
function
delete
(
$id
)
:
bool
public
function
delete
(
$id
)
{
//已用外键做级联删除 和 删除验证,不需要做逻辑验证
return
$this
->
find
(
$id
)
->
delete
();
return
parent
::
delete
(
$id
);
// TODO: Change the autogenerated stub
}
%
rs
%
}
src/Command/stubs/repositoryInterface.stub
View file @
fdb55ef9
...
...
@@ -14,7 +14,7 @@ namespace App\Repository\Interfaces;
use
Meibuyu\Micro\Repository\Contracts\RepositoryInterface
;
/**
* Interface
%ClassName%
* Interface %ClassName%
* @package App\Repository\Interfaces
*/
interface
%
ClassName
%
extends
RepositoryInterface
...
...
src/Command/stubs/validator.stub
View file @
fdb55ef9
...
...
@@ -16,6 +16,7 @@ use Meibuyu\Micro\Validator\HyperfValidator;
class
%
ModelClass
%
Validator
extends
HyperfValidator
{
protected
$rules
=
[
ValidatorInterface
::
RULE_CREATE
=>
[
%
createRules
%
...
...
@@ -29,8 +30,4 @@ class %ModelClass%Validator extends HyperfValidator
%
attributes
%
];
protected
$messages
=
[
%
messages
%
];
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment