作者 郭盛
1 个管道 的构建 通过 耗费 4 秒

修改数组返回自动匹配

@@ -482,39 +482,30 @@ class Attestation extends Api @@ -482,39 +482,30 @@ class Attestation extends Api
482 } 482 }
483 $where['status'] = ['eq',1]; 483 $where['status'] = ['eq',1];
484 $data = Db::name('government') 484 $data = Db::name('government')
  485 + ->field('id,company_name')
485 ->where($where) 486 ->where($where)
486 ->select(); 487 ->select();
487 if(empty($data)){ 488 if(empty($data)){
488 $city = Db::name('government') 489 $city = Db::name('government')
  490 + ->field('id,company_name')
489 ->where('province','Like',"$param[province]%") 491 ->where('province','Like',"$param[province]%")
490 ->where('city',$param['city']) 492 ->where('city',$param['city'])
491 ->select(); 493 ->select();
492 if(empty($city)){ 494 if(empty($city)){
493 $province = Db::name('government') 495 $province = Db::name('government')
  496 + ->field('id,company_name')
494 ->where('province','Like',"$param[province]%") 497 ->where('province','Like',"$param[province]%")
495 ->select(); 498 ->select();
496 if(empty($province)){ 499 if(empty($province)){
497 $this->success('暂无机构'); 500 $this->success('暂无机构');
498 }else{ 501 }else{
499 - foreach ($province as $v){  
500 - $res['id'] = $v['id'];  
501 - $res['institution'] = $v['company_name'];  
502 - }  
503 - $this->success('success',$res); 502 + $this->success('success',$province);
504 } 503 }
505 }else{ 504 }else{
506 - foreach ($city as $v){  
507 - $res['id'] = $v['id'];  
508 - $res['institution'] = $v['company_name'];  
509 - }  
510 - $this->success('success',$res); 505 + $this->success('success',$city);
511 } 506 }
512 }else{ 507 }else{
513 - foreach ($data as $v){  
514 - $res['id'] = $v['id'];  
515 - $res['institution'] = $v['company_name'];  
516 - }  
517 - $this->success('success',$res); 508 + $this->success('success',$data);
518 } 509 }
519 } 510 }
520 511