feat : city

This commit is contained in:
2024-11-07 16:42:31 +08:00
parent df421ede3d
commit 0c126ac468
3 changed files with 83 additions and 0 deletions

View File

@@ -18,6 +18,7 @@ use App\Extend\SystemUtil;
use App\Lib\Crypto\CryptoFactory;
use App\Model\AdminUser;
use App\Service\Admin\BaseService;
use App\Service\ServiceTrait\Admin\GetUserInfoTrait;
use Hyperf\Di\Annotation\Inject;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
@@ -25,6 +26,7 @@ use function Hyperf\Config\config;
class LoginService extends BaseService
{
use GetUserInfoTrait;
/**
* 注入管理员模型
@@ -71,10 +73,12 @@ class LoginService extends BaseService
if (!$userInfo->save()) throw new AdminException('登录失败');
$cityId = $this->getCityById($userInfo->id);
//生成 token
$token = $this->cryptoFactory->cryptoClass('admin-jwt',json_encode([
'id' => $userInfo->id,
'role' => $userInfo->role_id,
'city_id' => $cityId
]))->encrypt();
//单点登录
@@ -87,6 +91,7 @@ class LoginService extends BaseService
'avatar' => $userInfo->avatar,
'name' => $userInfo->chinese_name,
'role_id' => $userInfo->role_id,
'city_id' => $cityId
]
]);
}