可以使用if-else语句来判断查询结果是否为null,如果为null则执行selectByCondation2方法,否则直接返回查询结果。修改后的代码如下:

public List selectByCondation(Integer page, Integer limit, int categoryid, String keyword, BigDecimal minprice, BigDecimal maxprice, String brand, String supplier, String origin, String isActive, String isDeleted) { List products = selectByCondation(page * limit, (page + 1) * limit - 1, categoryid, keyword, minprice, maxprice, brand, supplier, origin, isActive, isDeleted); if (products == null) { products = selectByCondation2(categoryid); } return products;

public ListProducts selectByCondationInteger page Integer limit int categoryid String keyword BigDecimal minprice BigDecimal maxprice String brand String supplier String origin String isActive String

原文地址: https://www.cveoy.top/t/topic/dB8r 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录