From ee4f6f0a02a7c6693092d2635154e7ddf654038d Mon Sep 17 00:00:00 2001 From: Struchkov Mark Date: Wed, 29 Jun 2022 23:56:28 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=B2=D0=B8=D1=81=D0=B8=D0=BC=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D1=8C=20=D0=B4=D0=BB=D1=8F=20=D0=B2=D0=B0=D0=BB=D0=B8=D0=B4?= =?UTF-8?q?=D0=B0=D1=86=D0=B8=D0=B8=20=D0=B8=20=D0=BF=D0=BE=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=B8=D0=BB=20RequestParam?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 5 +++++ .../example/swagger/controller/PointController.java | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 5641c4d..d85dc58 100644 --- a/pom.xml +++ b/pom.xml @@ -40,6 +40,11 @@ springdoc-openapi-ui 1.6.9 + + + org.springframework.boot + spring-boot-starter-validation + diff --git a/src/main/java/org/sadtech/example/swagger/controller/PointController.java b/src/main/java/org/sadtech/example/swagger/controller/PointController.java index f4fda73..a2552e6 100644 --- a/src/main/java/org/sadtech/example/swagger/controller/PointController.java +++ b/src/main/java/org/sadtech/example/swagger/controller/PointController.java @@ -10,9 +10,10 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestPart; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import javax.validation.Valid; import javax.validation.constraints.Min; import javax.validation.constraints.NotBlank; import java.util.Map; @@ -36,8 +37,8 @@ public class PointController { @Operation(summary = "Управление баллами", description = "Позволяет удалить или добавить баллы пользователю") public HttpStatus changePoints( @PathVariable @NotBlank @Parameter(description = "Идентификатор пользователя") String key, - @RequestPart("point") @Min(0) @Parameter(description = "Количество баллов", required = true) Long point, - @RequestPart("type") @Parameter(description = "Тип операции", required = true) TypeOperation type + @RequestParam("point") @Min(0) @Parameter(description = "Количество баллов", required = true) Long point, + @RequestParam("type") @Parameter(description = "Тип операции", required = true) TypeOperation type ) { final UserDto userDto = repository.get(key); userDto.setPoints(