diff --git a/snowy-plugin-api/snowy-plugin-dev-api/src/main/java/vip/xiaonuo/dev/api/DevFileApi.java b/snowy-plugin-api/snowy-plugin-dev-api/src/main/java/vip/xiaonuo/dev/api/DevFileApi.java index 06a2b6c9..991339f9 100644 --- a/snowy-plugin-api/snowy-plugin-dev-api/src/main/java/vip/xiaonuo/dev/api/DevFileApi.java +++ b/snowy-plugin-api/snowy-plugin-dev-api/src/main/java/vip/xiaonuo/dev/api/DevFileApi.java @@ -12,6 +12,7 @@ */ package vip.xiaonuo.dev.api; +import cn.hutool.json.JSONObject; import org.springframework.web.multipart.MultipartFile; /** @@ -101,4 +102,12 @@ public interface DevFileApi { * @date 2022/6/22 17:44 **/ String storageFileWithReturnIdMinio(MultipartFile file); + + /** + * 通过文件id查询文件详情 + * + * @author chengchuanyao + * @date 2024/7/26 16:10 + */ + JSONObject getFileInfoById(String id); } diff --git a/snowy-plugin/snowy-plugin-dev/src/main/java/vip/xiaonuo/dev/modular/file/provider/DevFileApiProvider.java b/snowy-plugin/snowy-plugin-dev/src/main/java/vip/xiaonuo/dev/modular/file/provider/DevFileApiProvider.java index 6ced3a09..20efcec8 100644 --- a/snowy-plugin/snowy-plugin-dev/src/main/java/vip/xiaonuo/dev/modular/file/provider/DevFileApiProvider.java +++ b/snowy-plugin/snowy-plugin-dev/src/main/java/vip/xiaonuo/dev/modular/file/provider/DevFileApiProvider.java @@ -12,6 +12,8 @@ */ package vip.xiaonuo.dev.modular.file.provider; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; import jakarta.annotation.Resource; import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; @@ -19,6 +21,8 @@ import vip.xiaonuo.dev.api.DevFileApi; import vip.xiaonuo.dev.modular.file.enums.DevFileEngineTypeEnum; import vip.xiaonuo.dev.modular.file.service.DevFileService; +import java.util.Optional; + /** * 文件API接口提供者 * @@ -70,4 +74,11 @@ public class DevFileApiProvider implements DevFileApi { public String storageFileWithReturnIdMinio(MultipartFile file) { return devFileService.uploadReturnId(DevFileEngineTypeEnum.MINIO.getValue(), file); } + + @Override + public JSONObject getFileInfoById(String id) { + return Optional.ofNullable(devFileService.getById(id)) + .map(JSONUtil::parseObj) + .orElse(new JSONObject()); + } }