package com.oqpo.api.enums;

import com.oqpo.api.exception.GlobalException;
import lombok.Getter;
import lombok.Setter;

public enum ItemType {

    R01("IT00", "소모품"), //
    R02("IT01", "자산용"), //
    ;

    ItemType(String cd, String nm) {
        this.cd = cd;
        this.name = nm;
    }

    @Getter
    @Setter
    private String cd;

    @Getter
    @Setter
    private String name;

    public static String getCd(String nname) {
        ItemType[] values = ItemType.values();
        for (ItemType icd : values) {
            if (icd.name.equals(nname)) {
                return icd.cd;
            }
        }
        return nname;
    }

    public static String getName(String ccd) {
        ItemType[] values = ItemType.values();
        for (ItemType icd : values) {
            if (icd.cd.equals(ccd)) {
                return icd.name;
            }
        }
        return ccd;
    }

}
