|
1 | 1 | package com.github.cadecode.uniboot.framework.controller; |
2 | 2 |
|
3 | 3 | import cn.hutool.core.util.ObjectUtil; |
4 | | -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
5 | 4 | import com.github.cadecode.uniboot.common.core.web.response.PageResult; |
6 | 5 | import com.github.cadecode.uniboot.common.plugin.mybatis.converter.BoolToIntTypeHandler; |
7 | 6 | import com.github.cadecode.uniboot.framework.annotation.ApiFormat; |
|
10 | 9 | import com.github.cadecode.uniboot.framework.convert.SysLogConvert; |
11 | 10 | import com.github.cadecode.uniboot.framework.request.SysLogRequest.SysLogPageRequest; |
12 | 11 | import com.github.cadecode.uniboot.framework.service.SysLogService; |
| 12 | +import com.github.pagehelper.PageHelper; |
| 13 | +import com.github.pagehelper.PageInfo; |
13 | 14 | import io.swagger.annotations.Api; |
14 | 15 | import io.swagger.annotations.ApiOperation; |
15 | 16 | import lombok.RequiredArgsConstructor; |
@@ -44,17 +45,18 @@ public class SysLogController { |
44 | 45 | @ApiOperation("查询列表") |
45 | 46 | @PostMapping("page") |
46 | 47 | public PageResult<SysLogPageVo> page(@RequestBody @Valid SysLogPageRequest request) { |
47 | | - Page<SysLog> page = logService.lambdaQuery() |
48 | | - .ge(ObjectUtil.isNotEmpty(request.getStartTime()), SysLog::getCreateTime, request.getStartTime()) |
49 | | - .le(ObjectUtil.isNotEmpty(request.getEndTime()), SysLog::getCreateTime, request.getEndTime()) |
50 | | - .in(ObjectUtil.isNotEmpty(request.getLogTypeList()), SysLog::getLogType, request.getLogTypeList()) |
51 | | - .likeRight(ObjectUtil.isNotEmpty(request.getAccessUser()), SysLog::getAccessUser, request.getAccessUser()) |
52 | | - .like(ObjectUtil.isNotEmpty(request.getUrl()), SysLog::getUrl, request.getUrl()) |
53 | | - .eq(ObjectUtil.isNotNull(request.getExceptional()), SysLog::getExceptional, BoolToIntTypeHandler.mapping(request.getExceptional())) |
54 | | - .orderByDesc(SysLog::getCreateTime) |
55 | | - .page(new Page<>(request.getPageNumber(), request.getPageSize())); |
56 | | - List<SysLogPageVo> voList = SysLogConvert.INSTANCE.poToVo(page.getRecords()); |
57 | | - return new PageResult<>((int) page.getTotal(), voList); |
| 48 | + PageInfo<SysLog> pageInfo = PageHelper.startPage(request.getPageNumber(), request.getPageSize()) |
| 49 | + .doSelectPageInfo(() -> logService.lambdaQuery() |
| 50 | + .ge(ObjectUtil.isNotEmpty(request.getStartTime()), SysLog::getCreateTime, request.getStartTime()) |
| 51 | + .le(ObjectUtil.isNotEmpty(request.getEndTime()), SysLog::getCreateTime, request.getEndTime()) |
| 52 | + .in(ObjectUtil.isNotEmpty(request.getLogTypeList()), SysLog::getLogType, request.getLogTypeList()) |
| 53 | + .likeRight(ObjectUtil.isNotEmpty(request.getAccessUser()), SysLog::getAccessUser, request.getAccessUser()) |
| 54 | + .like(ObjectUtil.isNotEmpty(request.getUrl()), SysLog::getUrl, request.getUrl()) |
| 55 | + .eq(ObjectUtil.isNotNull(request.getExceptional()), SysLog::getExceptional, BoolToIntTypeHandler.mapping(request.getExceptional())) |
| 56 | + .orderByDesc(SysLog::getCreateTime) |
| 57 | + .list()); |
| 58 | + List<SysLogPageVo> voList = SysLogConvert.INSTANCE.poToVo(pageInfo.getList()); |
| 59 | + return new PageResult<>((int) pageInfo.getTotal(), voList); |
58 | 60 | } |
59 | 61 |
|
60 | 62 | @ApiOperation("删除") |
|
0 commit comments