Commit 8b616c315367b01cd4410012cb4dd73a7e9bfd7e
1 parent
e45e2ae2
feat:【system/infra】访问日志、操作日志、错误日志,增加 get 接口,满足 admin uniapp 查询诉求
Showing
9 changed files
with
70 additions
and
0 deletions
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/logger/ApiAccessLogController.java
| ... | ... | @@ -11,6 +11,7 @@ import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.Api |
| 11 | 11 | import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO; |
| 12 | 12 | import cn.iocoder.yudao.module.infra.service.logger.ApiAccessLogService; |
| 13 | 13 | import io.swagger.v3.oas.annotations.Operation; |
| 14 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 14 | 15 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 15 | 16 | import jakarta.annotation.Resource; |
| 16 | 17 | import jakarta.servlet.http.HttpServletResponse; |
| ... | ... | @@ -19,6 +20,7 @@ import org.springframework.security.access.prepost.PreAuthorize; |
| 19 | 20 | import org.springframework.validation.annotation.Validated; |
| 20 | 21 | import org.springframework.web.bind.annotation.GetMapping; |
| 21 | 22 | import org.springframework.web.bind.annotation.RequestMapping; |
| 23 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 22 | 24 | import org.springframework.web.bind.annotation.RestController; |
| 23 | 25 | |
| 24 | 26 | import java.io.IOException; |
| ... | ... | @@ -36,6 +38,15 @@ public class ApiAccessLogController { |
| 36 | 38 | @Resource |
| 37 | 39 | private ApiAccessLogService apiAccessLogService; |
| 38 | 40 | |
| 41 | + @GetMapping("/get") | |
| 42 | + @Operation(summary = "获得 API 访问日志") | |
| 43 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 44 | + @PreAuthorize("@ss.hasPermission('infra:api-access-log:query')") | |
| 45 | + public CommonResult<ApiAccessLogRespVO> getApiAccessLog(@RequestParam("id") Long id) { | |
| 46 | + ApiAccessLogDO apiAccessLog = apiAccessLogService.getApiAccessLog(id); | |
| 47 | + return success(BeanUtils.toBean(apiAccessLog, ApiAccessLogRespVO.class)); | |
| 48 | + } | |
| 49 | + | |
| 39 | 50 | @GetMapping("/page") |
| 40 | 51 | @Operation(summary = "获得API 访问日志分页") |
| 41 | 52 | @PreAuthorize("@ss.hasPermission('infra:api-access-log:query')") | ... | ... |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/logger/ApiErrorLogController.java
| ... | ... | @@ -50,6 +50,15 @@ public class ApiErrorLogController { |
| 50 | 50 | return success(true); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | + @GetMapping("/get") | |
| 54 | + @Operation(summary = "获得 API 错误日志") | |
| 55 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 56 | + @PreAuthorize("@ss.hasPermission('infra:api-error-log:query')") | |
| 57 | + public CommonResult<ApiErrorLogRespVO> getApiErrorLog(@RequestParam("id") Long id) { | |
| 58 | + ApiErrorLogDO apiErrorLog = apiErrorLogService.getApiErrorLog(id); | |
| 59 | + return success(BeanUtils.toBean(apiErrorLog, ApiErrorLogRespVO.class)); | |
| 60 | + } | |
| 61 | + | |
| 53 | 62 | @GetMapping("/page") |
| 54 | 63 | @Operation(summary = "获得 API 错误日志分页") |
| 55 | 64 | @PreAuthorize("@ss.hasPermission('infra:api-error-log:query')") | ... | ... |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogService.java
| ... | ... | @@ -20,6 +20,14 @@ public interface ApiAccessLogService { |
| 20 | 20 | void createApiAccessLog(ApiAccessLogCreateReqDTO createReqDTO); |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | + * 获得 API 访问日志 | |
| 24 | + * | |
| 25 | + * @param id 编号 | |
| 26 | + * @return API 访问日志 | |
| 27 | + */ | |
| 28 | + ApiAccessLogDO getApiAccessLog(Long id); | |
| 29 | + | |
| 30 | + /** | |
| 23 | 31 | * 获得 API 访问日志分页 |
| 24 | 32 | * |
| 25 | 33 | * @param pageReqVO 分页查询 | ... | ... |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiAccessLogServiceImpl.java
| ... | ... | @@ -46,6 +46,11 @@ public class ApiAccessLogServiceImpl implements ApiAccessLogService { |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | @Override |
| 49 | + public ApiAccessLogDO getApiAccessLog(Long id) { | |
| 50 | + return apiAccessLogMapper.selectById(id); | |
| 51 | + } | |
| 52 | + | |
| 53 | + @Override | |
| 49 | 54 | public PageResult<ApiAccessLogDO> getApiAccessLogPage(ApiAccessLogPageReqVO pageReqVO) { |
| 50 | 55 | return apiAccessLogMapper.selectPage(pageReqVO); |
| 51 | 56 | } | ... | ... |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogService.java
| ... | ... | @@ -20,6 +20,14 @@ public interface ApiErrorLogService { |
| 20 | 20 | void createApiErrorLog(ApiErrorLogCreateReqDTO createReqDTO); |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | + * 获得 API 错误日志 | |
| 24 | + * | |
| 25 | + * @param id 编号 | |
| 26 | + * @return API 错误日志 | |
| 27 | + */ | |
| 28 | + ApiErrorLogDO getApiErrorLog(Long id); | |
| 29 | + | |
| 30 | + /** | |
| 23 | 31 | * 获得 API 错误日志分页 |
| 24 | 32 | * |
| 25 | 33 | * @param pageReqVO 分页查询 | ... | ... |
yudao-module-infra/src/main/java/cn/iocoder/yudao/module/infra/service/logger/ApiErrorLogServiceImpl.java
| ... | ... | @@ -59,6 +59,11 @@ public class ApiErrorLogServiceImpl implements ApiErrorLogService { |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | @Override |
| 62 | + public ApiErrorLogDO getApiErrorLog(Long id) { | |
| 63 | + return apiErrorLogMapper.selectById(id); | |
| 64 | + } | |
| 65 | + | |
| 66 | + @Override | |
| 62 | 67 | public void updateApiErrorLogProcess(Long id, Integer processStatus, Long processUserId) { |
| 63 | 68 | ApiErrorLogDO errorLog = apiErrorLogMapper.selectById(id); |
| 64 | 69 | if (errorLog == null) { | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/logger/OperateLogController.java
| ... | ... | @@ -13,6 +13,7 @@ import cn.iocoder.yudao.module.system.dal.dataobject.logger.OperateLogDO; |
| 13 | 13 | import cn.iocoder.yudao.module.system.service.logger.OperateLogService; |
| 14 | 14 | import com.fhs.core.trans.anno.TransMethodResult; |
| 15 | 15 | import io.swagger.v3.oas.annotations.Operation; |
| 16 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 16 | 17 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 17 | 18 | import jakarta.annotation.Resource; |
| 18 | 19 | import jakarta.servlet.http.HttpServletResponse; |
| ... | ... | @@ -21,6 +22,7 @@ import org.springframework.security.access.prepost.PreAuthorize; |
| 21 | 22 | import org.springframework.validation.annotation.Validated; |
| 22 | 23 | import org.springframework.web.bind.annotation.GetMapping; |
| 23 | 24 | import org.springframework.web.bind.annotation.RequestMapping; |
| 25 | +import org.springframework.web.bind.annotation.RequestParam; | |
| 24 | 26 | import org.springframework.web.bind.annotation.RestController; |
| 25 | 27 | |
| 26 | 28 | import java.io.IOException; |
| ... | ... | @@ -38,6 +40,15 @@ public class OperateLogController { |
| 38 | 40 | @Resource |
| 39 | 41 | private OperateLogService operateLogService; |
| 40 | 42 | |
| 43 | + @GetMapping("/get") | |
| 44 | + @Operation(summary = "查看操作日志") | |
| 45 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 46 | + @PreAuthorize("@ss.hasPermission('system:operate-log:query')") | |
| 47 | + public CommonResult<OperateLogRespVO> getOperateLog(@RequestParam("id") Long id) { | |
| 48 | + OperateLogDO operateLog = operateLogService.getOperateLog(id); | |
| 49 | + return success(BeanUtils.toBean(operateLog, OperateLogRespVO.class)); | |
| 50 | + } | |
| 51 | + | |
| 41 | 52 | @GetMapping("/page") |
| 42 | 53 | @Operation(summary = "查看操作日志分页列表") |
| 43 | 54 | @PreAuthorize("@ss.hasPermission('system:operate-log:query')") | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/logger/OperateLogService.java
| ... | ... | @@ -21,6 +21,14 @@ public interface OperateLogService { |
| 21 | 21 | void createOperateLog(OperateLogCreateReqDTO createReqDTO); |
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | + * 获得操作日志 | |
| 25 | + * | |
| 26 | + * @param id 编号 | |
| 27 | + * @return 操作日志 | |
| 28 | + */ | |
| 29 | + OperateLogDO getOperateLog(Long id); | |
| 30 | + | |
| 31 | + /** | |
| 24 | 32 | * 获得操作日志分页列表 |
| 25 | 33 | * |
| 26 | 34 | * @param pageReqVO 分页条件 | ... | ... |
yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/logger/OperateLogServiceImpl.java
| ... | ... | @@ -32,6 +32,11 @@ public class OperateLogServiceImpl implements OperateLogService { |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | @Override |
| 35 | + public OperateLogDO getOperateLog(Long id) { | |
| 36 | + return operateLogMapper.selectById(id); | |
| 37 | + } | |
| 38 | + | |
| 39 | + @Override | |
| 35 | 40 | public PageResult<OperateLogDO> getOperateLogPage(OperateLogPageReqVO pageReqVO) { |
| 36 | 41 | return operateLogMapper.selectPage(pageReqVO); |
| 37 | 42 | } | ... | ... |