|
@@ -256,6 +256,16 @@ class NewsLogic extends BaseLogic |
|
@@ -256,6 +256,16 @@ class NewsLogic extends BaseLogic |
|
256
|
return $this->success();
|
256
|
return $this->success();
|
|
257
|
}
|
257
|
}
|
|
258
|
|
258
|
|
|
|
|
259
|
+ /**
|
|
|
|
260
|
+ * 新闻导入
|
|
|
|
261
|
+ * @param $project_id
|
|
|
|
262
|
+ * @param $user_id
|
|
|
|
263
|
+ * @param $data
|
|
|
|
264
|
+ * @return bool
|
|
|
|
265
|
+ * @throws \Exception
|
|
|
|
266
|
+ * @author Akun
|
|
|
|
267
|
+ * @date 2023/09/20 17:51
|
|
|
|
268
|
+ */
|
|
259
|
public function importNews($project_id, $user_id, $data)
|
269
|
public function importNews($project_id, $user_id, $data)
|
|
260
|
{
|
270
|
{
|
|
261
|
$category_id = '';
|
271
|
$category_id = '';
|
|
@@ -264,6 +274,29 @@ class NewsLogic extends BaseLogic |
|
@@ -264,6 +274,29 @@ class NewsLogic extends BaseLogic |
|
264
|
$newsCategoryLogic = new NewsCategoryLogic();
|
274
|
$newsCategoryLogic = new NewsCategoryLogic();
|
|
265
|
$category_id = $newsCategoryLogic->importNewsCategory($project_id, $user_id, $data[2]);
|
275
|
$category_id = $newsCategoryLogic->importNewsCategory($project_id, $user_id, $data[2]);
|
|
266
|
}
|
276
|
}
|
|
267
|
- dd($category_id);
|
277
|
+
|
|
|
|
278
|
+ $news = $this->model->read(['name'=>$data[0]]);
|
|
|
|
279
|
+ if(!$news){
|
|
|
|
280
|
+ $id = $this->model->addReturnId(
|
|
|
|
281
|
+ [
|
|
|
|
282
|
+ 'name' => $data[0],
|
|
|
|
283
|
+ 'category_id' => $category_id,
|
|
|
|
284
|
+ 'text' => $data[4],
|
|
|
|
285
|
+ 'remark' => $data[3],
|
|
|
|
286
|
+ 'image' => '',//TODO: 远程图片下载本地
|
|
|
|
287
|
+ 'seo_title' => $data[6],
|
|
|
|
288
|
+ 'seo_keywords' => $data[7],
|
|
|
|
289
|
+ 'seo_description' => $data[8],
|
|
|
|
290
|
+ 'project_id' => $project_id,
|
|
|
|
291
|
+ 'operator_id' => $user_id,
|
|
|
|
292
|
+ 'create_id' => $user_id
|
|
|
|
293
|
+ ]
|
|
|
|
294
|
+ );
|
|
|
|
295
|
+ //更新路由
|
|
|
|
296
|
+ $route = RouteMap::setRoute($data[0], RouteMap::SOURCE_NEWS, $id, $project_id);
|
|
|
|
297
|
+ $this->edit(['url' => $route], ['id' => $id]);
|
|
|
|
298
|
+ }
|
|
|
|
299
|
+
|
|
|
|
300
|
+ return true;
|
|
268
|
}
|
301
|
}
|
|
269
|
} |
302
|
} |