Search in sources :

Example 1 with HistoryValueSnapshotDO

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:
    }
}
Also used : ApplicationEnvRequest(com.orion.ops.entity.request.ApplicationEnvRequest) MachineEnvRequest(com.orion.ops.entity.request.MachineEnvRequest) HistoryValueSnapshotDO(com.orion.ops.entity.domain.HistoryValueSnapshotDO) HistoryOperator(com.orion.ops.consts.history.HistoryOperator) SystemEnvRequest(com.orion.ops.entity.request.SystemEnvRequest) HistoryValueType(com.orion.ops.consts.history.HistoryValueType)

Example 2 with HistoryValueSnapshotDO

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);
}
Also used : UserDTO(com.orion.ops.entity.dto.UserDTO) HistoryValueSnapshotDO(com.orion.ops.entity.domain.HistoryValueSnapshotDO) Date(java.util.Date)

Aggregations

HistoryValueSnapshotDO (com.orion.ops.entity.domain.HistoryValueSnapshotDO)2 HistoryOperator (com.orion.ops.consts.history.HistoryOperator)1 HistoryValueType (com.orion.ops.consts.history.HistoryValueType)1 UserDTO (com.orion.ops.entity.dto.UserDTO)1 ApplicationEnvRequest (com.orion.ops.entity.request.ApplicationEnvRequest)1 MachineEnvRequest (com.orion.ops.entity.request.MachineEnvRequest)1 SystemEnvRequest (com.orion.ops.entity.request.SystemEnvRequest)1 Date (java.util.Date)1