正在显示
1 个修改的文件
包含
15 行增加
和
10 行删除
| @@ -121,20 +121,25 @@ class AiBlogAuthorTask extends Command | @@ -121,20 +121,25 @@ class AiBlogAuthorTask extends Command | ||
| 121 | foreach ($data as $v){ | 121 | foreach ($data as $v){ |
| 122 | //查询当前数据是否存在 | 122 | //查询当前数据是否存在 |
| 123 | $info = $aiBlogAuthorModel->read(['author_id'=>$v['id']]); | 123 | $info = $aiBlogAuthorModel->read(['author_id'=>$v['id']]); |
| 124 | - if($info === false){ | ||
| 125 | - $param = [ | ||
| 126 | - 'author_id'=>$v['id'], | ||
| 127 | - 'title'=>$v['title'], | ||
| 128 | - 'image'=>str_replace_url($v['picture']), | ||
| 129 | - 'description'=>$v['description'], | ||
| 130 | - ]; | ||
| 131 | - try { | 124 | + $param = [ |
| 125 | + 'author_id'=>$v['id'], | ||
| 126 | + 'title'=>$v['title'], | ||
| 127 | + 'image'=>str_replace_url($v['picture']), | ||
| 128 | + 'description'=>$v['description'], | ||
| 129 | + ]; | ||
| 130 | + try { | ||
| 131 | + if($info === false){ | ||
| 132 | + echo '执行新增'.PHP_EOL; | ||
| 132 | $id = $aiBlogAuthorModel->addReturnId($param); | 133 | $id = $aiBlogAuthorModel->addReturnId($param); |
| 133 | $route = RouteMap::setRoute($v['route'] ?? $v['title'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $id, $project_id); | 134 | $route = RouteMap::setRoute($v['route'] ?? $v['title'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $id, $project_id); |
| 134 | $aiBlogAuthorModel->edit(['route'=>$route],['id'=>$id]); | 135 | $aiBlogAuthorModel->edit(['route'=>$route],['id'=>$id]); |
| 135 | - }catch (\Exception $e){ | ||
| 136 | - echo 'error:'.$e->getMessage(); | 136 | + }else{ |
| 137 | + $aiBlogAuthorModel->edit($param,['id'=>$info['id']]); | ||
| 138 | + echo '执行更新'.PHP_EOL; | ||
| 137 | } | 139 | } |
| 140 | + }catch (\Exception $e){ | ||
| 141 | + echo 'error:'.$e->getMessage(); | ||
| 142 | + continue; | ||
| 138 | } | 143 | } |
| 139 | } | 144 | } |
| 140 | return true; | 145 | return true; |
-
请 注册 或 登录 后发表评论