File size: 1,462 Bytes
b0798af
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { Controller, Get, Post, Param, Body, UseGuards } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiBearerAuth } from '@nestjs/swagger';
import { AdminService } from './admin.service';
import { JwtAuthGuard } from '../auth/jwt-auth.guard';

@ApiTags('Artist & Admin Portal')
@Controller('admin')
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
export class AdminController {
  constructor(private readonly adminService: AdminService) {}

  @Post('artists')
  @ApiOperation({ summary: 'Admin create or verify an artist profile' })
  verifyArtist(@Body() body: { artist_id: string }) {
    return this.adminService.verifyArtist(body.artist_id);
  }

  @Post('albums/:id/tracks/bulk-upload')
  @ApiOperation({
    summary: 'Bulk upload multiple audio files + CSV metadata for an album',
  })
  bulkUpload(@Param('id') id: string, @Body() body: { tracks_count: number }) {
    return this.adminService.bulkUpload(id, body.tracks_count || 1);
  }

  @Get('analytics/tracks/:id')
  @ApiOperation({
    summary: 'Play counts, unique listeners & geographic breakdown for a track',
  })
  getTrackAnalytics(@Param('id') id: string) {
    return this.adminService.getTrackAnalytics(id);
  }

  @Post('tracks/:id/audio')
  @ApiOperation({
    summary: 'Replace audio file for track & re-trigger transcoding',
  })
  replaceAudio(@Param('id') id: string, @Body() body: { audio_path: string }) {
    return this.adminService.replaceAudio(id, body.audio_path);
  }
}