diff --git a/app/Controller/PunchCard/User/UserController.php b/app/Controller/PunchCard/User/UserController.php index 9c41627..cbf85af 100644 --- a/app/Controller/PunchCard/User/UserController.php +++ b/app/Controller/PunchCard/User/UserController.php @@ -68,4 +68,26 @@ class UserController extends BaseController { return $this->getServiceResult($this->punchCardSystemExternalService->saveFeedback($this->request)); } + + /** + * 获取紧急联系人关系列表 + * + * @return array + */ + #[GetMapping(path: "user/emergency_contact_kinship")] + public function getEmergencyContactKinshipList() : array + { + return $this->getServiceResult($this->userExternalService->getEmergencyContactKinshipList()); + } + + /** + * 保存紧急联系人 + * + * @return array + */ + #[PostMapping(path: "user/add_emergency_contact")] + public function addEmergencyContact() : array + { + return $this->getServiceResult($this->userExternalService->addEmergencyContact($this->request)); + } } diff --git a/app/JsonRpc/UserExternalServiceConsumer.php b/app/JsonRpc/UserExternalServiceConsumer.php new file mode 100644 index 0000000..5c96fa1 --- /dev/null +++ b/app/JsonRpc/UserExternalServiceConsumer.php @@ -0,0 +1,59 @@ +__request(__FUNCTION__, compact('openid', 'field')); + } + + /** + * 通过微信授权新建用户 + * + * @param string $openid + * @return array + */ + public function wechatNewUser(string $openid) : array + { + return $this->__request(__FUNCTION__, compact('openid')); + } + + /** + * 获取紧急联系人关系列表 + * + * @return array + */ + public function getEmergencyContactKinshipList() : array + { + return $this->__request(__FUNCTION__, []); + } + + /** + * 保存紧急联系人 + * + * @param RequestInterface $request + * @return array + */ + public function addEmergencyContact(RequestInterface $request) : array + { + return $this->__request(__FUNCTION__, $request->all()); + } +} \ No newline at end of file diff --git a/app/JsonRpc/UserExternalServiceInterface.php b/app/JsonRpc/UserExternalServiceInterface.php index 928966e..1ba1e1e 100644 --- a/app/JsonRpc/UserExternalServiceInterface.php +++ b/app/JsonRpc/UserExternalServiceInterface.php @@ -2,6 +2,8 @@ namespace App\JsonRpc; +use Hyperf\HttpServer\Contract\RequestInterface; + interface UserExternalServiceInterface { /** @@ -20,4 +22,19 @@ interface UserExternalServiceInterface * @return array */ public function wechatNewUser(string $openid) : array; + + /** + * 获取紧急联系人关系列表 + * + * @return array + */ + public function getEmergencyContactKinshipList() : array; + + /** + * 保存紧急联系人 + * + * @param RequestInterface $request + * @return array + */ + public function addEmergencyContact(RequestInterface $request) : array; } \ No newline at end of file diff --git a/config/autoload/dependencies.php b/config/autoload/dependencies.php index 6699c29..e1b5ebf 100644 --- a/config/autoload/dependencies.php +++ b/config/autoload/dependencies.php @@ -14,5 +14,6 @@ use Hyperf\JsonRpc\JsonRpcTransporter; return [ JsonRpcTransporter::class => JsonRpcPoolTransporter::class, + App\JsonRpc\UserExternalServiceInterface::class => App\JsonRpc\UserExternalServiceConsumer::class, App\JsonRpc\PunchCardSystemExternalServiceInterface::class => App\JsonRpc\PunchCardSystemExternalServiceConsumer::class, ]; diff --git a/config/autoload/services.php b/config/autoload/services.php index 39c28f4..e54b759 100644 --- a/config/autoload/services.php +++ b/config/autoload/services.php @@ -18,7 +18,7 @@ return [ $consumers = []; // 这里示例自动创建代理消费者类的配置形式,顾存在 name 和 service 两个配置项,这里的做法不是唯一的,仅说明可以通过 PHP 代码来生成配置 $services = [ - 'UserExternalService' => App\JsonRpc\UserExternalServiceInterface::class, + 'UserExternalService' => '', 'PunchCardSystemExternalService' => '' ]; foreach ($services as $name => $interface) {