liaofei 2 лет назад
Родитель
Сommit
c8fcac91b0
1 измененных файлов с 20 добавлено и 2 удалено
  1. 20 2
      crmeb/app/services/system/SystemCrudServices.php

+ 20 - 2
crmeb/app/services/system/SystemCrudServices.php

@@ -368,6 +368,23 @@ class SystemCrudServices extends BaseServices
         return Db::execute($sql);
         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
      * @param string $tableName
@@ -470,10 +487,10 @@ class SystemCrudServices extends BaseServices
     public function createCrud(int $id, array $data)
     public function createCrud(int $id, array $data)
     {
     {
         $tableName = $data['tableName'];
         $tableName = $data['tableName'];
-        $tableComment = $data['tableComment'] ?? $data['menuName'];
         $tableField = $this->valueReplace($data['tableField']);
         $tableField = $this->valueReplace($data['tableField']);
         $filePath = $this->valueReplace($data['filePath']);
         $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)) {
         if (in_array($tableName, self::NOT_CRUD_TABANAME)) {
@@ -484,6 +501,7 @@ class SystemCrudServices extends BaseServices
 
 
         $tableInfo = null;
         $tableInfo = null;
         if ($id) {
         if ($id) {
+            $this->updateFromCommon($tableName, $tableComment);
             //删除数据库表
             //删除数据库表
             $tableInfo = $this->getTableInfo($tableName);
             $tableInfo = $this->getTableInfo($tableName);
             if ($tableInfo) {
             if ($tableInfo) {