deleteUserProfile static method

Future<bool> deleteUserProfile(
  1. String userId
)

删除用户画像

Implementation

static Future<bool> deleteUserProfile(String userId) async {
  final url = '${EnvironmentConfig.baseUrl}$_deleteProfilePath';
  print('========== 📤 删除用户画像请求 ==========');
  print('🔗 请求地址: $url');
  print('👤 用户ID: $userId');

  try {
    final response = await http.post(
      Uri.parse(url),
      headers: {
        'Content-Type': 'application/json',
      },
      body: json.encode({'user_id': userId}),
    ).timeout(
      Duration(seconds: EnvironmentConfig.apiTimeout),
      onTimeout: () {
        throw Exception('删除用户画像请求超时');
      },
    );

    print('✅ 收到删除用户画像响应 (状态码: ${response.statusCode})');

    if (response.statusCode == 200) {
      final Map<String, dynamic> responseData = json.decode(response.body);
      return responseData['success'] == true;
    } else {
      return false;
    }
  } catch (e) {
    print('❌ 删除用户画像异常: $e');
    return false;
  }
}