fixed default controller, fixed post methods

This commit is contained in:
ialbert 2022-08-26 18:19:34 +03:00
parent 6bc177d506
commit 0170065ddb
3 changed files with 10 additions and 3 deletions

View file

@ -7,10 +7,12 @@ import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerF
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.*;
import java.util.List;
import java.util.function.Consumer;
@SuppressWarnings("Duplicates")
@Configuration
@ -31,7 +33,12 @@ public class WebConfig implements WebMvcConfigurer {
@Autowired
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> messageConverters) {
messageConverters.add(customJsonHttpConverter);
Consumer<HttpMessageConverter<?>> addConverter = httpMessageConverter -> {
messageConverters.removeIf(registeredConverter -> registeredConverter.getClass().equals(httpMessageConverter.getClass()));
messageConverters.add(httpMessageConverter);
};
addConverter.accept(new StringHttpMessageConverter());
addConverter.accept(customJsonHttpConverter);
}
@Override

View file

@ -30,7 +30,7 @@ public class CudMoneyMarketSecurityController extends AbstractQueueController {
@ApiOperation(value = "create money security.")
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
@RequestMapping(value = "/", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public CudResponse add(
@ApiParam(value = "Параметры команды в JSON формате.", required = true)

View file

@ -30,7 +30,7 @@ public class CudKeyRateController extends AbstractQueueController {
@ApiOperation(value = "create key rate.")
@ApiResponses(value = {@ApiResponse(code = 200, message = "OK", response = CudResponse.class), @ApiResponse(code = 400, message = "Ошибка валидации", response = BasicSpcexResponse.class)})
@RequestMapping(value = "/", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public CudResponse add(
@ApiParam(value = "Параметры команды в JSON формате.", required = true)