正在显示
1 个修改的文件
包含
34 行增加
和
1 行删除
| @@ -9,6 +9,7 @@ use App\Models\News\News; | @@ -9,6 +9,7 @@ use App\Models\News\News; | ||
| 9 | use App\Models\Product\Keyword; | 9 | use App\Models\Product\Keyword; |
| 10 | use App\Models\Product\Product; | 10 | use App\Models\Product\Product; |
| 11 | use App\Models\RouteMap\RouteMap; | 11 | use App\Models\RouteMap\RouteMap; |
| 12 | +use App\Models\Template\BCustomTemplate; | ||
| 12 | use App\Services\ProjectServer; | 13 | use App\Services\ProjectServer; |
| 13 | use Illuminate\Console\Command; | 14 | use Illuminate\Console\Command; |
| 14 | use Illuminate\Support\Facades\DB; | 15 | use Illuminate\Support\Facades\DB; |
| @@ -143,7 +144,7 @@ class ProjectUpdate extends Command | @@ -143,7 +144,7 @@ class ProjectUpdate extends Command | ||
| 143 | } | 144 | } |
| 144 | } | 145 | } |
| 145 | } elseif ($api_type == 'news' || $api_type == 'blog') { | 146 | } elseif ($api_type == 'news' || $api_type == 'blog') { |
| 146 | - //产品 | 147 | + //新闻或博客 |
| 147 | $url = $api_url . '?' . http_build_query(['w' => $api_type, 'page' => 1, 'pagesize' => 0]); | 148 | $url = $api_url . '?' . http_build_query(['w' => $api_type, 'page' => 1, 'pagesize' => 0]); |
| 148 | $data = http_get($url, ['charset' => 'UTF-8']); | 149 | $data = http_get($url, ['charset' => 'UTF-8']); |
| 149 | if (isset($data['code']) && $data['code'] == 200) { | 150 | if (isset($data['code']) && $data['code'] == 200) { |
| @@ -169,6 +170,7 @@ class ProjectUpdate extends Command | @@ -169,6 +170,7 @@ class ProjectUpdate extends Command | ||
| 169 | $id = $model->addReturnId([ | 170 | $id = $model->addReturnId([ |
| 170 | 'project_id' => $project_id, | 171 | 'project_id' => $project_id, |
| 171 | 'name' => $item['ttile'], | 172 | 'name' => $item['ttile'], |
| 173 | + 'seo_title' => $item['ttile'], | ||
| 172 | 'text' => $item['content'], | 174 | 'text' => $item['content'], |
| 173 | 'image' => $item['images'][0] ?? '', | 175 | 'image' => $item['images'][0] ?? '', |
| 174 | 'status' => $api_type == 'news' ? News::STATUS_ONE : Blog::STATUS_ONE | 176 | 'status' => $api_type == 'news' ? News::STATUS_ONE : Blog::STATUS_ONE |
| @@ -180,6 +182,37 @@ class ProjectUpdate extends Command | @@ -180,6 +182,37 @@ class ProjectUpdate extends Command | ||
| 180 | } | 182 | } |
| 181 | } | 183 | } |
| 182 | } | 184 | } |
| 185 | + }else{ | ||
| 186 | + //单页 | ||
| 187 | + $url = $api_url . '?' . http_build_query(['w' => 'page', 'page' => 1, 'pagesize' => 0]); | ||
| 188 | + $data = http_get($url, ['charset' => 'UTF-8']); | ||
| 189 | + if (isset($data['code']) && $data['code'] == 200) { | ||
| 190 | + $count = $data['data']['count'] ?? 0; | ||
| 191 | + | ||
| 192 | + $total_page = ceil($count / $page_size); | ||
| 193 | + for ($page = 1; $page <= $total_page; $page++) { | ||
| 194 | + $url_page = $api_url . '?' . http_build_query(['w' => 'page', 'page' => $page, 'pagesize' => $page_size]); | ||
| 195 | + $data_page = http_get($url_page, ['charset' => 'UTF-8']); | ||
| 196 | + if (isset($data_page['code']) && $data_page['code'] == 200) { | ||
| 197 | + $items = $data_page['data']['data'] ?? []; | ||
| 198 | + | ||
| 199 | + $model = new BCustomTemplate(); | ||
| 200 | + | ||
| 201 | + foreach ($items as $item) { | ||
| 202 | + | ||
| 203 | + $custom = $model->read(['name' => $item['ttile']], 'id'); | ||
| 204 | + if (!$custom) { | ||
| 205 | + $id = $model->addReturnId([ | ||
| 206 | + 'project_id' => $project_id, | ||
| 207 | + 'name' => $item['ttile'] | ||
| 208 | + ]); | ||
| 209 | + $route = RouteMap::setRoute($item['ttile'], RouteMap::SOURCE_PAGE, $id, $project_id); | ||
| 210 | + $model->edit(['url' => $route], ['id' => $id]); | ||
| 211 | + } | ||
| 212 | + } | ||
| 213 | + } | ||
| 214 | + } | ||
| 215 | + } | ||
| 183 | } | 216 | } |
| 184 | } | 217 | } |
| 185 | //关闭数据库 | 218 | //关闭数据库 |
-
请 注册 或 登录 后发表评论