Mybatis-plus动态排序${}防注入(驼峰转下划线)

Mybatis-plus动态排序${}防注入(驼峰转下划线)

public static <T> void verifyAndSetColumn(BasePageQuery req, Class<T> clazz) {
    if (StringUtils.hasText(req.getColumn())) {
        try {
            clazz.getDeclaredField(req.getColumn());
            req.setColumn(StrUtil.toUnderlineCase(req.getColumn()));
         } catch (NoSuchFieldException e) {
            req.setColumn("");
        }
    }
}

 

posted @ 2022-08-01 09:59  整合侠  阅读(837)  评论(0编辑  收藏  举报