This action will force synchronization from 闲.大赋(李家智)/BeetlSQL, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
强化SQL管理,通过md文件管理sql,使用Beetl模板编写复杂sql
简单SQL可以通过Query类链式API完成
内置常见增删改查功能,节省项目50%工作量
BeetSql是一个全功能DAO工具, 同时具有Hibernate 优点 & Mybatis优点功能,适用于承认以SQL为中心,同时又需求工具能自动能生成大量常用的SQL的应用
List<User> list = userDao.createQuery().andEq("name","hi").orderBy("create_date").select();
如果是Java8,则可以
List<User> list1 = userDao.createLambdaQuery().andEq(User::getName, "hi").orderBy(User::getCreateDate).select();
Query接口分为俩类:
一部分是触发查询和更新操作,api分别是
另外一部分是各种条件:
方法 | 等价sql |
---|---|
andEq,andNotEq | ==,!= |
andGreat,andGreatEq | >,>= |
andLess,andLessEq | <,<= |
andLike,andNotLike | LIKE,NOT LIKE |
andIsNull,andIsNotNull | IS NULL,IS NOT NULL |
andIn ,andNotIn | IN (...) , NOT IN(...) |
andBetween,andNotBetween | BETWEEN ,NOT BETWEEN |
and | and ( .....) |
or系列方法 | 同and方法 |
limit | 限制结果结范围,依赖于不同数据库翻页 |
orderBY | ORDER BY |
groupBy | GROUP BY |
@SqlResource("console.user")
public interface UserConsoleDao extends BaseMapper<SysUser> {
void batchDelUserByIds(List<Long> ids);
void batchUpdateUserState( List<Long> ids, GeneralStateEnum stateEnum);
@Sql("update sys_user set password=? where id=?")
int changePassword(String newPassword,long id);
}
对应的sql文件是console/user.md,内容如下
batchDelUserByIds
===
update SYS_USER u set u.del_flag = 1 where u.id in( #join(ids)#)
batchUpdateUserState
===
update SYS_USER u set u.state = #state# where u.id in( #join(ids)#)
selectUserAndDepartment
===
select * from user where user_id=#userId#
@ orm.single({"departmentId":"id"},"Department");
@ orm.many({"id":"userId"},"user.selectRole","Role");
user.selectRole
===
select r.* from user_role ur left join role r on ur.role_id=r.id
where ur.user_id=#userId#
也支持注解说明映射关系
说明博客:https://my.oschina.net/xiandafu/blog/617542
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。