Commit 30fef09eee81577d83afac42e6229dd7188ad5dc

Authored by YunaiV
1 parent e541fe63

🔧 简化 errorLog 和 accessLog 模块的 VO

Showing 21 changed files with 185 additions and 654 deletions
yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/mapper/BaseMapperX.java
... ... @@ -28,7 +28,7 @@ public interface BaseMapperX<T> extends MPJBaseMapper<T> {
28 28  
29 29 default PageResult<T> selectPage(PageParam pageParam, @Param("ew") Wrapper<T> queryWrapper) {
30 30 // 特殊:不分页,直接查询全部
31   - if (PageParam.PAGE_SIZE_NONE.equals(pageParam.getPageNo())) {
  31 + if (PageParam.PAGE_SIZE_NONE.equals(pageParam.getPageSize())) {
32 32 List<T> list = selectList(queryWrapper);
33 33 return new PageResult<>(list, (long) list.size());
34 34 }
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/logger/ApiAccessLogController.java
1 1 package cn.iocoder.yudao.module.infra.controller.admin.logger;
2 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  4 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
4 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
  6 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
5 7 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
6 8 import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
7   -import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExcelVO;
8   -import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExportReqVO;
9 9 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO;
10 10 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogRespVO;
11   -import cn.iocoder.yudao.module.infra.convert.logger.ApiAccessLogConvert;
12 11 import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO;
13 12 import cn.iocoder.yudao.module.infra.service.logger.ApiAccessLogService;
14   -import io.swagger.v3.oas.annotations.tags.Tag;
15 13 import io.swagger.v3.oas.annotations.Operation;
  14 +import io.swagger.v3.oas.annotations.tags.Tag;
16 15 import org.springframework.security.access.prepost.PreAuthorize;
17 16 import org.springframework.validation.annotation.Validated;
18 17 import org.springframework.web.bind.annotation.GetMapping;
... ... @@ -40,21 +39,22 @@ public class ApiAccessLogController {
40 39 @GetMapping("/page")
41 40 @Operation(summary = "获得API 访问日志分页")
42 41 @PreAuthorize("@ss.hasPermission('infra:api-access-log:query')")
43   - public CommonResult<PageResult<ApiAccessLogRespVO>> getApiAccessLogPage(@Valid ApiAccessLogPageReqVO pageVO) {
44   - PageResult<ApiAccessLogDO> pageResult = apiAccessLogService.getApiAccessLogPage(pageVO);
45   - return success(ApiAccessLogConvert.INSTANCE.convertPage(pageResult));
  42 + public CommonResult<PageResult<ApiAccessLogRespVO>> getApiAccessLogPage(@Valid ApiAccessLogPageReqVO pageReqVO) {
  43 + PageResult<ApiAccessLogDO> pageResult = apiAccessLogService.getApiAccessLogPage(pageReqVO);
  44 + return success(BeanUtils.toBean(pageResult, ApiAccessLogRespVO.class));
46 45 }
47 46  
48 47 @GetMapping("/export-excel")
49 48 @Operation(summary = "导出API 访问日志 Excel")
50 49 @PreAuthorize("@ss.hasPermission('infra:api-access-log:export')")
51 50 @OperateLog(type = EXPORT)
52   - public void exportApiAccessLogExcel(@Valid ApiAccessLogExportReqVO exportReqVO,
  51 + public void exportApiAccessLogExcel(@Valid ApiAccessLogPageReqVO exportReqVO,
53 52 HttpServletResponse response) throws IOException {
54   - List<ApiAccessLogDO> list = apiAccessLogService.getApiAccessLogList(exportReqVO);
  53 + exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
  54 + List<ApiAccessLogDO> list = apiAccessLogService.getApiAccessLogPage(exportReqVO).getList();
55 55 // 导出 Excel
56   - List<ApiAccessLogExcelVO> datas = ApiAccessLogConvert.INSTANCE.convertList02(list);
57   - ExcelUtils.write(response, "API 访问日志.xls", "数据", ApiAccessLogExcelVO.class, datas);
  56 + ExcelUtils.write(response, "API 访问日志.xls", "数据", ApiAccessLogRespVO.class,
  57 + BeanUtils.toBean(list, ApiAccessLogRespVO.class));
58 58 }
59 59  
60 60 }
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/logger/ApiErrorLogController.java
1 1 package cn.iocoder.yudao.module.infra.controller.admin.logger;
2 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  4 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
4 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
  6 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
5 7 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
6 8 import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
7   -import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExcelVO;
8   -import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExportReqVO;
9 9 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO;
10 10 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogRespVO;
11   -import cn.iocoder.yudao.module.infra.convert.logger.ApiErrorLogConvert;
12 11 import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO;
13 12 import cn.iocoder.yudao.module.infra.service.logger.ApiErrorLogService;
14   -import io.swagger.v3.oas.annotations.tags.Tag;
  13 +import io.swagger.v3.oas.annotations.Operation;
15 14 import io.swagger.v3.oas.annotations.Parameter;
16 15 import io.swagger.v3.oas.annotations.Parameters;
17   -import io.swagger.v3.oas.annotations.Operation;
  16 +import io.swagger.v3.oas.annotations.tags.Tag;
18 17 import org.springframework.security.access.prepost.PreAuthorize;
19 18 import org.springframework.validation.annotation.Validated;
20 19 import org.springframework.web.bind.annotation.*;
... ... @@ -54,21 +53,22 @@ public class ApiErrorLogController {
54 53 @GetMapping("/page")
55 54 @Operation(summary = "获得 API 错误日志分页")
56 55 @PreAuthorize("@ss.hasPermission('infra:api-error-log:query')")
57   - public CommonResult<PageResult<ApiErrorLogRespVO>> getApiErrorLogPage(@Valid ApiErrorLogPageReqVO pageVO) {
58   - PageResult<ApiErrorLogDO> pageResult = apiErrorLogService.getApiErrorLogPage(pageVO);
59   - return success(ApiErrorLogConvert.INSTANCE.convertPage(pageResult));
  56 + public CommonResult<PageResult<ApiErrorLogRespVO>> getApiErrorLogPage(@Valid ApiErrorLogPageReqVO pageReqVO) {
  57 + PageResult<ApiErrorLogDO> pageResult = apiErrorLogService.getApiErrorLogPage(pageReqVO);
  58 + return success(BeanUtils.toBean(pageResult, ApiErrorLogRespVO.class));
60 59 }
61 60  
62 61 @GetMapping("/export-excel")
63 62 @Operation(summary = "导出 API 错误日志 Excel")
64 63 @PreAuthorize("@ss.hasPermission('infra:api-error-log:export')")
65 64 @OperateLog(type = EXPORT)
66   - public void exportApiErrorLogExcel(@Valid ApiErrorLogExportReqVO exportReqVO,
  65 + public void exportApiErrorLogExcel(@Valid ApiErrorLogPageReqVO exportReqVO,
67 66 HttpServletResponse response) throws IOException {
68   - List<ApiErrorLogDO> list = apiErrorLogService.getApiErrorLogList(exportReqVO);
  67 + exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
  68 + List<ApiErrorLogDO> list = apiErrorLogService.getApiErrorLogPage(exportReqVO).getList();
69 69 // 导出 Excel
70   - List<ApiErrorLogExcelVO> datas = ApiErrorLogConvert.INSTANCE.convertList02(list);
71   - ExcelUtils.write(response, "API 错误日志.xls", "数据", ApiErrorLogExcelVO.class, datas);
  70 + ExcelUtils.write(response, "API 错误日志.xls", "数据", ApiErrorLogRespVO.class,
  71 + BeanUtils.toBean(list, ApiErrorLogRespVO.class));
72 72 }
73 73  
74 74 }
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/logger/vo/apiaccesslog/ApiAccessLogBaseVO.java deleted
1   -package cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog;
2   -
3   -import io.swagger.v3.oas.annotations.media.Schema;
4   -import lombok.Data;
5   -import org.springframework.format.annotation.DateTimeFormat;
6   -
7   -import javax.validation.constraints.NotNull;
8   -import java.time.LocalDateTime;
9   -
10   -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
11   -
12   -/**
13   -* API 访问日志 Base VO,提供给添加、修改、详细的子 VO 使用
14   -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
15   -*/
16   -@Data
17   -public class ApiAccessLogBaseVO {
18   -
19   - @Schema(description = "链路追踪编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "66600cb6-7852-11eb-9439-0242ac130002")
20   - @NotNull(message = "链路追踪编号不能为空")
21   - private String traceId;
22   -
23   - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "666")
24   - @NotNull(message = "用户编号不能为空")
25   - private Long userId;
26   -
27   - @Schema(description = "用户类型,参见 UserTypeEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
28   - @NotNull(message = "用户类型不能为空")
29   - private Integer userType;
30   -
31   - @Schema(description = "应用名", requiredMode = Schema.RequiredMode.REQUIRED, example = "dashboard")
32   - @NotNull(message = "应用名不能为空")
33   - private String applicationName;
34   -
35   - @Schema(description = "请求方法名", requiredMode = Schema.RequiredMode.REQUIRED, example = "GET")
36   - @NotNull(message = "请求方法名不能为空")
37   - private String requestMethod;
38   -
39   - @Schema(description = "请求地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "/xxx/yyy")
40   - @NotNull(message = "请求地址不能为空")
41   - private String requestUrl;
42   -
43   - @Schema(description = "请求参数")
44   - private String requestParams;
45   -
46   - @Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1")
47   - @NotNull(message = "用户 IP不能为空")
48   - private String userIp;
49   -
50   - @Schema(description = "浏览器 UA", requiredMode = Schema.RequiredMode.REQUIRED, example = "Mozilla/5.0")
51   - @NotNull(message = "浏览器 UA不能为空")
52   - private String userAgent;
53   -
54   - @Schema(description = "开始请求时间", requiredMode = Schema.RequiredMode.REQUIRED)
55   - @NotNull(message = "开始请求时间不能为空")
56   - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
57   - private LocalDateTime beginTime;
58   -
59   - @Schema(description = "结束请求时间", requiredMode = Schema.RequiredMode.REQUIRED)
60   - @NotNull(message = "结束请求时间不能为空")
61   - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
62   - private LocalDateTime endTime;
63   -
64   - @Schema(description = "执行时长", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
65   - @NotNull(message = "执行时长不能为空")
66   - private Integer duration;
67   -
68   - @Schema(description = "结果码", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
69   - @NotNull(message = "结果码不能为空")
70   - private Integer resultCode;
71   -
72   - @Schema(description = "结果提示", example = "芋道源码,牛逼!")
73   - private String resultMsg;
74   -
75   -}
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/logger/vo/apiaccesslog/ApiAccessLogExcelVO.java deleted
1   -package cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog;
2   -
3   -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
4   -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
5   -import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
6   -import com.alibaba.excel.annotation.ExcelProperty;
7   -import lombok.Data;
8   -
9   -import java.time.LocalDateTime;
10   -
11   -/**
12   - * API 访问日志 Excel VO
13   - *
14   - * @author 芋道源码
15   - */
16   -@Data
17   -public class ApiAccessLogExcelVO {
18   -
19   - @ExcelProperty("日志主键")
20   - private Long id;
21   -
22   - @ExcelProperty("链路追踪编号")
23   - private String traceId;
24   -
25   - @ExcelProperty("用户编号")
26   - private Long userId;
27   -
28   - @ExcelProperty(value = "用户类型", converter = DictConvert.class)
29   - @DictFormat(DictTypeConstants.USER_TYPE)
30   - private Integer userType;
31   -
32   - @ExcelProperty("应用名")
33   - private String applicationName;
34   -
35   - @ExcelProperty("请求方法名")
36   - private String requestMethod;
37   -
38   - @ExcelProperty("请求地址")
39   - private String requestUrl;
40   -
41   - @ExcelProperty("请求参数")
42   - private String requestParams;
43   -
44   - @ExcelProperty("用户 IP")
45   - private String userIp;
46   -
47   - @ExcelProperty("浏览器 UA")
48   - private String userAgent;
49   -
50   - @ExcelProperty("开始请求时间")
51   - private LocalDateTime beginTime;
52   -
53   - @ExcelProperty("结束请求时间")
54   - private LocalDateTime endTime;
55   -
56   - @ExcelProperty("执行时长")
57   - private Integer duration;
58   -
59   - @ExcelProperty("结果码")
60   - private Integer resultCode;
61   -
62   - @ExcelProperty("结果提示")
63   - private String resultMsg;
64   -
65   -}
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/logger/vo/apiaccesslog/ApiAccessLogExportReqVO.java deleted
1   -package cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog;
2   -
3   -import io.swagger.v3.oas.annotations.media.Schema;
4   -import lombok.Data;
5   -import org.springframework.format.annotation.DateTimeFormat;
6   -
7   -import java.time.LocalDateTime;
8   -
9   -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
10   -
11   -@Schema(description = "管理后台 - API 访问日志 Excel 导出 Request VO,参数和 ApiAccessLogPageReqVO 是一致的")
12   -@Data
13   -public class ApiAccessLogExportReqVO {
14   -
15   - @Schema(description = "用户编号", example = "666")
16   - private Long userId;
17   -
18   - @Schema(description = "用户类型", example = "2")
19   - private Integer userType;
20   -
21   - @Schema(description = "应用名", example = "dashboard")
22   - private String applicationName;
23   -
24   - @Schema(description = "请求地址,模糊匹配", example = "/xxx/yyy")
25   - private String requestUrl;
26   -
27   - @Schema(description = "开始时间", example = "[2022-07-01 00:00:00, 2022-07-01 23:59:59]")
28   - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
29   - private LocalDateTime[] beginTime;
30   -
31   - @Schema(description = "执行时长,大于等于,单位:毫秒", example = "100")
32   - private Integer duration;
33   -
34   - @Schema(description = "结果码", example = "0")
35   - private Integer resultCode;
36   -
37   -}
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/logger/vo/apiaccesslog/ApiAccessLogRespVO.java
1 1 package cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog;
2 2  
  3 +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
  4 +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
  5 +import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
  6 +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
  7 +import com.alibaba.excel.annotation.ExcelProperty;
3 8 import io.swagger.v3.oas.annotations.media.Schema;
4 9 import lombok.Data;
5   -import lombok.EqualsAndHashCode;
6   -import lombok.ToString;
7 10  
8 11 import java.time.LocalDateTime;
9 12  
10 13 @Schema(description = "管理后台 - API 访问日志 Response VO")
11 14 @Data
12   -@EqualsAndHashCode(callSuper = true)
13   -@ToString(callSuper = true)
14   -public class ApiAccessLogRespVO extends ApiAccessLogBaseVO {
  15 +@ExcelIgnoreUnannotated
  16 +public class ApiAccessLogRespVO {
15 17  
16 18 @Schema(description = "日志主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
  19 + @ExcelProperty("日志主键")
17 20 private Long id;
18 21  
  22 + @Schema(description = "链路追踪编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "66600cb6-7852-11eb-9439-0242ac130002")
  23 + @ExcelProperty("链路追踪编号")
  24 + private String traceId;
  25 +
  26 + @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "666")
  27 + @ExcelProperty("用户编号")
  28 + private Long userId;
  29 +
  30 + @Schema(description = "用户类型,参见 UserTypeEnum 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
  31 + @ExcelProperty(value = "用户类型", converter = DictConvert.class)
  32 + @DictFormat(DictTypeConstants.USER_TYPE)
  33 + private Integer userType;
  34 +
  35 + @Schema(description = "应用名", requiredMode = Schema.RequiredMode.REQUIRED, example = "dashboard")
  36 + @ExcelProperty("应用名")
  37 + private String applicationName;
  38 +
  39 + @Schema(description = "请求方法名", requiredMode = Schema.RequiredMode.REQUIRED, example = "GET")
  40 + @ExcelProperty("请求方法名")
  41 + private String requestMethod;
  42 +
  43 + @Schema(description = "请求地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "/xxx/yyy")
  44 + @ExcelProperty("请求地址")
  45 + private String requestUrl;
  46 +
  47 + @Schema(description = "请求参数")
  48 + @ExcelProperty("请求参数")
  49 + private String requestParams;
  50 +
  51 + @Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1")
  52 + @ExcelProperty("用户 IP")
  53 + private String userIp;
  54 +
  55 + @Schema(description = "浏览器 UA", requiredMode = Schema.RequiredMode.REQUIRED, example = "Mozilla/5.0")
  56 + @ExcelProperty("浏览器 UA")
  57 + private String userAgent;
  58 +
  59 + @Schema(description = "开始请求时间", requiredMode = Schema.RequiredMode.REQUIRED)
  60 + @ExcelProperty("开始请求时间")
  61 + private LocalDateTime beginTime;
  62 +
  63 + @Schema(description = "结束请求时间", requiredMode = Schema.RequiredMode.REQUIRED)
  64 + @ExcelProperty("结束请求时间")
  65 + private LocalDateTime endTime;
  66 +
  67 + @Schema(description = "执行时长", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
  68 + @ExcelProperty("执行时长")
  69 + private Integer duration;
  70 +
  71 + @Schema(description = "结果码", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
  72 + @ExcelProperty("结果码")
  73 + private Integer resultCode;
  74 +
  75 + @Schema(description = "结果提示", example = "芋道源码,牛逼!")
  76 + @ExcelProperty("结果提示")
  77 + private String resultMsg;
  78 +
19 79 @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
20 80 private LocalDateTime createTime;
21 81  
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/logger/vo/apierrorlog/ApiErrorLogBaseVO.java deleted
1   -package cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog;
2   -import io.swagger.v3.oas.annotations.media.Schema;
3   -import lombok.Data;
4   -import org.springframework.format.annotation.DateTimeFormat;
5   -
6   -import javax.validation.constraints.NotNull;
7   -import java.time.LocalDateTime;
8   -
9   -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
10   -
11   -/**
12   -* API 错误日志 Base VO,提供给添加、修改、详细的子 VO 使用
13   -* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
14   -*/
15   -@Data
16   -public class ApiErrorLogBaseVO {
17   -
18   - @Schema(description = "链路追踪编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "66600cb6-7852-11eb-9439-0242ac130002")
19   - @NotNull(message = "链路追踪编号不能为空")
20   - private String traceId;
21   -
22   - @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "666")
23   - @NotNull(message = "用户编号不能为空")
24   - private Integer userId;
25   -
26   - @Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
27   - @NotNull(message = "用户类型不能为空")
28   - private Integer userType;
29   -
30   - @Schema(description = "应用名", requiredMode = Schema.RequiredMode.REQUIRED, example = "dashboard")
31   - @NotNull(message = "应用名不能为空")
32   - private String applicationName;
33   -
34   - @Schema(description = "请求方法名", requiredMode = Schema.RequiredMode.REQUIRED, example = "GET")
35   - @NotNull(message = "请求方法名不能为空")
36   - private String requestMethod;
37   -
38   - @Schema(description = "请求地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "/xx/yy")
39   - @NotNull(message = "请求地址不能为空")
40   - private String requestUrl;
41   -
42   - @Schema(description = "请求参数", requiredMode = Schema.RequiredMode.REQUIRED)
43   - @NotNull(message = "请求参数不能为空")
44   - private String requestParams;
45   -
46   - @Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1")
47   - @NotNull(message = "用户 IP不能为空")
48   - private String userIp;
49   -
50   - @Schema(description = "浏览器 UA", requiredMode = Schema.RequiredMode.REQUIRED, example = "Mozilla/5.0")
51   - @NotNull(message = "浏览器 UA不能为空")
52   - private String userAgent;
53   -
54   - @Schema(description = "异常发生时间", requiredMode = Schema.RequiredMode.REQUIRED)
55   - @NotNull(message = "异常发生时间不能为空")
56   - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
57   - private LocalDateTime exceptionTime;
58   -
59   - @Schema(description = "异常名", requiredMode = Schema.RequiredMode.REQUIRED)
60   - @NotNull(message = "异常名不能为空")
61   - private String exceptionName;
62   -
63   - @Schema(description = "异常导致的消息", requiredMode = Schema.RequiredMode.REQUIRED)
64   - @NotNull(message = "异常导致的消息不能为空")
65   - private String exceptionMessage;
66   -
67   - @Schema(description = "异常导致的根消息", requiredMode = Schema.RequiredMode.REQUIRED)
68   - @NotNull(message = "异常导致的根消息不能为空")
69   - private String exceptionRootCauseMessage;
70   -
71   - @Schema(description = "异常的栈轨迹", requiredMode = Schema.RequiredMode.REQUIRED)
72   - @NotNull(message = "异常的栈轨迹不能为空")
73   - private String exceptionStackTrace;
74   -
75   - @Schema(description = "异常发生的类全名", requiredMode = Schema.RequiredMode.REQUIRED)
76   - @NotNull(message = "异常发生的类全名不能为空")
77   - private String exceptionClassName;
78   -
79   - @Schema(description = "异常发生的类文件", requiredMode = Schema.RequiredMode.REQUIRED)
80   - @NotNull(message = "异常发生的类文件不能为空")
81   - private String exceptionFileName;
82   -
83   - @Schema(description = "异常发生的方法名", requiredMode = Schema.RequiredMode.REQUIRED)
84   - @NotNull(message = "异常发生的方法名不能为空")
85   - private String exceptionMethodName;
86   -
87   - @Schema(description = "异常发生的方法所在行", requiredMode = Schema.RequiredMode.REQUIRED)
88   - @NotNull(message = "异常发生的方法所在行不能为空")
89   - private Integer exceptionLineNumber;
90   -
91   - @Schema(description = "处理状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
92   - @NotNull(message = "处理状态不能为空")
93   - private Integer processStatus;
94   -
95   -}
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/logger/vo/apierrorlog/ApiErrorLogExcelVO.java deleted
1   -package cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog;
2   -
3   -import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
4   -import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
5   -import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
6   -import com.alibaba.excel.annotation.ExcelProperty;
7   -import lombok.Data;
8   -
9   -import java.time.LocalDateTime;
10   -
11   -/**
12   - * API 错误日志 Excel VO
13   - *
14   - * @author 芋道源码
15   - */
16   -@Data
17   -public class ApiErrorLogExcelVO {
18   -
19   - @ExcelProperty("编号")
20   - private Integer id;
21   -
22   - @ExcelProperty("链路追踪编号")
23   - private String traceId;
24   -
25   - @ExcelProperty("用户编号")
26   - private Integer userId;
27   -
28   - @ExcelProperty(value = "用户类型", converter = DictConvert.class)
29   - @DictFormat(cn.iocoder.yudao.module.system.enums.DictTypeConstants.USER_TYPE)
30   - private Integer userType;
31   -
32   - @ExcelProperty("应用名")
33   - private String applicationName;
34   -
35   - @ExcelProperty("请求方法名")
36   - private String requestMethod;
37   -
38   - @ExcelProperty("请求地址")
39   - private String requestUrl;
40   -
41   - @ExcelProperty("请求参数")
42   - private String requestParams;
43   -
44   - @ExcelProperty("用户 IP")
45   - private String userIp;
46   -
47   - @ExcelProperty("浏览器 UA")
48   - private String userAgent;
49   -
50   - @ExcelProperty("异常发生时间")
51   - private LocalDateTime exceptionTime;
52   -
53   - @ExcelProperty("异常名")
54   - private String exceptionName;
55   -
56   - @ExcelProperty("异常导致的消息")
57   - private String exceptionMessage;
58   -
59   - @ExcelProperty("异常导致的根消息")
60   - private String exceptionRootCauseMessage;
61   -
62   - @ExcelProperty("异常的栈轨迹")
63   - private String exceptionStackTrace;
64   -
65   - @ExcelProperty("异常发生的类全名")
66   - private String exceptionClassName;
67   -
68   - @ExcelProperty("异常发生的类文件")
69   - private String exceptionFileName;
70   -
71   - @ExcelProperty("异常发生的方法名")
72   - private String exceptionMethodName;
73   -
74   - @ExcelProperty("异常发生的方法所在行")
75   - private Integer exceptionLineNumber;
76   -
77   - @ExcelProperty("创建时间")
78   - private LocalDateTime createTime;
79   -
80   - @ExcelProperty(value = "处理状态", converter = DictConvert.class)
81   - @DictFormat(DictTypeConstants.API_ERROR_LOG_PROCESS_STATUS)
82   - private Integer processStatus;
83   -
84   - @ExcelProperty("处理时间")
85   - private LocalDateTime processTime;
86   -
87   - @ExcelProperty("处理用户编号")
88   - private Integer processUserId;
89   -
90   -}
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/logger/vo/apierrorlog/ApiErrorLogExportReqVO.java deleted
1   -package cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog;
2   -
3   -import io.swagger.v3.oas.annotations.media.Schema;
4   -import lombok.Data;
5   -import org.springframework.format.annotation.DateTimeFormat;
6   -
7   -import java.time.LocalDateTime;
8   -
9   -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
10   -
11   -@Schema(description = "管理后台 - API 错误日志 Excel 导出 Request VO,参数和 ApiErrorLogPageReqVO 是一致的")
12   -@Data
13   -public class ApiErrorLogExportReqVO {
14   -
15   - @Schema(description = "用户编号", example = "666")
16   - private Long userId;
17   -
18   - @Schema(description = "用户类型", example = "1")
19   - private Integer userType;
20   -
21   - @Schema(description = "应用名", example = "dashboard")
22   - private String applicationName;
23   -
24   - @Schema(description = "请求地址", example = "/xx/yy")
25   - private String requestUrl;
26   -
27   - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
28   - @Schema(description = "异常发生时间")
29   - private LocalDateTime[] exceptionTime;
30   -
31   - @Schema(description = "处理状态", example = "0")
32   - private Integer processStatus;
33   -
34   -}
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/logger/vo/apierrorlog/ApiErrorLogRespVO.java
1 1 package cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog;
2 2  
  3 +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
  4 +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
  5 +import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
  6 +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
  7 +import com.alibaba.excel.annotation.ExcelProperty;
3 8 import io.swagger.v3.oas.annotations.media.Schema;
4 9 import lombok.Data;
5   -import lombok.EqualsAndHashCode;
6   -import lombok.ToString;
7 10  
8 11 import java.time.LocalDateTime;
9 12  
10 13 @Schema(description = "管理后台 - API 错误日志 Response VO")
11 14 @Data
12   -@EqualsAndHashCode(callSuper = true)
13   -@ToString(callSuper = true)
14   -public class ApiErrorLogRespVO extends ApiErrorLogBaseVO {
  15 +@ExcelIgnoreUnannotated
  16 +public class ApiErrorLogRespVO {
15 17  
16 18 @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
  19 + @ExcelProperty("编号")
17 20 private Integer id;
18 21  
19   - @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
20   - private LocalDateTime createTime;
  22 + @Schema(description = "链路追踪编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "66600cb6-7852-11eb-9439-0242ac130002")
  23 + @ExcelProperty("链路追踪编号")
  24 + private String traceId;
  25 +
  26 + @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "666")
  27 + @ExcelProperty("用户编号")
  28 + private Integer userId;
  29 +
  30 + @Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  31 + @ExcelProperty(value = "用户类型", converter = DictConvert.class)
  32 + @DictFormat(cn.iocoder.yudao.module.system.enums.DictTypeConstants.USER_TYPE)
  33 + private Integer userType;
  34 +
  35 + @Schema(description = "应用名", requiredMode = Schema.RequiredMode.REQUIRED, example = "dashboard")
  36 + @ExcelProperty("应用名")
  37 + private String applicationName;
  38 +
  39 + @Schema(description = "请求方法名", requiredMode = Schema.RequiredMode.REQUIRED, example = "GET")
  40 + @ExcelProperty("请求方法名")
  41 + private String requestMethod;
  42 +
  43 + @Schema(description = "请求地址", requiredMode = Schema.RequiredMode.REQUIRED, example = "/xx/yy")
  44 + @ExcelProperty("请求地址")
  45 + private String requestUrl;
  46 +
  47 + @Schema(description = "请求参数", requiredMode = Schema.RequiredMode.REQUIRED)
  48 + @ExcelProperty("请求参数")
  49 + private String requestParams;
  50 +
  51 + @Schema(description = "用户 IP", requiredMode = Schema.RequiredMode.REQUIRED, example = "127.0.0.1")
  52 + @ExcelProperty("用户 IP")
  53 + private String userIp;
  54 +
  55 + @Schema(description = "浏览器 UA", requiredMode = Schema.RequiredMode.REQUIRED, example = "Mozilla/5.0")
  56 + @ExcelProperty("浏览器 UA")
  57 + private String userAgent;
  58 +
  59 + @Schema(description = "异常发生时间", requiredMode = Schema.RequiredMode.REQUIRED)
  60 + @ExcelProperty("异常发生时间")
  61 + private LocalDateTime exceptionTime;
  62 +
  63 + @Schema(description = "异常名", requiredMode = Schema.RequiredMode.REQUIRED)
  64 + @ExcelProperty("异常名")
  65 + private String exceptionName;
  66 +
  67 + @Schema(description = "异常导致的消息", requiredMode = Schema.RequiredMode.REQUIRED)
  68 + @ExcelProperty("异常导致的消息")
  69 + private String exceptionMessage;
  70 +
  71 + @Schema(description = "异常导致的根消息", requiredMode = Schema.RequiredMode.REQUIRED)
  72 + @ExcelProperty("异常导致的根消息")
  73 + private String exceptionRootCauseMessage;
  74 +
  75 + @Schema(description = "异常的栈轨迹", requiredMode = Schema.RequiredMode.REQUIRED)
  76 + @ExcelProperty("异常的栈轨迹")
  77 + private String exceptionStackTrace;
  78 +
  79 + @Schema(description = "异常发生的类全名", requiredMode = Schema.RequiredMode.REQUIRED)
  80 + @ExcelProperty("异常发生的类全名")
  81 + private String exceptionClassName;
  82 +
  83 + @Schema(description = "异常发生的类文件", requiredMode = Schema.RequiredMode.REQUIRED)
  84 + @ExcelProperty("异常发生的类文件")
  85 + private String exceptionFileName;
  86 +
  87 + @Schema(description = "异常发生的方法名", requiredMode = Schema.RequiredMode.REQUIRED)
  88 + @ExcelProperty("异常发生的方法名")
  89 + private String exceptionMethodName;
  90 +
  91 + @Schema(description = "异常发生的方法所在行", requiredMode = Schema.RequiredMode.REQUIRED)
  92 + @ExcelProperty("异常发生的方法所在行")
  93 + private Integer exceptionLineNumber;
  94 +
  95 + @Schema(description = "处理状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
  96 + @ExcelProperty(value = "处理状态", converter = DictConvert.class)
  97 + @DictFormat(DictTypeConstants.API_ERROR_LOG_PROCESS_STATUS)
  98 + private Integer processStatus;
21 99  
22 100 @Schema(description = "处理时间", requiredMode = Schema.RequiredMode.REQUIRED)
  101 + @ExcelProperty("处理时间")
23 102 private LocalDateTime processTime;
24 103  
25 104 @Schema(description = "处理用户编号", example = "233")
  105 + @ExcelProperty("处理用户编号")
26 106 private Integer processUserId;
27 107  
  108 + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
  109 + @ExcelProperty("创建时间")
  110 + private LocalDateTime createTime;
  111 +
28 112 }
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/logger/ApiAccessLogConvert.java deleted
1   -package cn.iocoder.yudao.module.infra.convert.logger;
2   -
3   -import cn.iocoder.yudao.framework.common.pojo.PageResult;
4   -import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO;
5   -import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExcelVO;
6   -import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogRespVO;
7   -import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO;
8   -import org.mapstruct.Mapper;
9   -import org.mapstruct.factory.Mappers;
10   -
11   -import java.util.List;
12   -
13   -/**
14   - * API 访问日志 Convert
15   - *
16   - * @author 芋道源码
17   - */
18   -@Mapper
19   -public interface ApiAccessLogConvert {
20   -
21   - ApiAccessLogConvert INSTANCE = Mappers.getMapper(ApiAccessLogConvert.class);
22   -
23   - ApiAccessLogRespVO convert(ApiAccessLogDO bean);
24   -
25   - List<ApiAccessLogRespVO> convertList(List<ApiAccessLogDO> list);
26   -
27   - PageResult<ApiAccessLogRespVO> convertPage(PageResult<ApiAccessLogDO> page);
28   -
29   - List<ApiAccessLogExcelVO> convertList02(List<ApiAccessLogDO> list);
30   -
31   - ApiAccessLogDO convert(ApiAccessLogCreateReqDTO bean);
32   -
33   -}
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/logger/ApiErrorLogConvert.java deleted
1   -package cn.iocoder.yudao.module.infra.convert.logger;
2   -
3   -import cn.iocoder.yudao.framework.common.pojo.PageResult;
4   -import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO;
5   -import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExcelVO;
6   -import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogRespVO;
7   -import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO;
8   -import org.mapstruct.Mapper;
9   -import org.mapstruct.factory.Mappers;
10   -
11   -import java.util.List;
12   -
13   -/**
14   - * API 错误日志 Convert
15   - *
16   - * @author 芋道源码
17   - */
18   -@Mapper
19   -public interface ApiErrorLogConvert {
20   -
21   - ApiErrorLogConvert INSTANCE = Mappers.getMapper(ApiErrorLogConvert.class);
22   -
23   - ApiErrorLogRespVO convert(ApiErrorLogDO bean);
24   -
25   - PageResult<ApiErrorLogRespVO> convertPage(PageResult<ApiErrorLogDO> page);
26   -
27   - List<ApiErrorLogExcelVO> convertList02(List<ApiErrorLogDO> list);
28   -
29   - ApiErrorLogDO convert(ApiErrorLogCreateReqDTO bean);
30   -
31   -}
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/logger/ApiAccessLogMapper.java
... ... @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.infra.dal.mysql.logger;
3 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 4 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
5 5 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
6   -import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExportReqVO;
7 6 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO;
8 7 import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO;
9 8 import org.apache.ibatis.annotations.Delete;
... ... @@ -11,7 +10,6 @@ import org.apache.ibatis.annotations.Mapper;
11 10 import org.apache.ibatis.annotations.Param;
12 11  
13 12 import java.time.LocalDateTime;
14   -import java.util.List;
15 13  
16 14 /**
17 15 * API 访问日志 Mapper
... ... @@ -34,19 +32,6 @@ public interface ApiAccessLogMapper extends BaseMapperX&lt;ApiAccessLogDO&gt; {
34 32 );
35 33 }
36 34  
37   - default List<ApiAccessLogDO> selectList(ApiAccessLogExportReqVO reqVO) {
38   - return selectList(new LambdaQueryWrapperX<ApiAccessLogDO>()
39   - .eqIfPresent(ApiAccessLogDO::getUserId, reqVO.getUserId())
40   - .eqIfPresent(ApiAccessLogDO::getUserType, reqVO.getUserType())
41   - .eqIfPresent(ApiAccessLogDO::getApplicationName, reqVO.getApplicationName())
42   - .likeIfPresent(ApiAccessLogDO::getRequestUrl, reqVO.getRequestUrl())
43   - .betweenIfPresent(ApiAccessLogDO::getBeginTime, reqVO.getBeginTime())
44   - .geIfPresent(ApiAccessLogDO::getDuration, reqVO.getDuration())
45   - .eqIfPresent(ApiAccessLogDO::getResultCode, reqVO.getResultCode())
46   - .orderByDesc(ApiAccessLogDO::getId)
47   - );
48   - }
49   -
50 35 /**
51 36 * 物理删除指定时间之前的日志
52 37 *
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/mysql/logger/ApiErrorLogMapper.java
... ... @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.infra.dal.mysql.logger;
3 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 4 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
5 5 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
6   -import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExportReqVO;
7 6 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO;
8 7 import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO;
9 8 import org.apache.ibatis.annotations.Delete;
... ... @@ -11,7 +10,6 @@ import org.apache.ibatis.annotations.Mapper;
11 10 import org.apache.ibatis.annotations.Param;
12 11  
13 12 import java.time.LocalDateTime;
14   -import java.util.List;
15 13  
16 14 /**
17 15 * API 错误日志 Mapper
... ... @@ -33,18 +31,6 @@ public interface ApiErrorLogMapper extends BaseMapperX&lt;ApiErrorLogDO&gt; {
33 31 );
34 32 }
35 33  
36   - default List<ApiErrorLogDO> selectList(ApiErrorLogExportReqVO reqVO) {
37   - return selectList(new LambdaQueryWrapperX<ApiErrorLogDO>()
38   - .eqIfPresent(ApiErrorLogDO::getUserId, reqVO.getUserId())
39   - .eqIfPresent(ApiErrorLogDO::getUserType, reqVO.getUserType())
40   - .eqIfPresent(ApiErrorLogDO::getApplicationName, reqVO.getApplicationName())
41   - .likeIfPresent(ApiErrorLogDO::getRequestUrl, reqVO.getRequestUrl())
42   - .betweenIfPresent(ApiErrorLogDO::getExceptionTime, reqVO.getExceptionTime())
43   - .eqIfPresent(ApiErrorLogDO::getProcessStatus, reqVO.getProcessStatus())
44   - .orderByDesc(ApiErrorLogDO::getId)
45   - );
46   - }
47   -
48 34 /**
49 35 * 物理删除指定时间之前的日志
50 36 *
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogService.java
... ... @@ -2,12 +2,9 @@ package cn.iocoder.yudao.module.infra.service.logger;
2 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 4 import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO;
5   -import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExportReqVO;
6 5 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO;
7 6 import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO;
8 7  
9   -import java.util.List;
10   -
11 8 /**
12 9 * API 访问日志 Service 接口
13 10 *
... ... @@ -31,14 +28,6 @@ public interface ApiAccessLogService {
31 28 PageResult<ApiAccessLogDO> getApiAccessLogPage(ApiAccessLogPageReqVO pageReqVO);
32 29  
33 30 /**
34   - * 获得 API 访问日志列表, 用于 Excel 导出
35   - *
36   - * @param exportReqVO 查询条件
37   - * @return API 访问日志分页
38   - */
39   - List<ApiAccessLogDO> getApiAccessLogList(ApiAccessLogExportReqVO exportReqVO);
40   -
41   - /**
42 31 * 清理 exceedDay 天前的访问日志
43 32 *
44 33 * @param exceedDay 超过多少天就进行清理
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImpl.java
1 1 package cn.iocoder.yudao.module.infra.service.logger;
2 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
4 5 import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO;
5   -import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExportReqVO;
6 6 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO;
7   -import cn.iocoder.yudao.module.infra.convert.logger.ApiAccessLogConvert;
8 7 import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO;
9 8 import cn.iocoder.yudao.module.infra.dal.mysql.logger.ApiAccessLogMapper;
10 9 import lombok.extern.slf4j.Slf4j;
... ... @@ -13,7 +12,6 @@ import org.springframework.validation.annotation.Validated;
13 12  
14 13 import javax.annotation.Resource;
15 14 import java.time.LocalDateTime;
16   -import java.util.List;
17 15  
18 16 /**
19 17 * API 访问日志 Service 实现类
... ... @@ -30,7 +28,7 @@ public class ApiAccessLogServiceImpl implements ApiAccessLogService {
30 28  
31 29 @Override
32 30 public void createApiAccessLog(ApiAccessLogCreateReqDTO createDTO) {
33   - ApiAccessLogDO apiAccessLog = ApiAccessLogConvert.INSTANCE.convert(createDTO);
  31 + ApiAccessLogDO apiAccessLog = BeanUtils.toBean(createDTO, ApiAccessLogDO.class);
34 32 apiAccessLogMapper.insert(apiAccessLog);
35 33 }
36 34  
... ... @@ -40,11 +38,6 @@ public class ApiAccessLogServiceImpl implements ApiAccessLogService {
40 38 }
41 39  
42 40 @Override
43   - public List<ApiAccessLogDO> getApiAccessLogList(ApiAccessLogExportReqVO exportReqVO) {
44   - return apiAccessLogMapper.selectList(exportReqVO);
45   - }
46   -
47   - @Override
48 41 @SuppressWarnings("DuplicatedCode")
49 42 public Integer cleanAccessLog(Integer exceedDay, Integer deleteLimit) {
50 43 int count = 0;
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogService.java
... ... @@ -2,12 +2,9 @@ package cn.iocoder.yudao.module.infra.service.logger;
2 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 4 import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO;
5   -import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExportReqVO;
6 5 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO;
7 6 import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO;
8 7  
9   -import java.util.List;
10   -
11 8 /**
12 9 * API 错误日志 Service 接口
13 10 *
... ... @@ -31,14 +28,6 @@ public interface ApiErrorLogService {
31 28 PageResult<ApiErrorLogDO> getApiErrorLogPage(ApiErrorLogPageReqVO pageReqVO);
32 29  
33 30 /**
34   - * 获得 API 错误日志列表, 用于 Excel 导出
35   - *
36   - * @param exportReqVO 查询条件
37   - * @return API 错误日志分页
38   - */
39   - List<ApiErrorLogDO> getApiErrorLogList(ApiErrorLogExportReqVO exportReqVO);
40   -
41   - /**
42 31 * 更新 API 错误日志已处理
43 32 *
44 33 * @param id API 日志编号
... ...
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImpl.java
1 1 package cn.iocoder.yudao.module.infra.service.logger;
2 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
4 5 import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO;
5   -import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExportReqVO;
6 6 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO;
7   -import cn.iocoder.yudao.module.infra.convert.logger.ApiErrorLogConvert;
8 7 import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO;
9 8 import cn.iocoder.yudao.module.infra.dal.mysql.logger.ApiErrorLogMapper;
10 9 import cn.iocoder.yudao.module.infra.enums.logger.ApiErrorLogProcessStatusEnum;
... ... @@ -14,11 +13,9 @@ import org.springframework.validation.annotation.Validated;
14 13  
15 14 import javax.annotation.Resource;
16 15 import java.time.LocalDateTime;
17   -import java.util.List;
18 16  
19 17 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
20   -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.API_ERROR_LOG_NOT_FOUND;
21   -import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.API_ERROR_LOG_PROCESSED;
  18 +import static cn.iocoder.yudao.module.infra.enums.ErrorCodeConstants.*;
22 19  
23 20 /**
24 21 * API 错误日志 Service 实现类
... ... @@ -35,7 +32,7 @@ public class ApiErrorLogServiceImpl implements ApiErrorLogService {
35 32  
36 33 @Override
37 34 public void createApiErrorLog(ApiErrorLogCreateReqDTO createDTO) {
38   - ApiErrorLogDO apiErrorLog = ApiErrorLogConvert.INSTANCE.convert(createDTO)
  35 + ApiErrorLogDO apiErrorLog = BeanUtils.toBean(createDTO, ApiErrorLogDO.class)
39 36 .setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus());
40 37 apiErrorLogMapper.insert(apiErrorLog);
41 38 }
... ... @@ -46,11 +43,6 @@ public class ApiErrorLogServiceImpl implements ApiErrorLogService {
46 43 }
47 44  
48 45 @Override
49   - public List<ApiErrorLogDO> getApiErrorLogList(ApiErrorLogExportReqVO exportReqVO) {
50   - return apiErrorLogMapper.selectList(exportReqVO);
51   - }
52   -
53   - @Override
54 46 public void updateApiErrorLogProcess(Long id, Integer processStatus, Long processUserId) {
55 47 ApiErrorLogDO errorLog = apiErrorLogMapper.selectById(id);
56 48 if (errorLog == null) {
... ...
yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImplTest.java
... ... @@ -5,7 +5,6 @@ import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstant
5 5 import cn.iocoder.yudao.framework.common.pojo.PageResult;
6 6 import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
7 7 import cn.iocoder.yudao.module.infra.api.logger.dto.ApiAccessLogCreateReqDTO;
8   -import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogExportReqVO;
9 8 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.ApiAccessLogPageReqVO;
10 9 import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO;
11 10 import cn.iocoder.yudao.module.infra.dal.mysql.logger.ApiAccessLogMapper;
... ... @@ -13,7 +12,6 @@ import org.junit.jupiter.api.Test;
13 12 import org.springframework.context.annotation.Import;
14 13  
15 14 import javax.annotation.Resource;
16   -import java.util.List;
17 15  
18 16 import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime;
19 17 import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildTime;
... ... @@ -76,49 +74,6 @@ public class ApiAccessLogServiceImplTest extends BaseDbUnitTest {
76 74 }
77 75  
78 76 @Test
79   - public void testGetApiAccessLogList() {
80   - ApiAccessLogDO apiAccessLogDO = randomPojo(ApiAccessLogDO.class, o -> {
81   - o.setUserId(2233L);
82   - o.setUserType(UserTypeEnum.ADMIN.getValue());
83   - o.setApplicationName("yudao-test");
84   - o.setRequestUrl("foo");
85   - o.setBeginTime(buildTime(2021, 3, 13));
86   - o.setDuration(1000);
87   - o.setResultCode(GlobalErrorCodeConstants.SUCCESS.getCode());
88   - });
89   - apiAccessLogMapper.insert(apiAccessLogDO);
90   - // 测试 userId 不匹配
91   - apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setUserId(3344L)));
92   - // 测试 userType 不匹配
93   - apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setUserType(UserTypeEnum.MEMBER.getValue())));
94   - // 测试 applicationName 不匹配
95   - apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setApplicationName("test")));
96   - // 测试 requestUrl 不匹配
97   - apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setRequestUrl("bar")));
98   - // 测试 beginTime 不匹配:构造一个早期时间 2021-02-06 00:00:00
99   - apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setBeginTime(buildTime(2021, 2, 6))));
100   - // 测试 duration 不匹配
101   - apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setDuration(100)));
102   - // 测试 resultCode 不匹配
103   - apiAccessLogMapper.insert(cloneIgnoreId(apiAccessLogDO, o -> o.setResultCode(2)));
104   - // 准备参数
105   - ApiAccessLogExportReqVO reqVO = new ApiAccessLogExportReqVO();
106   - reqVO.setUserId(2233L);
107   - reqVO.setUserType(UserTypeEnum.ADMIN.getValue());
108   - reqVO.setApplicationName("yudao-test");
109   - reqVO.setRequestUrl("foo");
110   - reqVO.setBeginTime(buildBetweenTime(2021, 3, 13, 2021, 3, 13));
111   - reqVO.setDuration(1000);
112   - reqVO.setResultCode(GlobalErrorCodeConstants.SUCCESS.getCode());
113   -
114   - // 调用
115   - List<ApiAccessLogDO> list = apiAccessLogService.getApiAccessLogList(reqVO);
116   - // 断言,只查到了一条符合条件的
117   - assertEquals(1, list.size());
118   - assertPojoEquals(apiAccessLogDO, list.get(0));
119   - }
120   -
121   - @Test
122 77 public void testCreateApiAccessLog() {
123 78 // 准备参数
124 79 ApiAccessLogCreateReqDTO createDTO = randomPojo(ApiAccessLogCreateReqDTO.class);
... ...
yudao-module-infra/yudao-module-infra-biz/src/test/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImplTest.java
... ... @@ -4,7 +4,6 @@ import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
4 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
5 5 import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
6 6 import cn.iocoder.yudao.module.infra.api.logger.dto.ApiErrorLogCreateReqDTO;
7   -import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogExportReqVO;
8 7 import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apierrorlog.ApiErrorLogPageReqVO;
9 8 import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiErrorLogDO;
10 9 import cn.iocoder.yudao.module.infra.dal.mysql.logger.ApiErrorLogMapper;
... ... @@ -13,7 +12,6 @@ import org.junit.jupiter.api.Test;
13 12 import org.springframework.context.annotation.Import;
14 13  
15 14 import javax.annotation.Resource;
16   -import java.util.List;
17 15  
18 16 import static cn.hutool.core.util.RandomUtil.randomEle;
19 17 import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime;
... ... @@ -79,46 +77,6 @@ public class ApiErrorLogServiceImplTest extends BaseDbUnitTest {
79 77 }
80 78  
81 79 @Test
82   - public void testGetApiErrorLogList() {
83   - // mock 数据
84   - ApiErrorLogDO apiErrorLogDO = randomPojo(ApiErrorLogDO.class, o -> {
85   - o.setUserId(2233L);
86   - o.setUserType(UserTypeEnum.ADMIN.getValue());
87   - o.setApplicationName("yudao-test");
88   - o.setRequestUrl("foo");
89   - o.setExceptionTime(buildTime(2021, 3, 13));
90   - o.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus());
91   - });
92   - apiErrorLogMapper.insert(apiErrorLogDO);
93   - // 测试 userId 不匹配
94   - apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, o -> o.setUserId(3344L)));
95   - // 测试 userType 不匹配
96   - apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, logDO -> logDO.setUserType(UserTypeEnum.MEMBER.getValue())));
97   - // 测试 applicationName 不匹配
98   - apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, logDO -> logDO.setApplicationName("test")));
99   - // 测试 requestUrl 不匹配
100   - apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, logDO -> logDO.setRequestUrl("bar")));
101   - // 测试 exceptionTime 不匹配:构造一个早期时间 2021-02-06 00:00:00
102   - apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, logDO -> logDO.setExceptionTime(buildTime(2021, 2, 6))));
103   - // 测试 progressStatus 不匹配
104   - apiErrorLogMapper.insert(cloneIgnoreId(apiErrorLogDO, logDO -> logDO.setProcessStatus(ApiErrorLogProcessStatusEnum.DONE.getStatus())));
105   - // 准备参数
106   - ApiErrorLogExportReqVO reqVO = new ApiErrorLogExportReqVO();
107   - reqVO.setUserId(2233L);
108   - reqVO.setUserType(UserTypeEnum.ADMIN.getValue());
109   - reqVO.setApplicationName("yudao-test");
110   - reqVO.setRequestUrl("foo");
111   - reqVO.setExceptionTime(buildBetweenTime(2021, 3, 1, 2021, 3, 31));
112   - reqVO.setProcessStatus(ApiErrorLogProcessStatusEnum.INIT.getStatus());
113   -
114   - // 调用
115   - List<ApiErrorLogDO> list = apiErrorLogService.getApiErrorLogList(reqVO);
116   - // 断言,只查到了一条符合条件的
117   - assertEquals(1, list.size());
118   - assertPojoEquals(apiErrorLogDO, list.get(0));
119   - }
120   -
121   - @Test
122 80 public void testCreateApiErrorLog() {
123 81 // 准备参数
124 82 ApiErrorLogCreateReqDTO createDTO = randomPojo(ApiErrorLogCreateReqDTO.class);
... ...