package com.ningdatech.carapi.common.constant;

import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 * 公司类型
 * @author PoffyZhang
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "CompanyTypeEnum", description = "公司类型-枚举")
public enum CompanyTypeEnum {
    /**
     * 管理公司
     */
    ADMIN(1, "管理单位"),

    /**
     * 企业公司
     */
    ENTERPRISE(2, "企业单位");


    private Integer code;
    private String desc;

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static String getDescByCode(Integer code) {
        if(Objects.isNull(code)){
            return StringUtils.EMPTY;
        }
        for (CompanyTypeEnum t : CompanyTypeEnum.values()) {
            if (code.equals(t.getCode())) {
                return t.desc;
            }
        }
        return StringUtils.EMPTY;
    }


    public boolean eq(String val) {
        return this.name().equals(val);
    }

}
