Compare commits

..

10 Commits

Author SHA1 Message Date
Amast
59f6635936 Fix 2019-12-12 14:40:51 +08:00
Amast
83445da8b2 Fix equals 2019-12-12 14:15:02 +08:00
Amast
38f76de228 Add __toString and toDecimalPlaces method. 2019-12-12 14:12:09 +08:00
Amast
8469f4124c Add decimal util. 2019-12-12 12:58:24 +08:00
Amast
065808e0fb Update dependencies. 2019-12-02 17:30:30 +08:00
Amast
f0bdbc9bbd Fix fromException call constructor parameters fail. 2019-11-12 17:28:11 +08:00
Amast
58848bfecd Add ControllerTraits. 2019-11-01 14:54:48 +08:00
Amast
3b147cd3be Refacting ApiException response code. 2019-10-31 17:23:54 +08:00
Amast
133d8ecfe0 Add ApiSystemException class. 2019-10-31 16:37:00 +08:00
Amast
0bb1ea384a Add ApiInvalidParamException class. 2019-10-31 16:18:14 +08:00
7 changed files with 465 additions and 162 deletions

View File

@ -13,7 +13,7 @@
"PdToolKit\\": "src/"
}
},
"require": {
"illuminate/http": "^5.5"
"require-dev": {
"illuminate/http": "5.*"
}
}

445
composer.lock generated
View File

