From c8fcac91b0a2b71948b9086f79d41624eef6e051 Mon Sep 17 00:00:00 2001 From: liaofei <136327134@qq.com> Date: Mon, 24 Apr 2023 19:24:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BF=AE=E6=94=B9=E8=A1=A8?= =?UTF-8?q?=E5=A4=87=E6=B3=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/system/SystemCrudServices.php | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/crmeb/app/services/system/SystemCrudServices.php b/crmeb/app/services/system/SystemCrudServices.php index 2d3daea82..92ec665be 100644 --- a/crmeb/app/services/system/SystemCrudServices.php +++ b/crmeb/app/services/system/SystemCrudServices.php @@ -368,6 +368,23 @@ class SystemCrudServices extends BaseServices return Db::execute($sql); } + /** + * 修改表备注 + * @param string $tableName + * @param string $common + * @return mixed + * @author 等风来 + * @email 136327134@qq.com + * @date 2023/4/24 + */ + protected function updateFromCommon(string $tableName, string $common) + { + $tableName = $this->getTableName($tableName); + $common = addslashes($common); + $sql = "ALTER TABLE `$tableName` COMMENT = '$common';"; + return Db::execute($sql); + } + /** * 对比字段变动了更改 * @param string $tableName @@ -470,10 +487,10 @@ class SystemCrudServices extends BaseServices public function createCrud(int $id, array $data) { $tableName = $data['tableName']; - $tableComment = $data['tableComment'] ?? $data['menuName']; $tableField = $this->valueReplace($data['tableField']); $filePath = $this->valueReplace($data['filePath']); - $modelName = $data['modelName'] ?? $data['menuName'] ?? $tableName; + $modelName = !empty($data['modelName']) ? $data['modelName'] : $tableName; + $tableComment = !empty($data['tableComment']) ? $data['tableComment'] : $modelName; //检测是否为系统表 if (in_array($tableName, self::NOT_CRUD_TABANAME)) { @@ -484,6 +501,7 @@ class SystemCrudServices extends BaseServices $tableInfo = null; if ($id) { + $this->updateFromCommon($tableName, $tableComment); //删除数据库表 $tableInfo = $this->getTableInfo($tableName); if ($tableInfo) {