package com.diagbot.facade;

import com.diagbot.client.TranServiceClient;
import com.diagbot.dto.RespDTO;
import com.diagbot.dto.TranFieldInfoDTO;
import com.diagbot.exception.CommonErrorCode;
import com.diagbot.exception.CommonException;
import com.diagbot.vo.TranFieldInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Description:
 * @author: wangyu
 * @time: 2018/11/21 14:13
 */
@Component
public class TranFieldInfoFacade {

    @Autowired
    TranServiceClient tranServiceClient;

    /**
     * 根据uuid获取相关信息
     *
     * @param info
     * @return
     */
    public List<TranFieldInfoDTO> getInfoByUuid(TranFieldInfoVO info) {
        RespDTO<List<TranFieldInfoDTO>> tranFieldInfoDTOList = tranServiceClient.getInfoByUuid(info);
        if (tranFieldInfoDTOList == null || !CommonErrorCode.OK.getCode().equals(tranFieldInfoDTOList.code)) {
            throw new CommonException(CommonErrorCode.RPC_ERROR,
                    "获取医生信息失败");
        }
        return tranFieldInfoDTOList.data;
    }
}
