作者 lyh

gx

@@ -109,7 +109,7 @@ class ComController extends BaseController @@ -109,7 +109,7 @@ class ComController extends BaseController
109 $info = $deployBuild->read(['project_id'=>$this->user['project_id']]); 109 $info = $deployBuild->read(['project_id'=>$this->user['project_id']]);
110 if(!empty($info['configuration'])){ 110 if(!empty($info['configuration'])){
111 $configuration = Arr::s2a($info['configuration']); 111 $configuration = Arr::s2a($info['configuration']);
112 - if(isset($configuration['is_home']) && ($configuration['is_home'] != "0")){ 112 + if(isset($configuration['is_home']) && ((int)$configuration['is_home'] != 0)){
113 return 1; 113 return 1;
114 } 114 }
115 } 115 }
@@ -8,6 +8,7 @@ use App\Exceptions\BsideGlobalException; @@ -8,6 +8,7 @@ use App\Exceptions\BsideGlobalException;
8 use App\Http\Logic\Logic; 8 use App\Http\Logic\Logic;
9 use App\Models\Com\UpdateNotify; 9 use App\Models\Com\UpdateNotify;
10 use App\Models\Project\Project; 10 use App\Models\Project\Project;
  11 +use App\Models\RouteMap\RouteDelete;
11 use Illuminate\Support\Facades\Cache; 12 use Illuminate\Support\Facades\Cache;
12 13
13 /** 14 /**
@@ -159,4 +160,22 @@ class BaseLogic extends Logic @@ -159,4 +160,22 @@ class BaseLogic extends Logic
159 } 160 }
160 return $this->success(); 161 return $this->success();
161 } 162 }
  163 +
  164 + /**
  165 + * @remark :删除和编辑路由时生成一条记录
  166 + * @name :setRouteDeleteSave
  167 + * @author :lyh
  168 + * @method :post
  169 + * @time :2023/9/7 9:38
  170 + */
  171 + public function setRouteDeleteSave($param){
  172 + $routeDeleteModel = new RouteDelete();
  173 + $data = [
  174 + 'project_id'=>$this->user['project_id'],
  175 + 'source'=>$param['source'],
  176 + 'created_at'=>date('Y-m-d H:i:s'),
  177 + 'route'=>$param['route'],
  178 + ];
  179 + return $routeDeleteModel->insert($data);
  180 + }
