Files
fast_response/digital_doctor/application/api/controller/Hdradmin.php
2025-03-17 10:56:09 +08:00

66 lines
1.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/*
* description
* authorwh
* email
* createTime{2024/8/7} {13:50}
*/
namespace app\api\controller;
use app\common\model\TabConf;
use think\Db;
use wanghua\general_utility_tools_php\Mmodel;
use wanghua\general_utility_tools_php\tool\Tools;
class Hdradmin extends BaseHttpApi
{
/**
* desc管理员登录
* api/Hdradmin/adminLogin
* authorwh
*/
function adminLogin(){
return Mmodel::catchJson(function (){
$username = input('username');
if(empty($username)){
return Tools::set_fail('参数错误:1');
}
$password = input('password');
if(empty($password)){
return Tools::set_fail('参数错误:2');
}
$user = Db::table(TabConf::$fa_hdradmin)
->where('username',$username)
->find();
if(empty($user)){
return Tools::set_fail('用户不存在');
}
if($password != $user['password']){
return Tools::set_fail('密码错误');
}
//session('api_user_info',$user);
unset($user['password']);
$expires = 7*86400+time();//报告完成之后重新获取票据
//返回票据
$ticketstr = md5($user['username'].$expires);
//修改有效期
Db::table('fa_hdradmin')
->data([
'ticket'=>$ticketstr,
'expires'=>$expires,//7天
])
->where('username',$username)
->update();
return Tools::set_ok('登录成功',['ticket'=>$ticketstr,'user'=>$user]);
});
}
}