<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.diagbot.mapper.ConceptMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.diagbot.entity.Concept">
        <id column="id" property="id" />
        <result column="lib_id" property="libId" />
        <result column="gmt_created" property="gmtCreated" />
        <result column="gmt_modified" property="gmtModified" />
    </resultMap>

    <select id="getConcept" parameterType="com.diagbot.vo.TermVo" resultType="com.diagbot.dto.ConceptDTO">
        SELECT
        a.id, a.lib_id, a.gmt_created, a.gmt_modified
        FROM concept a WHERE a.id IN (
            SELECT concept_id FROM library_info
            WHERE name = #{term} and type = #{type}
        )
    </select>

    <select id="getLimboItems" resultType="com.diagbot.dto.ConceptDTO">
        SELECT * FROM concept WHERE lib_id NOT in
        (
            SELECT id FROM library_info WHERE is_concept = 1
        )
    </select>
</mapper>
