package com.hz.pm.api.staging.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Objects;

/**
 * 消息类型枚举
 *
 * @author CMM
 * @since 2023/02/28 17:34
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum MsgTypeEnum {
    /**
     * 项目待审核
     */
    PROJECT_REVIEW(1, "项目审核"),
    /**
     * 预警提醒
     */
    WARING(2, "预警提醒"),
    /**
     * 专家评审
     */
    EXPERT_REVIEW(3, "专家评审"),
    /**
     * 评审会议
     */
    REVIEW_MEETING(4, "评审会议"),
    /**
     * 项目审核被退回
     */
    PROJECT_REVIEW_BACK(5, "项目审核"),
    /**
     * 项目审核通过
     */
    PROJECT_REVIEW_PASS(6, "项目审核"),
    /**
     * 项目审核驳回
     */
    PROJECT_REVIEW_REJECT(7, "项目审核"),

    PROJECT_REVIEW_CC(8, "项目抄送");

    private Integer code;
    private String desc;

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

    public static String getDescByName(String name) {
        if (StringUtils.isBlank(name)) {
            return StringUtils.EMPTY;
        }
        for (MsgTypeEnum t : MsgTypeEnum.values()) {
            if (name.equals(t.name())) {
                return t.desc;
            }
        }
        return StringUtils.EMPTY;
    }

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


}
