作者 lyh

gx

... ... @@ -196,11 +196,15 @@ class DomainInfoController extends BaseController
$this->request->validate([
'id'=>'required',
'type' => 'required',
'other_domain'=>'required',
'extend_config'=>'required'
],[
'id.required' => 'id不能为空',
'type.required' => '类型不能为空',
'other_domain.required' => '其他域名不能为空',
'extend_config.required' => '301配置不能为空',
]);
$domainInfoLogic->setDomainSsl();
$domainInfoLogic->sslSave();
$this->response('success');
}
}
... ...
... ... @@ -153,25 +153,8 @@ class DomainInfoLogic extends BaseLogic
* @author Akun
* @date 2023/10/17 11:52
*/
public function setDomainSsl()
public function setDomainSsl($initDomain,$domain,$rewrite,$other_domain)
{
$info = $this->model->read(['id'=>$this->param['id']]);
if($info === false){
$this->fail('当前数据不存在或者已被删除');
}
$project_model = new Project();
$project_info = $project_model->read(['id'=>$info['project_id']],'serve_id');
if($project_info === false){
$this->fail('获取项目数据失败');
}
$server_model = new ServerConfig();
$server_info = $server_model->read(['id'=>$project_info['serve_id']],'init_domain');
if($server_info === false){
$this->fail('获取服务器数据失败');
}
if($this->param['type'] == 2){
if(empty($this->param['key'])){
$this->fail('证书KEY值不能为空');
... ... @@ -179,18 +162,18 @@ class DomainInfoLogic extends BaseLogic
if(empty($this->param['cert'])){
$this->fail('证书cert值不能为空');
}
$api_url = 'http://'.$server_info['init_domain'].'/api/setSsl';
$api_url = 'http://'.$initDomain.'/api/setSsl';
$api_param = [
'domain' => $info['domain'],
'domain' => $domain,
'private_key' => $this->param['key'],
'cert' => $this->param['cert'],
'rewrite'=>$rewrite,
'other_domain'=>$other_domain
];
}else{
$api_url = 'http://'.$server_info['init_domain'].'/api/applySsl';
$api_param = ['domain' => $info['domain']];
$api_url = 'http://'.$initDomain.'/api/applySsl';
$api_param = ['domain' => $domain,'rewrite'=>$rewrite,'other_domain'=>$other_domain];
}
try {
$rs = HttpUtils::get($api_url, $api_param);
$rs = json_decode($rs, true);
... ... @@ -203,6 +186,41 @@ class DomainInfoLogic extends BaseLogic
errorLog('创建站点', $api_param, $e);
$this->fail('编辑证书失败');
}
return $this->success();
}
/**
* @remark :保存证书相关配置
* @name :sslSave
* @author :lyh
* @method :post
* @time :2023/11/6 10:50
*/
public function sslSave(){
$info = $this->model->read(['id'=>$this->param['id']]);
if($info === false){
$this->fail('当前数据不存在或者已被删除');
}
//获取项目数据
$project_model = new Project();
$project_info = $project_model->read(['id'=>$info['project_id']],'serve_id');
if($project_info === false){
$this->fail('获取项目数据失败');
}
$server_model = new ServerConfig();
$server_info = $server_model->read(['id'=>$project_info['serve_id']],'init_domain');
if($server_info === false){
$this->fail('获取服务器数据失败');
}
//保存301跳转数据+其他域名
$data = [
'other_domain'=>json_encode($this->param['other_domain']),
'extend_config'=>json_encode($this->param['extend_config']),
];
$this->model->edit($data,['id'=>$this->param['id']]);
//生成证书
$this->setDomainSsl($server_info['init_domain'],$info['domain'],$this->param['extend_config'],$this->param['other_domain']);
return $this->success();
}
}
... ...
... ... @@ -13,5 +13,5 @@ use App\Models\Base;
class CustomModule extends Base
{
protected $table = '';
protected $table = 'gl_custom_module';
}
... ...
<?php
/**
* @remark :
* @name :CustomModuleCategory.php
* @author :lyh
* @method :post
* @time :2023/11/6 10:04
*/
namespace App\Models\CustomModule;
use App\Models\Base;
class CustomModuleCategory extends Base
{
protected $table = 'gl_custom_module_category';
}
... ...
<?php
/**
* @remark :
* @name :CustomModuleContent.php
* @author :lyh
* @method :post
* @time :2023/11/6 10:04
*/
namespace App\Models\CustomModule;
use App\Models\Base;
class CustomModuleContent extends Base
{
protected $table = 'gl_custom_module_content';
}
... ...
<?php
/**
* @remark :
* @name :CustomModuleLabel.php
* @author :lyh
* @method :post
* @time :2023/11/6 10:05
*/
namespace App\Models\CustomModule;
use App\Models\Base;
class CustomModuleLabel extends Base
{
protected $table = 'gl_custom_module_label';
}
... ...