如题 Mybatis-Plus多条件or语句和and语句拼接
实现如下sql拼接语句
SELECT
*
FROM
tbale_a a
WHERE
(
a.is_delete = '0'
AND a.DAY_PLAN_NAME LIKE '%日%'
AND ( ( a.AIRDROME_DETAILS_ID LIKE '%1667060837901729794%' ) OR ( a.AIRDROME_DETAILS_ID LIKE '%1667060837893341186%' ) )
)
java实现
// 查询条件
QueryWrapper<SDto> qw = new QueryWrapper<>();
// 名称
qw.like(StrUtil.isNotBlank(dto.getName()), "a.DAY_PLAN_NAME ",
dto.getName());
// 适配内容 或语句
if (CollUtil.isNotEmpty(dto.getModelId())) {
List<Long> ModelIds= dto.getModelId();
qw.and(
q -> {
for (Long ids : ModelIds) {
q.or(
w -> {
w.like("a.AIRDROME_DETAILS_ID", ids);
}
);
}
}
);
}