正在显示
4 个修改的文件
包含
68 行增加
和
0 行删除
| @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Bside\Setting; | @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Bside\Setting; | ||
| 4 | 4 | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | use App\Http\Controllers\Bside\BaseController; | 6 | use App\Http\Controllers\Bside\BaseController; |
| 7 | +use App\Http\Logic\Aside\Domain\DomainInfoLogic; | ||
| 7 | use App\Http\Logic\Bside\Setting\ProjectCountryLogic; | 8 | use App\Http\Logic\Bside\Setting\ProjectCountryLogic; |
| 8 | 9 | ||
| 9 | /** | 10 | /** |
| @@ -32,4 +33,20 @@ class ProjectCountryController extends BaseController | @@ -32,4 +33,20 @@ class ProjectCountryController extends BaseController | ||
| 32 | $projectCountryLogic->country_save(); | 33 | $projectCountryLogic->country_save(); |
| 33 | $this->response('success'); | 34 | $this->response('success'); |
| 34 | } | 35 | } |
| 36 | + | ||
| 37 | + public function custom(DomainInfoLogic $domainInfoLogic){ | ||
| 38 | + $this->request->validate([ | ||
| 39 | + 'project_id'=>'required', | ||
| 40 | + 'language_id'=>'required', | ||
| 41 | + 'custom_domain'=>'required', | ||
| 42 | + 'is_create'=>'required', | ||
| 43 | + ],[ | ||
| 44 | + 'project_id.required' => 'project_id不能为空', | ||
| 45 | + 'language_id.required' => 'language_id不能为空', | ||
| 46 | + 'custom_domain.required' => 'custom_domain不能为空', | ||
| 47 | + 'is_create.required' => 'is_create不能为空', | ||
| 48 | + ]); | ||
| 49 | + $domainInfoLogic->country_custom(); | ||
| 50 | + $this->response('success'); | ||
| 51 | + } | ||
| 35 | } | 52 | } |
| @@ -6,6 +6,7 @@ namespace App\Http\Logic\Aside\Domain; | @@ -6,6 +6,7 @@ namespace App\Http\Logic\Aside\Domain; | ||
| 6 | use App\Http\Logic\Aside\BaseLogic; | 6 | use App\Http\Logic\Aside\BaseLogic; |
| 7 | use App\Models\Devops\ServerConfig; | 7 | use App\Models\Devops\ServerConfig; |
| 8 | use App\Models\Domain\DomainInfo; | 8 | use App\Models\Domain\DomainInfo; |
| 9 | +use App\Models\Project\CountryCustom; | ||
| 9 | use App\Models\Project\DeployOptimize; | 10 | use App\Models\Project\DeployOptimize; |
| 10 | use App\Models\Project\Project; | 11 | use App\Models\Project\Project; |
| 11 | use App\Utils\HttpUtils; | 12 | use App\Utils\HttpUtils; |
| @@ -350,4 +351,43 @@ class DomainInfoLogic extends BaseLogic | @@ -350,4 +351,43 @@ class DomainInfoLogic extends BaseLogic | ||
| 350 | } | 351 | } |
| 351 | return false; | 352 | return false; |
| 352 | } | 353 | } |
| 354 | + | ||
| 355 | + public function country_custom(){ | ||
| 356 | + $project_model = new Project(); | ||
| 357 | + $project_info = $project_model->read(['id'=>$this->param['project_id']],'serve_id'); | ||
| 358 | + if($project_info === false){ | ||
| 359 | + $this->fail('获取项目数据失败'); | ||
| 360 | + } | ||
| 361 | + | ||
| 362 | + if($this->param['is_create']){ | ||
| 363 | + //需要创建站点 | ||
| 364 | + $server_model = new ServerConfig(); | ||
| 365 | + $server_info = $server_model->read(['id'=>$project_info['serve_id']],['init_domain', 'host']); | ||
| 366 | + if($server_info === false){ | ||
| 367 | + $this->fail('获取服务器数据失败'); | ||
| 368 | + } | ||
| 369 | + | ||
| 370 | + //域名是否都已经解析 | ||
| 371 | + if(!$this->check_cname($this->param['custom_domain'], $server_info)){ | ||
| 372 | + $this->fail('域名' . $this->param['custom_domain'] . '未解析至目标服务器'); | ||
| 373 | + } | ||
| 374 | + } | ||
| 375 | + | ||
| 376 | + $custom_model = new CountryCustom(); | ||
| 377 | + $info = $custom_model->read(['project_id',$this->user['project_id'],'language_id'=>$this->param['language_id']]); | ||
| 378 | + if($info === false){ | ||
| 379 | + $custom_model->add($this->param); | ||
| 380 | + }else{ | ||
| 381 | + $custom_model->edit($this->param,['id'=>$info['id']]); | ||
| 382 | + } | ||
| 383 | + | ||
| 384 | + if($this->param['is_create']){ | ||
| 385 | + //创建站点,设置证书 | ||
| 386 | + $this->param['key'] = $this->param['private_key'] ?? ''; | ||
| 387 | + $this->param['cert'] = $this->param['private_cert'] ?? ''; | ||
| 388 | + $this->setDomainSsl($server_info['init_domain'],$this->param['custom_domain'],[],[],0); | ||
| 389 | + } | ||
| 390 | + | ||
| 391 | + return $this->success(); | ||
| 392 | + } | ||
| 353 | } | 393 | } |
app/Models/Project/CountryCustom.php
0 → 100644
| @@ -156,6 +156,7 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -156,6 +156,7 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 156 | Route::prefix('country')->group(function () { | 156 | Route::prefix('country')->group(function () { |
| 157 | Route::any('/info', [\App\Http\Controllers\Bside\Setting\ProjectCountryController::class, 'info'])->name('web_setting_country_info'); | 157 | Route::any('/info', [\App\Http\Controllers\Bside\Setting\ProjectCountryController::class, 'info'])->name('web_setting_country_info'); |
| 158 | Route::any('/save', [\App\Http\Controllers\Bside\Setting\ProjectCountryController::class, 'save'])->name('web_setting_country_save'); | 158 | Route::any('/save', [\App\Http\Controllers\Bside\Setting\ProjectCountryController::class, 'save'])->name('web_setting_country_save'); |
| 159 | + Route::any('/custom', [\App\Http\Controllers\Bside\Setting\ProjectCountryController::class, 'custom'])->name('web_setting_country_custom'); | ||
| 159 | }); | 160 | }); |
| 160 | //客服设置 | 161 | //客服设置 |
| 161 | Route::prefix('service')->group(function () { | 162 | Route::prefix('service')->group(function () { |
-
请 注册 或 登录 后发表评论