ImportLogic.php
1012 字节
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace App\Http\Logic\Bside\Import;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\Import\ImportTask;
class ImportLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->param = $this->requestAll;
$this->model = new ImportTask();
}
/**
* 新增导入任务
* @return array
* @throws \App\Exceptions\AsideGlobalException
* @throws \App\Exceptions\BsideGlobalException
* @author Akun
* @date 2023/09/20 11:17
*/
public function addImportTask()
{
$ext = explode('.', $this->param['file_url']);
if (end($ext) != 'csv') {
$this->fail('导入文件格式必须为csv');
}
$this->param['project_id'] = $this->user['project_id'];
$this->param['user_id'] = $this->user['id'];
$rs = $this->model->add($this->param);
if($rs === false){
$this->fail('error');
}
return $this->success();
}
}