diff --git a/application/controllers/Api/Cage.php b/application/controllers/Api/Cage.php index 9b0cb13..9d6cb18 100644 --- a/application/controllers/Api/Cage.php +++ b/application/controllers/Api/Cage.php @@ -9,12 +9,14 @@ class Api_CageController extends Ctrl_Api{ public $Cagemodel; public $POST; public $Cagecolormodel; + public $SquirrelModel; public $Usermodel; public function init() { $this->Cagemodel = new CageModel(); $this->POST =json_decode(file_get_contents('php://input'),true); $this->Cagecolormodel = new CagecolorModel(); $this->Usermodel = new UserModel(); + $this->SquirrelModel = new SquirrelModel(); } /** * 鼠笼列表接口 @@ -80,9 +82,6 @@ class Api_CageController extends Ctrl_Api{ $ret = $this->Cagemodel->insert($data); if(!$ret) Tool_Fnc::apiMsg('笼位建设失败', '500'); Tool_Fnc::apiMsg('笼位建设成功', '200'); - } - public function edidAction(){ - } /** * 获取笼位号 @@ -120,5 +119,15 @@ class Api_CageController extends Ctrl_Api{ $data = $this->Usermodel->getUser($uid); Tool_Fnc::apiMsg('获取成功', '200',$data); } + public function getCageinfoACtion(){ + $id = empty($this->POST['id'])?Tool_Fnc::apiMsg('缺少笼位ID', '500'):$this->POST['id']; + $type = empty($this->POST['type'])?Tool_Fnc::apiMsg('缺少笼位ID', '500'):$this->POST['type']; + $params['where'] = "and cage = {$id}"; + $params['type'] =$type; + $data['cage'] = $this->Cagemodel->getOneInfo($id); + $data['cage']['code'] = ''; + $data['squirrel'] = $this->SquirrelModel->getModelList($params); + Tool_Fnc::apiMsg('获取成功', '200',$data); + } } diff --git a/application/controllers/Api/Squirrel.php b/application/controllers/Api/Squirrel.php index 5facbea..1d7ae93 100644 --- a/application/controllers/Api/Squirrel.php +++ b/application/controllers/Api/Squirrel.php @@ -168,7 +168,7 @@ class Api_SquirrelController extends Ctrl_Api{ $data['infertility_time'] = date("Y-m-d",strtotime("+{$squirrelSet['infertility_time']} month",strtotime($data['birthday']))); $data['dose_time'] = date("Y-m-d",strtotime("+{$squirrelSet['dose_time']} day",strtotime($data['birthday']))); $ret = $this->Squirrelmodel->update($data); - if(!$ret) Tool_Fnc::apiMsg('信息更新失败', '500'); + if(!$ret) Tool_Fnc::apiMsg('信息未变更', '500'); Tool_Fnc::apiMsg('信息更新成功', '200'); } /** @@ -250,6 +250,37 @@ class Api_SquirrelController extends Ctrl_Api{ if(!$ret) Tool_Fnc::apiMsg('添加失败', '500'); Tool_Fnc::apiMsg('添加成功', '200'); } + public function editNewSquirrelAction(){ + //查询笼位号 + $data['c_user_id'] = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid']; + $data['id'] = empty($this->POST['id'])||!isset($this->POST['id'])?Tool_Fnc::apiMsg('系统错误', '500'):Tool_Fnc::safe_string($this->POST['id']); + $data['count'] =empty($this->POST['count'])||!isset($this->POST['birthday'])?Tool_Fnc::apiMsg('填写幼崽数量', '500'):Tool_Fnc::safe_string($this->POST['count']); + $data['birthday'] =empty($this->POST['birthday'])||!isset($this->POST['birthday'])?Tool_Fnc::apiMsg('请选择生日', '500'):Tool_Fnc::safe_string($this->POST['birthday']); + $data['father'] = empty($this->POST['father'])||!isset($this->POST['father'])?0:Tool_Fnc::safe_string($this->POST['father']); + $data['mother'] = empty($this->POST['mother'])||!isset($this->POST['father'])?0:Tool_Fnc::safe_string($this->POST['mother']); + $data['strains'] =empty($this->POST['strains'])||!isset($this->POST['strains'])?Tool_Fnc::apiMsg('请填写品系', '500'):Tool_Fnc::safe_string($this->POST['strains']); + $data['gene'] =empty($this->POST['gene'])||!isset($this->POST['gene'])?Tool_Fnc::apiMsg('请填写基因', '500'):Tool_Fnc::safe_string($this->POST['gene']); + $data['remark'] = empty($this->POST['remark'])||!isset($this->POST['remark'])?'':Tool_Fnc::safe_string($this->POST['remark']); + $data['cage'] =empty($this->POST['cage'])||!isset($this->POST['cage'])?Tool_Fnc::apiMsg('未找到当前笼位ID', '500'):Tool_Fnc::safe_string($this->POST['cage']); + $data['created'] = date('Y-m-d H:i:s',time()); + //获取当前用户仓鼠的配置 + $params['user_id'] = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid']; + $squirrelSet = $this->SquirrelSetModel->getsetinfo($params); + //根据生日获取各个提醒时间 + $data['weaning_time'] = date("Y-m-d",strtotime("+{$squirrelSet['weaning_time']} day",strtotime($data['birthday']))); + $data['nursing_time'] = date("Y-m-d",strtotime("+{$squirrelSet['nursing_time']} day",strtotime($data['birthday']))); + $data['grow_time'] =$data['sex']==1? date("Y-m-d",strtotime("+{$squirrelSet['male_grow_time']} days",strtotime($data['birthday']))):date("Y-m-d",strtotime("+{$squirrelSet['female_grow_time']} days",strtotime($data['birthday']))); + $data['infertility_time'] = date("Y-m-d",strtotime("+{$squirrelSet['infertility_time']} month",strtotime($data['birthday']))); + $data['dose_time'] = date("Y-m-d",strtotime("+{$squirrelSet['dose_time']} day",strtotime($data['birthday']))); + $ret = $this->NewSquirrelmodel->update($data); + if(!$ret) Tool_Fnc::apiMsg('信息未变更', '500'); + Tool_Fnc::apiMsg('编辑成功', '200'); + } + public function getNewSquirrelAction(){ + $id = empty($this->POST['id'])||!isset($this->POST['id'])?Tool_Fnc::apiMsg('幼崽ID缺失', '500'):Tool_Fnc::safe_string($this->POST['id']); + $data = $this->NewSquirrelmodel->getOneInfo($id); + Tool_Fnc::apiMsg('获取成功', '200',$data); + } public function getparentsAction(){ $return = $this->Squirrelmodel->partent(); Tool_Fnc::apiMsg('获取成功', '200',$return); @@ -272,5 +303,10 @@ class Api_SquirrelController extends Ctrl_Api{ $this->Squirrelmodel->operate($data); Tool_Fnc::apiMsg('操作已更新', '200'); } + public function getoperateAction(){ + $id = empty($this->POST['id'])?Tool_Fnc::apiMsg('小鼠ID缺失', '500'):$this->POST['id']; + $data = $this->Squirrelmodel->field('id,jianwei_time,jianwei_show,kill_time,kill_show,test_time,test_show,del_time,del_show')->where("id={$id}")->fRow(); + Tool_Fnc::apiMsg('获取成功', '200',$data); + } } diff --git a/application/models/NewSquirrel.php b/application/models/NewSquirrel.php index 460dc95..321b8ef 100644 --- a/application/models/NewSquirrel.php +++ b/application/models/NewSquirrel.php @@ -35,5 +35,8 @@ class NewSquirrelModel extends Orm_Base{ } return $data; } + public function getOneInfo($squirrel){ + return $this->field('count,birthday,father,mother,strains,gene,remark')->where("id={$squirrel}")->fRow(); + } } diff --git a/conf/application.ini b/conf/application.ini index 371dc94..a530b71 100644 --- a/conf/application.ini +++ b/conf/application.ini @@ -13,6 +13,8 @@ db.database.password = "root" redis.default.host = 127.0.0.1 redis.default.port = 6379 redis.default.db = 2 +cangshu.url.small = "/public/icon/small" +cangshu.url.big = "/public/icon/big" web.url.img = "http://lyl.medical_wx.91paiyipai.com/" web.url.getui = "http://ys.medical_wx.huayan100.com/"