修复图片上传类型选择

This commit is contained in:
weiz 2023-10-25 15:00:39 +08:00
parent 9caca3c5a0
commit ea1f5ca2c1
3 changed files with 9 additions and 6 deletions

View File

@ -38,6 +38,7 @@
Db::name('farmer_animal_pic')->insert([
'animal_id' => $animalId,
'pic' => $params['pic'],
'type' => 1,
'create_time' => time()
]);
}
@ -100,8 +101,8 @@
//上传动物养殖情况图片
public function addAnimalPic(): Json
{
$params = $this->request->post(['animal_id','pic']);
if(empty($params['animal_id']) || empty($params['pic'])){
$params = $this->request->post(['animal_id','pic','type']);
if(empty($params['animal_id']) || empty($params['pic']) || empty($params['type']) || !in_array($params['type'],[1,2])){
return $this->fail('参数错误');
}
//写入数据

View File

@ -88,6 +88,7 @@
if(!empty($params['pic'])){
Db::name('farmer_land_crop_pic')->insert([
'crop_id' => $landCropId,
'type' => 1,
'pic' => $params['pic'],
'create_time' => time()
]);
@ -101,8 +102,8 @@
public function addLandCropPic(): Json
{
//获取参数
$params = $this->request->post(['crop_id','pic']);
if(empty($params['crop_id']) || empty($params['pic'])){
$params = $this->request->post(['crop_id','pic','type']);
if(empty($params['crop_id']) || empty($params['pic']) || empty($params['type']) || !in_array($params['type'],[1,2,3])){
return $this->fail('参数错误');
}
//写入数据

View File

@ -38,6 +38,7 @@
Db::name('farmer_poultry_pic')->insert([
'poultry_id' => $animalId,
'pic' => $params['pic'],
'type' => 1,
'create_time' => time()
]);
}
@ -100,8 +101,8 @@
//上传家禽养殖情况图片
public function addPoultryPic(): Json
{
$params = $this->request->post(['poultry_id','pic']);
if(empty($params['poultry_id']) || empty($params['pic'])){
$params = $this->request->post(['poultry_id','pic','type']);
if(empty($params['poultry_id']) || empty($params['pic']) || empty($params['type']) || !in_array($params['type'],[1,2])){
return $this->fail('参数错误');
}
//写入数据