yangsai@163.com 9 months ago
parent fd2e3ca0e6
commit e93ccdfb46
  1. 66
      application/controllers/Admin/Login.php
  2. 102
      application/controllers/Api/Remind.php
  3. 5
      application/models/Admin.php

@ -8,65 +8,19 @@ class Admin_LoginController extends Ctrl_Admin{
}
public function LoginAction(){
$tAMO = new AdminModel;
$tURMO= new UserroteModel;
$tARMO= new AdminroteModel;
$tLMO = new LogModel;
$pPasswd = empty($_REQUEST['password'])?Tool_Fnc::ajaxMsg('密码不能为空'):trim($_REQUEST['password']);
$HospitalID = empty($_REQUEST['hospital'])?'0':trim($_REQUEST['hospital']);
$pName = empty($_REQUEST['username'])?Tool_Fnc::ajaxMsg('用户名不能为空'):Tool_Fnc::safe_string($_REQUEST['username']);
$Sql = $Sql = "select * from ".$tAMO->table.' a left join '.$tURMO->table.' ur on ur.u_id=a.admin_id left join '.$tARMO->table.' ar on ar.admin_r_id=ur.r_id where a.hospital='.$HospitalID.' AND admin_username=\''.$pName.'\'';
$AdminInfo = $tAMO->query($Sql);
$REQUEST =json_decode(file_get_contents('php://input'),true);
$pPasswd = empty($REQUEST['password'])?Tool_Fnc::ajaxMsg('密码不能为空'):trim($REQUEST['password']);
$pName = empty($REQUEST['username'])?Tool_Fnc::ajaxMsg('用户名不能为空'):Tool_Fnc::safe_string($REQUEST['username']);
$AdminInfo = $tAMO->field("*")->where("admin_username='{$pName}'")->fRow();
if (empty($AdminInfo)) {
Tool_Fnc::ajaxMsg('用户名错误');
Tool_Fnc::apiMsg('用户名错误',500);
}
$password = $AdminInfo[0]['admin_password'];
$QueryPwd = Tool_Fnc::markmd5($pPasswd,$AdminInfo[0]['admin_token']);
$password = $AdminInfo['admin_password'];
$QueryPwd = Tool_Fnc::markmd5($pPasswd,$AdminInfo['admin_token']);
if ($password!=$QueryPwd) {
Tool_Fnc::ajaxMsg('密码错误');
Tool_Fnc::apiMsg('密码错误',500);
}
$array=array(
'l_user'=>$AdminInfo[0]['admin_username'],
'hospital'=>$AdminInfo[0]['hospital'],
'l_created'=>time(),
'l_ip'=>$_SERVER['REMOTE_ADDR'],
);
// print_r($array);die;
$tLMO->insert($array);
$_SESSION['Admin'] = $AdminInfo[0]['admin_id'];
$_SESSION['UserName'] = $AdminInfo[0]['admin_username'];
$_SESSION['Name'] = $AdminInfo[0]['admin_name'];
$_SESSION['HospitalID'] = $AdminInfo[0]['hospital'];
$_SESSION['HospitalName'] = $AdminInfo[0]['hospital_name'];
$_SESSION['Rote'] = $AdminInfo[0]['admin_r_name'];
$_SESSION['RoteId'] = $AdminInfo[0]['admin_r_id'];
Tool_Fnc::ajaxMsg('登陆成功',1);
// $tRow = $tAMO->field('*')->where("admin_username = '{$pName}'")->fRow();
// if(!count($tRow)){Tool_Fnc::ajaxMsg('用户不存在');}
// if(Tool_Fnc::markmd5($pPasswd,$tRow['admin_token']) != $tRow['admin_password']){Tool_Fnc::ajaxMsg('密码不正确'); }
// $_SESSION['admin'] = array('id'=> $tRow['admin_id'],'name' => $tRow['admin_username'],'roles' => $tRow['me_a_type'],'do_id' => $tRow['me_a_ip']);
// setcookie('admin[roles]',$tRow['me_a_type'],time()+3600*24,'/');
// setcookie('admin[id]',$tRow['me_a_id'],time()+60*60*24*365,'/');
// setcookie('admin[name]',$tRow['me_a_username'],time()+60*60*24*365,'/');
}
/**
* [captchaAction 获取验证码]
* @return [type] [description]
*/
public function captchaAction(){
$captcha = new Tool_Captcha(80, 35, 4);
$_SESSION['captcha'] = $captcha;
$captcha->showImg();
exit;
}
/**
* [HospitalInfo 医院信息]
*/
public function HospitalInfo(){
$tHMO = new HospitalModel;
$HospitalInfo = $tHMO->field('hospital_id HospitalID,hospital_ip HospitalIP,hospital_name HospitalName,hospital_url HospitalUrl')->fList();
return $HospitalInfo;
$data['token'] = Tool_Fnc::markmd5($AdminInfo['admin_token'],$AdminInfo['admin_password']);
Tool_Fnc::apiMsg('登陆成功',20000,$data);
}
}

