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
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:
parent
153460b8e9
commit
0d3fc109ac
@ -26,7 +26,7 @@ export class AlbumController {
|
|||||||
|
|
||||||
@Put()
|
@Put()
|
||||||
async update(@Param('id') id: number, @Body() updateAlbumDto: UpdateAlbumDto): Promise<string> {
|
async update(@Param('id') id: number, @Body() updateAlbumDto: UpdateAlbumDto): Promise<string> {
|
||||||
return this.albumService.update(updateAlbumDto);
|
return this.albumService.update(id, updateAlbumDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
|
@ -15,6 +15,6 @@ export class Album {
|
|||||||
@Column()
|
@Column()
|
||||||
genre: string
|
genre: string
|
||||||
|
|
||||||
@OneToMany(() => Song, (song) => song.album, { eager: true })
|
@OneToMany(() => Song, (song) => song.album, { eager: true, onDelete: 'CASCADE' })
|
||||||
songs: Song[]
|
songs: Song[]
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,8 @@ export class SongController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Put()
|
@Put()
|
||||||
async update(@Body() updateSongDto: UpdateSongDto): Promise<string> {
|
async update(@Param('id') id: number, @Body() updateSongDto: UpdateSongDto): Promise<string> {
|
||||||
return this.songService.update(updateSongDto);
|
return this.songService.update(id, updateSongDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Delete(':id')
|
@Delete(':id')
|
||||||
|
@ -30,15 +30,19 @@ export class SongService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async update(updateSongDto: UpdateSongDto): Promise<string> {
|
async update(updateSongDto: UpdateSongDto): Promise<string> {
|
||||||
const song = this.songRepository.findOneBy({ id: updateSongDto.id });
|
if (id === updateSongDto.id) {
|
||||||
if (!song)
|
const song = this.songRepository.findOneBy({ id: updateSongDto.id });
|
||||||
return "Song not found";
|
if (!song)
|
||||||
|
return "Song not found";
|
||||||
|
|
||||||
await this.songRepository.update({ id: updateSongDto.id }, {
|
await this.songRepository.update({ id: updateSongDto.id }, {
|
||||||
title: updateSongDto.title,
|
title: updateSongDto.title,
|
||||||
duration: updateSongDto.duration
|
duration: updateSongDto.duration
|
||||||
});
|
});
|
||||||
return "Song updated successfully";
|
return "Song updated successfully";
|
||||||
|
} else {
|
||||||
|
return "Song ID does not match posted data"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async remove(id: number): Promise<void> {
|
async remove(id: number): Promise<void> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user