Преглед изворни кода

Merge branch 'v5.0.0dev' of https://gitee.com/ZhongBangKeJi/CRMEB into v5.0.0dev

From-wh пре 2 година
родитељ
комит
a1a5f766e4

+ 11 - 6
crmeb/.env

@@ -7,21 +7,26 @@ DEFAULT_TIMEZONE = Asia/Shanghai
 TYPE = mysql
 HOSTNAME = 127.0.0.1
 HOSTPORT = 3306
-USERNAME = crmeb
-PASSWORD = '123456'
-DATABASE = crmeb
+USERNAME =
+PASSWORD =
+DATABASE =
 PREFIX = eb_
-CHARSET = utf8
+CHARSET = utf8mb4
 DEBUG = true
 
 [LANG]
 default_lang = zh-cn
 
+[CACHE]
+DRIVER = file
+CACHE_PREFIX =
+CACHE_TAG_PREFIX =
+
 [REDIS]
 REDIS_HOSTNAME = 127.0.0.1
 PORT = 6379
-REDIS_PASSWORD = '123456'
+REDIS_PASSWORD =
 SELECT = 0
 
 [QUEUE]
-QUEUE_NAME = 638f005e37b38
+QUEUE_NAME =

+ 40 - 17
crmeb/app/adminapi/controller/v1/setting/SystemCrud.php

@@ -317,24 +317,41 @@ class SystemCrud extends AuthController
         if ($newColumn) {
             $info['field']['tableField'] = array_merge($newColumn, $info['field']['tableField']);
         }
-        $keyInfo = [];
-        $deleteInfo = [];
-        foreach ($info['field']['tableField'] as $key => $item) {
+
+        $keyInfo = $deleteInfo = $createInfo = $updateInfo = [];
+        $tableField = [];
+        foreach ($info['field']['tableField'] as $item) {
             if ($item['primaryKey']) {
                 $keyInfo = $item;
-                unset($info['field']['tableField'][$key]);
+                continue;
             }
-            if ($item['field_type'] == 'addSoftDelete') {
+            if ($item['field_type'] == 'timestamp' && $item['field'] === 'delete_time') {
                 $deleteInfo = $item;
-                unset($info['field']['tableField'][$key]);
+                continue;
+            }
+            if ($item['field_type'] == 'timestamp' && $item['field'] === 'create_time') {
+                $createInfo = $item;
+                continue;
+            }
+            if ($item['field_type'] == 'timestamp' && $item['field'] === 'update_time') {
+                $updateInfo = $item;
+                continue;
             }
+            $tableField[] = $item;
         }
         if ($keyInfo) {
-            array_unshift($info['field']['tableField'], $keyInfo);
+            array_unshift($tableField, $keyInfo);
+        }
+        if ($createInfo) {
+            array_push($tableField, $createInfo);
+        }
+        if ($updateInfo) {
+            array_push($tableField, $updateInfo);
         }
         if ($deleteInfo) {
-            array_push($info['field']['tableField'], $deleteInfo);
+            array_push($tableField, $deleteInfo);
         }
+        $info['field']['tableField'] = $tableField;
         $info['field']['pid'] = (int)$info['field']['pid'];
         return app('json')->success(['file' => $data, 'crudInfo' => $info]);
     }
@@ -446,17 +463,23 @@ class SystemCrud extends AuthController
         });
 
         if ($info->make_path) {
-            try {
-                foreach ($info->make_path as $key => $item) {
-                    if (in_array($key, ['pages', 'router', 'api'])) {
-                        $item = Make::adminTemplatePath() . $item;
-                    } else {
-                        $item = app()->getRootPath() . $item;
-                    }
+            $errorFile = [];
+            foreach ($info->make_path as $key => $item) {
+                if (in_array($key, ['pages', 'router', 'api'])) {
+                    $item = Make::adminTemplatePath() . $item;
+                } else {
+                    $item = app()->getRootPath() . $item;
+                }
+                try {
                     unlink($item);
+                } catch (\Throwable $e) {
+                    $errorFile[] = $item;
                 }
-            } catch (\Throwable $e) {
-                return app('json')->success(500040, [], ['message' => $e->getMessage()]);
+            }
+            if ($errorFile) {
+                return app('json')->success(500040, [], [
+                    'message' => '文件:' . implode("\n", $errorFile) . ';无法被删除!'
+                ]);
             }
         }
 

+ 15 - 1
crmeb/app/services/system/SystemCrudServices.php

@@ -352,7 +352,21 @@ class SystemCrudServices extends BaseServices
         if (in_array(strtolower($type), ['text', 'longtext', 'tinytext'])) {
             $sql = "ALTER TABLE `$tableName` ADD `$field` $type NULL COMMENT '$comment' $after;";
         } else {
-            $sql = "ALTER TABLE `$tableName` ADD `$field` $type($limit) NOT NULL DEFAULT '$default' COMMENT '$comment' $after;";
+            $defaultSql = "NOT NULL DEFAULT '$default'";
+            //处理时间字段默认值
+            if (in_array(strtolower($type), ['datetime', 'timestamp', 'time', 'date', 'year'])) {
+                switch ($field) {
+                    case 'delete_time':
+                        $defaultSql = 'NULL DEFAULT NULL';
+                        break;
+                    case 'create_time':
+                    case 'update_time':
+                        $defaultSql = 'NOT NULL DEFAULT CURRENT_TIMESTAMP';
+                        break;
+                }
+            }
+            $limitSql = $limit ? '(' . $limit . ')' : '';
+            $sql = "ALTER TABLE `$tableName` ADD `$field` $type$limitSql $defaultSql COMMENT '$comment' $after;";
         }
         return Db::execute($sql);
     }

+ 3 - 1
crmeb/crmeb/services/AccessTokenServeService.php

@@ -52,14 +52,16 @@ class AccessTokenServeService extends HttpService
     protected $apiHost = 'http://sms.crmeb.net/api/';
 
     /**
+     * 沙盒地址
      * @var string
      */
     protected $sandBoxApi = 'https://api_v2.crmeb.net/api/';
 
     /**
+     * 沙盒模式
      * @var bool
      */
-    protected $sandBox = true;
+    protected $sandBox = false;
 
     /**
      * 登录接口