package es.uv.garcosda.services;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import es.uv.garcosda.domain.Document;
import es.uv.garcosda.repositories.NewsRepository;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

@Service
@Transactional
public class NewsService {

	@Autowired
	NewsRepository nr;
	
	public Mono<Document> findById(Integer id){
		return this.nr.findById(id);
	}
	
	public Flux<Document> findAll() {
		return this.nr.findAll();
	}
	
	public Flux<Document> findByAuthor(String author){
		return this.nr.findByAuthor(author);
	}
	
	public Flux<Document> findByPublisher(String publisher){
		return this.nr.findByPublisher(publisher);
	}
	
	public Mono<Document> update(Document n){
		return this.nr.save(n);
	}
	
	public Mono<Document> insert(Document n) {
		return this.nr.save(n);
	}
	
	public Flux<Document> createAll(List<Document> ns){
		return this.nr.saveAll(ns);
	}
	
	public Mono<Void> deleteById(Integer id) {
		return this.nr.deleteById(id);
	}
	
	public Flux<String> findAuthors(){
        return this.nr.findAuthors();
    }

    public Flux<String> findPublishers(){
        return this.nr.findPublishers();
    }
}
