package cn.iocoder.lyzsys.module.tjt.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

/**
 * 项目状态枚举。
 */
@Getter
@AllArgsConstructor
public enum ProjectStatusEnum {

    IN_PROGRESS("in_progress", "进行中"),
    COMPLETED("completed", "完成"),
    PAUSED("paused", "暂停"),
    TERMINATED("terminated", "中止");

    private final String code;
    private final String label;

    public static ProjectStatusEnum of(String code) {
        return Arrays.stream(values())
                .filter(item -> item.getCode().equals(code))
                .findFirst()
                .orElse(null);
    }

    public static boolean contains(String code) {
        return of(code) != null;
    }

    public static String labelOf(String code) {
        ProjectStatusEnum item = of(code);
        return item == null ? code : item.getLabel();
    }

}
