yangsai@163.com 6 months ago
parent 3dfb75055a
commit 0f7f52fcd6
  1. 15
      application/controllers/Api/Cage.php
  2. 38
      application/controllers/Api/Squirrel.php
  3. 3
      application/models/NewSquirrel.php
  4. 2
      conf/application.ini

@ -9,12 +9,14 @@ class Api_CageController extends Ctrl_Api{
public $Cagemodel; public $Cagemodel;
public $POST; public $POST;
public $Cagecolormodel; public $Cagecolormodel;
public $SquirrelModel;
public $Usermodel; public $Usermodel;
public function init() { public function init() {
$this->Cagemodel = new CageModel(); $this->Cagemodel = new CageModel();
$this->POST =json_decode(file_get_contents('php://input'),true); $this->POST =json_decode(file_get_contents('php://input'),true);
$this->Cagecolormodel = new CagecolorModel(); $this->Cagecolormodel = new CagecolorModel();
$this->Usermodel = new UserModel(); $this->Usermodel = new UserModel();
$this->SquirrelModel = new SquirrelModel();
} }
/** /**
* 鼠笼列表接口 * 鼠笼列表接口
@ -80,9 +82,6 @@ class Api_CageController extends Ctrl_Api{
$ret = $this->Cagemodel->insert($data); $ret = $this->Cagemodel->insert($data);
if(!$ret) Tool_Fnc::apiMsg('笼位建设失败', '500'); if(!$ret) Tool_Fnc::apiMsg('笼位建设失败', '500');
Tool_Fnc::apiMsg('笼位建设成功', '200'); Tool_Fnc::apiMsg('笼位建设成功', '200');
}
public function edidAction(){
} }
/** /**
* 获取笼位号 * 获取笼位号
@ -120,5 +119,15 @@ class Api_CageController extends Ctrl_Api{
$data = $this->Usermodel->getUser($uid); $data = $this->Usermodel->getUser($uid);
Tool_Fnc::apiMsg('获取成功', '200',$data); 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);
}
} }

@ -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['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']))); $data['dose_time'] = date("Y-m-d",strtotime("+{$squirrelSet['dose_time']} day",strtotime($data['birthday'])));
$ret = $this->Squirrelmodel->update($data); $ret = $this->Squirrelmodel->update($data);
if(!$ret) Tool_Fnc::apiMsg('信息更新失败', '500'); if(!$ret) Tool_Fnc::apiMsg('信息未变更', '500');
Tool_Fnc::apiMsg('信息更新成功', '200'); Tool_Fnc::apiMsg('信息更新成功', '200');
} }
/** /**
@ -250,6 +250,37 @@ class Api_SquirrelController extends Ctrl_Api{
if(!$ret) Tool_Fnc::apiMsg('添加失败', '500'); if(!$ret) Tool_Fnc::apiMsg('添加失败', '500');
Tool_Fnc::apiMsg('添加成功', '200'); 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(){ public function getparentsAction(){
$return = $this->Squirrelmodel->partent(); $return = $this->Squirrelmodel->partent();
Tool_Fnc::apiMsg('获取成功', '200',$return); Tool_Fnc::apiMsg('获取成功', '200',$return);
@ -272,5 +303,10 @@ class Api_SquirrelController extends Ctrl_Api{
$this->Squirrelmodel->operate($data); $this->Squirrelmodel->operate($data);
Tool_Fnc::apiMsg('操作已更新', '200'); 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);
}
} }

@ -35,5 +35,8 @@ class NewSquirrelModel extends Orm_Base{
} }
return $data; return $data;
} }
public function getOneInfo($squirrel){
return $this->field('count,birthday,father,mother,strains,gene,remark')->where("id={$squirrel}")->fRow();
}
} }

@ -13,6 +13,8 @@ db.database.password = "root"
redis.default.host = 127.0.0.1 redis.default.host = 127.0.0.1
redis.default.port = 6379 redis.default.port = 6379
redis.default.db = 2 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.img = "http://lyl.medical_wx.91paiyipai.com/"
web.url.getui = "http://ys.medical_wx.huayan100.com/" web.url.getui = "http://ys.medical_wx.huayan100.com/"

Loading…
Cancel
Save