package com.shanghaichengdi.ghjgitem.enums;

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

@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum SupervisionAreaCode {
  CITY_CENTER("01", "市港航中心"),
  PD("02", "浦东"),
  BAO_SHAN("03", "宝山"),
  MIN_HANG("04", "闵行"),
  JIA_DING("05", "嘉定"),
  JIN_SHAN("06", "金山"),
  SONG_JIANG("07", "松江"),
  QING_PU("08", "青浦"),
  FENG_XIAN("09", "奉贤"),
  CHONG_MING("10", "崇明"),
  LIN_GANG("11", "临港");

  String code;
  String area;

  public static SupervisionAreaCode getByCode(String code) {
    return Arrays.stream(values())
        .filter(supervisionAreaCode -> supervisionAreaCode.getCode().equals(code))
        .findFirst().orElseThrow(() -> new EnumException("行业监管区域编号错误"));
  }
}
