merge: branch 'master' of github.com:hyperf-admin/hyperf-admin

This commit is contained in:
daodao97
2020-07-06 17:07:50 +08:00
4 changed files with 24 additions and 13 deletions

View File

@@ -332,7 +332,7 @@ class PermissionService
return false;
}
$controllerInstance = container($controller);
if (in_array($action, $controllerInstance->open_resources)) {
if (isset($controllerInstance->open_resources) && in_array($action, $controllerInstance->open_resources)) {
return true;
}

View File

@@ -135,6 +135,7 @@ class DevController extends AbstractController
'number' => 'number',
'float' => 'float',
'radio' => 'radio',
'textarea' => 'textarea',
'switch' => 'switch',
'date' => 'date',
'date_time' => 'date_time',
@@ -142,6 +143,12 @@ class DevController extends AbstractController
'datetime_range' => 'datetime_range',
'image' => 'image',
'file' => 'file',
'html' => 'html',
'icon-select' => 'icon-select',
'sub-form' => 'sub-form',
'inputRange' => 'inputRange',
'cascader' => 'cascader',
'json' => 'json',
],
'default' => 'input',
'col' => [
@@ -289,13 +296,13 @@ class DevController extends AbstractController
$ret = [];
$ignores = ['id', 'create_at', 'update_at', 'is_deleted'];
foreach ($schema as $item) {
if (in_array($item['column_name'], $ignores)) {
if (in_array($item['COLUMN_NAME'], $ignores)) {
continue;
}
$ret[] = [
'field' => $item['column_name'],
'label' => $item['column_comment'],
'type' => $this->transType($item['data_type']),
'field' => $item['COLUMN_NAME'],
'label' => $item['COLUMN_COMMENT'],
'type' => $this->transType($item['DATA_TYPE']),
];
}
@@ -309,6 +316,10 @@ class DevController extends AbstractController
return 'datetime';
case 'bigint':
return 'number';
case 'text':
return 'html';
case 'enum':
return 'radio';
default:
return 'input';
}

View File

@@ -22,7 +22,7 @@ class ModelMaker extends AbstractMaker
return false;
}
$columns = array_values(array_filter(array_map(function ($item) {
if(in_array($item['column_name'], [
if(in_array($item['COLUMN_NAME'], [
'create_at',
'update_at',
'is_deleted',
@@ -30,7 +30,7 @@ class ModelMaker extends AbstractMaker
return null;
}
return $item['column_name'];
return $item['COLUMN_NAME'];
}, $schema)));
$class_namespace = $this->pathToNamespace($path) . '\\' . Str::studly($database);
$class_name = Str::studly($table);
@@ -68,10 +68,10 @@ class ModelMaker extends AbstractMaker
protected function getProperty($column): array
{
$name = $column['column_name'];
$type = $this->formatPropertyType($column['data_type'], $column['cast'] ?? null);
$name = $column['COLUMN_NAME'];
$type = $this->formatPropertyType($column['DATA_TYPE'], $column['cast'] ?? null);
return [$name, $type, $column['column_comment']];
return [$name, $type, $column['COLUMN_COMMENT']];
}
protected function formatDatabaseType(string $type): ?string

View File

@@ -25,7 +25,7 @@ class TableSchema
$builder = $this->getSchemaBuilder($pool);
return $builder->getConnection()
->select('select `column_name`, `data_type`, `column_comment` from information_schema.columns where `table_schema` = ? and `table_name` = ? order by ORDINAL_POSITION', [
->select('select `COLUMN_NAME`, `DATA_TYPE`, `COLUMN_COMMENT` from information_schema.COLUMNS where `TABLE_SCHEMA` = ? and `TABLE_NAME` = ? order by ORDINAL_POSITION', [
$database,
$table_name,
]);
@@ -48,11 +48,11 @@ class TableSchema
{
$builder = $this->getSchemaBuilder($pool);
$ret = $builder->getConnection()
->select("select table_name from information_schema.tables where table_schema=? and table_type='base table';", [
->select("select TABLE_NAME from information_schema.tables where table_schema=? and table_type='BASE TABLE';", [
$database,
]);
return array_column($ret ?? [], 'table_name');
return array_column($ret ?? [], 'TABLE_NAME');
}
public function tableDesign($pool, $database, $table_name)