Commit d70d3ae0 by tyfanchz

修改分页查询条件

1 parent 6f0ce076
package cn.com.glsx.openplatform.vo;
import cn.com.glsx.openplatform.enums.ResultCodeEnum;
import java.util.HashMap;
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> {
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 结果
*/
public R putPageData(com.github.pagehelper.Page<?> page) {
public R putPageData(Object obj) {
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());//分页数据
if (obj instanceof com.github.pagehelper.Page) {
com.github.pagehelper.Page<?> page = (Page<?>) obj;
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());//分页数据
} else {
data.put(LIST_KEY, obj);
}
super.put(DATA_KEY, data);
return this;
}
......
......@@ -29,7 +29,7 @@ public class AdMgrServiceImpl implements AdMgrService {
PageHelper.startPage(page.getPageNumber(), page.getPageSize(),
true);
List<PlatformAd> adMgrList = adMapper.getAdMgrList(ad);
return R.ok().putPageData((com.github.pagehelper.Page<PlatformAd>) adMgrList);
return R.ok().putPageData(adMgrList);
}
@Override
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!