<?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.yeejoin.amos.knowledgebase.face.orm.dao.TagValueMapper">

    <select id="queryTagValuesByDocId" parameterType="long" resultType="com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagValue">
        SELECT
        tv.`INSTANCE_SEQ` instanceSeq,
        tv.`FIELD_NAME` fieldName,
        tv.`TAG_VALUE` tagValue,
        tv.`AGENCY_CODE` agencyCode,
        tv.`UNIT` unit
        FROM `knowledge_tag_instance` ti
          INNER JOIN `knowledge_tag_value` tv
            ON ti.`SEQUENCE_NBR` = tv.`INSTANCE_SEQ`
        WHERE ti.`TARGET_SEQ` = #{docSeq}
    </select>

    <select id="queryTagValuesByDocIds" parameterType="collection" resultType="com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagValue">
        SELECT
        tv.`INSTANCE_SEQ` instanceSeq,
        tv.`FIELD_NAME` fieldName,
        tv.`TAG_VALUE` tagValue,
        tv.`AGENCY_CODE` agencyCode,
        tv.`UNIT` unit
        FROM `knowledge_tag_instance` ti
          INNER JOIN `knowledge_tag_value` tv
            ON ti.`SEQUENCE_NBR` = tv.`INSTANCE_SEQ`
        WHERE ti.`TARGET_SEQ` in
          <foreach collection="docIds" open="(" close=")" separator="," item="docSeq">
            #{docSeq}
          </foreach>
    </select>
</mapper>
