|
|
|
@ -88,11 +88,7 @@ class Api_SquirrelController extends Ctrl_Api{ |
|
|
|
|
$CageNum = empty($CageNum)?1:(int) $CageNum['num']+1; |
|
|
|
|
$data['c_user_id'] = empty($this->POST['uid'])?Tool_Fnc::apiMsg('请先登录', '500'):$this->POST['uid']; |
|
|
|
|
$data['type'] = $this->POST['type']; |
|
|
|
|
$data['number'] = "SN00000".$CageNum; |
|
|
|
|
if($CageNum>9) $data['number'] = "SN0000".$CageNum; |
|
|
|
|
if($CageNum>99) $data['number'] = "SN000".$CageNum; |
|
|
|
|
if($CageNum>999) $data['number'] = "SN00".$CageNum; |
|
|
|
|
if($CageNum>9999) $data['number'] = "SN0".$CageNum; |
|
|
|
|
|
|
|
|
|
$data['sex'] =empty($this->POST['sex'])||!isset($this->POST['sex'])?Tool_Fnc::apiMsg('请选择性别', '500'):Tool_Fnc::safe_string($this->POST['sex']); |
|
|
|
|
$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']); |
|
|
|
@ -103,6 +99,11 @@ class Api_SquirrelController extends Ctrl_Api{ |
|
|
|
|
$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()); |
|
|
|
|
$data['number'] = $data['strains_id']."00000".$CageNum; |
|
|
|
|
if($CageNum>9) $data['number'] = $data['strains_id']."0000".$CageNum; |
|
|
|
|
if($CageNum>99) $data['number'] = $data['strains_id']."000".$CageNum; |
|
|
|
|
if($CageNum>999) $data['number'] = $data['strains_id']."00".$CageNum; |
|
|
|
|
if($CageNum>9999) $data['number'] = $data['strains_id']."0".$CageNum; |
|
|
|
|
//判断鼠笼鼠的数量是否可以容纳 |
|
|
|
|
if(!$this->Squirrelmodel->isFull($data['cage'],$this->POST['uid'])) Tool_Fnc::apiMsg('当前笼位已满,请重新选择笼位添加', '500'); |
|
|
|
|
//获取当前用户仓鼠的配置 |
|
|
|
@ -116,6 +117,12 @@ class Api_SquirrelController extends Ctrl_Api{ |
|
|
|
|
$data['dose_time'] = date("Y-m-d",strtotime("+{$squirrelSet['dose_time']} day",strtotime($data['birthday']))); |
|
|
|
|
$ret = $this->Squirrelmodel->insert($data); |
|
|
|
|
if(!$ret) Tool_Fnc::apiMsg('小鼠建档失败', '500'); |
|
|
|
|
//添加品系 |
|
|
|
|
$StrainsModel = new StrainsModel(); |
|
|
|
|
$StrainsModel->setInfo(['title'=>$data['gene'],'is_delete'=>$data['c_user_id'],'created'=>date("Y-m-d H:i:s",time())]); |
|
|
|
|
//添加基因 |
|
|
|
|
$GenModel = new GeneModel(); |
|
|
|
|
$GenModel->setInfo(['title'=>$data['gene'],'is_delete'=>$data['c_user_id'],'created'=>date("Y-m-d H:i:s",time())]); |
|
|
|
|
Tool_Fnc::apiMsg('小鼠建档成功', '200'); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|