diff --git a/app/api/controller/AnimalBreedController.php b/app/api/controller/AnimalBreedController.php index 521eaa6f..e869186e 100644 --- a/app/api/controller/AnimalBreedController.php +++ b/app/api/controller/AnimalBreedController.php @@ -17,15 +17,15 @@ //添加饲养动物 public function addAnimal(): Json { - $params = $this->request->post(['user_id','kind','breed','gender','age','status','weight','pic']); - if(empty($params['user_id']) || empty($params['kind']) || empty($params['breed']) || empty($params['gender']) || !in_array($params['gender'],[1,2]) || empty($params['age']) || empty($params['status']) || !in_array($params['status'],[1,2,3,4]) || empty($params['weight'])){ + $params = $this->request->post(['user_id','code','kind','breed','gender','age','status','weight','pic']); + if(empty($params['user_id']) || empty($params['code']) || empty($params['kind']) || empty($params['breed']) || empty($params['gender']) || !in_array($params['gender'],[1,2]) || empty($params['age']) || empty($params['status']) || !in_array($params['status'],[1,2,3,4]) || empty($params['weight'])){ return $this->fail('参数错误'); } //写入数据 Db::transaction(function () use($params) { $animalId = Db::name('farmer_animal_breed')->insertGetId([ 'user_id' => $params['user_id'], - 'animal_code' => '', + 'animal_code' => $params['code'], 'animal_kind' => $params['kind'], 'animal_breed' => $params['breed'], 'animal_gender' => $params['gender'], diff --git a/app/api/controller/PoultryBreedController.php b/app/api/controller/PoultryBreedController.php index 09c22d85..35b3a5eb 100644 --- a/app/api/controller/PoultryBreedController.php +++ b/app/api/controller/PoultryBreedController.php @@ -17,15 +17,15 @@ //添加饲养家禽 public function addPoultry(): Json { - $params = $this->request->post(['user_id','kind','breed','gender','age','status','weight','pic']); - if(empty($params['user_id']) || empty($params['kind']) || empty($params['breed']) || empty($params['gender']) || !in_array($params['gender'],[1,2]) || empty($params['age']) || empty($params['status']) || !in_array($params['status'],[1,2,3,4]) || empty($params['weight'])){ + $params = $this->request->post(['user_id','code','kind','breed','gender','age','status','weight','pic']); + if(empty($params['user_id']) || empty($params['code']) || empty($params['kind']) || empty($params['breed']) || empty($params['gender']) || !in_array($params['gender'],[1,2]) || empty($params['age']) || empty($params['status']) || !in_array($params['status'],[1,2,3,4]) || empty($params['weight'])){ return $this->fail('参数错误'); } //写入数据 Db::transaction(function () use($params) { $animalId = Db::name('farmer_poultry_breed')->insertGetId([ 'user_id' => $params['user_id'], - 'code' => '', + 'code' => $params['code'], 'kind' => $params['kind'], 'breed' => $params['breed'], 'gender' => $params['gender'],