ListController.class.php
2.13 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
/**
* Created by PhpStorm.
* User: liyifei2012it
* Date: 16/9/13
* Time: 14:54
*/
namespace Apicp\Controller\Attribute;
use Common\Model\AttrModel;
use Common\Service\AttrService;
class ListController extends AbstractController
{
/**
* 属性列表接口
* @author liyifei
* @time 2016-09-18 15:23:32
*/
public function Index_post()
{
$attrServ = new AttrService();
$data = $attrServ->list_by_conds([], [], [
'`order`' => 'asc',
'attr_id' => 'asc'
]);
$selctTypes = [AttrModel::ATTR_TYPE_RADIO, AttrModel::ATTR_TYPE_CHECKBOX];
// 将下拉框单选、多选类型的属性选项,反序列化
foreach ($data as &$item) {
$isSelectType = in_array($item['type'], $selctTypes) && !empty($item['option']);
$item['option'] = $isSelectType ? unserialize($item['option']) : [[],[]];
}
if (empty($data)) {
E('_ERR_ATTR_IS_EMPTY');
return false;
}
$this->_result = $data;
}
/**
* 模拟数据接口:属性列表接口
* @author liyifei
* @time 2016-09-13 15:54:29
*/
public function Test_get()
{
$this->_result = [
'list' => [
[
'attr_id' => 1,
'attr_name' => '姓名',
"is_system" => 1,
'order' => 1,
'is_open' => 1,
'is_open_edit' => 0,
'is_required' => 0,
'is_required_edit' => 0,
'is_show' => 1,
'is_show_edit' => 1
],
[
'attr_id' => 2,
'attr_name' => '最喜欢的运动',
"is_system" => 0,
'order' => 2,
'is_open' => 1,
"is_open_edit" => 0,
"is_required" => 0,
"is_required_edit" => 0,
"is_show" => 1,
"is_show_edit" => 1
]
]
];
}
}