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

import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.web.modules.diagnosis.domain.BizMedicalResource;
import com.ruoyi.web.modules.diagnosis.support.MedicalResourceMultiValueCodec;
import com.ruoyi.web.modules.diagnosis.support.MedicalResourceRules;
import com.ruoyi.web.modules.farming.domain.BizTechResource;
import com.ruoyi.web.modules.farming.support.TechResourceMultiValueCodec;
import com.ruoyi.web.modules.farming.support.TechResourceRules;

/**
 * 移动端畜牧资源详情：可见性校验与字段解码。
 */
public final class LivestockResourceDetailSupport
{
    private LivestockResourceDetailSupport()
    {
    }

    public static void assertVisibleMedical(BizMedicalResource row)
    {
        if (row == null
                || !MedicalResourceRules.isPublished(row.getPublishStatus())
                || !LivestockResourceRules.TYPE_EXPERT_TEAM.equals(row.getResourceType()))
        {
            throw new ServiceException(LivestockResourceRules.NOT_FOUND_MSG);
        }
    }

    public static void assertVisibleTech(BizTechResource row)
    {
        if (row == null
                || !TechResourceRules.isPublished(row.getPublishStatus())
                || !LivestockResourceRules.isAllowedType(row.getResourceType()))
        {
            throw new ServiceException(LivestockResourceRules.NOT_FOUND_MSG);
        }
    }

    public static void enrichMedical(BizMedicalResource row)
    {
        if (row != null)
        {
            MedicalResourceMultiValueCodec.decodeLists(row);
        }
    }

    public static void enrichTech(BizTechResource row)
    {
        if (row != null)
        {
            TechResourceMultiValueCodec.decodeLists(row);
        }
    }
}
