作者 李小龙

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into develop

... ... @@ -137,4 +137,5 @@ class AyrReleaseController extends BaseController
$ayrShareLogic->save_file($param_data);
$this->response('success');
}
}
... ...
... ... @@ -242,11 +242,13 @@ class BaseController extends Controller
$imageModel = new Image();
$info = $imageModel->read(['hash'=>$hash]);
$url = '';
if($info['is_cos'] == 1){
$cos = new CosService();
$url = $cos->getImageUrl($info['path']);
}else{
$url = url('b/image/'.$info['hash']);
if($info !== false){
if($info['is_cos'] == 1){
$cos = new CosService();
$url = $cos->getImageUrl($info['path']);
}else{
$url = url('b/image/'.$info['hash']);
}
}
return $url;
}
... ...
... ... @@ -66,8 +66,7 @@ class ProductController extends BaseController
'id.required' => 'ID不能为空'
]);
$data = $logic->getInfo($this->param['id']);
return $this->success(Arr::twoKeepKeys($data, ['id', 'project_id', 'title', 'gallery', 'attrs', 'category_id', 'keyword_id', 'attr_id', 'describe_id', 'intro', 'content',
'describe', 'seo_mate', 'related_product_id', 'status', 'category_id_text', 'keyword_id_text', 'status_text', 'created_uid', 'created_uid_text', 'route', 'url']));
return $this->success($data);
}
public function save(ProductRequest $request, ProductLogic $logic)
... ...
... ... @@ -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'] = url('/b/image/' . $v['translate']);
$lists['list'][$k]['image_link'] = $this->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'] = url('/b/image/' . $v['values']);
$v['values_link'] = $this->getImageUrl($v['values']);
$lists[$k] = $v;
}
}
... ...
... ... @@ -320,7 +320,7 @@ class FileController
$this->path = $this->uploads['path_a'].'/'.$this->file_type[$this->param['refer']].'/'.date('Y-m');
}else{
//B端上传
if(!isset($this->param['upload_method']) && $this->param['upload_method'] == 1){
if(isset($this->param['upload_method']) && $this->param['upload_method'] == 1){
//强制上传本地配置
$this->upload_location = 0;
}else{
... ... @@ -334,7 +334,7 @@ class FileController
}
/**
* @remark :获取文件交接链接
* @remark :获取文件链接
* @name :getImageUrl
* @author :lyh
* @method :post
... ...
... ... @@ -46,6 +46,8 @@ class ImageController extends Controller
1 => 'image_product',
2 => 'image_news',
3 => 'image_blog',
4 => 'image_product_icon',
5 => 'image_product_cate',
0 => 'image_other',
];
... ... @@ -150,7 +152,7 @@ class ImageController extends Controller
$imageModel = new ImageModel();
$image_hash = $imageModel->read(['hash'=>$hash]);
if($image_hash !== false){
return $this->response('图片资源',Code::SUCCESS,['image'=>$hash]);
return $this->response('图片资源',Code::SUCCESS,['image'=>$hash,'image_link'=>$this->getImageUrl($hash)]);
}
$url = $this->config['root'].$this->path;
$fileName = uniqid().rand(10000,99999).'.'.$image_type;
... ... @@ -295,9 +297,10 @@ class ImageController extends Controller
*/
public function getImageList(){
$imageModel = new ImageModel();
$lists = $imageModel->list([],$order = 'id',['id','hash','type','path','created_at']);
$lists = $imageModel->list($this->param,$order = 'id',['id','hash','type','path','created_at']);
foreach ($lists as $k => $v){
$v['image_link'] = $this->getImageUrl($v['image']);
$v['image_link'] = $this->getImageUrl($v['hash']);
$lists[$k] = $v;
}
$this->response('success',Code::SUCCESS,$lists);
}
... ...
... ... @@ -60,7 +60,6 @@ class AyrReleaseLogic extends BaseLogic
$arr = [];
foreach ($data as $k => $v){
if($k == 'images'){
// $images = explode(',',$v);
$images = $v;
$imageModel = new Image();
$list = $imageModel->list(['hash'=>['in',$images]],'id');
... ...
... ... @@ -213,7 +213,6 @@ class BTemplateLogic extends BaseLogic
],
],
];
//产品,新闻,博客,一级分类数据
$productCategory = Category::where("pid",0)->get();
$newCategory = NewsCategory::where("pid",0)->get();
... ... @@ -233,7 +232,6 @@ class BTemplateLogic extends BaseLogic
$data["blogs"]["category"][] =$item;
}
}
//返回
return $this->success($data);
}
... ...
... ... @@ -178,17 +178,17 @@ class CountLogic extends BaseLogic
case 'images':
$arr = explode(',',$v['values']);
foreach ($arr as $k1 => $v1){
$v['images_link'][$k1] = url('a/image/'.$v1);
$v['images_link'][$k1] = url('b/image/'.$v1);
}
break;
case 'android':
$v['android_link'] = url('a/image/'.$v['values']);
$v['android_link'] = url('b/image/'.$v['values']);
break;
case 'official_account':
$v['official_account_link'] = url('a/image/'.$v['values']);
$v['official_account_link'] = url('b/image/'.$v['values']);
break;
case 'ios':
$v['ios_link'] = url('a/image/'.$v['values']);
$v['ios_link'] = url('b/image/'.$v['values']);
break;
}
$lists[$k] = $v;
... ...
... ... @@ -31,13 +31,14 @@ class ProductLogic extends BaseLogic
$data = parent::getList($map, $sort, $columns, $limit);
foreach ($data['list'] as &$v){
$v = $this->formatData($v);
$v['thumb']['image_link'] = $v['thumb']['url'];//图片统一
}
return $this->success($data);
}
public function getInfo($id)
{
$info = parent::getInfo($id);
$info = $this->model->read(['id'=>$id]);
$info = $this->formatData($info);
return $this->success($info);
}
... ... @@ -54,6 +55,13 @@ class ProductLogic extends BaseLogic
$info['status_text'] = Product::statusMap()[$info['status']] ?? '';
$info['created_uid_text'] = (new UserLogic())->getCacheInfo($info['created_uid'])['name'] ?? '';
$info['url'] = $this->getProjectDomain() . $info['route'] ;
//统一图片链接
if(!empty($info['gallery'])){
foreach ($info['gallery'] as $k => $v){
$v['image_link'] = $v['url'];
$info['gallery'][$k] = $v;
}
}
return $info;
}
... ...
... ... @@ -13,7 +13,6 @@ class WebSettingServiceLogic extends BaseLogic
public function __construct()
{
parent::__construct();
$this->model = new WebSettingService();
$this->param = $this->requestAll;
}
... ...
... ... @@ -9,6 +9,8 @@ use App\Exceptions\AsideGlobalException;
use App\Exceptions\BsideGlobalException;
use App\Helper\Arr;
use App\Models\Devops\ServerInformationLog;
use App\Models\File\Image;
use App\Services\CosService;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\DB;
... ... @@ -380,7 +382,33 @@ class Logic
return $this->success($info);
}
/**
* @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['images_link'][$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('b/image/'.$info['hash']);
}
}
return $url;
}
/**
* 获取实例
... ...
... ... @@ -38,16 +38,8 @@ class ProductRequest extends FormRequest
return [
'title' => 'required|max:200',
'route' => 'required|max:200',
'gallery' => ['required', 'array', function ($attribute, $value, $fail) {
foreach ($value as $v) {
if (empty($v['url'])) {
$fail('图片链接不能为空');
}
if (!Str::contains($v['url'], env('UPLOAD_LOCAL_URL') ?: env('APP_URL'))) {
$fail('图片链接不正确');
}
}
}],
'gallery' => ['required', 'array'],
'icon' => 'required|array',
'attrs' => ['array', function ($attribute, $value, $fail) {
foreach ($value as $v) {
if (empty($v['key'])) {
... ...
... ... @@ -2,6 +2,8 @@
namespace App\Models;
use App\Models\File\Image;
use App\Services\CosService;
use Illuminate\Database\Eloquent\Model;
class Base extends Model
{
... ... @@ -209,5 +211,29 @@ class Base extends Model
});
return $query;
}
/**
* @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['images_link'][$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('b/image/'.$info['hash']);
}
}
return $url;
}
}
... ...
... ... @@ -33,27 +33,49 @@ class Product extends Base
}
public function setThumbAttribute($value){
$value['url'] = Upload::url2path($value['url']);
$this->attributes['thumb'] = Arr::a2s($value);
}
public function getThumbAttribute($value){
$value = Arr::s2a($value);
$value['url'] = Upload::path2url($value['url']);
$value['url'] = $this->getImageUrl($value['url']);
return $value;
}
public function setGalleryAttribute($value){
foreach ($value as &$v){
$v['url'] = Upload::url2path($v['url']);
}
$this->attributes['gallery'] = Arr::a2s($value);
}
public function getGalleryAttribute($value){
$value = Arr::s2a($value);
foreach ($value as &$v){
$v['url'] = Upload::path2url($v['url']);
$v['url'] = $this->getImageUrl($v['url']);
}
return $value;
}
/**
* @remark :图标获取器
* @name :getGalleryAttribute
* @author :lyh
* @method :post
* @time :2023/7/21 11:11
*/
public function setIconAttribute($value){
$this->attributes['icon'] = Arr::a2s($value);
}
/**
* @remark :图标获取器
* @name :getGalleryAttribute
* @author :lyh
* @method :post
* @time :2023/7/21 11:11
*/
public function getIconAttribute($value){
$value = Arr::s2a($value);
foreach ($value as &$v){
$v = $this->getImageUrl($v);
}
return $value;
}
... ...