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

/**
 * 项目与补贴-项目发布状态与封面白名单。
 */
public final class SubsidyProjectRules
{
    public static final int EXEC_NOT_STARTED = 1;

    public static final int EXEC_IN_PROGRESS = 2;

    public static final int EXEC_COMPLETED = 3;

    public static final int MANUAL_FLAG_AUTO = 0;

    public static final int MANUAL_FLAG_LOCKED = 1;

    private SubsidyProjectRules()
    {
    }

    public static boolean canEdit(Integer publishStatus)
    {
        return publishStatus != null && publishStatus == 0;
    }

    public static boolean canDelete(Integer publishStatus)
    {
        return publishStatus != null && publishStatus == 0;
    }

    public static boolean canPublish(Integer publishStatus)
    {
        return publishStatus != null && publishStatus == 0;
    }

    public static boolean canOffline(Integer publishStatus)
    {
        return publishStatus != null && publishStatus == 1;
    }

    public static boolean isCoverExtensionAllowed(String filenameOrPath)
    {
        String ext = extensionOf(filenameOrPath);
        return ext.equals("jpg") || ext.equals("jpeg") || ext.equals("png");
    }

    public static String extensionOf(String name)
    {
        if (name == null)
        {
            return "";
        }
        int i = name.lastIndexOf('.');
        if (i < 0 || i == name.length() - 1)
        {
            return "";
        }
        return name.substring(i + 1).toLowerCase();
    }
}
