fix: 字典编码、存储编码及类型、菜单类型不允许修改

This commit is contained in:
2024-05-15 23:37:48 +08:00
parent 90ecaab632
commit 79d0101e5e
3 changed files with 6 additions and 8 deletions

View File

@@ -55,12 +55,8 @@ public class DictServiceImpl extends BaseServiceImpl<DictMapper, DictDO, DictRes
protected void beforeUpdate(DictReq req, Long id) {
String name = req.getName();
CheckUtils.throwIf(this.isNameExists(name, id), "修改失败,[{}] 已存在", name);
String code = req.getCode();
CheckUtils.throwIf(this.isCodeExists(code, id), "修改失败,[{}] 已存在", code);
DictDO oldDict = super.getById(id);
if (Boolean.TRUE.equals(oldDict.getIsSystem())) {
CheckUtils.throwIfNotEqual(req.getCode(), oldDict.getCode(), "[{}] 是系统内置字典,不允许修改字典编码", oldDict.getName());
}
CheckUtils.throwIfNotEqual(req.getCode(), oldDict.getCode(), "不允许修改字典编码");
}
@Override

View File

@@ -65,6 +65,8 @@ public class MenuServiceImpl extends BaseServiceImpl<MenuMapper, MenuDO, MenuRes
public void update(MenuReq req, Long id) {
String title = req.getTitle();
CheckUtils.throwIf(this.isNameExists(title, req.getParentId(), id), "修改失败,[{}] 已存在", title);
MenuDO oldMenu = super.getById(id);
CheckUtils.throwIfNotEqual(req.getType(), oldMenu.getType(), "不允许修改菜单类型");
super.update(req, id);
}

View File

@@ -74,10 +74,10 @@ public class StorageServiceImpl extends BaseServiceImpl<StorageMapper, StorageDO
@Override
protected void beforeUpdate(StorageReq req, Long id) {
String code = req.getCode();
CheckUtils.throwIf(this.isCodeExists(code, id), "修改失败,[{}] 已存在", code);
DisEnableStatusEnum newStatus = req.getStatus();
StorageDO oldStorage = super.getById(id);
CheckUtils.throwIfNotEqual(req.getCode(), oldStorage.getCode(), "不允许修改存储编码");
CheckUtils.throwIfNotEqual(req.getType(), oldStorage.getType(), "不允许修改存储类型");
DisEnableStatusEnum newStatus = req.getStatus();
CheckUtils.throwIf(Boolean.TRUE.equals(oldStorage.getIsDefault()) && DisEnableStatusEnum.DISABLE
.equals(newStatus), "[{}] 是默认存储,不允许禁用", oldStorage.getName());
this.decodeSecretKey(req, oldStorage);