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
69fd4ca3
Commit
69fd4ca3
authored
May 26, 2020
by
jiangkebao
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of git.huaperfect.com:hwq/micro
parents
c2f035e1
a876e3b1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
71 deletions
+38
-71
MakeModelCommand.php
src/Command/MakeModelCommand.php
+8
-4
AppExceptionHandler.php
src/Exceptions/Handler/AppExceptionHandler.php
+1
-1
MessageCenter.php
src/Message/MessageCenter.php
+1
-1
MaterialServiceInterface.php
src/Service/Interfaces/MaterialServiceInterface.php
+4
-64
functions.php
src/functions.php
+24
-1
No files found.
src/Command/MakeModelCommand.php
View file @
69fd4ca3
...
...
@@ -113,6 +113,10 @@ class MakeModelCommand extends HyperfCommand
if
(
$v
==
'migrations'
)
{
continue
;
}
if
(
!
$this
->
builder
->
hasTable
(
$v
))
{
$this
->
info
(
"表"
.
$v
.
"不存在!"
);
continue
;
}
$this
->
tableIndex
=
$k
;
$this
->
input
->
setArgument
(
"name"
,
$v
);
$this
->
table
=
$v
;
...
...
@@ -495,11 +499,11 @@ class MakeModelCommand extends HyperfCommand
$list
.=
"
\t\t\$
list =
\$
this->model->where(function (
\$
q) use (
\$
conditions) {\n"
;
foreach
(
$info
[
'fields'
]
as
$v
)
{
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
}
\n
"
;
}
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
}
\n
"
;
}
...
...
@@ -668,7 +672,7 @@ class MakeModelCommand extends HyperfCommand
return
true
;
}
$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
Router::addGroup('"
.
$group
.
"', function () {"
;
$content
.=
"
\n\t\t
Router::get('', 'App\Controller
\\
"
.
$modelClass
.
"Controller@index');"
;
...
...
@@ -1192,7 +1196,7 @@ class MakeModelCommand extends HyperfCommand
}
$attributes
=
implode
(
"
\n
"
,
$attributes
);
$tableComment
=
""
;
if
(
$info
[
'table_comment'
])
{
if
(
isset
(
$info
[
'table_comment'
])
&&
$info
[
'table_comment'
])
{
$tableComment
=
'Db::statement("alter table `'
.
$table
.
'` comment \''
.
$info
[
'table_comment'
]
.
'\'");'
;
}
$patterns
=
[
"%ClassName%"
,
'%tablename%'
,
'%attributes%'
,
'%tableComment%'
];
...
...
src/Exceptions/Handler/AppExceptionHandler.php
View file @
69fd4ca3
...
...
@@ -38,7 +38,7 @@ class AppExceptionHandler extends ExceptionHandler
$this
->
stdoutLogger
->
error
(
$msg
);
$this
->
logger
->
error
(
$msg
);
$this
->
stdoutLogger
->
error
(
$throwable
->
getTraceAsString
());
return
$response
->
with
Header
(
"Server"
,
"H5Q-OA"
)
->
with
Status
(
500
)
->
withBody
(
new
SwooleStream
(
$msg
));
return
$response
->
withStatus
(
500
)
->
withBody
(
new
SwooleStream
(
$msg
));
}
public
function
isValid
(
Throwable
$throwable
)
:
bool
...
...
src/Message/MessageCenter.php
View file @
69fd4ca3
...
...
@@ -43,7 +43,7 @@ class MessageCenter
$options
=
[
'base_uri'
=>
$this
->
config
->
get
(
'message.center.domain'
)
.
'/api/'
,
'handler'
=>
HandlerStack
::
create
(
new
CoroutineHandler
()),
'timeout'
=>
5
,
'timeout'
=>
60
,
];
$proxy
=
$this
->
config
->
get
(
'message.center.proxy'
);
if
(
$proxy
)
{
...
...
src/Service/Interfaces/MaterialServiceInterface.php
View file @
69fd4ca3
...
...
@@ -28,71 +28,11 @@ interface MaterialServiceInterface
public
function
getByIdList
(
array
$idList
,
array
$columns
=
[
'*'
])
:
array
;
/**
* 通过原料品名id列表获取原料数组
* @param int $materialNameId 原料品名id
* @param array $relations 原料的关联关系,支持["material_name","color"]
* @param array $columns 原料表的字段,默认显示全部
* @return array
*/
public
function
getByMaterialNameId
(
$materialNameId
,
array
$relations
=
[],
array
$columns
=
[
'*'
])
:
array
;
/**
* 通过原料列表
* @param int $page 第几页数据,默认:1
* @param array $relations 原料的关联关系,支持["material_name","color"]
* @param int $pageSize 每页条数默认:15,最大支持100
* @param array $columns 原料表的字段,默认显示全部
* @return array
*/
public
function
list
(
$page
=
1
,
array
$relations
=
[],
$pageSize
=
15
,
array
$columns
=
[
'*'
])
:
array
;
/**
* 获取某个原料品名
* @param int $materialNameId 原料品名编号
* @param array $relations 原料的关联关系,支持["materials","material_name_category"]
* @return array
*/
public
function
getMaterialName
(
$materialNameId
,
array
$relations
=
[])
:
array
;
/**
* 通过id列表获取原料品名数组
* @param array $idList 原料品名id的列表
* @param array $relations 原料品名的关联关系,支持["materials","material_name_category"]
* @param array $columns 原料品名表的字段,默认显示全部
* 通过内部code列表获取原料列表
* @param array $codeList
* @param array $columns
* @return array
*/
public
function
get
MaterialNameByIdList
(
array
$idList
,
array
$relations
=
[],
array
$columns
=
[
'*'
])
:
array
;
public
function
get
ListByCodeList
(
array
$codeList
,
array
$columns
=
[
'id'
])
;
/**
* 通过原料类型id列表获取原料品名数组
* @param int $materialNameCategoryId 原料类型id
* @param array $relations 原料的关联关系,支持["material_name_category", "materials"]
* @param array $columns 原料品名表的字段,默认显示全部
* @return array
*/
public
function
getMaterialNameByMaterialNameCategoryId
(
$materialNameCategoryId
,
array
$relations
=
[],
array
$columns
=
[
'*'
])
:
array
;
/**
* 通过原料品名列表
* @param int $page 第几页数据,默认:1
* @param array $relations 原料品名的关联关系,支持 ["materials","material_name_category"]
* @param int $pageSize 每页条数默认:15,最大支持100
* @param array $columns 原料品名表的字段,默认显示全部
* @return array
*/
public
function
getMaterialNamelist
(
$page
=
1
,
array
$relations
=
[],
$pageSize
=
15
,
array
$columns
=
[
'*'
])
:
array
;
/** 根据id获取原料类型
* @param int $materialNameCategoryId 原料类型编号
* @param array $relations 原料类型的关联关系,支持 ["material_name"]
* @return array
*/
public
function
getMaterialNameCategoryById
(
$materialNameCategoryId
,
array
$relations
=
[])
:
array
;
/**
* 获取全部原料类型
* @param array $relations 原料类型的关联关系,支持 ["material_name"]
* @return array
*/
public
function
materialNameCategories
(
array
$relations
=
[])
:
array
;
}
src/functions.php
View file @
69fd4ca3
...
...
@@ -7,7 +7,6 @@ use Hyperf\Redis\Redis;
use
Hyperf\Utils\ApplicationContext
;
use
Psr\EventDispatcher\EventDispatcherInterface
;
/**
* 容器实例
*/
...
...
@@ -414,3 +413,27 @@ if (!function_exists('get_week_start_and_end')) {
return
array
(
"week_start"
=>
$week_start
,
"week_end"
=>
$week_end
);
}
}
if
(
!
function_exists
(
'empty_string_2_null'
))
{
/**
* 空字符串转NULL
* @param array $arr
* @return array
*/
function
empty_string_2_null
(
array
$arr
)
{
if
(
!
empty
(
$arr
))
{
foreach
(
$arr
as
$key
=>
$value
)
{
if
(
is_array
(
$value
))
{
$arr
[
$key
]
=
empty_string_2_null
(
$value
);
}
else
{
if
(
$value
===
''
)
{
$arr
[
$key
]
=
null
;
}
}
}
}
return
$arr
;
}
}
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