引入相关依赖
<dependency>
<groupId>com.idea-aedi</groupId>
<artifactId>common-mybatis-plus</artifactId>
<version>2100.8.8</version>
<exclusions>
<exclusion>
<groupId>com.idea-aedi</groupId>
<artifactId>common-spring</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.4.1</version>
</dependency>
启用增强功能
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Import;
@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 {
}
- 调用硬删除、硬查询方法即可
相关资料
- demo代码(force-select-delete分支)