ImportLogic.php
1.4 KB
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
42
43
44
45
46
47
48
49
50
51
<?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');
}
$domain = $this->param['domain'];
if (strpos($domain, 'https') === false || strpos($domain, 'http') == false) {
$this->fail('请输入完整的采集页面地址');
}
$domain_arr = parse_url($domain);
if (!isset($domain_arr['host'])) {
$this->fail('采集页面地址输入有误');
}
$this->param['domain'] = $domain_arr['host'];
$this->param['project_id'] = $this->user['project_id'];
$this->param['user_id'] = $this->user['id'];
$this->param['status'] = 9;
$rs = $this->model->add($this->param);
if ($rs === false) {
$this->fail('error');
}
return $this->success();
}
}