作者 lyh

gx

@@ -69,6 +69,8 @@ class NewsController extends BaseController @@ -69,6 +69,8 @@ class NewsController extends BaseController
69 * @method 69 * @method
70 */ 70 */
71 public function add(NewsRequest $newsRequest,NewsLogic $newsLogic){ 71 public function add(NewsRequest $newsRequest,NewsLogic $newsLogic){
  72 + var_dump($this->request->all());
  73 + die();
72 $newsRequest->validated(); 74 $newsRequest->validated();
73 $newsLogic->news_add(); 75 $newsLogic->news_add();
74 //TODO::通知网站更新 76 //TODO::通知网站更新
@@ -54,11 +54,9 @@ class NewsLogic extends BaseLogic @@ -54,11 +54,9 @@ class NewsLogic extends BaseLogic
54 * @method 54 * @method
55 */ 55 */
56 public function news_add(){ 56 public function news_add(){
57 - var_dump($this->param);  
58 - die();  
59 //拼接参数 57 //拼接参数
60 -// DB::beginTransaction();  
61 -// try { 58 + DB::beginTransaction();
  59 + try {
62 if(isset($this->param['image'])){ 60 if(isset($this->param['image'])){
63 $data = $this->upload(); 61 $data = $this->upload();
64 $this->param['image'] = $data; 62 $this->param['image'] = $data;
@@ -66,11 +64,11 @@ class NewsLogic extends BaseLogic @@ -66,11 +64,11 @@ class NewsLogic extends BaseLogic
66 $this->param = $this->paramProcessing($this->param); 64 $this->param = $this->paramProcessing($this->param);
67 $rs = $this->model->insertGetId($this->param); 65 $rs = $this->model->insertGetId($this->param);
68 RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']); 66 RouteMap::setRoute($this->param['url'] ?: $this->param['name'], RouteMap::SOURCE_NEWS, $rs, $this->user['project_id']);
69 -// DB::commit();  
70 -// }catch (\Exception $e){  
71 -// DB::rollBack();  
72 -// $this->fail('添加失败');  
73 -// } 67 + DB::commit();
  68 + }catch (\Exception $e){
  69 + DB::rollBack();
  70 + $this->fail('添加失败');
  71 + }
74 return $this->success(); 72 return $this->success();
75 } 73 }
76 74