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

@ -160,7 +160,7 @@ ps核心功能已经实现正在对接微信小程序中...
|---------------------------------------------------------------------------------------------|-----------------------|-----------|----------------------------------------------------------------| |---------------------------------------------------------------------------------------------|-----------------------|-----------|----------------------------------------------------------------|
| [Spring Boot](https://spring.io/projects/spring-boot) | 应用开发框架 | 2.6.9 | [文档](https://github.com/YunaiV/SpringBoot-Labs) | | [Spring Boot](https://spring.io/projects/spring-boot) | 应用开发框架 | 2.6.9 | [文档](https://github.com/YunaiV/SpringBoot-Labs) |
| [MySQL](https://www.mysql.com/cn/) | 数据库服务器 | 5.7 | | | [MySQL](https://www.mysql.com/cn/) | 数据库服务器 | 5.7 | |
| [Druid](https://github.com/alibaba/druid) | JDBC 连接池、监控组件 | 1.2.8 | [文档](http://www.iocoder.cn/Spring-Boot/datasource-pool/?yudao) | | [Druid](https://github.com/alibaba/druid) | JDBC 连接池、监控组件 | 1.2.11 | [文档](http://www.iocoder.cn/Spring-Boot/datasource-pool/?yudao) |
| [MyBatis Plus](https://mp.baomidou.com/) | MyBatis 增强工具包 | 3.5.2 | [文档](http://www.iocoder.cn/Spring-Boot/MyBatis/?yudao) | | [MyBatis Plus](https://mp.baomidou.com/) | MyBatis 增强工具包 | 3.5.2 | [文档](http://www.iocoder.cn/Spring-Boot/MyBatis/?yudao) |
| [Dynamic Datasource](https://dynamic-datasource.com/) | 动态数据源 | 3.5.0 | [文档](http://www.iocoder.cn/Spring-Boot/datasource-pool/?yudao) | | [Dynamic Datasource](https://dynamic-datasource.com/) | 动态数据源 | 3.5.0 | [文档](http://www.iocoder.cn/Spring-Boot/datasource-pool/?yudao) |
| [Redis](https://redis.io/) | key-value 数据库 | 5.0 | | | [Redis](https://redis.io/) | key-value 数据库 | 5.0 | |

View File

@ -2,14 +2,8 @@ package cn.iocoder.yudao.framework.common.util.collection;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.TypeUtil;
import org.springframework.cglib.core.TypeUtils;
import java.lang.reflect.Array;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Function; import java.util.function.Function;
@ -53,4 +47,11 @@ public class ArrayUtils {
return ArrayUtil.toArray(from, (Class<T>) CollectionUtil.getElementType(from.iterator())); return ArrayUtil.toArray(from, (Class<T>) CollectionUtil.getElementType(from.iterator()));
} }
public static <T> T get(T[] array, int index) {
if (null == array || index >= array.length) {
return null;
}
return array[index];
}
} }

View File

@ -51,6 +51,10 @@ public class JsonUtils {
return objectMapper.writeValueAsBytes(object); return objectMapper.writeValueAsBytes(object);
} }
@SneakyThrows
public static String toJsonPrettyString(Object object) {
return objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(object);
}
public static <T> T parseObject(String text, Class<T> clazz) { public static <T> T parseObject(String text, Class<T> clazz) {
if (StrUtil.isEmpty(text)) { if (StrUtil.isEmpty(text)) {

View File

@ -1,8 +1,8 @@
package cn.iocoder.yudao.framework.mybatis.core.query; package cn.iocoder.yudao.framework.mybatis.core.query;
import cn.hutool.core.util.ArrayUtil;
import cn.iocoder.yudao.framework.common.util.collection.ArrayUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ArrayUtils;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
@ -33,7 +33,7 @@ public class LambdaQueryWrapperX<T> extends LambdaQueryWrapper<T> {
} }
public LambdaQueryWrapperX<T> inIfPresent(SFunction<T, ?> column, Object... values) { public LambdaQueryWrapperX<T> inIfPresent(SFunction<T, ?> column, Object... values) {
if (!ArrayUtils.isEmpty(values)) { if (!ArrayUtil.isEmpty(values)) {
return (LambdaQueryWrapperX<T>) super.in(column, values); return (LambdaQueryWrapperX<T>) super.in(column, values);
} }
return this; return this;
@ -95,16 +95,9 @@ public class LambdaQueryWrapperX<T> extends LambdaQueryWrapper<T> {
} }
public LambdaQueryWrapperX<T> betweenIfPresent(SFunction<T, ?> column, Object[] values) { public LambdaQueryWrapperX<T> betweenIfPresent(SFunction<T, ?> column, Object[] values) {
if (values!= null && values.length >0 && values[0] != null && values[1] != null) { Object val1 = ArrayUtils.get(values, 0);
return (LambdaQueryWrapperX<T>) super.between(column, values[0], values[1]); Object val2 = ArrayUtils.get(values, 1);
} return betweenIfPresent(column, val1, val2);
if (values != null && values.length >0 && values[0] != null) {
return (LambdaQueryWrapperX<T>) ge(column, values[0]);
}
if (values != null && values.length >0 && values[1] != null) {
return (LambdaQueryWrapperX<T>) le(column, values[2]);
}
return this;
} }
// ========== 重写父类方法方便链式调用 ========== // ========== 重写父类方法方便链式调用 ==========

View File

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

View File

@ -60,7 +60,7 @@ public class FileServiceTest extends BaseDbUnitTest {
FilePageReqVO reqVO = new FilePageReqVO(); FilePageReqVO reqVO = new FilePageReqVO();
reqVO.setPath("yunai"); reqVO.setPath("yunai");
reqVO.setType("jp"); reqVO.setType("jp");
reqVO.setCreateTime((new Date[]{buildTime(2021, 1, 10),buildTime(2021, 1, 20)})); reqVO.setCreateTime((new Date[]{buildTime(2021, 1, 10), buildTime(2021, 1, 20)}));
// 调用 // 调用
PageResult<FileDO> pageResult = fileService.getFilePage(reqVO); PageResult<FileDO> pageResult = fileService.getFilePage(reqVO);

View File

@ -2,11 +2,10 @@ package cn.iocoder.yudao.module.system.dal.mysql.errorcode;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; 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.system.controller.admin.errorcode.vo.ErrorCodeExportReqVO; import cn.iocoder.yudao.module.system.controller.admin.errorcode.vo.ErrorCodeExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.errorcode.vo.ErrorCodePageReqVO; import cn.iocoder.yudao.module.system.controller.admin.errorcode.vo.ErrorCodePageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.errorcode.ErrorCodeDO; import cn.iocoder.yudao.module.system.dal.dataobject.errorcode.ErrorCodeDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.Collection; import java.util.Collection;
@ -17,36 +16,36 @@ import java.util.List;
public interface ErrorCodeMapper extends BaseMapperX<ErrorCodeDO> { public interface ErrorCodeMapper extends BaseMapperX<ErrorCodeDO> {
default PageResult<ErrorCodeDO> selectPage(ErrorCodePageReqVO reqVO) { default PageResult<ErrorCodeDO> selectPage(ErrorCodePageReqVO reqVO) {
return selectPage(reqVO, new QueryWrapperX<ErrorCodeDO>() return selectPage(reqVO, new LambdaQueryWrapperX<ErrorCodeDO>()
.eqIfPresent("type", reqVO.getType()) .eqIfPresent(ErrorCodeDO::getType, reqVO.getType())
.likeIfPresent("application_name", reqVO.getApplicationName()) .likeIfPresent(ErrorCodeDO::getApplicationName, reqVO.getApplicationName())
.eqIfPresent("code", reqVO.getCode()) .eqIfPresent(ErrorCodeDO::getCode, reqVO.getCode())
.likeIfPresent("message", reqVO.getMessage()) .likeIfPresent(ErrorCodeDO::getMessage, reqVO.getMessage())
.betweenIfPresent("create_time", reqVO.getCreateTime()) .betweenIfPresent(ErrorCodeDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc("code")); .orderByDesc(ErrorCodeDO::getCode));
} }
default List<ErrorCodeDO> selectList(ErrorCodeExportReqVO reqVO) { default List<ErrorCodeDO> selectList(ErrorCodeExportReqVO reqVO) {
return selectList(new QueryWrapperX<ErrorCodeDO>() return selectList(new LambdaQueryWrapperX<ErrorCodeDO>()
.eqIfPresent("type", reqVO.getType()) .eqIfPresent(ErrorCodeDO::getType, reqVO.getType())
.likeIfPresent("application_name", reqVO.getApplicationName()) .likeIfPresent(ErrorCodeDO::getApplicationName, reqVO.getApplicationName())
.eqIfPresent("code", reqVO.getCode()) .eqIfPresent(ErrorCodeDO::getCode, reqVO.getCode())
.likeIfPresent("message", reqVO.getMessage()) .likeIfPresent(ErrorCodeDO::getMessage, reqVO.getMessage())
.betweenIfPresent("create_time", reqVO.getCreateTime()) .betweenIfPresent(ErrorCodeDO::getCreateTime, reqVO.getCreateTime())
.orderByAsc("application_name", "code")); .orderByDesc(ErrorCodeDO::getCode));
} }
default List<ErrorCodeDO> selectListByCodes(Collection<Integer> codes) { default List<ErrorCodeDO> selectListByCodes(Collection<Integer> codes) {
return selectList(new QueryWrapper<ErrorCodeDO>().in("code", codes)); return selectList(new LambdaQueryWrapperX<ErrorCodeDO>().in(ErrorCodeDO::getCode, codes));
} }
default ErrorCodeDO selectByCode(Integer code) { default ErrorCodeDO selectByCode(Integer code) {
return selectOne(new QueryWrapper<ErrorCodeDO>().eq("code", code)); return selectOne(new LambdaQueryWrapperX<ErrorCodeDO>().eq(ErrorCodeDO::getCode, code));
} }
default List<ErrorCodeDO> selectListByApplicationNameAndUpdateTimeGt(String applicationName, Date minUpdateTime) { default List<ErrorCodeDO> selectListByApplicationNameAndUpdateTimeGt(String applicationName, Date minUpdateTime) {
return selectList(new QueryWrapperX<ErrorCodeDO>().eq("application_name", applicationName) return selectList(new LambdaQueryWrapperX<ErrorCodeDO>().eq(ErrorCodeDO::getApplicationName, applicationName)
.gtIfPresent("update_time", minUpdateTime)); .gtIfPresent(ErrorCodeDO::getUpdateTime, minUpdateTime));
} }
} }

View File

@ -1,11 +1,11 @@
package cn.iocoder.yudao.module.system.dal.mysql.logger; package cn.iocoder.yudao.module.system.dal.mysql.logger;
import cn.iocoder.yudao.module.system.dal.dataobject.logger.LoginLogDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; 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.system.controller.admin.logger.vo.loginlog.LoginLogExportReqVO; import cn.iocoder.yudao.module.system.controller.admin.logger.vo.loginlog.LoginLogExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.logger.vo.loginlog.LoginLogPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.logger.vo.loginlog.LoginLogPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.logger.LoginLogDO;
import cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum; import cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -15,30 +15,30 @@ import java.util.List;
public interface LoginLogMapper extends BaseMapperX<LoginLogDO> { public interface LoginLogMapper extends BaseMapperX<LoginLogDO> {
default PageResult<LoginLogDO> selectPage(LoginLogPageReqVO reqVO) { default PageResult<LoginLogDO> selectPage(LoginLogPageReqVO reqVO) {
QueryWrapperX<LoginLogDO> query = new QueryWrapperX<LoginLogDO>() LambdaQueryWrapperX<LoginLogDO> query = new LambdaQueryWrapperX<LoginLogDO>()
.likeIfPresent("user_ip", reqVO.getUserIp()) .likeIfPresent(LoginLogDO::getUserIp, reqVO.getUserIp())
.likeIfPresent("username", reqVO.getUsername()) .likeIfPresent(LoginLogDO::getUsername, reqVO.getUsername())
.betweenIfPresent("create_time", reqVO.getCreateTime()); .betweenIfPresent(LoginLogDO::getCreateTime, reqVO.getCreateTime());
if (Boolean.TRUE.equals(reqVO.getStatus())) { if (Boolean.TRUE.equals(reqVO.getStatus())) {
query.eq("result", LoginResultEnum.SUCCESS.getResult()); query.eq(LoginLogDO::getResult, LoginResultEnum.SUCCESS.getResult());
} else if (Boolean.FALSE.equals(reqVO.getStatus())) { } else if (Boolean.FALSE.equals(reqVO.getStatus())) {
query.gt("result", LoginResultEnum.SUCCESS.getResult()); query.gt(LoginLogDO::getResult, LoginResultEnum.SUCCESS.getResult());
} }
query.orderByDesc("id"); // 降序 query.orderByDesc(LoginLogDO::getId); // 降序
return selectPage(reqVO, query); return selectPage(reqVO, query);
} }
default List<LoginLogDO> selectList(LoginLogExportReqVO reqVO) { default List<LoginLogDO> selectList(LoginLogExportReqVO reqVO) {
QueryWrapperX<LoginLogDO> query = new QueryWrapperX<LoginLogDO>() LambdaQueryWrapperX<LoginLogDO> query = new LambdaQueryWrapperX<LoginLogDO>()
.likeIfPresent("user_ip", reqVO.getUserIp()) .likeIfPresent(LoginLogDO::getUserIp, reqVO.getUserIp())
.likeIfPresent("username", reqVO.getUsername()) .likeIfPresent(LoginLogDO::getUsername, reqVO.getUsername())
.betweenIfPresent("create_time", reqVO.getCreateTime()); .betweenIfPresent(LoginLogDO::getCreateTime, reqVO.getCreateTime());
if (Boolean.TRUE.equals(reqVO.getStatus())) { if (Boolean.TRUE.equals(reqVO.getStatus())) {
query.eq("result", LoginResultEnum.SUCCESS.getResult()); query.eq(LoginLogDO::getResult, LoginResultEnum.SUCCESS.getResult());
} else if (Boolean.FALSE.equals(reqVO.getStatus())) { } else if (Boolean.FALSE.equals(reqVO.getStatus())) {
query.gt("result", LoginResultEnum.SUCCESS.getResult()); query.gt(LoginLogDO::getResult, LoginResultEnum.SUCCESS.getResult());
} }
query.orderByDesc("id"); // 降序 query.orderByDesc(LoginLogDO::getId); // 降序
return selectList(query); return selectList(query);
} }

View File

@ -1,11 +1,11 @@
package cn.iocoder.yudao.module.system.dal.mysql.sms; package cn.iocoder.yudao.module.system.dal.mysql.sms;
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.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogExportReqVO; import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.sms.vo.log.SmsLogPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsLogDO; import cn.iocoder.yudao.module.system.dal.dataobject.sms.SmsLogDO;
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 org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.List; import java.util.List;
@ -14,27 +14,27 @@ import java.util.List;
public interface SmsLogMapper extends BaseMapperX<SmsLogDO> { public interface SmsLogMapper extends BaseMapperX<SmsLogDO> {
default PageResult<SmsLogDO> selectPage(SmsLogPageReqVO reqVO) { default PageResult<SmsLogDO> selectPage(SmsLogPageReqVO reqVO) {
return selectPage(reqVO, new QueryWrapperX<SmsLogDO>() return selectPage(reqVO, new LambdaQueryWrapperX<SmsLogDO>()
.eqIfPresent("channel_id", reqVO.getChannelId()) .eqIfPresent(SmsLogDO::getChannelId, reqVO.getChannelId())
.eqIfPresent("template_id", reqVO.getTemplateId()) .eqIfPresent(SmsLogDO::getTemplateId, reqVO.getTemplateId())
.likeIfPresent("mobile", reqVO.getMobile()) .likeIfPresent(SmsLogDO::getMobile, reqVO.getMobile())
.eqIfPresent("send_status", reqVO.getSendStatus()) .eqIfPresent(SmsLogDO::getSendStatus, reqVO.getSendStatus())
.betweenIfPresent("send_time", reqVO.getSendTime()) .betweenIfPresent(SmsLogDO::getSendTime, reqVO.getSendTime())
.eqIfPresent("receive_status", reqVO.getReceiveStatus()) .eqIfPresent(SmsLogDO::getSendStatus, reqVO.getReceiveStatus())
.betweenIfPresent("receive_time", reqVO.getReceiveTime()) .betweenIfPresent(SmsLogDO::getReceiveTime, reqVO.getReceiveTime())
.orderByDesc("id")); .orderByDesc(SmsLogDO::getId));
} }
default List<SmsLogDO> selectList(SmsLogExportReqVO reqVO) { default List<SmsLogDO> selectList(SmsLogExportReqVO reqVO) {
return selectList(new QueryWrapperX<SmsLogDO>() return selectList(new LambdaQueryWrapperX<SmsLogDO>()
.eqIfPresent("channel_id", reqVO.getChannelId()) .eqIfPresent(SmsLogDO::getChannelId, reqVO.getChannelId())
.eqIfPresent("template_id", reqVO.getTemplateId()) .eqIfPresent(SmsLogDO::getTemplateId, reqVO.getTemplateId())
.likeIfPresent("mobile", reqVO.getMobile()) .likeIfPresent(SmsLogDO::getMobile, reqVO.getMobile())
.eqIfPresent("send_status", reqVO.getSendStatus()) .eqIfPresent(SmsLogDO::getSendStatus, reqVO.getSendStatus())
.betweenIfPresent("send_time", reqVO.getSendTime()) .betweenIfPresent(SmsLogDO::getSendTime, reqVO.getSendTime())
.eqIfPresent("receive_status", reqVO.getReceiveStatus()) .eqIfPresent(SmsLogDO::getSendStatus, reqVO.getReceiveStatus())
.betweenIfPresent("receive_time", reqVO.getReceiveTime()) .betweenIfPresent(SmsLogDO::getReceiveTime, reqVO.getReceiveTime())
.orderByDesc("id")); .orderByDesc(SmsLogDO::getId));
} }
} }

View File

@ -1,12 +1,11 @@
package cn.iocoder.yudao.module.system.dal.mysql.user; package cn.iocoder.yudao.module.system.dal.mysql.user;
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserExportReqVO;
import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserPageReqVO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -36,7 +35,6 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
.betweenIfPresent(AdminUserDO::getCreateTime, reqVO.getCreateTime()) .betweenIfPresent(AdminUserDO::getCreateTime, reqVO.getCreateTime())
.inIfPresent(AdminUserDO::getDeptId, deptIds) .inIfPresent(AdminUserDO::getDeptId, deptIds)
.orderByDesc(AdminUserDO::getId)); .orderByDesc(AdminUserDO::getId));
} }
default List<AdminUserDO> selectList(UserExportReqVO reqVO, Collection<Long> deptIds) { default List<AdminUserDO> selectList(UserExportReqVO reqVO, Collection<Long> deptIds) {
@ -65,4 +63,3 @@ public interface AdminUserMapper extends BaseMapperX<AdminUserDO> {
} }
} }