标签:TE ext date index size XML wrap dex one
/** * * @author shenjing * @date 2018/6/20 */ @Service public class LocalDispatchServiceImpl extends ServiceImpl<Rep_DisPatchDao, Rep_DisPatch> implements LocalDispatchService { /** * 根据domain组合各种类型的查询,一般的查询就可以通过这个完成了,dao完全没有存在的意义了 * * @param domain * @return */ @Override public Rep_DisPatch findOneByDomain(Rep_DisPatch domain) { EntityWrapper<Rep_DisPatch> eWrapper = new EntityWrapper<>(domain); return selectOne(eWrapper); } /** * 根据分页参数进行查询 * * @param dispatchPageParam * @return */ @Override public Page<Rep_DisPatch> findListByPage(DispatchPageParam dispatchPageParam) { Page<Rep_DisPatch> page = new Page<>(dispatchPageParam.getStartIndex(), dispatchPageParam.getPageSize()); EntityWrapper<Rep_DisPatch> eWrapper = new EntityWrapper<>(dispatchPageParam.getObj()); Page<Rep_DisPatch> ret = selectPage(page, eWrapper); return ret; } }
此处ServiceImpl,是myBatisPlus提供的一个基类。
DispatchPageParam 是自己写的一个查询参数的封装
/** * 基础分页参数 * @author shenjing * @date 2018/6/20 */ public class BasePageParam<T> { T obj; int startIndex; int pageSize; public T getObj() { return obj; } public void setObj(T obj) { this.obj = obj; } public int getStartIndex() { return startIndex; } public void setStartIndex(int startIndex) { this.startIndex = startIndex; } public int getPageSize() { return pageSize; } public void setPageSize(int pageSize) { this.pageSize = pageSize; } }
实际上这个里面什么都没有,只要继承基类就可以了
/** * Created by shenjing on 2018/6/20. */ public class DispatchPageParam extends BasePageParam<Rep_DisPatch> { }
MyBatisPlus的通用查询,简直可以丢弃Dao和mapper.xml了
标签:TE ext date index size XML wrap dex one
原文地址:https://www.cnblogs.com/JangoJing/p/9205405.html