refactor: 时间区间查询传入数组

This commit is contained in:
YunaiV
2022-07-26 23:10:31 +08:00
parent 55adb8efa9
commit f1cf5f9f88
70 changed files with 706 additions and 637 deletions

View File

@@ -24,12 +24,8 @@ public class CodegenTablePageReqVO extends PageParam {
@ApiModelProperty(value = "表描述", example = "芋道", notes = "模糊匹配")
private String tableComment;
@ApiModelProperty(value = "开始创建时间", example = "2020-10-24 00:00:00")
@ApiModelProperty(value = "创建时间", example = "[2022-07-01 00:00:00, 2022-07-01 23:59:59]")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date beginCreateTime;
@ApiModelProperty(value = "结束创建时间", example = "2020-10-24 23:59:59")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private Date endCreateTime;
private Date[] createTime;
}

View File

@@ -24,12 +24,8 @@ public class FileConfigPageReqVO extends PageParam {
@ApiModelProperty(value = "存储器", example = "1")
private Integer storage;
@ApiModelProperty(value = "创建时间", example = "[2022-07-01 00:00:00, 2022-07-01 23:59:59]")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
private Date[] createTime;
}

View File

@@ -24,12 +24,8 @@ public class FilePageReqVO extends PageParam {
@ApiModelProperty(value = "文件类型", example = "jpg", notes = "模糊匹配")
private String type;
@ApiModelProperty(value = "创建时间", example = "[2022-07-01 00:00:00, 2022-07-01 23:59:59]")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
private Date[] createTime;
}

View File

@@ -25,13 +25,9 @@ public class ApiAccessLogExportReqVO {
@ApiModelProperty(value = "请求地址", example = "/xxx/yyy", notes = "模糊匹配")
private String requestUrl;
@ApiModelProperty(value = "开始时间", example = "[2022-07-01 00:00:00, 2022-07-01 23:59:59]")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始开始请求时间")
private Date beginBeginTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束开始请求时间")
private Date endBeginTime;
private Date[] beginTime;
@ApiModelProperty(value = "执行时长", example = "100", notes = "大于等于,单位:毫秒")
private Integer duration;

View File

@@ -30,13 +30,9 @@ public class ApiAccessLogPageReqVO extends PageParam {
@ApiModelProperty(value = "请求地址", example = "/xxx/yyy", notes = "模糊匹配")
private String requestUrl;
@ApiModelProperty(value = "开始时间", example = "[2022-07-01 00:00:00, 2022-07-01 23:59:59]")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始开始请求时间")
private Date beginBeginTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束开始请求时间")
private Date endBeginTime;
private Date[] beginTime;
@ApiModelProperty(value = "执行时长", example = "100", notes = "大于等于,单位:毫秒")
private Integer duration;

View File

@@ -26,12 +26,8 @@ public class ApiErrorLogExportReqVO {
private String requestUrl;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始异常发生时间")
private Date beginExceptionTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束异常发生时间")
private Date endExceptionTime;
@ApiModelProperty(value = "异常发生时间")
private Date[] exceptionTime;
@ApiModelProperty(value = "处理状态", example = "0")
private Integer processStatus;

View File

@@ -31,12 +31,8 @@ public class ApiErrorLogPageReqVO extends PageParam {
private String requestUrl;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始异常发生时间")
private Date beginExceptionTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束异常发生时间")
private Date endExceptionTime;
@ApiModelProperty(value = "异常发生时间")
private Date[] exceptionTime;
@ApiModelProperty(value = "处理状态", example = "0")
private Integer processStatus;

View File

@@ -1,11 +1,12 @@
package cn.iocoder.yudao.module.infra.controller.admin.test.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ApiModel(value = "管理后台 - 字典类型 Excel 导出 Request VO", description = "参数和 TestDemoPageReqVO 是一致的")
@@ -28,11 +29,7 @@ public class TestDemoExportReqVO {
private String remark;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
@ApiModelProperty(value = "创建时间")
private Date[] createTime;
}

View File

@@ -1,11 +1,15 @@
package cn.iocoder.yudao.module.infra.controller.admin.test.vo;
import lombok.*;
import java.util.*;
import io.swagger.annotations.*;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@ApiModel("管理后台 - 字典类型分页 Request VO")
@@ -30,11 +34,7 @@ public class TestDemoPageReqVO extends PageParam {
private String remark;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "开始创建时间")
private Date beginCreateTime;
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
@ApiModelProperty(value = "结束创建时间")
private Date endCreateTime;
@ApiModelProperty(value = "创建时间")
private Date[] createTime;
}

View File

@@ -21,7 +21,7 @@ public interface CodegenTableMapper extends BaseMapperX<CodegenTableDO> {
return selectPage(pageReqVO, new LambdaQueryWrapperX<CodegenTableDO>()
.likeIfPresent(CodegenTableDO::getTableName, pageReqVO.getTableName())
.likeIfPresent(CodegenTableDO::getTableComment, pageReqVO.getTableComment())
.betweenIfPresent(CodegenTableDO::getCreateTime, pageReqVO.getBeginCreateTime(), pageReqVO.getEndCreateTime()));
.betweenIfPresent(CodegenTableDO::getCreateTime, pageReqVO.getCreateTime()));
}
default List<CodegenTableDO> selectListByDataSourceConfigId(Long dataSourceConfigId) {

View File

@@ -22,7 +22,7 @@ public interface FileConfigMapper extends BaseMapperX<FileConfigDO> {
return selectPage(reqVO, new LambdaQueryWrapperX<FileConfigDO>()
.likeIfPresent(FileConfigDO::getName, reqVO.getName())
.eqIfPresent(FileConfigDO::getStorage, reqVO.getStorage())
.betweenIfPresent(FileConfigDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.betweenIfPresent(FileConfigDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(FileConfigDO::getId));
}

View File

@@ -19,7 +19,7 @@ public interface FileMapper extends BaseMapperX<FileDO> {
return selectPage(reqVO, new LambdaQueryWrapperX<FileDO>()
.likeIfPresent(FileDO::getPath, reqVO.getPath())
.likeIfPresent(FileDO::getType, reqVO.getType())
.betweenIfPresent(FileDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.betweenIfPresent(FileDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(FileDO::getId));
}

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.getBeginBeginTime(), reqVO.getEndBeginTime())
.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.getBeginBeginTime(), reqVO.getEndBeginTime())
.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.getBeginExceptionTime(), reqVO.getEndExceptionTime())
.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.getBeginExceptionTime(), reqVO.getEndExceptionTime())
.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)
);
}

