com.arextest.web.api.service.controller.config.AbstractMultiEnvConfigController Maven / Gradle / Ivy
package com.arextest.web.api.service.controller.config;
import com.arextest.config.model.dto.AbstractMultiEnvConfiguration;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
import com.arextest.common.annotation.AppAuth;
import com.arextest.common.model.response.Response;
import com.arextest.common.utils.ResponseUtils;
import com.arextest.config.model.dto.ModifyType;
import com.arextest.web.core.business.config.MultiEnvConfigurableHandler;
import lombok.Getter;
@Getter
public abstract class AbstractMultiEnvConfigController>
extends AbstractConfigurableController {
protected MultiEnvConfigurableHandler multiEnvConfigurableHandler;
protected AbstractMultiEnvConfigController(MultiEnvConfigurableHandler configurableHandler) {
super(configurableHandler);
this.multiEnvConfigurableHandler = configurableHandler;
}
@PostMapping("/modify/{modifyType}")
@ResponseBody
@AppAuth
@Override
public Response modify(@PathVariable ModifyType modifyType, @RequestBody T configuration)
throws Exception {
if (modifyType == ModifyType.UPDATE_MULTI_ENV) {
configuration.validateEnvConfigs();
return ResponseUtils.successResponse(getMultiEnvConfigurableHandler().editMultiEnvList(configuration));
}
if (modifyType == ModifyType.INSERT) {
configuration.validParameters();
return ResponseUtils.successResponse(getConfigurableHandler().insert(configuration));
}
if (modifyType == ModifyType.UPDATE) {
configuration.validParameters();
return ResponseUtils.successResponse(getConfigurableHandler().update(configuration));
}
if (modifyType == ModifyType.REMOVE) {
return ResponseUtils.successResponse(getConfigurableHandler().remove(configuration));
}
return ResponseUtils.resourceNotFoundResponse();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy