use of com.orion.ops.consts.history.HistoryOperator in project orion-ops by lijiahangmax.
the class HistoryValueServiceImpl method rollback.
@Override
public void rollback(Long id) {
HistoryValueSnapshotDO historyValue = historyValueSnapshotDAO.selectById(id);
Valid.notNull(historyValue, MessageConst.HISTORY_VALUE_ABSENT);
// 设置修改值
HistoryOperator operator = HistoryOperator.of(historyValue.getOperatorType());
String updateValue;
switch(operator) {
case ADD:
updateValue = historyValue.getAfterValue();
break;
case UPDATE:
case DELETE:
default:
updateValue = historyValue.getBeforeValue();
}
// 修改值
Long valueId = historyValue.getValueId();
HistoryValueType valueType = HistoryValueType.of(historyValue.getValueType());
switch(valueType) {
case MACHINE_ENV:
MachineEnvRequest machineEnvRequest = new MachineEnvRequest();
machineEnvRequest.setId(valueId);
machineEnvRequest.setValue(updateValue);
machineEnvService.updateEnv(machineEnvRequest);
return;
case APP_ENV:
ApplicationEnvRequest appEnvRequest = new ApplicationEnvRequest();
appEnvRequest.setId(valueId);
appEnvRequest.setValue(updateValue);
applicationEnvService.updateAppEnv(appEnvRequest);
return;
case SYSTEM_ENV:
SystemEnvRequest systemRequest = new SystemEnvRequest();
systemRequest.setId(valueId);
systemRequest.setValue(updateValue);
systemEnvService.updateEnv(systemRequest);
return;
default:
}
}
Aggregations