package com.alterdekim.game.service;

import com.alterdekim.flash.decompiler.mapper.OutputObjectCallback;
import com.alterdekim.game.entity.TextResource;
import com.alterdekim.game.repository.TextResourceRepository;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@NoArgsConstructor
@Service
public class TRService implements OutputObjectCallback {

    @Autowired
    private TextResourceRepository repository;

    @Override
    public void onOutputObjectReady(Object o) {
        this.repository.save((TextResource) o);
    }

    public List<TextResource> getAll() {
        return this.repository.findAll();
    }

    public Optional<TextResource> findById(Long id) {
        return this.repository.findById(id);
    }
}
