From cef5b1920df6521f021a9e793003eb1ad2e7cd8f Mon Sep 17 00:00:00 2001 From: Karson Date: Tue, 17 Jun 2025 14:09:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9ECRUD=E5=BC=BA=E5=88=B6?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/admin/command/Crud.php | 14 ++++++++++++-- application/admin/command/Crud/stubs/model.stub | 5 +++++ application/admin/command/Install.php | 1 - application/admin/command/Menu.php | 1 + application/admin/controller/auth/Group.php | 1 - 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/application/admin/command/Crud.php b/application/admin/command/Crud.php index 3c54d39f..361cce7a 100755 --- a/application/admin/command/Crud.php +++ b/application/admin/command/Crud.php @@ -711,6 +711,7 @@ class Crud extends Command $getAttrArr = []; $getEnumArr = []; $appendAttrList = []; + $typeDefineList = []; $controllerAssignList = []; $headingHtml = '{:build_heading()}'; $controllerImport = ''; @@ -743,10 +744,17 @@ class Crud extends Command if ($v['COLUMN_COMMENT'] != '') { $langList[] = $this->getLangItem($field, $v['COLUMN_COMMENT']); } - $inputType = ''; + + $inputType = $this->getFieldType($v); + + // 强制类型转换 + if ($inputType === 'number' && $v['DATA_TYPE'] == 'bigint') { + $typeDefineList[] = << 'string' +EOD; + } //保留字段不能修改和添加 if ($v['COLUMN_KEY'] != 'PRI' && !in_array($field, $this->reservedField) && !in_array($field, $this->ignoreFields)) { - $inputType = $this->getFieldType($v); // 如果是number类型时增加一个步长 $step = $inputType == 'number' && $v['NUMERIC_SCALE'] > 0 ? "0." . str_repeat(0, $v['NUMERIC_SCALE'] - 1) . "1" : 0; @@ -1135,6 +1143,7 @@ class Crud extends Command 'recyclebinHtml' => $recyclebinHtml, 'visibleFieldList' => $fields ? "\$row->visible(['" . implode("','", array_filter(in_array($priKey, explode(',', $fields)) ? explode(',', $fields) : explode(',', $priKey . ',' . $fields))) . "']);" : '', 'appendAttrList' => implode(",\n", $appendAttrList), + 'typeDefineList' => implode(",\n", $typeDefineList), 'getEnumList' => implode("\n\n", $getEnumArr), 'getAttrList' => implode("\n\n", $getAttrArr), 'setAttrList' => implode("\n\n", $setAttrArr), @@ -1273,6 +1282,7 @@ EOD; return; } $attrField = ucfirst($this->getCamelizeName($field)); + $return = ''; if ($inputType == 'datetime') { $return = << $v) { if (!is_dir(ROOT_PATH . $v)) { throw new Exception(__('Please go to the official website to download the full package or resource package and try to install')); - break; } } return true; diff --git a/application/admin/command/Menu.php b/application/admin/command/Menu.php index cc21f3bd..525b6043 100755 --- a/application/admin/command/Menu.php +++ b/application/admin/command/Menu.php @@ -256,6 +256,7 @@ class Menu extends Command \think\Lang::load(dirname(__DIR__) . DS . 'lang/zh-cn.php'); //先导入菜单的数据 + $name = ''; $pid = 0; foreach ($controllerArr as $k => $v) { $key = $k + 1; diff --git a/application/admin/controller/auth/Group.php b/application/admin/controller/auth/Group.php index 29ae01dd..6ee525af 100644 --- a/application/admin/controller/auth/Group.php +++ b/application/admin/controller/auth/Group.php @@ -175,7 +175,6 @@ class Group extends Backend } } $this->error(); - return; } $this->view->assign("row", $row); return $this->view->fetch();