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

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.ruoyi.web.modules.diagnosis.support.DiagnosisPageHelperGuard;
import com.ruoyi.web.modules.farming.domain.BizTechResource;
import com.ruoyi.web.modules.farming.mapper.BizTechResourceMapper;

/**
 * 解析当前登录用户绑定的科技专家资源 ID。
 */
@Component
public class ExpertProviderResolver
{
    @Autowired
    private BizTechResourceMapper bizTechResourceMapper;

    public Long resolveProviderId(Long sysUserId)
    {
        if (sysUserId == null)
        {
            return null;
        }
        BizTechResource resource = DiagnosisPageHelperGuard.withoutPaging(
                () -> bizTechResourceMapper.selectExpertResourceBySysUserId(sysUserId));
        return resource == null ? null : resource.getId();
    }
}
