Commit 9f4ac59a by hcy001

1

parent 8556ac3e
......@@ -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);
}
......
......@@ -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"=>$userInfo["name"],"email"=>$userInfo["email"]]));
if ($res != 'OK'){
Export(1001,"写入缓存失败");
}
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment