/*
 * @Author: XianKaiQun
 * @Date: 2020-09-10 14:33:43
 * @LastEditors: ChenYaJin
 * @LastEditTime: 2021-11-02 09:36:09
 * @Description: 
 */
import 'package:wisdom_cli/wisdom_ui.dart';

///小区-楼栋-单元-楼层-房屋通用
class CascadeModel implements WPickerEntity {
  String? id;
  String? name;
  String? status;
  bool? disabled;

  CascadeModel({
    this.id,
    this.name,
    this.status,
    this.disabled = false,
  });

  CascadeModel.fromJson(json) {
    Map<String, dynamic> map = Map.from(json ?? {});

    id = map['id'].toString();
    name = map['name'];
    status = map['status'];
    disabled = map['disabled'] ?? this.disabled;
  }

  Map<String, dynamic> toJson() {
    Map<String, dynamic> json = Map<String, dynamic>();

    json['id'] = this.id;
    json['name'] = this.name;
    json['status'] = this.status;
    json['disabled'] = this.disabled;
    return json;
  }

  @override
  String get selectName => this.name ?? '';

  @override
  get selectUnique => '$id--$status-$name';

  @override
  bool get selectDisabled => this.disabled ?? false;
}

class EnumModel implements WPickerEntity {
  String? code;
  String? name;
  bool? disabled;

  EnumModel({
    this.code,
    this.name,
    this.disabled = false,
  });

  EnumModel.fromJson(json) {
    Map<String, dynamic> map = Map.from(json ?? {});

    code = map['code'].toString();
    name = map['name'];
    disabled = map['disabled'] ?? this.disabled;
  }

  Map<String, dynamic> toJson() {
    Map<String, dynamic> json = Map<String, dynamic>();

    json['code'] = this.code;
    json['name'] = this.name;
    json['disabled'] = this.disabled;

    return json;
  }

  @override
  String get selectName => this.name ?? '';

  @override
  get selectUnique => this.code ?? '';

  @override
  bool get selectDisabled => this.disabled ?? false;
}
