正在显示
8 个修改的文件
包含
61 行增加
和
34 行删除
| @@ -33,7 +33,8 @@ class BlogCategoryLogic extends BaseLogic | @@ -33,7 +33,8 @@ class BlogCategoryLogic extends BaseLogic | ||
| 33 | try { | 33 | try { |
| 34 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 34 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 35 | //查看路由是否更新 | 35 | //查看路由是否更新 |
| 36 | - $id = $this->editCategoryRoute($this->param['id'], $this->param['alias']); | 36 | + $id = $this->param['id']; |
| 37 | + $this->editCategoryRoute($this->param['id'], $this->param['alias']); | ||
| 37 | $this->editHandleCategory($this->param['id'],$this->param['pid']); | 38 | $this->editHandleCategory($this->param['id'],$this->param['pid']); |
| 38 | $this->param['operator_id'] = $this->user['id']; | 39 | $this->param['operator_id'] = $this->user['id']; |
| 39 | $this->edit($this->param,['id'=>$this->param['id']]); | 40 | $this->edit($this->param,['id'=>$this->param['id']]); |
| @@ -119,7 +120,7 @@ class BlogCategoryLogic extends BaseLogic | @@ -119,7 +120,7 @@ class BlogCategoryLogic extends BaseLogic | ||
| 119 | ]; | 120 | ]; |
| 120 | $this->setRouteDeleteSave($data); | 121 | $this->setRouteDeleteSave($data); |
| 121 | } | 122 | } |
| 122 | - return $this->success($id); | 123 | + return true; |
| 123 | } | 124 | } |
| 124 | 125 | ||
| 125 | /** | 126 | /** |
| @@ -35,7 +35,8 @@ class BlogLogic extends BaseLogic | @@ -35,7 +35,8 @@ class BlogLogic extends BaseLogic | ||
| 35 | $this->param = $this->paramProcessing($this->param); | 35 | $this->param = $this->paramProcessing($this->param); |
| 36 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 36 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 37 | //是否更新路由 | 37 | //是否更新路由 |
| 38 | - $id = $this->editNewsRoute($this->param['id'],$this->param['url']); | 38 | + $id = $this->param['id']; |
| 39 | + $this->editNewsRoute($this->param['id'],$this->param['url']); | ||
| 39 | $this->edit($this->param,['id'=>$this->param['id']]); | 40 | $this->edit($this->param,['id'=>$this->param['id']]); |
| 40 | }else{ | 41 | }else{ |
| 41 | $id = $this->model->addReturnId($this->param); | 42 | $id = $this->model->addReturnId($this->param); |
| @@ -69,7 +70,7 @@ class BlogLogic extends BaseLogic | @@ -69,7 +70,7 @@ class BlogLogic extends BaseLogic | ||
| 69 | ]; | 70 | ]; |
| 70 | $this->setRouteDeleteSave($data); | 71 | $this->setRouteDeleteSave($data); |
| 71 | } | 72 | } |
| 72 | - return $id; | 73 | + return true; |
| 73 | } | 74 | } |
| 74 | 75 | ||
| 75 | /** | 76 | /** |
| @@ -46,7 +46,8 @@ class NewsCategoryLogic extends BaseLogic | @@ -46,7 +46,8 @@ class NewsCategoryLogic extends BaseLogic | ||
| 46 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 46 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 47 | $this->param['operator_id'] = $this->user['id']; | 47 | $this->param['operator_id'] = $this->user['id']; |
| 48 | //查看路由是否更新 | 48 | //查看路由是否更新 |
| 49 | - $id = $this->editCategoryRoute($this->param['id'],$this->param['alias']); | 49 | + $id = $this->param['id']; |
| 50 | + $this->editCategoryRoute($this->param['id'],$this->param['alias']); | ||
| 50 | $this->editHandleCategory($this->param['id'],$this->param['pid']); | 51 | $this->editHandleCategory($this->param['id'],$this->param['pid']); |
| 51 | $this->edit($this->param,['id'=>$this->param['id']]); | 52 | $this->edit($this->param,['id'=>$this->param['id']]); |
| 52 | }else{ | 53 | }else{ |
| @@ -129,7 +130,7 @@ class NewsCategoryLogic extends BaseLogic | @@ -129,7 +130,7 @@ class NewsCategoryLogic extends BaseLogic | ||
| 129 | ]; | 130 | ]; |
| 130 | $this->setRouteDeleteSave($data); | 131 | $this->setRouteDeleteSave($data); |
| 131 | } | 132 | } |
| 132 | - return $id; | 133 | + return true; |
| 133 | } | 134 | } |
| 134 | 135 | ||
| 135 | 136 |
| @@ -64,7 +64,8 @@ class NewsLogic extends BaseLogic | @@ -64,7 +64,8 @@ class NewsLogic extends BaseLogic | ||
| 64 | $this->param = $this->paramProcessing($this->param); | 64 | $this->param = $this->paramProcessing($this->param); |
| 65 | if (isset($this->param['id']) && !empty($this->param['id'])) { | 65 | if (isset($this->param['id']) && !empty($this->param['id'])) { |
| 66 | //是否更新路由 | 66 | //是否更新路由 |
| 67 | - $id = $this->editNewsRoute($this->param['id'], $this->param['url']); | 67 | + $this->editNewsRoute($this->param['id'], $this->param['url']); |
| 68 | + $id = $this->param['id']; | ||
| 68 | $this->edit($this->param, ['id' => $this->param['id']]); | 69 | $this->edit($this->param, ['id' => $this->param['id']]); |
| 69 | } else { | 70 | } else { |
| 70 | $id = $this->model->addReturnId($this->param); | 71 | $id = $this->model->addReturnId($this->param); |
| @@ -100,7 +101,7 @@ class NewsLogic extends BaseLogic | @@ -100,7 +101,7 @@ class NewsLogic extends BaseLogic | ||
| 100 | ]; | 101 | ]; |
| 101 | $this->setRouteDeleteSave($data); | 102 | $this->setRouteDeleteSave($data); |
| 102 | } | 103 | } |
| 103 | - return $id; | 104 | + return true; |
| 104 | } | 105 | } |
| 105 | 106 | ||
| 106 | 107 |
| @@ -115,6 +115,7 @@ class CategoryLogic extends BaseLogic | @@ -115,6 +115,7 @@ class CategoryLogic extends BaseLogic | ||
| 115 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 115 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 116 | //是否编辑路由 | 116 | //是否编辑路由 |
| 117 | $id = $this->editCategoryRoute($this->param['id'],$this->param['route']); | 117 | $id = $this->editCategoryRoute($this->param['id'],$this->param['route']); |
| 118 | + //处理子集 | ||
| 118 | $this->editHandleCategory($this->param['id'],$this->param['pid']); | 119 | $this->editHandleCategory($this->param['id'],$this->param['pid']); |
| 119 | $this->model->edit($this->param,['id'=>$this->param['id']]); | 120 | $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 120 | }else{ | 121 | }else{ |
| @@ -47,13 +47,15 @@ class ProductLogic extends BaseLogic | @@ -47,13 +47,15 @@ class ProductLogic extends BaseLogic | ||
| 47 | DB::connection('custom_mysql')->beginTransaction(); | 47 | DB::connection('custom_mysql')->beginTransaction(); |
| 48 | try { | 48 | try { |
| 49 | if(isset($this->param['id']) && !empty($this->param['id'])){ | 49 | if(isset($this->param['id']) && !empty($this->param['id'])){ |
| 50 | + $id = $this->param['id']; | ||
| 50 | //查看路由是否更新 | 51 | //查看路由是否更新 |
| 51 | - $id = $this->editProductRoute($this->param['id'],$this->param['route']); | 52 | + $this->param['route'] = $this->editProductRoute($this->param['route']); |
| 52 | $this->model->edit($this->param,['id'=>$this->param['id']]); | 53 | $this->model->edit($this->param,['id'=>$this->param['id']]); |
| 53 | }else{ | 54 | }else{ |
| 54 | $this->param['project_id'] = $this->user['project_id']; | 55 | $this->param['project_id'] = $this->user['project_id']; |
| 55 | $this->param['created_at'] = date('Y-m-d H:i:s'); | 56 | $this->param['created_at'] = date('Y-m-d H:i:s'); |
| 56 | $this->param['updated_at'] = $this->param['created_at']; | 57 | $this->param['updated_at'] = $this->param['created_at']; |
| 58 | + $this->param['route'] = $this->param['route'].'-'.RouteMap::SOURCE_PRODUCT; | ||
| 57 | $id = $this->model->addReturnId($this->param); | 59 | $id = $this->model->addReturnId($this->param); |
| 58 | } | 60 | } |
| 59 | $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']); | 61 | $route = RouteMap::setRoute($this->param['route'], RouteMap::SOURCE_PRODUCT, $id, $this->user['project_id']); |
| @@ -204,7 +206,7 @@ class ProductLogic extends BaseLogic | @@ -204,7 +206,7 @@ class ProductLogic extends BaseLogic | ||
| 204 | * @method :post | 206 | * @method :post |
| 205 | * @time :2023/9/7 10:02 | 207 | * @time :2023/9/7 10:02 |
| 206 | */ | 208 | */ |
| 207 | - public function editProductRoute($id,$route){ | 209 | + public function editProductRoute($route){ |
| 208 | $info = $this->model->read(['id'=>$this->param['id']]); | 210 | $info = $this->model->read(['id'=>$this->param['id']]); |
| 209 | if($info['route'] != $route){ | 211 | if($info['route'] != $route){ |
| 210 | //生成一条删除路由记录 | 212 | //生成一条删除路由记录 |
| @@ -213,8 +215,12 @@ class ProductLogic extends BaseLogic | @@ -213,8 +215,12 @@ class ProductLogic extends BaseLogic | ||
| 213 | 'route'=>$route, | 215 | 'route'=>$route, |
| 214 | ]; | 216 | ]; |
| 215 | $this->setRouteDeleteSave($data); | 217 | $this->setRouteDeleteSave($data); |
| 218 | + //"字符串以\"-product\"结尾" | ||
| 219 | + if (!endsWith($route, "-product")) { | ||
| 220 | + $route = $route."-product"; | ||
| 221 | + } | ||
| 216 | } | 222 | } |
| 217 | - return $id; | 223 | + return $route; |
| 218 | } | 224 | } |
| 219 | 225 | ||
| 220 | /** | 226 | /** |
| @@ -431,23 +437,27 @@ class ProductLogic extends BaseLogic | @@ -431,23 +437,27 @@ class ProductLogic extends BaseLogic | ||
| 431 | * @time :2023/8/15 17:53 | 437 | * @time :2023/8/15 17:53 |
| 432 | */ | 438 | */ |
| 433 | public function batchSetCategory(){ | 439 | public function batchSetCategory(){ |
| 434 | - DB::connection('custom_mysql')->beginTransaction(); | ||
| 435 | - try { | ||
| 436 | - //批量 | ||
| 437 | - $param = [ | ||
| 438 | - 'category_id'=>','.Arr::arrToSet($this->param['category_id']).',', | ||
| 439 | - 'status'=>$this->param['status'] | ||
| 440 | - ]; | ||
| 441 | - $this->model->edit($param,['id'=>['in',$this->param['id']]]); | ||
| 442 | - //分类关联 | ||
| 443 | - foreach ($this->param['id'] as $id){ | ||
| 444 | - CategoryRelated::saveRelated($id, $this->param['category_id']); | ||
| 445 | - } | ||
| 446 | - DB::connection('custom_mysql')->commit(); | ||
| 447 | - //对应添加关联表 | ||
| 448 | - }catch (\Exception $e){ | ||
| 449 | - DB::connection('custom_mysql')->rollBack(); | ||
| 450 | - $this->fail('系统错误,请联系管理员'); | 440 | + if(isset($this->param['category_id']) && !empty($this->param['category_id'])) { |
| 441 | + DB::connection('custom_mysql')->beginTransaction(); | ||
| 442 | + $category_ids = $this->getLastCategoryArr($this->param['category_id']); | ||
| 443 | + $this->param['category_id'] = ','.implode(',',$category_ids).','; | ||
| 444 | + try { | ||
| 445 | + //批量 | ||
| 446 | + $param = [ | ||
| 447 | + 'category_id'=>$this->param['category_id'], | ||
| 448 | + 'status'=>$this->param['status'] | ||
| 449 | + ]; | ||
| 450 | + $this->model->edit($param,['id'=>['in',$this->param['id']]]); | ||
| 451 | + //分类关联 | ||
| 452 | + foreach ($this->param['id'] as $id){ | ||
| 453 | + CategoryRelated::saveRelated($id, $category_ids); | ||
| 454 | + } | ||
| 455 | + DB::connection('custom_mysql')->commit(); | ||
| 456 | + //对应添加关联表 | ||
| 457 | + }catch (\Exception $e){ | ||
| 458 | + DB::connection('custom_mysql')->rollBack(); | ||
| 459 | + $this->fail('系统错误,请联系管理员'); | ||
| 460 | + } | ||
| 451 | } | 461 | } |
| 452 | return $this->success(); | 462 | return $this->success(); |
| 453 | } | 463 | } |
| @@ -34,12 +34,15 @@ class CategoryRelated extends Base | @@ -34,12 +34,15 @@ class CategoryRelated extends Base | ||
| 34 | self::where('product_id', $product_id)->delete(); | 34 | self::where('product_id', $product_id)->delete(); |
| 35 | //批量保存 | 35 | //批量保存 |
| 36 | $data = []; | 36 | $data = []; |
| 37 | - foreach ($cate_ids as $cate_id){ | ||
| 38 | - $data[] = [ | ||
| 39 | - 'product_id' => $product_id, | ||
| 40 | - 'cate_id' => $cate_id | ||
| 41 | - ]; | 37 | + if(!empty($cate_ids)){ |
| 38 | + foreach ($cate_ids as $cate_id){ | ||
| 39 | + $data[] = [ | ||
| 40 | + 'product_id' => $product_id, | ||
| 41 | + 'cate_id' => $cate_id | ||
| 42 | + ]; | ||
| 43 | + } | ||
| 44 | + self::insert($data); | ||
| 42 | } | 45 | } |
| 43 | - self::insert($data); | 46 | + return true; |
| 44 | } | 47 | } |
| 45 | } | 48 | } |
| @@ -109,6 +109,15 @@ class RouteMap extends Base | @@ -109,6 +109,15 @@ class RouteMap extends Base | ||
| 109 | if(!$route_map){ | 109 | if(!$route_map){ |
| 110 | $route_map = new self(); | 110 | $route_map = new self(); |
| 111 | $route_map->source = $source; | 111 | $route_map->source = $source; |
| 112 | + if($source == self::SOURCE_NEWS){ | ||
| 113 | + $route_map->path = self::SOURCE_NEWS; | ||
| 114 | + }elseif($source == self::SOURCE_NEWS_CATE){ | ||
| 115 | + $route_map->path = self::PATH_NEWS_CATE; | ||
| 116 | + }elseif ($source == self::SOURCE_BLOG){ | ||
| 117 | + $route_map->path = self::SOURCE_BLOG; | ||
| 118 | + }elseif ($source == self::SOURCE_BLOG_CATE){ | ||
| 119 | + $route_map->path = self::PATH_BLOG_CATE; | ||
| 120 | + } | ||
| 112 | $route_map->source_id = $source_id; | 121 | $route_map->source_id = $source_id; |
| 113 | $route_map->project_id = $project_id; | 122 | $route_map->project_id = $project_id; |
| 114 | } | 123 | } |
-
请 注册 或 登录 后发表评论