Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
myspringweb
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
김재현
myspringweb
Commits
989b2645
Commit
989b2645
authored
2 years ago
by
김재현
Browse files
Options
Downloads
Patches
Plain Diff
get_likes
parent
b4d7795a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/kr/ajousw/myspringweb/controller/MyWebController.java
+31
-7
31 additions, 7 deletions
...ava/kr/ajousw/myspringweb/controller/MyWebController.java
with
31 additions
and
7 deletions
src/main/java/kr/ajousw/myspringweb/controller/MyWebController.java
+
31
−
7
View file @
989b2645
...
...
@@ -4,18 +4,26 @@ import org.springframework.web.bind.annotation.RestController;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
import
java.io.IOException
;
import
java.util.List
;
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
Musiclist
musicSearchByPath
(
@
RequestParam
String
term
)
{
public
Musiclist
musicSearchByPath
(
@
PathVariable
String
term
)
{
RestTemplate
restTemplate
=
new
RestTemplate
();
String
url
=
"https://itunes.apple.com/search?term="
+
term
+
"&entity=musicVideo"
;
String
url
=
"https://itunes.apple.com/search?term="
+
term
+
"&entity=musicVideo"
;
// String url = "https://itunes.apple.com/search?term=aespa&entity=album";
try
{
String
response
=
restTemplate
.
getForObject
(
url
,
String
.
class
);
...
...
@@ -31,11 +39,10 @@ public class MyWebController {
}
@GetMapping
(
value
=
"/musicSearch"
)
public
Musiclist
musicSearchByParam
(
@RequestParam
(
value
=
"term"
)
String
name
)
{
public
Musiclist
musicSearchByParam
(
@RequestParam
String
term
)
{
RestTemplate
restTemplate
=
new
RestTemplate
();
// String url = "https://itunes.apple.com/search?term=" + term +
// "&entity=musicVideo";
String
url
=
"https://itunes.apple.com/search?term=aespa&entity=album"
;
String
url
=
"https://itunes.apple.com/search?term="
+
term
+
"&entity=musicVideo"
;
// String url = "https://itunes.apple.com/search?term=aespa&entity=album";
try
{
String
response
=
restTemplate
.
getForObject
(
url
,
String
.
class
);
ObjectMapper
mapper
=
new
ObjectMapper
();
...
...
@@ -48,4 +55,21 @@ public class MyWebController {
}
return
null
;
}
@GetMapping
(
value
=
"/likes"
)
public
List
<
FavoriteMusic
>
getLikes
()
{
try
{
return
albumsRepo
.
findAll
();
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
e
.
toString
());
return
null
;
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment