feat: 开放API授权相关
This commit is contained in:
32
app/openapi/model/OAuthAccessTokenModel.php
Normal file
32
app/openapi/model/OAuthAccessTokenModel.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\openapi\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class OAuthAccessTokenModel extends Model
|
||||
{
|
||||
// 表名
|
||||
protected $name = 'oauth_access_token';
|
||||
|
||||
// 字段信息
|
||||
protected $schema = [
|
||||
'id' => 'int',
|
||||
'client_id' => 'string',
|
||||
'user_id' => 'int',
|
||||
'access_token' => 'string',
|
||||
'expires' => 'int',
|
||||
'scope' => 'string',
|
||||
'created_at' => 'datetime',
|
||||
];
|
||||
|
||||
// access_token范围查询
|
||||
public function scopeAccessToken($query, $access_token)
|
||||
{
|
||||
$query->where('access_token', '=', $access_token);
|
||||
}
|
||||
}
|
||||
33
app/openapi/model/OAuthAuthCodeModel.php
Normal file
33
app/openapi/model/OAuthAuthCodeModel.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\openapi\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class OAuthAuthCodeModel extends Model
|
||||
{
|
||||
// 表名
|
||||
protected $name = 'oauth_auth_code';
|
||||
|
||||
// 字段信息
|
||||
protected $schema = [
|
||||
'id' => 'int',
|
||||
'code' => 'string',
|
||||
'client_id' => 'string',
|
||||
'user_id' => 'int',
|
||||
'expires' => 'int',
|
||||
'redirect_uri' => 'string',
|
||||
'scope' => 'string',
|
||||
'created_at' => 'datetime',
|
||||
];
|
||||
|
||||
// code范围查询
|
||||
public function scopeCode($query, $code)
|
||||
{
|
||||
$query->where('code', '=', $code);
|
||||
}
|
||||
}
|
||||
33
app/openapi/model/OAuthClientModel.php
Normal file
33
app/openapi/model/OAuthClientModel.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\openapi\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class OAuthClientModel extends Model
|
||||
{
|
||||
// 表名
|
||||
protected $name = 'oauth_client';
|
||||
|
||||
// 字段信息
|
||||
protected $schema = [
|
||||
'id' => 'int',
|
||||
'client_id' => 'string',
|
||||
'client_secret' => 'string',
|
||||
'redirect_uri' => 'string',
|
||||
'enabled' => 'int',
|
||||
'created_at' => 'datetime',
|
||||
'updated_at' => 'datetime',
|
||||
'deleted_at' => 'datetime'
|
||||
];
|
||||
|
||||
// client_id范围查询
|
||||
public function scopeClientId($query, $client_id)
|
||||
{
|
||||
$query->where('client_id', '=', $client_id);
|
||||
}
|
||||
}
|
||||
32
app/openapi/model/OAuthRefreshTokenModel.php
Normal file
32
app/openapi/model/OAuthRefreshTokenModel.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\openapi\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
/**
|
||||
* @mixin \think\Model
|
||||
*/
|
||||
class OAuthRefreshTokenModel extends Model
|
||||
{
|
||||
// 表名
|
||||
protected $name = 'oauth_refresh_token';
|
||||
|
||||
// 字段信息
|
||||
protected $schema = [
|
||||
'id' => 'int',
|
||||
'client_id' => 'string',
|
||||
'user_id' => 'int',
|
||||
'refresh_token' => 'string',
|
||||
'expires' => 'int',
|
||||
'scope' => 'string',
|
||||
'created_at' => 'datetime'
|
||||
];
|
||||
|
||||
// refresh_token范围查询
|
||||
public function scopeRefreshToken($query, $refresh_token)
|
||||
{
|
||||
$query->where('refresh_token', '=', $refresh_token);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user