package cn.axzo.msg.center.common.enums;

import cn.axzo.msg.center.common.exception.ServiceException;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
 * 项目名称：profiles
 * 类 名 称：OuType
 * 类 描 述：
 * 创建时间：2022/5/13 14:41
 * 创 建 人：xuyaozuo
 */
@RequiredArgsConstructor
@Getter
public enum OuType implements IEnum {
    OTHERS(0, "OTHERS"),
    CONTRACTOR_UNIT(1, "CONTRACTOR_UNIT"),
    BUILDING_UNIT(2, "BUILDING_UNIT"),
    LAB_SUBCONTRACTOR_UNIT(3, "LAB_SUBCONTRACTOR_UNIT"),
    PROFESSIONAL_SUBCONTRACTOR_UNIT(4, "PROFESSIONAL_SUBCONTRACTOR_UNIT"),
    SUPERVISING_UNIT(5, "SUPERVISING_UNIT"),
    WORKER_GROUP(6, "WORKER_GROUP"),
    ;
    @EnumValue
    private final Integer code;
    private final String message;

    public static OuType getOuType(Integer code) {
        OuType[] values = values();
        for (OuType item : values) {
            if (item.getCode().equals(code)) {
                return item;
            }
        }
        throw new ServiceException("班组类型不匹配 code:" + code);
    }
}
