Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄成意
/
php_frq_api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
9f4ac59a
authored
Mar 16, 2021
by
hcy001
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1
parent
8556ac3e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
8 deletions
app/Http/Controllers/ApiController.php
app/Model/LoginModel.php
app/Model/UserModel.php
app/Http/Controllers/ApiController.php
View file @
9f4ac59a
...
...
@@ -31,17 +31,20 @@ use RedisDB;
class
ApiController
extends
Controller
{
public
$user_id
=
""
;
//用户id
public
$user_name
=
""
;
//用户名称
public
$user_name
=
""
;
//用户中文名称
public
$email
=
""
;
//邮箱
public
function
Entrance
(
Request
$request
,
$id
)
{
$loginInfo
=
(
new
LoginModel
())
->
checkLogin
(
$request
);
$this
->
user_id
=
$loginInfo
[
"user_id"
];
$this
->
user_name
=
$loginInfo
[
"user_name"
];
$this
->
email
=
$loginInfo
[
"email"
];
$input
=
$_REQUEST
;
$input
[
"user_id"
]
=
$this
->
user_id
;
$input
[
"user_name"
]
=
$this
->
user_name
;
$input
[
"email"
]
=
$this
->
email
;
$input
[
"user_name"
]
=
$this
->
user_name
;
#用户中文名称
$this
->
$id
(
$input
,
$id
);
}
...
...
app/Model/LoginModel.php
View file @
9f4ac59a
...
...
@@ -40,7 +40,7 @@ class LoginModel extends Model
Export
(
1001
,
"请先登录"
);
}
$userInfo
=
\GuzzleHttp\json_decode
(
$userInfo
,
true
);
return
[
"user_id"
=>
$userInfo
[
"user_id"
],
"user_name"
=>
$userInfo
[
"user_name"
]]
;
return
$userInfo
;
}
/*
...
...
@@ -49,13 +49,14 @@ class LoginModel extends Model
public
function
CreatePcToken
(
$request
){
$Redis
=
\RedisDB
::
connection
();
$user_id
=
$request
->
input
(
"user_id"
);
$user_name
=
$request
->
input
(
"user_name"
);
if
(
empty
(
$user_id
)
||
empty
(
$user_name
)){
Export
(
1001
,
"用户id 或者用户名称不得为空"
);
$userInfo
=
(
new
UserModel
())
->
FinduserInfo
(
$user_id
);
if
(
empty
(
$user_id
)){
Export
(
1001
,
"用户id不得为空"
);
}
$key
=
md5
(
$user_id
.
$user_name
.
time
());
$key
=
md5
(
$user_id
.
time
());
$expire
=
3600
*
24
;
//过期24个小时
$res
=
$Redis
->
setex
(
'frq_login_'
.
$key
.
"_uid_"
.
$user_id
,
$expire
,
utf8JsonEncode
([
"user_id"
=>
$user_id
,
"user_name"
=>
$user
_name
]));
$res
=
$Redis
->
setex
(
'frq_login_'
.
$key
.
"_uid_"
.
$user_id
,
$expire
,
utf8JsonEncode
([
"user_id"
=>
$user_id
,
"user_name"
=>
$user
Info
[
"name"
],
"email"
=>
$userInfo
[
"email"
]
]));
if
(
$res
!=
'OK'
){
Export
(
1001
,
"写入缓存失败"
);
}
...
...
app/Model/UserModel.php
View file @
9f4ac59a
...
...
@@ -27,6 +27,16 @@ class UserModel extends Model
empty
(
$result
[
'name'
])
&&
$result
[
'name'
]
=
$result
[
'email'
];
return
$result
[
'name'
];
}
/*
* 查询用户明细
*/
public
function
FinduserInfo
(
$UserID
=
''
){
if
(
empty
(
$UserID
))
return
""
;
$result
=
$this
->
where
(
'userId'
,
'='
,
$UserID
)
->
select
(
'userId'
,
'name'
,
'email'
)
->
first
();
if
(
!
$result
)
return
""
;
$result
=
$result
->
toArray
();
return
$result
;
}
public
function
FindUserInfoNE
(
$UserID
=
''
){
if
(
empty
(
$UserID
))
return
false
;
...
...
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