From 57a45f1b0a96420e815c7c275066aeb23c11b226 Mon Sep 17 00:00:00 2001 From: wang hou sheng <76928547+wanghousheng@users.noreply.github.com> Date: Sat, 20 Apr 2024 21:07:16 +0800 Subject: [PATCH] 1 --- app/api/controller/Index.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/api/controller/Index.php b/app/api/controller/Index.php index 274014c8..b87f127f 100644 --- a/app/api/controller/Index.php +++ b/app/api/controller/Index.php @@ -2,13 +2,13 @@ namespace app\api\controller; +use app\api\model\City; use app\common\model\Banner; -use app\common\model\UploadFile; use think\db\exception\DataNotFoundException; use think\db\exception\DbException; use think\db\exception\ModelNotFoundException; use think\response\Json; -use app\api\model\City; + /** * 默认控制器 * Class Index @@ -23,10 +23,10 @@ class Index extends Controller public function getBannerList() { - $list = Banner::where("status", 10)->select()->toArray(); + $list = Banner::where("status", 10)->with(['image'])->select()->toArray(); foreach ($list as &$value) { - $file_path = UploadFile::where('file_id', $value['image_id'])->field('file_id,file_path,file_type,storage,domain')->find(); - $value['image'] = getUrl($file_path['file_path'], $file_path['domain']); + unset($value['image']); + $value['image'] = $value['image_url']; } return $this->renderSuccess($list); } @@ -51,7 +51,7 @@ class Index extends Controller */ public function cityList($search = "") { - + $model = City::withoutGlobalScope()->where('status', 1); if ($search) { $model = $model->where('name|first_letter', 'like', "%$search%"); @@ -65,7 +65,7 @@ class Index extends Controller } $list[$item['first_letter']][] = $item; } - $result = ['hotList'=>$hotList, "cityList"=>$list]; + $result = ['hotList' => $hotList, "cityList" => $list]; return $this->renderSuccess($result); } } \ No newline at end of file