作者 刘锟

小语种排序

... ... @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Bside\Setting;
use App\Enums\Common\Code;
use App\Http\Controllers\Bside\BaseController;
use App\Http\Logic\Aside\Domain\DomainInfoLogic;
use App\Http\Logic\Bside\Setting\ProjectCountryLogic;
/**
... ... @@ -32,4 +33,20 @@ class ProjectCountryController extends BaseController
$projectCountryLogic->country_save();
$this->response('success');
}
public function custom(DomainInfoLogic $domainInfoLogic){
$this->request->validate([
'project_id'=>'required',
'language_id'=>'required',
'custom_domain'=>'required',
'is_create'=>'required',
],[
'project_id.required' => 'project_id不能为空',
'language_id.required' => 'language_id不能为空',
'custom_domain.required' => 'custom_domain不能为空',
'is_create.required' => 'is_create不能为空',
]);
$domainInfoLogic->country_custom();
$this->response('success');
}
}
... ...
... ... @@ -6,6 +6,7 @@ namespace App\Http\Logic\Aside\Domain;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Devops\ServerConfig;
use App\Models\Domain\DomainInfo;
use App\Models\Project\CountryCustom;
use App\Models\Project\DeployOptimize;
use App\Models\Project\Project;
use App\Utils\HttpUtils;
... ... @@ -350,4 +351,43 @@ class DomainInfoLogic extends BaseLogic
}
return false;
}
public function country_custom(){
$project_model = new Project();
$project_info = $project_model->read(['id'=>$this->param['project_id']],'serve_id');
if($project_info === false){
$this->fail('获取项目数据失败');
}
if($this->param['is_create']){
//需要创建站点
$server_model = new ServerConfig();
$server_info = $server_model->read(['id'=>$project_info['serve_id']],['init_domain', 'host']);
if($server_info === false){
$this->fail('获取服务器数据失败');
}
//域名是否都已经解析
if(!$this->check_cname($this->param['custom_domain'], $server_info)){
$this->fail('域名' . $this->param['custom_domain'] . '未解析至目标服务器');
}
}
$custom_model = new CountryCustom();
$info = $custom_model->read(['project_id',$this->user['project_id'],'language_id'=>$this->param['language_id']]);
if($info === false){
$custom_model->add($this->param);
}else{
$custom_model->edit($this->param,['id'=>$info['id']]);
}
if($this->param['is_create']){
//创建站点,设置证书
$this->param['key'] = $this->param['private_key'] ?? '';
$this->param['cert'] = $this->param['private_cert'] ?? '';
$this->setDomainSsl($server_info['init_domain'],$this->param['custom_domain'],[],[],0);
}
return $this->success();
}
}
... ...
<?php
namespace App\Models\Project;
use App\Models\Base;
class CountryCustom extends Base
{
protected $table = 'gl_project_country_custom';
}
... ...
... ... @@ -156,6 +156,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::prefix('country')->group(function () {
Route::any('/info', [\App\Http\Controllers\Bside\Setting\ProjectCountryController::class, 'info'])->name('web_setting_country_info');
Route::any('/save', [\App\Http\Controllers\Bside\Setting\ProjectCountryController::class, 'save'])->name('web_setting_country_save');
Route::any('/custom', [\App\Http\Controllers\Bside\Setting\ProjectCountryController::class, 'custom'])->name('web_setting_country_custom');
});
//客服设置
Route::prefix('service')->group(function () {
... ...