diff --git a/src/main/java/org/sadtech/example/springvalidation/controller/PersonControllerNoValidation.java b/src/main/java/org/sadtech/example/springvalidation/controller/PersonControllerNoValidation.java new file mode 100644 index 0000000..46de153 --- /dev/null +++ b/src/main/java/org/sadtech/example/springvalidation/controller/PersonControllerNoValidation.java @@ -0,0 +1,29 @@ +package org.sadtech.example.springvalidation.controller; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.sadtech.example.springvalidation.dto.PersonDto; +import org.sadtech.example.springvalidation.service.PersonService; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/api/no-valid/person") +@Tag(name = "Пользователи системы 2", description = "Валидация на уровне сервиса") +@RequiredArgsConstructor +public class PersonControllerNoValidation { + + private final PersonService personService; + + @PostMapping + @Operation(summary = "Сохранение пользователя") + public ResponseEntity save(@RequestBody PersonDto personDto) { + personService.save(personDto); + return ResponseEntity.ok("valid"); + } + +} diff --git a/src/main/java/org/sadtech/example/springvalidation/service/PersonService.java b/src/main/java/org/sadtech/example/springvalidation/service/PersonService.java new file mode 100644 index 0000000..3059daf --- /dev/null +++ b/src/main/java/org/sadtech/example/springvalidation/service/PersonService.java @@ -0,0 +1,17 @@ +package org.sadtech.example.springvalidation.service; + +import org.sadtech.example.springvalidation.dto.PersonDto; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.validation.Valid; + +@Service +@Validated +public class PersonService { + + public void save(@Valid PersonDto personDto) { + // do something + } + +}