Skip to content
Snippets Groups Projects
Commit 81ae0aac authored by HyunjinNoh's avatar HyunjinNoh
Browse files

get_likes

parent e303fdd2
No related branches found
No related tags found
No related merge requests found
Pipeline #8288 canceled
package kr.ajousw.myspringweb.controller;
import java.io.IOException;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
......@@ -10,9 +12,13 @@ import org.springframework.web.client.RestTemplate;
import com.fasterxml.jackson.databind.ObjectMapper;
import kr.ajousw.myspringweb.dto.MusicList;
import kr.ajousw.myspringweb.entity.FavoriteMusic;
import kr.ajousw.myspringweb.repository.FavoriteRepository;
@RestController
public class MyWebController {
@Autowired
FavoriteRepository albumsRepo;
@GetMapping(value="/musicSearch/{term}")
public String musicSearch(@PathVariable String term) {
......@@ -32,4 +38,14 @@ public class MyWebController {
return "{\"resultCount\":0, \"results\":[]}";
}
//Get Favorite Music list from Database
@GetMapping(value="/likes")
public List<FavoriteMusic> getLikes() {
try {
return albumsRepo.findAll();
} catch (Exception e) {
System.out.println(e.toString());
return null;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment