zoukankan      html  css  js  c++  java
  • MybatisPlus逻辑删除、执行性能

    一、逻辑删除

    1、添加字段,默认值为0(或者使用 this.setFieldValByName("deleted",0,metaObject);)

    2、实体类,添加属性

    @TableLogic
        private Integer deleted;

    3、Configuration配置类中新增,逻辑删除插件

    //逻辑删除插件
        @Bean
        public ISqlInjector sqlInjector() {
            return new LogicSqlInjector();
        }

    4、配置文件

    #默认值(可进行修改)
    #mybatis-plus.global-config.db-config.logic-delete-value=1
    #mybatis-plus.global-config.db-config.logic-not-delete-value=0

    5、测试类

        //删除操作 物理删除
        @Test
        public void testDeleteById(){
            int result = userMapper.deleteById(1414586284076175361L);
            System.out.println(result);
        }

    二、执行性能

    1、配置文件

    #环境设置:dev、test、prod
    spring.profiles.active=dev

    2、Configuration配置类中新增,sql执行性能插件

    /**
         * SQL 执行性能分析插件
         * 开发环境使用,线上不推荐。 maxTime 指的是 sql 最大执行时长
         *
         * 三种环境
         *      * dev:开发环境
         *      * test:测试环境
         *      * prod:生产环境
         */
        @Bean
        @Profile({"dev","test"})// 设置 dev test 环境开启
        public PerformanceInterceptor performanceInterceptor() {
            PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
            performanceInterceptor.setMaxTime(500);//ms,超过此处设置的ms则sql不执行
            performanceInterceptor.setFormat(true);
            return performanceInterceptor;
        }
  • 相关阅读:
    禁止google浏览器强制跳转为https
    遍历打印文件目录结构
    添加忽略文件
    部署git服务器
    Location, History, Screen, Navigator对象
    Window 对象
    回调函数,setTimeout,Promise
    闭包
    this
    函数内部运作机制—上下文
  • 原文地址:https://www.cnblogs.com/64Byte/p/15004274.html
Copyright © 2011-2022 走看看