产品
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
namespace app\common\controller;
|
||||
|
||||
use app\common\controller\BaseController;
|
||||
use app\common\service\OssService;
|
||||
use app\common\traits\crud\CrudControllerTrait;
|
||||
use app\common\service\UsedCarService;
|
||||
|
||||
@@ -22,12 +23,22 @@ class UsedCarController extends BaseController
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
// protected function indexFormat($data)
|
||||
// {
|
||||
// if (isset($data['created_at']))
|
||||
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
// if (isset($data['updated_at']))
|
||||
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
// return $data;
|
||||
// }
|
||||
protected function indexFormat($data)
|
||||
{
|
||||
if (isset($data['created_at']))
|
||||
$data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
|
||||
if (isset($data['updated_at']))
|
||||
$data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
|
||||
if (!empty($data['images'])){
|
||||
$images = explode(',', $data['images']);
|
||||
$ossService = new OssService();
|
||||
$images_pull = [];
|
||||
foreach ($images as $image){
|
||||
$images_pull[] = $ossService->generatePrivateUrl($image);
|
||||
}
|
||||
$data['images_pull'] = $images_pull;
|
||||
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@ namespace app\common\service;
|
||||
use app\common\validate\UsedCarValidate;
|
||||
use app\common\traits\crud\CrudServiceTrait;
|
||||
use app\common\model\UsedCar;
|
||||
use support\exception\BusinessException;
|
||||
use support\Request;
|
||||
|
||||
class UsedCarService
|
||||
{
|
||||
@@ -28,4 +30,16 @@ class UsedCarService
|
||||
{
|
||||
return new $this->validator;
|
||||
}
|
||||
|
||||
|
||||
public function beforeServiceStore($data, Request $request): array
|
||||
{
|
||||
if(empty($data['product_name'])){
|
||||
throw new BusinessException('产品名称不能为空');
|
||||
}
|
||||
if(empty($data['images'])){
|
||||
throw new BusinessException('产品图片不能为空');
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user