Search in sources :

Example 26 with IPage

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;
}
Also used : BookDTO(com.github.lybgeek.swagger.dto.BookDTO) Book(com.github.lybgeek.swagger.model.Book) ArrayList(java.util.ArrayList) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage)

Example 27 with IPage

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;
}
Also used : BookDTO(com.github.lybgeek.spilt.dto.BookDTO) Book(com.github.lybgeek.spilt.model.Book) ArrayList(java.util.ArrayList) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage)

Example 28 with IPage

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);
}
Also used : RoleEntity(io.nerv.web.sys.role.entity.RoleEntity) QueryWrapper(com.baomidou.mybatisplus.core.conditions.query.QueryWrapper) Page(io.nerv.core.mvc.util.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage)

Example 29 with IPage

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;
}
Also used : Field(java.lang.reflect.Field) IPage(com.baomidou.mybatisplus.core.metadata.IPage) Collection(java.util.Collection) ReflectException(io.nerv.core.exception.ReflectException) Map(java.util.Map)

Example 30 with IPage

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;
}
Also used : BackException(ruangong.root.exception.BackException) JSONArray(cn.hutool.json.JSONArray) Page(com.baomidou.mybatisplus.extension.plugins.pagination.Page) IPage(com.baomidou.mybatisplus.core.metadata.IPage)

Aggregations

IPage (com.baomidou.mybatisplus.core.metadata.IPage)197 Page (com.baomidou.mybatisplus.extension.plugins.pagination.Page)152 QueryWrapper (com.baomidou.mybatisplus.core.conditions.query.QueryWrapper)73 ApiOperation (io.swagger.annotations.ApiOperation)28 ArrayList (java.util.ArrayList)21 Test (org.junit.Test)20 PageDTO (com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO)19 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)18 LoginUser (org.jeecg.common.system.vo.LoginUser)16 JSONObject (com.alibaba.fastjson.JSONObject)15 RequiresPermissions (org.apache.shiro.authz.annotation.RequiresPermissions)15 PageInfo (org.apache.dolphinscheduler.api.utils.PageInfo)13 LambdaQueryWrapper (com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper)11 Result (org.jeecg.common.api.vo.Result)10 List (java.util.List)9 User (org.apache.dolphinscheduler.dao.entity.User)9 Field (java.lang.reflect.Field)8 Date (java.util.Date)8 Collectors (java.util.stream.Collectors)7 UserRolesVo (top.hcode.hoj.pojo.vo.UserRolesVo)7