From 0d57902b66257ec54e39106f9718ca249ec4caa5 Mon Sep 17 00:00:00 2001 From: Gosowong <1329847115@qq.com> Date: Thu, 8 Jun 2023 15:03:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0cdn=E5=9F=9F=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adminapi/controller/v1/setting/SystemStorage.php | 3 ++- crmeb/app/services/other/UploadService.php | 1 + .../services/system/config/SystemStorageServices.php | 11 ++++++++--- crmeb/crmeb/services/upload/extend/obs/Client.php | 4 +--- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/crmeb/app/adminapi/controller/v1/setting/SystemStorage.php b/crmeb/app/adminapi/controller/v1/setting/SystemStorage.php index 853bbea62..9d1c3696a 100644 --- a/crmeb/app/adminapi/controller/v1/setting/SystemStorage.php +++ b/crmeb/app/adminapi/controller/v1/setting/SystemStorage.php @@ -202,6 +202,7 @@ class SystemStorage extends AuthController public function updateDomain($id) { $domain = $this->request->post('domain', ''); + $cdn = $this->request->post('cdn', ''); $data = $this->request->postMore([ ['pri', ''], ['ca', ''] @@ -217,7 +218,7 @@ class SystemStorage extends AuthController // return app('json')->fail('域名为HTTPS访问时,必须填写证书'); // } - $this->services->updateDomain($id, $domain); + $this->services->updateDomain($id, $domain, ['cdn' => $cdn]); return app('json')->success(100001); } diff --git a/crmeb/app/services/other/UploadService.php b/crmeb/app/services/other/UploadService.php index 45822ad2c..5e0fff9f6 100644 --- a/crmeb/app/services/other/UploadService.php +++ b/crmeb/app/services/other/UploadService.php @@ -95,6 +95,7 @@ class UploadService $config['uploadUrl'] = $res['domain']; $config['storageName'] = $res['name']; $config['storageRegion'] = $res['region']; + $config['cdn'] = $res['cdn']; } $thumb = SystemConfigService::more(['thumb_big_height', 'thumb_big_width', 'thumb_mid_height', 'thumb_mid_width', 'thumb_small_height', 'thumb_small_width',]); diff --git a/crmeb/app/services/system/config/SystemStorageServices.php b/crmeb/app/services/system/config/SystemStorageServices.php index dfd61fcd6..20da7bb27 100644 --- a/crmeb/app/services/system/config/SystemStorageServices.php +++ b/crmeb/app/services/system/config/SystemStorageServices.php @@ -425,11 +425,11 @@ class SystemStorageServices extends BaseServices */ public function getConfig(int $type) { - $res = ['name' => '', 'region' => '', 'domain' => '']; + $res = ['name' => '', 'region' => '', 'domain' => '', 'cdn' => '']; try { $config = $this->dao->get(['type' => $type, 'status' => 1, 'is_delete' => 0]); if ($config) { - return ['name' => $config->name, 'region' => $config->region, 'domain' => $config->domain]; + return ['name' => $config->name, 'region' => $config->region, 'domain' => $config->domain, 'cdn' => $config->cdn]; } } catch (\Throwable $e) { } @@ -448,6 +448,7 @@ class SystemStorageServices extends BaseServices $domain = $this->dao->value(['id' => $id], 'domain'); $rule = [ FormBuilder::input('domain', '空间域名', $domain), + FormBuilder::input('cdn', 'cdn域名', $domain), ]; return create_form('修改空间域名', $rule, '/system/config/storage/domain/' . $id); } @@ -488,7 +489,11 @@ class SystemStorageServices extends BaseServices $resDomain = $upload->getDomianInfo($domain); $info->cname = $resDomain['cname'] ?? ''; } - return $info->save(); + $info->save(); + } + if ($info->cdn != $data['cdn']) { + $info->cdn = $data['cdn']; + $info->save(); } $this->cacheDriver()->clear(); diff --git a/crmeb/crmeb/services/upload/extend/obs/Client.php b/crmeb/crmeb/services/upload/extend/obs/Client.php index b33ba9bb6..3fec47ae5 100644 --- a/crmeb/crmeb/services/upload/extend/obs/Client.php +++ b/crmeb/crmeb/services/upload/extend/obs/Client.php @@ -175,10 +175,8 @@ class Client extends BaseClient */ public function putObject(string $key, $body, string $contentType = 'image/jpeg') { - $url = $this->uploadUrl ?: $this->getRequestUrl($this->bucketName, $this->region); - $header = [ - 'Host' => $url, + 'Host' => $this->getRequestUrl($this->bucketName, $this->region), 'Content-Type' => $contentType, 'Content-Length' => strlen($body), ];