package com.platform2easy.genesis.domain.service;

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

import java.util.List;

@Service
@AllArgsConstructor
public class TxTokenService {

    private final TxTokenRepository repository;

    @Transactional
    public TxToken salvar(TxToken txToken) {
        repository.save(txToken);
        return txToken;
    }

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

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

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