<?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.ai.da.mapper.primary.TagsMapper">

    <select id="getMatchingTags" resultType="java.util.List">
        SELECT id, tag_name, MATCH(tag_name) AGAINST(#{userInput}) AS relevance
        FROM t_tags
        WHERE MATCH(tag_name) AGAINST(#{userInput})
        ORDER BY relevance DESC;
    </select>

    <select id="getTagByPortfolioId" resultType="com.ai.da.mapper.primary.entity.Tags">
        SELECT t.*
        FROM t_tags t
        JOIN t_portfolio_tags pt ON t.id = pt.tag_id
        WHERE pt.portfolio_id = #{portfolioId};
    </select>


</mapper>
