/** * * @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.getPageIndex(), 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 pageIndex; int pageSize; public T getObj() { return obj; } public void setObj(T obj) { this.obj = obj; } public int getPageIndex() { return pageIndex; } public void setPageIndex(int pageIndex) { this.pageIndex = pageIndex; } 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> { }