|
...
|
...
|
@@ -12,6 +12,7 @@ namespace App\Http\Controllers\Bside\SeoSetting; |
|
|
|
use App\Enums\Common\Code;
|
|
|
|
use App\Http\Controllers\Bside\BaseController;
|
|
|
|
use App\Models\Domain\DomainInfo;
|
|
|
|
use App\Models\WebSetting\WebSetting;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -58,24 +59,42 @@ class DomainSettingController extends BaseController |
|
|
|
if(!empty($domain)){
|
|
|
|
$this->param['domain'] = trim($domain['host']);
|
|
|
|
}
|
|
|
|
//添加域名到域名管理
|
|
|
|
$info = $this->model->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
if($info === false){
|
|
|
|
$domainInfo = $this->model->read(['domain'=>$domain]);
|
|
|
|
if ($domainInfo !== false) {
|
|
|
|
$this->fail('当前域名已存在');
|
|
|
|
//保存一条主域名记录
|
|
|
|
try {
|
|
|
|
$this->saveWebSetting($this->param['domain']);
|
|
|
|
//添加域名到域名管理
|
|
|
|
$info = $this->model->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
if($info === false){
|
|
|
|
//保存数据
|
|
|
|
$this->param['domain'] = str_replace('www','blog',$this->param['domain']);
|
|
|
|
$id = $this->model->addReturnId(['domain'=>$this->param['domain'],'project_id'=>$this->user['project_id'],'belong_to'=>2,'status'=>1]);
|
|
|
|
$projectModel = new Project();
|
|
|
|
$projectModel->edit(['domain'=>$id],['project_id'=>$this->user['project_id']]);
|
|
|
|
}else{
|
|
|
|
$this->model->edit(['domain'=>$this->param['domain']],['project_id'=>$this->user['project_id']]);
|
|
|
|
}
|
|
|
|
//保存数据
|
|
|
|
$id = $this->model->addReturnId(['domain'=>$this->param['domain'],'project_id'=>$this->user['project_id'],'belong_to'=>2,'status'=>1]);
|
|
|
|
$projectModel = new Project();
|
|
|
|
$projectModel->edit(['domain'=>$id],['project_id'=>$this->user['project_id']]);
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('保存失败,请联系管理员');
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->response('success');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存主域名设置
|
|
|
|
* @name :saveWebSetting
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/3/20 15:38
|
|
|
|
*/
|
|
|
|
public function saveWebSetting($domain){
|
|
|
|
$webSettingModel = new WebSetting();
|
|
|
|
$settingInfo = $webSettingModel->read(['project_id'=>$this->user['project_id']]);
|
|
|
|
if($settingInfo === false){
|
|
|
|
$webSettingModel->add(['seo_domain'=>$domain,'project_id'=>$this->user['project_id']]);
|
|
|
|
}else{
|
|
|
|
$id = $info['id'];
|
|
|
|
$domainInfo = $this->model->read(['domain'=>$domain,'id'=>['!=',$id]]);
|
|
|
|
if ($domainInfo !== false) {
|
|
|
|
$this->fail('当前域名已存在');
|
|
|
|
}
|
|
|
|
$this->model->edit(['domain'=>$this->param['domain']],['project_id'=>$this->user['project_id']]);
|
|
|
|
$webSettingModel->edit(['seo_domain'=>$domain],['id'=>$settingInfo['id']]);
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|