品牌信息

This commit is contained in:
2025-05-21 11:28:30 +08:00
parent ff07c5bcd9
commit f8fa2bf3a9
17 changed files with 997 additions and 12 deletions
+3 -1
View File
@@ -65,7 +65,9 @@ class LocationController extends BaseController
$params = parent::prepareParams($request, $scene);
if ($scene === 'default') {
$params['filters'] = [];
$params['filters'][] = ['field' => 'user_id', 'operator' => '=', 'value' => $request->input('user_id')];
// $params['filters'][] = ['field' => 'user_id', 'operator' => '=', 'value' => 111];
}
return $params;
@@ -0,0 +1,119 @@
<?php
namespace app\console\controller;
use app\console\model\BrandBannerModel;
use app\console\service\BrandBannerService;
use app\console\validate\BrandBannerValidator;
use support\Request;
use support\Response;
use app\mzl\common\controller\BaseController;
class BrandBannerController extends BaseController
{
/**
* 不需要验证token的接口
* @var array
*/
protected $noNeedJwt = [];
/**
* 验证器
*/
protected mixed $validator = BrandBannerValidator::class;
/**
* 返回业务 Service 实例
*/
protected function getService()
{
return new BrandBannerService(new BrandBannerModel());
}
/**
* 额外字段处理 (根据场景处理)
* @param array $item
* @param string $scene
* @return array
*/
protected function postProcessItem(array $item, string $scene): array
{
if ($scene === 'default') {
return [
'id' => $item['id'],
'status' => $item['status'],
'sort' => $item['sort'],
'brand_id' => $item['brand_id'],
'title' => isset($item['translation']) ? $item['translation']['title'] : '',
'content' => isset($item['translation']) ? $item['translation']['content'] : '',
'created_at' => date('Y-m-d H:i:s', $item['created_at']),
'updated_at' => date('Y-m-d H:i:s', $item['updated_at'])
];
}
if ($scene === 'preset') {
return [
'id' => $item['id'],
'name' => isset($item['translation']) ? $item['translation']['name'] : ''
];
}
return $item;
}
/**
* 参数预处理 (根据场景处理)
* @param Request $request
* @param string $scene
* @return array
*/
protected function prepareParams(Request $request, string $scene): array
{
$params = parent::prepareParams($request, $scene);
if ($scene === 'default') {
}
return $params;
}
/**
* 分页
*
* @param Request $request 请求对象
* @return Response 响应对象
*/
public function index(Request $request, string $scene = 'default'): Response
{
try {
return parent::index($request, $scene);
} catch (\Throwable $th) {
return $this->errorResponse($th->getMessage().$th->getFile().$th->getLine());
}
}
public function add(Request $request): Response
{
try {
$id = $this->getService()->add($request->all());
return $id ? $this->successResponse(['id' => $id])
: $this->errorResponse();
} catch (\Throwable $th) {
return $this->errorResponse($th->getMessage());
}
}
public function edit(Request $request, int $id): Response
{
try {
return $this->getService()->edit($request->all(), $id)
? $this->successResponse()
: $this->errorResponse();
} catch (\Throwable $th) {
return $this->errorResponse($th->getMessage());
}
}
}
+23 -5
View File
@@ -41,14 +41,28 @@ class BrandController extends BaseController
{
if ($scene === 'default') {
return [
$result = [
'id' => $item['id'],
'status' => $item['status'],
'sort' => $item['sort'],
'toppic' => $item['toppic'],
'descpic' => $item['descpic'],
'logo' => $item['logo'],
'name' => isset($item['translation']) ? $item['translation']['name'] : '',
'desc' => isset($item['translation']) ? $item['translation']['desc'] : '',
'toppic_alt' => isset($item['translation']) ? $item['translation']['toppic_alt'] : '',
'descpic_alt' => isset($item['translation']) ? $item['translation']['descpic_alt'] : '',
'logo_alt' => isset($item['translation']) ? $item['translation']['logo_alt'] : '',
'created_at' => date('Y-m-d H:i:s', $item['created_at']),
'updated_at' => date('Y-m-d H:i:s', $item['updated_at'])
'updated_at' => date('Y-m-d H:i:s', $item['updated_at']),
];
foreach ($item['banner'] as $k => $v) {
$result['banner'][$k] = $v;
}
foreach ($item['trait'] as $k => $v) {
$result['trait'][$k] = $v;
}
return $result;
}
if ($scene === 'preset') {
@@ -86,6 +100,9 @@ class BrandController extends BaseController
*/
public function index(Request $request, string $scene = 'default'): Response
{
// $Brand = BrandModel::with('banner')->with('trait')->where('id',314)->first()->toArray();
// var_dump($Brand);
// return json($Brand);
try {
return parent::index($request, $scene);
} catch (\Throwable $th) {
@@ -108,8 +125,8 @@ class BrandController extends BaseController
public function add(Request $request): Response
{
try {
return $this->getService()->add($request->all())
? $this->successResponse()
$id = $this->getService()->add($request->all());
return $id ? $this->successResponse(['id' => $id])
: $this->errorResponse();
} catch (\Throwable $th) {
return $this->errorResponse($th->getMessage());
@@ -119,11 +136,12 @@ class BrandController extends BaseController
public function edit(Request $request, int $id): Response
{
try {
$request->setPost('id',$id);
return $this->getService()->edit($request->all(), $id)
? $this->successResponse()
: $this->errorResponse();
} catch (\Throwable $th) {
return $this->errorResponse($th->getMessage());
return $this->errorResponse($th->getMessage().$th->getFile().$th->getLine());
}
}
}
@@ -0,0 +1,112 @@
<?php
namespace app\console\controller;
use app\console\model\BrandTraitModel;
use app\console\service\BrandTraitService;
use app\console\validate\BrandTraitValidator;
use support\Request;
use support\Response;
use app\mzl\common\controller\BaseController;
class BrandTraitController extends BaseController
{
/**
* 不需要验证token的接口
* @var array
*/
protected $noNeedJwt = [];
/**
* 验证器
*/
protected mixed $validator = BrandTraitValidator::class;
/**
* 返回业务 Service 实例
*/
protected function getService()
{
return new BrandTraitService(new BrandTraitModel());
}
/**
* 额外字段处理 (根据场景处理)
* @param array $item
* @param string $scene
* @return array
*/
protected function postProcessItem(array $item, string $scene): array
{
if ($scene === 'default') {
return [
'id' => $item['id'],
'status' => $item['status'],
'sort' => $item['sort'],
'brand_id' => $item['brand_id'],
'title' => isset($item['translation']) ? $item['translation']['title'] : '',
'content' => isset($item['translation']) ? $item['translation']['content'] : '',
'created_at' => date('Y-m-d H:i:s', $item['created_at']),
'updated_at' => date('Y-m-d H:i:s', $item['updated_at'])
];
}
return $item;
}
/**
* 参数预处理 (根据场景处理)
* @param Request $request
* @param string $scene
* @return array
*/
protected function prepareParams(Request $request, string $scene): array
{
$params = parent::prepareParams($request, $scene);
if ($scene === 'default') {
}
return $params;
}
/**
* 分页
*
* @param Request $request 请求对象
* @return Response 响应对象
*/
public function index(Request $request, string $scene = 'default'): Response
{
try {
return parent::index($request, $scene);
} catch (\Throwable $th) {
return $this->errorResponse($th->getMessage().$th->getFile().$th->getLine());
}
}
public function add(Request $request): Response
{
try {
$id = $this->getService()->add($request->all());
return $id ? $this->successResponse(['id' => $id])
: $this->errorResponse();
} catch (\Throwable $th) {
return $this->errorResponse($th->getMessage());
}
}
public function edit(Request $request, int $id): Response
{
try {
return $this->getService()->edit($request->all(), $id)
? $this->successResponse()
: $this->errorResponse();
} catch (\Throwable $th) {
return $this->errorResponse($th->getMessage());
}
}
}
+83
View File
@@ -0,0 +1,83 @@
<?php
namespace app\console\model;
use support\Model;
/**
* VehicleDataModel
*/
class BrandBannerModel extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'hs_brand_banner';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
/**
* 模型的数据字段的保存格式。
*
* @var string
*/
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'brand_id', 'pic', 'status', 'sort', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
public function brand()
{
return $this->belongsTo(BrandModel::class, 'brand_id');
}
/**
* 单条翻译
*/
public function translation()
{
return $this->hasOne(BrandBannerTranslationModel::class, 'brand_id')->where('locale', locale());
}
/**
* 多条翻译
*/
public function translations()
{
return $this->hasMany(VehicleDataTranslationModel::class, 'brand_id');
}
const TRANS_FIELDS = [
'name', 'condition_desc'
];
}
@@ -0,0 +1,68 @@
<?php
namespace app\console\model;
use support\Model;
/**
* VehicleDataModel
*/
class BrandBannerTranslationModel extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'hs_brand_banner_translation';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
/**
* 模型的数据字段的保存格式。
*
* @var string
*/
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'brand_id', 'banner_id', 'alt', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
public function brand()
{
return $this->belongsTo(BrandModel::class, 'brand_id');
}
public function banner()
{
return $this->belongsTo(BrandBannerModel::class, 'banner_id');
}
}
+10 -1
View File
@@ -47,7 +47,7 @@ class BrandModel extends Model
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'status', 'sort', 'created_at', 'updated_at'];
protected $fillable = ['id', 'status', 'sort', 'toppic', 'descpic', 'logo', 'letter', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
@@ -64,4 +64,13 @@ class BrandModel extends Model
{
return $this->hasMany(BrandTranslationModel::class, 'brand_id');
}
public function banner()
{
return $this->hasMany(BrandBannerModel::class, 'brand_id','id');
}
public function trait()
{
return $this->hasMany(BrandTraitModel::class, 'brand_id','id');
}
}
+84
View File
@@ -0,0 +1,84 @@
<?php
namespace app\console\model;
use support\Model;
/**
* VehicleDataModel
*/
class BrandTraitModel extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'hs_brand_trait';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
/**
* 模型的数据字段的保存格式。
*
* @var string
*/
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'brand_id', 'status', 'sort', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
public function brand()
{
return $this->belongsTo(BrandModel::class, 'brand_id');
}
/**
* 单条翻译
*/
public function translation()
{
return $this->hasOne(BrandTraitTranslationModel::class, 'trait_id')->where('locale', locale());
}
/**
* 多条翻译
*/
public function translations()
{
return $this->hasMany(BrandTraitTranslationModel::class, 'trait_id');
}
const TRANS_FIELDS = [
'name', 'condition_desc'
];
}
@@ -0,0 +1,67 @@
<?php
namespace app\console\model;
use support\Model;
/**
* VehicleDataModel
*/
class BrandTraitTranslationModel extends Model
{
/**
* The connection name for the model.
*
* @var string|null
*/
protected $connection = 'mysql';
/**
* The table associated with the model.
*
* @var string
*/
protected $table = 'hs_brand_trait_translation';
/**
* The primary key associated with the table.
*
* @var string
*/
protected $primaryKey = 'id';
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public $timestamps = true;
/**
* 模型的数据字段的保存格式。
*
* @var string
*/
protected $dateFormat = 'U';
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'brand_id', 'trait_id', 'locale', 'title', 'content', 'created_at', 'updated_at'];
/**
* 不允许自动填充模型字段
*/
protected $guarded = [];
public function brand()
{
return $this->belongsTo(BrandModel::class, 'brand_id');
}
public function brandTrait()
{
return $this->belongsTo(BrandTraitModel::class, 'trait_id');
}
}
+1 -1
View File
@@ -47,7 +47,7 @@ class BrandTranslationModel extends Model
/**
* 允许自动填充模型字段
*/
protected $fillable = ['id', 'brand_id', 'locale', 'name'];
protected $fillable = ['id', 'brand_id', 'locale', 'name', 'desc','toppic_alt','descpic_alt','logo_alt'];
/**
* 不允许自动填充模型字段
+120
View File
@@ -0,0 +1,120 @@
<?php
namespace app\console\service;
use app\console\model\BrandBannerModel;
use app\mzl\common\services\BaseService;
use app\mzl\modules\translation\service\TranslationService;
use support\Db;
use support\exception\BusinessException;
class BrandBannerService extends BaseService
{
/**
* 定义模型
*
* @return string
*/
public function getModel(): string
{
return BrandBannerModel::class;
}
/**
* 多场景配置
*/
public function queryScenes(): array
{
return [
'default' => function ($params) {
return [
'filters' => [
['field' => 'status', 'operator' => '=', 'value' => '1'],
['field' => 'brand_id', 'operator' => '=', 'value' => $params['brand_id']],
],
'fields' => ['id', 'status', 'sort', 'brand_id', 'pic', 'created_at', 'updated_at'],
'relations' => [
'translation' => ['brand_id','banner_id', 'title', 'content']
],
'sorts' => [
['field' => 'id', 'direction' => 'desc']
],
'pagination' => [
'page' => $params['page'] ?? 1,
'per_page' => $params['per_page'] ?? 10,
]
];
},
];
}
protected array $translatable = [
'alt'
];
public function add(array $params)
{
$sourceLocale = locale();
$sourceFields = $this->extractSourceFields($params);
$sourceFields['brand_id'] = $params['brand_id'];
if (empty($sourceFields)) {
throw new \InvalidArgumentException("请传递至少一条 {$sourceLocale} 语言的翻译字段");
};
Db::beginTransaction();
try {
$info = $this->create($params);
if (!$info) {
throw new BusinessException('提交失败');
}
// 异步翻译并写入 hs_vehicle_data_translation 表
(new TranslationService())->queueTranslations(
'brandBanner',
$info->id,
$sourceLocale,
$sourceFields
);
Db::commit();
return $info->id;
} catch (\Throwable $th) {
Db::rollBack();
throw $th;
}
}
public function edit(array $params, int $id)
{
$sourceLocale = locale();
$sourceFields = $this->extractSourceFields($params);
if (empty($sourceFields)) {
throw new \InvalidArgumentException("请传递至少一条 {$sourceLocale} 语言的翻译字段");
};
Db::beginTransaction();
try {
$info = $this->update($id, $params);
if (!$info) {
throw new BusinessException('提交失败');
}
// 异步翻译并写入 hs_vehicle_data_translation 表
(new TranslationService())->queueTranslations(
'brandBanner',
$id,
$sourceLocale,
$sourceFields
);
Db::commit();
return $id;
} catch (\Throwable $th) {
Db::rollBack();
throw $th;
}
}
}
+105 -4
View File
@@ -2,7 +2,9 @@
namespace app\console\service;
use app\console\model\BrandBannerModel;
use app\console\model\BrandModel;
use app\console\model\BrandTraitModel;
use app\mzl\common\services\BaseService;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
@@ -33,9 +35,13 @@ class BrandService extends BaseService
'filters' => [
['field' => 'status', 'operator' => '=', 'value' => '1']
],
'fields' => ['id', 'status', 'sort', 'created_at', 'updated_at'],
'fields' => ['id', 'status', 'sort', 'toppic', 'descpic', 'logo', 'letter', 'created_at', 'updated_at'],
'relations' => [
'translation' => ['brand_id', 'name']
'translation' => ['brand_id', 'name', 'desc','toppic_alt','descpic_alt','logo_alt'],
'banner' => ['id', 'pic', 'sort',],
'banner.translation' => ['id', 'alt',],
'trait' => ['id', 'sort',],
'trait.translation' => ['id', 'title', 'content',],
],
'sorts' => [
['field' => 'id', 'direction' => 'desc']
@@ -65,12 +71,20 @@ class BrandService extends BaseService
protected array $translatable = [
'name'
'name', 'desc','toppic_alt','descpic_alt','logo_alt'
];
public function add(array $params)
{
$sourceLocale = locale();
$BrandBannerService = new BrandBannerService(new BrandBannerModel());
$BrandTraitService = new BrandTraitService(new BrandTraitModel());
$banners = $params['banners'] ?? null;
unset($params['banners']);
$traits = $params['traits'] ?? null;
unset($params['traits']);
$sourceFields = $this->extractSourceFields($params);
if (empty($sourceFields)) {
throw new \InvalidArgumentException("请传递至少一条 {$sourceLocale} 语言的翻译字段");
@@ -91,8 +105,44 @@ class BrandService extends BaseService
$sourceFields
);
//品牌轮播图
foreach ($banners as $banner) {
$bannersourceFields = $BrandBannerService->extractSourceFields($banner);
$bannersourceFields['brand_id'] = $info->id;
$banner['brand_id'] = $info->id;
$banner = $BrandBannerService->create($banner);
if (!$banner) {
throw new BusinessException('提交失败');
}
(new TranslationService())->queueTranslations(
'brandBanner',
$banner->id,
$sourceLocale,
$bannersourceFields
);
}
//品牌特性
foreach ($traits as $trait) {
$traitsourceFields = $BrandTraitService->extractSourceFields($trait);
$traitsourceFields['brand_id'] = $info->id;
$trait['brand_id'] = $info->id;
$trait = $BrandTraitService->create($trait);
if (!$trait) {
throw new BusinessException('提交失败');
}
(new TranslationService())->queueTranslations(
'brandTrait',
$trait->id,
$sourceLocale,
$traitsourceFields
);
}
Db::commit();
return true;
return $info->id;
} catch (\Throwable $th) {
Db::rollBack();
throw $th;
@@ -102,6 +152,14 @@ class BrandService extends BaseService
public function edit(array $params, int $id)
{
$sourceLocale = locale();
$BrandBannerService = new BrandBannerService(new BrandBannerModel());
$BrandTraitService = new BrandTraitService(new BrandTraitModel());
$banners = $params['banners'] ?? null;
unset($params['banners']);
$traits = $params['traits'] ?? null;
unset($params['traits']);
$sourceFields = $this->extractSourceFields($params);
if (empty($sourceFields)) {
throw new \InvalidArgumentException("请传递至少一条 {$sourceLocale} 语言的翻译字段");
@@ -122,6 +180,49 @@ class BrandService extends BaseService
$sourceFields
);
//品牌轮播图
foreach ($banners as $banner) {
$bannersourceFields = $BrandBannerService->extractSourceFields($banner);
$bannersourceFields['brand_id'] = $id;
$bannerId = $banner['id'];
$banner['brand_id'] = $id;
$banner = $BrandBannerService->update($bannerId,$banner);
if (!$banner) {
throw new BusinessException('提交失败');
}
(new TranslationService())->queueTranslations(
'brandBanner',
$bannerId,
$sourceLocale,
$bannersourceFields
);
}
$ids = array_column($banners,'id');
BrandBannerModel::whereNotIn('id', $ids)->where('brand_id',$id)->delete();
//品牌特性
foreach ($traits as $trait) {
$traitsourceFields = $BrandTraitService->extractSourceFields($trait);
$traitsourceFields['brand_id'] = $id;
$traitId = $trait['id'];
$trait['brand_id'] = $id;
$trait = $BrandTraitService->update($traitId,$trait);
if (!$trait) {
throw new BusinessException('提交失败');
}
(new TranslationService())->queueTranslations(
'brandTrait',
$traitId,
$sourceLocale,
$traitsourceFields
);
}
$ids = array_column($traits,'id');
BrandTraitModel::whereNotIn('id', $ids)->where('brand_id',$id)->delete();
Db::commit();
return true;
} catch (\Throwable $th) {
+120
View File
@@ -0,0 +1,120 @@
<?php
namespace app\console\service;
use app\console\model\BrandTraitModel;
use app\mzl\common\services\BaseService;
use app\mzl\modules\translation\service\TranslationService;
use support\Db;
use support\exception\BusinessException;
class BrandTraitService extends BaseService
{
/**
* 定义模型
*
* @return string
*/
public function getModel(): string
{
return BrandTraitModel::class;
}
/**
* 多场景配置
*/
public function queryScenes(): array
{
return [
'default' => function ($params) {
return [
'filters' => [
['field' => 'status', 'operator' => '=', 'value' => '1'],
['field' => 'brand_id', 'operator' => '=', 'value' => $params['brand_id']],
],
'fields' => ['id', 'status', 'sort', 'brand_id', 'created_at', 'updated_at'],
'relations' => [
'translation' => ['brand_id','trait_id', 'title', 'content']
],
'sorts' => [
['field' => 'id', 'direction' => 'desc']
],
'pagination' => [
'page' => $params['page'] ?? 1,
'per_page' => $params['per_page'] ?? 10,
]
];
},
];
}
protected array $translatable = [
'title', 'content'
];
public function add(array $params)
{
$sourceLocale = locale();
$sourceFields = $this->extractSourceFields($params);
$sourceFields['brand_id'] = $params['brand_id'];
if (empty($sourceFields)) {
throw new \InvalidArgumentException("请传递至少一条 {$sourceLocale} 语言的翻译字段");
};
Db::beginTransaction();
try {
$info = $this->create($params);
if (!$info) {
throw new BusinessException('提交失败');
}
// 异步翻译并写入 hs_vehicle_data_translation 表
(new TranslationService())->queueTranslations(
'brandTrait',
$info->id,
$sourceLocale,
$sourceFields
);
Db::commit();
return $info->id;
} catch (\Throwable $th) {
Db::rollBack();
throw $th;
}
}
public function edit(array $params, int $id)
{
$sourceLocale = locale();
$sourceFields = $this->extractSourceFields($params);
if (empty($sourceFields)) {
throw new \InvalidArgumentException("请传递至少一条 {$sourceLocale} 语言的翻译字段");
};
Db::beginTransaction();
try {
$info = $this->update($id, $params);
if (!$info) {
throw new BusinessException('提交失败');
}
// 异步翻译并写入 hs_vehicle_data_translation 表
(new TranslationService())->queueTranslations(
'brandTrait',
$id,
$sourceLocale,
$sourceFields
);
Db::commit();
return $id;
} catch (\Throwable $th) {
Db::rollBack();
throw $th;
}
}
}
@@ -0,0 +1,30 @@
<?php
namespace app\console\validate;
use think\Validate;
class BrandBannerValidator extends Validate
{
// 规则
protected $rule = [
];
// 提示
protected $message = [
];
// 场景
protected $scene = [
'store' => [
],
'update' => [
]
];
}
@@ -0,0 +1,30 @@
<?php
namespace app\console\validate;
use think\Validate;
class BrandTraitValidator extends Validate
{
// 规则
protected $rule = [
];
// 提示
protected $message = [
];
// 场景
protected $scene = [
'store' => [
],
'update' => [
]
];
}
@@ -23,6 +23,14 @@ return [
'translation_model' => \app\console\model\BrandTranslationModel::class,
'foreign_key' => 'brand_id',
],
'brandBanner' => [
'translation_model' => \app\console\model\BrandBannerTranslationModel::class,
'foreign_key' => 'banner_id',
],
'brandTrait' => [
'translation_model' => \app\console\model\BrandTraitTranslationModel::class,
'foreign_key' => 'trait_id',
],
'agreement' => [
'translation_model' => \app\console\model\AgreementTranslationModel::class,
'foreign_key' => 'agreement_id',
+14
View File
@@ -40,6 +40,8 @@ Route::group('/apis', function() {
Route::any('/vehicle/random', [\app\apis\controller\VehicleDataController::class, 'random']);
// 隐私协议
Route::any('/agt/privacy', [\app\apis\controller\AgreementController::class, 'one']);
// 品牌按字母查询
Route::any('/brand/letterAll', [\app\apis\controller\BrandController::class, 'letterAll']);
});
// ====== ====== ====== 网站 ====== ====== ======
@@ -124,6 +126,18 @@ Route::group('/console', function() {
Route::any('/brand/{id}/detail', [\app\console\controller\BrandController::class, 'show']);
Route::any('/brand/preset', [\app\console\controller\BrandController::class, 'presets']);
// 品牌轮播
Route::any('/brandbanner/add', [\app\console\controller\BrandBannerController::class, 'add']);
Route::any('/brandbanner/update/{id}', [\app\console\controller\BrandBannerController::class, 'edit']);
Route::any('/brandbanner/list', [\app\console\controller\BrandBannerController::class, 'index']);
Route::any('/brandbanner/delete/{id}', [\app\console\controller\BrandBannerController::class, 'destroy']);
// 品牌特性
Route::any('/brandtrait/add', [\app\console\controller\BrandTraitController::class, 'add']);
Route::any('/brandtrait/update/{id}', [\app\console\controller\BrandTraitController::class, 'edit']);
Route::any('/brandtrait/list', [\app\console\controller\BrandTraitController::class, 'index']);
Route::any('/brandtrait/delete/{id}', [\app\console\controller\BrandTraitController::class, 'destroy']);
// 能源管理
Route::any('/energy/list', [\app\console\controller\EnergyController::class, 'index']);
Route::any('/energy/add', [\app\console\controller\EnergyController::class, 'add']);