ComLogic.php
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
namespace App\Http\Logic\Bside;
use App\Models\User as UserModel;
use Illuminate\Support\Facades\Cache;
class ComLogic extends BaseLogic
{
/***
* @name :登录
* @return void
* @author :liyuhang
* @method
*/
public function login($param){
#TODO 查询mobile, 验证密码 true->return; false-> 查询sms发送记录 验证code
$user = new UserModel();
$info = $user->read($param,'id,account,mobile,name');
if(empty($info)){
return false;
}
if(isset($info['token']) && !empty($info['token'])){
//清除上一次用户缓存
Cache::pull($info['token']);
}
//生成新token
$token = md5(uniqid().$info['id']);
//存储缓存
Cache::add($token,$info);
//更新数据库
$data = [
'token'=>$token,
//TODO::返回信息
];
$rs = UserModel->edit($data,['id'=>$info['id']]);
if($rs === false){
return false;
}
return $data;
}
}