73 lines
1.7 KiB
PHP
73 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace app\applet\controller;
|
|
|
|
use support\Request;
|
|
use support\Response;
|
|
use app\applet\model\BrandModel;
|
|
use app\applet\service\BrandService;
|
|
use app\applet\validate\BrandValidator;
|
|
use app\mzl\common\controller\BaseController;
|
|
|
|
class BrandController extends BaseController
|
|
{
|
|
|
|
/**
|
|
* 不需要验证token的接口
|
|
* @var array
|
|
*/
|
|
protected $noNeedJwt = [];
|
|
|
|
/**
|
|
* 验证器
|
|
*/
|
|
protected mixed $validator = BrandValidator::class;
|
|
|
|
/**
|
|
* 返回业务 Service 实例
|
|
*/
|
|
protected function getService()
|
|
{
|
|
return new BrandService(new BrandModel());
|
|
}
|
|
|
|
/**
|
|
* 额外字段处理 (根据场景处理)
|
|
* @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'],
|
|
'name' => isset($item['translation']) ? $item['translation']['name'] : '',
|
|
'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;
|
|
}
|
|
} |