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

/**
 * 交易市场管理枚举与附件白名单。
 */
public final class TradeMarketRules
{
    public static final int OPERATE_STATUS_NORMAL = 1;

    public static final int OPERATE_STATUS_SUSPENDED = 2;

    public static final int OPERATE_STATUS_CANCELLED = 3;

    public static final String DEL_FLAG_NORMAL = "0";

    public static final String DEL_FLAG_DELETED = "2";

    public static final long MAX_PHOTO_BYTES = 10L * 1024 * 1024;

    private TradeMarketRules()
    {
    }

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

    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();
    }

    public static String operateStatusName(Integer operateStatus)
    {
        if (operateStatus == null)
        {
            return "";
        }
        switch (operateStatus)
        {
            case OPERATE_STATUS_NORMAL:
                return "正常";
            case OPERATE_STATUS_SUSPENDED:
                return "停业";
            case OPERATE_STATUS_CANCELLED:
                return "注销";
            default:
                return "";
        }
    }
}
