正在显示
4 个修改的文件
包含
109 行增加
和
0 行删除
| @@ -184,4 +184,23 @@ class DomainInfoController extends BaseController | @@ -184,4 +184,23 @@ class DomainInfoController extends BaseController | ||
| 184 | return $this->response('success',Code::SUCCESS,['file_link'=>url('upload/excel/'.$filename)]); | 184 | return $this->response('success',Code::SUCCESS,['file_link'=>url('upload/excel/'.$filename)]); |
| 185 | } | 185 | } |
| 186 | 186 | ||
| 187 | + /** | ||
| 188 | + * 编辑网站证书 | ||
| 189 | + * @param DomainInfoLogic $domainInfoLogic | ||
| 190 | + * @throws \App\Exceptions\AsideGlobalException | ||
| 191 | + * @throws \App\Exceptions\BsideGlobalException | ||
| 192 | + * @author Akun | ||
| 193 | + * @date 2023/10/17 11:52 | ||
| 194 | + */ | ||
| 195 | + public function setSsl(DomainInfoLogic $domainInfoLogic){ | ||
| 196 | + $this->request->validate([ | ||
| 197 | + 'id'=>'required', | ||
| 198 | + 'type' => 'required', | ||
| 199 | + ],[ | ||
| 200 | + 'id.required' => 'id不能为空', | ||
| 201 | + 'type.required' => '类型不能为空', | ||
| 202 | + ]); | ||
| 203 | + $domainInfoLogic->setDomainSsl(); | ||
| 204 | + $this->response('success'); | ||
| 205 | + } | ||
| 187 | } | 206 | } |
| @@ -4,9 +4,11 @@ namespace App\Http\Logic\Aside\Domain; | @@ -4,9 +4,11 @@ namespace App\Http\Logic\Aside\Domain; | ||
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | use App\Http\Logic\Aside\BaseLogic; | 6 | use App\Http\Logic\Aside\BaseLogic; |
| 7 | +use App\Models\Devops\ServerConfig; | ||
| 7 | use App\Models\Domain\DomainInfo; | 8 | use App\Models\Domain\DomainInfo; |
| 8 | use App\Models\Project\DeployOptimize; | 9 | use App\Models\Project\DeployOptimize; |
| 9 | use App\Models\Project\Project; | 10 | use App\Models\Project\Project; |
| 11 | +use App\Utils\HttpUtils; | ||
| 10 | use GuzzleHttp\Client; | 12 | use GuzzleHttp\Client; |
| 11 | use GuzzleHttp\Exception\GuzzleException; | 13 | use GuzzleHttp\Exception\GuzzleException; |
| 12 | use Illuminate\Support\Carbon; | 14 | use Illuminate\Support\Carbon; |
| @@ -143,8 +145,65 @@ class DomainInfoLogic extends BaseLogic | @@ -143,8 +145,65 @@ class DomainInfoLogic extends BaseLogic | ||
| 143 | return $this->success($info); | 145 | return $this->success($info); |
| 144 | } | 146 | } |
| 145 | 147 | ||
| 148 | + /** | ||
| 149 | + * 编辑网站证书 | ||
| 150 | + * @return array | ||
| 151 | + * @throws \App\Exceptions\AsideGlobalException | ||
| 152 | + * @throws \App\Exceptions\BsideGlobalException | ||
| 153 | + * @author Akun | ||
| 154 | + * @date 2023/10/17 11:52 | ||
| 155 | + */ | ||
| 156 | + public function setDomainSsl() | ||
| 157 | + { | ||
| 158 | + $info = $this->model->read(['id'=>$this->param['id']]); | ||
| 159 | + if($info === false){ | ||
| 160 | + $this->fail('当前数据不存在或者已被删除'); | ||
| 161 | + } | ||
| 162 | + | ||
| 163 | + $project_model = new Project(); | ||
| 164 | + $project_info = $project_model->read(['id',$info['project_id']],'serve_id'); | ||
| 165 | + if($project_info === false){ | ||
| 166 | + $this->fail('获取项目数据失败'); | ||
| 167 | + } | ||
| 146 | 168 | ||
| 169 | + $server_model = new ServerConfig(); | ||
| 170 | + $server_info = $server_model->read(['id',$project_info['serve_id']],'init_domain'); | ||
| 171 | + if($server_info === false){ | ||
| 172 | + $this->fail('获取服务器数据失败'); | ||
| 173 | + } | ||
| 147 | 174 | ||
| 175 | + if($this->param['type'] == 2){ | ||
| 176 | + if(empty($this->param['key'])){ | ||
| 177 | + $this->fail('证书KEY值不能为空'); | ||
| 178 | + } | ||
| 179 | + if(empty($this->param['cert'])){ | ||
| 180 | + $this->fail('证书cert值不能为空'); | ||
| 181 | + } | ||
| 148 | 182 | ||
| 183 | +// $api_url = 'http://'.$server_info['init_domain'].'/setSsl'; | ||
| 184 | + $api_url = 'http://master2.globalso.com/api/setSsl'; | ||
| 185 | + $api_param = [ | ||
| 186 | + 'domain' => $info['domain'], | ||
| 187 | + 'private_key' => $this->param['key'], | ||
| 188 | + 'cert' => $this->param['cert'], | ||
| 189 | + ]; | ||
| 190 | + }else{ | ||
| 191 | +// $api_url = 'http://'.$server_info['init_domain'].'/applySsl'; | ||
| 192 | + $api_url = 'http://master2.globalso.com/api/applySsl'; | ||
| 193 | + $api_param = ['domain' => $info['domain']]; | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + try { | ||
| 197 | + $rs = HttpUtils::get($api_url, $api_param); | ||
| 198 | + if(isset($rs['status']) && $rs['status'] == 200){ | ||
| 199 | + return $this->success(); | ||
| 200 | + }else{ | ||
| 201 | + $this->fail($rs['message']??''); | ||
| 202 | + } | ||
| 203 | + } catch (\Exception | GuzzleException $e) { | ||
| 204 | + errorLog('创建站点', $api_param, $e); | ||
| 205 | + $this->fail('编辑证书失败'); | ||
| 206 | + } | ||
| 207 | + } | ||
| 149 | 208 | ||
| 150 | } | 209 | } |
| @@ -7,6 +7,8 @@ use App\Models\Devops\ServerConfig; | @@ -7,6 +7,8 @@ use App\Models\Devops\ServerConfig; | ||
| 7 | use App\Models\Project\ProjectRenew; | 7 | use App\Models\Project\ProjectRenew; |
| 8 | use App\Models\User\ProjectMenu; | 8 | use App\Models\User\ProjectMenu; |
| 9 | use App\Models\User\ProjectRole; | 9 | use App\Models\User\ProjectRole; |
| 10 | +use App\Utils\HttpUtils; | ||
| 11 | +use GuzzleHttp\Exception\GuzzleException; | ||
| 10 | use Illuminate\Support\Arr as SupArr; | 12 | use Illuminate\Support\Arr as SupArr; |
| 11 | use App\Helper\Arr; | 13 | use App\Helper\Arr; |
| 12 | use App\Helper\Common; | 14 | use App\Helper\Common; |
| @@ -109,6 +111,8 @@ class ProjectLogic extends BaseLogic | @@ -109,6 +111,8 @@ class ProjectLogic extends BaseLogic | ||
| 109 | $this->saveProjectDeployOptimize($this->param['deploy_optimize']); | 111 | $this->saveProjectDeployOptimize($this->param['deploy_optimize']); |
| 110 | //保存售后信息 | 112 | //保存售后信息 |
| 111 | $this->saveProjectAfter($this->param['project_after']); | 113 | $this->saveProjectAfter($this->param['project_after']); |
| 114 | + //创建站点 | ||
| 115 | + $this->createSite($this->param); | ||
| 112 | } | 116 | } |
| 113 | DB::commit(); | 117 | DB::commit(); |
| 114 | }catch (\Exception $e){ | 118 | }catch (\Exception $e){ |
| @@ -490,4 +494,30 @@ class ProjectLogic extends BaseLogic | @@ -490,4 +494,30 @@ class ProjectLogic extends BaseLogic | ||
| 490 | return $this->success(); | 494 | return $this->success(); |
| 491 | } | 495 | } |
| 492 | 496 | ||
| 497 | + /** | ||
| 498 | + * 创建站点 | ||
| 499 | + * @param $param | ||
| 500 | + * @author Akun | ||
| 501 | + * @date 2023/10/17 10:04 | ||
| 502 | + */ | ||
| 503 | + public function createSite($param){ | ||
| 504 | + if(isset($param['serve_id']) && $param['serve_id'] && isset($param['deploy_optimize']['domain']) && $param['deploy_optimize']['domain']){ | ||
| 505 | + $server_model = new ServerConfig(); | ||
| 506 | + $server_info = $server_model->read(['id',$param['serve_id']],'init_domain'); | ||
| 507 | + | ||
| 508 | + $domain_model = new DomainInfo(); | ||
| 509 | + $domain_info = $domain_model->read(['id',$param['deploy_optimize']['domain']],'domain'); | ||
| 510 | + | ||
| 511 | + if($server_info && $domain_info){ | ||
| 512 | +// $api_url = 'http://'.$server_info['init_domain'].'/api/createSite'; | ||
| 513 | + $api_url = 'http://master2.globalso.com/api/createSite'; | ||
| 514 | + $api_param = ['domain'=>$domain_info['domain']]; | ||
| 515 | + try { | ||
| 516 | + HttpUtils::get($api_url, $api_param); | ||
| 517 | + } catch (\Exception | GuzzleException $e) { | ||
| 518 | + errorLog('创建站点', $api_param, $e); | ||
| 519 | + } | ||
| 520 | + } | ||
| 521 | + } | ||
| 522 | + } | ||
| 493 | } | 523 | } |
| @@ -214,6 +214,7 @@ Route::middleware(['aloginauth'])->group(function () { | @@ -214,6 +214,7 @@ Route::middleware(['aloginauth'])->group(function () { | ||
| 214 | Route::any('/status', [Aside\Domain\DomainInfoController::class, 'status'])->name('admin.domain_status'); | 214 | Route::any('/status', [Aside\Domain\DomainInfoController::class, 'status'])->name('admin.domain_status'); |
| 215 | Route::any('/getProject', [Aside\Domain\DomainInfoController::class, 'getProject'])->name('admin.domain_getProject'); | 215 | Route::any('/getProject', [Aside\Domain\DomainInfoController::class, 'getProject'])->name('admin.domain_getProject'); |
| 216 | Route::any('/del', [Aside\Domain\DomainInfoController::class, 'del'])->name('admin.domain_del'); | 216 | Route::any('/del', [Aside\Domain\DomainInfoController::class, 'del'])->name('admin.domain_del'); |
| 217 | + Route::any('/setSsl', [Aside\Domain\DomainInfoController::class, 'setSsl'])->name('admin.domain_setSsl'); | ||
| 217 | Route::any('/log', [Aside\Domain\DomainInfoLogController::class, 'lists'])->name('admin.domain_log_lists'); // 日志 | 218 | Route::any('/log', [Aside\Domain\DomainInfoLogController::class, 'lists'])->name('admin.domain_log_lists'); // 日志 |
| 218 | 219 | ||
| 219 | }); | 220 | }); |
-
请 注册 或 登录 后发表评论