package com.platform2easy.genesis.domain.service;

import com.platform2easy.genesis.domain.model.TxCoin;
import com.platform2easy.genesis.domain.repository.TxCoinRepository;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@AllArgsConstructor
public class TxCoinService {

    private final TxCoinRepository repository;

    @Transactional
    public TxCoin salvar(TxCoin txCoin) {
        repository.save(txCoin);
        return txCoin;
    }

    public List<TxCoin> listarTodos() {
        return repository.findAll();
    }

    public TxCoin buscarPorId(String id) {
        return repository.findById(id).orElseThrow();
    }

    public void deletarPorId(String id) {
        repository.deleteById(id);
    }
}
