作者 lyh

gx

1 <?php 1 <?php
2 2
  3 +use App\Models\File\Image;
  4 +use App\Services\CosService;
3 use App\Utils\LogUtils; 5 use App\Utils\LogUtils;
4 use GuzzleHttp\Client; 6 use GuzzleHttp\Client;
5 use GuzzleHttp\Exception\GuzzleException; 7 use GuzzleHttp\Exception\GuzzleException;
@@ -405,28 +407,36 @@ if (!function_exists('getDateArray')) { @@ -405,28 +407,36 @@ if (!function_exists('getDateArray')) {
405 return $days; 407 return $days;
406 } 408 }
407 } 409 }
408 -/**  
409 - * @param $str  
410 - * @remark :判断是否为中文  
411 - * @name :isChinese  
412 - * @author :lyh  
413 - * @method :post  
414 - * @time :2023/6/28 16:15  
415 - */  
416 -function isChinese($str) {  
417 - return preg_match('/^[\x{4e00}-\x{9fa5}]+$/u', $str);  
418 -}  
419 410
420 -/**  
421 - * @param $str  
422 - * @remark :判断是否为英文  
423 - * @name :isEnglish 411 +if (!function_exists('getImageUrl')) {
  412 + /**
  413 + * @remark :获取图片链接
  414 + * @name :getImageUrl
424 * @author :lyh 415 * @author :lyh
425 * @method :post 416 * @method :post
426 - * @time :2023/6/28 16:15 417 + * @time :2023/7/20 16:46
427 */ 418 */
428 -function isEnglish($str) {  
429 - return preg_match('/^[a-zA-Z]+$/u', $str); 419 + function getImageUrl($hash){
  420 + if(is_array($hash)){
  421 + foreach ($hash as $v){
  422 + $url[] = getImageUrl($v);
  423 + }
  424 + }else{
  425 + $imageModel = new Image();
  426 + $info = $imageModel->read(['hash'=>$hash]);
  427 + if(!empty($info)){
  428 + if($info['is_cos'] == 1){
  429 + $cos = new CosService();
  430 + $url = $cos->getImageUrl($info['path']);
  431 + }else{
  432 + $url = url('a/image/'.$info['hash']);
  433 + }
  434 + }else{
  435 + $url = $hash;
  436 + }
  437 + }
  438 + return $url;
  439 + }
430 } 440 }
431 441
432 /** 442 /**
@@ -137,36 +137,6 @@ class BaseController extends Controller @@ -137,36 +137,6 @@ class BaseController extends Controller
137 throw new HttpResponseException($response); 137 throw new HttpResponseException($response);
138 } 138 }
139 139
140 -  
141 - /**  
142 - * @remark :获取图片链接  
143 - * @name :getImageUrl  
144 - * @author :lyh  
145 - * @method :post  
146 - * @time :2023/7/20 16:46  
147 - */  
148 - public function getImageUrl($hash){  
149 - if(is_array($hash)){  
150 - foreach ($hash as $k => $v){  
151 - $url[] = $this->getImageUrl($v);  
152 - }  
153 - }else{  
154 - $imageModel = new Image();  
155 - $info = $imageModel->read(['hash'=>$hash]);  
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 - }  
163 - }else{  
164 - $url = $hash;  
165 - }  
166 - }  
167 - return $url;  
168 - }  
169 -  
170 /** 140 /**
171 * @remark :获取文件交接链接 141 * @remark :获取文件交接链接
172 * @name :getImageUrl 142 * @name :getImageUrl
@@ -20,9 +20,9 @@ class HrController extends BaseController @@ -20,9 +20,9 @@ class HrController extends BaseController
20 $lists = $logic->getHrList($this->map,$this->page,$this->row,$this->order); 20 $lists = $logic->getHrList($this->map,$this->page,$this->row,$this->order);
21 if(!empty($lists['list'])){ 21 if(!empty($lists['list'])){
22 foreach ($lists['list'] as $k => $v){ 22 foreach ($lists['list'] as $k => $v){
23 - $v['photo_gallery_link'] = $this->getImageUrl(json_decode($v['photo_gallery']));  
24 - $v['id_card_gallery_link'] = $this->getImageUrl(json_decode($v['id_card_gallery']));  
25 - $v['certificate_gallery_link'] = $this->getImageUrl(json_decode($v['certificate_gallery'])); 23 + $v['photo_gallery_link'] = getImageUrl(json_decode($v['photo_gallery']));
  24 + $v['id_card_gallery_link'] = getImageUrl(json_decode($v['id_card_gallery']));
  25 + $v['certificate_gallery_link'] = getImageUrl(json_decode($v['certificate_gallery']));
26 $lists['list'][$k] = $v; 26 $lists['list'][$k] = $v;
27 } 27 }
28 } 28 }
@@ -36,9 +36,9 @@ class HrController extends BaseController @@ -36,9 +36,9 @@ class HrController extends BaseController
36 'id.required' => 'ID不能为空' 36 'id.required' => 'ID不能为空'
37 ]); 37 ]);
38 $info = $logic->getHrInfo($this->param['id']); 38 $info = $logic->getHrInfo($this->param['id']);
39 - $info['photo_gallery_link'] = $this->getImageUrl($info['photo_gallery']);  
40 - $info['id_card_gallery_link'] = $this->getImageUrl($info['id_card_gallery']);  
41 - $info['certificate_gallery_link'] = $this->getImageUrl($info['certificate_gallery']); 39 + $info['photo_gallery_link'] = getImageUrl($info['photo_gallery']);
  40 + $info['id_card_gallery_link'] = getImageUrl($info['id_card_gallery']);
  41 + $info['certificate_gallery_link'] = getImageUrl($info['certificate_gallery']);
42 return $this->success($info); 42 return $this->success($info);
43 } 43 }
44 44
@@ -232,35 +232,6 @@ class BaseController extends Controller @@ -232,35 +232,6 @@ class BaseController extends Controller
232 } 232 }
233 233
234 /** 234 /**
235 - * @remark :获取图片链接  
236 - * @name :getImageUrl  
237 - * @author :lyh  
238 - * @method :post  
239 - * @time :2023/7/20 16:46  
240 - */  
241 - public function getImageUrl($hash){  
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 - }  
256 - }else{  
257 - $url = $hash;  
258 - }  
259 - }  
260 - return $url;  
261 - }  
262 -  
263 - /**  
264 * @remark :获取文件交接链接 235 * @remark :获取文件交接链接
265 * @name :getImageUrl 236 * @name :getImageUrl
266 * @author :lyh 237 * @author :lyh
@@ -34,7 +34,7 @@ class BlogController extends BaseController @@ -34,7 +34,7 @@ class BlogController extends BaseController
34 $v = $blogLabelLogic->get_label_name($v); 34 $v = $blogLabelLogic->get_label_name($v);
35 $v['route'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG, $v['id'], $this->user['project_id']); 35 $v['route'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG, $v['id'], $this->user['project_id']);
36 $v['url'] = $this->getProjectDomain() . $v['route']; 36 $v['url'] = $this->getProjectDomain() . $v['route'];
37 - $v['image_link'] = $this->getImageUrl($v['image']); 37 + $v['image_link'] = getImageUrl($v['image']);
38 $lists['list'][$k] = $v; 38 $lists['list'][$k] = $v;
39 } 39 }
40 } 40 }
@@ -78,7 +78,7 @@ class BlogController extends BaseController @@ -78,7 +78,7 @@ class BlogController extends BaseController
78 $info = $blogLogic->blog_info(); 78 $info = $blogLogic->blog_info();
79 $info['route'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG, $info['id'], $this->user['project_id']); 79 $info['route'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG, $info['id'], $this->user['project_id']);
80 $info['url'] = $this->getProjectDomain() . $info['route']; 80 $info['url'] = $this->getProjectDomain() . $info['route'];
81 - $info['image_link'] = $this->getImageUrl($info['image']); 81 + $info['image_link'] = getImageUrl($info['image']);
82 $this->response('success',Code::SUCCESS,$info); 82 $this->response('success',Code::SUCCESS,$info);
83 } 83 }
84 84
@@ -32,7 +32,7 @@ class NewsController extends BaseController @@ -32,7 +32,7 @@ class NewsController extends BaseController
32 $v = $newsCategoryLogic->get_category_name($v); 32 $v = $newsCategoryLogic->get_category_name($v);
33 $v['route'] = RouteMap::getRoute(RouteMap::SOURCE_NEWS, $v['id'], $this->user['project_id']); 33 $v['route'] = RouteMap::getRoute(RouteMap::SOURCE_NEWS, $v['id'], $this->user['project_id']);
34 $v['url'] = $this->getProjectDomain() . $v['route']; 34 $v['url'] = $this->getProjectDomain() . $v['route'];
35 - $v['image_link'] = $this->getImageUrl($v['image']); 35 + $v['image_link'] = getImageUrl($v['image']);
36 $lists['list'][$k] = $v; 36 $lists['list'][$k] = $v;
37 } 37 }
38 } 38 }
@@ -75,7 +75,7 @@ class NewsController extends BaseController @@ -75,7 +75,7 @@ class NewsController extends BaseController
75 $info = $newsLogic->news_info(); 75 $info = $newsLogic->news_info();
76 $info['route'] = RouteMap::getRoute(RouteMap::SOURCE_NEWS, $info['id'], $this->user['project_id']); 76 $info['route'] = RouteMap::getRoute(RouteMap::SOURCE_NEWS, $info['id'], $this->user['project_id']);
77 $info['url'] = $this->getProjectDomain() . $info['route']; 77 $info['url'] = $this->getProjectDomain() . $info['route'];
78 - $info['image_link'] = $this->getImageUrl($info['image']); 78 + $info['image_link'] = getImageUrl($info['image']);
79 $this->response('success',Code::SUCCESS,$info); 79 $this->response('success',Code::SUCCESS,$info);
80 } 80 }
81 /** 81 /**
@@ -24,7 +24,7 @@ class ProofreadingController extends BaseController @@ -24,7 +24,7 @@ class ProofreadingController extends BaseController
24 $lists = $proofreadingLogic->proofreadingList($this->map,$this->page,$this->row); 24 $lists = $proofreadingLogic->proofreadingList($this->map,$this->page,$this->row);
25 if(!empty($lists['list']) && ($this->param['type'] == $this::TYPE_IMAGE)){ 25 if(!empty($lists['list']) && ($this->param['type'] == $this::TYPE_IMAGE)){
26 foreach ($lists['list'] as $k => $v){ 26 foreach ($lists['list'] as $k => $v){
27 - $lists['list'][$k]['image_link'] = $this->getImageUrl($v['translate']); 27 + $lists['list'][$k]['image_link'] = getImageUrl($v['translate']);
28 } 28 }
29 } 29 }
30 $this->response('success',Code::SUCCESS,$lists); 30 $this->response('success',Code::SUCCESS,$lists);
@@ -22,7 +22,7 @@ class WebSettingServiceController extends BaseController @@ -22,7 +22,7 @@ class WebSettingServiceController extends BaseController
22 $lists = $webSettingServiceLogic->setting_service_list(); 22 $lists = $webSettingServiceLogic->setting_service_list();
23 foreach ($lists as $k => $v){ 23 foreach ($lists as $k => $v){
24 if($v['type'] == self::TYPE_CODE){ 24 if($v['type'] == self::TYPE_CODE){
25 - $v['values_link'] = $this->getImageUrl($v['values']); 25 + $v['values_link'] = getImageUrl($v['values']);
26 $lists[$k] = $v; 26 $lists[$k] = $v;
27 } 27 }
28 } 28 }
@@ -20,7 +20,7 @@ class BTemplateController extends BaseController @@ -20,7 +20,7 @@ class BTemplateController extends BaseController
20 $lists = $BTemplateLogic->publicTemplateLists($this->map,$this->page,$this->row,$this->order); 20 $lists = $BTemplateLogic->publicTemplateLists($this->map,$this->page,$this->row,$this->order);
21 if(!empty($lists) && !empty($lists['list'])){ 21 if(!empty($lists) && !empty($lists['list'])){
22 foreach ($lists['list'] as $k => &$v){ 22 foreach ($lists['list'] as $k => &$v){
23 - $v['image_link'] = $this->getImageUrl($v['image']); 23 + $v['image_link'] = getImageUrl($v['image']);
24 $lists['list'][$k] = $v; 24 $lists['list'][$k] = $v;
25 } 25 }
26 } 26 }
@@ -302,7 +302,7 @@ class ImageController extends Controller @@ -302,7 +302,7 @@ class ImageController extends Controller
302 $imageModel = new ImageModel(); 302 $imageModel = new ImageModel();
303 $lists = $imageModel->list($this->param,$order = 'id'); 303 $lists = $imageModel->list($this->param,$order = 'id');
304 foreach ($lists as $k => $v){ 304 foreach ($lists as $k => $v){
305 - $v['image_link'] = $this->getImageUrl($v['hash']); 305 + $v['image_link'] = getImageUrl($v['hash']);
306 $lists[$k] = $v; 306 $lists[$k] = $v;
307 } 307 }
308 $this->response('success',Code::SUCCESS,$lists); 308 $this->response('success',Code::SUCCESS,$lists);
@@ -336,25 +336,6 @@ class ImageController extends Controller @@ -336,25 +336,6 @@ class ImageController extends Controller
336 } 336 }
337 337
338 /** 338 /**
339 - * @remark :获取图片链接  
340 - * @name :getImageUrl  
341 - * @author :lyh  
342 - * @method :post  
343 - * @time :2023/7/20 16:46  
344 - */  
345 - public function getImageUrl($hash){  
346 - $imageModel = new ImageModel();  
347 - $info = $imageModel->read(['hash'=>$hash]);  
348 - if($info['is_cos'] == 1){  
349 - $cos = new CosService();  
350 - $url = $cos->getImageUrl($info['path']);  
351 - }else{  
352 - $url = url('a/image/'.$info['hash']);  
353 - }  
354 - return $url;  
355 - }  
356 -  
357 - /**  
358 * @remark :统一返回参数处理 339 * @remark :统一返回参数处理
359 * @name :responseData 340 * @name :responseData
360 * @author :lyh 341 * @author :lyh
@@ -364,7 +345,7 @@ class ImageController extends Controller @@ -364,7 +345,7 @@ class ImageController extends Controller
364 public function responseData($hash){ 345 public function responseData($hash){
365 $data = [ 346 $data = [
366 'image'=>$hash, 347 'image'=>$hash,
367 - 'image_link'=>$this->getImageUrl($hash), 348 + 'image_link'=>getImageUrl($hash),
368 'image_download'=>url('a/downLoad/images?hash='.$hash), 349 'image_download'=>url('a/downLoad/images?hash='.$hash),
369 ]; 350 ];
370 return $data; 351 return $data;
@@ -102,7 +102,7 @@ class BTemplateLogic extends BaseLogic @@ -102,7 +102,7 @@ class BTemplateLogic extends BaseLogic
102 $ATemplateModel = new Template(); 102 $ATemplateModel = new Template();
103 $ATemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]); 103 $ATemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]);
104 $TemplateInfo['name'] = $ATemplateInfo['name']; 104 $TemplateInfo['name'] = $ATemplateInfo['name'];
105 - $TemplateInfo['image_link'] = $this->getImageUrl($ATemplateInfo['image']); 105 + $TemplateInfo['image_link'] = getImageUrl($ATemplateInfo['image']);
106 } 106 }
107 $TemplateInfo['html'] = $this->getHeadFooter($TemplateInfo['html']); 107 $TemplateInfo['html'] = $this->getHeadFooter($TemplateInfo['html']);
108 return $this->success($TemplateInfo); 108 return $this->success($TemplateInfo);
@@ -33,7 +33,7 @@ class CategoryLogic extends BaseLogic @@ -33,7 +33,7 @@ class CategoryLogic extends BaseLogic
33 foreach ($data as &$v){ 33 foreach ($data as &$v){
34 $v['url'] = $this->getProjectDomain() . $v['route'] ; 34 $v['url'] = $this->getProjectDomain() . $v['route'] ;
35 $v['product_num'] = $this->getProductNum($v['id']); 35 $v['product_num'] = $this->getProductNum($v['id']);
36 - $v['image_link'] = $this->getImageUrl($v['image']); 36 + $v['image_link'] = getImageUrl($v['image']);
37 } 37 }
38 if(!$map){ 38 if(!$map){
39 $data = Arr::listToTree($data); 39 $data = Arr::listToTree($data);
@@ -45,7 +45,7 @@ class CategoryLogic extends BaseLogic @@ -45,7 +45,7 @@ class CategoryLogic extends BaseLogic
45 { 45 {
46 $info = $this->model->read(['id'=>$id]); 46 $info = $this->model->read(['id'=>$id]);
47 $info['url'] = $this->getProjectDomain() . $info['route'] ; 47 $info['url'] = $this->getProjectDomain() . $info['route'] ;
48 - $info['image_link'] = $this->getImageUrl($info['image']); 48 + $info['image_link'] = getImageUrl($info['image']);
49 return $this->success($info); 49 return $this->success($info);
50 } 50 }
51 51
@@ -31,7 +31,7 @@ class ProductLogic extends BaseLogic @@ -31,7 +31,7 @@ class ProductLogic extends BaseLogic
31 $data = parent::getList($map, $sort, $columns, $limit); 31 $data = parent::getList($map, $sort, $columns, $limit);
32 foreach ($data['list'] as &$v){ 32 foreach ($data['list'] as &$v){
33 $v = $this->formatData($v); 33 $v = $this->formatData($v);
34 - $v['thumb']['image_link'] = $this->getImageUrl($v['thumb']['url']);//图片统一 34 + $v['thumb']['image_link'] = getImageUrl($v['thumb']['url']);//图片统一
35 } 35 }
36 return $this->success($data); 36 return $this->success($data);
37 } 37 }
@@ -43,11 +43,11 @@ class ProductLogic extends BaseLogic @@ -43,11 +43,11 @@ class ProductLogic extends BaseLogic
43 //统一图片链接 43 //统一图片链接
44 if(!empty($info['gallery'])){ 44 if(!empty($info['gallery'])){
45 foreach ($info['gallery'] as $k => $v){ 45 foreach ($info['gallery'] as $k => $v){
46 - $v['image_link'] = $this->getImageUrl($v['url']); 46 + $v['image_link'] = getImageUrl($v['url']);
47 $info['gallery'][$k] = $v; 47 $info['gallery'][$k] = $v;
48 } 48 }
49 } 49 }
50 - $info['icon_link'] = $this->getImageUrl($info['icon']); 50 + $info['icon_link'] = getImageUrl($info['icon']);
51 return $this->success($info); 51 return $this->success($info);
52 } 52 }
53 53
@@ -383,34 +383,6 @@ class Logic @@ -383,34 +383,6 @@ class Logic
383 } 383 }
384 384
385 /** 385 /**
386 - * @remark :获取图片链接  
387 - * @name :getImageUrl  
388 - * @author :lyh  
389 - * @method :post  
390 - * @time :2023/7/20 16:46  
391 - */  
392 - public function getImageUrl($hash){  
393 -  
394 - if(is_array($hash)){  
395 - $url = [];  
396 - foreach ($hash as $k => $v){  
397 - $url[$k] = $this->getImageUrl($v);  
398 - }  
399 - }else{  
400 - $imageModel = new Image();  
401 - $info = $imageModel->read(['hash'=>$hash]);  
402 - if($info['is_cos'] == 1){  
403 - $cos = new CosService();  
404 - $url = $cos->getImageUrl($info['path']);  
405 - }else{  
406 - $url = url('a/image/'.$info['hash']);  
407 - }  
408 - }  
409 -  
410 - return $url;  
411 - }  
412 -  
413 - /**  
414 * 获取实例 386 * 获取实例
415 * @param mixed ...$params 387 * @param mixed ...$params
416 * @return static 388 * @return static