From 4a59c1dc0df80f540c3d48be68c36837ec5ab85f Mon Sep 17 00:00:00 2001 From: "HESU\\HESU" <1696136552@qq.com> Date: Fri, 23 May 2025 16:49:21 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BD=91=E7=AB=99=E8=BD=A6=E8=BE=86=E7=AD=9B?= =?UTF-8?q?=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/apis/controller/BrandController.php | 20 ++++++++++++++++++-- app/apis/service/BrandService.php | 8 ++++++-- app/apis/service/VehicleNewService.php | 4 +--- config/route.php | 8 ++++---- 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/app/apis/controller/BrandController.php b/app/apis/controller/BrandController.php index de01980..116ce5f 100644 --- a/app/apis/controller/BrandController.php +++ b/app/apis/controller/BrandController.php @@ -41,7 +41,7 @@ class BrandController extends BaseController */ protected function postProcessItem(array $item, string $scene): array { - if ($scene === 'default' || $scene === 'letter' || $scene === 'hot') { + if ($scene === 'default' || $scene === 'letter' || $scene === 'hot' || $scene === 'show') { $result = [ 'id' => $item['id'], 'status' => $item['status'], @@ -107,7 +107,7 @@ class BrandController extends BaseController $params['filters'][] = ['field' => 'is_hot', 'operator' => '=', 'value' => 1]; } } - + return $params; } @@ -141,4 +141,20 @@ class BrandController extends BaseController } } + /** + * 详情 + * + * @param Request $request 请求对象 + * @return Response 响应对象 + */ + public function detail(Request $request, int $id, string $scene = 'show'): Response + { + try { + $request->setGet(['id'=>$id]); + return parent::one($request, $scene); + } catch (\Throwable $th) { + return $this->errorResponse($th->getMessage()); + } + } + } \ No newline at end of file diff --git a/app/apis/service/BrandService.php b/app/apis/service/BrandService.php index dcd4933..37de96c 100644 --- a/app/apis/service/BrandService.php +++ b/app/apis/service/BrandService.php @@ -61,7 +61,7 @@ class BrandService extends BaseService ], ]; }, - 'hot' => function ($params) { + 'show' => function ($params) { return [ 'filters' => [ ['field' => 'status', 'operator' => '=', 'value' => '1'], @@ -69,7 +69,11 @@ class BrandService extends BaseService ], 'fields' => ['id', 'status', 'sort', 'toppic', 'descpic', 'logo', 'letter', 'is_hot', 'created_at', 'updated_at'], 'relations' => [ - 'translation' => ['brand_id', 'name'] + 'translation' => ['brand_id', 'name', 'desc','toppic_alt','descpic_alt','logo_alt'], + 'banners' => ['id', 'pic', 'sort',], + 'banners.translation' => ['id', 'alt',], + 'traits' => ['id', 'sort',], + 'traits.translation' => ['id', 'title', 'content',], ], 'sorts' => [ ['field' => 'id', 'direction' => 'desc'] diff --git a/app/apis/service/VehicleNewService.php b/app/apis/service/VehicleNewService.php index dbba182..f07d994 100644 --- a/app/apis/service/VehicleNewService.php +++ b/app/apis/service/VehicleNewService.php @@ -29,9 +29,7 @@ class VehicleNewService extends BaseService 'default' => function ($params) { $keyword = $params['keyword'] ?? ''; return [ - 'filters' => [ -// ['field' => '***', 'operator' => '=', 'value' => '***'] - ], + 'filters' => $params['filters'], 'fields' => ['id', 'vin', 'brand', 'cover', 'price', 'type', 'energy', 'model', 'video', 'views', 'created_at', 'updated_at'], 'relations' => [ 'translation' => ['vehicle_id', 'locale', 'name', 'condition_desc', 'location'], diff --git a/config/route.php b/config/route.php index abd0e5a..99beb21 100644 --- a/config/route.php +++ b/config/route.php @@ -42,11 +42,11 @@ Route::group('/apis', function() { Route::any('/agt/privacy', [\app\apis\controller\AgreementController::class, 'one']); // 品牌按字母查询 Route::any('/brand/letterAll', [\app\apis\controller\BrandController::class, 'letterAll']); - // 品牌按字母查询 - Route::any('/brand/detail', [\app\apis\controller\BrandController::class, 'detail']); + // 品牌详情 + Route::any('/brand/detail/{id}', [\app\apis\controller\BrandController::class, 'detail']); // 新车管理 - Route::any('/vehicle/new/list', [\app\console\controller\VehicleNewController::class, 'index']); - Route::any('/vehicle/new/{id}/detail', [\app\console\controller\VehicleNewController::class, 'detail']); + Route::any('/vehicle/new/list', [\app\apis\controller\VehicleNewController::class, 'index']); + Route::any('/vehicle/new/{id}/detail', [\app\apis\controller\VehicleNewController::class, 'detail']); // 能源列表 Route::any('/energy/preset', [\app\console\controller\EnergyController::class, 'presets']); });