DetailController.class.php
1.75 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
84
<?php
/**
* DetailController.class.php
* 同事圈详情
* User: 代军
* Date: 2017-04-24
*/
namespace Apicp\Controller\Topic;
use Common\Common\Config;
use Common\Service\CircleService;
use Common\Service\SceneService;
use Common\Service\SettingService;
class DetailController extends AbstractController
{
/**
* @var CircleService 帖子信息表
*/
protected $_circle_serv;
/**
* @var SettingService 同事圈配置表
*/
protected $settingServ;
public function before_action($action = '')
{
if (!parent::before_action($action)) {
return false;
}
// 实例化帖子信息表
$this->_circle_serv = new CircleService();
// 实例化同事圈配置表
$this->settingServ = new SettingService();
return true;
}
public function Index_post()
{
// 接收参数
$id = I('post.id');
// 参数验证
if (empty($id)) {
$this->_set_error('_EMPTY_ID');
return false;
}
// 获取帖子基本信息
$data = $this->_circle_serv->get($id);
if (empty($data)) {
$this->_set_error('_ERR_DATA_EXIST');
return false;
}
// 格式化详情数据
$this->_circle_serv->format_detail($data);
$data['cover_url'] = imgUrlReal($data['cover_id']);
// 实例化场景表
$SceneSer = new SceneService();
$info = $SceneSer->get($data['sc_id']);
$data['sc_title'] = strval($info['title']);
$setting = Config::instance()->getCacheData();
$data['is_open_check'] = rintval($setting['is_need_check']);
// 返回数据
$this->_result = $data;
return true;
}
}