mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-09-10 14:29:46 +08:00
修改用户服务
This commit is contained in:
parent
7b7db7ee4f
commit
03a755acd9
@ -8,7 +8,7 @@ use think\admin\Controller;
|
|||||||
use think\exception\HttpResponseException;
|
use think\exception\HttpResponseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 授权认证基类
|
* 接口授权认证基类
|
||||||
* Class Auth
|
* Class Auth
|
||||||
* @package app\store\controller\api
|
* @package app\store\controller\api
|
||||||
*/
|
*/
|
||||||
@ -70,7 +70,7 @@ abstract class Auth extends Controller
|
|||||||
[$state, $info, $this->uuid] = UserTokenService::instance()->check($this->type, $token);
|
[$state, $info, $this->uuid] = UserTokenService::instance()->check($this->type, $token);
|
||||||
if (empty($state)) $this->error($info, '{-null-}', 401);
|
if (empty($state)) $this->error($info, '{-null-}', 401);
|
||||||
}
|
}
|
||||||
return UserService::instance()->get($this->type, $this->uuid);
|
return UserService::instance()->get($this->uuid, $this->type);
|
||||||
} catch (HttpResponseException $exception) {
|
} catch (HttpResponseException $exception) {
|
||||||
throw $exception;
|
throw $exception;
|
||||||
} catch (\Exception $exception) {
|
} catch (\Exception $exception) {
|
||||||
|
@ -50,22 +50,24 @@ class UserService extends Service
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户数据
|
* 获取用户数据
|
||||||
* @param string $type 接口类型
|
|
||||||
* @param integer $uuid 用户UID
|
* @param integer $uuid 用户UID
|
||||||
|
* @param ?string $type 接口类型
|
||||||
* @return array
|
* @return array
|
||||||
* @throws DbException
|
* @throws DbException
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function get(string $type, int $uuid): array
|
public function get(int $uuid, ?string $type = null): array
|
||||||
{
|
{
|
||||||
$user = $this->app->db->name('DataUser')->where(['id' => $uuid, 'deleted' => 0])->findOrEmpty();
|
$user = $this->app->db->name('DataUser')->where(['id' => $uuid, 'deleted' => 0])->findOrEmpty();
|
||||||
if (empty($user)) throw new Exception('指定UID用户不存在');
|
if (empty($user)) throw new Exception('指定UID用户不存在');
|
||||||
$data = $this->app->db->name('DataUserToken')->where(['uid' => $uuid, 'type' => $type])->findOrEmpty();
|
if (!is_null($type)) {
|
||||||
if (empty($data)) {
|
$data = $this->app->db->name('DataUserToken')->where(['uid' => $uuid, 'type' => $type])->findOrEmpty();
|
||||||
[$state, $info, $data] = UserTokenService::instance()->token($uuid, $type);
|
if (empty($data)) {
|
||||||
if (empty($state) || empty($data)) throw new Exception($info);
|
[$state, $info, $data] = UserTokenService::instance()->token($uuid, $type);
|
||||||
|
if (empty($state) || empty($data)) throw new Exception($info);
|
||||||
|
}
|
||||||
|
$user['token'] = ['token' => $data['token'], 'expire' => $data['time']];
|
||||||
}
|
}
|
||||||
$user['token'] = ['token' => $data['token'], 'expire' => $data['time']];
|
|
||||||
unset($user['deleted'], $user['password']);
|
unset($user['deleted'], $user['password']);
|
||||||
return $user;
|
return $user;
|
||||||
}
|
}
|
||||||
@ -94,7 +96,7 @@ class UserService extends Service
|
|||||||
if ($force) {
|
if ($force) {
|
||||||
UserTokenService::instance()->token(intval($uuid), $type);
|
UserTokenService::instance()->token(intval($uuid), $type);
|
||||||
}
|
}
|
||||||
return $this->get($type, $uuid);
|
return $this->get($uuid, $type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user