Это запрос от почтальона:
Код: Выделить всё
POST http://localhost:8084/api/user/user
body: {
"name": "Santiago",
"email": "yes",
"number": "4",
"password": "rftgybn",
"date_of_birth": "2024-11-06T12:30:00Z",
"location": "Medellin"
}
Код: Выделить всё
POST "/api/user/user", parameters={}
Request Body: {
"name": "string",
"email": "string",
"number": "string",
"password": "string",
"date_of_birth": "2024-11-07T11:27:15.086Z",
"location": "string"
}
Код: Выделить всё
@Getter
@ToString
@NoArgsConstructor
public class UserRegisterRequestDTO {
@JsonProperty("name")
private String name;
@JsonProperty("email")
private String email;
@JsonProperty("number")
private String number;
@JsonProperty("password")
private String password;
@JsonProperty("date_of_birth")
private Date dateOfBirth;
@JsonProperty("location")
private String location;
}
Код: Выделить всё
@RestController
@RequestMapping("/user")
@CrossOrigin(origins = "*")
public class UserControllerImplementation implements UserController {
@Override
@PostMapping(produces = "application/json")
public ResponseEntity createUser(@RequestBody UserRegisterRequestDTO user) {
System.out.println("\n\nCreating user");
System.out.println(user);
return ResponseEntity.status(HttpStatus.CREATED).body(userService.createUser(user));
}
}
Код: Выделить всё
Creating user
UserRegisterRequestDTO(name=null, email=null, number=null, password=null, dateOfBirth=null, location=null)
Подробнее здесь: https://stackoverflow.com/questions/791 ... -my-object