package com.alterdekim.game.service;

import com.alterdekim.flash.decompiler.mapper.OutputObjectCallback;
import com.alterdekim.game.entity.Good;
import com.alterdekim.game.repository.GoodRepository;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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


@Service
public class GoodsService implements OutputObjectCallback {

    @Autowired
    private GoodRepository repository;

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


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

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