feat(REQ-2997): 获取total
This commit is contained in:
parent
0d2feaffaa
commit
7d955d1499
@ -6,6 +6,7 @@ import cn.axzo.log.platform.client.model.req.LogBatchDeleteReq;
|
||||
import cn.axzo.log.platform.client.model.req.LogFindReq;
|
||||
import cn.axzo.log.platform.client.model.resp.LogResp;
|
||||
import cn.axzo.log.platform.server.dto.FindLogDto;
|
||||
import cn.axzo.log.platform.server.dto.FindLogResp;
|
||||
import cn.axzo.log.platform.server.entity.LogEntity;
|
||||
import cn.axzo.log.platform.server.service.LogService;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
@ -106,7 +107,7 @@ public class WebLogController {
|
||||
* @return 日志列表
|
||||
*/
|
||||
@PostMapping(value = "/findLogs")
|
||||
CommonResponse<List<LogEntity>> findLogs(@RequestBody @Valid FindLogDto req){
|
||||
CommonResponse<FindLogResp> findLogs(@RequestBody @Valid FindLogDto req){
|
||||
if (!directQueryValid) {
|
||||
return CommonResponse.fail("direct query is not allowed");
|
||||
}
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
package cn.axzo.log.platform.server.dto;
|
||||
|
||||
import cn.axzo.log.platform.server.entity.LogEntity;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author chenwenjian
|
||||
* @version 1.0
|
||||
* @date 2024/10/16 18:24
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class FindLogResp {
|
||||
|
||||
private Integer pageSize;
|
||||
|
||||
private Integer pageNum;
|
||||
|
||||
private Long total;
|
||||
|
||||
private List<LogEntity> data;
|
||||
}
|
||||
@ -6,6 +6,7 @@ import cn.axzo.log.platform.client.model.req.LogBatchDeleteReq;
|
||||
import cn.axzo.log.platform.client.model.req.LogFindReq;
|
||||
import cn.axzo.log.platform.client.model.resp.LogResp;
|
||||
import cn.axzo.log.platform.server.dto.FindLogDto;
|
||||
import cn.axzo.log.platform.server.dto.FindLogResp;
|
||||
import cn.axzo.log.platform.server.entity.LogEntity;
|
||||
|
||||
import java.util.List;
|
||||
@ -27,5 +28,5 @@ public interface LogService {
|
||||
|
||||
Boolean batchDeleteLogs(LogBatchDeleteReq req);
|
||||
|
||||
List<LogEntity> findLogs(FindLogDto req);
|
||||
FindLogResp findLogs(FindLogDto req);
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import cn.axzo.log.platform.client.model.req.LogBatchDeleteReq;
|
||||
import cn.axzo.log.platform.client.model.req.LogFindReq;
|
||||
import cn.axzo.log.platform.client.model.resp.LogResp;
|
||||
import cn.axzo.log.platform.server.dto.FindLogDto;
|
||||
import cn.axzo.log.platform.server.dto.FindLogResp;
|
||||
import cn.axzo.log.platform.server.entity.LogEntity;
|
||||
import cn.axzo.log.platform.server.mapper.LogMapper;
|
||||
import cn.axzo.log.platform.server.service.LogService;
|
||||
@ -169,7 +170,7 @@ public class LogServiceImpl implements LogService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LogEntity> findLogs(FindLogDto req) {
|
||||
public FindLogResp findLogs(FindLogDto req) {
|
||||
Document filterDoc = new Document();
|
||||
int skip = 0;
|
||||
int limit = 0;
|
||||
@ -205,7 +206,18 @@ public class LogServiceImpl implements LogService {
|
||||
logEntityList.add(logEntity);
|
||||
}
|
||||
}
|
||||
return logEntityList;
|
||||
FindLogResp findLogResp = new FindLogResp();
|
||||
findLogResp.setPageSize(req.getPageSize());
|
||||
findLogResp.setPageNum(req.getPageNum());
|
||||
findLogResp.setTotal(0L);
|
||||
findLogResp.setData(logEntityList);
|
||||
if (CollUtil.isEmpty(logEntityList)) {
|
||||
return findLogResp;
|
||||
}
|
||||
// 查询记录总数
|
||||
long count = logCollection.countDocuments(filterDoc);
|
||||
findLogResp.setTotal(count);
|
||||
return findLogResp;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Loading…
Reference in New Issue
Block a user