commit | author | age
|
b5d693
|
1 |
<?php |
W |
2 |
|
|
3 |
/** |
|
4 |
* 获取用户数据相关 Api |
|
5 |
* 王腾宇 |
|
6 |
*/ |
|
7 |
require '../framework/bootstrap.inc.php'; |
|
8 |
require '../web/common/interface.func.php'; |
|
9 |
|
|
10 |
|
|
11 |
if($_SERVER['REQUEST_METHOD'] != 'POST'){ |
|
12 |
http_response_code(405); |
|
13 |
} else { |
|
14 |
$retData=checkParam($_GET); |
|
15 |
switch ($retData["regMsg"]){ |
|
16 |
case "e00000": |
|
17 |
$userApi = new UserApi(); |
|
18 |
switch (getUrl($_SERVER['REQUEST_URI'])) |
|
19 |
{ |
|
20 |
case "getUserList": |
|
21 |
exit($userApi->getUserList($retData["regData"])); |
|
22 |
break; |
|
23 |
case "getUserOrderList": |
|
24 |
exit($userApi->getUserOrderList($retData["regData"])); |
|
25 |
break; |
|
26 |
default: http_response_code(404); |
|
27 |
} |
|
28 |
case "e00001": |
|
29 |
exit(array( |
|
30 |
"rspCode"=>"e00001", |
|
31 |
"rspMsg"=>"接入平台不存在" |
|
32 |
)); |
|
33 |
case "e00002": |
|
34 |
exit(array( |
|
35 |
"rspCode"=>"e00002", |
|
36 |
"rspMsg"=>"鉴权失败" |
|
37 |
)); |
|
38 |
} |
|
39 |
} |
|
40 |
|
|
41 |
|
|
42 |
class UserApi |
|
43 |
{ |
|
44 |
static $db; |
|
45 |
|
|
46 |
function _initialize() |
|
47 |
{ |
|
48 |
$db = $this-> pdo(); |
|
49 |
} |
|
50 |
function pdo() { |
|
51 |
static $db; |
|
52 |
global $_W; |
|
53 |
if(empty($db)) { |
|
54 |
if($_W['config']['db']['slave_status'] == true && !empty($_W['config']['db']['slave'])) { |
|
55 |
load()->classs('slave.db'); |
|
56 |
$db = new SlaveDb('master'); |
|
57 |
} else { |
|
58 |
load()->classs('db'); |
|
59 |
if(empty($_W['config']['db']['master'])) { |
|
60 |
$_W['config']['db']['master'] = $GLOBALS['_W']['config']['db']; |
|
61 |
$db = new DB($_W['config']['db']); |
|
62 |
} else { |
|
63 |
$db = new DB('master'); |
|
64 |
} |
|
65 |
} |
|
66 |
} |
|
67 |
return $db; |
|
68 |
} |
|
69 |
|
|
70 |
public function getUserList($param) |
|
71 |
{ |
|
72 |
return json_encode($param,JSON_UNESCAPED_UNICODE); |
|
73 |
} |
|
74 |
|
|
75 |
public function getUserOrderList($param) |
|
76 |
{ |
|
77 |
return json_encode($param,JSON_UNESCAPED_UNICODE); |
|
78 |
} |
|
79 |
} |