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,
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Module, forwardRef } from '@nestjs/common';
|
||||
import { NowPlayingGateway } from './now-playing.gateway';
|
||||
import { NowPlayingController } from './now-playing.controller';
|
||||
import { NowPlayingService } from './now-playing.service';
|
||||
import { RecordStationSyncService } from './record-station-sync.service';
|
||||
import { IcyNowPlayingService } from './icy-now-playing.service';
|
||||
@@ -7,6 +8,7 @@ import { ChartsModule } from '../charts/charts.module';
|
||||
|
||||
@Module({
|
||||
imports: [forwardRef(() => ChartsModule)],
|
||||
controllers: [NowPlayingController],
|
||||
providers: [
|
||||
NowPlayingGateway,
|
||||
NowPlayingService,
|
||||
|
||||
Reference in New Issue
Block a user