Skip to content
Snippets Groups Projects
Commit 303a6983 authored by dudgns2947's avatar dudgns2947
Browse files

Add delete Favorite

parent 766fc700
No related branches found
No related tags found
1 merge request!6Add delete Favorite
...@@ -44,4 +44,10 @@ public class MyWebController { ...@@ -44,4 +44,10 @@ public class MyWebController {
public int postLikes(@RequestBody FavoriteMusicRequestDto favorite) { public int postLikes(@RequestBody FavoriteMusicRequestDto favorite) {
return service.saveFavorite(favorite); return service.saveFavorite(favorite);
} }
@DeleteMapping(value="/likes/{id}")
@Transactional
public int deleteById(@PathVariable String id) {
return service.deleteFavorite(id);
}
} }
...@@ -7,4 +7,8 @@ import java.util.List; ...@@ -7,4 +7,8 @@ import java.util.List;
public interface FavoriteRepository extends JpaRepository<FavoriteMusic, String> { public interface FavoriteRepository extends JpaRepository<FavoriteMusic, String> {
List<FavoriteMusic> findAll(); List<FavoriteMusic> findAll();
@Override
void deleteById(String id);
} }
...@@ -71,6 +71,19 @@ public class MusicService { ...@@ -71,6 +71,19 @@ 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;
}
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment