From 72e14614bd7c054292f6de0f6ac2ab22284d2083 Mon Sep 17 00:00:00 2001 From: stylefeng Date: Sat, 31 Aug 2024 17:59:54 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=908.3.0=E3=80=91=E3=80=90file=E3=80=91?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=8E=B7=E5=8F=96=E6=96=87=E4=BB=B6=E5=AD=98?= =?UTF-8?q?=E5=82=A8=E7=9A=84=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/NewFileConfigController.java | 63 +++++++++++++++++++ .../modular/pojo/newconfig/StorageConfig.java | 34 ++++++++++ .../modular/service/NewConfigService.java | 45 +++++++++++++ .../service/impl/NewConfigServiceImpl.java | 44 +++++++++++++ 4 files changed, 186 insertions(+) create mode 100644 kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/controller/NewFileConfigController.java create mode 100644 kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/pojo/newconfig/StorageConfig.java create mode 100644 kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/service/NewConfigService.java create mode 100644 kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/service/impl/NewConfigServiceImpl.java diff --git a/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/controller/NewFileConfigController.java b/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/controller/NewFileConfigController.java new file mode 100644 index 000000000..e5103e637 --- /dev/null +++ b/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/controller/NewFileConfigController.java @@ -0,0 +1,63 @@ +/* + * Copyright [2020-2030] [https://www.stylefeng.cn] + * + * 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. + * + * Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: + * + * 1.请不要删除和修改根目录下的LICENSE文件。 + * 2.请不要删除和修改Guns源码头部的版权声明。 + * 3.请保留源码和相关描述文件的项目出处,作者声明等。 + * 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns + * 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns + * 6.若您的项目无法满足以上几点,可申请商业授权 + */ +package cn.stylefeng.roses.kernel.config.modular.controller; + +import cn.stylefeng.roses.kernel.config.modular.pojo.newconfig.StorageConfig; +import cn.stylefeng.roses.kernel.config.modular.service.NewConfigService; +import cn.stylefeng.roses.kernel.rule.pojo.response.ResponseData; +import cn.stylefeng.roses.kernel.rule.pojo.response.SuccessResponseData; +import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource; +import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource; +import jakarta.annotation.Resource; +import org.springframework.web.bind.annotation.RestController; + +/** + * 新配置设置-文件存储配置 + * + * @author fengshuonan + * @since 2024/8/31 16:34 + */ +@RestController +@ApiResource(name = "新配置设置-文件存储配置", requiredPermission = true, requirePermissionCode = SysConfigTypeController.SYS_CONFIG) +public class NewFileConfigController { + + @Resource + private NewConfigService newConfigService; + + /** + * 获取文件存储配置 + * + * @author fengshuonan + * @since 2024/8/31 17:05 + */ + @GetResource(name = "获取文件存储配置", path = "/new/sysConfig/getFileConfig") + public ResponseData getFileConfig() { + StorageConfig storageConfig = newConfigService.getStorageConfig(); + return new SuccessResponseData<>(storageConfig); + } + +} + + diff --git a/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/pojo/newconfig/StorageConfig.java b/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/pojo/newconfig/StorageConfig.java new file mode 100644 index 000000000..86ece673d --- /dev/null +++ b/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/pojo/newconfig/StorageConfig.java @@ -0,0 +1,34 @@ +package cn.stylefeng.roses.kernel.config.modular.pojo.newconfig; + +import cn.stylefeng.roses.kernel.rule.annotation.ChineseDescription; +import lombok.Data; + +/** + * 文件存储的配置 + * + * @author fengshuonan + * @since 2024/8/31 17:02 + */ +@Data +public class StorageConfig { + + /** + * 文件存储类型的配置 + *

+ * 10-本地,存储到默认路径(jar所在目录) + * 11-本地,存储到指定路径下(需要配置linux和windows的路径) + * 20-存储到MinIO + * 30-存储到阿里云 + * 40-存储到腾讯云 + * 50-存储到青云 + */ + @ChineseDescription("文件存储类型的配置:10-本地,存储到默认路径(jar所在目录),11-本地,存储到指定路径下(需要配置linux和windows的路径),20-存储到MinIO,30-存储到阿里云,40-存储到腾讯云,50-存储到青云") + private Integer fileSaveType; + + /** + * 本地存储路径 + */ + @ChineseDescription("本地存储路径") + private String localFileSavePath; + +} diff --git a/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/service/NewConfigService.java b/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/service/NewConfigService.java new file mode 100644 index 000000000..2f69a6510 --- /dev/null +++ b/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/service/NewConfigService.java @@ -0,0 +1,45 @@ +/* + * Copyright [2020-2030] [https://www.stylefeng.cn] + * + * 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. + * + * Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点: + * + * 1.请不要删除和修改根目录下的LICENSE文件。 + * 2.请不要删除和修改Guns源码头部的版权声明。 + * 3.请保留源码和相关描述文件的项目出处,作者声明等。 + * 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns + * 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns + * 6.若您的项目无法满足以上几点,可申请商业授权 + */ +package cn.stylefeng.roses.kernel.config.modular.service; + +import cn.stylefeng.roses.kernel.config.modular.pojo.newconfig.StorageConfig; + +/** + * 新的系统配置业务 + * + * @author fengshuonan + * @since 2024/8/31 17:00 + */ +public interface NewConfigService { + + /** + * 获取文件存储的配置 + * + * @author fengshuonan + * @since 2024/8/31 17:05 + */ + StorageConfig getStorageConfig(); + +} diff --git a/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/service/impl/NewConfigServiceImpl.java b/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/service/impl/NewConfigServiceImpl.java new file mode 100644 index 000000000..f15eab4ce --- /dev/null +++ b/kernel-d-config/config-business/src/main/java/cn/stylefeng/roses/kernel/config/modular/service/impl/NewConfigServiceImpl.java @@ -0,0 +1,44 @@ +package cn.stylefeng.roses.kernel.config.modular.service.impl; + +import cn.hutool.system.SystemUtil; +import cn.stylefeng.roses.kernel.config.api.constants.ConfigConstants; +import cn.stylefeng.roses.kernel.config.modular.pojo.newconfig.StorageConfig; +import cn.stylefeng.roses.kernel.config.modular.service.NewConfigService; +import cn.stylefeng.roses.kernel.config.modular.service.SysConfigService; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Service; + +/** + * 新版的配置业务 + * + * @author fengshuonan + * @since 2024/8/31 17:05 + */ +@Service +public class NewConfigServiceImpl implements NewConfigService { + + @Resource + private SysConfigService sysConfigService; + + @Override + public StorageConfig getStorageConfig() { + + StorageConfig storageConfig = new StorageConfig(); + + // 文件存储类型 + String fileSaveType = sysConfigService.getConfigValueByCode(ConfigConstants.SYS_FILE_SAVE_TYPE_CONFIG_CODE); + storageConfig.setFileSaveType(Integer.valueOf(fileSaveType)); + + // 本地文件存储路径 + if (SystemUtil.getOsInfo().isWindows()) { + String windowsPath = sysConfigService.getConfigValueByCode(ConfigConstants.SYS_LOCAL_FILE_SAVE_PATH_WINDOWS); + storageConfig.setLocalFileSavePath(windowsPath); + } else { + String linuxPath = sysConfigService.getConfigValueByCode(ConfigConstants.SYS_LOCAL_FILE_SAVE_PATH_LINUX); + storageConfig.setLocalFileSavePath(linuxPath); + } + + return storageConfig; + } + +}