Refactor SongController and RadioStationService to enhance song management functionality

This commit is contained in:
Lukas Weger 2025-08-02 00:42:47 +02:00
parent 776c693a27
commit 2a64ee72aa
2 changed files with 18 additions and 2 deletions

View file

@ -3,7 +3,6 @@ package com.serena.backend.controller;
import com.serena.backend.dto.ApiResponse;
import com.serena.backend.dto.ConnectClientRequest;
import com.serena.backend.dto.AddSongRequest;
import com.serena.backend.dto.AddSongToStationRequest;
import com.serena.backend.service.RadioStationService;
import com.serena.backend.service.JwtService;
import org.springframework.beans.factory.annotation.Autowired;
@ -30,7 +29,7 @@ public class SongController {
}
boolean success = radioStationService.addSongToQueue(request.getRadioStationId(), request.getSong());
if (success) {
return ResponseEntity.ok(new ApiResponse<>(true, "Song added to queue successfully", null));
} else {

View file

@ -115,4 +115,21 @@ public class RadioStationService {
return new ArrayList<>();
}
public boolean addSongToQueue(String radioStationId, Song song) {
RadioStation station = radioStations.get(radioStationId);
if (station != null) {
station.addSongToQueue(song);
return true;
}
return false;
}
public Optional<Song> getNextSong(String radioStationId) {
RadioStation station = radioStations.get(radioStationId);
if (station != null) {
return Optional.ofNullable(station.getNextSong());
}
return Optional.empty();
}
}