php管理和接口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

37 lines
878 B

<?php
namespace app\api\service;
use app\api\model\User;
use think\Db;
/**
* 用户表
*/
class UserService {
public function mktoken(){
// jwt
$guid = get_guid_v4();
$dtime = time();
return md5(uniqid($guid.$dtime,true));
}
/**
* 用户登录操作,传入用户查询后才对比密码
*/
public function userlogin(string $uname,string $pass){
// query db
$drs = User::where(['nick_name'=>$uname])->find();
// 异常处理
if(!isset($drs)){
throwError('用户不存在');
return false;
}else{
// 对比密码
if($drs['password'] != $pass){
throwError('密码错误');
return false;
}
// 返回用户信息
return $drs;
}
return false;
}
}