package com.shanghaichengdi.ghjgitem.enums;

import com.shanghaichengdi.ghjgitem.exception.EnumException;
import java.util.Arrays;
import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor
@Getter
public enum DangerDeclareGoodsEnum {
  MIN_HANG("闵行区", "310112"),
  BAO_SHAN("宝山区", "310113"),
  JIA_DING("嘉定区", "310114"),
  PU_DONG_XIN_QU("浦东新区", "310115"),
  JIN_SHAN("金山区", "310116"),
  SONG_JIANG("松江区", "310117"),
  QING_PU("青浦区", "310118"),
  FENG_XIAN("奉贤区", "310120"),
  LIN_GANG("临港新片区", "310130"),
  CHONG_MING("崇明区", "310230");

  String district;
  String code;

  public static DangerDeclareGoodsEnum getEnumByDistrict(String district) {
    return Arrays.stream(values()).filter(x -> x.getDistrict().equals(district))
        .findFirst().orElseThrow(() -> new EnumException("不合法的区域名"));
  }
}
