正在显示
1 个修改的文件
包含
8 行增加
和
7 行删除
| @@ -144,15 +144,15 @@ class KeywordLogic extends BaseLogic | @@ -144,15 +144,15 @@ class KeywordLogic extends BaseLogic | ||
| 144 | if($num > 1000){ | 144 | if($num > 1000){ |
| 145 | $this->fail('最大数量不能超过1000'); | 145 | $this->fail('最大数量不能超过1000'); |
| 146 | } | 146 | } |
| 147 | + foreach ($this->param['title'] as $k=>$v) { | ||
| 147 | DB::connection('custom_mysql')->beginTransaction(); | 148 | DB::connection('custom_mysql')->beginTransaction(); |
| 148 | try { | 149 | try { |
| 149 | - foreach ($this->param['title'] as $k=>$v){ | ||
| 150 | - if(empty($v)){ | 150 | + if (empty($v)) { |
| 151 | continue; | 151 | continue; |
| 152 | } | 152 | } |
| 153 | $this->model = new Keyword(); | 153 | $this->model = new Keyword(); |
| 154 | - $info = $this->model->read(['title'=>$v]); | ||
| 155 | - if($info !== false) { | 154 | + $info = $this->model->read(['title' => $v]); |
| 155 | + if ($info !== false) { | ||
| 156 | continue; | 156 | continue; |
| 157 | } | 157 | } |
| 158 | $param['project_id'] = $this->user['project_id']; | 158 | $param['project_id'] = $this->user['project_id']; |
| @@ -161,16 +161,17 @@ class KeywordLogic extends BaseLogic | @@ -161,16 +161,17 @@ class KeywordLogic extends BaseLogic | ||
| 161 | $param['title'] = $v; | 161 | $param['title'] = $v; |
| 162 | $id = $this->model->insertGetId($param); | 162 | $id = $this->model->insertGetId($param); |
| 163 | $route = RouteMap::setRoute($v, RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); | 163 | $route = RouteMap::setRoute($v, RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); |
| 164 | - if(empty($route)){ | 164 | + if (empty($route)) { |
| 165 | continue; | 165 | continue; |
| 166 | } | 166 | } |
| 167 | - $this->model->edit(['route'=>$route],['id'=>$id]); | ||
| 168 | - } | 167 | + $this->model->edit(['route' => $route], ['id' => $id]); |
| 169 | DB::connection('custom_mysql')->commit(); | 168 | DB::connection('custom_mysql')->commit(); |
| 170 | }catch (\Exception $e){ | 169 | }catch (\Exception $e){ |
| 171 | $this->fail('系统错误请联系管理员'); | 170 | $this->fail('系统错误请联系管理员'); |
| 172 | DB::connection('custom_mysql')->rollBack(); | 171 | DB::connection('custom_mysql')->rollBack(); |
| 173 | } | 172 | } |
| 173 | + | ||
| 174 | + } | ||
| 174 | return $this->success(); | 175 | return $this->success(); |
| 175 | } | 176 | } |
| 176 | 177 |
-
请 注册 或 登录 后发表评论