正在显示
3 个修改的文件
包含
31 行增加
和
36 行删除
| @@ -419,28 +419,18 @@ if (!function_exists('getImageUrl')) { | @@ -419,28 +419,18 @@ if (!function_exists('getImageUrl')) { | ||
| 419 | * @method :post | 419 | * @method :post |
| 420 | * @time :2023/7/20 16:46 | 420 | * @time :2023/7/20 16:46 |
| 421 | */ | 421 | */ |
| 422 | - function getImageUrl($hash){ | ||
| 423 | - if(is_array($hash)){ | ||
| 424 | - foreach ($hash as $v){ | 422 | + function getImageUrl($path,$location = 1){ |
| 423 | + if(is_array($path)){ | ||
| 424 | + foreach ($path as $v){ | ||
| 425 | $url[] = getImageUrl($v); | 425 | $url[] = getImageUrl($v); |
| 426 | } | 426 | } |
| 427 | }else{ | 427 | }else{ |
| 428 | - $imageModel = new Image(); | ||
| 429 | - if (strpos($hash, '.') !== false) { | ||
| 430 | - $info = $imageModel->read(['path'=>['like','%'.$hash.'%']]); | 428 | + if($location == 1){ |
| 429 | + $cos = config('filesystems.disks.cos'); | ||
| 430 | + $cosCdn = $cos['cdn']; | ||
| 431 | + $url = $cosCdn.$path; | ||
| 431 | }else{ | 432 | }else{ |
| 432 | - $info = $imageModel->read(['hash'=>$hash]); | ||
| 433 | - } | ||
| 434 | - if(!empty($info)){ | ||
| 435 | - if($info['is_cos'] == 1){ | ||
| 436 | - $cos = config('filesystems.disks.cos'); | ||
| 437 | - $cosCdn = $cos['cdn']; | ||
| 438 | - $url = $cosCdn.$info['path']; | ||
| 439 | - }else{ | ||
| 440 | - $url = url($info['path']); | ||
| 441 | - } | ||
| 442 | - }else{ | ||
| 443 | - $url = url($hash); | 433 | + $url = url($path); |
| 444 | } | 434 | } |
| 445 | } | 435 | } |
| 446 | return $url; | 436 | return $url; |
| @@ -454,8 +444,8 @@ if (!function_exists('getFileUrl')) { | @@ -454,8 +444,8 @@ if (!function_exists('getFileUrl')) { | ||
| 454 | * @method :post | 444 | * @method :post |
| 455 | * @time :2023/7/20 16:46 | 445 | * @time :2023/7/20 16:46 |
| 456 | */ | 446 | */ |
| 457 | - function getFileUrl($hash){ | ||
| 458 | - if(is_array($hash)){ | 447 | + function getFileUrl($path,$location = 1){ |
| 448 | + if(is_array($path)){ | ||
| 459 | foreach ($hash as $v){ | 449 | foreach ($hash as $v){ |
| 460 | $url[] = getFileUrl($v); | 450 | $url[] = getFileUrl($v); |
| 461 | } | 451 | } |
| @@ -31,15 +31,15 @@ class CategoryController extends BaseController | @@ -31,15 +31,15 @@ class CategoryController extends BaseController | ||
| 31 | */ | 31 | */ |
| 32 | public function index(Category $category) | 32 | public function index(Category $category) |
| 33 | { | 33 | { |
| 34 | - if(!empty($this->map['title'])){ | ||
| 35 | - $this->map['title'] = ['like','%'.$this->map['title'].'%']; | ||
| 36 | - } | ||
| 37 | - $this->map['project_id'] = $this->user['project_id']; | 34 | + $this->map = $this->searchParam(); |
| 38 | $filed = ['id', 'project_id', 'pid', 'title', 'image', 'route','keywords', 'describe', 'status','created_at']; | 35 | $filed = ['id', 'project_id', 'pid', 'title', 'image', 'route','keywords', 'describe', 'status','created_at']; |
| 39 | $list = $category->list($this->map,'id',$filed); | 36 | $list = $category->list($this->map,'id',$filed); |
| 40 | $data = []; | 37 | $data = []; |
| 41 | if(!empty($list)){ | 38 | if(!empty($list)){ |
| 42 | foreach ($list as $k =>$v){ | 39 | foreach ($list as $k =>$v){ |
| 40 | + $v['url'] = $this->user['domain'] . $v['url']; | ||
| 41 | + $v['product_num'] = Product::where('category_id','like' ,'%,'.$v['id'].',%')->count();; | ||
| 42 | + $v['image_link'] = getImageUrl($v['image']); | ||
| 43 | $v = $this->handleParam($v); | 43 | $v = $this->handleParam($v); |
| 44 | $list[$k] = $v; | 44 | $list[$k] = $v; |
| 45 | } | 45 | } |
| @@ -49,17 +49,18 @@ class CategoryController extends BaseController | @@ -49,17 +49,18 @@ class CategoryController extends BaseController | ||
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | /** | 51 | /** |
| 52 | - * @remark :分类处理参数 | ||
| 53 | - * @name :handleParam | 52 | + * @remark :搜索参数处理 |
| 53 | + * @name :searchParam | ||
| 54 | * @author :lyh | 54 | * @author :lyh |
| 55 | * @method :post | 55 | * @method :post |
| 56 | - * @time :2023/8/17 11:10 | 56 | + * @time :2023/9/14 14:57 |
| 57 | */ | 57 | */ |
| 58 | - public function handleParam($v){ | ||
| 59 | - $v['url'] = $this->user['domain'] . $v['url']; | ||
| 60 | - $v['product_num'] = Product::where('category_id','like' ,'%,'.$v['id'].',%')->count();; | ||
| 61 | - $v['image_link'] = getImageUrl($v['image']); | ||
| 62 | - return $v; | 58 | + public function searchParam(){ |
| 59 | + if(!empty($this->map['title'])){ | ||
| 60 | + $this->map['title'] = ['like','%'.$this->map['title'].'%']; | ||
| 61 | + } | ||
| 62 | + $this->map['project_id'] = $this->user['project_id']; | ||
| 63 | + return $this->map; | ||
| 63 | } | 64 | } |
| 64 | 65 | ||
| 65 | /** | 66 | /** |
| @@ -226,10 +226,12 @@ class Project extends Base | @@ -226,10 +226,12 @@ class Project extends Base | ||
| 226 | 226 | ||
| 227 | public function getNoticeFileAttribute($value) | 227 | public function getNoticeFileAttribute($value) |
| 228 | { | 228 | { |
| 229 | - $value = Arr::s2a($value); | ||
| 230 | if(!empty($value)) { | 229 | if(!empty($value)) { |
| 230 | + $value = Arr::s2a($value); | ||
| 231 | foreach ($value as &$v) { | 231 | foreach ($value as &$v) { |
| 232 | - $v['url'] = getFileUrl($v['url']); | 232 | + if(!empty($v['url'])){ |
| 233 | + $v['url'] = getFileUrl($v['url']); | ||
| 234 | + } | ||
| 233 | } | 235 | } |
| 234 | } | 236 | } |
| 235 | return $value; | 237 | return $value; |
| @@ -245,10 +247,12 @@ class Project extends Base | @@ -245,10 +247,12 @@ class Project extends Base | ||
| 245 | 247 | ||
| 246 | public function getConfirmFileAttribute($value) | 248 | public function getConfirmFileAttribute($value) |
| 247 | { | 249 | { |
| 248 | - $value = Arr::s2a($value); | ||
| 249 | if(!empty($value)) { | 250 | if(!empty($value)) { |
| 251 | + $value = Arr::s2a($value); | ||
| 250 | foreach ($value as &$v) { | 252 | foreach ($value as &$v) { |
| 251 | - $v['url'] = getFileUrl($v['url']); | 253 | + if(!empty($v['url'])){ |
| 254 | + $v['url'] = getFileUrl($v['url']); | ||
| 255 | + } | ||
| 252 | } | 256 | } |
| 253 | } | 257 | } |
| 254 | return $value; | 258 | return $value; |
-
请 注册 或 登录 后发表评论