feat(now-playing): REST GET /now-playing (ключ — id станции каталога)
Клиенту нужен now-playing с правильным маппингом id (Record now-эндпоинт использует id now-слотов, не каталога). Отдаём текущие треки по станциям с stationId = catalog id, чтобы клиент сопоставлял по station.id.
This commit is contained in:
22
src/now-playing/now-playing.controller.ts
Normal file
22
src/now-playing/now-playing.controller.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { ApiTags, ApiOperation } from '@nestjs/swagger';
|
||||
import { NowPlayingService } from './now-playing.service';
|
||||
|
||||
@ApiTags('now-playing')
|
||||
@Controller('now-playing')
|
||||
export class NowPlayingController {
|
||||
constructor(private readonly nowPlayingService: NowPlayingService) {}
|
||||
|
||||
// Текущие треки по всем станциям, ключ — числовой id станции (как в каталоге).
|
||||
@Get()
|
||||
@ApiOperation({ summary: 'Текущие треки по всем станциям' })
|
||||
async getAll() {
|
||||
const list = await this.nowPlayingService.getAllNowPlaying();
|
||||
return list.map((np) => ({
|
||||
stationId: np.station.stationId,
|
||||
song: np.song,
|
||||
artist: np.artist,
|
||||
coverUrl: np.coverUrl,
|
||||
}));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user