笼位转移

master
yangsai@163.com 6 months ago
parent 0eea0df19a
commit 31a52a7796
  1. 33
      application/controllers/Api/Cage.php

@ -127,5 +127,38 @@ class Api_CageController extends Ctrl_Api{
$data['squirrel'] = $this->SquirrelModel->getModelList($params); $data['squirrel'] = $this->SquirrelModel->getModelList($params);
Tool_Fnc::apiMsg('获取成功', '200',$data); Tool_Fnc::apiMsg('获取成功', '200',$data);
} }
public function cageMoveAction(){
$uid = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid'];
$id = empty($this->POST['id'])?Tool_Fnc::apiMsg('小鼠ID', '500'):$this->POST['id'];
$cage = empty($this->POST['cage'])?Tool_Fnc::apiMsg('笼位ID', '500'):$this->POST['cage'];
$data['id'] = $id;
$data['cage'] = $cage;
if(!$this->SquirrelModel->update($data)) Tool_Fnc::apiMsg('笼位未发生变化', '500');
Tool_Fnc::apiMsg('转移成功', '200');
}
//获取转移笼位列表
public function cagemovellistAction(){
$uid = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid'];
$id = empty($this->POST['id'])?Tool_Fnc::apiMsg('小鼠ID', '500'):$this->POST['id'];
$squirrel = $this->SquirrelModel->getOneInfo($id);
$data = $this->Cagemodel->field('id,number,color,strains,type ')->where("c_user_id='{$uid}' and id!={$squirrel['cage']}")->fList();
foreach($data as $key => $val){
if(!$this->SquirrelModel->isFull($val['cage'],$uid)) unset($data[$key]);
//查询公鼠
$sql = "select count(*) num from squirrel where cage={$data[$key]['id']} and is_kill=0 and is_delete=0 and sex=1";
$mannum = $this->Cagemodel->query($sql);
if(!empty($mannum)){
$data[$key]['mannum'] = $mannum[0]['num'];
}
//查询母鼠
$sql = "select count(*) num from squirrel where cage={$data[$key]['id']} and is_kill=0 and is_delete=0 and sex=2";
$womannum = $this->Cagemodel->query($sql);
if(!empty($womannum)){
$data[$key]['womannum'] = $womannum[0]['num'];
}
$data[$key]['type_color'] = $data[$key]['type']==2?'#FF0000':'';
}
Tool_Fnc::apiMsg('获取成功 ', '200',$data);
}
} }

Loading…
Cancel
Save