package com.yuchen.saas.park.api.enums.property;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * 1:园区 2:楼栋 3:单元 4:楼层 5:房间
 */
@Getter
@AllArgsConstructor
public enum SourceTypeEnum {
    PARK(1, "园区"),
    BUILDING(2, "楼栋"),
    UNIT(3, "单元"),
    FLOOR(4, "楼层"),
    HOUSE(5, "房间");

    private final Integer value;
    private final String desc;

    public static String getDescByCode(Integer value) {
        if (Objects.isNull(value)) {
            return "";
        }
        SourceTypeEnum[] enumArray = SourceTypeEnum.values();
        for (SourceTypeEnum e : enumArray) {
            if (e.getValue().equals(value)) {
                return e.getDesc();
            }
        }
        return "";
    }
    public static SourceTypeEnum matchCode(Integer value) {
        for (SourceTypeEnum shareTypeEnum : SourceTypeEnum.values()) {
            if (shareTypeEnum.getValue().equals(value)) {
                return shareTypeEnum;
            }
        }
        return null;
    }

}
