<?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.dromara.zjk.mapper.ZjkProductReviewsnMapper">

    <select id="selectDocumentPage" resultType="org.dromara.zjk.domain.vo.ZjkProductReviewsnVo">

        SELECT *, zp.product_name
        FROM (SELECT zpr.product_id, zpr.review_Sn, 2 AS type, so.*, zpr.create_time
              FROM zjk_product_reviewsn zpr
                       INNER JOIN zjk_expert_paper zep on zpr.id = zep.product_id
                       INNER JOIN sys_oss so on so.oss_id = zep.paper_path
              UNION all
              SELECT zpr.product_id, zpr.review_Sn, 1 AS type, so.*, zpr.create_time
              FROM zjk_product_reviewsn zpr
                       INNER JOIN zjk_expert_patent zep on zpr.id = zep.product_id
                       INNER JOIN sys_oss so on so.oss_id = zep.patent_path) a
                 INNER JOIN zjk_product zp on zp.id = a.product_id
        <where>
            <if test="bo.fileName != null and bo.fileName != ''">
                and a.original_name like '%' || #{bo.fileName} || '%'
            </if>
        </where>
    </select>
    <select id="selectVoByProductIdReviewSn" resultType="org.dromara.zjk.domain.ZjkProductReviewsn">
        select *
        from zjk_product_reviewsn
        where product_id = #{productId} and review_sn = #{reviewSn}
    </select>
</mapper>
