正在显示
1 个修改的文件
包含
14 行增加
和
15 行删除
| @@ -136,31 +136,30 @@ class KeywordLogic extends BaseLogic | @@ -136,31 +136,30 @@ class KeywordLogic extends BaseLogic | ||
| 136 | * @time :2023/8/28 14:03 | 136 | * @time :2023/8/28 14:03 |
| 137 | */ | 137 | */ |
| 138 | public function batchAdd(){ | 138 | public function batchAdd(){ |
| 139 | - $num = count($this->param['title']); | ||
| 140 | - if($num > 1000){ | ||
| 141 | - $this->fail('最大数量不能超过1000'); | 139 | + $route_array = Translate::tran($this->param['title'], 'en'); |
| 140 | + if (empty($route_array)) { | ||
| 141 | + $this->fail('路由生成失败,请稍后重试!'); | ||
| 142 | } | 142 | } |
| 143 | - $data = []; | ||
| 144 | - foreach ($this->param['title'] as $k=>$v) { | ||
| 145 | - if (empty($v)) { | 143 | + try { |
| 144 | + foreach ($this->param['title'] as $k=>$v){ | ||
| 145 | + if(empty($v)){ | ||
| 146 | continue; | 146 | continue; |
| 147 | } | 147 | } |
| 148 | $this->model = new Keyword(); | 148 | $this->model = new Keyword(); |
| 149 | - $info = $this->model->read(['title' => $v]); | ||
| 150 | - if ($info !== false) { | ||
| 151 | - continue; | ||
| 152 | - } | 149 | + $info = $this->model->read(['title'=>$v]); |
| 150 | + if($info === false){ | ||
| 153 | $param['project_id'] = $this->user['project_id']; | 151 | $param['project_id'] = $this->user['project_id']; |
| 154 | $param['created_at'] = date('Y-m-d H:i:s'); | 152 | $param['created_at'] = date('Y-m-d H:i:s'); |
| 155 | $param['updated_at'] = $param['created_at']; | 153 | $param['updated_at'] = $param['created_at']; |
| 156 | $param['title'] = $v; | 154 | $param['title'] = $v; |
| 157 | $id = $this->model->insertGetId($param); | 155 | $id = $this->model->insertGetId($param); |
| 158 | - $data[] = ['id'=>$id,'route'=>$v]; | 156 | + $route = RouteMap::setRoute($route_array[$k], RouteMap::SOURCE_PRODUCT_KEYWORD, $id, $this->user['project_id']); |
| 157 | +// $this->curlDelRoute(['new_route'=>$route]); | ||
| 158 | + $this->model->edit(['route'=>$route],['id'=>$id]); | ||
| 159 | + } | ||
| 159 | } | 160 | } |
| 160 | - sleep(5); | ||
| 161 | - foreach ($data as $v){ | ||
| 162 | - $route = RouteMap::setRoute($v['route'], RouteMap::SOURCE_PRODUCT_KEYWORD, $v['id'], $this->user['project_id']); | ||
| 163 | - $this->model->edit(['route' => $route], ['id' => $id]); | 161 | + }catch (\Exception $e){ |
| 162 | + $this->fail('error'); | ||
| 164 | } | 163 | } |
| 165 | return $this->success(); | 164 | return $this->success(); |
| 166 | } | 165 | } |
-
请 注册 或 登录 后发表评论