From 26a094a7109eab46da240aec297efa73b1224c85 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 27 Jul 2022 00:15:59 +0800 Subject: [PATCH] =?UTF-8?q?refactor=EF=BC=9A=E4=BC=98=E5=8C=96=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E8=8C=83=E5=9B=B4=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- .../common/util/collection/ArrayUtils.java | 13 +++--- .../framework/common/util/json/JsonUtils.java | 4 ++ .../core/query/LambdaQueryWrapperX.java | 19 +++------ .../dal/mysql/logger/ApiAccessLogMapper.java | 42 +++++++++---------- .../dal/mysql/logger/ApiErrorLogMapper.java | 34 +++++++-------- .../infra/service/file/FileServiceTest.java | 2 +- .../dal/mysql/errorcode/ErrorCodeMapper.java | 39 +++++++++-------- .../dal/mysql/logger/LoginLogMapper.java | 32 +++++++------- .../system/dal/mysql/sms/SmsLogMapper.java | 42 +++++++++---------- .../dal/mysql/user/AdminUserMapper.java | 9 ++-- 11 files changed, 116 insertions(+), 122 deletions(-) diff --git a/README.md b/README.md index 428b4ffd0..269a48f5b 100644 --- a/README.md +++ b/README.md @@ -160,7 +160,7 @@ ps:核心功能已经实现,正在对接微信小程序中... |---------------------------------------------------------------------------------------------|-----------------------|-----------|----------------------------------------------------------------| | [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 | | -| [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) | | [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 | | diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/collection/ArrayUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/collection/ArrayUtils.java index 899acbfc7..366f96008 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/collection/ArrayUtils.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/collection/ArrayUtils.java @@ -2,14 +2,8 @@ package cn.iocoder.yudao.framework.common.util.collection; import cn.hutool.core.collection.CollectionUtil; 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.List; import java.util.function.Consumer; import java.util.function.Function; @@ -53,4 +47,11 @@ public class ArrayUtils { return ArrayUtil.toArray(from, (Class) CollectionUtil.getElementType(from.iterator())); } + public static T get(T[] array, int index) { + if (null == array || index >= array.length) { + return null; + } + return array[index]; + } + } diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/JsonUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/JsonUtils.java index b36ce74cf..0be190942 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/JsonUtils.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/JsonUtils.java @@ -51,6 +51,10 @@ public class JsonUtils { return objectMapper.writeValueAsBytes(object); } + @SneakyThrows + public static String toJsonPrettyString(Object object) { + return objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(object); + } public static T parseObject(String text, Class clazz) { if (StrUtil.isEmpty(text)) { diff --git a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/LambdaQueryWrapperX.java b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/LambdaQueryWrapperX.java index d387e2865..9fd1d16f8 100644 --- a/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/LambdaQueryWrapperX.java +++ b/yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/LambdaQueryWrapperX.java @@ -1,8 +1,8 @@ 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.QueryWrapper; -import com.baomidou.mybatisplus.core.toolkit.ArrayUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import org.springframework.util.StringUtils; @@ -33,7 +33,7 @@ public class LambdaQueryWrapperX extends LambdaQueryWrapper { } public LambdaQueryWrapperX inIfPresent(SFunction column, Object... values) { - if (!ArrayUtils.isEmpty(values)) { + if (!ArrayUtil.isEmpty(values)) { return (LambdaQueryWrapperX) super.in(column, values); } return this; @@ -95,16 +95,9 @@ public class LambdaQueryWrapperX extends LambdaQueryWrapper { } public LambdaQueryWrapperX betweenIfPresent(SFunction column, Object[] values) { - if (values!= null && values.length >0 && values[0] != null && values[1] != null) { - return (LambdaQueryWrapperX) super.between(column, values[0], values[1]); - } - if (values != null && values.length >0 && values[0] != null) { - return (LambdaQueryWrapperX) ge(column, values[0]); - } - if (values != null && values.length >0 && values[1] != null) { - return (LambdaQueryWrapperX) le(column, values[2]); - } - return this; + Object val1 = ArrayUtils.get(values, 0); + Object val2 = ArrayUtils.get(values, 1); + return betweenIfPresent(column, val1, val2); } // ========== 重写父类方法,方便链式调用 ========== diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/logger/ApiAccessLogMapper.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/logger/ApiAccessLogMapper.java index 7adc09a38..427675636 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/logger/ApiAccessLogMapper.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/logger/ApiAccessLogMapper.java @@ -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 { default PageResult selectPage(ApiAccessLogPageReqVO reqVO) { - return selectPage(reqVO, new QueryWrapperX() - .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() + .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 selectList(ApiAccessLogExportReqVO reqVO) { - return selectList(new QueryWrapperX() - .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() + .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) ); } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/logger/ApiErrorLogMapper.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/logger/ApiErrorLogMapper.java index 17959a950..e9748b624 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/logger/ApiErrorLogMapper.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/logger/ApiErrorLogMapper.java @@ -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 { default PageResult selectPage(ApiErrorLogPageReqVO reqVO) { - return selectPage(reqVO, new QueryWrapperX() - .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() + .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 selectList(ApiErrorLogExportReqVO reqVO) { - return selectList(new QueryWrapperX() - .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() + .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) ); } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileServiceTest.java b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileServiceTest.java index 2ccceac69..9984da2de 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileServiceTest.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/file/FileServiceTest.java @@ -60,7 +60,7 @@ public class FileServiceTest extends BaseDbUnitTest { FilePageReqVO reqVO = new FilePageReqVO(); reqVO.setPath("yunai"); 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 pageResult = fileService.getFilePage(reqVO); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/errorcode/ErrorCodeMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/errorcode/ErrorCodeMapper.java index 0c3f77330..0fcfbf68b 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/errorcode/ErrorCodeMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/errorcode/ErrorCodeMapper.java @@ -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.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.ErrorCodePageReqVO; 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 java.util.Collection; @@ -17,36 +16,36 @@ import java.util.List; public interface ErrorCodeMapper extends BaseMapperX { default PageResult selectPage(ErrorCodePageReqVO reqVO) { - return selectPage(reqVO, new QueryWrapperX() - .eqIfPresent("type", reqVO.getType()) - .likeIfPresent("application_name", reqVO.getApplicationName()) - .eqIfPresent("code", reqVO.getCode()) - .likeIfPresent("message", reqVO.getMessage()) - .betweenIfPresent("create_time", reqVO.getCreateTime()) - .orderByDesc("code")); + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(ErrorCodeDO::getType, reqVO.getType()) + .likeIfPresent(ErrorCodeDO::getApplicationName, reqVO.getApplicationName()) + .eqIfPresent(ErrorCodeDO::getCode, reqVO.getCode()) + .likeIfPresent(ErrorCodeDO::getMessage, reqVO.getMessage()) + .betweenIfPresent(ErrorCodeDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(ErrorCodeDO::getCode)); } default List selectList(ErrorCodeExportReqVO reqVO) { - return selectList(new QueryWrapperX() - .eqIfPresent("type", reqVO.getType()) - .likeIfPresent("application_name", reqVO.getApplicationName()) - .eqIfPresent("code", reqVO.getCode()) - .likeIfPresent("message", reqVO.getMessage()) - .betweenIfPresent("create_time", reqVO.getCreateTime()) - .orderByAsc("application_name", "code")); + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(ErrorCodeDO::getType, reqVO.getType()) + .likeIfPresent(ErrorCodeDO::getApplicationName, reqVO.getApplicationName()) + .eqIfPresent(ErrorCodeDO::getCode, reqVO.getCode()) + .likeIfPresent(ErrorCodeDO::getMessage, reqVO.getMessage()) + .betweenIfPresent(ErrorCodeDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(ErrorCodeDO::getCode)); } default List selectListByCodes(Collection codes) { - return selectList(new QueryWrapper().in("code", codes)); + return selectList(new LambdaQueryWrapperX().in(ErrorCodeDO::getCode, codes)); } default ErrorCodeDO selectByCode(Integer code) { - return selectOne(new QueryWrapper().eq("code", code)); + return selectOne(new LambdaQueryWrapperX().eq(ErrorCodeDO::getCode, code)); } default List selectListByApplicationNameAndUpdateTimeGt(String applicationName, Date minUpdateTime) { - return selectList(new QueryWrapperX().eq("application_name", applicationName) - .gtIfPresent("update_time", minUpdateTime)); + return selectList(new LambdaQueryWrapperX().eq(ErrorCodeDO::getApplicationName, applicationName) + .gtIfPresent(ErrorCodeDO::getUpdateTime, minUpdateTime)); } } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/logger/LoginLogMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/logger/LoginLogMapper.java index dfa983b9f..1617fe075 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/logger/LoginLogMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/logger/LoginLogMapper.java @@ -1,11 +1,11 @@ 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.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.LoginLogPageReqVO; +import cn.iocoder.yudao.module.system.dal.dataobject.logger.LoginLogDO; import cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum; import org.apache.ibatis.annotations.Mapper; @@ -15,30 +15,30 @@ import java.util.List; public interface LoginLogMapper extends BaseMapperX { default PageResult selectPage(LoginLogPageReqVO reqVO) { - QueryWrapperX query = new QueryWrapperX() - .likeIfPresent("user_ip", reqVO.getUserIp()) - .likeIfPresent("username", reqVO.getUsername()) - .betweenIfPresent("create_time", reqVO.getCreateTime()); + LambdaQueryWrapperX query = new LambdaQueryWrapperX() + .likeIfPresent(LoginLogDO::getUserIp, reqVO.getUserIp()) + .likeIfPresent(LoginLogDO::getUsername, reqVO.getUsername()) + .betweenIfPresent(LoginLogDO::getCreateTime, reqVO.getCreateTime()); 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())) { - query.gt("result", LoginResultEnum.SUCCESS.getResult()); + query.gt(LoginLogDO::getResult, LoginResultEnum.SUCCESS.getResult()); } - query.orderByDesc("id"); // 降序 + query.orderByDesc(LoginLogDO::getId); // 降序 return selectPage(reqVO, query); } default List selectList(LoginLogExportReqVO reqVO) { - QueryWrapperX query = new QueryWrapperX() - .likeIfPresent("user_ip", reqVO.getUserIp()) - .likeIfPresent("username", reqVO.getUsername()) - .betweenIfPresent("create_time", reqVO.getCreateTime()); + LambdaQueryWrapperX query = new LambdaQueryWrapperX() + .likeIfPresent(LoginLogDO::getUserIp, reqVO.getUserIp()) + .likeIfPresent(LoginLogDO::getUsername, reqVO.getUsername()) + .betweenIfPresent(LoginLogDO::getCreateTime, reqVO.getCreateTime()); 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())) { - query.gt("result", LoginResultEnum.SUCCESS.getResult()); + query.gt(LoginLogDO::getResult, LoginResultEnum.SUCCESS.getResult()); } - query.orderByDesc("id"); // 降序 + query.orderByDesc(LoginLogDO::getId); // 降序 return selectList(query); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/sms/SmsLogMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/sms/SmsLogMapper.java index 49bbf8b58..33f93a8a1 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/sms/SmsLogMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/sms/SmsLogMapper.java @@ -1,11 +1,11 @@ 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.SmsLogPageReqVO; 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 java.util.List; @@ -14,27 +14,27 @@ import java.util.List; public interface SmsLogMapper extends BaseMapperX { default PageResult selectPage(SmsLogPageReqVO reqVO) { - return selectPage(reqVO, new QueryWrapperX() - .eqIfPresent("channel_id", reqVO.getChannelId()) - .eqIfPresent("template_id", reqVO.getTemplateId()) - .likeIfPresent("mobile", reqVO.getMobile()) - .eqIfPresent("send_status", reqVO.getSendStatus()) - .betweenIfPresent("send_time", reqVO.getSendTime()) - .eqIfPresent("receive_status", reqVO.getReceiveStatus()) - .betweenIfPresent("receive_time", reqVO.getReceiveTime()) - .orderByDesc("id")); + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(SmsLogDO::getChannelId, reqVO.getChannelId()) + .eqIfPresent(SmsLogDO::getTemplateId, reqVO.getTemplateId()) + .likeIfPresent(SmsLogDO::getMobile, reqVO.getMobile()) + .eqIfPresent(SmsLogDO::getSendStatus, reqVO.getSendStatus()) + .betweenIfPresent(SmsLogDO::getSendTime, reqVO.getSendTime()) + .eqIfPresent(SmsLogDO::getSendStatus, reqVO.getReceiveStatus()) + .betweenIfPresent(SmsLogDO::getReceiveTime, reqVO.getReceiveTime()) + .orderByDesc(SmsLogDO::getId)); } default List selectList(SmsLogExportReqVO reqVO) { - return selectList(new QueryWrapperX() - .eqIfPresent("channel_id", reqVO.getChannelId()) - .eqIfPresent("template_id", reqVO.getTemplateId()) - .likeIfPresent("mobile", reqVO.getMobile()) - .eqIfPresent("send_status", reqVO.getSendStatus()) - .betweenIfPresent("send_time", reqVO.getSendTime()) - .eqIfPresent("receive_status", reqVO.getReceiveStatus()) - .betweenIfPresent("receive_time", reqVO.getReceiveTime()) - .orderByDesc("id")); + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(SmsLogDO::getChannelId, reqVO.getChannelId()) + .eqIfPresent(SmsLogDO::getTemplateId, reqVO.getTemplateId()) + .likeIfPresent(SmsLogDO::getMobile, reqVO.getMobile()) + .eqIfPresent(SmsLogDO::getSendStatus, reqVO.getSendStatus()) + .betweenIfPresent(SmsLogDO::getSendTime, reqVO.getSendTime()) + .eqIfPresent(SmsLogDO::getSendStatus, reqVO.getReceiveStatus()) + .betweenIfPresent(SmsLogDO::getReceiveTime, reqVO.getReceiveTime()) + .orderByDesc(SmsLogDO::getId)); } } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java index dfcb4dd31..e6713bacb 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java @@ -1,12 +1,11 @@ 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.mybatis.core.mapper.BaseMapperX; 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 org.apache.ibatis.annotations.Mapper; @@ -36,7 +35,6 @@ public interface AdminUserMapper extends BaseMapperX { .betweenIfPresent(AdminUserDO::getCreateTime, reqVO.getCreateTime()) .inIfPresent(AdminUserDO::getDeptId, deptIds) .orderByDesc(AdminUserDO::getId)); - } default List selectList(UserExportReqVO reqVO, Collection deptIds) { @@ -65,4 +63,3 @@ public interface AdminUserMapper extends BaseMapperX { } } -