|
@@ -11,6 +11,7 @@ namespace App\Http\Controllers\Bside\SeoSetting; |
|
@@ -11,6 +11,7 @@ namespace App\Http\Controllers\Bside\SeoSetting; |
|
11
|
|
11
|
|
|
12
|
use App\Enums\Common\Code;
|
12
|
use App\Enums\Common\Code;
|
|
13
|
use App\Http\Controllers\Bside\BaseController;
|
13
|
use App\Http\Controllers\Bside\BaseController;
|
|
|
|
14
|
+use App\Http\Logic\Bside\SeoSetting\DomainSettingLogic;
|
|
14
|
use App\Models\Domain\DomainInfo;
|
15
|
use App\Models\Domain\DomainInfo;
|
|
15
|
use App\Models\WebSetting\WebSetting;
|
16
|
use App\Models\WebSetting\WebSetting;
|
|
16
|
use Illuminate\Http\Request;
|
17
|
use Illuminate\Http\Request;
|
|
@@ -49,52 +50,13 @@ class DomainSettingController extends BaseController |
|
@@ -49,52 +50,13 @@ class DomainSettingController extends BaseController |
|
49
|
* @method :post
|
50
|
* @method :post
|
|
50
|
* @time :2025/3/20 11:29
|
51
|
* @time :2025/3/20 11:29
|
|
51
|
*/
|
52
|
*/
|
|
52
|
- public function save(){
|
53
|
+ public function save(DomainSettingLogic $logic){
|
|
53
|
$this->request->validate([
|
54
|
$this->request->validate([
|
|
54
|
'domain'=>['required'],
|
55
|
'domain'=>['required'],
|
|
55
|
],[
|
56
|
],[
|
|
56
|
'domain.required' => 'domain不能为空',
|
57
|
'domain.required' => 'domain不能为空',
|
|
57
|
]);
|
58
|
]);
|
|
58
|
- $domain = parse_url($this->param['domain'], PHP_URL_HOST);
|
|
|
|
59
|
- if(!empty($domain)){
|
|
|
|
60
|
- $this->param['domain'] = trim($domain['host']);
|
|
|
|
61
|
- }
|
|
|
|
62
|
- //保存一条主域名记录
|
|
|
|
63
|
- try {
|
|
|
|
64
|
- $this->saveWebSetting($this->param['domain']);
|
|
|
|
65
|
- //添加域名到域名管理
|
|
|
|
66
|
- $info = $this->model->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
67
|
- if($info === false){
|
|
|
|
68
|
- //保存数据
|
|
|
|
69
|
- $this->param['domain'] = str_replace('www','blog',$this->param['domain']);
|
|
|
|
70
|
- $id = $this->model->addReturnId(['domain'=>$this->param['domain'],'project_id'=>$this->user['project_id'],'belong_to'=>2,'status'=>1]);
|
|
|
|
71
|
- $projectModel = new Project();
|
|
|
|
72
|
- $projectModel->edit(['domain'=>$id],['project_id'=>$this->user['project_id']]);
|
|
|
|
73
|
- }else{
|
|
|
|
74
|
- $this->model->edit(['domain'=>$this->param['domain']],['project_id'=>$this->user['project_id']]);
|
|
|
|
75
|
- }
|
|
|
|
76
|
- }catch (\Exception $e){
|
|
|
|
77
|
- $this->fail('保存失败,请联系管理员');
|
|
|
|
78
|
- }
|
|
|
|
79
|
-
|
|
|
|
80
|
- $this->response('success');
|
|
|
|
81
|
- }
|
|
|
|
82
|
-
|
|
|
|
83
|
- /**
|
|
|
|
84
|
- * @remark :保存主域名设置
|
|
|
|
85
|
- * @name :saveWebSetting
|
|
|
|
86
|
- * @author :lyh
|
|
|
|
87
|
- * @method :post
|
|
|
|
88
|
- * @time :2025/3/20 15:38
|
|
|
|
89
|
- */
|
|
|
|
90
|
- public function saveWebSetting($domain){
|
|
|
|
91
|
- $webSettingModel = new WebSetting();
|
|
|
|
92
|
- $settingInfo = $webSettingModel->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
93
|
- if($settingInfo === false){
|
|
|
|
94
|
- $webSettingModel->add(['seo_domain'=>$domain,'project_id'=>$this->user['project_id']]);
|
|
|
|
95
|
- }else{
|
|
|
|
96
|
- $webSettingModel->edit(['seo_domain'=>$domain],['id'=>$settingInfo['id']]);
|
|
|
|
97
|
- }
|
|
|
|
98
|
- return $this->success();
|
59
|
+ $data = $logic->saveDomain();
|
|
|
|
60
|
+ $this->response('success',Code::SUCCESS,$data);
|
|
99
|
}
|
61
|
}
|
|
100
|
} |
62
|
} |