正在显示
1 个修改的文件
包含
10 行增加
和
1 行删除
| @@ -105,6 +105,8 @@ class KeywordLogic extends BaseLogic | @@ -105,6 +105,8 @@ class KeywordLogic extends BaseLogic | ||
| 105 | * @time :2023/8/28 14:03 | 105 | * @time :2023/8/28 14:03 |
| 106 | */ | 106 | */ |
| 107 | public function batchAdd(){ | 107 | public function batchAdd(){ |
| 108 | + try { | ||
| 109 | + $idArr = []; | ||
| 108 | foreach ($this->param['title'] as $v){ | 110 | foreach ($this->param['title'] as $v){ |
| 109 | $info = $this->model->read(['title'=>$v]); | 111 | $info = $this->model->read(['title'=>$v]); |
| 110 | if($info === false){ | 112 | if($info === false){ |
| @@ -113,9 +115,16 @@ class KeywordLogic extends BaseLogic | @@ -113,9 +115,16 @@ class KeywordLogic extends BaseLogic | ||
| 113 | $param['updated_at'] = $param['created_at']; | 115 | $param['updated_at'] = $param['created_at']; |
| 114 | $param['title'] = $v; | 116 | $param['title'] = $v; |
| 115 | $id = $this->model->insertGetId($param); | 117 | $id = $this->model->insertGetId($param); |
| 116 | - $route = RouteMap::setRoute($v, RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); | 118 | + $idArr[] = ['id'=>$id,'title'=>$v]; |
| 119 | + } | ||
| 120 | + } | ||
| 121 | + //批量生成路由 | ||
| 122 | + foreach ($idArr as $v){ | ||
| 123 | + $route = RouteMap::setRoute($v['title'], RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $this->user['project_id']); | ||
| 117 | $this->model->edit(['route'=>$route],['id'=>$id]); | 124 | $this->model->edit(['route'=>$route],['id'=>$id]); |
| 118 | } | 125 | } |
| 126 | + }catch (\Exception $e){ | ||
| 127 | + $this->fail('error'); | ||
| 119 | } | 128 | } |
| 120 | return $this->success(); | 129 | return $this->success(); |
| 121 | } | 130 | } |
-
请 注册 或 登录 后发表评论