InfoController.class.php
2.35 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
<?php
/**
* Created by PhpStorm.
* User: liyifei2012it
* Date: 18/4/24
* Time: 11:24
*/
namespace Apicp\Controller\Path;
use Common\Common\Constant;
use Common\Service\PathContentService;
use Common\Service\PathService;
use Common\Service\MapPathService;
class InfoController extends \Apicp\Controller\AbstractController
{
/**
* Info
* @author liyifei
* @desc 路径详情接口
* @param Int path_id:true 路径ID
* @return Array
* array(
* 'path_id' => 1, // 路径ID
* 'path_name' => 1, // 路径名称
* 'is_used' => 1, // 是否被地图引用(1=否;2=是)
* 'map_num' => 2, // 被地图使用次数
* 'is_step' => 1, // 是否开启闯关(1=未开启;2=已开启)
* 'description' => 1, // 介绍
* 'contents' => array( // 学习内容
* array(
* 'path_content_id' => 1, // 内容ID
* 'app' => 'course', // 应用
* 'app_data_id' => 1, // 应用数据ID
* 'title' => '好好学习,天天向上', // 标题
* 'is_learn' => 2, // 是否必学(1=否;2=是)
* 'order' => 1, // 排序(升序)
* 'url' => 'http://dengta.vchangyi.com/123', // 内容详细地址
* ),
* ),
* )
*/
public function Index_post()
{
$pathId = I('post.path_id', 0, 'intval');
if ($pathId <= 0) {
E('_ERR_PATH_ID_LOSE');
}
// 路径不存在
$pathServ = new PathService();
$path = $pathServ->get($pathId);
if (empty($path)) {
E('_ERR_PATH_NOT_FOUND');
}
// 学习内容不存在
$contentServ = new PathContentService();
$path['contents'] = $contentServ->formatPathContent($pathId);
if (empty($path['contents'])) {
E('_ERR_PATH_CONTENT_NOT_FOUND');
}
// 路径关联地图列表
$mapPathServ = new MapPathService();
$mapPath = $mapPathServ->list_by_conds(['path_id' => $pathId]);
$path['is_used'] = empty($mapPath) ? Constant::PATH_IS_USED_FALSE : Constant::PATH_IS_USED_TRUE;
$path['map_num'] = count($mapPath);
$this->_result = $path;
}
}