前往小程序,Get更优阅读体验!
立即前往
发布
社区首页 >专栏 >mybatis-plus防止全表更新与删除

mybatis-plus防止全表更新与删除

作者头像
阿超
发布2022-08-16 20:40:52
发布2022-08-16 20:40:52
1.2K00
代码可运行
举报
文章被收录于专栏:快乐阿超快乐阿超
运行总次数:0
代码可运行

宁要好梨一个,不要烂梨一筐。积极肯干和忠心耿耿的人即使只有两三个,也比十个朝气沉沉的人强。——列宁

我们可以如下配置

代码语言:javascript
代码运行次数:0
复制
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
    MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
    PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor(DbType.MYSQL);
    // 阻止全表更新与删除
    BlockAttackInnerInterceptor blockAttackInnerInterceptor = new BlockAttackInnerInterceptor();
    // 设置请求的页面大于最大页后操作, true调回到首页,false 继续请求  默认false
    paginationInnerInterceptor.setOverflow(true);
    paginationInnerInterceptor.setMaxLimit(200L);
    interceptor.addInnerInterceptor(paginationInnerInterceptor);
    interceptor.addInnerInterceptor(blockAttackInnerInterceptor);
    return interceptor;
}

主要的是这个BlockAttackInnerInterceptor

然后我们试着全表更新

然后是全表删除

发现都操作不了了

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2021-07-10,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档