From 655779b28999427b38b32577bdb942505fd15669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=9D=E8=A1=B7?= <2370392733@qq.com> Date: Tue, 27 Aug 2024 10:17:50 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=80=9A=E8=BF=87=E6=96=87=E4=BB=B6id=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=96=87=E4=BB=B6=E8=AF=A6=E6=83=85=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/vip/xiaonuo/dev/api/DevFileApi.java | 9 +++++++++ .../dev/modular/file/provider/DevFileApiProvider.java | 11 +++++++++++ 2 files changed, 20 insertions(+) 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()); + } }