mirror of https://gitee.com/karson/fastadmin.git
parent
578044505a
commit
448eaad5f5
|
|
@ -15,7 +15,6 @@ use think\exception\PDOException;
|
|||
|
||||
class Addon extends Command
|
||||
{
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
|
|
@ -33,6 +32,7 @@ class Addon extends Command
|
|||
|
||||
protected function execute(Input $input, Output $output)
|
||||
{
|
||||
\think\Config::load(dirname(dirname(__FILE__)) . DS . 'config.php');
|
||||
$name = $input->getOption('name') ?: '';
|
||||
$action = $input->getOption('action') ?: '';
|
||||
if (stripos($name, 'addons' . DS) !== false) {
|
||||
|
|
@ -82,7 +82,6 @@ class Addon extends Command
|
|||
$createTableSql = $result[0]['Create Table'];
|
||||
}
|
||||
} catch (PDOException $e) {
|
||||
|
||||
}
|
||||
|
||||
$data = [
|
||||
|
|
@ -177,12 +176,12 @@ class Addon extends Command
|
|||
if (!$info) {
|
||||
throw new Exception(__('Addon info file data incorrect'));
|
||||
}
|
||||
$infoname = isset($info['name']) ? $info['name'] : '';
|
||||
$infoname = $info['name'] ?? '';
|
||||
if (!$infoname || !preg_match("/^[a-z]+$/i", $infoname) || $infoname != $name) {
|
||||
throw new Exception(__('Addon info name incorrect'));
|
||||
}
|
||||
|
||||
$infoversion = isset($info['version']) ? $info['version'] : '';
|
||||
$infoversion = $info['version'] ?? '';
|
||||
if (!$infoversion || !preg_match("/^\d+\.\d+\.\d+$/i", $infoversion)) {
|
||||
throw new Exception(__('Addon info version incorrect'));
|
||||
}
|
||||
|
|
@ -340,5 +339,4 @@ class Addon extends Command
|
|||
{
|
||||
return __DIR__ . '/Addon/stubs/' . $name . '.stub';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -466,7 +466,7 @@ class Crud extends Command
|
|||
}
|
||||
}
|
||||
$relationTableInfo = $relationTableInfo[0];
|
||||
$relationModel = isset($relationModels[$index]) ? $relationModels[$index] : '';
|
||||
$relationModel = $relationModels[$index] ?? '';
|
||||
|
||||
list($relationNamespace, $relationName, $relationFile) = $this->getModelData($modelModuleName, $relationModel, $relationName);
|
||||
|
||||
|
|
@ -666,8 +666,8 @@ class Crud extends Command
|
|||
//如果是关联模型
|
||||
foreach ($relations as $index => &$relation) {
|
||||
if ($relation['relationMode'] == 'hasone') {
|
||||
$relationForeignKey = $relation['relationForeignKey'] ? $relation['relationForeignKey'] : $table . "_id";
|
||||
$relationPrimaryKey = $relation['relationPrimaryKey'] ? $relation['relationPrimaryKey'] : $priKey;
|
||||
$relationForeignKey = $relation['relationForeignKey'] ?: $table . "_id";
|
||||
$relationPrimaryKey = $relation['relationPrimaryKey'] ?: $priKey;
|
||||
|
||||
if (!in_array($relationForeignKey, $relation['relationFieldList'])) {
|
||||
throw new Exception('relation table [' . $relation['relationTableName'] . '] must be contain field [' . $relationForeignKey . ']');
|
||||
|
|
@ -676,8 +676,8 @@ class Crud extends Command
|
|||
throw new Exception('table [' . $modelTableName . '] must be contain field [' . $relationPrimaryKey . ']');
|
||||
}
|
||||
} elseif ($relation['relationMode'] == 'belongsto') {
|
||||
$relationForeignKey = $relation['relationForeignKey'] ? $relation['relationForeignKey'] : Loader::parseName($relation['relationName']) . "_id";
|
||||
$relationPrimaryKey = $relation['relationPrimaryKey'] ? $relation['relationPrimaryKey'] : $relation['relationPriKey'];
|
||||
$relationForeignKey = $relation['relationForeignKey'] ?: Loader::parseName($relation['relationName']) . "_id";
|
||||
$relationPrimaryKey = $relation['relationPrimaryKey'] ?: $relation['relationPriKey'];
|
||||
if (!in_array($relationForeignKey, $fieldArr)) {
|
||||
throw new Exception('table [' . $modelTableName . '] must be contain field [' . $relationForeignKey . ']');
|
||||
}
|
||||
|
|
@ -685,8 +685,8 @@ class Crud extends Command
|
|||
throw new Exception('relation table [' . $relation['relationTableName'] . '] must be contain field [' . $relationPrimaryKey . ']');
|
||||
}
|
||||
} elseif ($relation['relationMode'] == 'hasmany') {
|
||||
$relationForeignKey = $relation['relationForeignKey'] ? $relation['relationForeignKey'] : $table . "_id";
|
||||
$relationPrimaryKey = $relation['relationPrimaryKey'] ? $relation['relationPrimaryKey'] : $priKey;
|
||||
$relationForeignKey = $relation['relationForeignKey'] ?: $table . "_id";
|
||||
$relationPrimaryKey = $relation['relationPrimaryKey'] ?: $priKey;
|
||||
if (!in_array($relationForeignKey, $relation['relationFieldList'])) {
|
||||
throw new Exception('relation table [' . $relation['relationTableName'] . '] must be contain field [' . $relationForeignKey . ']');
|
||||
}
|
||||
|
|
@ -901,6 +901,12 @@ class Crud extends Command
|
|||
$cssClassArr[] = 'selectpage';
|
||||
$selectpageTable = substr($field, 0, strripos($field, '_'));
|
||||
$selectpageField = '';
|
||||
foreach ($relations as $index => $relation) {
|
||||
if ($relation['relationForeignKey'] === $field) {
|
||||
$selectpageTable = substr($relation['relationTableName'], strlen($prefix));
|
||||
break;
|
||||
}
|
||||
}
|
||||
$selectpageController = str_replace('_', '/', $selectpageTable);
|
||||
$attrArr['data-source'] = $selectpageController . "/index";
|
||||
//如果是类型表需要特殊处理下
|
||||
|
|
|
|||
|
|
@ -441,8 +441,11 @@ class Addon extends Backend
|
|||
} catch (\Exception $e) {
|
||||
|
||||
}
|
||||
$rows = isset($json['rows']) ? $json['rows'] : [];
|
||||
$rows = $json['rows'] ?? [];
|
||||
foreach ($rows as $index => $row) {
|
||||
if (!isset($row['name'])) {
|
||||
continue;
|
||||
}
|
||||
$onlineaddons[$row['name']] = $row;
|
||||
}
|
||||
Cache::set("onlineaddons", $onlineaddons, 600);
|
||||
|
|
|
|||
Loading…
Reference in New Issue