I am trying inject a dependency or at least filtrate the ID parameter that come into a RestControler in Spring. I am very new in Spring. How can i be sure that the parameter that comes passed in the API is valid and/or how can i inject its dependency related to Customer Entity?
This is my rest controller CustomerController method
@PatchMapping("/{id}")
public Customer updateCustomer(@PathVariable Long id, @RequestBody Customer customer) {
return customerService.updateCustomer(id, customer);
}
This is the request that at the moment filtrates only the firstname and last name
package com.appsdeveloperblock.app.ws.requests.customer;
import javax.validation.constraints.NotNull;
public class CreateCustomerRequest {
@NotNull
private String firstname;
@NotNull
private String lastname;
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
}
Thank you!