<?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.njcn.system.mapper.TemplateRelMapper">
    <insert id="batchInsert">
        INSERT INTO report_relevancy
        (Rt_Id,Rd_Id)
        VALUES
        <foreach collection="list" item="item" index="index" separator=",">
        (#{item.rtId},
        #{item.rdId})
        </foreach>
    </insert>

    <delete id="deleteByRtId">
        DELETE FROM report_relevancy WHERE Rt_Id=#{rtId}
    </delete>

    <select id="selectRelevance" resultType="TemplateRel">
        select report_relevancy.*
        from report_relevancy report_relevancy
        where report_relevancy.Rt_id in
        <foreach collection="ids" item="item" index="index"  open="(" separator="," close=")">
            #{item}
        </foreach>
    </select>
    <select id="selectReleation" resultType="java.lang.String">
        SELECT
        rd.Name
        FROM report_relevancy rr
        INNER JOIN report_dict rd ON rr.Rd_Id = rd.Id
        WHERE rr.Rt_Id = #{id}
    </select>
</mapper>
