作者 lyh

gx

<?php
use App\Models\File\Image;
use App\Services\CosService;
use App\Utils\LogUtils;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
... ... @@ -405,28 +407,36 @@ if (!function_exists('getDateArray')) {
return $days;
}
}
/**
* @param $str
* @remark :判断是否为中文
* @name :isChinese
* @author :lyh
* @method :post
* @time :2023/6/28 16:15
*/
function isChinese($str) {
return preg_match('/^[\x{4e00}-\x{9fa5}]+$/u', $str);
}
/**
* @param $str
* @remark :判断是否为英文
* @name :isEnglish
* @author :lyh
* @method :post
* @time :2023/6/28 16:15
*/
function isEnglish($str) {
return preg_match('/^[a-zA-Z]+$/u', $str);
if (!function_exists('getImageUrl')) {
/**
* @remark :获取图片链接
* @name :getImageUrl
* @author :lyh
* @method :post
* @time :2023/7/20 16:46
*/
function getImageUrl($hash){
if(is_array($hash)){
foreach ($hash as $v){
$url[] = getImageUrl($v);
}
}else{
$imageModel = new Image();
$info = $imageModel->read(['hash'=>$hash]);
if(!empty($info)){
if($info['is_cos'] == 1){
$cos = new CosService();
$url = $cos->getImageUrl($info['path']);
}else{
$url = url('a/image/'.$info['hash']);
}
}else{
$url = $hash;
}
}
return $url;
}
}
/**
... ...
... ... @@ -137,36 +137,6 @@ class BaseController extends Controller
throw new HttpResponseException($response);
}
/**
* @remark :获取图片链接
* @name :getImageUrl
* @author :lyh
* @method :post
* @time :2023/7/20 16:46
*/
public function getImageUrl($hash){
if(is_array($hash)){
foreach ($hash as $k => $v){
$url[] = $this->getImageUrl($v);
}
}else{
$imageModel = new Image();
$info = $imageModel->read(['hash'=>$hash]);
if(!empty($info)){
if($info['is_cos'] == 1){
$cos = new CosService();
$url = $cos->getImageUrl($info['path']);
}else{
$url = url('a/image/'.$info['hash']);
}
}else{
$url = $hash;
}
}
return $url;
}
/**
* @remark :获取文件交接链接
* @name :getImageUrl
... ...
... ... @@ -20,9 +20,9 @@ class HrController extends BaseController
$lists = $logic->getHrList($this->map,$this->page,$this->row,$this->order);
if(!empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
$v['photo_gallery_link'] = $this->getImageUrl(json_decode($v['photo_gallery']));
$v['id_card_gallery_link'] = $this->getImageUrl(json_decode($v['id_card_gallery']));
$v['certificate_gallery_link'] = $this->getImageUrl(json_decode($v['certificate_gallery']));
$v['photo_gallery_link'] = getImageUrl(json_decode($v['photo_gallery']));
$v['id_card_gallery_link'] = getImageUrl(json_decode($v['id_card_gallery']));
$v['certificate_gallery_link'] = getImageUrl(json_decode($v['certificate_gallery']));
$lists['list'][$k] = $v;
}
}
... ... @@ -36,9 +36,9 @@ class HrController extends BaseController
'id.required' => 'ID不能为空'
]);
$info = $logic->getHrInfo($this->param['id']);
$info['photo_gallery_link'] = $this->getImageUrl($info['photo_gallery']);
$info['id_card_gallery_link'] = $this->getImageUrl($info['id_card_gallery']);
$info['certificate_gallery_link'] = $this->getImageUrl($info['certificate_gallery']);
$info['photo_gallery_link'] = getImageUrl($info['photo_gallery']);
$info['id_card_gallery_link'] = getImageUrl($info['id_card_gallery']);
$info['certificate_gallery_link'] = getImageUrl($info['certificate_gallery']);
return $this->success($info);
}
... ...
... ... @@ -232,35 +232,6 @@ class BaseController extends Controller
}
/**
* @remark :获取图片链接
* @name :getImageUrl
* @author :lyh
* @method :post
* @time :2023/7/20 16:46
*/
public function getImageUrl($hash){
if(is_array($hash)){
foreach ($hash as $k => $v){
$url[] = $this->getImageUrl($v);
}
}else{
$imageModel = new Image();
$info = $imageModel->read(['hash'=>$hash]);
if(!empty($info)){
if($info['is_cos'] == 1){
$cos = new CosService();
$url = $cos->getImageUrl($info['path']);
}else{
$url = url('a/image/'.$info['hash']);
}
}else{
$url = $hash;
}
}
return $url;
}
/**
* @remark :获取文件交接链接
* @name :getImageUrl
* @author :lyh
... ...
... ... @@ -34,7 +34,7 @@ class BlogController extends BaseController
$v = $blogLabelLogic->get_label_name($v);
$v['route'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG, $v['id'], $this->user['project_id']);
$v['url'] = $this->getProjectDomain() . $v['route'];
$v['image_link'] = $this->getImageUrl($v['image']);
$v['image_link'] = getImageUrl($v['image']);
$lists['list'][$k] = $v;
}
}
... ... @@ -78,7 +78,7 @@ class BlogController extends BaseController
$info = $blogLogic->blog_info();
$info['route'] = RouteMap::getRoute(RouteMap::SOURCE_BLOG, $info['id'], $this->user['project_id']);
$info['url'] = $this->getProjectDomain() . $info['route'];
$info['image_link'] = $this->getImageUrl($info['image']);
$info['image_link'] = getImageUrl($info['image']);
$this->response('success',Code::SUCCESS,$info);
}
... ...
... ... @@ -32,7 +32,7 @@ class NewsController extends BaseController
$v = $newsCategoryLogic->get_category_name($v);
$v['route'] = RouteMap::getRoute(RouteMap::SOURCE_NEWS, $v['id'], $this->user['project_id']);
$v['url'] = $this->getProjectDomain() . $v['route'];
$v['image_link'] = $this->getImageUrl($v['image']);
$v['image_link'] = getImageUrl($v['image']);
$lists['list'][$k] = $v;
}
}
... ... @@ -75,7 +75,7 @@ class NewsController extends BaseController
$info = $newsLogic->news_info();
$info['route'] = RouteMap::getRoute(RouteMap::SOURCE_NEWS, $info['id'], $this->user['project_id']);
$info['url'] = $this->getProjectDomain() . $info['route'];
$info['image_link'] = $this->getImageUrl($info['image']);
$info['image_link'] = getImageUrl($info['image']);
$this->response('success',Code::SUCCESS,$info);
}
/**
... ...
... ... @@ -24,7 +24,7 @@ class ProofreadingController extends BaseController
$lists = $proofreadingLogic->proofreadingList($this->map,$this->page,$this->row);
if(!empty($lists['list']) && ($this->param['type'] == $this::TYPE_IMAGE)){
foreach ($lists['list'] as $k => $v){
$lists['list'][$k]['image_link'] = $this->getImageUrl($v['translate']);
$lists['list'][$k]['image_link'] = getImageUrl($v['translate']);
}
}
$this->response('success',Code::SUCCESS,$lists);
... ...
... ... @@ -22,7 +22,7 @@ class WebSettingServiceController extends BaseController
$lists = $webSettingServiceLogic->setting_service_list();
foreach ($lists as $k => $v){
if($v['type'] == self::TYPE_CODE){
$v['values_link'] = $this->getImageUrl($v['values']);
$v['values_link'] = getImageUrl($v['values']);
$lists[$k] = $v;
}
}
... ...
... ... @@ -20,7 +20,7 @@ class BTemplateController extends BaseController
$lists = $BTemplateLogic->publicTemplateLists($this->map,$this->page,$this->row,$this->order);
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $k => &$v){
$v['image_link'] = $this->getImageUrl($v['image']);
$v['image_link'] = getImageUrl($v['image']);
$lists['list'][$k] = $v;
}
}
... ...
... ... @@ -302,7 +302,7 @@ class ImageController extends Controller
$imageModel = new ImageModel();
$lists = $imageModel->list($this->param,$order = 'id');
foreach ($lists as $k => $v){
$v['image_link'] = $this->getImageUrl($v['hash']);
$v['image_link'] = getImageUrl($v['hash']);
$lists[$k] = $v;
}
$this->response('success',Code::SUCCESS,$lists);
... ... @@ -336,25 +336,6 @@ class ImageController extends Controller
}
/**
* @remark :获取图片链接
* @name :getImageUrl
* @author :lyh
* @method :post
* @time :2023/7/20 16:46
*/
public function getImageUrl($hash){
$imageModel = new ImageModel();
$info = $imageModel->read(['hash'=>$hash]);
if($info['is_cos'] == 1){
$cos = new CosService();
$url = $cos->getImageUrl($info['path']);
}else{
$url = url('a/image/'.$info['hash']);
}
return $url;
}
/**
* @remark :统一返回参数处理
* @name :responseData
* @author :lyh
... ... @@ -364,7 +345,7 @@ class ImageController extends Controller
public function responseData($hash){
$data = [
'image'=>$hash,
'image_link'=>$this->getImageUrl($hash),
'image_link'=>getImageUrl($hash),
'image_download'=>url('a/downLoad/images?hash='.$hash),
];
return $data;
... ...
... ... @@ -102,7 +102,7 @@ class BTemplateLogic extends BaseLogic
$ATemplateModel = new Template();
$ATemplateInfo = $ATemplateModel->read(['id'=>$info['template_id']]);
$TemplateInfo['name'] = $ATemplateInfo['name'];
$TemplateInfo['image_link'] = $this->getImageUrl($ATemplateInfo['image']);
$TemplateInfo['image_link'] = getImageUrl($ATemplateInfo['image']);
}
$TemplateInfo['html'] = $this->getHeadFooter($TemplateInfo['html']);
return $this->success($TemplateInfo);
... ...
... ... @@ -33,7 +33,7 @@ class CategoryLogic extends BaseLogic
foreach ($data as &$v){
$v['url'] = $this->getProjectDomain() . $v['route'] ;
$v['product_num'] = $this->getProductNum($v['id']);
$v['image_link'] = $this->getImageUrl($v['image']);
$v['image_link'] = getImageUrl($v['image']);
}
if(!$map){
$data = Arr::listToTree($data);
... ... @@ -45,7 +45,7 @@ class CategoryLogic extends BaseLogic
{
$info = $this->model->read(['id'=>$id]);
$info['url'] = $this->getProjectDomain() . $info['route'] ;
$info['image_link'] = $this->getImageUrl($info['image']);
$info['image_link'] = getImageUrl($info['image']);
return $this->success($info);
}
... ...
... ... @@ -31,7 +31,7 @@ class ProductLogic extends BaseLogic
$data = parent::getList($map, $sort, $columns, $limit);
foreach ($data['list'] as &$v){
$v = $this->formatData($v);
$v['thumb']['image_link'] = $this->getImageUrl($v['thumb']['url']);//图片统一
$v['thumb']['image_link'] = getImageUrl($v['thumb']['url']);//图片统一
}
return $this->success($data);
}
... ... @@ -43,11 +43,11 @@ class ProductLogic extends BaseLogic
//统一图片链接
if(!empty($info['gallery'])){
foreach ($info['gallery'] as $k => $v){
$v['image_link'] = $this->getImageUrl($v['url']);
$v['image_link'] = getImageUrl($v['url']);
$info['gallery'][$k] = $v;
}
}
$info['icon_link'] = $this->getImageUrl($info['icon']);
$info['icon_link'] = getImageUrl($info['icon']);
return $this->success($info);
}
... ...
... ... @@ -383,34 +383,6 @@ class Logic
}
/**
* @remark :获取图片链接
* @name :getImageUrl
* @author :lyh
* @method :post
* @time :2023/7/20 16:46
*/
public function getImageUrl($hash){
if(is_array($hash)){
$url = [];
foreach ($hash as $k => $v){
$url[$k] = $this->getImageUrl($v);
}
}else{
$imageModel = new Image();
$info = $imageModel->read(['hash'=>$hash]);
if($info['is_cos'] == 1){
$cos = new CosService();
$url = $cos->getImageUrl($info['path']);
}else{
$url = url('a/image/'.$info['hash']);
}
}
return $url;
}
/**
* 获取实例
* @param mixed ...$params
* @return static
... ...