import 'package:kaer_with_panels/app/model/response/kr_is_register.dart';
import 'package:kaer_with_panels/app/model/response/kr_login_data.dart';
import 'package:kaer_with_panels/app/model/response/kr_node_list.dart';
import 'package:kaer_with_panels/app/model/response/kr_package_list.dart';

import 'response/kr_already_subscribe.dart';
import 'response/kr_config_data.dart';
import 'response/kr_kr_affiliate_count.dart';
import 'response/kr_message_list.dart';
import 'response/kr_node_group_list.dart';
import 'response/kr_order_status.dart';
import 'response/kr_payment_methods.dart';
import 'response/kr_purchase_order_no.dart';
import 'response/kr_status.dart';
import 'response/kr_user_available_subscribe.dart';
import 'response/kr_user_info.dart';
import 'response/kr_user_online_duration.dart';
import 'response/kr_web_text.dart';

/// json转换成实体类，每新建一个实体类就新增加一个case
abstract class EntityFromJsonUtil {
  static T parseJsonToEntity<T>(Map<String, dynamic> json) {
    switch (T.toString()) {
      case "KRIsRegister":
        return KRIsRegister.fromJson(json) as T;
      case "KRLoginData":
        return KRLoginData.fromJson(json) as T;
      case "KRPackageList":
        return KRPackageList.fromJson(json) as T;
      case "KRNodeList":
        return KRNodeList.fromJson(json) as T;
      case "KRMessageList":
        return KRMessageList.fromJson(json) as T;
      case "KRUserInfo":
        return KRUserInfo.fromJson(json) as T;
      case "KRAffiliateCount":
        return KRAffiliateCount.fromJson(json) as T;
      case "KRPaymentMethods":
        return KRPaymentMethods.fromJson(json) as T;
      case "KRConfigData":
        return KRConfigData.fromJson(json) as T;
      case "KRPurchaseOrderNo":
        return KRPurchaseOrderNo.fromJson(json) as T;
      case "KRPurchaseOrderUrl":
        return KRPurchaseOrderUrl.fromJson(json) as T;
      case "KROrderStatus":
        return KROrderStatus.fromJson(json) as T;
      case "KRAlreadySubscribeList":
        return KRAlreadySubscribeList.fromJson(json) as T;
      case "KRNodeGroupList":
        return KRNodeGroupList.fromJson(json) as T;
      case "KRWebText":
        return KRWebText.fromJson(json) as T; 
      case "KRUserOnlineDurationResponse":
        return KRUserOnlineDurationResponse.fromJson(json) as T;
      case "KRUserAvailableSubscribeList":
        return KRUserAvailableSubscribeList.fromJson(json) as T;
      case "KRStatus":
        return KRStatus.fromJson(json) as T;
      default:
        throw ("类型转换错误,是否忘记添加了case!");
    }
  }
}
