-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathUser.php
446 lines (416 loc) · 10.7 KB
/
User.php
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
<?php
/**
* 用户模块
* User=> hejinyu
* Date=> 2018/7/23
* Time=> 11=>41
*/
namespace RongCloud\Lib\User;
use RongCloud\Lib\User\Tag\Tag;
use RongCloud\Lib\User\Block\Block;
use RongCloud\Lib\User\Blacklist\Blacklist;
use RongCloud\Lib\User\Whitelist\Whitelist;
use RongCloud\Lib\User\MuteGroups\MuteGroups;
use RongCloud\Lib\User\Onlinestatus\Onlinestatus;
use RongCloud\Lib\User\MuteChatrooms\MuteChatrooms;
use RongCloud\Lib\User\Chat\Ban;
use RongCloud\Lib\User\Remark\Remark;
use RongCloud\Lib\User\BlockPushPeriod\BlockPushPeriod;
use RongCloud\Lib\User\Profile\Profile;
use RongCloud\Lib\Utils;
use RongCloud\Lib\Request;
class User
{
/**
* 用户模块路径
*
* @var string
*/
private $jsonPath = 'Lib/User/';
/**
* 请求配置文件
*
* @var string
*/
private $conf = "";
/**
* 校验配置文件
*
* @var string
*/
private $verify = "";
/**
* User constructor.
*/
function __construct()
{
//初始化请求配置和校验文件路径
$this->conf = Utils::getJson($this->jsonPath . 'api.json');
$this->verify = Utils::getJson($this->jsonPath . 'verify.json');
}
/**
* @param $User array 用户注册
* @param
* $User = [
* 'id'=> 'ujadk90ha',//用户id
* 'name'=> 'Maritn',//用户名称
* 'portrait'=> 'http://7xogjk.com1.z0.glb.clouddn.com/IuDkFprSQ1493563384017406982' //用户头像
* ];
* @return array
*/
public function register(array $User = [])
{
$conf = $this->conf['register'];
$error = (new Utils())->check(
[
'api' => $conf,
'model' => 'user',
'data' => $User,
'verify' => $this->verify['user']
]
);
if ($error) {
return $error;
}
$User = (new Utils())->rename($User, [
'id' => 'userId',
'portrait' => 'portraitUri'
]);
$result = (new Request())->Request($conf['url'], $User);
$bodyParameter = (new Request())->getQueryFields($User);
$result = (new Utils())->responseError($result, $conf['response']['fail'], $bodyParameter);
return $result;
}
/**
* Token 失效
*
* @param $User array 用户信息
* @param
* $User = [
* 'id'=> ['ujadk90ha1'], //需要设置 Token 失效的用户 ID,支持设置多个最多不超过 20 个。
* 'time'=> 1623123911000 //过期时间戳精确到毫秒,该时间戳前用户获取的 Token 全部失效,使用时间戳之前的 Token 已经在连接中的用户不会立即失效,断开后无法进行连接。
* ];
* @return array
*/
public function expire(array $User = [])
{
$conf = $this->conf['expire'];
$error = (new Utils())->check(
[
'api' => $conf,
'model' => 'user',
'data' => $User,
'verify' => $this->verify['expire']
]
);
if ($error) {
return $error;
}
$User = (new Utils())->rename($User, [
'id' => 'userId'
]);
$result = (new Request())->Request($conf['url'], $User);
$bodyParameter = (new Request())->getQueryFields($User);
$result = (new Utils())->responseError($result, $conf['response']['fail'], $bodyParameter);
return $result;
}
/**
* @param $User array 用户信息更新
* @param
* $User = [
* 'id'=> 'ujadk90ha',//用户id
* 'name'=> 'Maritn',//用户名称
* 'portrait'=> 'http://7xogjk.com1.z0.glb.clouddn.com/IuDkFprSQ1493563384017406982' //用户头像
* ];
* @return array
*/
public function update(array $User = [])
{
$conf = $this->conf['update'];
$error = (new Utils())->check(
[
'api' => $conf,
'model' => 'user',
'data' => $User,
'verify' => $this->verify['user']
]
);
if ($error) {
return $error;
}
$User = (new Utils())->rename($User, [
'id' => 'userId',
'portrait' => 'portraitUri'
]);
$result = (new Request())->Request($conf['url'], $User);
$result = (new Utils())->responseError($result, $conf['response']['fail']);
return $result;
}
/**
* @param $User array 查询用户信息
* @param
* $User = [
* 'id'=> 'ujadk90ha',//用户id
* ];
* @return array
*/
public function get(array $User = [])
{
$conf = $this->conf['get'];
$error = (new Utils())->check(
[
'api' => $conf,
'model' => 'user',
'data' => $User,
'verify' => $this->verify['user']
]
);
if ($error) {
return $error;
}
$User = (new Utils())->rename($User, [
'id' => 'userId',
]);
$result = (new Request())->Request($conf['url'], $User);
$result = (new Utils())->responseError($result, $conf['response']['fail']);
if ($result['code'] == 200) {
$result = (new Utils())->rename($result, [
'userName' => 'name',
'userPortrait' => 'portrait',
]);
}
return $result;
}
/**
* @param $User array 用户注销
* @param
* $User = [
* 'id'=> 'ujadk90ha',//用户id
* ];
* @return array
*/
public function abandon(array $User = [])
{
$conf = $this->conf['cancel_set'];
$error = (new Utils())->check(
[
'api' => $conf,
'model' => 'user',
'data' => $User,
'verify' => $this->verify['user']
]
);
if ($error) {
return $error;
}
$User = (new Utils())->rename($User, [
'id' => 'userId',
]);
$result = (new Request())->Request($conf['url'], $User);
$result = (new Utils())->responseError($result, $conf['response']['fail']);
return $result;
}
/**
* @param $User array 查询已注销用户
* @param
* @return array
*/
public function abandonQuery(array $params = ["page"=>1,"size"=>50])
{
$conf = $this->conf['cancel_query'];
$User = (new Utils())->rename($params, [
'page' => 'pageNo',
'size' => 'pageSize'
]);
$result = (new Request())->Request($conf['url'], $User);
$result = (new Utils())->responseError($result, $conf['response']['fail']);
return $result;
}
/**
* @param $User array 注销用户激活
* @param
* $User = [
* 'id'=> 'ujadk90ha',//用户id
* ];
* @return array
*/
public function activate(array $User = [])
{
$conf = $this->conf['active'];
$error = (new Utils())->check(
[
'api' => $conf,
'model' => 'user',
'data' => $User,
'verify' => $this->verify['user']
]
);
if ($error) {
return $error;
}
$User = (new Utils())->rename($User, [
'id' => 'userId',
]);
$result = (new Request())->Request($conf['url'], $User);
$result = (new Utils())->responseError($result, $conf['response']['fail']);
return $result;
}
/**
* 重新激活用户 ID
* @param $User array 用户id
* @param
* $User = [
* 'id'=> 'ujadk90ha',//用户id
* ];
* @return array
*/
public function reactivate(array $User = [])
{
$conf = $this->conf['reactivate'];
$error = (new Utils())->check(
[
'api' => $conf,
'model' => 'user',
'data' => $User,
'verify' => $this->verify['user']
]
);
if ($error) {
return $error;
}
$User = (new Utils())->rename($User, [
'id' => 'userId',
]);
$result = (new Request())->Request($conf['url'], $User);
$result = (new Utils())->responseError($result, $conf['response']['fail']);
return $result;
}
/**
* @param $User array 查询用户所在群组
* @param
* $User = [
* 'id'=> 'ujadk90ha',//用户id
* ];
* @return array
*/
public function getGroups(array $User = [])
{
$conf = $this->conf['getGroups'];
$error = (new Utils())->check(
[
'api' => $conf,
'model' => 'user',
'data' => $User,
'verify' => $this->verify['user']
]
);
if ($error) {
return $error;
}
$User = (new Utils())->rename($User, [
'id' => 'userId',
]);
$result = (new Request())->Request($conf['url'], $User);
$result = (new Utils())->responseError($result, $conf['response']['fail']);
return $result;
}
/**
* 创建封禁对象
*
* @return Block
*/
public function Block()
{
return new Block();
}
/**
* 创建黑名单对象
*
* @return Blacklist
*/
public function Blacklist()
{
return new Blacklist();
}
/**
* 创建用户在线状态对象
*
* @return Onlinestatus
*/
public function Onlinestatus()
{
return new Onlinestatus();
}
/**
* 全局群组禁言
*
* @return MuteGroups
*/
public function MuteGroups()
{
return new MuteGroups();
}
/**
* 全局聊天室禁言
*
* @return MuteChatrooms
*/
public function MuteChatrooms()
{
return new MuteChatrooms();
}
/**
* 用户标签
*
* @return Tag
*/
public function Tag()
{
return new Tag();
}
/**
* 创建白名单对象
*
* @return Whitelist
*/
public function Whitelist()
{
return new Whitelist();
}
/**
* 用户单聊禁言
*
* @return Ban
*/
public function Ban()
{
return new Ban();
}
/**
* 用户推送备注
*
* @return Remark
*/
public function Remark()
{
return new Remark();
}
/**
* 用户免打扰时间段
*
* @return Remark
*/
public function BlockPushPeriod()
{
return new BlockPushPeriod();
}
/**
* 用户信息托管
*
* @return Profile
*/
public function Profile()
{
return new Profile();
}
}