Skip to content
Snippets Groups Projects
Commit 1e484f32 authored by 황 수빈's avatar 황 수빈
Browse files

Add delete Favorite

parent 7ea75d07
No related branches found
No related tags found
No related merge requests found
Pipeline #8388 failed
...@@ -14,6 +14,7 @@ import kr.ajousw.myspringweb.service.MusicService; ...@@ -14,6 +14,7 @@ import kr.ajousw.myspringweb.service.MusicService;
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;
@RestController @RestController
...@@ -41,4 +42,9 @@ public class MyWebController { ...@@ -41,4 +42,9 @@ public class MyWebController {
return service.saveFavorite(favorite); return service.saveFavorite(favorite);
} }
@DeleteMapping(value = "/likes/{id}")
public void deleteLikes(@PathVariable String id) {
service.deleteFavorite(id);
}
} }
...@@ -9,4 +9,6 @@ import kr.ajousw.myspringweb.entity.FavoriteMusic; ...@@ -9,4 +9,6 @@ import kr.ajousw.myspringweb.entity.FavoriteMusic;
public interface FavoriteRepository extends public interface FavoriteRepository extends
JpaRepository<FavoriteMusic, String> { JpaRepository<FavoriteMusic, String> {
List<FavoriteMusic> findAll(); List<FavoriteMusic> findAll();
void deleteById(String collectionId);
} }
...@@ -56,5 +56,12 @@ public class MusicService { ...@@ -56,5 +56,12 @@ public class MusicService {
} }
} }
public void deleteFavorite(String id) {
try {
albumsRepo.deleteById(id);
} catch (Exception e) {
System.out.println(e.toString());
}
}
} }
\ No newline at end of file
No preview for this file type
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment