Merge pull request 'update' (#33) from zhangwei into dev

Reviewed-on: #33
This commit is contained in:
weiz 2023-11-30 11:22:21 +08:00
commit 160d6bc844
1 changed files with 4 additions and 19 deletions

View File

@ -59,7 +59,7 @@
public function add(): Json public function add(): Json
{ {
//获取参数并验证 //获取参数并验证
$fields = ['title','area','province_code','city_code','county_code','town_code','village_code','group_code','master_name','master_phone','pic']; $fields = ['title','area','province_code','city_code','county_code','address','longitude','latitude','master_name','master_phone','pic'];
$params = $this->request->post($fields); $params = $this->request->post($fields);
foreach($fields as $v){ foreach($fields as $v){
if(!isset($params[$v]) || $params[$v] == ''){ if(!isset($params[$v]) || $params[$v] == ''){
@ -84,18 +84,6 @@
if($county->isEmpty()){ if($county->isEmpty()){
return $this->fail('区县编码错误'); return $this->fail('区县编码错误');
} }
$town = Town::field('town_name')->where('county_code',$params['county_code'])->where('town_code',$params['town_code'])->findOrEmpty();
if($town->isEmpty()){
return $this->fail('镇街编码错误');
}
$village = Village::field('village_name')->where('town_code',$params['town_code'])->where('village_code',$params['village_code'])->findOrEmpty();
if($village->isEmpty()){
return $this->fail('乡村编码错误');
}
$group = Group::field('group_name')->where('id',$params['group_code'])->findOrEmpty();
if($group->isEmpty()){
return $this->fail('小组编码错误');
}
//验证土地图片字段是否是json数组 //验证土地图片字段是否是json数组
$pic = json_decode($params['pic'],true); $pic = json_decode($params['pic'],true);
if(empty($pic)){ if(empty($pic)){
@ -113,12 +101,9 @@
'city_name' => $city['city_name'], 'city_name' => $city['city_name'],
'county_code' => $params['county_code'], 'county_code' => $params['county_code'],
'county_name' => $county['county_name'], 'county_name' => $county['county_name'],
'town_code' => $params['town_code'], 'address' => $params['address'],
'town_name' => $town['town_name'], 'longitude' => $params['longitude'],
'village_code' => $params['village_code'], 'latitude' => $params['latitude'],
'village_name' => $village['village_name'],
'group_code' => $params['group_code'],
'group_name' => $group['group_name'],
'master_name' => $params['master_name'], 'master_name' => $params['master_name'],
'master_phone' => $params['master_phone'], 'master_phone' => $params['master_phone'],
'pic' => $params['pic'], 'pic' => $params['pic'],