From 31a52a7796b55987561ee548d521500fd4f9ae40 Mon Sep 17 00:00:00 2001 From: "yangsai@163.com" <2624183217@qq.com> Date: Tue, 21 May 2024 15:36:22 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AC=BC=E4=BD=8D=E8=BD=AC=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/controllers/Api/Cage.php | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/application/controllers/Api/Cage.php b/application/controllers/Api/Cage.php index 11dae7e..982054f 100644 --- a/application/controllers/Api/Cage.php +++ b/application/controllers/Api/Cage.php @@ -127,5 +127,38 @@ class Api_CageController extends Ctrl_Api{ $data['squirrel'] = $this->SquirrelModel->getModelList($params); 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); + } }