动态select/where/group by/order by/列组合
单列
单列动态 复杂select/where/group by/order by/列组合
java
List<SysUser> list=QueryChain.of(sysUserMapper)
.select(SysUser::getName,c -> c.left(4).as(SysUserVo::getFirstName)) //select单列 调用 left(name,4)
.from(SysUser.class)
.like(SysUser::getName,"xx")
.and(SysUser::getName,c -> c.in("admin","admin2")) // where 单列 name in ('admin','admin2')
.groupBy(SysUser::getName,c->c.left(4)) // group by 单列 调用 left(name,4)
.orderBy(SysUser::getName,c->c.left(4)) // order by 单列 调用 left(name,4)
.list();
多列
多列 复杂select/where/group by/order by/列组合
java
List<SysUser> list=QueryChain.of(sysUserMapper)
.select(GetterFields.of(SysUser::getName,SysRole::getName2),cs -> CmdTemplate.create("{0}+{1}",cs[0],cs[1]).as(SysUserVo::getFullName)) //select多列合并成一列 (name + name2)
.from(SysUser.class)
.join(SysUser.class,SysRole.class)
.like(SysUser::getName,"xx")
.and(GetterFields.of(SysUser::getId, SysRole::getId2), cs -> ConditionTemplate.create("{0}+{1}={2}", cs[0], cs[1], 2).as("123")) // where 多列组合条件
.groupBy(GetterFields.of(SysUser::getName,SysRole::getName2),cs -> CmdTemplate.create("{0}+{1}",cs[0],cs[1])) //group by多列合并成一列 (name + name2)
.orderBy(GetterFields.of(SysUser::getName,SysRole::getName2),cs -> CmdTemplate.create("{0}+{1}",cs[0],cs[1])) //order by多列合并成一列 (name + name2)
.list();