【8.3.0】【file】更新获取文件存储的配置

master
stylefeng 2024-08-31 17:59:54 +08:00
parent bddc093197
commit 72e14614bd
4 changed files with 186 additions and 0 deletions

View File

@ -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.
*
* GunsAPACHE 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<StorageConfig> getFileConfig() {
StorageConfig storageConfig = newConfigService.getStorageConfig();
return new SuccessResponseData<>(storageConfig);
}
}

View File

@ -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 {
/**
*
* <p>
* 10-jar
* 11-linuxwindows
* 20-MinIO
* 30-
* 40-
* 50-
*/
@ChineseDescription("文件存储类型的配置10-本地存储到默认路径jar所在目录11-本地存储到指定路径下需要配置linux和windows的路径20-存储到MinIO30-存储到阿里云40-存储到腾讯云50-存储到青云")
private Integer fileSaveType;
/**
*
*/
@ChineseDescription("本地存储路径")
private String localFileSavePath;
}

View File

@ -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.
*
* GunsAPACHE 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();
}

View File

@ -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;
}
}