Commit 69a03df0 by qiuweili123

优化分页对象

parent 5669ff52
...@@ -36,7 +36,9 @@ public class BeanUtil extends BeanUtils { ...@@ -36,7 +36,9 @@ public class BeanUtil extends BeanUtils {
return Maps.newHashMapWithExpectedSize(0); return Maps.newHashMapWithExpectedSize(0);
} }
try { try {
return PropertyUtils.describe(object); Map<String, Object> dataMap = PropertyUtils.describe(object);
dataMap.remove("class");
return dataMap;
} catch (Exception e) { } catch (Exception e) {
throw new SystemInternalException(); throw new SystemInternalException();
} }
......
...@@ -2,11 +2,14 @@ package com.secoo.mall.mybatis.bean; ...@@ -2,11 +2,14 @@ package com.secoo.mall.mybatis.bean;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.secoo.mall.common.core.bean.Pageable; import com.secoo.mall.common.core.bean.Pageable;
import com.secoo.mall.common.util.colletion.CollectionUtil;
import java.util.List; import java.util.List;
public class DataPage<T> implements Pageable<T> { public class DataPage<T> implements Pageable<T> {
private List dataList;
private Page<T> page; private Page<T> page;
public DataPage(Page<T> page) { public DataPage(Page<T> page) {
...@@ -15,6 +18,9 @@ public class DataPage<T> implements Pageable<T> { ...@@ -15,6 +18,9 @@ public class DataPage<T> implements Pageable<T> {
@Override @Override
public List<T> getResultList() { public List<T> getResultList() {
if (CollectionUtil.isNotEmpty(dataList)) {
return dataList;
}
return page.getRecords(); return page.getRecords();
} }
...@@ -32,4 +38,9 @@ public class DataPage<T> implements Pageable<T> { ...@@ -32,4 +38,9 @@ public class DataPage<T> implements Pageable<T> {
public Long getPageSize() { public Long getPageSize() {
return page.getSize(); return page.getSize();
} }
public void setDataList(List dataList) {
this.dataList = dataList;
}
} }
...@@ -6,6 +6,7 @@ import com.secoo.mall.common.constant.PageConstant; ...@@ -6,6 +6,7 @@ import com.secoo.mall.common.constant.PageConstant;
import com.secoo.mall.common.core.bean.ReqPage; import com.secoo.mall.common.core.bean.ReqPage;
import com.secoo.mall.common.core.bean.Sort; import com.secoo.mall.common.core.bean.Sort;
import com.secoo.mall.common.core.exception.ParameterException; import com.secoo.mall.common.core.exception.ParameterException;
import com.secoo.mall.common.util.colletion.CollectionUtil;
import com.secoo.mall.common.util.string.StringUtil; import com.secoo.mall.common.util.string.StringUtil;
import com.secoo.mall.mybatis.bean.DataPage; import com.secoo.mall.mybatis.bean.DataPage;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -73,5 +74,12 @@ public interface PageUtil { ...@@ -73,5 +74,12 @@ public interface PageUtil {
} }
} }
static void setResultList(DataPage dataPage, List dataList) {
if (CollectionUtil.isEmpty(dataList)) {
dataList = new ArrayList();
}
dataPage.setDataList(dataList);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment