Commit 69fd4ca3 authored by jiangkebao's avatar jiangkebao

Merge branch 'master' of git.huaperfect.com:hwq/micro

parents c2f035e1 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\tif(\$conditions['" . $v['column_name'] . "'] !== '') {\n"; $list .= "\t\t\tif(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\tif(\$conditions['keyword'] !== '') {\n"; $list .= "\t\t\tif(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\tRouter::addGroup('" . $group . "', function () {"; $content .= "\n\tRouter::addGroup('" . $group . "', function () {";
$content .= "\n\t\tRouter::get('', 'App\Controller\\" . $modelClass . "Controller@index');"; $content .= "\n\t\tRouter::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%'];
......
...@@ -38,7 +38,7 @@ class AppExceptionHandler extends ExceptionHandler ...@@ -38,7 +38,7 @@ class AppExceptionHandler extends ExceptionHandler
$this->stdoutLogger->error($msg); $this->stdoutLogger->error($msg);
$this->logger->error($msg); $this->logger->error($msg);
$this->stdoutLogger->error($throwable->getTraceAsString()); $this->stdoutLogger->error($throwable->getTraceAsString());
return $response->withHeader("Server", "H5Q-OA")->withStatus(500)->withBody(new SwooleStream($msg)); return $response->withStatus(500)->withBody(new SwooleStream($msg));
} }
public function isValid(Throwable $throwable): bool public function isValid(Throwable $throwable): bool
......
...@@ -43,7 +43,7 @@ class MessageCenter ...@@ -43,7 +43,7 @@ class MessageCenter
$options = [ $options = [
'base_uri' => $this->config->get('message.center.domain') . '/api/', 'base_uri' => $this->config->get('message.center.domain') . '/api/',
'handler' => HandlerStack::create(new CoroutineHandler()), 'handler' => HandlerStack::create(new CoroutineHandler()),
'timeout' => 5, 'timeout' => 60,
]; ];
$proxy = $this->config->get('message.center.proxy'); $proxy = $this->config->get('message.center.proxy');
if ($proxy) { if ($proxy) {
......
...@@ -28,71 +28,11 @@ interface MaterialServiceInterface ...@@ -28,71 +28,11 @@ interface MaterialServiceInterface
public function getByIdList(array $idList, array $columns = ['*']): array; public function getByIdList(array $idList, array $columns = ['*']): array;
/** /**
* 通过原料品名id列表获取原料数组 * 通过内部code列表获取原料列表
* @param int $materialNameId 原料品名id * @param array $codeList
* @param array $relations 原料的关联关系,支持["material_name","color"] * @param array $columns
* @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 原料品名表的字段,默认显示全部
* @return array * @return array
*/ */
public function getMaterialNameByIdList(array $idList, array $relations = [], array $columns = ['*']): array; public function getListByCodeList(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;
} }
...@@ -7,7 +7,6 @@ use Hyperf\Redis\Redis; ...@@ -7,7 +7,6 @@ use Hyperf\Redis\Redis;
use Hyperf\Utils\ApplicationContext; use Hyperf\Utils\ApplicationContext;
use Psr\EventDispatcher\EventDispatcherInterface; use Psr\EventDispatcher\EventDispatcherInterface;
/** /**
* 容器实例 * 容器实例
*/ */
...@@ -414,3 +413,27 @@ if (!function_exists('get_week_start_and_end')) { ...@@ -414,3 +413,27 @@ if (!function_exists('get_week_start_and_end')) {
return array("week_start" => $week_start, "week_end" => $week_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;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment