InfoController.class.php
1.8 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
<?php
/**
* Created by PhpStorm.
* User: liyifei2012it
* Date: 16/9/13
* Time: 17:17
*/
namespace Apicp\Controller\Attribute;
use Common\Service\AttrService;
class InfoController extends AbstractController
{
/**
* 编辑属性查询接口
* @author liyifei
* @time 2016-09-18 18:08:38
*/
public function Index_post()
{
// 接收参数
$attrId = I('post.attr_id', 0, 'Intval');
if (empty($attrId)) {
E('_ERR_ATTR_UNDEFINED');
return false;
}
// 属性是否存在
$attrServ = new AttrService();
$data = $attrServ->get_by_conds(['attr_id' => $attrId]);
if (empty($data)) {
E('_ERR_ATTR_UNDEFINED');
return false;
}
// 处理返回值
$result = [
'attr_id' => $data['attr_id'],
'attr_name' => $data['attr_name'],
'type' => $data['type'],
'order' => $data['order'],
'option' => empty($data['option']) ? '' : unserialize($data['option']),
'is_system' => $data['is_system'],
'is_open' => $data['is_open'],
'is_required' => $data['is_required'],
'is_show' => $data['is_show']
];
$this->_result = $result;
}
/**
* 模拟数据接口:编辑属性查询接口
* @author liyifei
* @time 2016-09-13 17:24:19
*/
public function Test_get()
{
$this->_result = [
"attr_name" => "喜爱的运动项目",
"type" => 2,
"order" => 7,
"option" => [
0 => "篮球",
1 => "足球"
],
"is_system" => 0,
"is_open" => 1,
"is_required" => 0,
"is_show" => 1
];
}
}