Skip to content

Commit

Permalink
fix: 修复修改存储时同时设置默认存储及启用判断顺序错误
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Sep 24, 2024
1 parent ad69d44 commit d9602e8
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ protected void beforeUpdate(StorageReq req, Long id) {
.equals(newStatus), "[{}] 是默认存储,不允许禁用", oldStorage.getName());
this.decodeSecretKey(req, oldStorage);
DisEnableStatusEnum oldStatus = oldStorage.getStatus();
if (Boolean.TRUE.equals(req.getIsDefault())) {
CheckUtils.throwIf(this.isDefaultExists(id), "请先取消原有默认存储");
CheckUtils.throwIf(!DisEnableStatusEnum.ENABLE.equals(oldStatus) && !DisEnableStatusEnum.ENABLE
.equals(newStatus), "请先启用该存储");
}
// 先卸载
if (DisEnableStatusEnum.ENABLE.equals(oldStatus)) {
this.unload(BeanUtil.copyProperties(oldStorage, StorageReq.class));
Expand All @@ -91,10 +96,6 @@ protected void beforeUpdate(StorageReq req, Long id) {
if (DisEnableStatusEnum.ENABLE.equals(newStatus)) {
this.load(req);
}
if (Boolean.TRUE.equals(req.getIsDefault())) {
CheckUtils.throwIf(!DisEnableStatusEnum.ENABLE.equals(oldStatus), "请先启用该存储");
CheckUtils.throwIf(this.isDefaultExists(id), "请先取消原有默认存储");
}
}

@Override
Expand Down

0 comments on commit d9602e8

Please sign in to comment.