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 33f93a8a1..8ebd34fcf 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 @@ -20,7 +20,7 @@ public interface SmsLogMapper extends BaseMapperX { .likeIfPresent(SmsLogDO::getMobile, reqVO.getMobile()) .eqIfPresent(SmsLogDO::getSendStatus, reqVO.getSendStatus()) .betweenIfPresent(SmsLogDO::getSendTime, reqVO.getSendTime()) - .eqIfPresent(SmsLogDO::getSendStatus, reqVO.getReceiveStatus()) + .eqIfPresent(SmsLogDO::getReceiveStatus, reqVO.getReceiveStatus()) .betweenIfPresent(SmsLogDO::getReceiveTime, reqVO.getReceiveTime()) .orderByDesc(SmsLogDO::getId)); } @@ -32,7 +32,7 @@ public interface SmsLogMapper extends BaseMapperX { .likeIfPresent(SmsLogDO::getMobile, reqVO.getMobile()) .eqIfPresent(SmsLogDO::getSendStatus, reqVO.getSendStatus()) .betweenIfPresent(SmsLogDO::getSendTime, reqVO.getSendTime()) - .eqIfPresent(SmsLogDO::getSendStatus, reqVO.getReceiveStatus()) + .eqIfPresent(SmsLogDO::getReceiveStatus, reqVO.getReceiveStatus()) .betweenIfPresent(SmsLogDO::getReceiveTime, reqVO.getReceiveTime()) .orderByDesc(SmsLogDO::getId)); } diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/logger/LoginLogServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/logger/LoginLogServiceImplTest.java index d3d8f9fd0..d867d4c12 100644 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/logger/LoginLogServiceImplTest.java +++ b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/logger/LoginLogServiceImplTest.java @@ -1,19 +1,18 @@ package cn.iocoder.yudao.module.system.service.logger; import cn.hutool.core.util.RandomUtil; -import cn.iocoder.yudao.module.system.dal.dataobject.logger.LoginLogDO; import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils; +import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; +import cn.iocoder.yudao.framework.test.core.util.RandomUtils; +import cn.iocoder.yudao.module.system.api.logger.dto.LoginLogCreateReqDTO; 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.dal.mysql.logger.LoginLogMapper; -import cn.iocoder.yudao.framework.test.core.util.RandomUtils; -import cn.iocoder.yudao.framework.common.util.object.ObjectUtils; import cn.iocoder.yudao.module.system.enums.logger.LoginLogTypeEnum; -import cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum; -import cn.iocoder.yudao.module.system.api.logger.dto.LoginLogCreateReqDTO; -import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; import org.junit.jupiter.api.Test; import org.springframework.context.annotation.Import; @@ -22,8 +21,9 @@ import java.time.LocalDateTime; import java.util.List; import static cn.hutool.core.util.RandomUtil.randomEle; -import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.buildLocalDateTime; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; +import static cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum.*; import static org.junit.jupiter.api.Assertions.assertEquals; @Import(LoginLogServiceImpl.class) @@ -47,13 +47,13 @@ public class LoginLogServiceImplTest extends BaseDbUnitTest { logDO.setUserIp("192.168.199.16"); logDO.setUsername("wangkai"); logDO.setCreateTime(buildLocalDateTime(2021, 3, 6)); - logDO.setResult(cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum.SUCCESS.getResult()); + logDO.setResult(SUCCESS.getResult()); }); loginLogMapper.insert(loginLogDO); // 下面几个都是不匹配的数据 // 登录失败的 - loginLogMapper.insert(ObjectUtils.cloneIgnoreId(loginLogDO, logDO -> logDO.setResult(cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum.CAPTCHA_CODE_ERROR.getResult()))); + loginLogMapper.insert(ObjectUtils.cloneIgnoreId(loginLogDO, logDO -> logDO.setResult(CAPTCHA_CODE_ERROR.getResult()))); // 不同ip段的 loginLogMapper.insert(ObjectUtils.cloneIgnoreId(loginLogDO, logDO -> logDO.setUserIp("192.168.128.18"))); // 不同username @@ -67,7 +67,8 @@ public class LoginLogServiceImplTest extends BaseDbUnitTest { reqVO.setUsername("wangkai"); reqVO.setUserIp("192.168.199"); reqVO.setStatus(true); - reqVO.setCreateTime((new LocalDateTime[]{buildLocalDateTime(2021, 3, 5),buildLocalDateTime(2021, 3, 5)})); + reqVO.setCreateTime((new LocalDateTime[]{buildLocalDateTime(2021, 3, 5), + buildLocalDateTime(2021, 3, 7)})); // 调用service方法 PageResult pageResult = loginLogService.getLoginLogPage(reqVO); @@ -91,13 +92,13 @@ public class LoginLogServiceImplTest extends BaseDbUnitTest { logDO.setUserIp("192.168.111.16"); logDO.setUsername("wangxiaokai"); logDO.setCreateTime(buildLocalDateTime(2021, 3, 6)); - logDO.setResult(cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum.SUCCESS.getResult()); + logDO.setResult(SUCCESS.getResult()); }); loginLogMapper.insert(loginLogDO); // 下面几个都是不匹配的数据 // 登录失败的 - loginLogMapper.insert(ObjectUtils.cloneIgnoreId(loginLogDO, logDO -> logDO.setResult(cn.iocoder.yudao.module.system.enums.logger.LoginResultEnum.CAPTCHA_CODE_ERROR.getResult()))); + loginLogMapper.insert(ObjectUtils.cloneIgnoreId(loginLogDO, logDO -> logDO.setResult(CAPTCHA_CODE_ERROR.getResult()))); // 不同ip段的 loginLogMapper.insert(ObjectUtils.cloneIgnoreId(loginLogDO, logDO -> logDO.setUserIp("192.168.128.18"))); // 不同username @@ -110,7 +111,8 @@ public class LoginLogServiceImplTest extends BaseDbUnitTest { reqVO.setUsername("wangxiaokai"); reqVO.setUserIp("192.168.111"); reqVO.setStatus(true); - reqVO.setCreateTime((new LocalDateTime[]{buildLocalDateTime(2021, 3, 5),buildLocalDateTime(2021, 3, 5)})); + reqVO.setCreateTime((new LocalDateTime[]{buildLocalDateTime(2021, 3, 5), + buildLocalDateTime(2021, 3, 7)})); // 调用service方法 List loginLogList = loginLogService.getLoginLogList(reqVO); @@ -126,7 +128,7 @@ public class LoginLogServiceImplTest extends BaseDbUnitTest { // 指定随机的范围,避免超出范围入库失败 vo.setUserType(randomEle(UserTypeEnum.values()).getValue()); vo.setLogType(randomEle(LoginLogTypeEnum.values()).getType()); - vo.setResult(randomEle(LoginResultEnum.values()).getResult()); + vo.setResult(randomEle(values()).getResult()); vo.setTraceId(TracerUtils.getTraceId()); }); diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImplTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImplTest.java index b016e700b..5dfa31d36 100644 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImplTest.java +++ b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImplTest.java @@ -104,7 +104,8 @@ public class OperateLogServiceImplTest extends BaseDbUnitTest { reqVO.setUserNickname("wangkai"); reqVO.setModule("order"); reqVO.setType(OperateTypeEnum.CREATE.getType()); - reqVO.setStartTime((new LocalDateTime[]{buildLocalDateTime(2021, 3, 5),buildLocalDateTime(2021, 3, 7)})); + reqVO.setStartTime((new LocalDateTime[]{buildLocalDateTime(2021, 3, 5), + buildLocalDateTime(2021, 3, 7)})); reqVO.setSuccess(true); // 调用service方法 diff --git a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsLogServiceTest.java b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsLogServiceTest.java index 547bc2390..8be82e9a8 100644 --- a/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsLogServiceTest.java +++ b/yudao-module-system/yudao-module-system-biz/src/test/java/cn/iocoder/yudao/module/system/service/sms/SmsLogServiceTest.java @@ -74,9 +74,11 @@ public class SmsLogServiceTest extends BaseDbUnitTest { reqVO.setTemplateId(10L); reqVO.setMobile("156"); reqVO.setSendStatus(SmsSendStatusEnum.INIT.getStatus()); - reqVO.setSendTime((new LocalDateTime[]{buildLocalDateTime(2020, 11, 1),buildLocalDateTime(2020, 11, 30)})); + reqVO.setSendTime((new LocalDateTime[]{buildLocalDateTime(2020, 11, 1), + buildLocalDateTime(2020, 11, 30)})); reqVO.setReceiveStatus(SmsReceiveStatusEnum.INIT.getStatus()); - reqVO.setReceiveTime((new LocalDateTime[]{buildLocalDateTime(2021, 11, 1),buildLocalDateTime(2021, 11, 30)})); + reqVO.setReceiveTime((new LocalDateTime[]{buildLocalDateTime(2021, 11, 1), + buildLocalDateTime(2021, 11, 30)})); // 调用 PageResult pageResult = smsLogService.getSmsLogPage(reqVO); @@ -119,9 +121,11 @@ public class SmsLogServiceTest extends BaseDbUnitTest { reqVO.setTemplateId(10L); reqVO.setMobile("156"); reqVO.setSendStatus(SmsSendStatusEnum.INIT.getStatus()); - reqVO.setSendTime((new LocalDateTime[]{buildLocalDateTime(2020, 11, 1),buildLocalDateTime(2020, 11, 30)})); + reqVO.setSendTime((new LocalDateTime[]{buildLocalDateTime(2020, 11, 1), + buildLocalDateTime(2020, 11, 30)})); reqVO.setReceiveStatus(SmsReceiveStatusEnum.INIT.getStatus()); - reqVO.setReceiveTime((new LocalDateTime[]{buildLocalDateTime(2021, 11, 1),buildLocalDateTime(2021, 11, 30)})); + reqVO.setReceiveTime((new LocalDateTime[]{buildLocalDateTime(2021, 11, 1), + buildLocalDateTime(2021, 11, 30)})); // 调用 List list = smsLogService.getSmsLogList(reqVO);