作者 lyh

gx

@@ -196,11 +196,15 @@ class DomainInfoController extends BaseController @@ -196,11 +196,15 @@ class DomainInfoController extends BaseController
196 $this->request->validate([ 196 $this->request->validate([
197 'id'=>'required', 197 'id'=>'required',
198 'type' => 'required', 198 'type' => 'required',
  199 + 'other_domain'=>'required',
  200 + 'extend_config'=>'required'
199 ],[ 201 ],[
200 'id.required' => 'id不能为空', 202 'id.required' => 'id不能为空',
201 'type.required' => '类型不能为空', 203 'type.required' => '类型不能为空',
  204 + 'other_domain.required' => '其他域名不能为空',
  205 + 'extend_config.required' => '301配置不能为空',
202 ]); 206 ]);
203 - $domainInfoLogic->setDomainSsl(); 207 + $domainInfoLogic->sslSave();
204 $this->response('success'); 208 $this->response('success');
205 } 209 }
206 } 210 }
@@ -153,25 +153,8 @@ class DomainInfoLogic extends BaseLogic @@ -153,25 +153,8 @@ class DomainInfoLogic extends BaseLogic
153 * @author Akun 153 * @author Akun
154 * @date 2023/10/17 11:52 154 * @date 2023/10/17 11:52
155 */ 155 */
156 - public function setDomainSsl() 156 + public function setDomainSsl($initDomain,$domain,$rewrite,$other_domain)
157 { 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 - }  
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 - }  
174 -  
175 if($this->param['type'] == 2){ 158 if($this->param['type'] == 2){
176 if(empty($this->param['key'])){ 159 if(empty($this->param['key'])){
177 $this->fail('证书KEY值不能为空'); 160 $this->fail('证书KEY值不能为空');
@@ -179,18 +162,18 @@ class DomainInfoLogic extends BaseLogic @@ -179,18 +162,18 @@ class DomainInfoLogic extends BaseLogic
179 if(empty($this->param['cert'])){ 162 if(empty($this->param['cert'])){
180 $this->fail('证书cert值不能为空'); 163 $this->fail('证书cert值不能为空');
181 } 164 }
182 -  
183 - $api_url = 'http://'.$server_info['init_domain'].'/api/setSsl'; 165 + $api_url = 'http://'.$initDomain.'/api/setSsl';
184 $api_param = [ 166 $api_param = [
185 - 'domain' => $info['domain'], 167 + 'domain' => $domain,
186 'private_key' => $this->param['key'], 168 'private_key' => $this->param['key'],
187 'cert' => $this->param['cert'], 169 'cert' => $this->param['cert'],
  170 + 'rewrite'=>$rewrite,
  171 + 'other_domain'=>$other_domain
188 ]; 172 ];
189 }else{ 173 }else{
190 - $api_url = 'http://'.$server_info['init_domain'].'/api/applySsl';  
191 - $api_param = ['domain' => $info['domain']]; 174 + $api_url = 'http://'.$initDomain.'/api/applySsl';
  175 + $api_param = ['domain' => $domain,'rewrite'=>$rewrite,'other_domain'=>$other_domain];
192 } 176 }
193 -  
194 try { 177 try {
195 $rs = HttpUtils::get($api_url, $api_param); 178 $rs = HttpUtils::get($api_url, $api_param);
196 $rs = json_decode($rs, true); 179 $rs = json_decode($rs, true);
@@ -203,6 +186,41 @@ class DomainInfoLogic extends BaseLogic @@ -203,6 +186,41 @@ class DomainInfoLogic extends BaseLogic
203 errorLog('创建站点', $api_param, $e); 186 errorLog('创建站点', $api_param, $e);
204 $this->fail('编辑证书失败'); 187 $this->fail('编辑证书失败');
205 } 188 }
  189 + return $this->success();
  190 + }
  191 +
  192 + /**
  193 + * @remark :保存证书相关配置
  194 + * @name :sslSave
  195 + * @author :lyh
  196 + * @method :post
  197 + * @time :2023/11/6 10:50
  198 + */
  199 + public function sslSave(){
  200 + $info = $this->model->read(['id'=>$this->param['id']]);
  201 + if($info === false){
  202 + $this->fail('当前数据不存在或者已被删除');
  203 + }
  204 + //获取项目数据
  205 + $project_model = new Project();
  206 + $project_info = $project_model->read(['id'=>$info['project_id']],'serve_id');
  207 + if($project_info === false){
  208 + $this->fail('获取项目数据失败');
  209 + }
  210 + $server_model = new ServerConfig();
  211 + $server_info = $server_model->read(['id'=>$project_info['serve_id']],'init_domain');
  212 + if($server_info === false){
  213 + $this->fail('获取服务器数据失败');
  214 + }
  215 + //保存301跳转数据+其他域名
  216 + $data = [
  217 + 'other_domain'=>json_encode($this->param['other_domain']),
  218 + 'extend_config'=>json_encode($this->param['extend_config']),
  219 + ];
  220 + $this->model->edit($data,['id'=>$this->param['id']]);
  221 + //生成证书
  222 + $this->setDomainSsl($server_info['init_domain'],$info['domain'],$this->param['extend_config'],$this->param['other_domain']);
  223 + return $this->success();
206 } 224 }
207 225
208 } 226 }
@@ -13,5 +13,5 @@ use App\Models\Base; @@ -13,5 +13,5 @@ use App\Models\Base;
13 13
14 class CustomModule extends Base 14 class CustomModule extends Base
15 { 15 {
16 - protected $table = ''; 16 + protected $table = 'gl_custom_module';
17 } 17 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :CustomModuleCategory.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/11/6 10:04
  8 + */
  9 +
  10 +namespace App\Models\CustomModule;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class CustomModuleCategory extends Base
  15 +{
  16 + protected $table = 'gl_custom_module_category';
  17 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :CustomModuleContent.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/11/6 10:04
  8 + */
  9 +
  10 +namespace App\Models\CustomModule;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class CustomModuleContent extends Base
  15 +{
  16 + protected $table = 'gl_custom_module_content';
  17 +}
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :CustomModuleLabel.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/11/6 10:05
  8 + */
  9 +
  10 +namespace App\Models\CustomModule;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class CustomModuleLabel extends Base
  15 +{
  16 + protected $table = 'gl_custom_module_label';
  17 +}