作者 lyh

gx

... ... @@ -28,12 +28,12 @@ class BlogCategoryLogic extends BaseLogic
public function categorySave(){
//验证名称是否存在
$this->verifyParamName($this->param['name']);
// DB::beginTransaction();
// try {
DB::beginTransaction();
try {
if(isset($this->param['id']) && !empty($this->param['id'])){
//查看路由是否更新
$id = $this->editCategoryRoute($this->param['id'], $this->param['alias']);
// $this->editHandleCategory($this->param['id'],$this->param['pid']);
$this->editHandleCategory($this->param['id'],$this->param['pid']);
$this->param['operator_id'] = $this->user['id'];
$this->edit($this->param,['id'=>$this->param['id']]);
}else{
... ... @@ -46,11 +46,11 @@ class BlogCategoryLogic extends BaseLogic
$route = RouteMap::setRoute(isset($this->param['alias']) ? $this->param['alias'] : $this->param['name'],
RouteMap::SOURCE_BLOG_CATE, $id, $this->user['project_id']);
$this->edit(['alias'=>$route],['id'=>$id]);
// DB::commit();
// }catch (\Exception $e){
// DB::rollBack();
// $this->fail('系统错误,请联系管理');
// }
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('系统错误,请联系管理');
}
//通知更新
$this->updateNotify(['project_id'=>$this->user['project_id'], 'type'=>RouteMap::SOURCE_BLOG_CATE, 'route'=>$route]);
return $this->success();
... ... @@ -113,7 +113,7 @@ class BlogCategoryLogic extends BaseLogic
];
$this->setRouteDeleteSave($data);
}
return $this->success();
return $this->success($id);
}
... ...
... ... @@ -104,7 +104,7 @@ class RouteMap extends Base
if(!$route){
throw new \Exception('路由不能为空');
}
// try {
try {
$route_map = self::where('project_id', $project_id)->where('source_id', $source_id)->where('source', $source)->first();
if(!$route_map){
$route_map = new self();
... ... @@ -113,11 +113,10 @@ class RouteMap extends Base
$route_map->project_id = $project_id;
}
$route_map->route = $route;
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($route_map, true) . PHP_EOL, FILE_APPEND);
$route_map->save();
// }catch (\Exception $e){
// throw new \Exception('路由映射失败');
// }
}catch (\Exception $e){
throw new \Exception('路由映射失败');
}
return $route;
}
... ...