Files
digital_doctor/digital_doctor/application/api/controller/Usersty.php
2024-08-07 15:07:14 +08:00

123 lines
3.2 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/3/26} {20:55}
*/
namespace app\api\controller;
use app\api\logic\TychatLogic;
use app\api\logic\UserOfflinePrizeLogic;
use app\common\model\TabConf;
use GatewayWorker\Lib\Gateway;
use think\Db;
use think\Exception;
use wanghua\general_utility_tools_php\Mmodel;
use wanghua\general_utility_tools_php\SundryConfig;
use wanghua\general_utility_tools_php\tool\Tools;
use wanghua\general_utility_tools_php\wechat\UserAuth;
/**
* 听译-用户
* Class Users
* @package app\api\controller
*/
class Usersty extends BaseHttpApi
{
/**
* desc听译-授权,登录
*
* /api/Usersty/login
*
* 参数:clientid 客户端标识
* username 用户名
* password 密码
*
* authorwh
*/
function login()
{
return Mmodel::catchJson(function (){
$clientid = input('clientid');
if(empty($clientid)){
return Tools::set_fail('clientid error');
}
$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('fa_ty_users')
->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']);
//表示已登陆
if($user['ticket']){
//返回票据
$ticketstr = $user['ticket'];
}else{
//未登录
$expires = 7*86400+time();
$ticketstr = md5($user['username'].$expires);
//修改有效期
Db::table('fa_ty_users')
->data([
'ticket'=>$ticketstr,
'expires'=>$expires,//7天
])
->where('username',$username)
->update();
}
return Tools::set_ok('登录成功',['ticket'=>$ticketstr,'user'=>$user]);
});
}
/**
* desc 绑定设备(选择角色时调用)
*
* api/Usersty/bindDevice
*
* 参数username
* clientid
* type 用户类型:user=用户,doc=医生
*/
//function bindDevice(){
// return Mmodel::catchJson(function (){
// //绑定设备
// $devidata = [
// 'username'=>input('username'),
// 'clientid'=>input('clientid'),
// 'type'=>input('type'),
// 'login_time'=>Tools::get_now_date(),
// ];
// Mmodel::existsUpdateInsert('fa_device',[
// 'username'=>input('username'),
// 'clientid'=>input('clientid'),
// ],$devidata);
// return Tools::set_ok('绑定成功');
// });
//}
}