合并分支 'lyh-server' 到 'master'
更新 ai——blogs拉取作者 查看合并请求 !1483
正在显示
1 个修改的文件
包含
8 行增加
和
4 行删除
| @@ -72,7 +72,7 @@ class AiBlogAuthorTask extends Command | @@ -72,7 +72,7 @@ class AiBlogAuthorTask extends Command | ||
| 72 | continue; | 72 | continue; |
| 73 | } | 73 | } |
| 74 | if(empty($result['data'])){ | 74 | if(empty($result['data'])){ |
| 75 | - echo '没有作者任务:创建作者任务'.PHP_EOL; | 75 | + echo '没有作者任务-'.PHP_EOL; |
| 76 | continue; | 76 | continue; |
| 77 | } | 77 | } |
| 78 | //保存当前项目ai_blog数据 | 78 | //保存当前项目ai_blog数据 |
| @@ -118,19 +118,23 @@ class AiBlogAuthorTask extends Command | @@ -118,19 +118,23 @@ class AiBlogAuthorTask extends Command | ||
| 118 | return true; | 118 | return true; |
| 119 | } | 119 | } |
| 120 | $aiBlogAuthorModel = new AiBlogAuthor(); | 120 | $aiBlogAuthorModel = new AiBlogAuthor(); |
| 121 | - $info = $aiBlogAuthorModel->counts(['id'=>['!=',0]]); | ||
| 122 | - if($info == 0){ | ||
| 123 | - echo '项目id:'.$project_id.'执行新增。'.$info; | ||
| 124 | foreach ($data as $v){ | 121 | foreach ($data as $v){ |
| 122 | + //查询当前数据是否存在 | ||
| 123 | + $info = $aiBlogAuthorModel->read(['author_id'=>$v['id']]); | ||
| 124 | + if($info === false){ | ||
| 125 | $param = [ | 125 | $param = [ |
| 126 | 'author_id'=>$v['id'], | 126 | 'author_id'=>$v['id'], |
| 127 | 'title'=>$v['title'], | 127 | 'title'=>$v['title'], |
| 128 | 'image'=>str_replace_url($v['picture']), | 128 | 'image'=>str_replace_url($v['picture']), |
| 129 | 'description'=>$v['description'], | 129 | 'description'=>$v['description'], |
| 130 | ]; | 130 | ]; |
| 131 | + try { | ||
| 131 | $id = $aiBlogAuthorModel->addReturnId($param); | 132 | $id = $aiBlogAuthorModel->addReturnId($param); |
| 132 | $route = RouteMap::setRoute($v['route'] ?? $v['title'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $id, $project_id); | 133 | $route = RouteMap::setRoute($v['route'] ?? $v['title'], RouteMap::SOURCE_AI_BLOG_AUTHOR, $id, $project_id); |
| 133 | $aiBlogAuthorModel->edit(['route'=>$route],['id'=>$id]); | 134 | $aiBlogAuthorModel->edit(['route'=>$route],['id'=>$id]); |
| 135 | + }catch (\Exception $e){ | ||
| 136 | + echo 'error:'.$e->getMessage(); | ||
| 137 | + } | ||
| 134 | } | 138 | } |
| 135 | } | 139 | } |
| 136 | return true; | 140 | return true; |
-
请 注册 或 登录 后发表评论