package com.zd.common.core.enums;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.zd.common.core.domain.hazard.HardwareType;

import java.util.Arrays;

/**
 * 硬件类型枚举
 */
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
public enum HardwareTypeEnum implements BaseEnum<Integer>, HardwareType {

    ONE_MACHINE(0, "一体机", ""),
    SWITCH(1, "电源开关", ""),
    AI_VENTILATION(2, "智能通风", ""),
    VOICE_INTERCOM(3, "语音对讲", ""),
    VIDEO_MONITOR(4, "视频监控", ""),
    AI_TERMINAL(5, "智能终端", ""),
    AI_DOORLOCK(6, "智能门锁", ""),
    RFID_RECOGNIZER(7, "RFID识别器", ""),
    AI_ALARM(8, "智能报警器", ""),
    AI_CABINETLOCK(9, "智能柜锁", "");



    private final Integer code;
    private final String name;
    private final String img;

    HardwareTypeEnum(int code, String name, String img) {
        this.code = code;
        this.name = name;
        this.img = img;
    }

    public static HardwareTypeEnum getByCode(Integer code) {
        return Arrays.stream(HardwareTypeEnum.values()).filter(a -> a.code.equals(code)).findFirst().orElse(null);
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public String getImg() {
        return img;
    }

    @Override
    public Integer getDictKey() {
        return code;
    }

    @Override
    public Integer getHardwareTypeCode() {
        return code;
    }

    @Override
    public String getHardwareTypeName() {
        return name;
    }

    public String getEnumName() {
        return super.toString();
    }
}
