扩展mybatis-plus,保留逻辑删、逻辑查的前提下,扩展硬删除、硬查询

引入相关依赖


<dependency>
    <groupId>com.idea-aedigroupId>
    <artifactId>common-mybatis-plusartifactId>
    <version>2100.8.8version>
    <exclusions>
        
        <exclusion>
            <groupId>com.idea-aedigroupId>
            <artifactId>common-springartifactId>
        exclusion>
    exclusions>
dependency>


<dependency>
    <groupId>com.baomidougroupId>
    <artifactId>mybatis-plus-boot-starterartifactId>
    <version>3.5.4.1version>
dependency>

启用增强功能

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Import;

/**
 * 导出sql注入器
 */
// 或:@ComponentScan(basePackages = "com.ideaaedi.commonmp.injector")
@Import(com.ideaaedi.commonmp.injector.MybatisPlusSqlInjector.class)
@SpringBootApplication
public class StartUp {
    public static void main(String[] args) {
        SpringApplication.run(StartUp.class, args);
    }
}

使用示例

  • 编写mapper
    import com.ideaaedi.commonmp.mapper.BaseMapperExt;
    import com.ideaaedi.demo.entity.UserPO;
    import org.apache.ibatis.annotations.Mapper;
    
    @Mapper
    public interface UserMapper extends BaseMapperExt<UserPO> {
    }
    
  • 编写service
    import com.ideaaedi.commonmp.service.IServiceExt;
    import com.ideaaedi.demo.entity.UserPO;
    
    public interface UserService extends IServiceExt<UserPO> {
    }
    
  • 编写service-impl
    import com.ideaaedi.commonmp.service.ServiceImplExt;
    import com.ideaaedi.demo.entity.UserPO;
    import com.ideaaedi.demo.mapper.UserMapper;
    import com.ideaaedi.demo.service.UserService;
    import org.springframework.stereotype.Service;
    
    @Service
    public class UserServiceImpl extends ServiceImplExt<UserMapper, UserPO> implements UserService {
    }
    
  • 调用硬删除、硬查询方法即可
    扩展mybatis-plus,保留逻辑删、逻辑查的前提下,扩展硬删除、硬查询_第1张图片

相关资料

  • demo代码(force-select-delete分支)

你可能感兴趣的:(Java知识大杂烩,mybatis-plus硬删除,mybatis-plus硬查询,mybatis-plus扩展,mybatis-plus,mybatis)