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
a876e3b1
Commit
a876e3b1
authored
May 22, 2020
by
梁俊杰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
生成数据修复
parent
4af65c32
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
4 deletions
+8
-4
MakeModelCommand.php
src/Command/MakeModelCommand.php
+8
-4
No files found.
src/Command/MakeModelCommand.php
View file @
a876e3b1
...
@@ -113,6 +113,10 @@ class MakeModelCommand extends HyperfCommand
...
@@ -113,6 +113,10 @@ class MakeModelCommand extends HyperfCommand
if
(
$v
==
'migrations'
)
{
if
(
$v
==
'migrations'
)
{
continue
;
continue
;
}
}
if
(
!
$this
->
builder
->
hasTable
(
$v
))
{
$this
->
info
(
"表"
.
$v
.
"不存在!"
);
continue
;
}
$this
->
tableIndex
=
$k
;
$this
->
tableIndex
=
$k
;
$this
->
input
->
setArgument
(
"name"
,
$v
);
$this
->
input
->
setArgument
(
"name"
,
$v
);
$this
->
table
=
$v
;
$this
->
table
=
$v
;
...
@@ -495,11 +499,11 @@ class MakeModelCommand extends HyperfCommand
...
@@ -495,11 +499,11 @@ class MakeModelCommand extends HyperfCommand
$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"
))
{
$list
.=
"
\t\t\t
if(
\$
conditions['"
.
$v
[
'column_name'
]
.
"'] !== '') {\n"
;
$list
.=
"
\t\t\t
if(
isset(
\$
conditions['"
.
$v
[
'column_name'
]
.
"']) &&
\$
conditions['"
.
$v
[
'column_name'
]
.
"'] !== '') {\n"
;
$list
.=
"
\t\t\t\t\$
q->where('"
.
$v
[
'column_name'
]
.
"',
\$
conditions['"
.
$v
[
'column_name'
]
.
"']);
\n
"
;
$list
.=
"
\t\t\t\t\$
q->where('"
.
$v
[
'column_name'
]
.
"',
\$
conditions['"
.
$v
[
'column_name'
]
.
"']);
\n
"
;
$list
.=
"
\t\t\t
}
\n
"
;
$list
.=
"
\t\t\t
}
\n
"
;
}
else
if
(
$v
[
'column_name'
]
==
'name'
||
Str
::
contains
(
$v
[
'column_name'
],
"_name"
))
{
}
else
if
(
$v
[
'column_name'
]
==
'name'
||
Str
::
contains
(
$v
[
'column_name'
],
"_name"
))
{
$list
.=
"
\t\t\t
if(
\$
conditions['keyword'] !== '') {\n"
;
$list
.=
"
\t\t\t
if(
isset(
\$
conditions['"
.
$v
[
'column_name'
]
.
"']) &&
\$
conditions['keyword'] !== '') {\n"
;
$list
.=
"
\t\t\t\t\$
q->where('"
.
$v
[
'column_name'
]
.
"',
\$
conditions['keyword']);
\n
"
;
$list
.=
"
\t\t\t\t\$
q->where('"
.
$v
[
'column_name'
]
.
"',
\$
conditions['keyword']);
\n
"
;
$list
.=
"
\t\t\t
}
\n
"
;
$list
.=
"
\t\t\t
}
\n
"
;
}
}
...
@@ -668,7 +672,7 @@ class MakeModelCommand extends HyperfCommand
...
@@ -668,7 +672,7 @@ class MakeModelCommand extends HyperfCommand
return
true
;
return
true
;
}
}
$info
=
$this
->
currentTableStructure
;
$info
=
$this
->
currentTableStructure
;
$tableComment
=
$info
[
'table_comment'
]
?
$info
[
'table_comment'
]
:
$table
;
$tableComment
=
(
isset
(
$info
[
'table_comment'
])
&&
$info
[
'table_comment'
])
?
$info
[
'table_comment'
]
:
$table
;
$content
.=
"
\n\t
// "
.
$tableComment
;
$content
.=
"
\n\t
// "
.
$tableComment
;
$content
.=
"
\n\t
Router::addGroup('"
.
$group
.
"', function () {"
;
$content
.=
"
\n\t
Router::addGroup('"
.
$group
.
"', function () {"
;
$content
.=
"
\n\t\t
Router::get('', 'App\Controller
\\
"
.
$modelClass
.
"Controller@index');"
;
$content
.=
"
\n\t\t
Router::get('', 'App\Controller
\\
"
.
$modelClass
.
"Controller@index');"
;
...
@@ -1192,7 +1196,7 @@ class MakeModelCommand extends HyperfCommand
...
@@ -1192,7 +1196,7 @@ class MakeModelCommand extends HyperfCommand
}
}
$attributes
=
implode
(
"
\n
"
,
$attributes
);
$attributes
=
implode
(
"
\n
"
,
$attributes
);
$tableComment
=
""
;
$tableComment
=
""
;
if
(
$info
[
'table_comment'
])
{
if
(
isset
(
$info
[
'table_comment'
])
&&
$info
[
'table_comment'
])
{
$tableComment
=
'Db::statement("alter table `'
.
$table
.
'` comment \''
.
$info
[
'table_comment'
]
.
'\'");'
;
$tableComment
=
'Db::statement("alter table `'
.
$table
.
'` comment \''
.
$info
[
'table_comment'
]
.
'\'");'
;
}
}
$patterns
=
[
"%ClassName%"
,
'%tablename%'
,
'%attributes%'
,
'%tableComment%'
];
$patterns
=
[
"%ClassName%"
,
'%tablename%'
,
'%attributes%'
,
'%tableComment%'
];
...
...
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