@ -0,0 +1,102 @@
<?php
/**
* 待办接口
* @author YS
* @version 1.0
*/
class Api_RemindController extends Ctrl_Api{
public $SquirrelModel;
public $newSquirrelModel;
public $SquirrelSetModel;
public $CageModel;
public function init(){
$SquirrelModel = new SquirrelModel();
$newSquirrelModel = new NewSquirrelModel();
$SquirrelSetModel = new SquirrelSetModel();
$CageModel = new CageModel();
$this->POST =json_decode(file_get_contents('php://input'),true);
}
public function getListAction(){
$uid = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid'];
//查询鼠提示信息
$Squirrel = $this->SquirrelModel->field('*')->where("c_user_id={$uid} and is_kill = 0 and is_delete=0")->fList();
$newSquirrel = $this->newSquirrelModel->field('*')->where("c_user_id={$uid} and is_kill = 0 and is_delete=0")->fList();
foreach($Squirrel as $key => $val){
//获取笼位号
$cage = $this->CageModel->field("number,type")->where("cage={$val['cage']}")->fRow();
$type = $cage['type']==1?"库存笼":"繁殖笼";
//断奶提醒
if($val['weaning_time']==date("Y-m-d",time())){
$remind[] = "{$type}【{$cage['number']}】里{$val['number']}于{$val['weaning_time']}断奶";
}
//护理结束提醒
if($val['weaning_time']==date("Y-m-d",time())){
$remind[] = "{$type}【{$cage['number']}】里{$val['number']}于{$val['weaning_time']}结束护理";
}
//性成熟时间提醒
if($val['grow_time']==date("Y-m-d",time())){
$remind[] = "{$type}【{$cage['number']}】里{$val['number']}于{$val['weaning_time']}成熟";
}
//不育鼠时间提醒
if($val['infertility_time']==date("Y-m-d",time())){
$remind[] = "{$type}【{$cage['number']}】里{$val['number']}于{$val['weaning_time']}结束不育时间";
}
//处死提醒
if($val['kill_time']==date("Y-m-d",time())){
$remind[] = "{$type}【{$cage['number']}】里{$val['number']}{$val['weaning_time']}已到处死时间";
}
//删除提醒
if($val['del_time']==date("Y-m-d",time())){
$remind[] = "{$type}【{$cage['number']}】里{$val['number']}{$val['weaning_time']}已到删除时间";
}
//剪尾提醒
if($val['jianwei_time']==date("Y-m-d",time())){
$remind[] = "{$type}【{$cage['number']}】里{$val['number']}{$val['weaning_time']}改进行剪尾";
}
//实验提醒
if($val['test_time']==date("Y-m-d",time())){
$remind[] = "{$type}【{$cage['number']}】里{$val['number']}已到可实验时间{$val['weaning_time']}";
}
}
foreach($newSquirrel as $key => $v){
//获取笼位号
$cage = $this->CageModel->field("number,type")->where("cage={$v['cage']}")->fRow();
$type = $cage['type']==1?"库存笼":"繁殖笼";
//断奶提醒
if($v['weaning_time']==date("Y-m-d",time())){
$remind[] = "{$type}【{$cage['number']}】幼崽已到{$v['weaning_time']}断奶";
}
//护理结束提醒
if($v['weaning_time']==date("Y-m-d",time())){
$remind[] = "{$type}【{$cage['number']}】幼崽已到{$v['weaning_time']}结束护理";
}
//性成熟时间提醒
if($v['grow_time']==date("Y-m-d",time())){
$remind[] = "{$type}【{$cage['number']}】幼崽已到{$v['weaning_time']}成熟";
}
//不育鼠时间提醒
if($v['infertility_time']==date("Y-m-d",time())){
$remind[] = "{$type}【{$cage['number']}】幼崽已到{$v['weaning_time']}结束不育时间";
}
//处死提醒
if($v['kill_time']==date("Y-m-d",time())){
$remind[] = "{$type}【{$cage['number']}】幼崽已到{$v['weaning_time']}已到处死时间";
}
//删除提醒
if($v['del_time']==date("Y-m-d",time())){
$remind[] = "{$type}【{$cage['number']}】幼崽已到{$v['weaning_time']}已到删除时间";
}
//剪尾提醒
if($v['jianwei_time']==date("Y-m-d",time())){
$remind[] = "{$type}【{$cage['number']}】幼崽已到{$v['weaning_time']}改进行剪尾";
}
//实验提醒
if($v['test_time']==date("Y-m-d",time())){
$remind[] = "{$type}【{$cage['number']}】幼崽已到可实验时间{$v['weaning_time']}";
}
}
Tool_Fnc::apiMsg('获取成功', '200');
}
}

@ -7,12 +7,9 @@ class AdminModel extends Orm_Base{
'admin_username' => array('type' => "varchar(45)",'comment' => ''),
'admin_password' => array('type' => "int(11)",'comment' => ''),
'admin_created' => array('type' => "char(15)",'comment' => ''),
'hospital' => array('type' => "int(11)",'comment' => ''),
'hospital_name' => array('type' => "char(15)",'comment' => ''),
'admin_status' => array('type' => "int(1)",'comment' => ''),
'admin_token' => array('type' => "varchar(33)",'comment' => ''),
'admin_pwd' => array('type' => "varchar(33)",'comment' => ''),
);
public $pk = 'admin_id';
}
?>

Loading…
Cancel
Save