Skip to content
Snippets Groups Projects
Commit 53ec9bda authored by 김재현's avatar 김재현
Browse files

Add delete Favorite

parent 2b39641c
No related branches found
No related tags found
No related merge requests found
Pipeline #8367 failed
......@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.DeleteMapping;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException;
import java.util.List;
......@@ -48,4 +49,10 @@ public class MyWebController {
return service.saveFavorite(favorite);
}
@DeleteMapping(value = "/likes/{id}")
@Transactional
public int deleteLikes(@PathVariable Long id) {
return service.deleteFavorite(id);
}
}
......@@ -6,4 +6,6 @@ import java.util.List;
public interface FavoriteRepository extends JpaRepository<FavoriteMusic, String> {
List<FavoriteMusic> findAll();
void deleteById(Long id);
}
......@@ -52,6 +52,16 @@ public class MusicService {
} else {
return 0;
}
}
public int deleteFavorite(Long 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