作者 lyh

gx

@@ -40,6 +40,10 @@ class DomainInfo extends Command @@ -40,6 +40,10 @@ class DomainInfo extends Command
40 $map = ['status'=>['!=',2]]; 40 $map = ['status'=>['!=',2]];
41 $list = $domainModel->list($map); 41 $list = $domainModel->list($map);
42 foreach ($list as $v){ 42 foreach ($list as $v){
  43 + //域名结束时间<2天时,重新生成
  44 + if($v['certificate_end_time'] > date('Y-m-d H:i:s',time()+ 24*3600)){
  45 + $this->updatePrivate($v);
  46 + }
43 $ssl = $this->updateDomainSsl($v['domain']); 47 $ssl = $this->updateDomainSsl($v['domain']);
44 $time = $this->updateDomain($v['domain']); 48 $time = $this->updateDomain($v['domain']);
45 $data = [ 49 $data = [
@@ -48,12 +52,53 @@ class DomainInfo extends Command @@ -48,12 +52,53 @@ class DomainInfo extends Command
48 'domain_start_time'=>$time['start'], 52 'domain_start_time'=>$time['start'],
49 'domain_end_time'=>$time['end'] 53 'domain_end_time'=>$time['end']
50 ]; 54 ];
  55 +
51 $domainModel->edit($data,['id'=>$v['id']]); 56 $domainModel->edit($data,['id'=>$v['id']]);
52 } 57 }
53 return 1; 58 return 1;
54 } 59 }
55 60
56 /** 61 /**
  62 + * @remark :更新正式
  63 + * @name :updatePrivate
  64 + * @author :lyh
  65 + * @method :post
  66 + * @time :2023/12/8 16:16
  67 + */
  68 + public function updatePrivate($param)
  69 + {
  70 + $key = $param['private_key'];
  71 + $cert = $param['private_cert'];
  72 + if (empty($key) || empty($cert)){
  73 + $url = 'https://' . $v->domain. '/api/applySsl/';
  74 + }else{
  75 + $url = 'https://' . $v->domain. '/api/setSsl/';
  76 + }
  77 +
  78 + $extend_config = json_decode($v->extend_config, true);
  79 + $top_domain = Str::getTopDomain($v->domain);
  80 + if ((empty($extend_config) || empty($extend_config[0]['origin'])) && $v->id != 3) {
  81 + $extend_config = [
  82 + ['origin' => $top_domain, 'target' => $v->domain]
  83 + ];
  84 + }
  85 + $param = [
  86 + 'project_id' => $k,
  87 + 'type' => 1,
  88 + 'route' => 1,
  89 + "domain" =>$v->domain,
  90 + "rewrite"=> $extend_config,
  91 + 'other_domain' => [$top_domain, '*.' . $top_domain],
  92 + 'private_key' => $key,
  93 + 'cert' => $cert
  94 + ];
  95 + $result = app(ToolRepository::class)->curlRequest($url, $param);
  96 + Log::info('domain id: ' . $v->id . ', domain: ' . $v->domain . ', result: ' . var_export($result, true));
  97 + var_dump($result);
  98 +
  99 + }
  100 +
  101 + /**
57 * @remark :更新域名证书 102 * @remark :更新域名证书
58 * @name :updateDomainSsl 103 * @name :updateDomainSsl
59 * @author :lyh 104 * @author :lyh
@@ -38,6 +38,23 @@ class CustomModuleContentController extends BaseController @@ -38,6 +38,23 @@ class CustomModuleContentController extends BaseController
38 } 38 }
39 39
40 /** 40 /**
  41 + * @remark :获取所有分类名称
  42 + * @name :getAllCategoryName
  43 + * @author :lyh
  44 + * @method :post
  45 + * @time :2023/12/8 15:47
  46 + */
  47 + public function getAllCategoryName(){
  48 + $categoryModel = new CustomModuleCategory();
  49 + $list = $categoryModel->list(['status'=>0],'id',['id','name']);
  50 + $data = [];
  51 + foreach ($list as $v){
  52 + $data[$v['id']] = $v['name'];
  53 + }
  54 + return $this->success($data);
  55 + }
  56 +
  57 + /**
41 * @remark :添加/编辑内容时获取分类 58 * @remark :添加/编辑内容时获取分类
42 * @name :getCategoryList 59 * @name :getCategoryList
43 * @author :lyh 60 * @author :lyh
@@ -299,9 +299,9 @@ class CustomModuleCategoryLogic extends BaseLogic @@ -299,9 +299,9 @@ class CustomModuleCategoryLogic extends BaseLogic
299 */ 299 */
300 public function delRoute($id) 300 public function delRoute($id)
301 { 301 {
302 - RouteMap::delRoute(RouteMap::SOURCE_MODULE_CATE.$this->param['module_id'], $id, $this->user['project_id']); 302 + $info = $this->model->read(['id' => $id], ['id', 'route','module_id']);
  303 + RouteMap::delRoute(RouteMap::SOURCE_MODULE_CATE.$info['module_id'], $id, $this->user['project_id']);
303 //通知 304 //通知
304 - $info = $this->model->read(['id' => $id], ['id', 'route']);  
305 $this->curlDelRoute(['route'=>$info['route']]); 305 $this->curlDelRoute(['route'=>$info['route']]);
306 return $this->success(); 306 return $this->success();
307 } 307 }