package com.ningdatech.pmapi.common.helper.basic;

import com.ningdatech.pmapi.common.helper.RegionCacheHelper;
import com.ningdatech.pmapi.common.helper.RegionLimitHelper;
import com.ningdatech.pmapi.expert.entity.ExpertUserFullInfo;
import com.ningdatech.pmapi.expert.service.IExpertUserFullInfoService;
import com.ningdatech.pmapi.meta.model.ExpertRegionInfo;
import lombok.AllArgsConstructor;

import java.util.Objects;

/**
 * <p>
 * AbstractRegionLimitHelper
 * </p>
 *
 * @author WendyYang
 * @since 14:35 2023/3/1
 */
@AllArgsConstructor
public abstract class AbstractRegionLimitHelper implements RegionLimitHelper {

    protected final RegionCacheHelper regionCache;
    protected final IExpertUserFullInfoService expertUserFullInfoService;


    /**
     * 根据 专家用户id 获取专家层级
     *
     * @param expertUserId /
     * @return /
     */
    protected ExpertRegionInfo getExpertRegionInfo(Long expertUserId) {
        ExpertUserFullInfo userFullInfo = expertUserFullInfoService.getByUserId(expertUserId);
        if (Objects.isNull(userFullInfo)) {
            return new ExpertRegionInfo();
        }
        ExpertRegionInfo regionInfo = new ExpertRegionInfo();
        regionInfo.setRegionCode(userFullInfo.getRegionCode());
        regionInfo.setRegionLevel(userFullInfo.getRegionLevel());
        return regionInfo;
    }

}
