<?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.unis.policy.info.modular.mlpDraftAudit.mapper.MlpDraftAuditMapper">
    <select id="select" resultType="com.unis.policy.info.modular.mlpDraftAudit.vo.MlpDraftAuditVO">
        select t1.*, t2.plan_content, t1.id draftAuditId
        from biz_mlp_draft_audit t1
                 join biz_mlp_draft_modify t2 on t1.draft_modify_id = t2.id
        where t1.id = #{id}
    </select>



    <select id="selectPlanningFinish"
            resultType="com.unis.policy.info.modular.mlpDraftAudit.vo.PlanningFinishVO">
        select a.*,b.id as draftAuditId
        from biz_mlp_draft_modify as a
        LEFT JOIN biz_mlp_draft_audit as b
        ON a.id = b.draft_modify_id
        where  a.id=#{id} ORDER BY b.create_time desc LIMIT 1
    </select>


    <select id="page" resultType="com.unis.policy.info.modular.mlpDraftAudit.vo.PlanningFinishPageVO">

        SELECT
        t1.id draftModifyId,
        t1.plan_name,
        t1.attachment,
        t1.plan_content,
        t2.id draftAuditId,
        t2.publish_time,
        t2.`status`
        FROM
        biz_mlp_draft_modify t1
        JOIN biz_mlp_draft_audit t2 ON t1.id = t2.draft_modify_id
        <where>
            t2.STATUS iN('1' ,'2')
            AND t1.delete_flag = 'NOT_DELETE' AND t2.delete_flag='NOT_DELETE'
            <if test="planName!=null and planName!=''">
                and t1.plan_name like concat("%",#{planName},"%")
            </if>
        </where>
        order by t2.publish_time desc
    </select>



</mapper>