package com.ningdatech.carapi.industry.enums;

import java.util.Objects;

import org.apache.commons.lang3.StringUtils;

import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * @return
 * @author CMM
 * @since 2023/01/04 11:03
 */

@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "AddTypeEnum", description = "证书添加类型-枚举")
public enum AddTypeEnum {
    /**
     * 证书新增类型
     */
    NEW(1,"新增"),
    REPLACE(2,"换证");

    private  Integer code;
    private  String desc;

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

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

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