package shop.alien.util.common.constant;

/**
 * 订单操作类型枚举
 */
public enum OrderActionType {
    /**
     * 接单
     */
    ACCEPT("1", "接单"),
    
    /**
     * 取消
     */
    CANCEL("2", "取消");

    private final String code;
    private final String description;

    OrderActionType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 根据code获取枚举
     *
     * @param code 操作类型代码
     * @return 枚举值，如果不存在则返回null
     */
    public static OrderActionType getByCode(String code) {
        if (code == null) {
            return null;
        }
        for (OrderActionType type : OrderActionType.values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        return null;
    }
}

