getUserProfileList static method
获取用户画像列表
Implementation
static Future<List<UserProfileModel>> getUserProfileList({
int page = 1,
int limit = 20,
String? gender,
}) async {
var url = '${EnvironmentConfig.baseUrl}$_listProfilePath?page=$page&limit=$limit';
if (gender != null) {
url += '&gender=$gender';
}
print('========== 📤 获取用户画像列表请求 ==========');
print('🔗 请求地址: $url');
try {
final response = await http.get(
Uri.parse(url),
headers: {
'Content-Type': 'application/json',
},
).timeout(
Duration(seconds: EnvironmentConfig.apiTimeout),
onTimeout: () {
throw Exception('获取用户画像列表请求超时');
},
);
print('✅ 收到用户画像列表响应 (状态码: ${response.statusCode})');
if (response.statusCode == 200) {
final Map<String, dynamic> responseData = json.decode(response.body);
if (responseData['success'] == true && responseData['data'] != null) {
final List<dynamic> dataList = responseData['data'];
return dataList.map((json) => UserProfileModel.fromJson(json)).toList();
}
}
return [];
} catch (e) {
print('❌ 获取用户画像列表异常: $e');
return [];
}
}