diff --git a/application/controllers/Api/Squirrel.php b/application/controllers/Api/Squirrel.php index 54de3ad..ae60f3d 100644 --- a/application/controllers/Api/Squirrel.php +++ b/application/controllers/Api/Squirrel.php @@ -88,7 +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'] =empty($this->POST['number'])||!isset($this->POST['sex'])?Tool_Fnc::apiMsg('请输入编号', '500'):Tool_Fnc::safe_string($this->POST['number']); + $data['number'] =empty($this->POST['number'])||!isset($this->POST['number'])?Tool_Fnc::apiMsg('请输入编号', '500'):Tool_Fnc::safe_string($this->POST['number']); $number = $this->Squirrelmodel->field("type")->where("number='{$data['number']}'")->fRow(); if(!empty($number)) Tool_Fnc::apiMsg('该编号已存在', '500'); $data['sex'] =empty($this->POST['sex'])||!isset($this->POST['sex'])?Tool_Fnc::apiMsg('请选择性别', '500'):Tool_Fnc::safe_string($this->POST['sex']); @@ -182,6 +182,9 @@ class Api_SquirrelController extends Ctrl_Api{ $data['gene'] =empty($this->POST['gene'])||!isset($this->POST['gene'])?Tool_Fnc::apiMsg('请填写基因', '500'):Tool_Fnc::safe_string($this->POST['gene']); $data['hair_color'] =empty($this->POST['hair_color'])||!isset($this->POST['hair_color'])?Tool_Fnc::apiMsg('请选择毛色', '500'):Tool_Fnc::safe_string($this->POST['hair_color']); $data['remark'] = empty($this->POST['remark'])||!isset($this->POST['remark'])?'':Tool_Fnc::safe_string($this->POST['remark']); + $data['number'] =empty($this->POST['number'])||!isset($this->POST['number'])?Tool_Fnc::apiMsg('请输入编号', '500'):Tool_Fnc::safe_string($this->POST['number']); + $number = $this->Squirrelmodel->field("type")->where("number='{$data['number']}' and id!={$data['id'] }")->fRow(); + if(!empty($number)) Tool_Fnc::apiMsg('该编号已存在', '500'); $data['created'] = date('Y-m-d H:i:s',time()); $squirrelinfo = $this->Squirrelmodel->field("*")->where("id={$data['id']}")->fRow(); $cageinfo = $this->CageModel->field("id,type")->where("id={$squirrelinfo['cage']}")->fRow();