View File

@@ -25,7 +25,7 @@ public interface TestDemoMapper extends BaseMapperX<TestDemoDO> {
.eqIfPresent(TestDemoDO::getType, reqVO.getType())
.eqIfPresent(TestDemoDO::getCategory, reqVO.getCategory())
.eqIfPresent(TestDemoDO::getRemark, reqVO.getRemark())
.betweenIfPresent(TestDemoDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.betweenIfPresent(TestDemoDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(TestDemoDO::getId));
}
@@ -36,7 +36,7 @@ public interface TestDemoMapper extends BaseMapperX<TestDemoDO> {
.eqIfPresent(TestDemoDO::getType, reqVO.getType())
.eqIfPresent(TestDemoDO::getCategory, reqVO.getCategory())
.eqIfPresent(TestDemoDO::getRemark, reqVO.getRemark())
.betweenIfPresent(TestDemoDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime())
.betweenIfPresent(TestDemoDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(TestDemoDO::getId));
}

View File

@@ -22,6 +22,7 @@ import org.springframework.context.annotation.Import;
import javax.annotation.Resource;
import javax.validation.Validator;
import java.io.Serializable;
import java.util.Date;
import java.util.Map;
import static cn.hutool.core.util.RandomUtil.randomEle;
@@ -39,10 +40,10 @@ import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
/**
* {@link FileConfigServiceImpl} 的单元测试类
*
* @author 芋道源码
*/
* {@link FileConfigServiceImpl} 的单元测试类
*
* @author 芋道源码
*/
@Import(FileConfigServiceImpl.class)
public class FileConfigServiceImplTest extends BaseDbUnitTest {
@@ -172,8 +173,8 @@ public class FileConfigServiceImplTest extends BaseDbUnitTest {
// 调用
fileConfigService.deleteFileConfig(id);
// 校验数据不存在了
assertNull(fileConfigMapper.selectById(id));
// 校验数据不存在了
assertNull(fileConfigMapper.selectById(id));
// verify 调用
verify(fileConfigProducer).sendFileConfigRefreshMessage();
}
@@ -201,30 +202,29 @@ public class FileConfigServiceImplTest extends BaseDbUnitTest {
@Test
public void testGetFileConfigPage() {
// mock 数据
FileConfigDO dbFileConfig = randomFileConfigDO().setName("芋道源码")
.setStorage(FileStorageEnum.LOCAL.getStorage());
dbFileConfig.setCreateTime(buildTime(2022, 11, 11));// 等会查询到
fileConfigMapper.insert(dbFileConfig);
// 测试 name 不匹配
fileConfigMapper.insert(cloneIgnoreId(dbFileConfig, o -> o.setName("源码")));
// 测试 storage 不匹配
fileConfigMapper.insert(cloneIgnoreId(dbFileConfig, o -> o.setStorage(FileStorageEnum.DB.getStorage())));
// 测试 createTime 不匹配
fileConfigMapper.insert(cloneIgnoreId(dbFileConfig, o -> o.setCreateTime(buildTime(2022, 12, 12))));
// 准备参数
FileConfigPageReqVO reqVO = new FileConfigPageReqVO();
reqVO.setName("芋道");
reqVO.setStorage(FileStorageEnum.LOCAL.getStorage());
reqVO.setBeginCreateTime(buildTime(2022, 11, 10));
reqVO.setEndCreateTime(buildTime(2022, 11, 12));
// mock 数据
FileConfigDO dbFileConfig = randomFileConfigDO().setName("芋道源码")
.setStorage(FileStorageEnum.LOCAL.getStorage());
dbFileConfig.setCreateTime(buildTime(2022, 11, 11));// 等会查询到
fileConfigMapper.insert(dbFileConfig);
// 测试 name 不匹配
fileConfigMapper.insert(cloneIgnoreId(dbFileConfig, o -> o.setName("源码")));
// 测试 storage 不匹配
fileConfigMapper.insert(cloneIgnoreId(dbFileConfig, o -> o.setStorage(FileStorageEnum.DB.getStorage())));
// 测试 createTime 不匹配
fileConfigMapper.insert(cloneIgnoreId(dbFileConfig, o -> o.setCreateTime(buildTime(2022, 12, 12))));
// 准备参数
FileConfigPageReqVO reqVO = new FileConfigPageReqVO();
reqVO.setName("芋道");
reqVO.setStorage(FileStorageEnum.LOCAL.getStorage());
reqVO.setCreateTime((new Date[]{buildTime(2022, 11, 10),buildTime(2022, 11, 12)}));
// 调用
PageResult<FileConfigDO> pageResult = fileConfigService.getFileConfigPage(reqVO);
// 断言
assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size());
assertPojoEquals(dbFileConfig, pageResult.getList().get(0));
// 调用
PageResult<FileConfigDO> pageResult = fileConfigService.getFileConfigPage(reqVO);
// 断言
assertEquals(1, pageResult.getTotal());
assertEquals(1, pageResult.getList().size());
assertPojoEquals(dbFileConfig, pageResult.getList().get(0));
}
@Test

View File

@@ -15,6 +15,8 @@ import org.springframework.context.annotation.Import;
import javax.annotation.Resource;
import java.util.Date;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.buildTime;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*;
@@ -58,8 +60,7 @@ public class FileServiceTest extends BaseDbUnitTest {
FilePageReqVO reqVO = new FilePageReqVO();
reqVO.setPath("yunai");
reqVO.setType("jp");
reqVO.setBeginCreateTime(buildTime(2021, 1, 10));
reqVO.setEndCreateTime(buildTime(2021, 1, 20));
reqVO.setCreateTime((new Date[]{buildTime(2021, 1, 10),buildTime(2021, 1, 20)}));
// 调用
PageResult<FileDO> pageResult = fileService.getFilePage(reqVO);

View File

@@ -1,7 +1,6 @@
package cn.iocoder.yudao.module.infra.service.logger;
import cn.hutool.core.util.RandomUtil;
import cn.iocoder.yudao.framework.apilog.core.service.ApiAccessLog;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
@@ -78,8 +77,7 @@ public class ApiAccessLogServiceImplTest extends BaseDbUnitTest {
reqVO.setUserType(userType);
reqVO.setApplicationName(applicationName);
reqVO.setRequestUrl(requestUrl);
reqVO.setBeginBeginTime(buildTime(2021, 3, 12));
reqVO.setEndBeginTime(buildTime(2021, 3, 14));
reqVO.setBeginTime((new Date[]{buildTime(2021, 3, 12),buildTime(2021, 3, 14)}));
reqVO.setDuration(duration);
reqVO.setResultCode(resultCode);
@@ -136,8 +134,7 @@ public class ApiAccessLogServiceImplTest extends BaseDbUnitTest {
reqVO.setUserType(userType);
reqVO.setApplicationName(applicationName);
reqVO.setRequestUrl(requestUrl);
reqVO.setBeginBeginTime(buildTime(2021, 3, 12));
reqVO.setEndBeginTime(buildTime(2021, 3, 14));
reqVO.setBeginTime((new Date[]{buildTime(2021, 3, 12),buildTime(2021, 3, 14)}));
reqVO.setDuration(duration);
reqVO.setResultCode(resultCode);
@@ -150,7 +147,7 @@ public class ApiAccessLogServiceImplTest extends BaseDbUnitTest {
}
@Test
public void testCreateApiAccessLog() {
public void testCreateApiAccessLogAsync() {
// 准备参数
ApiAccessLogCreateReqDTO createDTO = RandomUtils.randomPojo(ApiAccessLogCreateReqDTO.class,
dto -> dto.setUserType(RandomUtil.randomEle(UserTypeEnum.values()).getValue()));
@@ -163,5 +160,4 @@ public class ApiAccessLogServiceImplTest extends BaseDbUnitTest {
assertPojoEquals(createDTO, infApiAccessLogDO);
}
}

View File

@@ -1,7 +1,6 @@
package cn.iocoder.yudao.module.infra.service.logger;
import cn.hutool.core.util.RandomUtil;
import cn.iocoder.yudao.framework.apilog.core.service.ApiErrorLog;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
@@ -78,8 +77,7 @@ public class ApiErrorLogServiceImplTest extends BaseDbUnitTest {
reqVO.setUserType(userType);
reqVO.setApplicationName(applicationName);
reqVO.setRequestUrl(requestUrl);
reqVO.setBeginExceptionTime(buildTime(2021, 3, 12));
reqVO.setEndExceptionTime(buildTime(2021, 3, 14));
reqVO.setExceptionTime((new Date[]{buildTime(2021, 3, 12),buildTime(2021, 3, 14)}));
reqVO.setProcessStatus(progressStatus);
// 调用service方法
@@ -131,8 +129,7 @@ public class ApiErrorLogServiceImplTest extends BaseDbUnitTest {
reqVO.setUserType(userType);
reqVO.setApplicationName(applicationName);
reqVO.setRequestUrl(requestUrl);
reqVO.setBeginExceptionTime(buildTime(2021, 3, 12));
reqVO.setEndExceptionTime(buildTime(2021, 3, 14));
reqVO.setExceptionTime((new Date[]{buildTime(2021, 3, 12),buildTime(2021, 3, 14)}));
reqVO.setProcessStatus(progressStatus);
// 调用service方法
@@ -182,7 +179,7 @@ public class ApiErrorLogServiceImplTest extends BaseDbUnitTest {
}
@Test
public void testCreateApiErrorLog() {
public void testCreateApiErrorLogAsync() {
// 准备参数
ApiErrorLogCreateReqDTO createDTO = RandomUtils.randomPojo(ApiErrorLogCreateReqDTO.class,
dto -> dto.setUserType(RandomUtil.randomEle(UserTypeEnum.values()).getValue()));

View File

@@ -14,8 +14,10 @@ import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Import;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.buildTime;
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
@@ -132,8 +134,7 @@ public class TestDemoServiceImplTest extends BaseDbUnitTest {
reqVO.setType(1);
reqVO.setCategory(2);
reqVO.setRemark("哈哈哈");
reqVO.setBeginCreateTime(DateUtils.buildTime(2021, 11, 10));
reqVO.setEndCreateTime(DateUtils.buildTime(2021, 11, 12));
reqVO.setCreateTime((new Date[]{buildTime(2021, 11, 10),buildTime(2021, 11, 12)}));
// 调用
PageResult<TestDemoDO> pageResult = testDemoService.getTestDemoPage(reqVO);
@@ -174,8 +175,7 @@ public class TestDemoServiceImplTest extends BaseDbUnitTest {
reqVO.setType(1);
reqVO.setCategory(2);
reqVO.setRemark("哈哈哈");
reqVO.setBeginCreateTime(DateUtils.buildTime(2021, 11, 10));
reqVO.setEndCreateTime(DateUtils.buildTime(2021, 11, 12));
reqVO.setCreateTime((new Date[]{buildTime(2021, 11, 10),buildTime(2021, 11, 12)}));
// 调用
List<TestDemoDO> list = testDemoService.getTestDemoList(reqVO);