mirror of https://gitee.com/stylefeng/roses
【8.3.0】【file】更新获取文件存储的配置
parent
bddc093197
commit
72e14614bd
|
@ -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<StorageConfig> getFileConfig() {
|
||||
StorageConfig storageConfig = newConfigService.getStorageConfig();
|
||||
return new SuccessResponseData<>(storageConfig);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -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-本地,存储到指定路径下(需要配置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;
|
||||
|
||||
}
|
|
@ -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();
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue