优化webman-buildadmin框架
This commit is contained in:
@@ -96,11 +96,12 @@ class Helper
|
||||
|
||||
protected static array $attrType = [
|
||||
'controller' => [
|
||||
'preExcludeFields' => 'array|string',
|
||||
'quickSearchField' => 'string|array',
|
||||
'withJoinTable' => 'array',
|
||||
'defaultSortField' => 'string|array',
|
||||
'weighField' => 'string',
|
||||
'preExcludeFields' => 'array|string',
|
||||
'quickSearchField' => 'string|array',
|
||||
'withJoinTable' => 'array',
|
||||
'defaultSortField' => 'string|array',
|
||||
'weighField' => 'string',
|
||||
'autoFillAdminId' => 'bool',
|
||||
],
|
||||
];
|
||||
|
||||
@@ -692,7 +693,14 @@ class Helper
|
||||
$modelMethodList = isset($modelData['relationMethodList']) ? array_merge($modelData['methods'], $modelData['relationMethodList']) : $modelData['methods'];
|
||||
$modelData['methods'] = $modelMethodList ? "\n" . implode("\n", $modelMethodList) : '';
|
||||
$modelData['append'] = self::buildModelAppend($modelData['append'] ?? []);
|
||||
$modelData['fieldType'] = self::buildModelFieldType($modelData['fieldType'] ?? []);
|
||||
$fieldType = $modelData['fieldType'] ?? [];
|
||||
if ($modelData['autoWriteTimestamp'] == 'true') {
|
||||
$fieldType = array_merge(
|
||||
['create_time' => 'integer', 'update_time' => 'integer'],
|
||||
$fieldType
|
||||
);
|
||||
}
|
||||
$modelData['fieldType'] = self::buildModelFieldType($fieldType);
|
||||
|
||||
if (isset($modelData['beforeInsertMixins']['snowflake'])) {
|
||||
$modelData['beforeInsert'] = self::assembleStub('mixins/model/beforeInsert', [
|
||||
@@ -726,6 +734,9 @@ class Helper
|
||||
$attrType = self::$attrType['controller'][$key] ?? '';
|
||||
if (is_array($item)) {
|
||||
$controllerAttr .= "\n" . self::tab() . "protected $attrType \$$key = ['" . implode("', '", $item) . "'];\n";
|
||||
} elseif ($attrType === 'bool') {
|
||||
$val = ($item === true || $item === 'true') ? 'true' : 'false';
|
||||
$controllerAttr .= "\n" . self::tab() . "protected $attrType \$$key = $val;\n";
|
||||
} elseif ($item) {
|
||||
$controllerAttr .= "\n" . self::tab() . "protected $attrType \$$key = '$item';\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user