DeleteController.class.php
1.28 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
<?php
/**
* 【下载中心-后台】批量删除文件
* @author: heyuelong
* @email: 271608475@qq.com
* @date : 2018年4月18日11:12:18
* @version $Id$
*/
namespace Apicp\Controller\Down;
use Common\Common\ExportDownload;
use Common\Service\DownloadService;
class DeleteController extends \Apicp\Controller\AbstractController
{
public function Index_post()
{
$params = I('post.');
// 获取传递的ID集合
$ids = array_column($params['ids'], 'id');
// 如果IDS为空
if (empty($ids)) {
E('_EMPTY_DOWNLOAD_ID');
}
// 实例化DownLoadService
$service = new DownloadService();
// 组装查询条件
$conds = [
'id' => $ids,
'ea_id' => $this->_login->user['eaId']
];
// 未生成文件状态
$wait_status = ['file_status' => ExportDownload::FILE_STATUS_FALSE];
// 合并数据
$condition = array_merge($conds, $wait_status);
// 查询是否存在为生成文件
$total = $service->count_by_conds($condition);
if ($total) {
E('_ERR_NOT_MAKE_FILE_ID');
}
// 删除下载
$service->delete_by_conds($conds);
$this->_result = [];
return true;
}
}