findDepartmentByDescription

Repository

Usamos o AllowFiltering no Repository, igual vimos no comando do cqlsh. Utilizaremos também, os query methods. Spring Data Cassandra Query Methodsarrow-up-right.

public interface ProductRepository extends CassandraRepository<Product, UUID> {
    @AllowFiltering
    List<Product> findProductsByDescription(String description);
}

Service

Mesma lógica do anterior, se for nulo, retorna o findAll.

public List<ProductDTO> findByDescription(String description) {
    List<Product> entity;

    if ("".equals(description)) {
        entity = repository.findAll();
    } else {
        entity = repository.findProductsByDescription(description);

    }
    return entity.stream().map(ProductDTO::new).toList();
}

Controller

Mesma lógica do anterior, se for nulo, retorna o findAll.

Atualizado