package com.alterdekim.game.service;

import com.alterdekim.game.entity.Miniquest;
import com.alterdekim.game.entity.PhoneMessage;
import com.alterdekim.game.repository.MiniquestRepository;
import com.alterdekim.game.repository.PhoneMessageRepository;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@AllArgsConstructor
@Service
public class PhoneMessageService {
    private final PhoneMessageRepository repository;

    public List<PhoneMessage> getAllPhoneMessages() {
        return repository.findAll();
    }

    public List<PhoneMessage> getAllByReceiverId(Integer id) {
        return repository.findByReceiverId(id);
    }

    public void markAsRead(Long messageId) {
        this.repository.markAsRead(messageId);
    }

    public PhoneMessage getPhoneMessageById(long id) {
        return repository.findById(id).orElse(null);
    }

    public void removeById(long id) {
        repository.deleteById(id);
    }

    public void savePhoneMessage(PhoneMessage phoneMessage) {
        repository.save(phoneMessage);
    }
}
