下载不需要水印

This commit is contained in:
2025-07-18 14:23:22 +08:00
parent d7d503212f
commit f54595466a
4 changed files with 11 additions and 6 deletions

View File

@@ -613,7 +613,7 @@ public class GoodsServiceImpl implements GoodsService {
sourceReqQuery.setFaceId(query.getFaceId());
List<SourceRespVO> list = sourceMapper.listUser(sourceReqQuery);
if (query.getGoodsId() != null) {
list = list.stream().filter(source -> source.getId().equals(query.getGoodsId())).collect(Collectors.toList());
list = list.stream().filter(source -> source.getId().equals(query.getGoodsId())).toList();
}
if (!Integer.valueOf(2).equals(query.getSourceType())) {
return list.stream().map(source -> {
@@ -634,8 +634,8 @@ public class GoodsServiceImpl implements GoodsService {
}
return true;
}).count();
IsBuyRespVO isBuy = orderBiz.isBuy(face.getMemberId(), face.getScenicId(), query.getSourceType(), face.getId());
if (count > 0) {
IsBuyRespVO isBuy = orderBiz.isBuy(face.getMemberId(), face.getScenicId(), query.getSourceType(), face.getId());
if (!isBuy.isBuy()) {
return Collections.emptyList();
}
@@ -654,7 +654,7 @@ public class GoodsServiceImpl implements GoodsService {
log.warn("未配置小程序参数,无法生成二维码");
return defaultUrlList;
}
if (scenicConfig != null && scenicConfig.getWatermarkType() != null) {
if (scenicConfig != null && scenicConfig.getWatermarkType() != null && !isBuy.isBuy()) {
ImageWatermarkOperatorEnum type = ImageWatermarkOperatorEnum.getByCode(scenicConfig.getWatermarkType());
if (type != null) {
IStorageAdapter adapter;

View File

@@ -1,6 +1,7 @@
package com.ycwl.basic.utils;
import cn.hutool.core.codec.Base64;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.multipart.MultipartFile;
import javax.imageio.ImageIO;
@@ -12,6 +13,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@Slf4j
public class ImageUtils {
public static MultipartFile base64ToMultipartFile(String base64) {
String[] baseStrs = base64.split(",");
@@ -27,10 +29,12 @@ public class ImageUtils {
public static MultipartFile cropImage(MultipartFile file, int x, int y, int w, int h) throws IOException {
BufferedImage image = ImageIO.read(file.getInputStream());
if (image.getWidth() > w) {
log.info("图片宽高:{}", image.getWidth() + "x" + image.getHeight());
log.info("图片裁切:{}@{}", w + "x" + h, x + "," + y);
if (image.getWidth() < w) {
w = image.getWidth();
}
if (image.getHeight() > h) {
if (image.getHeight() < h) {
h = image.getHeight();
}
int targetX = x;
@@ -45,6 +49,7 @@ public class ImageUtils {
} else if ((y + h) > image.getHeight()) {
targetY = image.getHeight() - h;
}
log.info("图片实际裁切:{}@{}", w + "x" + h, targetX + "," + targetY);
BufferedImage targetImage = image.getSubimage(targetX, targetY, w, h);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(targetImage, "jpg", baos);