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.

106 lines
2.6 KiB

<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2019/4/18 0018
* Time: 上午 1:03
*/
namespace app\admin\model;
use app\lib\exception\JsonException;
use app\model\BaseUser;
class User extends BaseUser
{
public static function loginCheck($name,$password){
// $sessionVerify = Session::get('verify');
// if($verify != $sessionVerify){
// throw new HtmlException("验证码输入错误,请重试!");
// }
$user = self::where(['name'=>$name,'password'=>$password])->find();
if(!$user){
throw new JsonException(1,"用户名或密码输入错误,请重试!");
}
// if($user->status == \app\lib\enum\User::DELETED){
// throw new JsonException(1,"该用户已经被删除!");
// }
return $user;
}
//获取性别
public function getSexAttr($var){
switch($var){
case '1':
return "";
break;
case '2':
return "";
break;
default:
return "未知";
}
}
//获取科室
public function getDepartmentAttr($var){
switch($var){
case '1':
return "内科";
break;
case '2':
return "儿科";
break;
case '3':
return "神经科";
break;
case '4':
return "口腔科";
break;
case '5':
return "眼科";
break;
case '6':
return "耳鼻喉科";
break;
case '7':
return "妇科";
break;
case '8':
return "中医科";
break;
default:
return "";
}
}
//获取职位
public function getPositionAttr($var){
switch($var){
case '1':
return "管理员";
break;
case '2':
return "医生";
break;
case '3':
return "护士";
break;
default:
return "无职位";
}
}
//获取任职时间
public function getEntryTimeAttr($val,$data)
{
if (empty($data['entry_time']))
return '暂无记录';
return date("Y-m-d",$data['entry_time']);
}
}