package com.chushang.inspection.terminal.enums;


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

@Getter
@AllArgsConstructor
public enum MerTypeOperation {
    // 1-POS 商户，2-条码支付商户
    POS_MERCHANT("1", 7),
    BARCODE_PAYMENT_MERCHANT("2", 8);

    private final String code;
    private final Integer merType;

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

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

}
