/**
 * 分发状态枚举，定义数据分发的不同状态
 *
 * @version 1.0
 * @since 2025
 */
package com.xdap.self_development.domain.enums;

import lombok.Getter;

@Getter
public enum DistributeStatusEnum {

    /**
     * 已分发
     */
    DISTRIBUTED(1, "已分发"),
    /**
     * 未分发
     */
    UNDISTRIBUTED(2, "未分发"),
    /**
     * 部分分发
     */
    PART(3, "部分分发"),

    COMPLETE(4, "已完成");

    /**
     * 编码
     */
    private final Integer code;
    /**
     * 描述
     */
    private final String desc;

    DistributeStatusEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static DistributeStatusEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (DistributeStatusEnum status : values()) {
            if (status.code.equals(code)) {
                return status;
            }
        }
        return null;
    }

    public static DistributeStatusEnum getByDesc(String desc) {
        if (desc == null) {
            return null;
        }
        for (DistributeStatusEnum status : values()) {
            if (status.desc.equals(desc)) {
                return status;
            }
        }
        return null;
    }
}
