ListController.class.php
2.16 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
* 【下载中心-后台】获取下载中心搜索列表
* @author: heyuelong
* @email: 271608475@qq.com
* @date : 2018年4月18日11:12:18
* @version $Id$
*/
namespace Apicp\Controller\Down;
use Common\Common\Helper;
use Common\Service\DownloadService;
class ListController extends \Apicp\Controller\AbstractController
{
// 导出文件夹对应文件名
public $_DirName = [
'Exam' => '考试中心',
'Course' => '课程中心',
'Task' => '员圈任务',
'Sale' => '业绩比拼',
'DataCenter' => '数据中心',
'Contact' => '员工管理',
'Live' => '员圈直播',
'Train' => '线下培训',
];
public function Index_post()
{
// 接收post参数
$params = I('post.');
// 默认值
$page = !empty($params['page']) ? intval($params['page']) : Helper::DEFAULT_PAGE;
$limit = !empty($params['limit']) ? intval($params['limit']) : Helper::DEFAULT_LIMIT;
// 分页
list($start, $limit) = page_limit($page, $limit);
// 实例化DownLoadService
$service = new DownloadService();
// 组装查询条件
$conds['ea_id'] = $this->_login->user['eaId'];
// 如果搜索名称
if (!empty($params['title'])) {
$conds['title LIKE ?'] = '%' . $params['title'] . '%';
}
// 获取记录总数
$total = $service->count_by_conds($conds);
// 获取列表数据
$list = [];
if ($total > 0) {
// 排序
$order_option = ['id' => 'DESC'];
// 查询字段
$field = 'id,title,size,username,file_status,type,created,app_dir';
$list = $service->list_by_conds($conds, [$start, $limit], $order_option, $field);
// 新增返回文件名称
foreach ($list as &$v) {
$v['app_name'] = $this->_DirName[$v['app_dir']];
}
}
$this->_result = [
'total' => intval($total),
'limit' => intval($limit),
'page' => intval($page),
'list' => $list
];
return true;
}
}