gongchunyi
10 小时以前 c7cf4606c748e3ef2a4df1811b60e0ef000ff9e8
src/main/resources/mapper/basic/ProductModelMapper.xml
@@ -56,6 +56,22 @@
            <if test="c.parentName != null and c.parentName != ''">
                AND pt.top_name LIKE CONCAT('%', #{c.parentName}, '%')
            </if>
            <if test="c.topProductParentId != null and c.topProductParentId > 0">
                and p.id in (
                    WITH RECURSIVE product_tree AS (
                        SELECT id
                        FROM product
                        WHERE id = #{c.topProductParentId}
                        UNION ALL
                        SELECT p.id
                        FROM product p
                        INNER JOIN product_tree pt ON p.parent_id = pt.id
                    )
                    select id from product_tree
                )
            </if>
        </where>
        ORDER BY pm.id DESC
    </select>