package com.ningdatech.pmapi.expert.helper;

import com.ningdatech.pmapi.expert.model.dto.ExpertFullInfoAllDTO;
import com.ningdatech.pmapi.expert.model.dto.ExpertUserFullInfoDTO;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * @author liuxinxin
 * @date 2022/7/28 上午10:18
 */
@Component
public class ExpertInfoCommonHelper {

    /**
     * 获取专家的所有文件id
     * 头像,学位证书，毕业证书，推荐证明材料，职称证明
     *
     * @param expertUserFullInfoAll
     * @return
     */
    public List<Long> getExpertFileIdList(ExpertFullInfoAllDTO expertUserFullInfoAll) {
        ExpertUserFullInfoDTO expertUserInfoDTO = expertUserFullInfoAll.getExpertUserInfoDTO();
        List<Long> fileIdList = new ArrayList<>();
        if (Objects.nonNull(expertUserInfoDTO.getAvatarFileId())) {
            fileIdList.add(expertUserInfoDTO.getAvatarFileId());
        }
        if (CollectionUtils.isNotEmpty(expertUserInfoDTO.getDegreeCertificateFileIdList())) {
            fileIdList.addAll(expertUserInfoDTO.getDegreeCertificateFileIdList());
        }
        if (CollectionUtils.isNotEmpty(expertUserInfoDTO.getGraduationCertificateFileIdList())) {
            fileIdList.addAll(expertUserInfoDTO.getGraduationCertificateFileIdList());
        }
        if (CollectionUtils.isNotEmpty(expertUserInfoDTO.getRecommendationProofFileIdList())) {
            fileIdList.addAll(expertUserInfoDTO.getRecommendationProofFileIdList());
        }
        if (CollectionUtils.isNotEmpty(expertUserInfoDTO.getTitleCertificateFileIdList())) {
            fileIdList.addAll(expertUserInfoDTO.getTitleCertificateFileIdList());
        }
        return fileIdList;
    }
}
