feat: song illustration
This commit is contained in:
committed by
Clément Le Bihan
parent
7b5629f4a4
commit
8dbb724a0f
+13
-12
@@ -46,18 +46,19 @@ model SearchHistory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
model Song {
|
model Song {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
name String @unique
|
name String @unique
|
||||||
midiPath String
|
midiPath String
|
||||||
musicXmlPath String
|
musicXmlPath String
|
||||||
artistId Int?
|
illustrationPath String?
|
||||||
artist Artist? @relation(fields: [artistId], references: [id])
|
artistId Int?
|
||||||
albumId Int?
|
artist Artist? @relation(fields: [artistId], references: [id])
|
||||||
album Album? @relation(fields: [albumId], references: [id])
|
albumId Int?
|
||||||
genreId Int?
|
album Album? @relation(fields: [albumId], references: [id])
|
||||||
genre Genre? @relation(fields: [genreId], references: [id])
|
genreId Int?
|
||||||
difficulties Json
|
genre Genre? @relation(fields: [genreId], references: [id])
|
||||||
SongHistory SongHistory[]
|
difficulties Json
|
||||||
|
SongHistory SongHistory[]
|
||||||
}
|
}
|
||||||
|
|
||||||
model SongHistory {
|
model SongHistory {
|
||||||
|
|||||||
@@ -48,6 +48,20 @@ export class SongController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Get(':id/illustration')
|
||||||
|
async getIllustration(@Param('id', ParseIntPipe) id: number) {
|
||||||
|
const song = await this.songService.song({ id });
|
||||||
|
if (!song) throw new NotFoundException('Song not found');
|
||||||
|
|
||||||
|
if (song.illustrationPath === null) throw new NotFoundException();
|
||||||
|
try {
|
||||||
|
const file = createReadStream(song.illustrationPath);
|
||||||
|
return new StreamableFile(file);
|
||||||
|
} catch {
|
||||||
|
throw new InternalServerErrorException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Get(':id/musicXml')
|
@Get(':id/musicXml')
|
||||||
async getMusicXml(@Param('id', ParseIntPipe) id: number) {
|
async getMusicXml(@Param('id', ParseIntPipe) id: number) {
|
||||||
const song = await this.songService.song({ id });
|
const song = await this.songService.song({ id });
|
||||||
|
|||||||
Reference in New Issue
Block a user