This commit is contained in:
2026-01-05 16:15:27 +08:00
parent 8470fdc2a9
commit cc5fe0bcaa
2 changed files with 33 additions and 8 deletions
+19 -8
View File
@@ -2,6 +2,7 @@
namespace app\common\controller; namespace app\common\controller;
use app\common\controller\BaseController; use app\common\controller\BaseController;
use app\common\service\OssService;
use app\common\traits\crud\CrudControllerTrait; use app\common\traits\crud\CrudControllerTrait;
use app\common\service\UsedCarService; use app\common\service\UsedCarService;
@@ -22,12 +23,22 @@ class UsedCarController extends BaseController
* @param array $data * @param array $data
* @return array * @return array
*/ */
// protected function indexFormat($data) protected function indexFormat($data)
// { {
// if (isset($data['created_at'])) if (isset($data['created_at']))
// $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']);
// if (isset($data['updated_at'])) if (isset($data['updated_at']))
// $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']);
// return $data; 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;
}
} }
+14
View File
@@ -5,6 +5,8 @@ namespace app\common\service;
use app\common\validate\UsedCarValidate; use app\common\validate\UsedCarValidate;
use app\common\traits\crud\CrudServiceTrait; use app\common\traits\crud\CrudServiceTrait;
use app\common\model\UsedCar; use app\common\model\UsedCar;
use support\exception\BusinessException;
use support\Request;
class UsedCarService class UsedCarService
{ {
@@ -28,4 +30,16 @@ class UsedCarService
{ {
return new $this->validator; 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;
}
} }