fixed
This commit is contained in:
parent
50fc7c1d15
commit
af9cfe7ae8
|
@ -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'],
|
||||
|
|
|
@ -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'],
|
||||
|
|
Loading…
Reference in New Issue