Get the App
SLTechnology News&Howtos  ›  Development  › 

How to solve the problem of invalid mybatis-plus logic deletion

Shulou Source: shulou.com Published: 2022-06-03 10:23:25 11月15日 Update

This article shows you how to solve the problem of invalid mybatis-plus logic deletion, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Add the following note: value represents the default value delval represents the value when deleted

/ * * whether to delete * / @ TableLogic (value = "0", delval = "1") @ TableField (value = "del_flag") private Boolean delFlag

The following figure shows the entire configuration code (if you know where to add the previous configuration, please ignore the following code configuration)

Import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;import com.baomidou.mybatisplus.core.injector.ISqlInjector;import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;import com.fasterxml.jackson.databind.ObjectMapper;import com.fasterxml.jackson.databind.module.SimpleModule;import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;import org.mybatis.spring.annotation.MapperScan;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder / * mybatis-plus configuration * * / @ Configuration@MapperScan ({"com.sjyf.gym.mapper.**", "com.sjyf.gym.mapper"}) public class MybatisPlusConfig {/ * paging plug-in * / @ Bean public PaginationInterceptor paginationInterceptor () {return new PaginationInterceptor () } / * pagination * @ param builder * @ return * / @ Bean public ObjectMapper objectMapper (Jackson2ObjectMapperBuilder builder) {ObjectMapper objectMapper = builder.createXmlMapper (false). Build (); SimpleModule simpleModule = new SimpleModule (); / / convert all Long types directly to String simpleModule.addSerializer (Long.class, ToStringSerializer.instance); simpleModule.addSerializer (Long.TYPE, ToStringSerializer.instance) ObjectMapper.registerModule (simpleModule); return objectMapper;} / * * logical deletion * @ return * / @ Bean public ISqlInjector sqlInjector () {return new DefaultSqlInjector ();}} the above is how to solve the problem of invalid mybatis-plus logic deletion. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Configuration logic questions code representatives content skills knowledge concise concise the following figure that is plug-ins articles more notes articles types industries information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information OPPO Reno vpn MariaDB Shulou Technology