Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
doc_phone
Project
Project
Details
Activity
Releases
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
jiangyipeng
doc_phone
Commits
25b88882
Commit
25b88882
authored
May 27, 2020
by
jiangyipeng
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of gitlab.linanquan.com:jiangyipeng/doc_phone
parents
5c866dc7
3456d78b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
18 deletions
+41
-18
Index.php
application/api/controller/Index.php
+17
-3
common.php
application/common.php
+8
-0
Index.php
application/login/controller/Index.php
+16
-15
No files found.
application/api/controller/Index.php
View file @
25b88882
...
...
@@ -6,15 +6,29 @@ use think\Request;
use
think\Controller
;
use
app\api\model\Folder
;
use
app\api\model\Doclist
;
use
think\Cache
;
class
Index
extends
Controller
{
public
function
index
()
public
function
_initialize
()
{
$token
=
input
(
'post.token'
);
$old_token
=
Cache
::
get
(
'token'
);
if
(
$old_token
){
if
(
$token
!=
$old_token
){
$rs
=
json_encode
(
code
([],
10003
,
'token不合法'
));
exit
(
$rs
);
}
}
else
{
$rs
=
json_encode
(
code
([],
10003
,
'token不存在或已过期'
));
exit
(
$rs
);
}
}
public
function
folderList
()
{
$request
=
Request
::
instance
();
...
...
@@ -180,7 +194,7 @@ class Index extends Controller
$doc
=
input
(
'post.doc'
);
$docid
=
input
(
'post.docid'
);
$model
=
new
Doclist
();
if
(
empty
(
$title
)
||
empty
(
$doc
)
||
empty
(
$docid
))
{
if
(
empty
(
$folderid
)
||
empty
(
$title
)
||
empty
(
$doc
)
||
empty
(
$docid
))
{
return
json
(
code
([],
10001
,
'参数不足'
));
}
$res
=
$model
->
editArticle
(
$title
,
$folderid
,
$doc
,
$docid
);
...
...
application/common.php
View file @
25b88882
...
...
@@ -62,3 +62,11 @@ function randomkeys($length)
}
return
$key
;
}
function
create_unique
()
{
$uniqid
=
uniqid
();
$uniqid
=
str_replace
(
'.'
,
''
,
$uniqid
);
$unString
=
base_convert
(
$uniqid
,
16
,
36
);
// 补足17位
return
str_pad
(
$unString
,
17
,
rand
(
1
,
9999999
));
}
application/login/controller/Index.php
View file @
25b88882
...
...
@@ -50,9 +50,10 @@ class Index extends Controller
$User
=
new
Dingtalk\User
();
$userid
=
$User
->
code
(
$code
);
$result
=
$this
->
create
(
$userid
);
return
$result
;
//$userid='231115647';
$token
=
md5
(
create_unique
());
$expireSecond
=
config
(
'token_expire_second'
);
$rs
=
cache
(
'token'
,
$token
,
$expireSecond
);
if
(
$userid
===
false
){
$data
[
'status'
]
=-
10001
;
$data
[
'errmsg'
]
=
'登录失败'
;
...
...
@@ -60,20 +61,20 @@ class Index extends Controller
$data
[
'status'
]
=
0
;
$data
[
'errmsg'
]
=
'登录成功'
;
$data
[
'userid'
]
=
$userid
;
$data
[
'token'
]
=
$
result
;
$data
[
'token'
]
=
$
token
;
}
// return json($data);
return
json
(
code
([
$data
],
0
,
'ok'
));
}
public
function
create
(
$uid
)
{
$tokenModel
=
new
TokenModel
();
$token
=
$tokenModel
->
createToken
(
$uid
);
if
(
$token
==
false
)
{
return
json
(
code
([],
$tokenModel
->
getErrCode
(),
$tokenModel
->
getError
()));
}
else
{
return
json
(
code
([
'token'
=>
$token
,
'expire_second'
=>
config
(
'token_expire_second'
)]));
}
}
//
public function create($uid)
//
{
//
//
$tokenModel = new TokenModel();
//
$token = $tokenModel->createToken($uid);
//
if ($token == false) {
//
return json(code([], $tokenModel->getErrCode(), $tokenModel->getError()));
//
} else {
//
return json(code(['token' => $token, 'expire_second' => config('token_expire_second')]));
//
}
//
}
}
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