mirror of
http://124.126.16.154:8888/singularity/hdk-auth.git
synced 2026-01-15 05:35:07 +08:00
feat(userRpc): 更新
* 在每次请求时再获取当前语言 * 请求的接口路径改为了完整 path
This commit is contained in:
@@ -11,6 +11,8 @@ use Psr\Http\Client\ClientExceptionInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Singularity\HDK\Core\Service\HttpRequestService;
|
||||
|
||||
use function Hyperf\Config\config;
|
||||
|
||||
class UserRpc
|
||||
{
|
||||
#[Inject]
|
||||
@@ -21,15 +23,12 @@ class UserRpc
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->requestService->setOptions([
|
||||
$this->requestService->setOptions(
|
||||
[
|
||||
'headers' => [
|
||||
'Accept-Language' => $this->translator->getLocale(),
|
||||
],
|
||||
],
|
||||
'base_uri' => config('common.http_request.account.rpc_base_uri'),
|
||||
RequestOptions::ALLOW_REDIRECTS => true,
|
||||
]);
|
||||
'base_uri' => config('common.http_request.account.rpc_base_uri'),
|
||||
RequestOptions::ALLOW_REDIRECTS => true,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,7 +39,15 @@ class UserRpc
|
||||
*/
|
||||
public function alive($name): ResponseInterface
|
||||
{
|
||||
return $this->requestService->requestGet('/user/alive?username=' . urlencode($name));
|
||||
return $this->requestService
|
||||
->setOptions([
|
||||
[
|
||||
'headers' => [
|
||||
'Accept-Language' => $this->translator->getLocale(),
|
||||
],
|
||||
],
|
||||
])
|
||||
->requestGet('/rpc/user/alive?username=' . urlencode($name));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -51,7 +58,15 @@ class UserRpc
|
||||
*/
|
||||
public function detail($uid): ResponseInterface
|
||||
{
|
||||
return $this->requestService->requestGet('/user/detail?uid=' . $uid);
|
||||
return $this->requestService
|
||||
->setOptions([
|
||||
[
|
||||
'headers' => [
|
||||
'Accept-Language' => $this->translator->getLocale(),
|
||||
],
|
||||
],
|
||||
])
|
||||
->requestGet('/rpc/user/detail?uid=' . $uid);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,7 +76,15 @@ class UserRpc
|
||||
*/
|
||||
public function create($data): ResponseInterface
|
||||
{
|
||||
return $this->requestService->requestPost('/user/create', $data);
|
||||
return $this->requestService
|
||||
->setOptions([
|
||||
[
|
||||
'headers' => [
|
||||
'Accept-Language' => $this->translator->getLocale(),
|
||||
],
|
||||
],
|
||||
])
|
||||
->requestPost('/rpc/user/create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,7 +95,15 @@ class UserRpc
|
||||
*/
|
||||
public function update($uid, $data): ResponseInterface
|
||||
{
|
||||
return $this->requestService->requestPost('/user/update', $data, params: ['uid' => $uid]);
|
||||
return $this->requestService
|
||||
->setOptions([
|
||||
[
|
||||
'headers' => [
|
||||
'Accept-Language' => $this->translator->getLocale(),
|
||||
],
|
||||
],
|
||||
])
|
||||
->requestPost('/rpc/user/update', $data, params: ['uid' => $uid]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,7 +114,15 @@ class UserRpc
|
||||
*/
|
||||
public function list($uid_arr): ResponseInterface
|
||||
{
|
||||
return $this->requestService->requestGet('/user', $uid_arr);
|
||||
return $this->requestService
|
||||
->setOptions([
|
||||
[
|
||||
'headers' => [
|
||||
'Accept-Language' => $this->translator->getLocale(),
|
||||
],
|
||||
],
|
||||
])
|
||||
->requestGet('/rpc/user', $uid_arr);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,7 +132,15 @@ class UserRpc
|
||||
*/
|
||||
public function checkNamePass($data): ResponseInterface
|
||||
{
|
||||
return $this->requestService->requestPost('/user/signIn', $data);
|
||||
return $this->requestService
|
||||
->setOptions([
|
||||
[
|
||||
'headers' => [
|
||||
'Accept-Language' => $this->translator->getLocale(),
|
||||
],
|
||||
],
|
||||
])
|
||||
->requestPost('/rpc/user/signIn', $data);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user