mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-10-31 10:57:13 +08:00 
			
		
		
		
	fix(system/storage): 增加设置默认存储前的状态检查
This commit is contained in:
		| @@ -32,13 +32,13 @@ import java.io.Serial; | ||||
| import java.io.Serializable; | ||||
|  | ||||
| /** | ||||
|  * 存储请求参数 | ||||
|  * 创建或修改存储参数 | ||||
|  * | ||||
|  * @author Charles7c | ||||
|  * @since 2023/12/26 22:09 | ||||
|  */ | ||||
| @Data | ||||
| @Schema(description = "存储请求参数") | ||||
| @Schema(description = "创建或修改存储参数") | ||||
| public class StorageReq implements Serializable { | ||||
|  | ||||
|     @Serial | ||||
|   | ||||
| @@ -26,13 +26,13 @@ import top.continew.starter.security.mask.annotation.JsonMask; | ||||
| import java.io.Serial; | ||||
|  | ||||
| /** | ||||
|  * 存储响应信息 | ||||
|  * 存储信息 | ||||
|  * | ||||
|  * @author Charles7c | ||||
|  * @since 2023/12/26 22:09 | ||||
|  */ | ||||
| @Data | ||||
| @Schema(description = "存储响应信息") | ||||
| @Schema(description = "存储信息") | ||||
| public class StorageResp extends BaseDetailResp { | ||||
|  | ||||
|     @Serial | ||||
|   | ||||
| @@ -87,10 +87,9 @@ public class StorageServiceImpl extends BaseServiceImpl<StorageMapper, StorageDO | ||||
|         DisEnableStatusEnum newStatus = req.getStatus(); | ||||
|         CheckUtils.throwIf(Boolean.TRUE.equals(oldStorage.getIsDefault()) && DisEnableStatusEnum.DISABLE | ||||
|             .equals(newStatus), "[{}] 是默认存储,不允许禁用", oldStorage.getName()); | ||||
|         // 重新加载存储引擎 | ||||
|         DisEnableStatusEnum oldStatus = oldStorage.getStatus(); | ||||
|         // 重新加载配置 | ||||
|         // 先卸载 | ||||
|         if (DisEnableStatusEnum.ENABLE.equals(oldStatus)) { | ||||
|         if (fileStorageService.getFileStorage(req.getCode()) != null) { | ||||
|             this.unload(BeanUtil.copyProperties(oldStorage, StorageReq.class)); | ||||
|         } | ||||
|         // 再加载 | ||||
| @@ -145,6 +144,8 @@ public class StorageServiceImpl extends BaseServiceImpl<StorageMapper, StorageDO | ||||
|         if (Boolean.TRUE.equals(storage.getIsDefault())) { | ||||
|             return; | ||||
|         } | ||||
|         // 启用状态才能设为默认存储 | ||||
|         CheckUtils.throwIfNotEqual(DisEnableStatusEnum.ENABLE, storage.getStatus(), "请先启用所选存储"); | ||||
|         baseMapper.lambdaUpdate().eq(StorageDO::getIsDefault, true).set(StorageDO::getIsDefault, false).update(); | ||||
|         baseMapper.lambdaUpdate().eq(StorageDO::getId, id).set(StorageDO::getIsDefault, true).update(); | ||||
|     } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user