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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
황 재인
MySpringWeb
Commits
093e0d91
Commit
093e0d91
authored
3 weeks ago
by
황 재인
Browse files
Options
Downloads
Patches
Plain Diff
musicSearch
parent
ae488407
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/com/ajou/prcoding/myweb/controller/MyWebController.java
+49
-0
49 additions, 0 deletions
...a/com/ajou/prcoding/myweb/controller/MyWebController.java
src/main/java/com/ajou/prcoding/myweb/dto/MusicList.java
+14
-0
14 additions, 0 deletions
src/main/java/com/ajou/prcoding/myweb/dto/MusicList.java
with
63 additions
and
0 deletions
src/main/java/com/ajou/prcoding/myweb/controller/MyWebController.java
0 → 100644
+
49
−
0
View file @
093e0d91
package
com.ajou.prcoding.myweb.controller
;
import
java.io.IOException
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.client.RestTemplate
;
import
com.ajou.prcoding.myweb.dto.MusicList
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
@RestController
public
class
MyWebController
{
@GetMapping
(
value
=
"/musicSearch/{term}"
)
public
MusicList
musicSearchByPath
(
@PathVariable
String
term
)
{
RestTemplate
restTemplate
=
new
RestTemplate
();
try
{
String
response
=
restTemplate
.
getForObject
(
"https://itunes.apple.com/search?term={term}&entity=album"
,
String
.
class
,
"aespa"
);
ObjectMapper
mapper
=
new
ObjectMapper
();
MusicList
list
=
mapper
.
readValue
(
response
,
MusicList
.
class
);
System
.
out
.
println
(
list
.
getResultCount
());
return
list
;
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
e
.
toString
());
}
return
null
;
}
@GetMapping
(
value
=
"/musicSearch"
)
public
MusicList
musicSearchByParam
(
@RequestParam
String
term
){
RestTemplate
restTemplate
=
new
RestTemplate
();
try
{
String
response
=
restTemplate
.
getForObject
(
"https://itunes.apple.com/search?term={term}&entity=album"
,
String
.
class
,
"aespa"
);
ObjectMapper
mapper
=
new
ObjectMapper
();
MusicList
list
=
mapper
.
readValue
(
response
,
MusicList
.
class
);
System
.
out
.
println
(
list
.
getResultCount
());
return
list
;
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
e
.
toString
());
}
return
null
;
}
}
This diff is collapsed.
Click to expand it.
src/main/java/com/ajou/prcoding/myweb/dto/MusicList.java
0 → 100644
+
14
−
0
View file @
093e0d91
package
com.ajou.prcoding.myweb.dto
;
import
lombok.Getter
;
import
lombok.Setter
;
import
lombok.ToString
;
import
java.util.*
;
@Getter
@Setter
@ToString
public
class
MusicList
{
private
Integer
resultCount
;
private
List
<
Map
<
String
,
Object
>>
results
;
}
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