主要是注意or拼接的两个条件,与第三个条件组合时的and是怎么使用的
// 参数
final List<UserOrder> userOrders = getUserOrders();
// 创建查询参数
LambdaQueryWrapper<UserOrder> lqw = new LambdaQueryWrapper<>();
lqw.eq(UserOrder::getChargeObjectType, "x");
lqw.and(ilqw -> {
userOrders.forEach(o -> {
ilqw.or(iilqw -> iilqw.eq(UserOrder::getUserId, o.getUserId()).eq(UserOrder::getUserType, o.getUserType()));
});
}
);
// 查询
List<UserOrder> list = userOrderService.list(lqw);
SELECT
*
FROM
user_order
WHERE
charge_object_type = ? AND ((user_type = ? AND user_id = ?) OR (user_type = ? AND user_id = ?))```