Last active
July 23, 2020 05:48
-
-
Save krnbr/ca25aa02ca7c642f05b6991c863cdbd9 to your computer and use it in GitHub Desktop.
TestController And TestDto
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.springframework.web.bind.annotation.*; | |
import org.springframework.web.server.ServerWebExchange; | |
import reactor.core.publisher.Mono; | |
import javax.validation.Valid; | |
/** | |
* @author Karanbir Singh on 07/23/2020 | |
*/ | |
@RestController | |
public class TestController { | |
@GetMapping("test") | |
public Mono<TestDto> getTestDto(final @RequestParam String name, | |
final ServerWebExchange exchange) { | |
TestDto testDto = new TestDto(); | |
testDto.setName(name); | |
testDto.setAge(0); | |
testDto.setName("Welcome "+name); | |
return Mono.just(testDto); | |
} | |
@PostMapping("test") | |
public Mono<TestDto> postTestDto(@Valid @RequestBody final TestDto testDto, | |
final ServerWebExchange exchange) { | |
return Mono.just(testDto); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.validation.constraints.NotEmpty; | |
import javax.validation.constraints.NotNull; | |
/** | |
* @author Karanbir Singh on 07/23/2020 | |
*/ | |
public class TestDto { | |
@NotEmpty | |
private String message; | |
@NotEmpty | |
private String name; | |
@NotNull | |
private Integer age; | |
public String getMessage() { | |
return message; | |
} | |
public void setMessage(String message) { | |
this.message = message; | |
} | |
public String getName() { | |
return name; | |
} | |
public void setName(String name) { | |
this.name = name; | |
} | |
public Integer getAge() { | |
return age; | |
} | |
public void setAge(Integer age) { | |
this.age = age; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment