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
84d84ec6
Commit
84d84ec6
authored
May 07, 2020
by
王源
🎧
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化生成模板
parent
6e7419a2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
20 additions
and
26 deletions
+20
-26
MakeModelCommand.php
src/Command/MakeModelCommand.php
+7
-12
controller.stub
src/Command/stubs/controller.stub
+3
-1
model.stub
src/Command/stubs/model.stub
+1
-1
repository.stub
src/Command/stubs/repository.stub
+7
-8
repositoryInterface.stub
src/Command/stubs/repositoryInterface.stub
+2
-3
validator.stub
src/Command/stubs/validator.stub
+0
-1
No files found.
src/Command/MakeModelCommand.php
View file @
84d84ec6
...
...
@@ -454,8 +454,7 @@ class MakeModelCommand extends HyperfCommand
/**
* 创建验证文件
*/
private
function
makeValidator
()
private
function
makeValidator
()
{
$stubFile
=
$this
->
path
.
'validator.stub'
;
$folder
=
$this
->
appPath
.
'/Validators'
;
...
...
@@ -570,8 +569,7 @@ class MakeModelCommand extends HyperfCommand
$this
->
writeToFile
(
$file
,
$content
);
}
private
function
makeRepositoryInterface
()
private
function
makeRepositoryInterface
()
{
$stubFile
=
$this
->
path
.
'repositoryInterface.stub'
;
$folder
=
$this
->
appPath
.
'/Repository/Interfaces'
;
...
...
@@ -600,7 +598,7 @@ class MakeModelCommand extends HyperfCommand
$content
=
file_get_contents
(
$stubFile
);
$info
=
$this
->
currentTableStructure
;
//列表
$list
=
"
\$
conditions =
\$
this->request->input();
\n
"
;
$list
=
"
\$
conditions =
\$
this->request->input
s
();
\n
"
;
$list
.=
"
\t\t\$
list =
\$
this->model->where(function (
\$
q) use (
\$
conditions) {\n"
;
foreach
(
$info
[
'fields'
]
as
$v
)
{
if
(
Str
::
endsWith
(
$v
[
'column_name'
],
"_id"
))
{
...
...
@@ -669,7 +667,7 @@ class MakeModelCommand extends HyperfCommand
foreach
(
$info
[
'relations'
][
'hasMany'
]
as
$v
)
{
$rs
.=
"
\n\t
public function
{
$v
[
'function'
]
}
(
\$
id): array
\n
"
;
$rs
.=
"
\t
{\n"
;
$rs
.=
"
\t\t\$
pageSize = (int)
\$
this->request->input('page_size',
env(
\"
DEFAULT_PAGE_SIZE
\"
,10)
);
\n
"
;
$rs
.=
"
\t\t\$
pageSize = (int)
\$
this->request->input('page_size',
DEFAULT_PAGE_SIZE
);
\n
"
;
$rs
.=
"
\t\t
return
\$
this->find(
\$
id)->
{
$v
[
'function'
]
}
()->orderByDesc('id')->paginate(
\$
pageSize)->toArray();
\n
"
;
$rs
.=
"
\t
}
\n
"
;
}
...
...
@@ -1017,14 +1015,12 @@ class MakeModelCommand extends HyperfCommand
/**生成迁移文件的日期格式
* @return string
*/
private
function
getDatePrefix
()
:
string
private
function
getDatePrefix
()
:
string
{
return
date
(
'Y_m_dHis'
);
}
public
function
configure
()
public
function
configure
()
{
//$this->call()
parent
::
configure
();
...
...
@@ -1042,8 +1038,7 @@ class MakeModelCommand extends HyperfCommand
* 配置文件内容
* @return array
*/
protected
function
getArguments
()
protected
function
getArguments
()
{
return
[
[
'name'
,
InputArgument
::
OPTIONAL
,
'数据库表名'
],
...
...
src/Command/stubs/controller.stub
View file @
84d84ec6
...
...
@@ -40,7 +40,7 @@ class %ModelClass%Controller extends AbstractController
/**
* 获取列表数据
* @Perm("index")
* @param $id id编号
* @param
int
$id id编号
* @return mixed
*/
public
function
show
(
$id
)
...
...
@@ -61,6 +61,7 @@ class %ModelClass%Controller extends AbstractController
/**
* 更新数据
* @param int $id id编号
* @return mixed
*/
public
function
update
(
$id
)
...
...
@@ -71,6 +72,7 @@ class %ModelClass%Controller extends AbstractController
/**
* 删除单条数据
* @param int $id id编号
* @return mixed
*/
public
function
delete
(
$id
)
...
...
src/Command/stubs/model.stub
View file @
84d84ec6
...
...
@@ -13,7 +13,7 @@ namespace App\Model;
%
namespace
%
/**
* 模型类 %ClassName%
* @package App\Model
s
* @package App\Model
%properties%
*/
class
%
ClassName
%
extends
Model
...
...
src/Command/stubs/repository.stub
View file @
84d84ec6
...
...
@@ -18,16 +18,15 @@ use Meibuyu\Micro\Exceptions\HttpResponseException;
use
Meibuyu\Micro\Repository\Eloquent\BaseRepository
;
/**
* %ModelClass%RepositoryEloquent 类.
*
* @package namespace App\Repository\Eloquent;
* Class %ModelClass%RepositoryEloquent
* @package App\Repository\Eloquent;
*/
class
%
ModelClass
%
RepositoryEloquent
extends
BaseRepository
implements
%
ModelClass
%
Repository
{
/**
* %ModelClass% 模型
* @return %ModelClass%
* @return %ModelClass%
|string
*/
public
function
model
()
:
%
ModelClass
%
{
...
...
@@ -36,7 +35,7 @@ class %ModelClass%RepositoryEloquent extends BaseRepository implements %ModelCla
/**
* 数据校验器
* @return %ModelClass%Validator
* @return %ModelClass%Validator
|string
*/
public
function
validator
()
:
%
ModelClass
%
Validator
{
...
...
@@ -49,8 +48,8 @@ class %ModelClass%RepositoryEloquent extends BaseRepository implements %ModelCla
*/
public
function
list
()
:
array
{
$pageSize
=
(
int
)
$this
->
request
->
input
(
'page_size'
,
env
(
"DEFAULT_PAGE_SIZE"
,
10
)
);
%
list
%
;
$pageSize
=
(
int
)
$this
->
request
->
input
(
'page_size'
,
DEFAULT_PAGE_SIZE
);
%
list
%
}
/**
...
...
@@ -60,7 +59,7 @@ class %ModelClass%RepositoryEloquent extends BaseRepository implements %ModelCla
*/
public
function
show
(
$id
)
:
array
{
%
show
%
;
%
show
%
}
/**
...
...
src/Command/stubs/repositoryInterface.stub
View file @
84d84ec6
...
...
@@ -14,9 +14,8 @@ namespace App\Repository\Interfaces;
use
Meibuyu\Micro\Repository\Contracts\RepositoryInterface
;
/**
* %ClassName% 接口类.
*
* @package namespace App\Repository\Interfaces;
* Interface %ClassName%
* @package App\Repository\Interfaces
*/
interface
%
ClassName
%
extends
RepositoryInterface
{
...
...
src/Command/stubs/validator.stub
View file @
84d84ec6
...
...
@@ -9,7 +9,6 @@
declare
(
strict_types
=
1
);
namespace
App\Validators
;
use
Meibuyu\Micro\Validator\Contracts\ValidatorInterface
;
...
...
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