package com.alterdekim.hearthhack.service;

import com.alterdekim.hearthhack.entity.Room;
import com.alterdekim.hearthhack.repository.RoomRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

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

@RequiredArgsConstructor
@Service
public class RoomService implements IService {
    private final RoomRepository roomRepository;

    public List<Room> getAll() {
        return roomRepository.findAll();
    }

    public Optional<Room> findById(Long id) {
        return roomRepository.findById(id);
    }

    public Long createRoom(Room room) {
        return roomRepository.save(room).getId();
    }

    public void clearEmptyRooms() {
        roomRepository.clearEmptyRooms();
    }

    public void removeRoom(Long roomId) {
        roomRepository.deleteById(roomId);
    }
}
