AbstractController.class.php
1.87 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
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
* AbstractController.class.php
* $author$
*/
namespace Apicp\Controller\Attachment;
use Common\Service\SourceAttachService;
use Common\Service\SourceService;
use Common\Service\TaskService;
abstract class AbstractController extends \Common\Controller\Apicp\AbstractController
{
protected $_require_login = false;
protected $needCheckThePayment = false;
/**
*保存附件
* @param array $params
* @return \Think\mixed
*/
public function saveAtt($params = [])
{
// 素材附件表
$AttachService = new SourceAttachService();
$source_data['ea_id'] = $this->_login->user['eaId'];
$source_data['ea_name'] = $this->_login->user['eaRealname'];
$source_data['update_time'] = MILLI_TIME;
$source_data['study_time'] = 0;
$source_data['source_type'] = $params['source_type'];
$source_data['source_title'] = $params['title'];
$source_data['content'] = '';
$source_data['source_status'] = $params['source_status'];
// 素材表
$sourceServ = new SourceService();
$source_data['source_key'] = $sourceServ->createSourceKey($params);
$source_id = $sourceServ->insert($source_data);
$CourseArticle = [
'source_id' => $source_id,
'at_id' => $params['at_id'],
'at_name' => $params['at_name'],
'at_type' => $params['at_type'],
'at_time' => intval($params['at_time']),
'at_size' => intval($params['at_size']),
'at_url' => $params['at_url'],
'at_convert_url' => strval($params['at_convert_url']),
'at_cover_url' => strval($params['at_cover_url'])
];
$AttachService->insert($CourseArticle);
// 创建计划任务
$taskServ = new TaskService();
$taskServ->create($source_id);
return $source_id;
}
}