正在显示
1 个修改的文件
包含
53 行增加
和
50 行删除
| @@ -60,9 +60,20 @@ class RouteMap extends Base | @@ -60,9 +60,20 @@ class RouteMap extends Base | ||
| 60 | } | 60 | } |
| 61 | $i=1; | 61 | $i=1; |
| 62 | $sign = generateRoute($title); | 62 | $sign = generateRoute($title); |
| 63 | - $route = $sign; | ||
| 64 | - while(self::isExist($route, $source, $source_id, $project_id)){ | ||
| 65 | - $route = $sign .'-'.$i; | 63 | + $info = self::where(['project_id' => $project_id, 'source' => $source, 'source_id'=>$source_id])->first(); |
| 64 | + if($info === false){ | ||
| 65 | + if($source == self::SOURCE_PRODUCT_KEYWORD){ | ||
| 66 | + $suffix = '-tag'; | ||
| 67 | + } | ||
| 68 | + if($source == self::SOURCE_PRODUCT){ | ||
| 69 | + $suffix = '-product'; | ||
| 70 | + } | ||
| 71 | + }else{ | ||
| 72 | + $suffix = ''; | ||
| 73 | + } | ||
| 74 | + $route = $sign.$suffix; | ||
| 75 | + while(self::isExist($route, $source_id, $project_id)){ | ||
| 76 | + $route = $sign .'-'.$i.$suffix; | ||
| 66 | $i++; | 77 | $i++; |
| 67 | } | 78 | } |
| 68 | return $route; | 79 | return $route; |
| @@ -78,14 +89,13 @@ class RouteMap extends Base | @@ -78,14 +89,13 @@ class RouteMap extends Base | ||
| 78 | * @author zbj | 89 | * @author zbj |
| 79 | * @date 2023/4/17 | 90 | * @date 2023/4/17 |
| 80 | */ | 91 | */ |
| 81 | - protected static function isExist($route, $source, $source_id, $project_id){ | 92 | + protected static function isExist($route, $source_id, $project_id){ |
| 82 | $fixed = ['search','api']; //固定的路由 | 93 | $fixed = ['search','api']; //固定的路由 |
| 83 | if(in_array($route, $fixed)){ | 94 | if(in_array($route, $fixed)){ |
| 84 | return true; | 95 | return true; |
| 85 | } | 96 | } |
| 86 | $where = [ | 97 | $where = [ |
| 87 | - 'project_id' => $project_id, | ||
| 88 | - 'route' => $route, | 98 | + 'project_id' => $project_id, 'route' => $route, |
| 89 | ]; | 99 | ]; |
| 90 | $route = self::where($where)->first(); | 100 | $route = self::where($where)->first(); |
| 91 | if($route){ | 101 | if($route){ |
| @@ -119,13 +129,6 @@ class RouteMap extends Base | @@ -119,13 +129,6 @@ class RouteMap extends Base | ||
| 119 | $route_map->source = $source; | 129 | $route_map->source = $source; |
| 120 | $route_map->source_id = $source_id; | 130 | $route_map->source_id = $source_id; |
| 121 | $route_map->project_id = $project_id; | 131 | $route_map->project_id = $project_id; |
| 122 | - if ($source == self::SOURCE_PRODUCT_KEYWORD){ | ||
| 123 | - $route = self::setKeywordRoute($route); | ||
| 124 | - //查看当前路由是否存在 | ||
| 125 | - }elseif ($source == self::SOURCE_PRODUCT){ | ||
| 126 | - //产品单独处理路由 | ||
| 127 | - $route = self::setProductRoute($route); | ||
| 128 | - } | ||
| 129 | } | 132 | } |
| 130 | if($source == self::SOURCE_NEWS){ | 133 | if($source == self::SOURCE_NEWS){ |
| 131 | $route_map->path = self::SOURCE_NEWS; | 134 | $route_map->path = self::SOURCE_NEWS; |
| @@ -141,43 +144,43 @@ class RouteMap extends Base | @@ -141,43 +144,43 @@ class RouteMap extends Base | ||
| 141 | } | 144 | } |
| 142 | 145 | ||
| 143 | 146 | ||
| 144 | - /** | ||
| 145 | - * @remark :产品新增单独处理路由 | ||
| 146 | - * @name :setProductRoute | ||
| 147 | - * @author :lyh | ||
| 148 | - * @method :post | ||
| 149 | - * @time :2023/11/21 18:48 | ||
| 150 | - */ | ||
| 151 | - public static function setProductRoute($route,$i = 0){ | ||
| 152 | - $routes = $route.'-'.$i.'-product'; | ||
| 153 | - $routeMapModel = new RouteMap(); | ||
| 154 | - $routeInfo = $routeMapModel->read(['route'=>$routes]); | ||
| 155 | - if($routeInfo === false){ | ||
| 156 | - return $routes; | ||
| 157 | - }else{ | ||
| 158 | - $i = $i + 1; | ||
| 159 | - return self::setProductRoute($route,$i); | ||
| 160 | - } | ||
| 161 | - } | ||
| 162 | - | ||
| 163 | - /** | ||
| 164 | - * @remark :关键字新增单独处理路由 | ||
| 165 | - * @name :setProductRoute | ||
| 166 | - * @author :lyh | ||
| 167 | - * @method :post | ||
| 168 | - * @time :2023/11/21 18:48 | ||
| 169 | - */ | ||
| 170 | - public static function setKeywordRoute($route,$i = 0){ | ||
| 171 | - $routes = $route.'-'.$i.'-tag'; | ||
| 172 | - $routeMapModel = new RouteMap(); | ||
| 173 | - $routeInfo = $routeMapModel->read(['route'=>$routes]); | ||
| 174 | - if($routeInfo === false){ | ||
| 175 | - return $routes; | ||
| 176 | - }else{ | ||
| 177 | - $i = $i + 1; | ||
| 178 | - return self::setProductRoute($route,$i); | ||
| 179 | - } | ||
| 180 | - } | 147 | +// /** |
| 148 | +// * @remark :产品新增单独处理路由 | ||
| 149 | +// * @name :setProductRoute | ||
| 150 | +// * @author :lyh | ||
| 151 | +// * @method :post | ||
| 152 | +// * @time :2023/11/21 18:48 | ||
| 153 | +// */ | ||
| 154 | +// public static function setProductRoute($route,$i = 0){ | ||
| 155 | +// $routes = $route.'-'.$i.'-product'; | ||
| 156 | +// $routeMapModel = new RouteMap(); | ||
| 157 | +// $routeInfo = $routeMapModel->read(['route'=>$routes]); | ||
| 158 | +// if($routeInfo === false){ | ||
| 159 | +// return $routes; | ||
| 160 | +// }else{ | ||
| 161 | +// $i = $i + 1; | ||
| 162 | +// return self::setProductRoute($route,$i); | ||
| 163 | +// } | ||
| 164 | +// } | ||
| 165 | +// | ||
| 166 | +// /** | ||
| 167 | +// * @remark :关键字新增单独处理路由 | ||
| 168 | +// * @name :setProductRoute | ||
| 169 | +// * @author :lyh | ||
| 170 | +// * @method :post | ||
| 171 | +// * @time :2023/11/21 18:48 | ||
| 172 | +// */ | ||
| 173 | +// public static function setKeywordRoute($route,$i = 0){ | ||
| 174 | +// $routes = $route.'-'.$i.'-tag'; | ||
| 175 | +// $routeMapModel = new RouteMap(); | ||
| 176 | +// $routeInfo = $routeMapModel->read(['route'=>$routes]); | ||
| 177 | +// if($routeInfo === false){ | ||
| 178 | +// return $routes; | ||
| 179 | +// }else{ | ||
| 180 | +// $i = $i + 1; | ||
| 181 | +// return self::setKeywordRoute($route,$i); | ||
| 182 | +// } | ||
| 183 | +// } | ||
| 181 | 184 | ||
| 182 | /** | 185 | /** |
| 183 | * @param $route | 186 | * @param $route |
-
请 注册 或 登录 后发表评论