Department.class.php
5.64 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<?php
/**
* Department.class.php
* 部门接口操作类
*
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
* @copyright Copyright (c) 2014 - ? VcySDK (http://www.vchangyi.com/)
* @author zhuxun37
* @version 1.0.0
*/
namespace VcySDK;
class Department
{
/**
* 接口调用类
*
* @var object
*/
private $serv = null;
/**
* SERVICE 类
*
* @var null
*/
private $service = null;
/**
* 创建部门的接口地址
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const CREATE_URL = '%s/department/create';
/**
* 编辑部门的接口地址
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const MODIFY_URL = '%s/department/modify';
/**
* 删除部门的接口地址
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const DELETE_URL = '%s/department/del';
/**
* 获取部门列表的接口地址
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const LIST_URL = '%s/department/page-list';
/**
* 获取部门列表的接口地址 (无鉴权)
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const IGNORE_PERMISSIONS_LIST_URL = '%s/department/ignore-permissions/page-list';
/**
* 获取部门详情的接口地址
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const DETAIL_URL = '%s/department/detail';
/**
* 获取部门类型列表的接口地址
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const TYPE_LIST_URL = '%s/department/type-list';
/**
* 获取部门类型配置列表的接口地址
* %s = {apiUrl}/a/{enumber}/{pluginIdentifier}/{thirdIdentifier}
*
* @var string
*/
const FIELD_CONFIG_LIST_URL = '%s/department/field-config-list';
/**
* 初始化
*
* @param Service $serv 接口调用类
*/
public function __construct(Service $serv)
{
$this->serv = $serv;
$this->service = new Service();
}
/**
* 创建部门
*
* @param array $condition 请求参数
* + dpName string 部门名称
* + dpParentid int 上级ID
* + dpDisplayorder int 排序值
*
* @return boolean|multitype:
*/
public function create($condition)
{
return $this->serv->postSDK(self::CREATE_URL, $condition, 'generateApiUrlA');
}
/**
* 编辑部门
*
* @param array $condition 请求参数
* + dpId string 部门ID
* + dpName string 部门名称
* + dpParentid int 上级ID
* + dpDisplayorder int 排序值
*
* @return boolean|multitype:
*/
public function modify($condition)
{
return $this->serv->postSDK(self::MODIFY_URL, $condition, 'generateApiUrlA');
}
/**
* 删除部门
*
* @param array $condition 请求参数
* + dpId string 部门ID
*
* @return boolean|multitype:
*/
public function delete($condition)
{
return $this->serv->postSDK(self::DELETE_URL, $condition, 'generateApiUrlA');
}
/**
* 获取部门列表
*
* @param array $condition 查询条件数据
* @param mixed $orders 排序字段
* @param int $page 当前页码
* @param int $perpage 每页记录数
*
* @return boolean|multitype:
*/
public function listAll($condition = array(), $page = 1, $perpage = 30, $orders = array(), $ignorePermissions = true)
{
// 查询参数
if (isset($condition['thirds']) && is_array($condition['thirds'])) {
$this->service->getValue($condition, ['thirds']);
}
$condition = $this->serv->mergeListApiParams($condition, $orders, $page, $perpage);
return $this->serv->postSDK(!$ignorePermissions ? self::LIST_URL : self::IGNORE_PERMISSIONS_LIST_URL, $condition, 'generateApiUrlA');
}
/**
* 获取部门详情
*
* @param array $condition 请求参数
* + dpId string 部门ID
*
* @return boolean|multitype:
*/
public function detail($condition)
{
return $this->serv->postSDK(self::DETAIL_URL, $condition, 'generateApiUrlA');
}
/**
* 获取部门类型列表
* @param array $condition
* @param int $page
* @param int $perpage
* @param array $orders
* @return array|bool
*/
public function listType($condition = array(), $page = 1, $perpage = 30, $orders = array())
{
$condition = $this->serv->mergeListApiParams($condition, $orders, $page, $perpage);
return $this->serv->postSDK(self::TYPE_LIST_URL, $condition, 'generateApiUrlA');
}
/**
* 获取部门类型配置列表
* @param array $condition
* @param int $page
* @param int $perpage
* @param array $orders
* @return array|bool
*/
public function listFieldConfig($condition = array(), $page = 1, $perpage = 30, $orders = array())
{
$condition = $this->serv->mergeListApiParams($condition, $orders, $page, $perpage);
return $this->serv->postSDK(self::FIELD_CONFIG_LIST_URL, $condition, 'generateApiUrlA');
}
}