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