缩略图相关方法调整
This commit is contained in:
parent
56d486e010
commit
c32999aa03
@ -37,13 +37,4 @@ public interface FileManagerPlugin {
|
||||
*/
|
||||
void deleteFile(List<String> key);
|
||||
|
||||
/**
|
||||
* 根据原图生成规定尺寸的图片
|
||||
*
|
||||
* @param url 连接
|
||||
* @param width 宽
|
||||
* @param height 高
|
||||
* @return
|
||||
*/
|
||||
String getUrl(String url, Integer width, Integer height);
|
||||
}
|
||||
|
@ -183,11 +183,4 @@ public class AliFileManagerPlugin implements FileManagerPlugin {
|
||||
ossClient.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUrl(String url, Integer width, Integer height) {
|
||||
//缩略图全路径
|
||||
//返回缩略图全路径
|
||||
return url + "?x-oss-process=style/" + width + "X" + height;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
package cn.lili.modules.file.util;
|
||||
|
||||
/**
|
||||
* FileUtil
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2021-11-22 11:19
|
||||
*/
|
||||
public class FileUtil {
|
||||
|
||||
/**
|
||||
* 根据原图生成规定尺寸的图片
|
||||
*
|
||||
* @param url 连接
|
||||
* @param width 宽
|
||||
* @param height 高
|
||||
* @return
|
||||
*/
|
||||
public static String getUrl(String url, Integer width, Integer height) {
|
||||
//缩略图全路径
|
||||
return url + "?x-oss-process=style/" + width + "X" + height;
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
package cn.lili.modules.goods.serviceimpl;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.modules.file.plugin.FileManagerPlugin;
|
||||
import cn.lili.modules.file.util.FileUtil;
|
||||
import cn.lili.modules.goods.entity.dos.GoodsGallery;
|
||||
import cn.lili.modules.goods.mapper.GoodsGalleryMapper;
|
||||
import cn.lili.modules.goods.service.GoodsGalleryService;
|
||||
@ -29,11 +29,6 @@ import java.util.List;
|
||||
@Service
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class GoodsGalleryServiceImpl extends ServiceImpl<GoodsGalleryMapper, GoodsGallery> implements GoodsGalleryService {
|
||||
/**
|
||||
* 文件
|
||||
*/
|
||||
@Autowired
|
||||
private FileManagerPlugin fileManagerPlugin;
|
||||
/**
|
||||
* 设置
|
||||
*/
|
||||
@ -65,9 +60,9 @@ public class GoodsGalleryServiceImpl extends ServiceImpl<GoodsGalleryMapper, Goo
|
||||
Setting setting = settingService.get(SettingEnum.GOODS_SETTING.name());
|
||||
GoodsSetting goodsSetting = JSONUtil.toBean(setting.getSettingValue(), GoodsSetting.class);
|
||||
//缩略图
|
||||
String thumbnail = fileManagerPlugin.getUrl(origin, goodsSetting.getAbbreviationPictureWidth(), goodsSetting.getAbbreviationPictureHeight());
|
||||
String thumbnail = FileUtil.getUrl(origin, goodsSetting.getAbbreviationPictureWidth(), goodsSetting.getAbbreviationPictureHeight());
|
||||
//小图
|
||||
String small = fileManagerPlugin.getUrl(origin, goodsSetting.getSmallPictureWidth(), goodsSetting.getSmallPictureHeight());
|
||||
String small = FileUtil.getUrl(origin, goodsSetting.getSmallPictureWidth(), goodsSetting.getSmallPictureHeight());
|
||||
//赋值
|
||||
goodsGallery.setSmall(small);
|
||||
goodsGallery.setThumbnail(thumbnail);
|
||||
|
Loading…
x
Reference in New Issue
Block a user