deptIds.add("3");
deptIds.add("5");
ItemsList itemsList = new ExpressionList(deptIds.stream().map(StringValue::new).collect(Collectors.toList()));
InExpression inExpression = new InExpression(new Column(dataColumn.getAliasDotName()), itemsList);
if (null == plainSelect.getWhere()) {
// 不存在 where 条件
plainSelect.setWhere(new Parenthesis(inExpression));
} else {
// 存在 where 条件 and 处理
plainSelect.setWhere(new AndExpression(plainSelect.getWhere(), inExpression));
}
} else if ("mobile".equals(dataColumn.getName())) {
// 支持一个自定义条件
LikeExpression likeExpression = new LikeExpression();
likeExpression.setLeftExpression(new Column(dataColumn.getAliasDotName()));
likeExpression.setRightExpression(new StringValue("%1533%"));
plainSelect.setWhere(new AndExpression(plainSelect.getWhere(), likeExpression));
}
}
}
}
};
}
最终执行 SQL 输出:
SELECT u.* FROM user u
WHERE (u.department_id IN ('1', '2', '3', '5'))
AND u.mobile LIKE '%1533%' LIMIT 1, 10
目前仅有付费版本 , 了解更多 mybatis-mate 使用示例详见:
https://gitee.com/baomidou/mybatis-mate-example
原文链接:
https://mp.weixin.qq.com/s/3Uim4i5YK4QWL4GHiNpjdA
【MyBatisPlus又在搞事了!发布神器,一个依赖轻松搞定权限问题】
推荐阅读
- 化妆|杨幂又在引领潮流!松紧发带+乐福鞋,成为一周标配
- 学会了MybatisPlus,代码开发效率提高了10倍
- 江疏影|新时代律政俏佳人上线!刘敏涛江疏影携手搞事业《女士的法则》大爽文来袭
- SpringBoot整合MybatisPlus基本的增删改查,保姆级教程
- SpringBoot整合MybatisPlus数据自动填充
- MybatisPlus中实体类属性对应枚举类实现
- 用了MybatisPlus后,我很久没有手写sql了
- 上饶又一网红打卡地,首家搞事情的辰色酒馆
- iPhone|iPhone 14细节曝光 摄像头留遗憾:苹果供应商近10亿元搞事
- 梦到喜欢的人离婚了,然后和自己在一起了 梦到离婚的人又在一起
