package com.ruoyi.web.modules.technology.support;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.web.modules.farming.support.TechResourceRules;

/**
 * 网上培训课程只读查询规则。
 */
public final class OnlineTrainingCourseRules
{
    public static final String NOT_FOUND_MSG = "该课程已下线或不存在";

    public static final String DEFAULT_VIDEO_FILE_LABEL = "已上传";

    private OnlineTrainingCourseRules()
    {
    }

    public static String resourceTypeVideo()
    {
        return TechResourceRules.RESOURCE_TYPE_VIDEO;
    }

    public static int publishStatusPublished()
    {
        return TechResourceRules.PUBLISH_STATUS_PUBLISHED;
    }

    public static String delFlagNormal()
    {
        return TechResourceRules.DEL_FLAG_NORMAL;
    }

    public static String resolveVideoFileName(String videoFilePath)
    {
        if (StringUtils.isEmpty(videoFilePath))
        {
            return DEFAULT_VIDEO_FILE_LABEL;
        }
        String normalized = videoFilePath.replace('\\', '/');
        int slash = normalized.lastIndexOf('/');
        String name = slash >= 0 ? normalized.substring(slash + 1) : normalized;
        return StringUtils.isNotEmpty(name) ? name : DEFAULT_VIDEO_FILE_LABEL;
    }
}
