package com.diagbot.facade;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.diagbot.dto.LibraryInfoDTO;
import com.diagbot.dto.TermDTO;
import com.diagbot.entity.LibraryInfo;
import com.diagbot.service.impl.LibraryInfoServiceImpl;
import com.diagbot.vo.TermVo;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Description: 术语基本信息查询业务层
 * @author: Weixuan Huang
 * @time: 2019/1/16 14:17
 */
@Component
public class LibraryInfoFacade extends LibraryInfoServiceImpl {

    /**
     * 获取医学术语基本信息
     *
     * @param termVo
     * @result LibraryInfo
     */
    public LibraryInfo getLibraryInfor(TermVo termVo) {
        QueryWrapper<LibraryInfo> wrapper = new QueryWrapper();

        if (termVo.getConcept_id() != 0) {
            wrapper.eq("concept_id", termVo.getConcept_id());
        }
        if (termVo.getId() != 0) {
            wrapper.eq("id", termVo.getId());
        }
        if (termVo.getTerm() != null) {
            wrapper.eq("name", termVo.getTerm());
        }
        if (termVo.getType() != null) {
            wrapper.eq("type", termVo.getType());
        }

        LibraryInfo libraryinfor = this.getOne(wrapper);
        return libraryinfor;
    }

}
