<?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="org.jeecg.modules.stm.baosong.mapper.BaosongTaskReviewMapper">

    <select id="queryTaskReview" resultType="java.util.Map">
        SELECT
            A.id AS taskid,
            B.id AS tplid,
            A.name AS taskName,
            A.tp,
            B.nm AS tplName,
            B.code,
            B.xmlfile_path AS xmlfilePath
        FROM baosong_task A
                 INNER JOIN baosong_tpl B ON A.tp = B.tp
        ORDER BY A.id, B.code
    </select>

    <select id="queryTaskRecordForXml" resultType="java.util.Map">
        SELECT
        A.content,
        A.taskid,
        A.itemid,
        A.rind,
        B.tplid,
        B.code,
        B.pcode,
        B.title
        FROM baosong_task_record A
        RIGHT JOIN baosong_tpl_item B ON A.itemid = B.id
        <where>
            <if test="query.taskid != null">
                AND A.taskid = #{query.taskid}
            </if>
            <if test="query.tplid != null">
                AND B.tplid = #{query.tplid}
            </if>
        </where>
        ORDER BY B.id, B.pcode, B.code
    </select>

</mapper>