From 0b6f55b429d3766de579b1ccef1febe60e916d39 Mon Sep 17 00:00:00 2001 From: fantasticbin Date: Tue, 15 Nov 2022 16:33:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84RPC=E6=89=8B=E5=8A=A8?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E6=B6=88=E8=B4=B9=E8=80=85=E7=B1=BB=E5=A4=84?= =?UTF-8?q?=E7=90=86=E9=97=AE=E9=A2=98=E5=8F=8D=E9=A6=88=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PunchCard/User/UserController.php | 71 +++++++++++++++++++ app/Controller/TestController.php | 10 --- ...PunchCardSystemExternalServiceConsumer.php | 26 +++++++ ...unchCardSystemExternalServiceInterface.php | 16 +++++ app/JsonRpc/UserExternalServiceInterface.php | 5 +- app/Model/Model.php | 5 +- config/autoload/dependencies.php | 1 + config/autoload/services.php | 1 + 8 files changed, 119 insertions(+), 16 deletions(-) create mode 100644 app/Controller/PunchCard/User/UserController.php create mode 100644 app/JsonRpc/PunchCardSystemExternalServiceConsumer.php create mode 100644 app/JsonRpc/PunchCardSystemExternalServiceInterface.php diff --git a/app/Controller/PunchCard/User/UserController.php b/app/Controller/PunchCard/User/UserController.php new file mode 100644 index 0000000..9c41627 --- /dev/null +++ b/app/Controller/PunchCard/User/UserController.php @@ -0,0 +1,71 @@ +request->input('openid', ''); + return $this->getServiceResult($this->userExternalService->getUserInfo($openid, [ + 'user_name', + 'user_phone', + ])); + } + + /** + * 保存个人资料 + * + * @return void + */ + #[PostMapping(path: "user/save_information")] + public function saveInformation() : void + { + $phone = $this->request->input('phone', ''); + // TODO 逻辑完善 + } + + /** + * 保存问题反馈 + * + * @return array + */ + #[PostMapping(path: "user/save_feedback")] + public function saveFeedback() : array + { + return $this->getServiceResult($this->punchCardSystemExternalService->saveFeedback($this->request)); + } +} diff --git a/app/Controller/TestController.php b/app/Controller/TestController.php index 021cd3d..674b454 100644 --- a/app/Controller/TestController.php +++ b/app/Controller/TestController.php @@ -74,14 +74,4 @@ class TestController extends BaseController return new Paginator($users, $perPage, $currentPage); } - - /** - * RPC调用示例 - * - * @return array - */ - public function user_info() - { - return $this->getServiceResult($this->userService->getUserInfo()); - } } \ No newline at end of file diff --git a/app/JsonRpc/PunchCardSystemExternalServiceConsumer.php b/app/JsonRpc/PunchCardSystemExternalServiceConsumer.php new file mode 100644 index 0000000..913e4b1 --- /dev/null +++ b/app/JsonRpc/PunchCardSystemExternalServiceConsumer.php @@ -0,0 +1,26 @@ +__request(__FUNCTION__, $request->all()); + } +} \ No newline at end of file diff --git a/app/JsonRpc/PunchCardSystemExternalServiceInterface.php b/app/JsonRpc/PunchCardSystemExternalServiceInterface.php new file mode 100644 index 0000000..ce993cc --- /dev/null +++ b/app/JsonRpc/PunchCardSystemExternalServiceInterface.php @@ -0,0 +1,16 @@ + JsonRpcPoolTransporter::class, + App\JsonRpc\PunchCardSystemExternalServiceInterface::class => App\JsonRpc\PunchCardSystemExternalServiceConsumer::class, ]; diff --git a/config/autoload/services.php b/config/autoload/services.php index a7df251..39c28f4 100644 --- a/config/autoload/services.php +++ b/config/autoload/services.php @@ -19,6 +19,7 @@ return [ // 这里示例自动创建代理消费者类的配置形式,顾存在 name 和 service 两个配置项,这里的做法不是唯一的,仅说明可以通过 PHP 代码来生成配置 $services = [ 'UserExternalService' => App\JsonRpc\UserExternalServiceInterface::class, + 'PunchCardSystemExternalService' => '' ]; foreach ($services as $name => $interface) { $consumers[] = [