![]()
//第一步 添加属性和注解 @TableLogic private Integer deleted //第二步 配置逻辑删除插件 @Bean public ISqlInjector sqlInjector() { return new LogicSqlInjector(); }
application.properties #mysql数据库连接 spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.datasource.url=jdbc:mysql://localhost:3306/mybatis_plus spring.datasource.username=root spring.datasource.password=123456 mybatis-plus.global-config.db-config.logic-delete-value=1 mybatis-plus.global-config.db-config.logic-not-delete-value=0 #mybatis日志 mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
//测试删除代码 //物理删除 @Test public void testDeleteById() { int result = userMapper.deleteById(9001); System.out.println(result); } //批量删除 @Test public void testDeleteBatchIds() { int result = userMapper.deleteBatchIds(Arrays.asList(901,902)); System.out.println(result); }

浙公网安备 33010602011771号