From 74c4270323782f37947214c43024258831a26006 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Thu, 13 Mar 2025 21:13:38 +0800 Subject: [PATCH] =?UTF-8?q?refactor(system/file):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=9B=B8=E5=85=B3=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/constant/SysFileConstants.java | 48 ------------------- .../FileInfoContainer.java | 11 ++++- .../admin/system/service/FileService.java | 17 ++++++- .../system/service/impl/UserServiceImpl.java | 20 +++++--- .../main/resources/config/application-dev.yml | 5 +- .../resources/config/application-prod.yml | 5 +- 6 files changed, 46 insertions(+), 60 deletions(-) delete mode 100644 continew-common/src/main/java/top/continew/admin/common/constant/SysFileConstants.java rename continew-module-system/src/main/java/top/continew/admin/system/config/{container => file}/FileInfoContainer.java (90%) diff --git a/continew-common/src/main/java/top/continew/admin/common/constant/SysFileConstants.java b/continew-common/src/main/java/top/continew/admin/common/constant/SysFileConstants.java deleted file mode 100644 index 50973481..00000000 --- a/continew-common/src/main/java/top/continew/admin/common/constant/SysFileConstants.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package top.continew.admin.common.constant; - -import top.continew.starter.core.constant.StringConstants; - -import java.time.LocalDate; - -/** - * 系统文件相关常量 - * - * @author luoqiz - * @since 2025/3/12 18:11 - */ -public class SysFileConstants { - - /** - * 用户头像路径前缀 - */ - public static final String USER_AVATAR_PATH = "user/avatar/"; - - /** - * 默认文件路径 - */ - public static String getDefaultFilePath() { - LocalDate today = LocalDate.now(); - String path = today.getYear() + StringConstants.SLASH + today.getMonthValue() + StringConstants.SLASH + today - .getDayOfMonth() + StringConstants.SLASH; - return path; - } - - private SysFileConstants() { - } -} diff --git a/continew-module-system/src/main/java/top/continew/admin/system/config/container/FileInfoContainer.java b/continew-module-system/src/main/java/top/continew/admin/system/config/file/FileInfoContainer.java similarity index 90% rename from continew-module-system/src/main/java/top/continew/admin/system/config/container/FileInfoContainer.java rename to continew-module-system/src/main/java/top/continew/admin/system/config/file/FileInfoContainer.java index e74322c3..80421f5f 100644 --- a/continew-module-system/src/main/java/top/continew/admin/system/config/container/FileInfoContainer.java +++ b/continew-module-system/src/main/java/top/continew/admin/system/config/file/FileInfoContainer.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package top.continew.admin.system.config.container; +package top.continew.admin.system.config.file; import cn.crane4j.core.container.Container; import lombok.RequiredArgsConstructor; @@ -29,19 +29,26 @@ import java.util.Map; import java.util.function.Function; import java.util.stream.Collectors; +/** + * 文件信息填充容器 + * + * @author luoqiz + * @since 2025/3/12 18:11 + */ @Component @RequiredArgsConstructor public class FileInfoContainer implements Container { private final FileService fileService; + @Override public String getNamespace() { return ContainerConstants.FILE_INFO; } + @Override public Map get(Collection ids) { List list = fileService.listByIds(ids); return list.stream().collect(Collectors.toMap(FileDO::getId, Function.identity())); } - } \ No newline at end of file diff --git a/continew-module-system/src/main/java/top/continew/admin/system/service/FileService.java b/continew-module-system/src/main/java/top/continew/admin/system/service/FileService.java index fcc22619..3486d76e 100644 --- a/continew-module-system/src/main/java/top/continew/admin/system/service/FileService.java +++ b/continew-module-system/src/main/java/top/continew/admin/system/service/FileService.java @@ -18,15 +18,16 @@ package top.continew.admin.system.service; import org.dromara.x.file.storage.core.FileInfo; import org.springframework.web.multipart.MultipartFile; -import top.continew.admin.common.constant.SysFileConstants; import top.continew.admin.system.model.entity.FileDO; import top.continew.admin.system.model.query.FileQuery; import top.continew.admin.system.model.req.FileReq; import top.continew.admin.system.model.resp.file.FileResp; import top.continew.admin.system.model.resp.file.FileStatisticsResp; +import top.continew.starter.core.constant.StringConstants; import top.continew.starter.data.mp.service.IService; import top.continew.starter.extension.crud.service.BaseService; +import java.time.LocalDate; import java.util.List; /** @@ -44,13 +45,14 @@ public interface FileService extends BaseService page(UserQuery query, PageQuery pageQuery) { @@ -389,11 +390,18 @@ public class UserServiceImpl extends BaseServiceImpl