添加了获取歌单中所有歌曲和获取我的作品接口

master
Plus One 2 weeks ago
parent 8d4a9e519e
commit 520115c2b0

@ -2,13 +2,41 @@ import 'package:dio/dio.dart';
import 'package:music_player_miao/models/search_bean.dart';
import 'package:music_player_miao/models/songlist_bean.dart';
import '../models/getAllSongs_bean.dart';
import '../models/universal_bean.dart';
import 'package:music_player_miao/models/getMyWorks.dart';
const String _SonglistURL = 'http://flyingpig.fun:10010/songlists';
///
const String _MyWorksURL = 'http://flyingpig.fun:10010/musics/upload-music';
class SonglistApi {
final Dio dio = Dio();
///
Future<MyMusicListBean> getAllSongs({required int id, required String Authorization}) async {
String urlWithId = 'http://flyingpig.fun:10010/songlist-musics/$id/music-list';
Response response = await dio.get(urlWithId,
options: Options(headers: {
'Authorization': Authorization,
'Content-Type': 'application/json;charset=UTF-8'
}));
print(response.data);
return MyMusicListBean.formMap(response.data);
}
///
Future<MyWorks> getMyworks({required String Authorization}) async {
Response response = await dio.get(_MyWorksURL,
data: {
'Authorization': Authorization,
},
options: Options(headers: {
'Authorization': Authorization,
'Content-Type': 'application/json;charset=UTF-8'
}));
print(response.data);
return MyWorks.formMap(response.data);
}
///
Future<SearchBean> getSonglist({required String Authorization}) async {
Response response = await dio.get(_SonglistURL,
data: {

@ -0,0 +1,43 @@
class MyMusicListBean {
int? code;
String? msg;
List<DataBean>? data;
MyMusicListBean.formMap(Map map) {
code = map['code'];
msg = map['msg'];
if (map['data'] is! List) return;
List<dynamic> dataList = map['data'];
data = dataList.map((item) => DataBean._formMap(item)).toList();
}
}
class DataBean {
int? songlistId;
List<SongDetails>? musicDetail;
DataBean._formMap(Map map) {
songlistId = map['songlistId'];
List<dynamic>? musicDetailList = map['musicDetail'];
if (musicDetailList == null) return;
musicDetail = musicDetailList.map((item) => SongDetails._formMap(item)).toList();
}
}
class SongDetails {
int? id;
String? name;
String? coverPath;
String? musicPath;
String? singerName;
String? uploadUserName;
SongDetails._formMap(Map map) {
id = map['id'];
name = map['name'];
coverPath = map['coverPath'];
musicPath = map['musicPath'];
singerName = map['singerName'];
uploadUserName = map['uploadUserName'];
}
}
Loading…
Cancel
Save