mirror of
https://gitee.com/apiadmin/ApiAdmin.git
synced 2025-04-06 03:58:00 +08:00
改善数据库操作方式
This commit is contained in:
parent
30775cbe64
commit
b261a80c24
@ -2,4 +2,5 @@
|
||||
//配置文件
|
||||
return [
|
||||
'auth_key' => 'mbvUenPqbpxT5WTAXXkFVPHF})0AOGfsMIN01XLu52SgS<R]DQDfj6TlThl897Qd',
|
||||
'online_time' => 3600
|
||||
];
|
@ -28,20 +28,23 @@ class User extends Base {
|
||||
if( $userInfo['status'] ){
|
||||
|
||||
//保存用户信息和登录凭证
|
||||
S($userInfo['_id'], session_id(), C('ONLINE_TIME'));
|
||||
session('uid', $userInfo['_id']);
|
||||
cache($userInfo['id'], session_id(), config('online_time'));
|
||||
session('uid', $userInfo['id']);
|
||||
|
||||
//获取跳转链接,做到从哪来到哪去
|
||||
$url = empty(session('loginFrom')) ? U('Index/index') : session('loginFrom');
|
||||
session('loginFrom', null);
|
||||
if( $request->has('from', 'get') ){
|
||||
$url = $request->get('from');
|
||||
}else{
|
||||
$url = url('Index/index');
|
||||
}
|
||||
|
||||
//更新用户数据
|
||||
$userData = D('UserData')->where(['uid' => $userInfo['_id']])->find();
|
||||
$data = [];
|
||||
if( $userData ){
|
||||
$data['loginTimes'] = $userData['loginTimes'] + 1;
|
||||
$data['lastLoginIp'] = get_client_ip(1);
|
||||
$data['lastLoginTime'] = NOW_TIME;
|
||||
$data['lastLoginIp'] = Request::instance()->ip(1);
|
||||
$data['lastLoginTime'] = time();
|
||||
D('UserData')->where(['uid' => $userInfo['_id']])->save($data);
|
||||
}else{
|
||||
$data['loginTimes'] = 1;
|
||||
|
14
application/admin/model/UserData.php
Normal file
14
application/admin/model/UserData.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* @since 2016-11-05
|
||||
* @author zhaoxiang <zhaoxiang051405@gmail.com>
|
||||
*/
|
||||
|
||||
namespace app\admin\model;
|
||||
|
||||
|
||||
use think\Model;
|
||||
|
||||
class UserData extends Model {
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user