作者 lyh

gx

@@ -148,18 +148,20 @@ class BaseController extends Controller @@ -148,18 +148,20 @@ 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]);
158 - if($info['is_cos'] == 1){  
159 - $cos = new CosService();  
160 - $url = $cos->getImageUrl($info['path']); 156 + if(!empty($info)){
  157 + if($info['is_cos'] == 1){
  158 + $cos = new CosService();
  159 + $url = $cos->getImageUrl($info['path']);
  160 + }else{
  161 + $url = url('a/image/'.$info['hash']);
  162 + }
161 }else{ 163 }else{
162 - $url = url('a/image/'.$info['hash']); 164 + $url = $hash;
163 } 165 }
164 } 166 }
165 return $url; 167 return $url;
@@ -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 - $imageModel = new Image();  
243 - $info = $imageModel->read(['hash'=>$hash]);  
244 - $url = '';  
245 - if($info !== false){  
246 - if($info['is_cos'] == 1){  
247 - $cos = new CosService();  
248 - $url = $cos->getImageUrl($info['path']); 242 + if(is_array($hash)){
  243 + foreach ($hash as $k => $v){
  244 + $url[] = $this->getImageUrl($v);
  245 + }
  246 + }else{
  247 + $imageModel = new Image();
  248 + $info = $imageModel->read(['hash'=>$hash]);
  249 + if(!empty($info)){
  250 + if($info['is_cos'] == 1){
  251 + $cos = new CosService();
  252 + $url = $cos->getImageUrl($info['path']);
  253 + }else{
  254 + $url = url('a/image/'.$info['hash']);
  255 + }
249 }else{ 256 }else{
250 - $url = url('b/image/'.$info['hash']); 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 }