|
@@ -5,11 +5,11 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.github.pagehelper.PageHelper;
|
|
|
-import com.github.pagehelper.PageInfo;
|
|
|
import com.fdkk.sxz.base.IBaseMapper;
|
|
|
import com.fdkk.sxz.base.IBaseService;
|
|
|
import com.fdkk.sxz.base.RequestBase;
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@@ -21,8 +21,6 @@ import java.util.List;
|
|
|
public abstract class BaseServiceImpl<M extends IBaseMapper<T>, T> extends ServiceImpl<M, T> implements IBaseService<T> {
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
@Override
|
|
|
public boolean save(T entity) {
|
|
|
return super.save(entity);
|
|
@@ -55,42 +53,57 @@ public abstract class BaseServiceImpl<M extends IBaseMapper<T>, T> extends Servi
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public PageInfo<T> listByPage(RequestBase page, T condition) {
|
|
|
+ public PageInfo<T> listByPage(RequestBase page, T condition) {
|
|
|
if (ObjectUtil.isNotNull(page)) {
|
|
|
- if (!page.getIsALL()){
|
|
|
+ if (!page.getIsALL()) {
|
|
|
PageHelper.startPage(page.getPageNum(), page.getPageSize());
|
|
|
if (StrUtil.isNotEmpty(page.getOrderBy())) {
|
|
|
PageHelper.orderBy(page.getOrderBy() + " " + page.getSortBy());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return new PageInfo<T>(super.list(new QueryWrapper<>(condition)));
|
|
|
+ PageInfo<T> tPageInfo = new PageInfo<T>(super.list(new QueryWrapper<>(condition)));
|
|
|
+ if (tPageInfo.getPageNum() > tPageInfo.getPages() && !tPageInfo.isHasNextPage() && tPageInfo.isHasPreviousPage()) {
|
|
|
+ PageHelper.startPage(tPageInfo.getPages(), page.getPageSize());
|
|
|
+ tPageInfo = new PageInfo<T>(super.list(new QueryWrapper<>(condition)));
|
|
|
+ }
|
|
|
+ return tPageInfo;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public PageInfo<T> listByPage(RequestBase page, Wrapper<T> queryWrapper) {
|
|
|
if (ObjectUtil.isNotNull(page)) {
|
|
|
- if (!page.getIsALL()){
|
|
|
- PageHelper.startPage(page.getPageNum(),page.getPageSize());
|
|
|
- if (StrUtil.isNotEmpty(page.getOrderBy())){
|
|
|
- PageHelper.orderBy(page.getOrderBy()+" "+page.getSortBy());
|
|
|
+ if (!page.getIsALL()) {
|
|
|
+ PageHelper.startPage(page.getPageNum(), page.getPageSize());
|
|
|
+ if (StrUtil.isNotEmpty(page.getOrderBy())) {
|
|
|
+ PageHelper.orderBy(page.getOrderBy() + " " + page.getSortBy());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return new PageInfo<T>(super.list(queryWrapper));
|
|
|
+ PageInfo<T> tPageInfo = new PageInfo<>(super.list(queryWrapper));
|
|
|
+ if (tPageInfo.getPageNum() > tPageInfo.getPages() && !tPageInfo.isHasNextPage() && tPageInfo.isHasPreviousPage()) {
|
|
|
+ PageHelper.startPage(tPageInfo.getPages(), page.getPageSize());
|
|
|
+ tPageInfo = new PageInfo<>(super.list(queryWrapper));
|
|
|
+ }
|
|
|
+ return tPageInfo;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public PageInfo<T> listByPage(RequestBase page) {
|
|
|
if (ObjectUtil.isNotNull(page)) {
|
|
|
- if (!page.getIsALL()){
|
|
|
+ if (!page.getIsALL()) {
|
|
|
PageHelper.startPage(page.getPageNum(), page.getPageSize());
|
|
|
if (StrUtil.isNotEmpty(page.getOrderBy())) {
|
|
|
PageHelper.orderBy(page.getOrderBy() + " " + page.getSortBy());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- return new PageInfo<T>(super.list());
|
|
|
+ PageInfo<T> tPageInfo = new PageInfo<T>(super.list());
|
|
|
+ if (tPageInfo.getPageNum() > tPageInfo.getPages() && !tPageInfo.isHasNextPage() && tPageInfo.isHasPreviousPage()) {
|
|
|
+ PageHelper.startPage(tPageInfo.getPages(), page.getPageSize());
|
|
|
+ tPageInfo = new PageInfo<T>(super.list());
|
|
|
+ }
|
|
|
+ return tPageInfo;
|
|
|
}
|
|
|
|
|
|
@Override
|