0
Hello,
I am implementing a web project in spring boot + data + Angularjs. Where the client makes Rest requests to the server. On the Spring side I’m using repositories to develop database research with Crudrepository.
@RepositoryRestResource
public interface ClientRepository extends CrudRepository< Client , Integer > {
List< Client > findAll( );
}
Only I need to edit the save function of the repository. I tried to create a service layer that runs save but is not working.
@Component( "clientService" )
@Transactional
public class ClientRepositoryImpl implements ClientService{
private final ClientRepository clientRepository;
public ClientRepositoryImpl( ClientRepository clientRepository ) {
this.clientRepository = clientRepository;
}
@Override
public String addClient( Client saved ) {
// ....
if( this.clientRepository.save( saved ) != null )
return "OK";
else
return "NOK";
}
}
Can anyone give an idea how to create some logic before invoking save from the repository ? I’m doing the log I need to validate the data entered on the server side and I’m not sure how to validate before the repository saves. Since on the client side I make a Rest call ( /clients ) with the parameters to insert.