Merge branch 'feature/hot' into develop
This commit is contained in:
@@ -5,6 +5,8 @@ namespace app\apis\controller;
|
|||||||
use app\apis\model\BrandBannerModel;
|
use app\apis\model\BrandBannerModel;
|
||||||
use app\apis\model\BrandTraitModel;
|
use app\apis\model\BrandTraitModel;
|
||||||
use app\apis\model\BrandTranslationModel;
|
use app\apis\model\BrandTranslationModel;
|
||||||
|
use app\apis\model\VehicleNewModel;
|
||||||
|
use app\apis\service\VehicleNewService;
|
||||||
use support\Request;
|
use support\Request;
|
||||||
use support\Response;
|
use support\Response;
|
||||||
use app\apis\model\BrandModel;
|
use app\apis\model\BrandModel;
|
||||||
@@ -88,6 +90,13 @@ class BrandController extends BaseController
|
|||||||
unset($v['translation']);
|
unset($v['translation']);
|
||||||
$result['trait'][$k] = $v;
|
$result['trait'][$k] = $v;
|
||||||
}
|
}
|
||||||
|
if($scene === 'hot'){
|
||||||
|
$vehicles = VehicleNewModel::where(['brand'=>$item['id']])->limit(8)->get();
|
||||||
|
foreach ($vehicles as &$v) {
|
||||||
|
$v['cover_full'] = (new \app\mzl\modules\upload\service\OssService())->generatePrivateUrl($v['cover']);
|
||||||
|
}
|
||||||
|
$result['vehicle'] = $vehicles;
|
||||||
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
return $item;
|
return $item;
|
||||||
@@ -103,12 +112,12 @@ class BrandController extends BaseController
|
|||||||
{
|
{
|
||||||
$params = parent::prepareParams($request, $scene);
|
$params = parent::prepareParams($request, $scene);
|
||||||
|
|
||||||
if ($scene === 'default' || $scene === 'letter') {
|
if ($scene === 'default' || $scene === 'letter' || $scene === 'hot') {
|
||||||
$params['filters'][] = ['field' => 'status', 'operator' => '=', 'value' => '1'];
|
$params['filters'][] = ['field' => 'status', 'operator' => '=', 'value' => '1'];
|
||||||
if(!empty($params['letter'])){
|
if(!empty($params['letter'])){
|
||||||
$params['filters'][] = ['field' => 'letter', 'operator' => '=', 'value' => $params['letter']];
|
$params['filters'][] = ['field' => 'letter', 'operator' => '=', 'value' => $params['letter']];
|
||||||
}
|
}
|
||||||
if(isset($params['is_hot']) && $params['is_hot'] == 1){
|
if(isset($params['is_hot']) && $params['is_hot'] == 1 || $scene === 'hot'){
|
||||||
$params['filters'][] = ['field' => 'is_hot', 'operator' => '=', 'value' => 1];
|
$params['filters'][] = ['field' => 'is_hot', 'operator' => '=', 'value' => 1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -146,6 +155,21 @@ class BrandController extends BaseController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页
|
||||||
|
*
|
||||||
|
* @param Request $request 请求对象
|
||||||
|
* @return Response 响应对象
|
||||||
|
*/
|
||||||
|
public function hot(Request $request, string $scene = 'hot'): Response
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
return parent::all($request, $scene);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
return $this->errorResponse($th->getMessage().$th->getFile().$th->getLine());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 详情
|
* 详情
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -61,6 +61,22 @@ class BrandService extends BaseService
|
|||||||
],
|
],
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
'hot' => function ($params) {
|
||||||
|
return [
|
||||||
|
'filters' => $params['filters'],
|
||||||
|
'fields' => ['id', 'status', 'sort', 'toppic', 'descpic', 'logo', 'letter', 'is_hot', 'created_at', 'updated_at'],
|
||||||
|
'relations' => [
|
||||||
|
'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']
|
||||||
|
],
|
||||||
|
];
|
||||||
|
},
|
||||||
'show' => function ($params) {
|
'show' => function ($params) {
|
||||||
return [
|
return [
|
||||||
'filters' => [
|
'filters' => [
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ Route::group('/apis', function() {
|
|||||||
Route::any('/agt/privacy', [\app\apis\controller\AgreementController::class, 'one']);
|
Route::any('/agt/privacy', [\app\apis\controller\AgreementController::class, 'one']);
|
||||||
// 品牌按字母查询
|
// 品牌按字母查询
|
||||||
Route::any('/brand/letterAll', [\app\apis\controller\BrandController::class, 'letterAll']);
|
Route::any('/brand/letterAll', [\app\apis\controller\BrandController::class, 'letterAll']);
|
||||||
|
//查询热门品牌
|
||||||
|
Route::any('/brand/hot', [\app\apis\controller\BrandController::class, 'hot']);
|
||||||
// 品牌详情
|
// 品牌详情
|
||||||
Route::any('/brand/detail/{id}', [\app\apis\controller\BrandController::class, 'detail']);
|
Route::any('/brand/detail/{id}', [\app\apis\controller\BrandController::class, 'detail']);
|
||||||
// 新车管理
|
// 新车管理
|
||||||
|
|||||||
Reference in New Issue
Block a user