this is 3.24 update

This commit is contained in:
chen-xin-zhi 2025-03-27 11:02:08 +08:00
parent 10cc960fb9
commit 9bcddcf515

View File

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