this is 3.24 update
This commit is contained in:
parent
10cc960fb9
commit
9bcddcf515
|
@ -31,15 +31,11 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.coobird.thumbnailator.Thumbnails;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
@ -158,27 +154,27 @@ public class WeChatLogisticsController {
|
|||
for (OrderItems orderItems : orderItemsList) {
|
||||
GoodSnapshot goodSnapshot = orderItems.getGoodSnapshot();
|
||||
String name = goodSnapshot.getName();
|
||||
String goodImg = goodSnapshot.getGoodImg();
|
||||
String[] imgArr = goodImg.split(";");
|
||||
String imgUrl = FileConstant.SERVER_HOST + imgArr[0];
|
||||
String filePath = null;
|
||||
try {
|
||||
URL url = new URL(imgUrl);
|
||||
// 压缩图片到目标质量并返回InputStream
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
Thumbnails.of(url)
|
||||
// .scale(0.2f)
|
||||
.size(70, 70) // 设定压缩后的图片大小
|
||||
.outputQuality(1) // 设置压缩质量
|
||||
.toOutputStream(outputStream);
|
||||
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(outputStream.toByteArray());
|
||||
filePath = RandomStringUtils.randomAlphabetic(16) + ".png";
|
||||
iHweiYunOBSService.fileUpload(byteArrayInputStream, filePath);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// String goodImg = goodSnapshot.getGoodImg();
|
||||
// String[] imgArr = goodImg.split(";");
|
||||
// String imgUrl = FileConstant.SERVER_HOST + imgArr[0];
|
||||
// String filePath = null;
|
||||
// try {
|
||||
// URL url = new URL(imgUrl);
|
||||
// // 压缩图片到目标质量并返回InputStream
|
||||
// ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
// Thumbnails.of(url)
|
||||
//// .scale(0.2f)
|
||||
// .size(70, 70) // 设定压缩后的图片大小
|
||||
// .outputQuality(1) // 设置压缩质量
|
||||
// .toOutputStream(outputStream);
|
||||
// ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(outputStream.toByteArray());
|
||||
// filePath = RandomStringUtils.randomAlphabetic(16) + ".png";
|
||||
// iHweiYunOBSService.fileUpload(byteArrayInputStream, filePath);
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
String resultUrl = FileConstant.SERVER_HOST + filePath;
|
||||
String resultUrl = FileConstant.SERVER_HOST + RandomStringUtils.randomAlphabetic(8) + ".png";
|
||||
GoodLogisticsInfoVO goodLogisticsInfoVO = GoodLogisticsInfoVO.builder().goods_name(name).goods_img_url(resultUrl).build();
|
||||
goodLogisticsInfoVOS.add(goodLogisticsInfoVO);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user