package com.ningdatech.pmapi.meta.helper;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ningdatech.pmapi.expert.entity.ExpertUserFullInfo;
import com.ningdatech.pmapi.expert.service.IExpertUserFullInfoService;
import com.ningdatech.pmapi.meta.model.ExpertRegionInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * @author liuxinxin
 * @date 2022/8/30 下午2:17
 * 公共专家相关信息工具类 用于获取专家的一些基础信息
 */
@Component
@RequiredArgsConstructor
public class ExpertUserInfoHelperImpl implements ExpertUserInfoHelper {

    private final IExpertUserFullInfoService iExpertUserFullInfoService;

    /**
     * 获取专家
     *
     * @param expertUserId
     * @return
     */
    @Override
    public ExpertUserFullInfo getExpertBasicFullInfo(Long expertUserId) {
        ExpertUserFullInfo one = iExpertUserFullInfoService
                .getOne(Wrappers.lambdaQuery(ExpertUserFullInfo.class).eq(ExpertUserFullInfo::getUserId, expertUserId));
        return one;
    }

    /**
     * 获取专家层级
     *
     * @param expertUserId
     * @return
     */
    @Override
    public ExpertRegionInfo getExpertRegionInfo(Long expertUserId) {
        ExpertUserFullInfo one = getExpertBasicFullInfo(expertUserId);

        Integer regionLevel = one.getRegionLevel();
        String regionCode = one.getRegionCode();
        ExpertRegionInfo expertRegionInfo = new ExpertRegionInfo();
        expertRegionInfo.setRegionCode(regionCode);
        expertRegionInfo.setRegionLevel(regionLevel);
        return expertRegionInfo;
    }

//    /**
//     * 专家是否已经出库
//     */
//    public Boolean isDelivery(Long expertUserId) {
//        ExpertUserFullInfo one = getExpertBasicFullInfo(expertUserId);
//        if (Objects.isNull(one)) {
//            return true;
//        }
//        return ExpertAccountStatusEnum.DELIVERY.getKey().equals(one.getExpertAccountStatus());
//    }

}
