Refactor SongController and RadioStationService to enhance song management functionality
This commit is contained in:
parent
776c693a27
commit
2a64ee72aa
2 changed files with 18 additions and 2 deletions
|
@ -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 {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue