作者 lyh

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into develop

... ... @@ -184,4 +184,23 @@ class DomainInfoController extends BaseController
return $this->response('success',Code::SUCCESS,['file_link'=>url('upload/excel/'.$filename)]);
}
/**
* 编辑网站证书
* @param DomainInfoLogic $domainInfoLogic
* @throws \App\Exceptions\AsideGlobalException
* @throws \App\Exceptions\BsideGlobalException
* @author Akun
* @date 2023/10/17 11:52
*/
public function setSsl(DomainInfoLogic $domainInfoLogic){
$this->request->validate([
'id'=>'required',
'type' => 'required',
],[
'id.required' => 'id不能为空',
'type.required' => '类型不能为空',
]);
$domainInfoLogic->setDomainSsl();
$this->response('success');
}
}
... ...
... ... @@ -4,9 +4,11 @@ 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\DeployOptimize;
use App\Models\Project\Project;
use App\Utils\HttpUtils;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Support\Carbon;
... ... @@ -143,8 +145,65 @@ class DomainInfoLogic extends BaseLogic
return $this->success($info);
}
/**
* 编辑网站证书
* @return array
* @throws \App\Exceptions\AsideGlobalException
* @throws \App\Exceptions\BsideGlobalException
* @author Akun
* @date 2023/10/17 11:52
*/
public function setDomainSsl()
{
$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值不能为空');
}
if(empty($this->param['cert'])){
$this->fail('证书cert值不能为空');
}
// $api_url = 'http://'.$server_info['init_domain'].'/setSsl';
$api_url = 'http://master2.globalso.com/api/setSsl';
$api_param = [
'domain' => $info['domain'],
'private_key' => $this->param['key'],
'cert' => $this->param['cert'],
];
}else{
// $api_url = 'http://'.$server_info['init_domain'].'/applySsl';
$api_url = 'http://master2.globalso.com/api/applySsl';
$api_param = ['domain' => $info['domain']];
}
try {
$rs = HttpUtils::get($api_url, $api_param);
if(isset($rs['status']) && $rs['status'] == 200){
return $this->success();
}else{
$this->fail($rs['message']??'');
}
} catch (\Exception | GuzzleException $e) {
errorLog('创建站点', $api_param, $e);
$this->fail('编辑证书失败');
}
}
}
... ...
... ... @@ -7,6 +7,8 @@ use App\Models\Devops\ServerConfig;
use App\Models\Project\ProjectRenew;
use App\Models\User\ProjectMenu;
use App\Models\User\ProjectRole;
use App\Utils\HttpUtils;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Support\Arr as SupArr;
use App\Helper\Arr;
use App\Helper\Common;
... ... @@ -109,6 +111,8 @@ class ProjectLogic extends BaseLogic
$this->saveProjectDeployOptimize($this->param['deploy_optimize']);
//保存售后信息
$this->saveProjectAfter($this->param['project_after']);
//创建站点
$this->createSite($this->param);
}
DB::commit();
}catch (\Exception $e){
... ... @@ -490,4 +494,30 @@ class ProjectLogic extends BaseLogic
return $this->success();
}
/**
* 创建站点
* @param $param
* @author Akun
* @date 2023/10/17 10:04
*/
public function createSite($param){
if(isset($param['serve_id']) && $param['serve_id'] && isset($param['deploy_optimize']['domain']) && $param['deploy_optimize']['domain']){
$server_model = new ServerConfig();
$server_info = $server_model->read(['id',$param['serve_id']],'init_domain');
$domain_model = new DomainInfo();
$domain_info = $domain_model->read(['id',$param['deploy_optimize']['domain']],'domain');
if($server_info && $domain_info){
// $api_url = 'http://'.$server_info['init_domain'].'/api/createSite';
$api_url = 'http://master2.globalso.com/api/createSite';
$api_param = ['domain'=>$domain_info['domain']];
try {
HttpUtils::get($api_url, $api_param);
} catch (\Exception | GuzzleException $e) {
errorLog('创建站点', $api_param, $e);
}
}
}
}
}
... ...
... ... @@ -214,6 +214,7 @@ Route::middleware(['aloginauth'])->group(function () {
Route::any('/status', [Aside\Domain\DomainInfoController::class, 'status'])->name('admin.domain_status');
Route::any('/getProject', [Aside\Domain\DomainInfoController::class, 'getProject'])->name('admin.domain_getProject');
Route::any('/del', [Aside\Domain\DomainInfoController::class, 'del'])->name('admin.domain_del');
Route::any('/setSsl', [Aside\Domain\DomainInfoController::class, 'setSsl'])->name('admin.domain_setSsl');
Route::any('/log', [Aside\Domain\DomainInfoLogController::class, 'lists'])->name('admin.domain_log_lists'); // 日志
});
... ...