倒序拼接字符串
@ApiOperation("分页查询")
@GetMapping(value = "/list")
public ActionResult<Map<String, Object>> list(@RequestParam Map<String, Object> params) {
List<String> list = Arrays.asList(new String[]{"create_time"});
return new ActionResult(StatusCode.SUCCESS, iUmsMemberService.selectPage(new Query<>(params),
new EntityWrapper<UmsMember>().eq("deleted", 0).orderDesc(list)));
}
等同于
SELECT id AS id,member_level_id AS memberLevelId,username, FROM ums_member WHERE (deleted = 0) ORDER BY create_time DESC LIMIT 0,5
把sql用字符串拼接好后直接取出使用
Object aa(@Param(value = "sql") String sql);
<select id="aa" resultType="Object">
${sql}
</select>
以上为个人经验,希望能给大家一个参考,也希望大家多多支持编程网。