作者 赵彬吉

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

<?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);
}
... ...
... ... @@ -67,6 +67,7 @@ class InquiryInfoController extends BaseController
'type.required' => '类型不能为空',
]);
}
/**
* @remark :保存询盘信息
* @name :save
... ...
... ... @@ -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);
}
/**
... ...
... ... @@ -55,7 +55,7 @@ class ProductController extends BaseController
$map[] = ['status', $this->param['status']];
}
$sort = ['id' => 'desc'];
$data = $logic->getList($map, $sort, ['id', 'project_id', 'title', 'thumb', 'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at']);
$data = $logic->getList($map, $sort, ['id', 'project_id', 'title', 'thumb', 'product_type' ,'category_id', 'keyword_id', 'status', 'created_uid', 'created_at', 'updated_at']);
return $this->success($data);
}
... ...
... ... @@ -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;
}
}
... ...
... ... @@ -35,7 +35,7 @@ class FileController
public $token = '';//token
public $cache = '';//缓存数据
public $upload_location = 1;
public $upload_location = 0;
public $file_type = [
2 => 'other',//其他
1 => 'video',//视频
... ... @@ -47,8 +47,6 @@ class FileController
$this->param = $this->request->all();
$this->config = config('filesystems.disks.upload');
$this->uploads = config('upload.default_file');
$this->token = $this->request->header('token');
$this->cache = Cache::get($this->token);
}
/**
... ... @@ -77,8 +75,7 @@ class FileController
$size = $info['size'];
header("Content-Length: ".$size);
// 设置Content-Type头部
header("Content-Type: video/mp4");
// 发送完整文件
header("Content-Type: {$info['mime']}");
readfile($path);
exit;
}
... ... @@ -108,7 +105,8 @@ class FileController
} else {
$size = $files->getSize();
$file_type = $files->getClientOriginalExtension();
return $this->single($files,$size,$file_type);
$mime = $files->getMimeType();
return $this->single($files,$size,$file_type,$mime);
}
}
... ... @@ -119,7 +117,7 @@ class FileController
* @method :post
* @time :2023/6/17 16:32
*/
public function single(&$files,$size,$file_type){
public function single(&$files,$size,$file_type,$mime = ''){
$hash = hash_file('md5', $files->getPathname());
//查看文件是否存在
$fileModel = new File();
... ... @@ -139,7 +137,7 @@ class FileController
return $this->response($files->getError(), Code::USER_ERROR);
}
}
$this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location);
$this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location,$mime);
return $this->response('资源',Code::SUCCESS,$this->responseData($fileModel,$hash));
}
... ... @@ -150,7 +148,7 @@ class FileController
* @method :post
* @time :2023/7/19 16:38
*/
public function saveMysql(&$fileModel,$size,$image_type,$fileName,$hash,$is_cos = 0){
public function saveMysql(&$fileModel,$size,$image_type,$fileName,$hash,$is_cos = 0,$mime = ''){
$data = [
'path' => $this->path.'/'.$fileName,
'created_at' => date('Y-m-d H:i:s',time()),
... ... @@ -158,7 +156,8 @@ class FileController
'hash' => $hash,
'type'=>$image_type,
'refer'=>$this->param['refer'] ?? 1,
'is_cos'=>$is_cos
'is_cos'=>$is_cos,
'mime'=>$mime,
];
$rs = $fileModel->add($data);
if ($rs === false) {
... ... @@ -198,7 +197,8 @@ class FileController
}
}
$size = $file->getSize();
$this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location);
$mime = $file->getMimeType();
$this->saveMysql($fileModel,$size,$file_type,$fileName,$hash,$this->upload_location,$mime);
$data[] = $this->responseData($fileModel,$hash);
}
$this->response('资源',Code::SUCCESS,$data);
... ... @@ -269,15 +269,17 @@ class FileController
if(isset($this->param['refer_type']) && $this->param['refer_type'] == 1){
$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){
//强制上传本地配置
$this->upload_location = 0;
}else{
//获取当前登录用户详情
$this->token = $this->request->header('token');
$this->cache = Cache::get($this->token);
//B端上传,upload_method 为 1时 强制上传到本地
if(!isset($this->param['upload_method'])) {
//根据项目上传标识区分上传到cos/本地
$projectModel = new Project();
$project_info = $projectModel->read(['id'=>$this->cache['project_id']],['upload_location']);
$this->upload_location = $project_info['upload_location'];
$project_info = $projectModel->read(['id' => $this->cache['project_id']], ['project_location']);
if ($project_info['project_location'] == 0) {//不为普通项目时 上传到本地服务器
$this->upload_location = 1;//1:上传到本地
}
}
$this->path = $this->uploads['path_b'].'/'.$this->cache['project_id'].'/'.$this->file_type[$this->param['refer']].'/'.date('Y-m');
}
... ...
... ... @@ -16,17 +16,6 @@ use Intervention\Image\Facades\Image;
class ImageController extends Controller
{
public $upload_img = [
//设置静态缓存参数(304)
'header' => [
'Cache-Control' => 'max-age=2592000',
'Pragma' => 'cache',
'Expires' => "%Expires%", // cache 1 month
'etag' => "%etag%",
'Last-Modified' => "%Last-Modified%",
'Content-Description' => 'File Transfer',
],
];
public $path = '';//路径
public $config = '';//存储默认配置
... ... @@ -53,8 +42,6 @@ class ImageController extends Controller
public function __construct()
{
$this->request = request();
$this->token = $this->request->header('token');
$this->cache = Cache::get($this->token);
$this->param = $this->request->all();
$this->config = config('filesystems.disks.upload');
$this->uploads = config('upload.default_image');
... ... @@ -79,34 +66,37 @@ class ImageController extends Controller
//查看缩略图是否存在
$filename = $this->config['root'] . '/' .$info['path'] . '_' . $w . '_' . $h;
if(is_file($filename)){
$last_modified_time = gmdate(time() + ((30 * 60 * 60 * 24))) . " GMT";
$header = str_replace(['%Expires%', "%etag%", '%Last-Modified%'],
[$last_modified_time, $hash . ':' . $w . '_' . $h . '_' . 1, $last_modified_time], $this->upload_img['header']);
$content = file_get_contents($filename);
$header['Content-Length'] = strlen($content);
}else{
$path = $this->config['root'].'/'.$info['path'];
if (!is_file($path)) {
$this->response('指定图片已被系统删除!', Code::USER_ERROR);
}
$content = '';
$last_modified_time = gmdate(time() + ((30 * 60 * 60 * 24))) . " GMT";
$header = str_replace(['%Expires%', "%etag%", '%Last-Modified%'],
[$last_modified_time, $hash . ':' . $w . '_' . $h . '_' . 1, $last_modified_time], $this->upload_img['header']);
if ($w > 0 && $h > 0) {
$path = $this->cacheImage($info, $w, $h);
$content = file_get_contents($path);
$header['Content-Length'] = strlen($content);
} else {
$content = file_get_contents($path);
$header['Content-Length'] = strlen($content);
}
$content = $this->readImageContent($info,$w,$h);
$header['Content-Length'] = strlen($content);
}
$header['Content-Type'] = 'image/'.$info['type'];
$header['Content-Type'] = $info['mime'];
return response($content,200,$header);
}
/**
* @remark :缩略图不存在时获取图片
* @name :readImageContent
* @author :lyh
* @method :post
* @time :2023/7/27 9:26
*/
public function readImageContent($info,$w,$h)
{
$path = $this->config['root'] . '/' . $info['path'];
if (!is_file($path)) {
$this->response('指定图片已被系统删除!', Code::USER_ERROR);
}
if ($w > 0 && $h > 0) {
$path = $this->cacheImage($info, $w, $h);
$content = file_get_contents($path);
} else {
$content = file_get_contents($path);
}
return $content;
}
/**
* @name :(图片上传)upload
* @author :lyh
... ... @@ -130,7 +120,8 @@ class ImageController extends Controller
}else{
$size = $files->getSize();
$image_type = $files->getClientOriginalExtension();
return $this->single($files,$size,$image_type);
$mime = $files->getMimeType();
return $this->single($files,$size,$image_type,$mime);
}
}
... ... @@ -142,7 +133,7 @@ class ImageController extends Controller
* @method :post
* @time :2023/6/17 16:30
*/
public function single(&$files,$size,$image_type){
public function single(&$files,$size,$image_type,$mime){
$hash = hash_file('md5', $files->getPathname());
//查看文件是否存在
$imageModel = new ImageModel();
... ... @@ -162,7 +153,7 @@ class ImageController extends Controller
return $this->response($files->getError(), Code::USER_ERROR);
}
}
$this->saveMysql($imageModel,$size,$image_type,$fileName,$hash,$this->upload_location);
$this->saveMysql($imageModel,$size,$image_type,$fileName,$hash,$this->upload_location,$mime);
return $this->response('图片资源',Code::SUCCESS,$this->responseData($hash));
}
... ... @@ -173,7 +164,7 @@ class ImageController extends Controller
* @method :post
* @time :2023/7/19 16:38
*/
public function saveMysql(&$imageModel,$size,$image_type,$fileName,$hash,$is_cos = 0){
public function saveMysql(&$imageModel,$size,$image_type,$fileName,$hash,$is_cos = 0,$mime = ''){
$data = [
'path' => $this->path.'/'.$fileName,
'created_at' => date('Y-m-d H:i:s',time()),
... ... @@ -181,7 +172,8 @@ class ImageController extends Controller
'hash' => $hash,
'type'=>$image_type,
'refer'=>$this->param['refer'] ?? 1,
'is_cos'=>$is_cos
'is_cos'=>$is_cos,
'mime'=>$mime
];
$rs = $imageModel->add($data);
if ($rs === false) {
... ... @@ -219,6 +211,7 @@ class ImageController extends Controller
foreach ($files as $file) {
$size = $file->getSize();
$image_type = $file->getClientOriginalExtension();
$mime = $file->getMimeType();
$imageModel = new ImageModel();
$hash = hash_file('md5', $file->getPathname());
$image_hash = $imageModel->read(['hash'=>$hash]);
... ... @@ -239,7 +232,7 @@ class ImageController extends Controller
}
}
//批量存储
$this->saveMysql($imageModel,$size,$image_type,$fileName,$hash,$this->upload_location);
$this->saveMysql($imageModel,$size,$image_type,$fileName,$hash,$this->upload_location,$mime);
$data[] = $this->responseData($hash);
}
$this->response('图片资源',Code::SUCCESS,$data);
... ... @@ -309,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);
... ... @@ -328,39 +321,21 @@ class ImageController extends Controller
$this->path = $this->uploads['path_a'].'/'.$this->image_type[$this->param['refer']].'/'.date('Y-m');
}else{
//B端上传
if(isset($this->param['upload_method']) && $this->param['upload_method'] == 1){
//强制上传本地配置
$this->upload_location = 0;
}else{
$this->token = $this->request->header('token');
$this->cache = Cache::get($this->token);
if(!isset($this->param['upload_method'])){
//根据项目上传标识区分上传到cos/本地
$projectModel = new Project();
$project_info = $projectModel->read(['id'=>$this->cache['project_id']],['upload_location']);
$this->upload_location = $project_info['upload_location'];
if ($project_info['project_location'] == 0) {//不为普通项目时 上传到本地服务器
$this->upload_location = 1;//上传到cos
}
}
$this->path = $this->uploads['path_b'].'/'.$this->cache['project_id'].'/'.$this->image_type[$this->param['refer']].'/'.date('Y-m');
}
}
/**
* @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
... ... @@ -370,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;
... ...
... ... @@ -8,8 +8,6 @@ use App\Models\Manage\BelongingGroup;
use App\Models\Manage\EntryPosition;
use App\Models\Manage\JobLevel;
use App\Models\Manage\ManageHr;
use Illuminate\Support\Facades\Log;
/**
* Class ManageHrLogic
... ... @@ -38,11 +36,9 @@ class HrLogic extends BaseLogic
}
public function save($param){
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($param, true) . PHP_EOL, FILE_APPEND);
foreach ($this->model::specieField() as $v){
$param = $this->setJson($v,$param);
}
@file_put_contents(storage_path('logs/lyh_error.log'), var_export($param, true) . PHP_EOL, FILE_APPEND);
return parent::save($param);
}
... ...
... ... @@ -154,7 +154,6 @@ class InquiryInfoLogic extends BaseLogic
$arr_url = explode(',',$param['forward_url']);
foreach ($arr_url as $v){
$data['url'] = $v;
@file_put_contents(storage_path('logs/lyh_error.log'), var_export(json_encode($data).'debug---------------33333333333', true) . PHP_EOL, FILE_APPEND);
$this->inquiryForward($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);
... ... @@ -125,7 +125,7 @@ class BTemplateLogic extends BaseLogic
$this->fail('请先装修首页');
}
$html = preg_replace('/<style id="vvvebjs-styles">(.*?)<\/style>/s', "<style id='vvvebjs-styles'></style>", $homeTemplateInfo['html']);
$html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', "<main></main>", $html);
$html = preg_replace('/<main\b[^>]*>(.*?)<\/main>/s', "<main>{$this->getProductModule()}</main>", $html);
}else{
$homeTemplateInfo = $this->webTemplateInfo($info['template_id'],1,0);
if($homeTemplateInfo === false){
... ... @@ -338,4 +338,18 @@ class BTemplateLogic extends BaseLogic
//返回
return $this->success($data);
}
/**
* @remark :默认产品模块
* @name :getProductModule
* @author :lyh
* @method :post
* @time :2023/7/27 15:08
*/
public function getProductModule(){
//获取公共主题头部底部
$serviceSettingModel = new ServiceSettingModel();
$info = $serviceSettingModel->read(['type'=>3]);
return $info['values'];
}
}
... ...
... ... @@ -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);
}
... ... @@ -58,6 +58,7 @@ class ProductLogic extends BaseLogic
foreach ($info['keyword_id'] as $keyword_id){
$info['keyword_id_text'][] =(new KeywordLogic())->getCacheInfo($keyword_id)['title']??'';
}
$info['product_type_text'] = $this->model->productType[$info['product_type']];
$info['category_id_text'] = Arr::arrToSet($info['category_id_text'], 'trim');
$info['keyword_id_text'] = Arr::arrToSet($info['keyword_id_text'], 'trim');
$info['status_text'] = Product::statusMap()[$info['status']] ?? '';
... ...
... ... @@ -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
... ...
... ... @@ -32,6 +32,15 @@ class Product extends Base
];
}
/**
* @var 获取产品类型
*/
public $productType = [
1=>'一般产品',
2=>'推荐产品',
3=>'热销产品'
];
public function setThumbAttribute($value){
$this->attributes['thumb'] = Arr::a2s($value);
}
... ...
... ... @@ -4,7 +4,7 @@ namespace App\Services;
use Qcloud\Cos\Client;
/**
* @remark :
* @remark :对象存储cos
* @class :CosService.php
* @author :lyh
* @time :2023/7/19 15:09
... ... @@ -60,5 +60,5 @@ class CosService
$imageUrl = $cosClient->getObjectUrl($cos['bucket'], trim($image_name,'/'), '+10 years');
return $imageUrl;
}
}
... ...