package com.diagbot.facade;

import com.diagbot.dto.LibraryDTO;
import com.diagbot.dto.TermDTO;
import com.diagbot.service.impl.LibraryServiceImpl;
import com.diagbot.vo.TermVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * @Description: 术语查询业务层
 * @author: Weixuan Huang
 * @time: 2019/1/14 16:17
 */
@Component
public class LibraryFacade extends LibraryServiceImpl {

    @Autowired
    private InformationFacade informationFacade;
    @Autowired
    private MedicalFacade medicalFacade;


    /**
     * 获取医学术语信息
     *
     * @param termvo
     * @return TermDTO
     */
    public TermDTO getTermInfo(@RequestBody TermVo termvo) {

        TermDTO termDTO = new TermDTO();
        LibraryDTO libraryDTO = getLibrary(termvo);
        // 获取与医学术语的基本信息
        termDTO.setLibrary(libraryDTO);
        // 获取与术语相关的医学知识
        termDTO.setInformation(informationFacade.getInfor(libraryDTO));
        // 获取与术语相关的临床医学信息
//        termDTO.setMedicalInfo(medicalFacade.getInfor(libraryDTO));
//        // 获取术语的所有上级信息
//        List<LevelDTO> levelDTOList = levelFacade.getInfor(libraryDTO);
//        for (LevelDTO item : levelDTOList) {
//            while (item.getUplevel() != null) {
//                item.setUplevel_val(getOne("id", item.getUplevel().toString()).getName());
//                item.setGrpId_val(getOne("id", item.getGrpId().toString()).getName());
//            }
//        }
//        termDTO.setLevelInfo(levelDTOList);

        return termDTO;
    }

    /**
     * 获取术语基本信息
     *
     * @param termVo
     * @return
     */
    public LibraryDTO getTerm(@RequestBody TermVo termVo) {
        LibraryDTO libraryDTO = getLibrary(termVo);

        return  libraryDTO;
    }

}
