feat: song illustration

This commit is contained in:
GitBluub
2023-05-30 00:51:36 +09:00
committed by Clément Le Bihan
parent 7b5629f4a4
commit 8dbb724a0f
2 changed files with 27 additions and 12 deletions
+13 -12
View File
@@ -46,18 +46,19 @@ model SearchHistory {
}
model Song {
id Int @id @default(autoincrement())
name String @unique
midiPath String
musicXmlPath String
artistId Int?
artist Artist? @relation(fields: [artistId], references: [id])
albumId Int?
album Album? @relation(fields: [albumId], references: [id])
genreId Int?
genre Genre? @relation(fields: [genreId], references: [id])
difficulties Json
SongHistory SongHistory[]
id Int @id @default(autoincrement())
name String @unique
midiPath String
musicXmlPath String
illustrationPath String?
artistId Int?
artist Artist? @relation(fields: [artistId], references: [id])
albumId Int?
album Album? @relation(fields: [albumId], references: [id])
genreId Int?
genre Genre? @relation(fields: [genreId], references: [id])
difficulties Json
SongHistory SongHistory[]
}
model SongHistory {
+14
View File
@@ -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')
async getMusicXml(@Param('id', ParseIntPipe) id: number) {
const song = await this.songService.song({ id });