作者 lyh

gx

... ... @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api;
use App\Enums\Common\Code;
use App\Models\Product\Product;
use App\Services\CosService;
use App\Services\ProjectServer;
use App\Utils\LogUtils;
use Illuminate\Http\Request;
... ... @@ -62,12 +63,26 @@ class ProductController extends BaseController
if (!$project) {
$this->response('项目不存在', Code::SYSTEM_ERROR);
}
$gallery = [];
$thumb = [];
if(!empty($this->param['image']) && in_array($this->param['image'])){
foreach ($this->param['image'] as $k => $v){
//TODO::图片转存
$url = CosService::uploadRemote($this->param['project_id'],'image_product',$v);
if($k == 0){
$thumb = ['url'=>$url,'alt'=>''];
}
$gallery[] = ['url'=>$url,'alt'=>''];
}
}
try {
$param = [
'project_id'=>$this->param['project_id'],
'title'=>$this->param['title'],
'intro'=>$this->param['intro'] ?? '',
'content'=>$this->param['content'] ?? ''
'content'=>$this->param['content'] ?? '',
'thumb'=>json_encode($thumb,true),
'gallery'=>json_encode($gallery,true),
];
$productModel = new Product();
$productModel->add($param);
... ...