Repository navigation
Expand file tree
/
Copy pathApi_Sync_CheckController.php
More file actions
75 lines (62 loc) · 2.01 KB
/
Copy pathApi_Sync_CheckController.php
File metadata and controls
75 lines (62 loc) · 2.01 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
<?php
/**
* Created by PhpStorm.
* User: anguoyue
* Date: 03/08/2018
* Time: 9:02 PM
*/
class Api_Sync_CheckController extends BaseController
{
/**
* @var string
*/
protected $action = "api.sync.check";
private $classNameForRequest = '\Zaly\Proto\Site\ApiSyncCheckRequest';
private $classNameForResponse = '\Zaly\Proto\Site\ApiSyncCheckResponse';
public function rpcRequestClassName()
{
return $this->classNameForRequest;
}
/**
* @param \Zaly\Proto\Site\ApiSyncCheckRequest $request
* @param \Google\Protobuf\Internal\Message $transportData
*/
public function rpc(\Google\Protobuf\Internal\Message $request, \Google\Protobuf\Internal\Message $transportData)
{
$tag = __CLASS__ . "->" . __FUNCTION__;
$userId = $this->userId;
$request->getLocalVersion();
$type = $request->getType();
$response = new \Zaly\Proto\Site\ApiSyncCheckResponse();
try {
switch ($type) {
case \Zaly\Proto\Site\ApiSyncType::ApiSyncFriendList:
$friendVerion = $this->getUserFriendVersion($userId);
$response->setVersion($friendVerion);
$this->setRpcError($this->defaultErrorCode, "");
break;
case \Zaly\Proto\Site\ApiSyncType::ApiSyncInvalid:
$this->setRpcError("error.notExists", "");
break;
}
} catch (Exception $e) {
$this->setRpcError("error.alert", "");
$this->ctx->wpf_Logger->error($tag, $e);
}
$this->rpcReturn($this->action, $response);
}
/**
* @param $userId
* @return int
*/
private function getUserFriendVersion($userId)
{
$tag = __CLASS__ . "->" . __FUNCTION__;
try {
return $this->ctx->SiteUserTable->getUserFriendVersion($userId);
} catch (Exception $e) {
$this->ctx->Wpf_Logger->error($tag, $e);
}
return 0;
}
}