Skip to content
Snippets Groups Projects
Commit 456f6767 authored by suhyeon's avatar suhyeon
Browse files

Add delete Favorite

parent 828e6099
No related branches found
No related tags found
No related merge requests found
Pipeline #8379 failed
......@@ -15,6 +15,7 @@ import java.io.IOException;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -51,4 +52,10 @@ public class MyWebController {
public int postLikes(@RequestBody FavoriteMusicRequestDto favorite) {
return service.saveFavorite(favorite);
}
@DeleteMapping(value="/likes/{id}")
@Transactional
public int deleteById(@PathVariable String id) {
return service.deleteFavorite(id);
}
}
\ No newline at end of file
......@@ -68,6 +68,16 @@ public class MusicService {
}
}
public int deleteFavorite(@PathVariable String id) {
try {
albumsRepo.deleteById(id);
return 1;
} catch (Exception e) {
System.out.println(e.toString());
return 0;
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment