Skip to content
Snippets Groups Projects
Commit eb4ecc64 authored by 최현수's avatar 최현수
Browse files

Add delete Favorite

parent a3362f52
No related branches found
No related tags found
No related merge requests found
Pipeline #8354 failed
...@@ -4,6 +4,7 @@ import java.io.IOException; ...@@ -4,6 +4,7 @@ import java.io.IOException;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; 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.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
...@@ -45,4 +46,9 @@ public class MyWebController { ...@@ -45,4 +46,9 @@ public class MyWebController {
return service.saveFavorite(favorite); return service.saveFavorite(favorite);
} }
@DeleteMapping(value="/likes/{id}") // Delete Favorite Music by ID
public int deleteFavorite(@PathVariable String id) {
return service.deleteFavorite(id);
}
} }
\ No newline at end of file
...@@ -58,4 +58,13 @@ public class MusicService{ ...@@ -58,4 +58,13 @@ public class MusicService{
} }
} }
public int deleteFavorite(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