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 ];