From 18813ca83b94c807e35756a8a5f52effa5b99ba8 Mon Sep 17 00:00:00 2001 From: zepengdev <lzpsmith@outlook.com> Date: Tue, 17 Jun 2025 16:00:42 +0800 Subject: [PATCH] feat(product): 新增商品批量查询接口 --- oying-system/src/main/java/com/oying/modules/pc/utils/ImageUtils.java | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-) diff --git a/oying-system/src/main/java/com/oying/modules/pc/utils/ImageUtils.java b/oying-system/src/main/java/com/oying/modules/pc/utils/ImageUtils.java new file mode 100644 index 0000000..5593278 --- /dev/null +++ b/oying-system/src/main/java/com/oying/modules/pc/utils/ImageUtils.java @@ -0,0 +1,31 @@ +package com.oying.modules.pc.utils; + +import com.oying.domain.BucketStorage; +import com.oying.exception.EntityNotFoundException; +import com.oying.service.BucketStorageService; +import com.oying.utils.ObsProperties; +import com.oying.utils.ObsUtils; +import com.oying.utils.SpringBeanHolder; + +import java.util.Optional; + +public class ImageUtils { + + private final static ObsProperties properties = SpringBeanHolder.getBean(ObsProperties.class); + private final static BucketStorageService bucketStorageService = SpringBeanHolder.getBean(BucketStorageService.class); + + public static String getPublicObjectUrl(String path) { + return ObsUtils.getPublicObjectUrl(properties, path); + } + + public static String getPublicObjectUrl(Long storageId) { + return Optional.ofNullable(storageId).map(v -> { + BucketStorage bucketStorage = bucketStorageService.getById(storageId); + String path = Optional.ofNullable(bucketStorage) + .map(BucketStorage::getPath) + .orElseThrow(() -> new EntityNotFoundException(BucketStorage.class, "bucketStorageId", storageId.toString())); + return getPublicObjectUrl(path); + }).orElse(null); + } + +} -- Gitblit v1.9.3