作者 刘锟

自建站项目转发接口增加返回值

@@ -8,8 +8,10 @@ use App\Models\Project\DeployBuild; @@ -8,8 +8,10 @@ use App\Models\Project\DeployBuild;
8 use App\Models\Project\Project; 8 use App\Models\Project\Project;
9 use App\Models\User\User; 9 use App\Models\User\User;
10 use App\Models\Visit\SyncSubmitTask; 10 use App\Models\Visit\SyncSubmitTask;
  11 +use App\Models\WebSetting\WebSettingFormBack;
11 use App\Services\CosService; 12 use App\Services\CosService;
12 use Illuminate\Http\Request; 13 use Illuminate\Http\Request;
  14 +use Illuminate\Support\Facades\Cache;
13 use Illuminate\Support\Facades\Redis; 15 use Illuminate\Support\Facades\Redis;
14 16
15 class SelfSiteController extends BaseController 17 class SelfSiteController extends BaseController
@@ -88,7 +90,34 @@ class SelfSiteController extends BaseController @@ -88,7 +90,34 @@ class SelfSiteController extends BaseController
88 'user_agent' => $user_agent 90 'user_agent' => $user_agent
89 ]; 91 ];
90 SyncSubmitTask::createTask($array, $type, $traffic); 92 SyncSubmitTask::createTask($array, $type, $traffic);
91 - return $this->success([]); 93 +
  94 + $result = [];
  95 + if ($type == SyncSubmitTask::TYPE_INQUIRY) {
  96 + $result = $this->inquiryResult($pid, $domain);
  97 + }
  98 + return $this->success($result);
  99 + }
  100 +
  101 + protected function inquiryResult($pid, $domain)
  102 + {
  103 + $cache_key = 'inquiry_form_back_' . $domain;
  104 + $result = Cache::get($cache_key);
  105 + if (!$result) {
  106 + $result = [
  107 + 'message' => "",
  108 + 'url' => "",
  109 + 'other' => ""
  110 + ];
  111 + $webFormBack = WebSettingFormBack::getBack($pid);
  112 + if (!empty($webFormBack)) {
  113 + $result["message"] = $webFormBack->message ?? "";
  114 + $result["url"] = $webFormBack->url ?? "";
  115 + $result["other"] = $webFormBack->other ?? "";
  116 + Cache::put($cache_key, $result, 3600);
  117 + }
  118 + }
  119 +
  120 + return $result;
92 } 121 }
93 122
94 /** 123 /**