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>