<?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.PortfolioMapper">


    <select id="getByIdAll" resultType="com.ai.da.mapper.primary.entity.Portfolio">
        select
            *
        from portfolio
        where id = #{originalPortfolioId}
    </select>

    <select id="getByTag" resultType="com.ai.da.mapper.primary.entity.Portfolio">
        SELECT p.*
        FROM portfolio p
                 JOIN t_portfolio_tags pt ON p.id = pt.portfolio_id
                 JOIN t_tags t ON pt.tag_id = t.id
        WHERE p.account_id = #{accountId}
          AND t.tag_name = #{tagName};
    </select>

</mapper>
