作者 李宇航

合并分支 'develop' 到 'master'

Develop



查看合并请求 !381
正在显示 32 个修改的文件 包含 247 行增加128 行删除
... ... @@ -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'];
... ...
... ... @@ -217,7 +217,10 @@ class OptimizeController extends BaseController
$query = $query->whereBetween('gl_project_deploy_optimize.updated_at', $this->map['online_updated_at']);
}
if(isset($this->map['special'])){
$query = $query->where('gl_project_deploy_optimize.special','like','%'.$this->map['special'].'%');
$query = $query->whereRaw("FIND_IN_SET(?, gl_project_deploy_optimize.special) > 0", [$this->map['special']]);
}
if(isset($this->map['is_remain_today'])){
$query = $query->where('gl_project.is_remain_today',$this->map['is_remain_today']);
}
if(isset($this->map['manager_mid']) && !empty($this->map['manager_mid'])){
$query = $query->where('gl_project_deploy_build.manager_mid','like','%'.$this->map['manager_mid'].'%');
... ...
... ... @@ -26,7 +26,7 @@ class ATemplateController extends BaseController
*/
public function lists(ATemplateLogic $aTemplateLogic){
$filed = ['id','name','image','url','status','sort','deleted_status','test_model','created_at','project_id'];
$this->map['project_id'] = 0;
$this->map['test_model'] = 0;
$lists = $aTemplateLogic->aTemplateList($this->map,$this->page,$this->row,$this->order,$filed);
if(!empty($lists) && !empty($lists['list'])){
foreach ($lists['list'] as $k => $v){
... ...
... ... @@ -25,8 +25,10 @@ class ATemplateModuleController extends BaseController
* @time :2023/6/28 16:54
*/
public function lists(ATemplateModuleLogic $ATemplateModuleLogic){
if(!isset($this->map['test_model'])){
$this->map['test_model'] = 0;
if(isset($this->map['type']) && ($this->map['type'] == 99)){
$this->map['type'] = 99;
}else{
$this->map['project_id'] = 0;
}
$lists = $ATemplateModuleLogic->aTemplateModuleLists($this->map,$this->page,$this->row,$this->order);
$this->response('success',Code::SUCCESS,$lists);
... ...
... ... @@ -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;
... ... @@ -299,4 +299,21 @@ class NewsController extends BaseController
$logic->batchSetCategory();
$this->response('success');
}
/**
* @remark :Ai发布新闻
* @name :sendAiNews
* @author :lyh
* @method :post
* @time :2024/1/26 15:33
*/
public function sendAiNews(){
$this->request->validate([
'keyword'=>'required',
],[
'keyword.required' => 'keyword不能为空',
]);
$data = http_get('http://gnews.globalso.com/gnews_news.php?keyword='.$this->param['keyword']);
$this->response('success',Code::SUCCESS,$data);
}
}
... ...
... ... @@ -41,7 +41,7 @@ class CategoryController extends BaseController
foreach ($list as $k =>$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']);
$v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST,$template_id,$v['id']);
$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);
}
... ...
... ... @@ -78,25 +78,25 @@ class ProductController extends BaseController
public function getHandleFileImage($v){
//ToDo::处理图片及文件
if(!empty($v['thumb']) && !empty($v['thumb']['url'])){
$v['thumb']['url'] = getImageUrl($v['thumb']['url'],$this->user['storage_type'] ?? 0);
$v['thumb']['url'] = getImageUrl($v['thumb']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
}
if(!empty($v['gallery'])){
foreach ($v['gallery'] as $gallery_k => $gallery_v){
$gallery_v['url'] = getImageUrl($gallery_v['url'],$this->user['storage_type'] ?? 0);
$gallery_v['url'] = getImageUrl($gallery_v['url'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
$v['gallery'][$gallery_k] = $gallery_v;
}
}
if(!empty($v['icon'])){
foreach ($v['icon'] as $icon_k => $icon_v){
$icon_v = getImageUrl($icon_v,$this->user['storage_type'] ?? 0);
$icon_v = getImageUrl($icon_v,$this->user['storage_type'] ?? 0,$this->user['project_location']);
$v['icon'][$icon_k] = $icon_v;
}
}
if(!empty($v['video']) && !empty($v['video']['url'])){
$v['video']['url'] = getImageUrl($v['video']['url'],$this->user['storage_type'] ?? 0);
$v['video']['url'] = getImageUrl($v['video']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
}
if(!empty($v['files']) && !empty($v['files']['url'])){
$v['files']['url'] = getImageUrl($v['files']['url'],$this->user['storage_type'] ?? 0);
$v['files']['url'] = getImageUrl($v['files']['url'],$this->user['storage_type'] ?? 0,$this->user['project_location']);
}
return $this->success($v);
}
... ... @@ -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'] ?? 0),
'name'=>$name,
'image_download'=>url('a/download_images?path='.$path)
];
... ...
... ... @@ -3,8 +3,10 @@
namespace App\Http\Logic\Aside\Project;
use App\Enums\Common\Code;
use App\Events\CopyImageFile;
use App\Events\CopyProject;
use App\Exceptions\AsideGlobalException;
use App\Jobs\CopyImageFileJob;
use App\Models\Com\NoticeLog;
use App\Models\Com\UpdateLog;
use App\Models\Devops\ServerConfig;
... ... @@ -128,8 +130,8 @@ class ProjectLogic extends BaseLogic
* @time :2023/8/30 11:57
*/
public function projectSave(){
DB::beginTransaction();
try {
// DB::beginTransaction();
// try {
if($this->param['type'] == Project::TYPE_SEVEN){
//错误单直接返回,单独处理
$this->setTypeSevenEdit($this->param);
... ... @@ -149,19 +151,26 @@ class ProjectLogic extends BaseLogic
//保存询盘过滤配置
// $this->param['inquiry_filter_config']['project_id'] = $this->param['id'];
// $this->saveInquiryFilterConfig($this->param['inquiry_filter_config']);
$this->syncImageFile($this->param['project_location'],$this->param['id']);
//创建站点
// $this->createSite($this->param);
}
DB::commit();
}catch (\Exception $e){
DB::rollBack();
$this->fail('保存失败,请联系管理员');
}
// DB::commit();
// }catch (\Exception $e){
// DB::rollBack();
// $this->fail('保存失败,请联系管理员');
// }
(new SyncService())->projectAcceptAddress($this->param['id']);
return $this->success();
}
public function syncImageFile($location,$project_id){
if($location == 1){
CopyImageFileJob::dispatch(['project_id'=>$project_id]);
}
return $this->success();
}
/**
* @remark :保存项目
* @name :setExtendType
... ... @@ -330,7 +339,7 @@ class ProjectLogic extends BaseLogic
$config['filter_mobiles'] = Arr::a2s(!empty($config['filter_mobiles']) ? $config['filter_mobiles'] : []);
$config['filter_names'] = Arr::a2s(!empty($config['filter_names']) ? $config['filter_names'] : []);
$config['black_ips'] = $config['black_ips'] ?? '';
$model = InquiryFilterConfig::where('project_id', $config['project_id'])->first();
if(!$model){
$model = new InquiryFilterConfig();
... ...
... ... @@ -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']);
... ...
... ... @@ -3,6 +3,7 @@
namespace App\Http\Logic\Bside\News;
use App\Enums\Common\Code;
use App\Helper\Arr;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\News\News;
use App\Models\News\NewsCategory;
... ... @@ -147,7 +148,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);
}
... ... @@ -181,6 +182,9 @@ class NewsLogic extends BaseLogic
*/
public function paramProcessing($param)
{
if(isset($param['image'])){
$param['image'] = str_replace_url($param['image'] ?? '');
}
if(isset($this->param['id'])){
$param['operator_id'] = $this->user['id'];
if(isset($param['category_id']) && !empty($param['category_id'])){
... ...
... ... @@ -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);
$info['url'] = $this->user['domain'] . $info['route'];
$info['related_news_info'] = News::whereIn('id', $info['related_news_ids'])->select(['id', 'name'])->get();
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\Jobs;
use App\Events\CopyImageFile;
use App\Models\File\File as FileModel;
use App\Models\File\Image as ImageModel;
use App\Services\AmazonS3Service;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class CopyImageFileJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public $tries = 3; // 可配置任务重试次数
protected $param;
/**
* Create a new job instance.
*
* @param CopyImageFile $event
* @return void
*/
public function __construct($data)
{
$this->param = $data;
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$imageModel = new ImageModel();
//获取当前项目的所有图片
$imageList = $imageModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos','size']);
if(!empty($imageList)){
$amazonS3Service = new AmazonS3Service();
foreach ($imageList as $k => $v){
$amazonS3Service->syncImageFiles(getImageUrl($v['path']));
$imageModel->edit(['is_cos'=>0],['id'=>$v['id']]);
}
}
$fileModel = new FileModel();
$fileList = $fileModel->list(['project_id'=>$this->param['project_id'],'is_cos'=>1],'id',['id','path','is_cos']);
if(!empty($fileList)){
$amazonS3Service = new AmazonS3Service();
foreach ($fileList as $k => $v){
$amazonS3Service->syncImageFiles(getImageUrl($v['path']));
$fileModel->edit(['is_cos'=>0],['id'=>$v['id']]);
}
}
return true;
}
}
... ...
... ... @@ -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
{
... ...
... ... @@ -56,4 +56,30 @@ class AmazonS3Service
return false;
}
}
/**
* @remark :同步图片文件到亚马逊
* @name :uploadImage
* @author :lyh
* @method :post
* @time :2024/1/23 9:20
*/
public function syncImageFiles($files)
{
$file_content = curl_c($files,false);
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($file_content, true) . PHP_EOL, FILE_APPEND);
$key = str_replace_url($files);
try {
$result = $this->s3->putObject([
'Bucket' => $this->bucket,
'Key' => ltrim($key,'/'),
'Body' => $file_content,
]);
// unlink($location);
return $result['ObjectURL'];
} catch (AwsException $e) {
return '上传文件到S3时发生错误:' . $e->getMessage();
}
}
}
... ...
... ... @@ -13,7 +13,7 @@ return [
|
*/
'default' => env('QUEUE_CONNECTION', 'sync'),
'default' => env('QUEUE_CONNECTION', 'redis'),
/*
|--------------------------------------------------------------------------
... ...
... ... @@ -75,6 +75,7 @@ Route::middleware(['bloginauth'])->group(function () {
Route::any('/del', [\App\Http\Controllers\Bside\News\NewsController::class, 'del'])->name('news_del');
Route::any('/status', [\App\Http\Controllers\Bside\News\NewsController::class, 'status'])->name('news_status');
Route::any('/sort', [\App\Http\Controllers\Bside\News\NewsController::class, 'sort'])->name('news_sort');
Route::any('/sendAiNews', [\App\Http\Controllers\Bside\News\NewsController::class, 'sendAiNews'])->name('news_sendAiNews');
Route::any('/allSort', [\App\Http\Controllers\Bside\News\NewsController::class, 'allSort'])->name('news_allSort');
Route::any('/batchSetCategory', [\App\Http\Controllers\Bside\News\NewsController::class, 'batchSetCategory'])->name('news_batchSetCategory');
Route::any('/statusNum', [\App\Http\Controllers\Bside\News\NewsController::class, 'getStatusNumber'])->name('news_statusNum');
... ...