作者 lyh

gx

@@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api; @@ -4,6 +4,7 @@ namespace App\Http\Controllers\Api;
4 4
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
6 use App\Models\Product\Product; 6 use App\Models\Product\Product;
  7 +use App\Services\CosService;
7 use App\Services\ProjectServer; 8 use App\Services\ProjectServer;
8 use App\Utils\LogUtils; 9 use App\Utils\LogUtils;
9 use Illuminate\Http\Request; 10 use Illuminate\Http\Request;
@@ -62,12 +63,26 @@ class ProductController extends BaseController @@ -62,12 +63,26 @@ class ProductController extends BaseController
62 if (!$project) { 63 if (!$project) {
63 $this->response('项目不存在', Code::SYSTEM_ERROR); 64 $this->response('项目不存在', Code::SYSTEM_ERROR);
64 } 65 }
  66 + $gallery = [];
  67 + $thumb = [];
  68 + if(!empty($this->param['image']) && in_array($this->param['image'])){
  69 + foreach ($this->param['image'] as $k => $v){
  70 + //TODO::图片转存
  71 + $url = CosService::uploadRemote($this->param['project_id'],'image_product',$v);
  72 + if($k == 0){
  73 + $thumb = ['url'=>$url,'alt'=>''];
  74 + }
  75 + $gallery[] = ['url'=>$url,'alt'=>''];
  76 + }
  77 + }
65 try { 78 try {
66 $param = [ 79 $param = [
67 'project_id'=>$this->param['project_id'], 80 'project_id'=>$this->param['project_id'],
68 'title'=>$this->param['title'], 81 'title'=>$this->param['title'],
69 'intro'=>$this->param['intro'] ?? '', 82 'intro'=>$this->param['intro'] ?? '',
70 - 'content'=>$this->param['content'] ?? '' 83 + 'content'=>$this->param['content'] ?? '',
  84 + 'thumb'=>json_encode($thumb,true),
  85 + 'gallery'=>json_encode($gallery,true),
71 ]; 86 ];
72 $productModel = new Product(); 87 $productModel = new Product();
73 $productModel->add($param); 88 $productModel->add($param);