-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathRemark.php
121 lines (112 loc) · 2.72 KB
/
Remark.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
<?php
/**
* User backup note
*/
namespace RongCloud\Lib\User\Remark;
use RongCloud\Lib\Request;
use RongCloud\Lib\Utils;
class Remark {
/**
* User Module User Notes
*
* @var string
*/
private $jsonPath = 'Lib/User/Remark/';
/**
* Request configuration file
*
* @var string
*/
private $conf = '';
/**
* Validate configuration file
*
* @var string
*/
private $verify = '';
/**
* User constructor.
*/
function __construct()
{
// Initialize request configuration and validate file path
$this->conf = Utils::getJson($this->jsonPath.'api.json');
$this->verify = Utils::getJson($this->jsonPath.'../verify.json');
}
/**
* Add user remark
*
* @param array $User
* @param
* $User = [
* 'userId'=> 'ujadk90ha1',//User ID
* 'remark'=> [
* ["id"=>'userid',"remark"=>'Remark2'],
* ["id"=>'userid2',"remark"=>'Remark2']
* ]//User remark
* ];
* @return array
*/
public function set(array $User=[]){
$conf = $this->conf['set'];
$error = (new Utils())->check([
'api'=> $conf,
'model'=> 'user',
'data'=> $User,
'verify'=> $this->verify['remark']
]);
if($error) return $error;
$result = (new Request())->Request($conf['url'],$User);
$result = (new Utils())->responseError($result, $conf['response']['fail']);
return $result;
}
/**
* Delete user remark
*
* @param array $User
* @param
* $User = [
* 'userId'=> 'ujadk90ha1',//User ID
* 'targetId'=> 'targetUserid'//User remark
* ];
* @return array
*/
public function del(array $User=[]){
$conf = $this->conf['del'];
$error = (new Utils())->check([
'api'=> $conf,
'model'=> 'user',
'data'=> $User,
'verify'=> $this->verify['remark']
]);
if($error) return $error;
$result = (new Request())->Request($conf['url'],$User);
$result = (new Utils())->responseError($result, $conf['response']['fail']);
return $result;
}
/**
* Get user annotation
* @param array $User
* @param
* $User = [
* 'userId'=> 'ujadk90ha1', // User ID
* 'size'=> 50 // Default 50
* 'page' => 1 // Default first page
* ];
* @return array
* @return array
*/
public function get(array $User=[]){
$conf = $this->conf['get'];
$error = (new Utils())->check([
'api'=> $conf,
'model'=> 'user',
'data'=> $User,
'verify'=> $this->verify['remark']
]);
if($error) return $error;
$result = (new Request())->Request($conf['url'],$User);
$result = (new Utils())->responseError($result, $conf['response']['fail']);
return $result;
}
}