refactor:优化时间范围查询

This commit is contained in:
YunaiV
2022-07-27 00:15:59 +08:00
parent 1e3bd47213
commit 26a094a710
11 changed files with 116 additions and 122 deletions

View File

@@ -1,10 +1,10 @@
package cn.iocoder.yudao.module.infra.dal.mysql.logger;
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExportReqVO;
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExportReqVO;
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO;
import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO;
import org.apache.ibatis.annotations.Mapper;
@@ -19,28 +19,28 @@ import java.util.List;
public interface ApiAccessLogMapper extends BaseMapperX<ApiAccessLogDO> {
default PageResult<ApiAccessLogDO> selectPage(ApiAccessLogPageReqVO reqVO) {
return selectPage(reqVO, new QueryWrapperX<ApiAccessLogDO>()
.eqIfPresent("user_id", reqVO.getUserId())
.eqIfPresent("user_type", reqVO.getUserType())
.eqIfPresent("application_name", reqVO.getApplicationName())
.likeIfPresent("request_url", reqVO.getRequestUrl())
.betweenIfPresent("begin_time", reqVO.getBeginTime())
.geIfPresent("duration", reqVO.getDuration())
.eqIfPresent("result_code", reqVO.getResultCode())
.orderByDesc("id")
return selectPage(reqVO, new LambdaQueryWrapperX<ApiAccessLogDO>()
.eqIfPresent(ApiAccessLogDO::getUserId, reqVO.getUserId())
.eqIfPresent(ApiAccessLogDO::getUserType, reqVO.getUserType())
.eqIfPresent(ApiAccessLogDO::getApplicationName, reqVO.getApplicationName())
.likeIfPresent(ApiAccessLogDO::getRequestUrl, reqVO.getRequestUrl())
.betweenIfPresent(ApiAccessLogDO::getBeginTime, reqVO.getBeginTime())
.geIfPresent(ApiAccessLogDO::getDuration, reqVO.getDuration())
.eqIfPresent(ApiAccessLogDO::getResultCode, reqVO.getResultCode())
.orderByDesc(ApiAccessLogDO::getId)
);
}
default List<ApiAccessLogDO> selectList(ApiAccessLogExportReqVO reqVO) {
return selectList(new QueryWrapperX<ApiAccessLogDO>()
.eqIfPresent("user_id", reqVO.getUserId())
.eqIfPresent("user_type", reqVO.getUserType())
.eqIfPresent("application_name", reqVO.getApplicationName())
.likeIfPresent("request_url", reqVO.getRequestUrl())
.betweenIfPresent("begin_time", reqVO.getBeginTime())
.geIfPresent("duration", reqVO.getDuration())
.eqIfPresent("result_code", reqVO.getResultCode())
.orderByDesc("id")
return selectList(new LambdaQueryWrapperX<ApiAccessLogDO>()
.eqIfPresent(ApiAccessLogDO::getUserId, reqVO.getUserId())
.eqIfPresent(ApiAccessLogDO::getUserType, reqVO.getUserType())
.eqIfPresent(ApiAccessLogDO::getApplicationName, reqVO.getApplicationName())
.likeIfPresent(ApiAccessLogDO::getRequestUrl, reqVO.getRequestUrl())
.betweenIfPresent(ApiAccessLogDO::getBeginTime, reqVO.getBeginTime())
.geIfPresent(ApiAccessLogDO::getDuration, reqVO.getDuration())
.eqIfPresent(ApiAccessLogDO::getResultCode, reqVO.getResultCode())
.orderByDesc(ApiAccessLogDO::getId)
);
}

View File

@@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.infra.dal.mysql.logger;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExportReqVO;
import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO;
import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO;
@@ -19,26 +19,26 @@ import java.util.List;
public interface ApiErrorLogMapper extends BaseMapperX<ApiErrorLogDO> {
default PageResult<ApiErrorLogDO> selectPage(ApiErrorLogPageReqVO reqVO) {
return selectPage(reqVO, new QueryWrapperX<ApiErrorLogDO>()
.eqIfPresent("user_id", reqVO.getUserId())
.eqIfPresent("user_type", reqVO.getUserType())
.eqIfPresent("application_name", reqVO.getApplicationName())
.likeIfPresent("request_url", reqVO.getRequestUrl())
.betweenIfPresent("exception_time", reqVO.getExceptionTime())
.eqIfPresent("process_status", reqVO.getProcessStatus())
.orderByDesc("id")
return selectPage(reqVO, new LambdaQueryWrapperX<ApiErrorLogDO>()
.eqIfPresent(ApiErrorLogDO::getUserId, reqVO.getUserId())
.eqIfPresent(ApiErrorLogDO::getUserType, reqVO.getUserType())
.eqIfPresent(ApiErrorLogDO::getApplicationName, reqVO.getApplicationName())
.likeIfPresent(ApiErrorLogDO::getRequestUrl, reqVO.getRequestUrl())
.betweenIfPresent(ApiErrorLogDO::getExceptionTime, reqVO.getExceptionTime())
.eqIfPresent(ApiErrorLogDO::getProcessStatus, reqVO.getProcessStatus())
.orderByDesc(ApiErrorLogDO::getId)
);
}
default List<ApiErrorLogDO> selectList(ApiErrorLogExportReqVO reqVO) {
return selectList(new QueryWrapperX<ApiErrorLogDO>()
.eqIfPresent("user_id", reqVO.getUserId())
.eqIfPresent("user_type", reqVO.getUserType())
.eqIfPresent("application_name", reqVO.getApplicationName())
.likeIfPresent("request_url", reqVO.getRequestUrl())
.betweenIfPresent("exception_time", reqVO.getExceptionTime())
.eqIfPresent("process_status", reqVO.getProcessStatus())
.orderByDesc("id")
return selectList(new LambdaQueryWrapperX<ApiErrorLogDO>()
.eqIfPresent(ApiErrorLogDO::getUserId, reqVO.getUserId())
.eqIfPresent(ApiErrorLogDO::getUserType, reqVO.getUserType())
.eqIfPresent(ApiErrorLogDO::getApplicationName, reqVO.getApplicationName())
.likeIfPresent(ApiErrorLogDO::getRequestUrl, reqVO.getRequestUrl())
.betweenIfPresent(ApiErrorLogDO::getExceptionTime, reqVO.getExceptionTime())
.eqIfPresent(ApiErrorLogDO::getProcessStatus, reqVO.getProcessStatus())
.orderByDesc(ApiErrorLogDO::getId)
);
}