Commit d70d3ae0 by tyfanchz

修改分页查询条件

1 parent 6f0ce076
package cn.com.glsx.openplatform.vo; package cn.com.glsx.openplatform.vo;
import cn.com.glsx.openplatform.enums.ResultCodeEnum;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import cn.com.glsx.openplatform.enums.ResultCodeEnum;
import com.github.pagehelper.Page;
/** /**
* 返回数据 * 返回数据
...@@ -79,19 +79,41 @@ public class R extends HashMap<String, Object> { ...@@ -79,19 +79,41 @@ public class R extends HashMap<String, Object> {
return this; return this;
} }
///**
// * mybatis PageHelper分页数据
// *
// * @param page PageHelper分页数据
// * @return 结果
// */
//public R putPageData(com.github.pagehelper.Page<?> page) {
// Map<Object, Object> data = new HashMap<>(2);
// Map<Object, Object> pageMap = new HashMap<>();
// pageMap.put("pages", page.getPages());
// pageMap.put("total", page.getTotal());
// data.put(PAGE_KEY, pageMap);//分页信息
// data.put(LIST_KEY, page.getResult());//分页数据
// super.put(DATA_KEY, data);
// return this;
//}
/** /**
* mybatis PageHelper分页数据 * 分页数据
* *
* @param page PageHelper分页数据 * @param obj 数据
* @return 结果 * @return 结果
*/ */
public R putPageData(com.github.pagehelper.Page<?> page) { public R putPageData(Object obj) {
Map<Object, Object> data = new HashMap<>(2); Map<Object, Object> data = new HashMap<>(2);
if (obj instanceof com.github.pagehelper.Page) {
com.github.pagehelper.Page<?> page = (Page<?>) obj;
Map<Object, Object> pageMap = new HashMap<>(); Map<Object, Object> pageMap = new HashMap<>();
pageMap.put("pages", page.getPages()); pageMap.put("pages", page.getPages());
pageMap.put("total", page.getTotal()); pageMap.put("total", page.getTotal());
data.put(PAGE_KEY, pageMap);//分页信息 data.put(PAGE_KEY, pageMap);//分页信息
data.put(LIST_KEY, page.getResult());//分页数据 data.put(LIST_KEY, page.getResult());//分页数据
} else {
data.put(LIST_KEY, obj);
}
super.put(DATA_KEY, data); super.put(DATA_KEY, data);
return this; return this;
} }
......
...@@ -29,7 +29,7 @@ public class AdMgrServiceImpl implements AdMgrService { ...@@ -29,7 +29,7 @@ public class AdMgrServiceImpl implements AdMgrService {
PageHelper.startPage(page.getPageNumber(), page.getPageSize(), PageHelper.startPage(page.getPageNumber(), page.getPageSize(),
true); true);
List<PlatformAd> adMgrList = adMapper.getAdMgrList(ad); List<PlatformAd> adMgrList = adMapper.getAdMgrList(ad);
return R.ok().putPageData((com.github.pagehelper.Page<PlatformAd>) adMgrList); return R.ok().putPageData(adMgrList);
} }
@Override @Override
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!