mirror of
http://124.126.16.154:8888/singularity/hdk-auth.git
synced 2026-01-15 03:35:05 +08:00
feat: 更新了用户相关的 rpc 操作
This commit is contained in:
@@ -14,16 +14,18 @@
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.4",
|
||||
"php": ">=8.0",
|
||||
"ext-redis": "*",
|
||||
"composer/composer": "~2.0.14",
|
||||
"hyperf/validation": "^2.2.33",
|
||||
"singularity/hdk-core": "0.1.x-dev",
|
||||
"symfony/polyfill-php80": "^1.27",
|
||||
"ext-redis": "*"
|
||||
"donjan-deng/hyperf-casbin": "^3.21",
|
||||
"hyperf/validation": "3.0.*",
|
||||
"singularity/hdk-core": "dev-develop",
|
||||
"symfony/polyfill-php80": "^1.27"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^9.5",
|
||||
"firebase/php-jwt": "^6.3"
|
||||
"firebase/php-jwt": "^6.3",
|
||||
"guzzlehttp/guzzle": "^7.5",
|
||||
"phpunit/phpunit": "^9.5"
|
||||
},
|
||||
"suggest": {
|
||||
"firebase/php-jwt": "^6.3"
|
||||
|
||||
2681
composer.lock
generated
2681
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1,60 +1,99 @@
|
||||
<?php
|
||||
|
||||
namespace Singularity\HDK\Auth\Services\Http;
|
||||
namespace Singularity\HDK\Auth\Sdk;
|
||||
|
||||
|
||||
use GuzzleHttp\Exception\GuzzleException;
|
||||
use GuzzleHttp\RequestOptions;
|
||||
use Hyperf\Contract\TranslatorInterface;
|
||||
use Hyperf\Di\Annotation\Inject;
|
||||
use Singularity\HDK\Utils\Service\HttpRequestService;
|
||||
use Psr\Http\Client\ClientExceptionInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Singularity\HDK\Core\Service\HttpRequestService;
|
||||
|
||||
class UserRpc extends HttpRequestService
|
||||
class UserRpc
|
||||
{
|
||||
/**
|
||||
* @Inject
|
||||
* @var TranslatorInterface
|
||||
*/
|
||||
#[Inject]
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
#[Inject]
|
||||
private HttpRequestService $requestService;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
$this->requestService->setOptions([
|
||||
[
|
||||
'headers' => [
|
||||
'Accept-Language' => $this->translator->getLocale()
|
||||
]
|
||||
'Accept-Language' => $this->translator->getLocale(),
|
||||
],
|
||||
],
|
||||
config('common.http_request.account.rpc_base_uri')
|
||||
);
|
||||
'base_uri' => config('common.http_request.account.rpc_base_uri'),
|
||||
RequestOptions::ALLOW_REDIRECTS => true,
|
||||
]);
|
||||
}
|
||||
|
||||
public function alive($name)
|
||||
/**
|
||||
* @param $name
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
* @throws ClientExceptionInterface
|
||||
*/
|
||||
public function alive($name): ResponseInterface
|
||||
{
|
||||
return $this->get('user/alive?username=' . urlencode($name));
|
||||
return $this->requestService->requestGet('/user/alive?username=' . urlencode($name));
|
||||
}
|
||||
|
||||
public function detail($uid)
|
||||
/**
|
||||
* @param $uid
|
||||
* @return ResponseInterface
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function detail($uid): ResponseInterface
|
||||
{
|
||||
return $this->get('user/detail?uid=' . $uid);
|
||||
return $this->requestService->requestGet('/user/detail?uid=' . $uid);
|
||||
}
|
||||
|
||||
public function create($data)
|
||||
/**
|
||||
* @param $data
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function create($data): ResponseInterface
|
||||
{
|
||||
return $this->post('user/create', $data);
|
||||
return $this->requestService->requestPost('/user/create', $data);
|
||||
}
|
||||
|
||||
public function update($uid, $data)
|
||||
/**
|
||||
* @param $uid
|
||||
* @param $data
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function update($uid, $data): ResponseInterface
|
||||
{
|
||||
return $this->post('user/update?uid=' . $uid, $data);
|
||||
return $this->requestService->requestPost('/user/update', $data, params: ['uid' => $uid]);
|
||||
}
|
||||
|
||||
public function list($uid_arr)
|
||||
/**
|
||||
* @param $uid_arr
|
||||
* @return ResponseInterface
|
||||
* @throws ClientExceptionInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function list($uid_arr): ResponseInterface
|
||||
{
|
||||
return $this->post('user', $uid_arr);
|
||||
return $this->requestService->requestGet('/user', $uid_arr);
|
||||
}
|
||||
|
||||
public function checkNamePass($data)
|
||||
/**
|
||||
* @param $data
|
||||
* @return ResponseInterface
|
||||
* @throws GuzzleException
|
||||
*/
|
||||
public function checkNamePass($data): ResponseInterface
|
||||
{
|
||||
return $this->post('user/signIn', $data);
|
||||
return $this->requestService->requestPost('/user/signIn', $data);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user