package com.bcxin.backend.domain.services.impls;

import com.bcxin.backend.domain.models.DomainSuperviseDTO;
import com.bcxin.backend.domain.repositories.DomainSuperviseRepository;
import com.bcxin.backend.domain.services.DomainSuperviseService;
import org.springframework.stereotype.Service;
import java.util.Collection;

@Service
public class DomainSuperviseServiceImpl implements DomainSuperviseService {

    private final DomainSuperviseRepository domainSuperviseRepository;

    public DomainSuperviseServiceImpl(DomainSuperviseRepository domainSuperviseRepository) {
        this.domainSuperviseRepository = domainSuperviseRepository;
    }

    @Override
    public Collection<DomainSuperviseDTO> getByDomainIds(Collection<String> domainId) {
        return getDomainSuperviseDTOs(domainId);
    }


    private Collection<DomainSuperviseDTO> getDomainSuperviseDTOs(Collection<String> domainIds) {
        if (domainIds.size() == 0) {
            return this.domainSuperviseRepository.getDomainSuperviseDTOForBaseData();
        }

        return  this.domainSuperviseRepository.getAll(domainIds);
    }
}
