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

import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;

/**
 * 畜牧资源列表常量（v_livestock_resource）。
 */
public final class LivestockResourceRules
{
    public static final int DEFAULT_PAGE_NUM = 1;

    public static final int DEFAULT_PAGE_SIZE = 10;

    public static final int MAX_PAGE_SIZE = 50;

    /** 来源：biz_medical_resource */
    public static final int SOURCE_MEDICAL = 1;

    /** 来源：biz_tech_resource */
    public static final int SOURCE_TECH = 2;

    /** 专家团队（biz_medical_resource） */
    public static final String TYPE_EXPERT_TEAM = "004002";

    /** 技术成果 */
    public static final String TYPE_ACHIEVEMENT = "004006";

    /** 共享仪器 */
    public static final String TYPE_INSTRUMENT = "004007";

    /** 视频课程 */
    public static final String TYPE_VIDEO = "004008";

    public static final String NOT_FOUND_MSG = "该资源已下线或不存在";

    public static final String MSG_SOURCE_TYPE_REQUIRED = "来源类型不能为空";

    public static final String MSG_SOURCE_TYPE_INVALID = "来源类型无效，请使用 1（医疗）或 2（科技）";

    public static final String MSG_ID_REQUIRED = "资源主键不能为空";

    private static final Set<String> ALLOWED_TYPES = Collections.unmodifiableSet(new HashSet<>(
            Arrays.asList(TYPE_EXPERT_TEAM, TYPE_ACHIEVEMENT, TYPE_INSTRUMENT, TYPE_VIDEO)));

    private LivestockResourceRules()
    {
    }

    public static boolean isAllowedType(String typeCode)
    {
        return typeCode != null && ALLOWED_TYPES.contains(typeCode.trim());
    }

    public static boolean isAllowedSourceType(Integer sourceType)
    {
        return sourceType != null
                && (sourceType == SOURCE_MEDICAL || sourceType == SOURCE_TECH);
    }
}
