Fixing delete
Some checks failed
Music Collection CI Workflow / test (./backend) (push) Successful in 22s
Music Collection CI Workflow / test (./frontend) (push) Successful in 29s
Music Collection CI Workflow / build-and-push-images (./backend/Dockerfile, git.anatid.net/tabris/msuic-collection-backend, ./backend) (push) Failing after 35s
Music Collection CI Workflow / build-and-push-images (./frontend/Dockerfile, git.anatid.net/tabris/music-collection-frontend, ./frontend) (push) Successful in 1m44s
Music Collection CI Workflow / deploy (push) Has been skipped

This commit is contained in:
Phill Pover 2025-04-06 22:42:54 +01:00
parent 153460b8e9
commit 0d3fc109ac
4 changed files with 16 additions and 12 deletions

View File

@ -26,7 +26,7 @@ export class AlbumController {
@Put()
async update(@Param('id') id: number, @Body() updateAlbumDto: UpdateAlbumDto): Promise<string> {
return this.albumService.update(updateAlbumDto);
return this.albumService.update(id, updateAlbumDto);
}
@Delete(':id')

View File

@ -15,6 +15,6 @@ export class Album {
@Column()
genre: string
@OneToMany(() => Song, (song) => song.album, { eager: true })
@OneToMany(() => Song, (song) => song.album, { eager: true, onDelete: 'CASCADE' })
songs: Song[]
}

View File

@ -25,8 +25,8 @@ export class SongController {
}
@Put()
async update(@Body() updateSongDto: UpdateSongDto): Promise<string> {
return this.songService.update(updateSongDto);
async update(@Param('id') id: number, @Body() updateSongDto: UpdateSongDto): Promise<string> {
return this.songService.update(id, updateSongDto);
}
@Delete(':id')

View File

@ -30,6 +30,7 @@ export class SongService {
}
async update(updateSongDto: UpdateSongDto): Promise<string> {
if (id === updateSongDto.id) {
const song = this.songRepository.findOneBy({ id: updateSongDto.id });
if (!song)
return "Song not found";
@ -39,6 +40,9 @@ export class SongService {
duration: updateSongDto.duration
});
return "Song updated successfully";
} else {
return "Song ID does not match posted data"
}
}
async remove(id: number): Promise<void> {