From 60faecae99d7950053d17feef8c7a5aef68f6618 Mon Sep 17 00:00:00 2001 From: lq Date: Wed, 7 May 2025 22:44:15 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/HomeController.php | 15 +++++++++++++++ app/Service/HomeService.php | 19 ++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 7bd56920..5120216e 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -33,4 +33,19 @@ class HomeController extends BaseController '轮播图列表' ); } + + /** + * 项目列表 + * @Method GET + * @return JsonResponse + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ + public function projectList(): JsonResponse + { + return jok( + $this->service->projectList(), + '项目列表' + ); + } } diff --git a/app/Service/HomeService.php b/app/Service/HomeService.php index 9ace3626..e28761bb 100644 --- a/app/Service/HomeService.php +++ b/app/Service/HomeService.php @@ -27,7 +27,7 @@ class HomeService extends BaseService } /** - * 获取项目列表 + * 获取精选项目 * @return array * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface @@ -50,6 +50,23 @@ class HomeService extends BaseService * @throws ContainerExceptionInterface * @throws NotFoundExceptionInterface */ + public function projectList(): array + { + $this->where[] = [ 'status', '=', 1 ]; + $this->with = [ + 'frameworks:id,name', + 'labels:id,name', + 'category:id,name', + ]; + return $this->getPageList(); + } + + /** + * 获取轮播图 + * @return array + * @throws ContainerExceptionInterface + * @throws NotFoundExceptionInterface + */ public function carousel(): array { $this->where[] = [ 'is_carousel', '=', 1 ];