package com.chushang.inspection.work.enums;


import cn.hutool.core.util.StrUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum TerminalTypeOperation {
    NEW_INSTALLATION("001", 4),
    INSPECTION("002", 5),
    REMOVAL("003", 3),
    REPLACEMENT("004", 2);



    private final String code;
    private final Integer terminalType;


    // 通过编号获取枚举值
    public static Integer valueOfCode(String code) {
        if (StrUtil.isEmpty(code)) {
            return null;
        }
        for (TerminalTypeOperation operation : TerminalTypeOperation.values()) {
            if (operation.code.equals(code)) {
                return operation.terminalType;
            }
        }
        return null;
    }

    // 通过编号获取枚举值
    public static String valueOfTerminalType(Integer workType) {
        if (workType == null) {
            return null;
        }
        for (TerminalTypeOperation operation : TerminalTypeOperation.values()) {
            if (operation.terminalType.equals(workType)) {
                return operation.code;
            }
        }
        return null;
    }

}