162 } 181 }
@@ -33,20 +33,19 @@ class ProductLogic extends BaseLogic @@ -33,20 +33,19 @@ class ProductLogic extends BaseLogic
33 * @time :2023/8/21 18:35 33 * @time :2023/8/21 18:35
34 */ 34 */
35 public function productSave(){ 35 public function productSave(){
  36 + //参数处理
36 $this->param = $this->handleSaveParam($this->param); 37 $this->param = $this->handleSaveParam($this->param);
37 DB::beginTransaction(); 38 DB::beginTransaction();
38 try { 39 try {
39 if(isset($this->param['id']) && !empty($this->param['id'])){ 40 if(isset($this->param['id']) && !empty($this->param['id'])){
40 - $id = $this->param['id'];  
41 - $this->model->edit($this->param,['id'=>$this->param['id']]); 41 + $id = $this->editProduct();
42 }else{ 42 }else{
43 - $this->param['project_id'] = $this->user['project_id'];  
44 - $this->param['created_at'] = date('Y-m-d H:i:s');  
45 - $this->param['updated_at'] = $this->param['created_at'];  
46 - $id = $this->model->insertGetId($this->param); 43 + $id = $this->addProduct();
47 } 44 }
48 //路由映射 45 //路由映射
49 $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']); 46 $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
  47 + //更新路由
  48 + $this->model->edit(['route'=>$route],['id'=>$id]);
50 DB::commit(); 49 DB::commit();
51 }catch (\Exception $e){ 50 }catch (\Exception $e){
52 DB::rollBack(); 51 DB::rollBack();
@@ -58,6 +57,43 @@ class ProductLogic extends BaseLogic @@ -58,6 +57,43 @@ class ProductLogic extends BaseLogic
58 } 57 }
59 58
60 /** 59 /**
  60 + * @remark :新增产品
  61 + * @name :addProduct
  62 + * @author :lyh
  63 + * @method :post
  64 + * @time :2023/9/7 10:01
  65 + */
  66 + public function addProduct(){
  67 + $this->param['project_id'] = $this->user['project_id'];
  68 + $this->param['created_at'] = date('Y-m-d H:i:s');
  69 + $this->param['updated_at'] = $this->param['created_at'];
  70 + $id = $this->model->addReturnId($this->param);
  71 + return $id;
  72 + }
  73 +
  74 + /**
  75 + * @remark :编辑产品
  76 + * @name :editProduct
  77 + * @author :lyh
  78 + * @method :post
  79 + * @time :2023/9/7 10:02
  80 + */
  81 + public function editProduct(){
  82 + $info = $this->model->read(['id'=>$this->param['id']]);
  83 + if($info['route'] != $this->param['route']){
  84 + //生成一条删除路由记录
  85 + $data = [
  86 + 'source'=>RouteMap::SOURCE_PRODUCT,
  87 + 'route'=>$info['route'],
  88 + ];
  89 + $this->setRouteDeleteSave($data);
  90 + }
  91 + $id = $this->param['id'];
  92 + $this->model->edit($this->param,['id'=>$this->param['id']]);
  93 + return $id;
  94 + }
  95 +
  96 + /**
61 * @remark :不使用save处理参数 97 * @remark :不使用save处理参数
62 * @name :handleSaveParam 98 * @name :handleSaveParam
63 * @author :lyh 99 * @author :lyh
@@ -91,6 +127,7 @@ class ProductLogic extends BaseLogic @@ -91,6 +127,7 @@ class ProductLogic extends BaseLogic
91 return $param; 127 return $param;
92 } 128 }
93 129
  130 +
94 /** 131 /**
95 * @remark :删除数据 132 * @remark :删除数据
96 * @name :delete 133 * @name :delete
@@ -106,6 +143,12 @@ class ProductLogic extends BaseLogic @@ -106,6 +143,12 @@ class ProductLogic extends BaseLogic
106 if($info['status'] == Product::STATUS_RECYCLE){ 143 if($info['status'] == Product::STATUS_RECYCLE){
107 //删除路由映射 144 //删除路由映射
108 RouteMap::delRoute(RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']); 145 RouteMap::delRoute(RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']);
  146 + //生成一条删除路由记录
  147 + $data = [
  148 + 'source'=>RouteMap::SOURCE_PRODUCT,
  149 + 'route'=>$info['route'],
  150 + ];
  151 + $this->setRouteDeleteSave($data);
109 //删除当前产品模版 152 //删除当前产品模版
110 $this->delProductModule($id); 153 $this->delProductModule($id);
111 $this->model->del(['id'=>$id]); 154 $this->model->del(['id'=>$id]);
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :RouteDelete.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2023/9/7 9:35
  8 + */
  9 +
  10 +namespace App\Models\RouteMap;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class RouteDelete extends Base
  15 +{
  16 + //设置关联表名
  17 + protected $table = 'gl_route_map';
  18 + //连接数据库
  19 + protected $connection = 'custom_mysql';
  20 +}
@@ -48,7 +48,6 @@ class RouteMap extends Base @@ -48,7 +48,6 @@ class RouteMap extends Base
48 if(preg_match('/[\x{4e00}-\x{9fa5}]/u', $title)){ 48 if(preg_match('/[\x{4e00}-\x{9fa5}]/u', $title)){
49 $title = Translate::tran($title, 'en'); 49 $title = Translate::tran($title, 'en');
50 } 50 }
51 -  
52 $i=1; 51 $i=1;
53 $sign = generateRoute($title); 52 $sign = generateRoute($title);
54 $route = $sign; 53 $route = $sign;
@@ -77,14 +76,14 @@ class RouteMap extends Base @@ -77,14 +76,14 @@ class RouteMap extends Base
77 $where = [ 76 $where = [
78 'project_id' => $project_id, 77 'project_id' => $project_id,
79 'route' => $route, 78 'route' => $route,
80 -// 'source' => $source 79 + 'source' => $source
81 ]; 80 ];
82 - if($source == self::SOURCE_BLOG_CATE){  
83 - $where['path'] = self::PATH_BLOG_CATE;  
84 - }  
85 - if($source == self::SOURCE_NEWS_CATE){  
86 - $where['path'] = self::PATH_NEWS_CATE;  
87 - } 81 +// if($source == self::SOURCE_BLOG_CATE){
  82 +// $where['path'] = self::PATH_BLOG_CATE;
  83 +// }
  84 +// if($source == self::SOURCE_NEWS_CATE){
  85 +// $where['path'] = self::PATH_NEWS_CATE;
  86 +// }
88 $route = self::where($where)->first(); 87 $route = self::where($where)->first();
89 if($route){ 88 if($route){
90 if($route->source_id == $source_id){ 89 if($route->source_id == $source_id){
@@ -117,12 +116,6 @@ class RouteMap extends Base @@ -117,12 +116,6 @@ class RouteMap extends Base
117 $route_map->source = $source; 116 $route_map->source = $source;
118 $route_map->source_id = $source_id; 117 $route_map->source_id = $source_id;
119 $route_map->project_id = $project_id; 118 $route_map->project_id = $project_id;
120 - if($source == self::SOURCE_BLOG_CATE){  
121 - $route_map->path = self::PATH_BLOG_CATE;  
122 - }  
123 - if($source == self::SOURCE_NEWS_CATE){  
124 - $route_map->path = self::PATH_NEWS_CATE;  
125 - }  
126 } 119 }
127 $route_map->route = $route; 120 $route_map->route = $route;
128 $route_map->save(); 121 $route_map->save();