Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tl_estate
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujun
tl_estate
Commits
30e1fef5
Commit
30e1fef5
authored
Dec 08, 2017
by
clone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
autoken验证
parent
adf067c6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
26 deletions
+34
-26
Basic.php
application/api/extend/Basic.php
+33
-25
BannerModel.php
application/model/BannerModel.php
+1
-1
No files found.
application/api/extend/Basic.php
View file @
30e1fef5
...
@@ -10,8 +10,10 @@ namespace app\api\extend;
...
@@ -10,8 +10,10 @@ namespace app\api\extend;
* 基类
* 基类
*/
*/
use
think\Controller
;
use
think\Controller
;
use
think\helper\Time
;
use
think\Request
;
use
think\Request
;
use
think\Response
;
use
think\Response
;
use
Qiniu
;
class
Basic
extends
Controller
class
Basic
extends
Controller
{
{
...
@@ -21,20 +23,17 @@ class Basic extends Controller
...
@@ -21,20 +23,17 @@ class Basic extends Controller
*/
*/
public
$request
;
public
$request
;
/**
public
$params
;
* 当前访问身份
* @var string
*/
public
$token
;
protected
$authToken
;
/**
/**
* @var int userId
* @var int userId
*/
*/
protected
$userId
;
protected
$userId
;
protected
$access_token
;
protected
$phone
;
protected
$phone
;
protected
$timeStamp_
;
/**
/**
* 基础接口SDK
* 基础接口SDK
...
@@ -46,8 +45,35 @@ class Basic extends Controller
...
@@ -46,8 +45,35 @@ class Basic extends Controller
$this
->
corsOptionsHandler
();
$this
->
corsOptionsHandler
();
// 输入对象
// 输入对象
$this
->
request
=
is_null
(
$request
)
?
Request
::
instance
()
:
$request
;
$this
->
request
=
is_null
(
$request
)
?
Request
::
instance
()
:
$request
;
if
(
strtoupper
(
$this
->
request
->
method
())
===
"GET"
)
{
$this
->
params
=
$this
->
request
->
param
();
}
elseif
(
strtoupper
(
$this
->
request
->
method
())
===
"POST"
)
{
$this
->
params
=
json_decode
(
$this
->
request
->
param
());
}
$jwt
=
new
\Firebase\JWT\JWT
();
$this
->
authToken
=
$this
->
params
[
'AuthToken'
];
$result
=
$jwt
->
decode
(
$this
->
authToken
,
config
(
'jwt_key'
),
array
(
'HS256'
));
//解码token
$this
->
userId
=
$result
[
'data'
][
"userId"
];
$this
->
phone
=
$result
[
'data'
][
"phone"
];
$this
->
timeStamp_
=
$result
[
"timeStamp_"
];
$this
->
verifyTime
();
}
}
public
function
verifyTime
(){
$today
=
Time
::
today
();
//authToken有效期为30天
if
((
$today
-
$this
->
timeStamp_
)
>
2592000
){
return
$this
->
response
(
"101"
,
"AuthToken失效,请重新登录!"
);
}
}
/**
/**
* 输出返回数据
* 输出返回数据
* @param string $msg 提示消息内容
* @param string $msg 提示消息内容
...
@@ -165,25 +191,7 @@ class Basic extends Controller
...
@@ -165,25 +191,7 @@ class Basic extends Controller
'Access-Defined-X-Servers'
=>
'Guangzhou Cuci Technology Co. Ltd'
,
'Access-Defined-X-Servers'
=>
'Guangzhou Cuci Technology Co. Ltd'
,
];
];
}
}
/**
* 加密token或解码token
* @param type $data 加密token
* @param type $token 解密token
* @return type
*/
public
static
function
getJwtToken
(
$data
,
$token
=
''
)
{
$jwt
=
new
\Firebase\JWT\JWT
();
if
(
$token
)
{
$result
=
$jwt
->
decode
(
$token
,
config
(
'jwt_key'
),
array
(
'HS256'
));
//解码token
}
else
{
$data_arr
[
'expire'
]
=
time
();
$data_arr
[
'data'
]
=
$data
;
$result
=
$jwt
->
encode
(
$data
,
config
(
'jwt_key'
));
//生成token
}
return
$result
;
}
}
}
...
...
application/model/BannerModel.php
View file @
30e1fef5
...
@@ -84,7 +84,7 @@ class BannerModel extends Model
...
@@ -84,7 +84,7 @@ class BannerModel extends Model
*/
*/
function
upIsShow
(
$param
)
function
upIsShow
(
$param
)
{
{
$this
->
logger
->
info
(
'日志信息'
);
//
$this->logger->info('日志信息');
$banner
=
$this
->
db
;
$banner
=
$this
->
db
;
$arr
=
array
(
$arr
=
array
(
"id"
=>
$param
[
'id'
],
"id"
=>
$param
[
'id'
],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment