ExtrasService.java
package com.sintia.ffl.admin.optique.services.services;
import com.sintia.ffl.admin.optique.dal.entities.catalogue.SupplementVerreCatalogue;
import com.sintia.ffl.admin.optique.dal.repositories.catalogue.SupplementVerreCatalogueRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Optional;
@Service
public class ExtrasService {
@Autowired
private SupplementVerreCatalogueRepository supplementVerreRepository;
/**
* Return a Extras from the database, and with the corresponding maker, provider and extrasCode.<br>
* If there's no corresponding extras in the database, return null
*
* @param maker
* @param provider
* @param extrasCode
* @return
*/
public SupplementVerreCatalogue getSupplementVerre(String maker, String provider, String extrasCode) {
Optional<SupplementVerreCatalogue> result = supplementVerreRepository.findByCodeSupplementVerreAndCodeOptoDistributeurAndCodeOptoFabricant(
extrasCode, maker, provider);
if (result.isPresent() && !result.isEmpty())
return result.get();
return null;
}
}