@ -1,23 +1,24 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "f807b62673cb935be7233f59ceb15f57",
"packages": [
"content-hash": "89c4efd9f30183c9f385b99df9bbda0a",
"packages": [],
"packages-dev": [
{
"name": "doctrine/inflector",
"version": "v1.3.0",
"version": "1.3.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/inflector.git",
"reference": "5527a48b7313d15261292c149e55e26eae771b0a"
"reference": "ec3a55242203ffa6a4b27c58176da97ff0a7aec1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/inflector/zipball/5527a48b7313d15261292c149e55e26eae771b0a",
"reference": "5527a48b7313d15261292c149e55e26eae771b0a",
"url": "https://api.github.com/repos/doctrine/inflector/zipball/ec3a55242203ffa6a4b27c58176da97ff0a7aec1",
"reference": "ec3a55242203ffa6a4b27c58176da97ff0a7aec1",
"shasum": "",
"mirrors": [
{
@ -48,6 +49,10 @@
"MIT"
],
"authors": [
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
@ -56,10 +61,6 @@
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
@ -77,7 +78,7 @@
"singularize",
"string"
],
"time": "2018-01-09T20:05:19+00:00"
"time": "2019-10-30T19:59:35+00:00"
},
{
"name": "illuminate/contracts",
@ -369,16 +370,16 @@
},
{
"name": "nesbot/carbon",
"version": "2.25.3",
"version": "2.27.0",
"source": {
"type": "git",
"url": "https://github.com/briannesbitt/Carbon.git",
"reference": "d07636581795383e2fea2d711212d30f941f2039"
"reference": "13b8485a8690f103bf19cba64879c218b102b726"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/d07636581795383e2fea2d711212d30f941f2039",
"reference": "d07636581795383e2fea2d711212d30f941f2039",
"url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/13b8485a8690f103bf19cba64879c218b102b726",
"reference": "13b8485a8690f103bf19cba64879c218b102b726",
"shasum": "",
"mirrors": [
{
@ -390,7 +391,7 @@
"require": {
"ext-json": "*",
"php": "^7.1.8 || ^8.0",
"symfony/translation": "^3.4 || ^4.0"
"symfony/translation": "^3.4 || ^4.0 || ^5.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.14 || ^3.0",
@ -405,6 +406,9 @@
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
},
"laravel": {
"providers": [
"Carbon\\Laravel\\ServiceProvider"
@ -438,7 +442,7 @@
"datetime",
"time"
],
"time": "2019-10-20T11:05:44+00:00"
"time": "2019-11-20T06:59:06+00:00"
},
{
"name": "psr/container",
@ -497,16 +501,16 @@
},
{
"name": "psr/log",
"version": "1.1.1",
"version": "1.1.2",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "bf73deb2b3b896a9d9c75f3f0d88185d2faa27e2"
"reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/bf73deb2b3b896a9d9c75f3f0d88185d2faa27e2",
"reference": "bf73deb2b3b896a9d9c75f3f0d88185d2faa27e2",
"url": "https://api.github.com/repos/php-fig/log/zipball/446d54b4cb6bf489fc9d75f55843658e6f25d801",
"reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801",
"shasum": "",
"mirrors": [
{
@ -546,7 +550,7 @@
"psr",
"psr-3"
],
"time": "2019-10-25T08:06:51+00:00"
"time": "2019-11-01T11:05:21+00:00"
},
{
"name": "psr/simple-cache",
@ -604,16 +608,16 @@
},
{
"name": "symfony/debug",
"version": "v4.3.5",
"version": "v4.4.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/debug.git",
"reference": "cc5c1efd0edfcfd10b354750594a46b3dd2afbbe"
"reference": "b8600a1d7d20b0e80906398bb1f50612fa074a8e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/cc5c1efd0edfcfd10b354750594a46b3dd2afbbe",
"reference": "cc5c1efd0edfcfd10b354750594a46b3dd2afbbe",
"url": "https://api.github.com/repos/symfony/debug/zipball/b8600a1d7d20b0e80906398bb1f50612fa074a8e",
"reference": "b8600a1d7d20b0e80906398bb1f50612fa074a8e",
"shasum": "",
"mirrors": [
{
@ -630,12 +634,12 @@
"symfony/http-kernel": "<3.4"
},
"require-dev": {
"symfony/http-kernel": "~3.4|~4.0"
"symfony/http-kernel": "^3.4|^4.0|^5.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.3-dev"
"dev-master": "4.4-dev"
}
},
"autoload": {
@ -662,20 +666,82 @@
],
"description": "Symfony Debug Component",
"homepage": "https://symfony.com",
"time": "2019-09-19T15:51:53+00:00"
"time": "2019-11-28T13:33:56+00:00"
},
{
"name": "symfony/event-dispatcher",
"version": "v4.3.5",
"name": "symfony/error-handler",
"version": "v4.4.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
"reference": "6229f58993e5a157f6096fc7145c0717d0be8807"
"url": "https://github.com/symfony/error-handler.git",
"reference": "a1ad02d62789efed1d2b2796f1c15e0c6a00fc3b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/6229f58993e5a157f6096fc7145c0717d0be8807",
"reference": "6229f58993e5a157f6096fc7145c0717d0be8807",
"url": "https://api.github.com/repos/symfony/error-handler/zipball/a1ad02d62789efed1d2b2796f1c15e0c6a00fc3b",
"reference": "a1ad02d62789efed1d2b2796f1c15e0c6a00fc3b",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": "^7.1.3",
"psr/log": "~1.0",
"symfony/debug": "^4.4",
"symfony/var-dumper": "^4.4|^5.0"
},
"require-dev": {
"symfony/http-kernel": "^4.4|^5.0",
"symfony/serializer": "^4.4|^5.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.4-dev"
}
},
"autoload": {
"psr-4": {
"Symfony\\Component\\ErrorHandler\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony ErrorHandler Component",
"homepage": "https://symfony.com",
"time": "2019-12-01T08:46:01+00:00"
},
{
"name": "symfony/event-dispatcher",
"version": "v4.4.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
"reference": "b3c3068a72623287550fe20b84a2b01dcba2686f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/b3c3068a72623287550fe20b84a2b01dcba2686f",
"reference": "b3c3068a72623287550fe20b84a2b01dcba2686f",
"shasum": "",
"mirrors": [
{
@ -697,12 +763,12 @@
},
"require-dev": {
"psr/log": "~1.0",
"symfony/config": "~3.4|~4.0",
"symfony/dependency-injection": "~3.4|~4.0",
"symfony/expression-language": "~3.4|~4.0",
"symfony/http-foundation": "^3.4|^4.0",
"symfony/service-contracts": "^1.1",
"symfony/stopwatch": "~3.4|~4.0"
"symfony/config": "^3.4|^4.0|^5.0",
"symfony/dependency-injection": "^3.4|^4.0|^5.0",
"symfony/expression-language": "^3.4|^4.0|^5.0",
"symfony/http-foundation": "^3.4|^4.0|^5.0",
"symfony/service-contracts": "^1.1|^2",
"symfony/stopwatch": "^3.4|^4.0|^5.0"
},
"suggest": {
"symfony/dependency-injection": "",
@ -711,7 +777,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.3-dev"
"dev-master": "4.4-dev"
}
},
"autoload": {
@ -738,7 +804,7 @@
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com",
"time": "2019-10-01T16:40:32+00:00"
"time": "2019-11-28T13:33:56+00:00"
},
{
"name": "symfony/event-dispatcher-contracts",
@ -806,16 +872,16 @@
},
{
"name": "symfony/finder",
"version": "v4.3.5",
"version": "v4.4.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "5e575faa95548d0586f6bedaeabec259714e44d1"
"reference": "ce8743441da64c41e2a667b8eb66070444ed911e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/5e575faa95548d0586f6bedaeabec259714e44d1",
"reference": "5e575faa95548d0586f6bedaeabec259714e44d1",
"url": "https://api.github.com/repos/symfony/finder/zipball/ce8743441da64c41e2a667b8eb66070444ed911e",
"reference": "ce8743441da64c41e2a667b8eb66070444ed911e",
"shasum": "",
"mirrors": [
{
@ -830,7 +896,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.3-dev"
"dev-master": "4.4-dev"
}
},
"autoload": {
@ -857,20 +923,20 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
"time": "2019-09-16T11:29:48+00:00"
"time": "2019-11-17T21:56:56+00:00"
},
{
"name": "symfony/http-foundation",
"version": "v4.3.5",
"version": "v4.4.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-foundation.git",
"reference": "76590ced16d4674780863471bae10452b79210a5"
"reference": "8bccc59e61b41963d14c3dbdb23181e5c932a1d5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/76590ced16d4674780863471bae10452b79210a5",
"reference": "76590ced16d4674780863471bae10452b79210a5",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/8bccc59e61b41963d14c3dbdb23181e5c932a1d5",
"reference": "8bccc59e61b41963d14c3dbdb23181e5c932a1d5",
"shasum": "",
"mirrors": [
{
@ -881,17 +947,17 @@
},
"require": {
"php": "^7.1.3",
"symfony/mime": "^4.3",
"symfony/mime": "^4.3|^5.0",
"symfony/polyfill-mbstring": "~1.1"
},
"require-dev": {
"predis/predis": "~1.0",
"symfony/expression-language": "~3.4|~4.0"
"symfony/expression-language": "^3.4|^4.0|^5.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.3-dev"
"dev-master": "4.4-dev"
}
},
"autoload": {
@ -918,20 +984,20 @@
],
"description": "Symfony HttpFoundation Component",
"homepage": "https://symfony.com",
"time": "2019-10-04T19:48:13+00:00"
"time": "2019-11-28T13:33:56+00:00"
},
{
"name": "symfony/http-kernel",
"version": "v4.3.5",
"version": "v4.4.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-kernel.git",
"reference": "5f08141850932e8019c01d8988bf3ed6367d2991"
"reference": "e4187780ed26129ee86d5234afbebf085e144f88"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/5f08141850932e8019c01d8988bf3ed6367d2991",
"reference": "5f08141850932e8019c01d8988bf3ed6367d2991",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/e4187780ed26129ee86d5234afbebf085e144f88",
"reference": "e4187780ed26129ee86d5234afbebf085e144f88",
"shasum": "",
"mirrors": [
{
@ -943,18 +1009,18 @@
"require": {
"php": "^7.1.3",
"psr/log": "~1.0",
"symfony/debug": "~3.4|~4.0",
"symfony/event-dispatcher": "^4.3",
"symfony/http-foundation": "^4.1.1",
"symfony/polyfill-ctype": "~1.8",
"symfony/error-handler": "^4.4",
"symfony/event-dispatcher": "^4.4",
"symfony/http-foundation": "^4.4|^5.0",
"symfony/polyfill-ctype": "^1.8",
"symfony/polyfill-php73": "^1.9"
},
"conflict": {
"symfony/browser-kit": "<4.3",
"symfony/config": "<3.4",
"symfony/console": ">=5",
"symfony/dependency-injection": "<4.3",
"symfony/translation": "<4.2",
"symfony/var-dumper": "<4.1.1",
"twig/twig": "<1.34|<2.4,>=2"
},
"provide": {
@ -962,34 +1028,32 @@
},
"require-dev": {
"psr/cache": "~1.0",
"symfony/browser-kit": "^4.3",
"symfony/config": "~3.4|~4.0",
"symfony/console": "~3.4|~4.0",
"symfony/css-selector": "~3.4|~4.0",
"symfony/dependency-injection": "^4.3",
"symfony/dom-crawler": "~3.4|~4.0",
"symfony/expression-language": "~3.4|~4.0",
"symfony/finder": "~3.4|~4.0",
"symfony/process": "~3.4|~4.0",
"symfony/routing": "~3.4|~4.0",
"symfony/stopwatch": "~3.4|~4.0",
"symfony/templating": "~3.4|~4.0",
"symfony/translation": "~4.2",
"symfony/translation-contracts": "^1.1",
"symfony/var-dumper": "^4.1.1",
"twig/twig": "^1.34|^2.4"
"symfony/browser-kit": "^4.3|^5.0",
"symfony/config": "^3.4|^4.0|^5.0",
"symfony/console": "^3.4|^4.0",
"symfony/css-selector": "^3.4|^4.0|^5.0",
"symfony/dependency-injection": "^4.3|^5.0",
"symfony/dom-crawler": "^3.4|^4.0|^5.0",
"symfony/expression-language": "^3.4|^4.0|^5.0",
"symfony/finder": "^3.4|^4.0|^5.0",
"symfony/process": "^3.4|^4.0|^5.0",
"symfony/routing": "^3.4|^4.0|^5.0",
"symfony/stopwatch": "^3.4|^4.0|^5.0",
"symfony/templating": "^3.4|^4.0|^5.0",
"symfony/translation": "^4.2|^5.0",
"symfony/translation-contracts": "^1.1|^2",
"twig/twig": "^1.34|^2.4|^3.0"
},
"suggest": {
"symfony/browser-kit": "",
"symfony/config": "",
"symfony/console": "",
"symfony/dependency-injection": "",
"symfony/var-dumper": ""
"symfony/dependency-injection": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.3-dev"
"dev-master": "4.4-dev"
}
},
"autoload": {
@ -1016,20 +1080,20 @@
],
"description": "Symfony HttpKernel Component",
"homepage": "https://symfony.com",
"time": "2019-10-07T15:06:41+00:00"
"time": "2019-12-01T14:06:38+00:00"
},
{
"name": "symfony/mime",
"version": "v4.3.5",
"version": "v5.0.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/mime.git",
"reference": "32f71570547b91879fdbd9cf50317d556ae86916"
"reference": "0e6a4ced216e49d457eddcefb61132173a876d79"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/mime/zipball/32f71570547b91879fdbd9cf50317d556ae86916",
"reference": "32f71570547b91879fdbd9cf50317d556ae86916",
"url": "https://api.github.com/repos/symfony/mime/zipball/0e6a4ced216e49d457eddcefb61132173a876d79",
"reference": "0e6a4ced216e49d457eddcefb61132173a876d79",
"shasum": "",
"mirrors": [
{
@ -1039,18 +1103,21 @@
]
},
"require": {
"php": "^7.1.3",
"php": "^7.2.5",
"symfony/polyfill-intl-idn": "^1.10",
"symfony/polyfill-mbstring": "^1.0"
},
"conflict": {
"symfony/mailer": "<4.4"
},
"require-dev": {
"egulias/email-validator": "^2.1.10",
"symfony/dependency-injection": "~3.4|^4.1"
"symfony/dependency-injection": "^4.4|^5.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.3-dev"
"dev-master": "5.0-dev"
}
},
"autoload": {
@ -1081,20 +1148,20 @@
"mime",
"mime-type"
],
"time": "2019-09-19T17:00:15+00:00"
"time": "2019-11-30T14:12:50+00:00"
},
{
"name": "symfony/polyfill-ctype",
"version": "v1.12.0",
"version": "v1.13.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "550ebaac289296ce228a706d0867afc34687e3f4"
"reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/550ebaac289296ce228a706d0867afc34687e3f4",
"reference": "550ebaac289296ce228a706d0867afc34687e3f4",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f8f0b461be3385e56d6de3dbb5a0df24c0c275e3",
"reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3",
"shasum": "",
"mirrors": [
{
@ -1112,7 +1179,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.12-dev"
"dev-master": "1.13-dev"
}
},
"autoload": {
@ -1145,20 +1212,20 @@
"polyfill",
"portable"
],
"time": "2019-08-06T08:03:45+00:00"
"time": "2019-11-27T13:56:44+00:00"
},
{
"name": "symfony/polyfill-intl-idn",
"version": "v1.12.0",
"version": "v1.13.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-idn.git",
"reference": "6af626ae6fa37d396dc90a399c0ff08e5cfc45b2"
"reference": "6f9c239e61e1b0c9229a28ff89a812dc449c3d46"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/6af626ae6fa37d396dc90a399c0ff08e5cfc45b2",
"reference": "6af626ae6fa37d396dc90a399c0ff08e5cfc45b2",
"url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/6f9c239e61e1b0c9229a28ff89a812dc449c3d46",
"reference": "6f9c239e61e1b0c9229a28ff89a812dc449c3d46",
"shasum": "",
"mirrors": [
{
@ -1178,7 +1245,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.12-dev"
"dev-master": "1.13-dev"
}
},
"autoload": {
@ -1213,20 +1280,20 @@
"portable",
"shim"
],
"time": "2019-08-06T08:03:45+00:00"
"time": "2019-11-27T13:56:44+00:00"
},
{
"name": "symfony/polyfill-mbstring",
"version": "v1.12.0",
"version": "v1.13.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-mbstring.git",
"reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17"
"reference": "7b4aab9743c30be783b73de055d24a39cf4b954f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/b42a2f66e8f1b15ccf25652c3424265923eb4f17",
"reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17",
"url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7b4aab9743c30be783b73de055d24a39cf4b954f",
"reference": "7b4aab9743c30be783b73de055d24a39cf4b954f",
"shasum": "",
"mirrors": [
{
@ -1244,7 +1311,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.12-dev"
"dev-master": "1.13-dev"
}
},
"autoload": {
@ -1278,20 +1345,20 @@
"portable",
"shim"
],
"time": "2019-08-06T08:03:45+00:00"
"time": "2019-11-27T14:18:11+00:00"
},
{
"name": "symfony/polyfill-php72",
"version": "v1.12.0",
"version": "v1.13.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php72.git",
"reference": "04ce3335667451138df4307d6a9b61565560199e"
"reference": "66fea50f6cb37a35eea048d75a7d99a45b586038"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/04ce3335667451138df4307d6a9b61565560199e",
"reference": "04ce3335667451138df4307d6a9b61565560199e",
"url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/66fea50f6cb37a35eea048d75a7d99a45b586038",
"reference": "66fea50f6cb37a35eea048d75a7d99a45b586038",
"shasum": "",
"mirrors": [
{
@ -1306,7 +1373,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.12-dev"
"dev-master": "1.13-dev"
}
},
"autoload": {
@ -1339,20 +1406,20 @@
"portable",
"shim"
],
"time": "2019-08-06T08:03:45+00:00"
"time": "2019-11-27T13:56:44+00:00"
},
{
"name": "symfony/polyfill-php73",
"version": "v1.12.0",
"version": "v1.13.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-php73.git",
"reference": "2ceb49eaccb9352bff54d22570276bb75ba4a188"
"reference": "4b0e2222c55a25b4541305a053013d5647d3a25f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/2ceb49eaccb9352bff54d22570276bb75ba4a188",
"reference": "2ceb49eaccb9352bff54d22570276bb75ba4a188",
"url": "https://api.github.com/repos/symfony/polyfill-php73/zipball/4b0e2222c55a25b4541305a053013d5647d3a25f",
"reference": "4b0e2222c55a25b4541305a053013d5647d3a25f",
"shasum": "",
"mirrors": [
{
@ -1367,7 +1434,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.12-dev"
"dev-master": "1.13-dev"
}
},
"autoload": {
@ -1403,20 +1470,20 @@
"portable",
"shim"
],
"time": "2019-08-06T08:03:45+00:00"
"time": "2019-11-27T16:25:15+00:00"
},
{
"name": "symfony/translation",
"version": "v4.3.5",
"version": "v4.4.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation.git",
"reference": "fe6193b066c457c144333c06aaa869a2d42a167f"
"reference": "897fb68ee7933372517b551d6f08c6d4bb0b8c40"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/fe6193b066c457c144333c06aaa869a2d42a167f",
"reference": "fe6193b066c457c144333c06aaa869a2d42a167f",
"url": "https://api.github.com/repos/symfony/translation/zipball/897fb68ee7933372517b551d6f08c6d4bb0b8c40",
"reference": "897fb68ee7933372517b551d6f08c6d4bb0b8c40",
"shasum": "",
"mirrors": [
{
@ -1428,11 +1495,12 @@
"require": {
"php": "^7.1.3",
"symfony/polyfill-mbstring": "~1.0",
"symfony/translation-contracts": "^1.1.6"
"symfony/translation-contracts": "^1.1.6|^2"
},
"conflict": {
"symfony/config": "<3.4",
"symfony/dependency-injection": "<3.4",
"symfony/http-kernel": "<4.4",
"symfony/yaml": "<3.4"
},
"provide": {
@ -1440,15 +1508,14 @@
},
"require-dev": {
"psr/log": "~1.0",
"symfony/config": "~3.4|~4.0",
"symfony/console": "~3.4|~4.0",
"symfony/dependency-injection": "~3.4|~4.0",
"symfony/finder": "~2.8|~3.0|~4.0",
"symfony/http-kernel": "~3.4|~4.0",
"symfony/intl": "~3.4|~4.0",
"symfony/service-contracts": "^1.1.2",
"symfony/var-dumper": "~3.4|~4.0",
"symfony/yaml": "~3.4|~4.0"
"symfony/config": "^3.4|^4.0|^5.0",
"symfony/console": "^3.4|^4.0|^5.0",
"symfony/dependency-injection": "^3.4|^4.0|^5.0",
"symfony/finder": "~2.8|~3.0|~4.0|^5.0",
"symfony/http-kernel": "^4.4",
"symfony/intl": "^3.4|^4.0|^5.0",
"symfony/service-contracts": "^1.1.2|^2",
"symfony/yaml": "^3.4|^4.0|^5.0"
},
"suggest": {
"psr/log-implementation": "To use logging capability in translator",
@ -1458,7 +1525,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.3-dev"
"dev-master": "4.4-dev"
}
},
"autoload": {
@ -1485,20 +1552,20 @@
],
"description": "Symfony Translation Component",
"homepage": "https://symfony.com",
"time": "2019-09-27T14:37:39+00:00"
"time": "2019-11-12T17:18:47+00:00"
},
{
"name": "symfony/translation-contracts",
"version": "v1.1.7",
"version": "v2.0.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation-contracts.git",
"reference": "364518c132c95642e530d9b2d217acbc2ccac3e6"
"reference": "8cc682ac458d75557203b2f2f14b0b92e1c744ed"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/translation-contracts/zipball/364518c132c95642e530d9b2d217acbc2ccac3e6",
"reference": "364518c132c95642e530d9b2d217acbc2ccac3e6",
"url": "https://api.github.com/repos/symfony/translation-contracts/zipball/8cc682ac458d75557203b2f2f14b0b92e1c744ed",
"reference": "8cc682ac458d75557203b2f2f14b0b92e1c744ed",
"shasum": "",
"mirrors": [
{
@ -1508,7 +1575,7 @@
]
},
"require": {
"php": "^7.1.3"
"php": "^7.2.5"
},
"suggest": {
"symfony/translation-implementation": ""
@ -1516,7 +1583,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1-dev"
"dev-master": "2.0-dev"
}
},
"autoload": {
@ -1548,10 +1615,90 @@
"interoperability",
"standards"
],
"time": "2019-09-17T11:12:18+00:00"
"time": "2019-11-18T17:27:11+00:00"
},
{
"name": "symfony/var-dumper",
"version": "v5.0.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-dumper.git",
"reference": "a4862009387721e155be6dc115061f42ee209205"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/a4862009387721e155be6dc115061f42ee209205",
"reference": "a4862009387721e155be6dc115061f42ee209205",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": "^7.2.5",
"symfony/polyfill-mbstring": "~1.0"
},
"conflict": {
"phpunit/phpunit": "<5.4.3",
"symfony/console": "<4.4"
},
"require-dev": {
"ext-iconv": "*",
"symfony/console": "^4.4|^5.0",
"symfony/process": "^4.4|^5.0",
"twig/twig": "^2.4|^3.0"
},
"suggest": {
"ext-iconv": "To convert non-UTF-8 strings to UTF-8 (or symfony/polyfill-iconv in case ext-iconv cannot be used).",
"ext-intl": "To show region name in time zone dump",
"symfony/console": "To use the ServerDumpCommand and/or the bin/var-dump-server script"
},
"bin": [
"Resources/bin/var-dump-server"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "5.0-dev"
}
},
"autoload": {
"files": [
"Resources/functions/dump.php"
],
"psr-4": {
"Symfony\\Component\\VarDumper\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony mechanism for exploring and dumping PHP variables",
"homepage": "https://symfony.com",
"keywords": [
"debug",
"dump"
],
"time": "2019-11-28T14:20:16+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],

View File

@ -12,26 +12,21 @@ class ApiException extends Exception
* 返回到接口的验证码
* @var int $response_code
*/
protected $response_code = 0;
protected $response_code = 400000;
/**
* ApiException constructor.
* @param string $message
* @param int $response_code
* @param Throwable|null $previous
*/
public function __construct(
$message,
$response_code = 400000,
Throwable $previous = null
) {
parent::__construct($message, 0, $previous);
$this->response_code = $response_code;
public function __construct(string $message, Throwable $previous = null)
{
parent::__construct($message, $this->response_code, $previous);
}
public static function formException(Exception $e, $response_code = 400000)
public static function fromException(Exception $e)
{
return new ApiException($e->getMessage(), $response_code, $e);
return new ApiException($e->getMessage(), $e);
}
/**

View File

@ -0,0 +1,8 @@
<?php
namespace PdToolKit\Exceptions;
class ApiInvalidParamException extends ApiException
{
protected $response_code = 400400;
}

View File

@ -0,0 +1,15 @@
<?php
namespace PdToolKit\Exceptions;
use Throwable;
class ApiSystemException extends ApiException
{
protected $response_code = 400000;
public function __construct($message = "网络波动,稍后再试", Throwable $previous = null)
{
parent::__construct($message, $previous);
}
}

View File

@ -0,0 +1,42 @@
<?php
namespace PdToolKit\Traits;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Str;
use PdToolKit\Exceptions\ApiException;
use PdToolKit\Exceptions\ApiInvalidParamException;
trait ControllerTraits
{
public function success($data = null, $message = '请求成功')
{
return new JsonResponse([
'code' => 0,
'message' => $message,
'data' => $data,
]);
}
/**
* @param Request $request
* @param array $rules
* @param array $messages
* @param array $customAttributes
* @return array
* @throws ApiException
*/
public function validateRequestParams(Request $request, array $rules, array $messages = [], array $customAttributes = [])
{
$validator = Validator::make($request->all(), $rules, $messages, $customAttributes);
if ($validator->fails()) {
throw new ApiInvalidParamException($validator->errors()->first());
}
return $request->only(collect($rules)->keys()->map(function ($rule) {
return Str::contains($rule, '.') ? explode('.', $rule)[0] : $rule;
})->unique()->toArray());
}
}

96
src/Utils/Decimal.php Normal file
View File

@ -0,0 +1,96 @@
<?php
namespace PdToolKit\Utils;
use Illuminate\Support\Arr;
/**
* Class Decimal
* @package PdToolKit\Utils
* @method Decimal add(int|float|string|Decimal $v);
* @method Decimal sub(int|float|string|Decimal $v);
* @method Decimal mul(int|float|string|Decimal $v);
* @method Decimal div(int|float|string|Decimal $v);
*/
class Decimal
{
protected $source;
protected $dp;
// Rounds away from zero.
const ROUND_UP = 0;
// Rounds towards zero.
const ROUND_DOWN = 1;
function __construct($v, int $dp = 8)
{
if (!$this->isNumeric($v)) {
throw new \Exception("value type must be int|float|string|Decimal.");
}
$this->dp = $dp;
$val = $v instanceof Decimal ? $v->getSource() : $v;
$this->source = bcadd($val, "0", $dp);
}
private function isNumeric($v)
{
if ($v instanceof Decimal) return true;
return is_numeric($v);
}
function getSource()
{
return $this->source;
}
function __call($name, $arguments)
{
$methods = ['add', 'sub', 'mul', 'div'];
if (in_array($name, $methods)) {
$method = "bc$name";
$v = new Decimal($arguments[0]);
return new Decimal($method($this->source, $v->getSource()));
}
throw new \Exception("method $name not found.");
}
function __toString(): string
{
return $this->source;
}
function equals($v): bool
{
return (new Decimal($v))->getSource() == new Decimal($this->source);
}
function toDecimalPlaces(int $dp, int $rm = self::ROUND_UP): Decimal
{
return new Decimal($this->toFixed($dp, $rm), $dp);
}
function toFixed(int $dp, int $rm = self::ROUND_UP): string
{
if ($rm == self::ROUND_UP) {
return number_format($this->source, $dp, ".", "");
}
if ($rm == self::ROUND_DOWN) {
return bcadd($this->source, 0, $dp);
}
throw new \Exception("$rm must be " . self::ROUND_UP . ' or ' . self::ROUND_DOWN);
}
function toInt(): int
{
return (int) $this->source;
}
function toFloat(): float
{
return (float) $this->source;
}
}