use of com.orion.ops.entity.domain.HistoryValueSnapshotDO 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:
}
}
use of com.orion.ops.entity.domain.HistoryValueSnapshotDO in project orion-ops by lijiahangmax.
the class HistoryValueServiceImpl method addHistory.
@Override
public void addHistory(Long valueId, HistoryValueType valueType, HistoryOperator operatorType, String beforeValue, String afterValue) {
UserDTO user = Currents.getUser();
HistoryValueSnapshotDO insert = new HistoryValueSnapshotDO();
insert.setValueId(valueId);
insert.setOperatorType(operatorType.getType());
insert.setValueType(valueType.getType());
insert.setBeforeValue(beforeValue);
insert.setAfterValue(afterValue);
if (user != null) {
insert.setUpdateUserId(user.getId());
insert.setUpdateUserName(user.getUsername());
}
insert.setCreateTime(new Date());
insert.setUpdateTime(new Date());
historyValueSnapshotDAO.insert(insert);
}
Aggregations