use of com.baomidou.mybatisplus.core.metadata.IPage in project springboot-learning by lyb-geek.
the class BookServiceImpl method pageBook.
@Override
public PageResult<BookDTO> pageBook(PageQuery<BookDTO> pageQuery) {
BookDTO bookDTO = pageQuery.getQueryParams();
Wrapper<Book> wrapper = wrapperQueryCondition(bookDTO);
IPage<Book> page = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
IPage<Book> bookIPage = baseMapper.selectPage(page, wrapper);
if (bookIPage != null) {
List<BookDTO> bookDTOS = new ArrayList<>();
if (CollectionUtils.isNotEmpty(bookIPage.getRecords())) {
bookDTOS = BeanMapperUtils.mapList(bookIPage.getRecords(), BookDTO.class);
}
return PageUtil.INSTANCE.getPage(bookIPage, bookDTOS);
}
return null;
}
use of com.baomidou.mybatisplus.core.metadata.IPage in project springboot-learning by lyb-geek.
the class BookServiceImpl method pageBook.
@Override
public PageResult<BookDTO> pageBook(PageQuery<BookDTO> pageQuery) {
BookDTO bookDTO = pageQuery.getQueryParams();
Wrapper<Book> wrapper = wrapperQueryCondition(bookDTO);
IPage<Book> page = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
IPage<Book> bookIPage = baseMapper.selectPage(page, wrapper);
if (bookIPage != null) {
List<BookDTO> bookDTOS = new ArrayList<>();
if (CollectionUtils.isNotEmpty(bookIPage.getRecords())) {
bookDTOS = BeanMapperUtils.mapList(bookIPage.getRecords(), BookDTO.class);
}
return PageUtil.INSTANCE.getPage(bookIPage, bookDTOS);
}
return null;
}
use of com.baomidou.mybatisplus.core.metadata.IPage in project EVA-API by PKAQ-LAB.
the class RoleService method listRole.
/**
* 查询角色列表
* @param roleEntity
* @return
*/
public IPage<RoleEntity> listRole(RoleEntity roleEntity, Integer page, Integer pageSize) {
page = null != page ? page : 1;
pageSize = null != pageSize ? pageSize : 10;
// 查询条件
QueryWrapper<RoleEntity> wrapper = new QueryWrapper<>(roleEntity);
// 分页条件
Page pagination = new Page();
pagination.setCurrent(page);
pagination.setSize(pageSize);
return this.mapper.selectPage(pagination, wrapper);
}
use of com.baomidou.mybatisplus.core.metadata.IPage in project EVA-API by PKAQ-LAB.
the class Response method exclude.
/**
* 对data对象里对应的属性置空
* @param values 需要为空的属性名
* @return
*/
public Response exclude(Object data, String[] values) {
Object thisObject = data;
if (data != null) {
for (String value : values) {
// 如果对象是Ipage对象,则fatherObject等于实际传给前台的对象即records集合。
if (data instanceof IPage) {
thisObject = ((IPage) data).getRecords();
}
String[] splitValue = value.split("\\.");
// thisObject的直接属性的话,判断什么类型然后直接置位空
if (splitValue.length == 1) {
// 对thisObject的splitValue[0]属性赋空值
ReflectHelper.setNull(thisObject, splitValue[0]);
} else {
// 链式属性的话,循环每一阶层的属性名
for (int i = 0; i < splitValue.length; i++) {
String stepValue = splitValue[i];
// 得到当前循环的子集的所有下层子集
int begin = value.indexOf(".", i + 1);
String[] sValue = { value.substring(begin + 1, value.length()) };
// 如果是数组或集合,则循环属性值,把接下去的阶层属性置空
if (thisObject.getClass().isArray() || thisObject instanceof Collection) {
for (Object obj : (Collection) thisObject) {
Field field = ReflectHelper.getField(obj, stepValue);
if (field != null) {
field.setAccessible(true);
try {
exclude(field.get(obj), sValue);
} catch (IllegalAccessException e) {
throw new ReflectException("得到" + obj.getClass() + "对象的" + stepValue + "属性值失败");
}
}
}
break;
} else if (thisObject instanceof Map) {
// 如果是map集合的话,则得到map对应的key(下一阶层的属性名)的value对象,然后递归该对象
Map map = (Map) thisObject;
exclude(map.get(stepValue), sValue);
break;
} else {
Field field = ReflectHelper.getField(thisObject, stepValue);
if (field != null) {
field.setAccessible(true);
try {
exclude(field.get(thisObject), sValue);
} catch (IllegalAccessException e) {
throw new ReflectException("得到" + thisObject.getClass() + "对象的" + stepValue + "属性值失败");
}
}
}
}
}
}
}
this.setData(thisObject);
return this;
}
use of com.baomidou.mybatisplus.core.metadata.IPage in project RG by ADrWondertainment.
the class AnswerServiceImpl method getAnswersByUserID.
@Override
public Result getAnswersByUserID(Integer id, Integer pageNum, Integer size) {
IPage<Answer> page = new Page(pageNum, size);
QueryWrapper<Answer> query = Wrappers.query();
query.eq("uid", id);
IPage<Answer> answerIPage = answerMapper.selectPage(page, query);
if (answerIPage == null) {
throw new BackException(ErrorCode.TEMPLATE_SELECT_FAILURE, "分页数据查询失败");
}
List<Answer> records = answerIPage.getRecords();
JSONArray jsonArray = JSONUtil.parseArray(records);
System.out.println(JSONUtil.toJsonPrettyStr(jsonArray));
ResultUtil.quickSet(result, ErrorCode.ALL_SET, "查询成功", JSONUtil.toJsonPrettyStr(jsonArray));
return result;
}
Aggregations