作者 lyh

gx

@@ -28,12 +28,12 @@ class BlogCategoryLogic extends BaseLogic @@ -28,12 +28,12 @@ class BlogCategoryLogic extends BaseLogic
28 public function categorySave(){ 28 public function categorySave(){
29 //验证名称是否存在 29 //验证名称是否存在
30 $this->verifyParamName($this->param['name']); 30 $this->verifyParamName($this->param['name']);
31 -// DB::beginTransaction();  
32 -// try { 31 + DB::beginTransaction();
  32 + try {
33 if(isset($this->param['id']) && !empty($this->param['id'])){ 33 if(isset($this->param['id']) && !empty($this->param['id'])){
34 //查看路由是否更新 34 //查看路由是否更新
35 $id = $this->editCategoryRoute($this->param['id'], $this->param['alias']); 35 $id = $this->editCategoryRoute($this->param['id'], $this->param['alias']);
36 -// $this->editHandleCategory($this->param['id'],$this->param['pid']); 36 + $this->editHandleCategory($this->param['id'],$this->param['pid']);
37 $this->param['operator_id'] = $this->user['id']; 37 $this->param['operator_id'] = $this->user['id'];
38 $this->edit($this->param,['id'=>$this->param['id']]); 38 $this->edit($this->param,['id'=>$this->param['id']]);
39 }else{ 39 }else{
@@ -46,11 +46,11 @@ class BlogCategoryLogic extends BaseLogic @@ -46,11 +46,11 @@ class BlogCategoryLogic extends BaseLogic
46 $route = RouteMap::setRoute(isset($this->param['alias']) ? $this->param['alias'] : $this->param['name'], 46 $route = RouteMap::setRoute(isset($this->param['alias']) ? $this->param['alias'] : $this->param['name'],
47 RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']); 47 RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']);
48 $this->edit(['alias'=>$route],['id'=>$id]); 48 $this->edit(['alias'=>$route],['id'=>$id]);
49 -// DB::commit();  
50 -// }catch (\Exception $e){  
51 -// DB::rollBack();  
52 -// $this->fail('系统错误,请联系管理');  
53 -// } 49 + DB::commit();
  50 + }catch (\Exception $e){
  51 + DB::rollBack();
  52 + $this->fail('系统错误,请联系管理');
  53 + }
54 //通知更新 54 //通知更新
55 $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_BLOG_CATE, 'route'=>$route]); 55 $this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_BLOG_CATE, 'route'=>$route]);
56 return $this->success(); 56 return $this->success();
@@ -113,7 +113,7 @@ class BlogCategoryLogic extends BaseLogic @@ -113,7 +113,7 @@ class BlogCategoryLogic extends BaseLogic
113 ]; 113 ];
114 $this->setRouteDeleteSave($data); 114 $this->setRouteDeleteSave($data);
115 } 115 }
116 - return $this->success(); 116 + return $this->success($id);
117 } 117 }
118 118
119 119
@@ -104,7 +104,7 @@ class RouteMap extends Base @@ -104,7 +104,7 @@ class RouteMap extends Base
104 if(!$route){ 104 if(!$route){
105 throw new \Exception('路由不能为空'); 105 throw new \Exception('路由不能为空');
106 } 106 }
107 -// try { 107 + try {
108 $route_map = self::where('project_id', $project_id)->where('source_id', $source_id)->where('source', $source)->first(); 108 $route_map = self::where('project_id', $project_id)->where('source_id', $source_id)->where('source', $source)->first();
109 if(!$route_map){ 109 if(!$route_map){
110 $route_map = new self(); 110 $route_map = new self();
@@ -113,11 +113,10 @@ class RouteMap extends Base @@ -113,11 +113,10 @@ class RouteMap extends Base
113 $route_map->project_id = $project_id; 113 $route_map->project_id = $project_id;
114 } 114 }
115 $route_map->route = $route; 115 $route_map->route = $route;
116 - @file_put_contents(storage_path('logs/lyh_error.log'), var_export($route_map, true) . PHP_EOL, FILE_APPEND);  
117 $route_map->save(); 116 $route_map->save();
118 -// }catch (\Exception $e){  
119 -// throw new \Exception('路由映射失败');  
120 -// } 117 + }catch (\Exception $e){
  118 + throw new \Exception('路由映射失败');
  119 + }
121 return $route; 120 return $route;
122 } 121 }
123 122