mybatis plus
基本概念: Mybatis 的增强工具,在 Mybatis 的基础上只做增强不做改变,为简化开发、提高效率而生,它已经封装好了一些crud方法,不需要再写xml了,直接调用这些方法就行,就类似于JPA。
通用CRUD操作:内置通用 Mapper、通用 Service,仅仅通过少量配置即可实现单表大部分 CRUD 操作,更有强大的条件构造器,满足各类使用需求;
内置分页插件:基于Mybatis物理分页,开发者无需关心具体操作,配置好插件之后,写分页等同于写基本List查询;
Page page = new Page(); page.setCurrent(1); page.setSize(20); public IPage orderList(Page page, SearchDto searchDto) { orderIPage = vehicleApplicationOrderMapper.getOrderPage(page,searchDto); //按条件查询 return orderIPage;}
BaseMapper接口,默认提供了一系列的增删改查的基础方法,并且开发人员对于这些基础操作不需要写SQL进行处理操作(Mybatis提供的机制就是需要开发人员在mapper.xml中提供sql语句
Dao/Mapper: public interface SomethingMapper/SomethingDao extends BaseMapper<Something> { }
Service: public interface SomethingService extends IService<Something> { }
ServiceImp: public class SomethingServiceImpl extends ServiceImpl<SomethingMapper, Something> implements SomethingService { }
QueryWrapper实体对象封装操作类
例:List<CategoryEntity> catelogId = relationDao.selectList(new QueryWrapper<CategoryEntity>().eq("catelog_id", catId));
QueryWrapper<Card> wrapper = new QueryWrapper<Card>(); wrapper.eq(CommonSearchEnum.STATUS.getColumn(), CommonSearchEnum.STATUS.getValue()); wrapper.and(rap -> rap.eq("card_type_id",sendCardBatchVo.getCardTypeId())); wrapper.in("card_code",cardCodeList); //in:列 包含在list中 Integer count = cardMapper.selectCount(wrapper); //查询数量 if(count != null && count.equals(cardCodeList.size())){ }else{ return ValidateUtil.returnError(DataTransferCodeEnum.PERSON_CARD_CODE_IS_NOT_EXISTS).toR(); }
 
                    
                
 
 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号