作者 lyh

gx

<?php
/**
* @remark :
* @name :CopyProject.php
* @author :lyh
* @method :post
* @time :2024/1/9 16:01
*/
namespace App\Events;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
class CopyImageFile
{
use Dispatchable, InteractsWithSockets, SerializesModels;
public $data;
/**
* 监听更新HTML静态页
*/
public function __construct($data)
{
$this->data = $data;
}
}
... ...
... ... @@ -471,11 +471,6 @@ if (!function_exists('getImageUrl')) {
if(substr($path,0,2) == '//'){
return 'https:'.$path;
}
// $imageModel = new Image();
// $imageInfo = $imageModel->read(['path'=>$path],['is_cos']);
// if($imageInfo === false){
// return '';
// }
if($location == 0){
$cos = config('filesystems.disks.cos');
$cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1'];
... ... @@ -514,11 +509,6 @@ if (!function_exists('getFileUrl')) {
if(substr($path,0,2) == '//'){
return 'https:'.$path;
}
// $fileModel = new FileModel();
// $fileInfo = $fileModel->read(['path'=>$path],['is_cos']);
// if($fileInfo === false){
// return '';
// }
if($location == 0){
$cos = config('filesystems.disks.cos');
$cosCdn = ($storage_type == 0) ? $cos['cdn'] : $cos['cdn1'];
... ...
... ... @@ -38,7 +38,7 @@ class BlogController extends BaseController
foreach ($lists['list'] as $k => $v){
$v['category_name'] = $this->categoryName($v['category_id'],$data);
$v['url'] = $this->user['domain'] . getRouteMap(RouteMap::SOURCE_BLOG,$v['id']);
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type']);
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
$v['operator_name'] = $user->getName($v['operator_id']);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_BLOG,BTemplate::IS_DETAIL,$template_id,$v['id']);
$lists['list'][$k] = $v;
... ...
... ... @@ -37,7 +37,7 @@ class CustomModuleContentController extends BaseController
$data = $this->getAllCategoryName();
foreach ($lists['list'] as $k=>$v){
$v['category_name'] = $this->categoryName($v['category_id'],$data);
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type']);
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
$v['operator_name'] = (new User())->getName($v['operator_id']);
$lists['list'][$k] = $v;
}
... ...
... ... @@ -35,6 +35,7 @@ class NavController extends BaseController
if(!empty($lists)){
foreach ($lists as $v){
$v = (array)$v;
$v = $this->handleReturnInfo($v);
if ($v['pid'] == 0) {
$v['sub'] = _get_child($v['id'], $lists);
$data[] = $v;
... ... @@ -52,6 +53,23 @@ class NavController extends BaseController
}
/**
* @remark :单独处理图片文件
* @name :HandleReturnInfo
* @author :lyh
* @method :post
* @time :2024/1/26 9:44
*/
public function handleReturnInfo($param){
if(isset($param['image']) && !empty($param['image'])){
$param['image'] = getImageUrl($param['image'],$this->user['storage_type'],$this->user['project_location']);
}
if(isset($param['remark_image']) && !empty($param['remark_image'])){
$param['remark_image'] = getImageUrl($param['image'],$this->user['storage_type'],$this->user['project_location']);
}
return $this->success($param);
}
/**
* @remark :根据固定的数组排序
* @name :findDetailsInList
* @author :lyh
... ...
... ... @@ -41,7 +41,7 @@ class NewsController extends BaseController
foreach ($lists['list'] as $k => $v){
$v['category_name'] = $this->categoryName($v['category_id'],$data);
$v['url'] = $this->user['domain'].getRouteMap(RouteMap::SOURCE_NEWS,$v['id']);
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type']);
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
$v['operator_name'] = $user->getName($v['operator_id']);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_NEWS,BTemplate::IS_DETAIL,$template_id,$v['id']);
$lists['list'][$k] = $v;
... ...
... ... @@ -43,6 +43,7 @@ class KeywordController extends BaseController
}else{
$v['tdk'] = 0;
}
$v = $this->handleReturnInfo($v);
$v['url'] = $this->user['domain'] . $v['route'].'/';
}
}
... ... @@ -50,6 +51,23 @@ class KeywordController extends BaseController
}
/**
* @remark :单独处理图片文件
* @name :HandleReturnInfo
* @author :lyh
* @method :post
* @time :2024/1/26 9:44
*/
public function handleReturnInfo($param){
if(isset($param['keyword_top_banner']) && !empty($param['keyword_top_banner'])){
$param['keyword_top_banner'] = getImageUrl($param['keyword_top_banner'],$this->user['storage_type'],$this->user['project_location']);
}
if(isset($param['keyword_foot_banner']) && !empty($param['keyword_foot_banner'])){
$param['keyword_foot_banner'] = getImageUrl($param['keyword_foot_banner'],$this->user['storage_type'],$this->user['project_location']);
}
return $this->success($param);
}
/**
* @remark :搜索
* @name :searchParam
* @author :lyh
... ... @@ -82,6 +100,9 @@ class KeywordController extends BaseController
'id.required' => 'ID不能为空'
]);
$data = $logic->getKeywordInfo();
if($data !== false){
$data = $this->handleReturnInfo($data);
}
$this->response('success',Code::SUCCESS,$data);
}
... ...
... ... @@ -330,7 +330,7 @@ class ProductController extends BaseController
$arr = json_decode($info['values']);
foreach ($arr as $k1=>$v1){
$v1 = (array)$v1;
$v1['url'] = getImageUrl($v1['url'],$this->user['storage_type']);
$v1['url'] = getImageUrl($v1['url'],$this->user['storage_type'],$this->user['project_location']);
$arr[$k1] = $v1;
}
$v['values'] = $arr;
... ... @@ -339,9 +339,9 @@ class ProductController extends BaseController
foreach ($arr1 as $k1=>$v1){
$v1 = (array)$v1;
if(isset($v1['url'])){
$v1['url'] = getFileUrl($v1['url'],$this->user['storage_type']);
$v1['url'] = getFileUrl($v1['url'],$this->user['storage_type'],$this->user['project_location']);
}else{
$v1 = getFileUrl($v1,$this->user['storage_type']);
$v1 = getFileUrl($v1,$this->user['storage_type'],$this->user['project_location']);
}
$arr1[$k1] = $v1;
}
... ...
... ... @@ -25,7 +25,7 @@ class WebSettingImageController extends BaseController
public function lists(WebSettingImage $webSettingImage){
$list = $webSettingImage->list([],'id',['id','image','type']);
foreach ($list as $k=>$v){
$v['image'] = getImageUrl($v['image'],$this->user['storage_type']);
$v['image'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
$list[$k] = $v;
}
$this->response('success',Code::SUCCESS,$list);
... ...
... ... @@ -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'] = getImageUrl($v['values']);
$v['values_link'] = getImageUrl($v['values'],$this->user['storage_type'],$this->user['project_location']);
$lists[$k] = $v;
}
}
... ...
... ... @@ -22,7 +22,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'] = getImageUrl($v['image'],$this->user['storage_type']);
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
$lists['list'][$k] = $v;
}
}
... ...
... ... @@ -363,7 +363,7 @@ class ImageController extends Controller
$lists = $imageModel->lists($this->map,$this->page,$this->row);
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
$v['image_link'] = getImageUrl($v['path'],$this->cache['storage_type'] ?? 0);
$v['image_link'] = getImageUrl($v['path'],$this->cache['storage_type'] ?? 0,$this->cache['project_location']);
$lists['list'][$k] = $v;
}
}
... ... @@ -429,7 +429,7 @@ class ImageController extends Controller
public function responseData($path = '', $name = ''){
$data = [
'image'=>$path,
'image_link'=>getImageUrl($path,$this->cache['storage_type'] ?? 0),
'image_link'=>getImageUrl($path,$this->cache['storage_type'] ?? 0,$this->cache['project_location']),
'name'=>$name,
'image_download'=>url('a/download_images?path='.$path)
];
... ...
... ... @@ -64,12 +64,12 @@ class AyrReleaseLogic extends BaseLogic
$imageModel = new Image();
$list = $imageModel->list(['path'=>['in',$images]],'id');
foreach ($list as $v1){
$arr[] = getImageUrl($v1['path']);
$arr[] = getImageUrl($v1['path'],$this->user['storage_type'],$this->user['project_location']);
}
}else{
$fileModel = new File();
$info = $fileModel->read(['path'=>$v]);
$arr[] = getFileUrl($info['path']);
$arr[] = getFileUrl($info['path'],$this->user['storage_type'],$this->user['project_location']);
}
}
return $this->success($arr);
... ...
... ... @@ -101,7 +101,7 @@ class BlogLogic extends BaseLogic
//获取标签名称
$blogLabelLogic = new BlogLabelLogic();
$info['label_name'] = $blogLabelLogic->getLabelName($info['label_id']);
$info['image_link'] = getImageUrl($info['image'],$this->user['storage_type']);
$info['image_link'] = getImageUrl($info['image'],$this->user['storage_type'],$this->user['project_location']);
return $this->success($info);
}
... ...
... ... @@ -82,7 +82,7 @@ class CustomModuleCategoryLogic extends BaseLogic
if($info === false){
$this->fail('当前数据不存在或已被删除');
}
$info['image'] = getImageUrl($info['image']);
$info['image'] = getImageUrl($info['image'],$this->user['storage_type'],$this->user['project_location']);
return $this->success($info);
}
... ...
... ... @@ -39,7 +39,7 @@ class CustomModuleContentLogic extends BaseLogic
if($info === false){
$this->fail('当前数据不存在或已被删除');
}
$info['image'] = getImageUrl($info['image'],$this->user['storage_type']);
$info['image'] = getImageUrl($info['image'],$this->user['storage_type'],$this->user['project_location']);
$info['extend'] = $this->getExtendInfo($info['module_id'],$info['id']);
return $this->success($info);
}
... ... @@ -86,14 +86,14 @@ class CustomModuleContentLogic extends BaseLogic
$arr = json_decode($info['values']);
foreach ($arr as $k1=>$v1){
$v1 = (array)$v1;
$v1['url'] = getImageUrl($v1['url'],$this->user['storage_type']);
$v1['url'] = getImageUrl($v1['url'],$this->user['storage_type'],$this->user['project_location']);
$arr[$k1] = $v1;
}
$v['values'] = $arr;
}elseif($v['type'] == 4){
$arr1 = json_decode($info['values']);
foreach ($arr1 as $k1=>$v1){
$v1 = getFileUrl($v1,$this->user['storage_type']);
$v1 = getFileUrl($v1,$this->user['storage_type'],$this->user['project_location']);
$arr1[$k1] = $v1;
}
$v['values'] = $arr1;
... ...
... ... @@ -97,7 +97,7 @@ class InquiryLogic extends BaseLogic
foreach ($data['list'] as &$v){
foreach ($v['data'] as &$field){
if(is_array($field) && !empty($field['path'])){
$field['path'] = getImageUrl($field['path']);
$field['path'] = getImageUrl($field['path'],$this->user['storage_type'],$this->user['project_location']);
}
}
$v = array_merge($v, $v['data']);
... ...
... ... @@ -147,7 +147,7 @@ class NewsLogic extends BaseLogic
$this->fail('error');
}
$info['category_id'] = explode(',',trim($info['category_id'],','));
$info['image_link'] = getImageUrl($info['image'],$this->user['storage_type']);
$info['image_link'] = getImageUrl($info['image'],$this->user['storage_type'],$this->user['project_location']);
return $this->success($info);
}
... ...
... ... @@ -32,7 +32,7 @@ class CategoryLogic extends BaseLogic
foreach ($data as &$v){
$v['url'] = $this->user['domain'] . $v['route'] ;
$v['product_num'] = Category::getProductNum($v['id']);
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type']);
$v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
}
if(!$map){
$data = Arr::listToTree($data);
... ... @@ -100,8 +100,8 @@ class CategoryLogic extends BaseLogic
if($info === false){
$this->fail('当前数据不存在或者已被删除');
}
$info['image_link'] = getImageUrl($info['image']);
$info['describe_image'] = !empty($info['describe_image']) ? getImageUrl(json_decode($info['describe_image'])) : [];
$info['image_link'] = getImageUrl($info['image'],$this->user['storage_type'],$this->user['project_location']);
$info['describe_image'] = !empty($info['describe_image']) ? getImageUrl(json_decode($info['describe_image']),$this->user['storage_type'],$this->user['project_location']) : [];
return $this->success($info);
}
... ...
... ... @@ -40,8 +40,10 @@ class KeywordLogic extends BaseLogic
public function getKeywordInfo()
{
$info = $this->model->read($this->param);
if($info !== false){
$info['url'] = $this->user['domain'] . $info['route'];
$info['related_news_info'] = News::whereIn('id', $info['related_news_ids'])->select(['id', 'name'])->get();
}
return $this->success($info);
}
... ... @@ -103,30 +105,20 @@ class KeywordLogic extends BaseLogic
* @time :2023/10/23 14:47
*/
public function handleSaveParam($param){
if(isset($param['keyword_top_banner']) && !empty($param['keyword_top_banner'])){
$param['keyword_top_banner'] = str_replace_url($param['keyword_top_banner']);
}else{
unset($param['keyword_top_banner']);
if(isset($param['keyword_top_banner'])){
$param['keyword_top_banner'] = str_replace_url($param['keyword_top_banner'] ?? []);
}
if(isset($param['keyword_foot_banner']) && !empty($param['keyword_foot_banner'])){
$param['keyword_foot_banner'] = str_replace_url($param['keyword_foot_banner']);
}else{
unset($param['keyword_foot_banner']);
if(isset($param['keyword_foot_banner'])){
$param['keyword_foot_banner'] = str_replace_url($param['keyword_foot_banner'] ?? []);
}
if(isset($param['keyword_video']) && !empty($param['keyword_video'])){
$param['keyword_video'] = Arr::a2s($param['keyword_video']);
}else{
unset($param['keyword_video']);
if(isset($param['keyword_video'])){
$param['keyword_video'] = Arr::a2s($param['keyword_video'] ?? []);
}
if(!empty($param['related_news_ids'])){
$param['related_news_ids'] = Arr::arrToSet($param['related_news_ids']);
}else{
unset($param['related_news_ids']);
$param['related_news_ids'] = Arr::arrToSet($param['related_news_ids'] ?? []);
}
if(!empty($param['related_blog_ids'])){
$param['related_blog_ids'] = Arr::arrToSet($param['related_blog_ids']);
}else{
unset($param['related_blog_ids']);
$param['related_blog_ids'] = Arr::arrToSet($param['related_blog_ids'] ?? []);
}
return $param;
}
... ...
... ... @@ -28,11 +28,11 @@ class WebSettingAmpLogic extends BaseLogic
return $this->success();
}
//log图处理
$info['top_logo'] = getImageUrl($info['top_logo'], $this->user['storage_type'] ?? 0);
$info['top_logo'] = getImageUrl($info['top_logo'],$this->user['storage_type'],$this->user['project_location']);
//banner处理
if (!empty($info['index_banner'])) {
foreach ($info['index_banner'] as &$v) {
$v = getImageUrl($v, $this->user['storage_type'] ?? 0);
$v = getImageUrl($v,$this->user['storage_type'],$this->user['project_location']);
}
}
return $this->success($info);
... ...
<?php
namespace App\Listeners;
use App\Events\CopyImageFile;
use App\Events\UpdateHtml;
use App\Jobs\updateHtmlJob;
use Illuminate\Contracts\Queue\ShouldQueue;
class CopyImageFileListener implements ShouldQueue
{
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param UpdateHtml $event
* @return void
*/
public function handle(CopyImageFile $event)
{
$this->param = $event->data;
}
/**
* @remark :同步图片文件到亚马逊
* @name :uploadImageFile
* @author :lyh
* @method :post
* @time :2024/1/26 10:15
*/
public function uploadImageFile(){
}
}
... ...
... ... @@ -65,31 +65,31 @@ class BNav extends Base
return static::where(['pid'=>$id,'project_id'=>$project_id])->limit(1)->count();
}
/**
* @remark :获取图片
* @name :getImageAttribute
* @author :lyh
* @method :post
* @time :2023/9/18 16:20
*/
public function getImageAttribute($value)
{
$value = getImageUrl($value);
return $value;
}
/**
* @remark :获取图片
* @name :getImageAttribute
* @author :lyh
* @method :post
* @time :2023/9/18 16:20
*/
public function getRemarkImageAttribute($value)
{
$value = getImageUrl($value);
return $value;
}
// /**
// * @remark :获取图片
// * @name :getImageAttribute
// * @author :lyh
// * @method :post
// * @time :2023/9/18 16:20
// */
// public function getImageAttribute($value)
// {
// $value = getImageUrl($value);
// return $value;
// }
//
// /**
// * @remark :获取图片
// * @name :getImageAttribute
// * @author :lyh
// * @method :post
// * @time :2023/9/18 16:20
// */
// public function getRemarkImageAttribute($value)
// {
// $value = getImageUrl($value);
// return $value;
// }
/**
* 是否支持一键导入
... ...
... ... @@ -13,35 +13,8 @@ class Keyword extends Base
//设置关联表名
protected $table = 'gl_product_keyword';
// protected $appends = ['route'];
//连接数据库
protected $connection = 'custom_mysql';
// public function getRouteAttribute(){
// return RouteMap::getRoute(RouteMap::SOURCE_PRODUCT_KEYWORD, $this->id, $this->project_id);
// }
/**
* @remark :图
* @name :getKeywordTopBannerAttribute
* @author :lyh
* @method :post
* @time :2023/7/21 11:11
*/
public function getKeywordTopBannerAttribute($value){
return getImageUrl($value);
}
/**
* @remark :图
* @name :getKeywordTopBannerAttribute
* @author :lyh
* @method :post
* @time :2023/7/21 11:11
*/
public function getKeywordFootBannerAttribute($value){
return getImageUrl($value);
}
/**
* @remark :视频
... ...
... ... @@ -2,12 +2,13 @@
namespace App\Providers;
use App\Events\CopyImageFile;
use App\Events\CopyProject;
use App\Listeners\CopyImageFileListener;
use App\Listeners\CopyProjectListener;
use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
class EventServiceProvider extends ServiceProvider
{
... ... @@ -25,6 +26,7 @@ class EventServiceProvider extends ServiceProvider
'App\Listeners\QueryListener',
],
CopyProject::class => [CopyProjectListener::class],
CopyImageFile::class => [CopyImageFileListener::class],
];
/**
... ...
... ... @@ -56,4 +56,29 @@ class AmazonS3Service
return false;
}
}
/**
* @remark :同步图片文件到亚马逊
* @name :uploadImage
* @author :lyh
* @method :post
* @time :2024/1/23 9:20
*/
public function SyncImageFiles($files)
{
$key = str_replace_url($files);
$body = $files;
try {
$result = $this->s3->putObject([
'Bucket' => $this->bucket,
'Key' => $key,
'Body' => fopen($body, 'rb'),
]);
echo '文件成功上传到S3!';
} catch (AwsException $e) {
echo '上传文件到S3时发生错误:' . $e->getMessage();
return false;
}
}
}
... ...