正在显示
1 个修改的文件
包含
7 行增加
和
3 行删除
| @@ -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; |
-
请 注册 或 登录 后发表评论