Merge branch 'feature/brand'

This commit is contained in:
2025-06-04 11:04:01 +08:00
116 changed files with 7676 additions and 27 deletions
@@ -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());
}
}
}
+54 -7
View File
@@ -2,6 +2,9 @@
namespace app\console\controller;
use app\console\model\BrandBannerModel;
use app\console\model\BrandTraitModel;
use app\console\model\BrandTranslationModel;
use support\Request;
use support\Response;
use app\console\model\BrandModel;
@@ -39,16 +42,49 @@ class BrandController extends BaseController
*/
protected function postProcessItem(array $item, string $scene): array
{
if ($scene === 'default') {
return [
$result = [
'id' => $item['id'],
'status' => $item['status'],
'sort' => $item['sort'],
'toppic' => $item['toppic'],
'descpic' => $item['descpic'],
'logo' => $item['logo'],
'is_hot' => $item['is_hot'],
'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']),
];
if ($item['toppic']) {
$result['toppic_full'] = (new \app\mzl\modules\upload\service\OssService())->generatePrivateUrl($item['toppic']);
}
if ($item['descpic']) {
$result['descpic_full'] = (new \app\mzl\modules\upload\service\OssService())->generatePrivateUrl($item['descpic']);
}
if ($item['logo']) {
$result['logo_full'] = (new \app\mzl\modules\upload\service\OssService())->generatePrivateUrl($item['logo']);
}
$banners = BrandBannerModel::with('translation')->where(['brand_id' => $item['id']])->get();
foreach ($banners as $k => $v) {
$v['alt'] = isset($v['translation']) ? $v['translation']['alt'] : '';
unset($v['translation']);
if ($v['pic']) {
$v['pic_full'] = (new \app\mzl\modules\upload\service\OssService())->generatePrivateUrl($v['pic']);
}
$result['banner'][$k] = $v;
}
$traits = BrandTraitModel::with('translation')->where(['brand_id' => $item['id']])->get();
foreach ($traits as $k => $v) {
$v['title'] = isset($v['translation']) ? $v['translation']['title'] : '';
$v['content'] = isset($v['translation']) ? $v['translation']['content'] : '';
unset($v['translation']);
$result['trait'][$k] = $v;
}
return $result;
}
if ($scene === 'preset') {
@@ -72,7 +108,14 @@ class BrandController extends BaseController
$params = parent::prepareParams($request, $scene);
if ($scene === 'default') {
$params['filters'] = [];
if(isset($params['status']) && $params['status'] != ''){
$params['filters'][] = ['field' => 'status', 'operator' => '=', 'value' => $params['status']];
}
if(!empty($params['name'])){
$id = BrandTranslationModel::where('name', 'like', '%'.$params['name'].'%')->pluck('brand_id')->toArray();
$params['filters'][] = ['field' => 'id', 'operator' => 'in', 'value' => $id];
}
}
return $params;
@@ -86,6 +129,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 +154,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 +165,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());
}
}
}
@@ -0,0 +1,81 @@
<?php
namespace app\console\controller;
use support\Request;
use support\Response;
use app\console\model\VehicleNewAlbumModel;
use app\console\service\VehicleNewAlbumService;
use app\console\validate\VehicleNewAlbumValidator;
use app\mzl\common\controller\BaseController;
class VehicleNewAlbumController extends BaseController
{
/**
* 不需要验证token的接口
* @var array
*/
protected $noNeedJwt = [];
/**
* 验证器
*/
protected mixed $validator = VehicleNewAlbumValidator::class;
/**
* 返回业务 Service 实例
*/
protected function getService()
{
return new VehicleNewAlbumService(new VehicleNewAlbumModel());
}
/**
* 额外字段处理 (根据场景处理)
* @param array $item
* @param string $scene
* @return array
*/
protected function postProcessItem(array $item, string $scene): array
{
if ($scene === 'default') {
}
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());
}
}
}
@@ -0,0 +1,81 @@
<?php
namespace app\console\controller;
use support\Request;
use support\Response;
use app\console\model\VehicleNewAlbumTranslationModel;
use app\console\service\VehicleNewAlbumTranslationService;
use app\console\validate\VehicleNewAlbumTranslationValidator;
use app\mzl\common\controller\BaseController;
class VehicleNewAlbumTranslationController extends BaseController
{
/**
* 不需要验证token的接口
* @var array
*/
protected $noNeedJwt = [];
/**
* 验证器
*/
protected mixed $validator = VehicleNewAlbumTranslationValidator::class;
/**
* 返回业务 Service 实例
*/
protected function getService()
{
return new VehicleNewAlbumTranslationService(new VehicleNewAlbumTranslationModel());
}
/**
* 额外字段处理 (根据场景处理)
* @param array $item
* @param string $scene
* @return array
*/
protected function postProcessItem(array $item, string $scene): array
{
if ($scene === 'default') {
}
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());
}
}
}
@@ -0,0 +1,81 @@
<?php
namespace app\console\controller;
use support\Request;
use support\Response;
use app\console\model\VehicleNewAskedModel;
use app\console\service\VehicleNewAskedService;
use app\console\validate\VehicleNewAskedValidator;
use app\mzl\common\controller\BaseController;
class VehicleNewAskedController extends BaseController
{
/**
* 不需要验证token的接口
* @var array
*/
protected $noNeedJwt = [];
/**
* 验证器
*/
protected mixed $validator = VehicleNewAskedValidator::class;
/**
* 返回业务 Service 实例
*/
protected function getService()
{
return new VehicleNewAskedService(new VehicleNewAskedModel());
}
/**
* 额外字段处理 (根据场景处理)
* @param array $item
* @param string $scene
* @return array
*/
protected function postProcessItem(array $item, string $scene): array
{
if ($scene === 'default') {
}
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());
}
}
}
@@ -0,0 +1,81 @@
<?php
namespace app\console\controller;
use support\Request;
use support\Response;
use app\console\model\VehicleNewAskedTranslationModel;
use app\console\service\VehicleNewAskedTranslationService;
use app\console\validate\VehicleNewAskedTranslationValidator;
use app\mzl\common\controller\BaseController;
class VehicleNewAskedTranslationController extends BaseController
{
/**
* 不需要验证token的接口
* @var array
*/
protected $noNeedJwt = [];
/**
* 验证器
*/
protected mixed $validator = VehicleNewAskedTranslationValidator::class;
/**
* 返回业务 Service 实例
*/
protected function getService()
{
return new VehicleNewAskedTranslationService(new VehicleNewAskedTranslationModel());
}
/**
* 额外字段处理 (根据场景处理)
* @param array $item
* @param string $scene
* @return array
*/
protected function postProcessItem(array $item, string $scene): array
{
if ($scene === 'default') {
}
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());
}
}
}
@@ -0,0 +1,81 @@
<?php
namespace app\console\controller;
use support\Request;
use support\Response;
use app\console\model\VehicleNewContentModel;
use app\console\service\VehicleNewContentService;
use app\console\validate\VehicleNewContentValidator;
use app\mzl\common\controller\BaseController;
class VehicleNewContentController extends BaseController
{
/**
* 不需要验证token的接口
* @var array
*/
protected $noNeedJwt = [];
/**
* 验证器
*/
protected mixed $validator = VehicleNewContentValidator::class;
/**
* 返回业务 Service 实例
*/
protected function getService()
{
return new VehicleNewContentService(new VehicleNewContentModel());
}
/**
* 额外字段处理 (根据场景处理)
* @param array $item
* @param string $scene
* @return array
*/
protected function postProcessItem(array $item, string $scene): array
{
if ($scene === 'default') {
}
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());
}
}
}
@@ -0,0 +1,81 @@
<?php
namespace app\console\controller;
use support\Request;
use support\Response;
use app\console\model\VehicleNewContentTranslationModel;
use app\console\service\VehicleNewContentTranslationService;
use app\console\validate\VehicleNewContentTranslationValidator;
use app\mzl\common\controller\BaseController;
class VehicleNewContentTranslationController extends BaseController
{
/**
* 不需要验证token的接口
* @var array
*/
protected $noNeedJwt = [];
/**
* 验证器
*/
protected mixed $validator = VehicleNewContentTranslationValidator::class;
/**
* 返回业务 Service 实例
*/
protected function getService()
{
return new VehicleNewContentTranslationService(new VehicleNewContentTranslationModel());
}
/**
* 额外字段处理 (根据场景处理)
* @param array $item
* @param string $scene
* @return array
*/
protected function postProcessItem(array $item, string $scene): array
{
if ($scene === 'default') {
}
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());
}
}
}
@@ -0,0 +1,189 @@
<?php
namespace app\console\controller;
use app\console\model\VehicleNewTranslationModel;
use support\Request;
use support\Response;
use app\console\model\VehicleNewModel;
use app\console\service\VehicleNewService;
use app\console\validate\VehicleNewValidator;
use app\mzl\common\controller\BaseController;
class VehicleNewController extends BaseController
{
/**
* 不需要验证token的接口
* @var array
*/
protected $noNeedJwt = [];
/**
* 验证器
*/
protected mixed $validator = VehicleNewValidator::class;
/**
* 返回业务 Service 实例
*/
protected function getService()
{
return new VehicleNewService(new VehicleNewModel());
}
/**
* 额外字段处理 (根据场景处理)
* @param array $item
* @param string $scene
* @return array
*/
protected function postProcessItem(array $item, string $scene): array
{
if ($scene === 'default' || $scene === 'show') {
$result = [
'id' => $item['id'],
'vin' => $item['vin'],
'price' => $item['price'],
'cover' => $item['cover'],
'brand' => is_array($item['brand']) ? $item['brand']['translation']['brand_id'] : $item['brand'],
'energy' => is_array($item['energy']) ? $item['energy']['translation']['energy_id'] : $item['energy'],
'type' => isset($item['types']) ? $item['types']['translation']['type_id'] : $item['type'],
'model' => isset($item['models']) ? $item['models']['translation']['model_id'] : $item['model'],
'video' => $item['video'],
'name' => isset($item['translation']) ? $item['translation']['name'] : '',
'condition_desc' => isset($item['translation']) ? $item['translation']['condition_desc'] : '',
'created_at' => date('Y-m-d H:i:s', $item['created_at']),
'updated_at' => date('Y-m-d H:i:s', $item['updated_at']),
'brand_name' => is_array($item['brand']) ? $item['brand']['translation']['name'] : '',
'energy_name' => is_array($item['energy']) ? $item['energy']['translation']['name'] : '',
'type_name' => isset($item['types']) ? $item['types']['translation']['name'] : '',
'model_name' => isset($item['models']) ? $item['models']['translation']['name'] : '',
];
if ($item['cover']) {
$result['cover_full'] = (new \app\mzl\modules\upload\service\OssService())->generatePrivateUrl($item['cover']);
}
if ($item['video']) {
$result['video_full'] = (new \app\mzl\modules\upload\service\OssService())->generatePrivateUrl($item['video']);
}
foreach ($item['asked'] as $asked) {
$askedRes['id'] = $asked['id'];
$askedRes['vehicle_id'] = $asked['vehicle_id'];
$askedRes['status'] = $asked['status'];
$askedRes['title'] = isset($asked['translation']) ? $asked['translation']['title']:'';
$askedRes['content'] = isset($asked['translation']) ? $asked['translation']['content']:'';
$result['asked'][] = $askedRes;
}
foreach ($item['trait'] as $trait) {
$traitRes['id'] = $trait['id'];
$traitRes['vehicle_id'] = $trait['vehicle_id'];
$traitRes['status'] = $trait['status'];
$traitRes['title'] = isset($trait['translation']) ? $trait['translation']['title']:'';
$traitRes['content'] = isset($trait['translation']) ? $trait['translation']['content']:'';
$result['trait'][] = $traitRes;
}
foreach ($item['album'] as $album) {
$albumRes['id'] = $album['id'];
$albumRes['vehicle_id'] = $album['vehicle_id'];
$albumRes['pic'] = $album['pic'];
$albumRes['status'] = $album['status'];
$albumRes['alt'] = isset($album['translation']) ? $album['translation']['alt']:'';
if ($albumRes['pic']) {
$albumRes['pic_full'] = (new \app\mzl\modules\upload\service\OssService())->generatePrivateUrl($albumRes['pic']);
}
$result['album'][] = $albumRes;
}
foreach ($item['content'] as $content) {
$contentRes['id'] = $content['id'];
$contentRes['vehicle_id'] = $content['vehicle_id'];
$contentRes['status'] = $content['status'];
$contentRes['content'] = isset($content['translation']) ? $content['translation']['content']:'';
$result['content'][] = $contentRes;
}
return $result;
}
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') {
$params['filters'] = [];
if(!empty($params['brand'])){
$params['filters'][] = ['field' => 'brand', 'operator' => '=', 'value' => $params['brand']];
}
if(!empty($params['type'])){
$params['filters'][] = ['field' => 'type', 'operator' => '=', 'value' => $params['type']];
}
if(!empty($params['energy'])){
$params['filters'][] = ['field' => 'energy', 'operator' => '=', 'value' => $params['energy']];
}
if(!empty($params['name_like'])){
$id = VehicleNewTranslationModel::where('name', 'like', '%'.$params['name_like'].'%')->pluck('vehicle_id')->toArray();
$params['filters'][] = ['field' => 'id', 'operator' => 'in', 'value' => $id];
}
}
return $params;
}
public function add(Request $request): Response
{
try {
return $this->getService()->add($request->all())
? $this->successResponse()
: $this->errorResponse();
} catch (\Throwable $th) {
return $this->errorResponse($th->getMessage().$th->getLine().$th->getFile());
}
}
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());
}
}
/**
* 分页
*
* @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->getLine().$th->getFile());
}
}
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());
}
}
}
@@ -0,0 +1,81 @@
<?php
namespace app\console\controller;
use support\Request;
use support\Response;
use app\console\model\VehicleNewTraitModel;
use app\console\service\VehicleNewTraitService;
use app\console\validate\VehicleNewTraitValidator;
use app\mzl\common\controller\BaseController;
class VehicleNewTraitController extends BaseController
{
/**
* 不需要验证token的接口
* @var array
*/
protected $noNeedJwt = [];
/**
* 验证器
*/
protected mixed $validator = VehicleNewTraitValidator::class;
/**
* 返回业务 Service 实例
*/
protected function getService()
{
return new VehicleNewTraitService(new VehicleNewTraitModel());
}
/**
* 额外字段处理 (根据场景处理)
* @param array $item
* @param string $scene
* @return array
*/
protected function postProcessItem(array $item, string $scene): array
{
if ($scene === 'default') {
}
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());
}
}
}
@@ -0,0 +1,81 @@
<?php
namespace app\console\controller;
use support\Request;
use support\Response;
use app\console\model\VehicleNewTraitTranslationModel;
use app\console\service\VehicleNewTraitTranslationService;
use app\console\validate\VehicleNewTraitTranslationValidator;
use app\mzl\common\controller\BaseController;
class VehicleNewTraitTranslationController extends BaseController
{
/**
* 不需要验证token的接口
* @var array
*/
protected $noNeedJwt = [];
/**
* 验证器
*/
protected mixed $validator = VehicleNewTraitTranslationValidator::class;
/**
* 返回业务 Service 实例
*/
protected function getService()
{
return new VehicleNewTraitTranslationService(new VehicleNewTraitTranslationModel());
}
/**
* 额外字段处理 (根据场景处理)
* @param array $item
* @param string $scene
* @return array
*/
protected function postProcessItem(array $item, string $scene): array
{
if ($scene === 'default') {
}
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());
}
}
}
@@ -0,0 +1,81 @@
<?php
namespace app\console\controller;
use support\Request;
use support\Response;
use app\console\model\VehicleNewTranslationModel;
use app\console\service\VehicleNewTranslationService;
use app\console\validate\VehicleNewTranslationValidator;
use app\mzl\common\controller\BaseController;
class VehicleNewTranslationController extends BaseController
{
/**
* 不需要验证token的接口
* @var array
*/
protected $noNeedJwt = [];
/**
* 验证器
*/
protected mixed $validator = VehicleNewTranslationValidator::class;
/**
* 返回业务 Service 实例
*/
protected function getService()
{
return new VehicleNewTranslationService(new VehicleNewTranslationModel());
}
/**
* 额外字段处理 (根据场景处理)
* @param array $item
* @param string $scene
* @return array
*/
protected function postProcessItem(array $item, string $scene): array
{
if ($scene === 'default') {
}
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());
}
}
}