ContentListController.class.php
2.29 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
<?php
/**
* Created by PhpStorm.
* User: zhonglei
* Date: 18/4/24
* Time: 11:57
*/
namespace Apicp\Controller\Path;
use Com\PackageValidate;
use Com\Rpc;
use Common\Common\Constant;
use Common\Service\PathContentService;
class ContentListController extends \Apicp\Controller\AbstractController
{
/**
* ContentList
* @author zhonglei
* @desc 获取路径内容列表接口
* @param string app:true 应用(course=课程;exam=考试;questionnaire=调研)
* @param Int class_id 分类ID
* @param string keyword 搜索关键字
* @param Int page:1 当前页
* @param Int limit:20 每页数据总数
* @return array
array(
'page' => 1, // 当前页
'limit' => 20, // 每页数据总数
'total' => 100, // 数据总数
'list' => array( // 列表数据
'app_data_id' => 1, // 数据ID
'title' => '电商冲击,实体店靠什么赢', // 标题
'class_name' => '导购FM', // 分类名称
'author' => '张三', // 作者
'status' => '未开始', // 状态
),
),
*/
public function Index_post()
{
// 验证规则
$rules = [
'app' => 'require|in:course,exam,questionnaire',
'class_id' => 'integer',
'keyword' => 'max:50',
'page' => 'integer',
'limit' => 'integer',
'path_id' => 'integer'
];
// 验证数据
$validate = new PackageValidate($rules, [], array_keys($rules));
$post_data = $validate->postData;
// 考试、调研需要获取已使用数据ID数组
if (in_array($post_data['app'], [Constant::APP_EXAM, Constant::APP_QUESTIONNAIRE])) {
$contentServ = new PathContentService();
$post_data['app_data_ids'] = $contentServ->getAppDataIds(
$post_data['app'],
$post_data['path_id'] ? $post_data['path_id'] : 0
);
}
$app = ucfirst(strtolower($post_data['app']));
$url = rpcUrl("/{$app}/Rpc/OtherClass/List");
$this->_result = Rpc::phprpc($url)->invoke('index', $post_data);
}
}