package com.diagbot.facade;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.diagbot.dto.RelationDTO;
import com.diagbot.entity.LexiconRelationship;
import com.diagbot.service.impl.LexiconRelationshipServiceImpl;
import org.springframework.stereotype.Component;

/**
 * @Description: 实体间关系信息查询业务层
 * @author: Weixuan Huang
 * @time: 2019/2/1 16:07
 */
@Component
public class RelationshipFacade extends LexiconRelationshipServiceImpl {

    /**
     * 获取术语间关系名称
     *
     * @param relationDTO
     * @result LexiconRelationship
     */
    public LexiconRelationship getLexiconRelationship(RelationDTO relationDTO) {

        QueryWrapper<LexiconRelationship> wrapper = new QueryWrapper<>();
        LexiconRelationship lexiconRelationship = null;

        if (relationDTO.getRelationId() != 0) {
            wrapper.eq("id", relationDTO.getRelationId());
        }

        lexiconRelationship = this.getOne(wrapper);

        return lexiconRelationship;
    }
}
