ComposerUpdate

This commit is contained in:
Anyon 2019-12-17 18:30:22 +08:00
parent c2f9f8ed6a
commit 5325601793
7 changed files with 42 additions and 45 deletions

8
composer.lock generated
View File

@ -909,12 +909,12 @@
"source": {
"type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "ca6df0b64b3d22c210260a218bb31134661c881d"
"reference": "1f0c1902fcab3cd7d257f79d607712619a4b660e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/ca6df0b64b3d22c210260a218bb31134661c881d",
"reference": "ca6df0b64b3d22c210260a218bb31134661c881d",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/1f0c1902fcab3cd7d257f79d607712619a4b660e",
"reference": "1f0c1902fcab3cd7d257f79d607712619a4b660e",
"shasum": "",
"mirrors": [
{
@ -958,7 +958,7 @@
],
"description": "ThinkPHP v6.0 Development Library",
"homepage": "http://framework.thinkadmin.top",
"time": "2019-12-16T03:27:06+00:00"
"time": "2019-12-17T10:24:30+00:00"
},
{
"name": "zoujingli/wechat-developer",

View File

@ -935,12 +935,12 @@
"source": {
"type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git",
"reference": "ca6df0b64b3d22c210260a218bb31134661c881d"
"reference": "1f0c1902fcab3cd7d257f79d607712619a4b660e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/ca6df0b64b3d22c210260a218bb31134661c881d",
"reference": "ca6df0b64b3d22c210260a218bb31134661c881d",
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/1f0c1902fcab3cd7d257f79d607712619a4b660e",
"reference": "1f0c1902fcab3cd7d257f79d607712619a4b660e",
"shasum": "",
"mirrors": [
{
@ -956,7 +956,7 @@
"ext-json": "*",
"topthink/framework": "^6.0"
},
"time": "2019-12-16T03:27:06+00:00",
"time": "2019-12-17T10:24:30+00:00",
"type": "library",
"extra": {
"think": {

2
vendor/services.php vendored
View File

@ -1,5 +1,5 @@
<?php
// This file is automatically generated at:2019-12-16 11:42:37
// This file is automatically generated at:2019-12-17 18:30:13
declare (strict_types = 1);
return array (
0 => 'think\\app\\Service',

View File

@ -52,10 +52,11 @@ class Install extends Command
*/
protected $bind = [
'admin' => [
'rules' => [
'think',
'app/admin',
],
'rules' => ['think', 'app/admin'],
'ignore' => [],
],
'wechat' => [
'rules' => ['app/wechat'],
'ignore' => [],
],
'static' => [

View File

@ -166,10 +166,9 @@ class InstallService extends Service
foreach ($local as $t) $_local[$t['name']] = $t;
unset($serve, $local);
// 线上数据差异计算
foreach ($_serve as $t) if (isset($_local[$t['name']])) array_push($_new, [
foreach ($_serve as $t) isset($_local[$t['name']]) ? array_push($_new, [
'type' => $t['hash'] === $_local[$t['name']]['hash'] ? null : 'mod', 'name' => $t['name'],
]);
else array_push($_new, ['type' => 'add', 'name' => $t['name']]);
]) : array_push($_new, ['type' => 'add', 'name' => $t['name']]);
// 本地数据增量计算
foreach ($_local as $t) if (!isset($_serve[$t['name']])) array_push($_new, ['type' => 'del', 'name' => $t['name']]);
unset($_serve, $_local);

View File

@ -44,35 +44,28 @@ class JsonRpcClientService extends Service
*/
public function create($proxy)
{
$this->proxy = $proxy;
$this->requestid = CodeExtend::uniqidNumber();
$this->proxy = $proxy;
return $this;
}
/**
* 执行 JsonRCP 请求
* 执行 JsonRpc 请求
* @param string $method
* @param array $params
* @return array|boolean
* @return mixed
* @throws \think\Exception
*/
public function __call($method, $params)
{
// check
if (!is_scalar($method)) {
throw new \think\Exception('Method name has no scalar value');
}
// check
if (is_array($params)) {
$params = array_values($params);
} else {
throw new \think\Exception('Params must be given as array');
}
// performs the HTTP POST
// Performs the HTTP POST
$options = [
'http' => [
'method' => 'POST', 'header' => 'Content-type: application/json',
'content' => json_encode(['method' => $method, 'params' => $params, 'id' => $this->requestid], JSON_UNESCAPED_UNICODE),
'method' => 'POST',
'header' => 'Content-type: application/json',
'content' => json_encode([
'jsonrpc' => '2.0', 'method' => $method, 'params' => $params, 'id' => $this->requestid,
], JSON_UNESCAPED_UNICODE),
],
];
if ($fp = fopen($this->proxy, 'r', false, stream_context_create($options))) {
@ -81,16 +74,16 @@ class JsonRpcClientService extends Service
fclose($fp);
$response = json_decode($response, true);
} else {
throw new \think\Exception("Unable to connect to {$this->proxy}");
throw new \think\Exception("无法连接到 {$this->proxy}");
}
// final checks and return
// Final checks and return
if ($response['id'] != $this->requestid) {
throw new \think\Exception("Incorrect response id (request id: {$this->requestid}, response id: {$response['id']}");
throw new \think\Exception("错误的响应标记 (请求标记: {$this->requestid}, 响应标记: {$response['id']}");
}
if (is_null($response['error'])) {
return $response['result'];
} else {
throw new \think\Exception("Request error: {$response['error']}");
throw new \think\Exception("请求错误:[{$response['error']['code']}] {$response['error']['message']}");
}
}
}

View File

@ -28,7 +28,6 @@ class JsonRpcServerService extends Service
/**
* 设置监听对象
* @param mixed $object
* @throws \think\Exception
*/
public function handle($object)
{
@ -41,18 +40,23 @@ class JsonRpcServerService extends Service
} else {
// Reads the input data
$request = json_decode(file_get_contents('php://input'), true);
if (empty($request['id'])) {
throw new \think\Exception('JsonRpc Request id cannot be empty');
}
// Executes the task on local object
try {
if (empty($request)) {
$error = ['code' => '-32700', 'message' => '语法解析错误', 'meaning' => '服务端接收到无效的JSON'];
$response = ['jsonrpc' => '2.0', 'id' => $request['id'], 'result' => null, 'error' => $error];
} elseif (!isset($request['id']) || !isset($request['method']) || !isset($request['params'])) {
$error = ['code' => '-32600', 'message' => '无效的请求', 'meaning' => '发送的JSON不是一个有效的请求对象'];
$response = ['jsonrpc' => '2.0', 'id' => $request['id'], 'result' => null, 'error' => $error];
} else try {
// Executes the task on local object
if ($result = @call_user_func_array([$object, $request['method']], $request['params'])) {
$response = ['id' => $request['id'], 'result' => $result, 'error' => null];
$response = ['jsonrpc' => '2.0', 'id' => $request['id'], 'result' => $result, 'error' => null];
} else {
$response = ['id' => $request['id'], 'result' => null, 'error' => 'unknown method or incorrect parameters'];
$error = ['code' => '-32601', 'message' => '找不到方法', 'meaning' => '该方法不存在或无效'];
$response = ['jsonrpc' => '2.0', 'id' => $request['id'], 'result' => null, 'error' => $error];
}
} catch (\Exception $e) {
$response = ['id' => $request['id'], 'result' => null, 'error' => $e->getMessage()];
$error = ['code' => $e->getCode(), 'message' => $e->getMessage()];
$response = ['jsonrpc' => '2.0', 'id' => $request['id'], 'result' => null, 'error' => $error];
}
// Output the response
throw new HttpResponseException(json($response)->contentType('text/javascript'));