创建模型
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace App\BaseApp;
|
||||
|
||||
use App\Models\UserModel;
|
||||
use App\Models\AdminModel;
|
||||
use App\Service\common\JWTService;
|
||||
use App\Service\common\UtilsService;
|
||||
use Exception;
|
||||
@@ -25,6 +25,10 @@ class BaseService
|
||||
* @var int 用户ID,默认值为0,表示未登录状态
|
||||
*/
|
||||
protected int $userId = 0;
|
||||
/**
|
||||
* @var int 角色ID,默认值为0,表示未登录状态
|
||||
*/
|
||||
protected int $roleId = 0;
|
||||
|
||||
/**
|
||||
* @var array 用户信息
|
||||
@@ -36,11 +40,6 @@ class BaseService
|
||||
*/
|
||||
protected $model;
|
||||
|
||||
/**
|
||||
* @var bool 是否需要验证用户权限
|
||||
*/
|
||||
protected bool $isAuth = true;
|
||||
|
||||
/**
|
||||
* @var array 查询的字段
|
||||
*/
|
||||
@@ -93,17 +92,9 @@ class BaseService
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
if ($this->isAuth) {
|
||||
$this->userInfo = JWTService::getInstance()->getToken()->getUserInfo();
|
||||
$this->userId = $this->userInfo['id'] ?? 0;
|
||||
} else {
|
||||
try {
|
||||
$this->userInfo = JWTService::getInstance()->getToken()->getUserInfo();
|
||||
$this->userId = $this->userInfo['id'] ?? 0;
|
||||
} catch (Exception $e) {
|
||||
$this->userId = 0;
|
||||
}
|
||||
}
|
||||
$this->userInfo = JWTService::getInstance()->getToken()->getUserInfo();
|
||||
$this->userId = $this->userInfo['id'] ?? 0;
|
||||
$this->roleId = $this->userInfo['role_id'] ?? 0;
|
||||
$this->utils = UtilsService::getInstance();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user