Merge branch 'feature-BOX一期' of http://47.99.132.106:10081/wulin/qiuguo-iot into feature-BOX一期
This commit is contained in:
commit
13fe2e56a7
@ -30,6 +30,14 @@ public class SearchResponse {
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private List<Artist> artists;
|
||||
|
||||
@Data
|
||||
public static class Artist{
|
||||
|
||||
private String name;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -22,6 +22,14 @@ public class SingerSongsResponse {
|
||||
private String id;
|
||||
|
||||
private String name;
|
||||
|
||||
private List<ArName> ar;
|
||||
|
||||
@Data
|
||||
public static class ArName{
|
||||
|
||||
private String name;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -25,6 +25,8 @@ public class SongInfoResponse {
|
||||
|
||||
private String name;
|
||||
|
||||
private String artistName;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -20,7 +20,6 @@ import org.springframework.web.reactive.function.client.WebClient;
|
||||
import reactor.core.publisher.Mono;
|
||||
import com.qiuguo.iot.third.resp.SearchResponse;
|
||||
|
||||
import static org.springframework.http.MediaType.APPLICATION_FORM_URLENCODED_VALUE;
|
||||
import static org.springframework.util.MimeTypeUtils.APPLICATION_JSON_VALUE;
|
||||
|
||||
/**
|
||||
@ -48,8 +47,16 @@ public class MusicService {
|
||||
if (ObjectUtils.isEmpty(keyword)) {
|
||||
keyword = "追梦赤子心";
|
||||
}
|
||||
WebClient build = WebClient.builder().defaultHeader(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON_VALUE).build();
|
||||
String baseUrl = "http://bilibiliz.cn:8031";
|
||||
WebClient build = WebClient.builder()
|
||||
.defaultHeader("Content-Type", "application/json; charset=utf-8")
|
||||
.defaultHeader("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS")
|
||||
.defaultHeader("Access-Control-Allow-Headers", "X-Requested-With,Content-Type")
|
||||
.defaultHeader("Accept", "*")
|
||||
.defaultHeader("Access-Control-Allow-Methods:", "PUT,POST,GET,DELETE,OPTIONS")
|
||||
.defaultHeader("Access-Control-Allow-Methods:", "PUT,POST,GET,DELETE,OPTIONS")
|
||||
.defaultHeader(HttpHeaders.CONTENT_TYPE, APPLICATION_JSON_VALUE)
|
||||
.build();
|
||||
String baseUrl = "http://121.40.172.241:8031";
|
||||
if (type == 1) {
|
||||
return build.get().uri(baseUrl.concat("/search?keywords=").concat(keyword).concat("&limit=10")).retrieve()
|
||||
.bodyToMono(SearchResponse.class).flatMap(res -> {
|
||||
@ -58,16 +65,18 @@ public class MusicService {
|
||||
}
|
||||
String ids = res.getResult().getSongs().stream().map(SearchResponse.Song::getId)
|
||||
.collect(Collectors.joining(","));
|
||||
Map<String, String> songMap = res.getResult().getSongs().stream()
|
||||
.collect(Collectors.toMap(SearchResponse.Song::getId, SearchResponse.Song::getName));
|
||||
Map<String,SearchResponse.Song > songMap = res.getResult().getSongs().stream()
|
||||
.collect(Collectors.toMap(SearchResponse.Song::getId, Function.identity()));
|
||||
|
||||
return build.get().uri(baseUrl.concat("/song/url?id=").concat(ids)).retrieve()
|
||||
.bodyToMono(SongInfoResponse.class).flatMap(song -> {
|
||||
if (Objects.equals(200, song.getCode()) && song.getData().size() > 0) {
|
||||
|
||||
List<SongInfoResponse.ResultSong> data = song.getData();
|
||||
for (SongInfoResponse.ResultSong datum : data) {
|
||||
datum.setName(songMap.get(datum.getId()));
|
||||
SearchResponse.Song innerSong = songMap.get(datum.getId());
|
||||
datum.setName(innerSong.getName());
|
||||
datum.setArtistName(ObjectUtils.isEmpty(innerSong.getArtists()) ? null
|
||||
: innerSong.getArtists().get(0).getName());
|
||||
}
|
||||
return Mono.just(data);
|
||||
}
|
||||
@ -95,7 +104,11 @@ public class MusicService {
|
||||
&& so.getData().size() > 0) {
|
||||
List<SongInfoResponse.ResultSong> data = so.getData();
|
||||
for (SongInfoResponse.ResultSong datum : data) {
|
||||
datum.setName(songMap.get(datum.getId()).getName());
|
||||
|
||||
SingerSongsResponse.Song innerSong = songMap.get(datum.getId());
|
||||
datum.setName(innerSong.getName());
|
||||
datum.setArtistName(ObjectUtils.isEmpty(innerSong.getAr()) ? null
|
||||
: innerSong.getAr().get(0).getName());
|
||||
}
|
||||
return Mono.just(data);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user