作者 lyh

gx

@@ -148,19 +148,21 @@ class BaseController extends Controller @@ -148,19 +148,21 @@ class BaseController extends Controller
148 public function getImageUrl($hash){ 148 public function getImageUrl($hash){
149 if(is_array($hash)){ 149 if(is_array($hash)){
150 foreach ($hash as $k => $v){ 150 foreach ($hash as $k => $v){
151 - var_dump($v);  
152 - die();  
153 $url[] = $this->getImageUrl($v); 151 $url[] = $this->getImageUrl($v);
154 } 152 }
155 }else{ 153 }else{
156 $imageModel = new Image(); 154 $imageModel = new Image();
157 $info = $imageModel->read(['hash'=>$hash]); 155 $info = $imageModel->read(['hash'=>$hash]);
  156 + if(!empty($info)){
158 if($info['is_cos'] == 1){ 157 if($info['is_cos'] == 1){
159 $cos = new CosService(); 158 $cos = new CosService();
160 $url = $cos->getImageUrl($info['path']); 159 $url = $cos->getImageUrl($info['path']);
161 }else{ 160 }else{
162 $url = url('a/image/'.$info['hash']); 161 $url = url('a/image/'.$info['hash']);
163 } 162 }
  163 + }else{
  164 + $url = $hash;
  165 + }
164 } 166 }
165 return $url; 167 return $url;
166 } 168 }
@@ -239,15 +239,22 @@ class BaseController extends Controller @@ -239,15 +239,22 @@ class BaseController extends Controller
239 * @time :2023/7/20 16:46 239 * @time :2023/7/20 16:46
240 */ 240 */
241 public function getImageUrl($hash){ 241 public function getImageUrl($hash){
  242 + if(is_array($hash)){
  243 + foreach ($hash as $k => $v){
  244 + $url[] = $this->getImageUrl($v);
  245 + }
  246 + }else{
242 $imageModel = new Image(); 247 $imageModel = new Image();
243 $info = $imageModel->read(['hash'=>$hash]); 248 $info = $imageModel->read(['hash'=>$hash]);
244 - $url = '';  
245 - if($info !== false){ 249 + if(!empty($info)){
246 if($info['is_cos'] == 1){ 250 if($info['is_cos'] == 1){
247 $cos = new CosService(); 251 $cos = new CosService();
248 $url = $cos->getImageUrl($info['path']); 252 $url = $cos->getImageUrl($info['path']);
249 }else{ 253 }else{
250 - $url = url('b/image/'.$info['hash']); 254 + $url = url('a/image/'.$info['hash']);
  255 + }
  256 + }else{
  257 + $url = $hash;
251 } 258 }
252 } 259 }
253 return $url; 260 return $url;
@@ -267,7 +274,7 @@ class BaseController extends Controller @@ -267,7 +274,7 @@ class BaseController extends Controller
267 $cos = new CosService(); 274 $cos = new CosService();
268 $url = $cos->getImageUrl($info['path']); 275 $url = $cos->getImageUrl($info['path']);
269 }else{ 276 }else{
270 - $url = url('b/file_hash/'.$info['hash']); 277 + $url = url('a/file/'.$info['hash']);
271 } 278 }
272 return $url; 279 return $url;
273 } 280 }