import 'package:zhiying_base_widget/dialog/global_dialog/intellect_search_goods_dialog/model/no_goods_dialog_style_model.dart';
import 'package:zhiying_comm/zhiying_comm.dart';

class CustomBannerModel {
  String name;
  String desc;
  String moduleType;
  String moduleKey;
  String isTopMargin;
  String isLeftRightMargin;
  String isShow;
  String topMargin;
  String leftRightMargin;
  String topLeftRadius;
  String topRightRadius;
  String bottomLeftRadius;
  String bottomRightRadius;
  List<CustomBannerListStyle> listStyle;
  int moduleKeyId;

  CustomBannerModel({
    this.name,
    this.desc,
    this.moduleType,
    this.moduleKey,
    this.isTopMargin,
    this.isLeftRightMargin,
    this.isShow,
    this.topMargin,
    this.leftRightMargin,
    this.listStyle,
    this.moduleKeyId,
    this.topLeftRadius,
    this.topRightRadius,
    this.bottomLeftRadius,
    this.bottomRightRadius,
  });

  CustomBannerModel.fromJson(Map<String, dynamic> json) {
    name = json['name'];
    desc = json['desc'];
    moduleType = json['module_type'];
    moduleKey = json['module_key'];
    isTopMargin = json['is_top_margin'];
    isLeftRightMargin = json['is_left_right_margin'];
    isShow = json['is_show'];
    topMargin = json['top_margin'];
    leftRightMargin = json['left_right_margin'];
    topLeftRadius = json['top_left_radius'];
    topRightRadius = json['top_right_radius'];
    bottomLeftRadius = json['bottom_left_radius'];
    bottomRightRadius = json['bottom_right_radius'];
    if (json['list_style'] != null) {
      listStyle = new List<CustomBannerListStyle>();
      json['list_style'].forEach((v) {
        listStyle.add(new CustomBannerListStyle.fromJson(v));
      });
    }
    moduleKeyId = json['module_key_id'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['name'] = this.name;
    data['desc'] = this.desc;
    data['module_type'] = this.moduleType;
    data['module_key'] = this.moduleKey;
    data['is_top_margin'] = this.isTopMargin;
    data['is_left_right_margin'] = this.isLeftRightMargin;
    data['is_show'] = this.isShow;
    data['top_margin'] = this.topMargin;
    data['left_right_margin'] = this.leftRightMargin;
    data['top_left_radius'] = this.topLeftRadius;
    data['top_right_radius'] = this.topRightRadius;
    data['bottom_left_radius'] = this.bottomLeftRadius;
    data['bottom_right_radius'] = this.bottomRightRadius;
    if (this.listStyle != null) {
      data['list_style'] = this.listStyle.map((v) => v.toJson()).toList();
    }
    data['module_key_id'] = this.moduleKeyId;
    return data;
  }
}

class CustomBannerListStyle extends SkipModel {
  String name;
  String img;
  String locationType;
  String locationName;
  String requiredLogin;
  String requiredTaobaoAuth;
  String skipIdentifier;

  CustomBannerListStyle({this.name, this.img, this.locationType, this.locationName, this.requiredLogin, this.requiredTaobaoAuth, this.skipIdentifier});

  CustomBannerListStyle.fromJson(Map<String, dynamic> json) {
    super.fromJson(json);
    name = json['name'];
    img = json['img'];
    locationType = json['location_type']?.toString();
    locationName = json['location_name']?.toString();
    requiredLogin = json['required_login']?.toString();
    requiredTaobaoAuth = json['required_taobao_auth'];
    skipIdentifier = json['skip_identifier']?.toString();
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = super.toJson();

    data['name'] = this.name;
    data['img'] = this.img;
    data['location_type'] = this.locationType;
    data['location_name'] = this.locationName;
    data['required_login'] = this.requiredLogin;
    data['required_taobao_auth'] = this.requiredTaobaoAuth;
    data['skip_identifier'] = this.skipIdentifier;
    return data;
  }
}
