InfoController.class.php
4.1 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?php
/**
* Created by PhpStorm.
* User: tangxingguo
* Date: 2017/4/13
* Time: 17:02
*/
namespace Apicp\Controller\CourseClass;
use Com\PackageValidate;
use Common\Service\ClassService;
use Common\Service\RightService;
class InfoController extends \Apicp\Controller\AbstractController
{
/**
* Info
* @author tangxingguo
* @desc 分类详情
* @param int class_id:true 分类ID
* @return array 分类信息
array(
'class_id' => 2, // 分类ID
'class_name' => '分类名称', // 分类名称
'parent_id' => 1, // 父类ID
'parent_name' => '一级分类', // 父类名称
'description' => '分类描述', // 分类描述
'is_open' => 1, // 启用分类(1=禁用,2=启用)
'right' => array( // 权限
'is_all' => 1, // 是否全公司(1=否,2=是)
'user_list' => array( // 人员信息
array(
'uid' => '0E19B0B47F0000012652058BA42EEEDE', // 人员ID
'username' => '张三', // 人员姓名
'face' => 'http://qy.vchangyi.com', // 人员头像
),
),
'tag_list' => array( // 标签信息
array(
'tag_id' => '0E19B0B47F0000012652058BA42EEEDE', // 标签ID
'tag_name' => '吃货', // 标签名称
),
),
'dp_list' => array( // 部门信息
array(
'dp_id' => '0E19B0B47F0000012652058BA42EEEDE', // 部门ID
'dp_name' => '技术部', // 部门名称
),
),
'job_list' => array( // 职位信息
array(
'job_id' => '0E19B0B47F0000012652058BA42EEEDE', // 职位ID
'job_name' => '攻城狮', // 职位名称
),
),
'role_list' => array( // 角色信息
array(
'role_id' => '0E19B0B47F0000012652058BA42EEEDE', // 角色ID
'role_name' => '国王', // 角色名称
),
),
),
)
*/
public function Index_post()
{
// 验证规则
$rules = [
'class_id' => 'require|integer',
];
// 验证数据
$validate = new PackageValidate($rules, [], array_keys($rules));
$postData = $validate->postData;
// 取分类信息
$classServ = new ClassService();
$classInfo = $classServ->get($postData['class_id']);
if (empty($classInfo)) {
E('_ERR_CLASS_DATA_NOT_FOUND');
}
$info = [
'class_id' => $classInfo['class_id'],
'class_name' => $classInfo['class_name'],
'description' => $classInfo['description'],
];
// 二级三级分类取父类、权限
$classServ->getLevel($postData['class_id'], $level);
if (in_array($level, [2, 3])) {
$parentInfo = $classServ->get($classInfo['parent_id']);
if ($parentInfo) {
$info['parent_name'] = $parentInfo['class_name'];
$info['parent_id'] = $parentInfo['class_id'];
$info['is_open'] = $classInfo['is_open'];
}
// 取权限(三级继承二级权限)
$classId = $postData['class_id'];
if ($level == 3) {
$classId = $info['parent_id'];
}
$rightServ = new RightService();
$info['right'] = $rightServ->getData(['class_id' => $classId]);
}
$this->_result = $info;
}
}