作者 刘锟

upload_remote

@@ -73,7 +73,7 @@ class ProjectImport extends Command @@ -73,7 +73,7 @@ class ProjectImport extends Command
73 $project = ProjectServer::useProject($task->project_id); 73 $project = ProjectServer::useProject($task->project_id);
74 if ($project) { 74 if ($project) {
75 foreach ($line_of_text as $k => $v) { 75 foreach ($line_of_text as $k => $v) {
76 - if ($k > 0 && $v) { 76 + if ($k > 0 && $v[0]) {
77 $total_count += 1; 77 $total_count += 1;
78 if ($task->type == ImportTask::TYPE_NEWS) { 78 if ($task->type == ImportTask::TYPE_NEWS) {
79 if ((new NewsLogic())->importNews($task->project_id, $task->user_id, $v)) { 79 if ((new NewsLogic())->importNews($task->project_id, $task->user_id, $v)) {
@@ -270,7 +270,7 @@ class NewsLogic extends BaseLogic @@ -270,7 +270,7 @@ class NewsLogic extends BaseLogic
270 public function importNews($project_id, $user_id, $data) 270 public function importNews($project_id, $user_id, $data)
271 { 271 {
272 $category_id = ''; 272 $category_id = '';
273 - if (!empty($data[2])) { 273 + if ($data[2]) {
274 //处理分类 274 //处理分类
275 $newsCategoryLogic = new NewsCategoryLogic(); 275 $newsCategoryLogic = new NewsCategoryLogic();
276 $category_id = $newsCategoryLogic->importNewsCategory($project_id, $user_id, $data[2]); 276 $category_id = $newsCategoryLogic->importNewsCategory($project_id, $user_id, $data[2]);
@@ -282,12 +282,12 @@ class NewsLogic extends BaseLogic @@ -282,12 +282,12 @@ class NewsLogic extends BaseLogic
282 [ 282 [
283 'name' => $data[0], 283 'name' => $data[0],
284 'category_id' => $category_id, 284 'category_id' => $category_id,
285 - 'text' => $data[4],  
286 - 'remark' => $data[3], 285 + 'text' => $data[4] ?? '',
  286 + 'remark' => $data[3] ?? '',
287 'image' => $data['5'] ? CosService::uploadRemote($project_id, 'image_news', $data[5]) : '', 287 'image' => $data['5'] ? CosService::uploadRemote($project_id, 'image_news', $data[5]) : '',
288 - 'seo_title' => $data[6],  
289 - 'seo_keywords' => $data[7],  
290 - 'seo_description' => $data[8], 288 + 'seo_title' => $data[6] ?? '',
  289 + 'seo_keywords' => $data[7] ?? '',
  290 + 'seo_description' => $data[8] ?? '',
291 'project_id' => $project_id, 291 'project_id' => $project_id,
292 'operator_id' => $user_id, 292 'operator_id' => $user_id,
293 'create_id' => $user_id 293 'create_id' => $user_id
@@ -95,10 +95,11 @@ class CosService @@ -95,10 +95,11 @@ class CosService
95 'Key' => $key, 95 'Key' => $key,
96 'Body' => fopen($file_url, 'r'), 96 'Body' => fopen($file_url, 'r'),
97 ]); 97 ]);
98 - return $key;  
99 }catch (\Exception $e){ 98 }catch (\Exception $e){
100 LogUtils::error('uploadRemote error', $e->getMessage()); 99 LogUtils::error('uploadRemote error', $e->getMessage());
101 } 100 }
  101 +
  102 + return $key;
102 } 103 }
103 104
104 } 105 }