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
Show 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;
...
@@ -21,6 +21,7 @@ use Meibuyu\Micro\Annotation\Perm;
*/
*/
class
%
ModelClass
%
Controller
extends
AbstractController
class
%
ModelClass
%
Controller
extends
AbstractController
{
{
/**
/**
* @Inject()
* @Inject()
* @var %ModelClass%Repository
* @var %ModelClass%Repository
...
...
src/Command/stubs/migration.stub
View file @
fdb55ef9
...
@@ -7,20 +7,21 @@
...
@@ -7,20 +7,21 @@
* Description:
* Description:
*/
*/
use
Hyperf\Database\Schema\Schema
;
use
Hyperf\Database\Schema\Blueprint
;
use
Hyperf\Database\Migrations\Migration
;
use
Hyperf\Database\Migrations\Migration
;
use
Hyperf\Database\Schema\Blueprint
;
use
Hyperf\Database\Schema\Schema
;
use
Hyperf\DbConnection\Db
;
use
Hyperf\DbConnection\Db
;
class
%
ClassName
%
extends
Migration
class
%
ClassName
%
extends
Migration
{
{
/**
/**
* Run the migrations.
* Run the migrations.
*/
*/
public
function
up
()
:
void
public
function
up
()
:
void
{
{
Schema
::
disableForeignKeyConstraints
();
Schema
::
disableForeignKeyConstraints
();
Schema
::
create
(
'%table
n
ame%'
,
function
(
Blueprint
$table
)
{
Schema
::
create
(
'%table
N
ame%'
,
function
(
Blueprint
$table
)
{
%
attributes
%
%
attributes
%
});
});
%
tableComment
%
%
tableComment
%
...
@@ -33,7 +34,8 @@ class %ClassName% extends Migration
...
@@ -33,7 +34,8 @@ class %ClassName% extends Migration
public
function
down
()
:
void
public
function
down
()
:
void
{
{
Schema
::
disableForeignKeyConstraints
();
Schema
::
disableForeignKeyConstraints
();
Schema
::
dropIfExists
(
'%table
n
ame%'
);
Schema
::
dropIfExists
(
'%table
N
ame%'
);
Schema
::
enableForeignKeyConstraints
();
Schema
::
enableForeignKeyConstraints
();
}
}
}
}
src/Command/stubs/repository.stub
View file @
fdb55ef9
...
@@ -25,19 +25,11 @@ use Meibuyu\Micro\Repository\Eloquent\BaseRepository;
...
@@ -25,19 +25,11 @@ use Meibuyu\Micro\Repository\Eloquent\BaseRepository;
class
%
ModelClass
%
RepositoryEloquent
extends
BaseRepository
implements
%
ModelClass
%
Repository
class
%
ModelClass
%
RepositoryEloquent
extends
BaseRepository
implements
%
ModelClass
%
Repository
{
{
/**
* %ModelClass% 模型
* @return mixed
*/
public
function
model
()
public
function
model
()
{
{
return
%
ModelClass
%::
class
;
return
%
ModelClass
%::
class
;
}
}
/**
* 数据校验器
* @return mixed
*/
public
function
validator
()
public
function
validator
()
{
{
return
%
ModelClass
%
Validator
::
class
;
return
%
ModelClass
%
Validator
::
class
;
...
@@ -47,7 +39,7 @@ class %ModelClass%RepositoryEloquent extends BaseRepository implements %ModelCla
...
@@ -47,7 +39,7 @@ class %ModelClass%RepositoryEloquent extends BaseRepository implements %ModelCla
* 获取数据列表
* 获取数据列表
* @return array
* @return array
*/
*/
public
function
list
()
:
array
public
function
list
()
{
{
$pageSize
=
(
int
)
$this
->
request
->
input
(
'page_size'
,
DEFAULT_PAGE_SIZE
);
$pageSize
=
(
int
)
$this
->
request
->
input
(
'page_size'
,
DEFAULT_PAGE_SIZE
);
%
list
%
%
list
%
...
@@ -58,7 +50,7 @@ class %ModelClass%RepositoryEloquent extends BaseRepository implements %ModelCla
...
@@ -58,7 +50,7 @@ class %ModelClass%RepositoryEloquent extends BaseRepository implements %ModelCla
* @param $id
* @param $id
* @return array
* @return array
*/
*/
public
function
show
(
$id
)
:
array
public
function
show
(
$id
)
{
{
%
show
%
%
show
%
}
}
...
@@ -68,7 +60,7 @@ class %ModelClass%RepositoryEloquent extends BaseRepository implements %ModelCla
...
@@ -68,7 +60,7 @@ class %ModelClass%RepositoryEloquent extends BaseRepository implements %ModelCla
* @param array $attributes
* @param array $attributes
* @return bool
* @return bool
*/
*/
public
function
create
(
array
$attributes
)
:
bool
public
function
create
(
array
$attributes
)
{
{
Db
::
transaction
(
function
()
use
(
$attributes
)
{
Db
::
transaction
(
function
()
use
(
$attributes
)
{
%
create
%
%
create
%
...
@@ -82,7 +74,7 @@ class %ModelClass%RepositoryEloquent extends BaseRepository implements %ModelCla
...
@@ -82,7 +74,7 @@ class %ModelClass%RepositoryEloquent extends BaseRepository implements %ModelCla
* @param $id
* @param $id
* @return bool
* @return bool
*/
*/
public
function
update
(
array
$attributes
,
$id
)
:
bool
public
function
update
(
array
$attributes
,
$id
)
{
{
Db
::
transaction
(
function
()
use
(
$attributes
,
$id
)
{
Db
::
transaction
(
function
()
use
(
$attributes
,
$id
)
{
%
update
%
%
update
%
...
@@ -96,10 +88,9 @@ class %ModelClass%RepositoryEloquent extends BaseRepository implements %ModelCla
...
@@ -96,10 +88,9 @@ class %ModelClass%RepositoryEloquent extends BaseRepository implements %ModelCla
* @return bool
* @return bool
* @throws HttpResponseException
* @throws HttpResponseException
*/
*/
public
function
delete
(
$id
)
:
bool
public
function
delete
(
$id
)
{
{
//已用外键做级联删除 和 删除验证,不需要做逻辑验证
return
parent
::
delete
(
$id
);
// TODO: Change the autogenerated stub
return
$this
->
find
(
$id
)
->
delete
();
}
}
%
rs
%
%
rs
%
}
}
src/Command/stubs/repositoryInterface.stub
View file @
fdb55ef9
src/Command/stubs/validator.stub
View file @
fdb55ef9
...
@@ -16,6 +16,7 @@ use Meibuyu\Micro\Validator\HyperfValidator;
...
@@ -16,6 +16,7 @@ use Meibuyu\Micro\Validator\HyperfValidator;
class
%
ModelClass
%
Validator
extends
HyperfValidator
class
%
ModelClass
%
Validator
extends
HyperfValidator
{
{
protected
$rules
=
[
protected
$rules
=
[
ValidatorInterface
::
RULE_CREATE
=>
[
ValidatorInterface
::
RULE_CREATE
=>
[
%
createRules
%
%
createRules
%
...
@@ -29,8 +30,4 @@ class %ModelClass%Validator extends HyperfValidator
...
@@ -29,8 +30,4 @@ class %ModelClass%Validator extends HyperfValidator
%
attributes
%
%
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