完善用户中心紧急联系人功能
This commit is contained in:
parent
e6266edc07
commit
fe656375b4
@ -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));
|
||||
}
|
||||
}
|
||||
|
59
app/JsonRpc/UserExternalServiceConsumer.php
Normal file
59
app/JsonRpc/UserExternalServiceConsumer.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
namespace App\JsonRpc;
|
||||
|
||||
use Hyperf\RpcClient\AbstractServiceClient;
|
||||
use Hyperf\HttpServer\Contract\RequestInterface;
|
||||
|
||||
class UserExternalServiceConsumer extends AbstractServiceClient implements UserExternalServiceInterface
|
||||
{
|
||||
/**
|
||||
* 定义对应服务提供者的服务名称
|
||||
* @var string
|
||||
*/
|
||||
protected $serviceName = 'UserExternalService';
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
*
|
||||
* @param string $openid
|
||||
* @param array $field
|
||||
* @return array
|
||||
*/
|
||||
public function getUserInfo(string $openid, array $field = []) : array
|
||||
{
|
||||
return $this->__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());
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
@ -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,
|
||||
];
|
||||
|
@ -18,7 +18,7 @@ return [
|
||||
$consumers = [];
|
||||
// 这里示例自动创建代理消费者类的配置形式,顾存在 name 和 service 两个配置项,这里的做法不是唯一的,仅说明可以通过 PHP 代码来生成配置
|
||||
$services = [
|
||||
'UserExternalService' => App\JsonRpc\UserExternalServiceInterface::class,
|
||||
'UserExternalService' => '',
|
||||
'PunchCardSystemExternalService' => ''
|
||||
];
|
||||
foreach ($services as $name => $interface) {
|
||||
|
Loading…
Reference in New Issue
Block a user