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,6 +11,7 @@ import cn.iocoder.yudao.module.infra.controller.admin.logger.vo.apiaccesslog.Api | ||
| 11 | import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO; | 11 | import cn.iocoder.yudao.module.infra.dal.dataobject.logger.ApiAccessLogDO; |
| 12 | import cn.iocoder.yudao.module.infra.service.logger.ApiAccessLogService; | 12 | import cn.iocoder.yudao.module.infra.service.logger.ApiAccessLogService; |
| 13 | import io.swagger.v3.oas.annotations.Operation; | 13 | import io.swagger.v3.oas.annotations.Operation; |
| 14 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 14 | import io.swagger.v3.oas.annotations.tags.Tag; | 15 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 15 | import jakarta.annotation.Resource; | 16 | import jakarta.annotation.Resource; |
| 16 | import jakarta.servlet.http.HttpServletResponse; | 17 | import jakarta.servlet.http.HttpServletResponse; |
| @@ -19,6 +20,7 @@ import org.springframework.security.access.prepost.PreAuthorize; | @@ -19,6 +20,7 @@ import org.springframework.security.access.prepost.PreAuthorize; | ||
| 19 | import org.springframework.validation.annotation.Validated; | 20 | import org.springframework.validation.annotation.Validated; |
| 20 | import org.springframework.web.bind.annotation.GetMapping; | 21 | import org.springframework.web.bind.annotation.GetMapping; |
| 21 | import org.springframework.web.bind.annotation.RequestMapping; | 22 | import org.springframework.web.bind.annotation.RequestMapping; |
| 23 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 22 | import org.springframework.web.bind.annotation.RestController; | 24 | import org.springframework.web.bind.annotation.RestController; |
| 23 | 25 | ||
| 24 | import java.io.IOException; | 26 | import java.io.IOException; |
| @@ -36,6 +38,15 @@ public class ApiAccessLogController { | @@ -36,6 +38,15 @@ public class ApiAccessLogController { | ||
| 36 | @Resource | 38 | @Resource |
| 37 | private ApiAccessLogService apiAccessLogService; | 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 | @GetMapping("/page") | 50 | @GetMapping("/page") |
| 40 | @Operation(summary = "获得API 访问日志分页") | 51 | @Operation(summary = "获得API 访问日志分页") |
| 41 | @PreAuthorize("@ss.hasPermission('infra:api-access-log:query')") | 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,6 +50,15 @@ public class ApiErrorLogController { | ||
| 50 | return success(true); | 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 | @GetMapping("/page") | 62 | @GetMapping("/page") |
| 54 | @Operation(summary = "获得 API 错误日志分页") | 63 | @Operation(summary = "获得 API 错误日志分页") |
| 55 | @PreAuthorize("@ss.hasPermission('infra:api-error-log:query')") | 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,6 +20,14 @@ public interface ApiAccessLogService { | ||
| 20 | void createApiAccessLog(ApiAccessLogCreateReqDTO createReqDTO); | 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 | * 获得 API 访问日志分页 | 31 | * 获得 API 访问日志分页 |
| 24 | * | 32 | * |
| 25 | * @param pageReqVO 分页查询 | 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,6 +46,11 @@ public class ApiAccessLogServiceImpl implements ApiAccessLogService { | ||
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | @Override | 48 | @Override |
| 49 | + public ApiAccessLogDO getApiAccessLog(Long id) { | ||
| 50 | + return apiAccessLogMapper.selectById(id); | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + @Override | ||
| 49 | public PageResult<ApiAccessLogDO> getApiAccessLogPage(ApiAccessLogPageReqVO pageReqVO) { | 54 | public PageResult<ApiAccessLogDO> getApiAccessLogPage(ApiAccessLogPageReqVO pageReqVO) { |
| 50 | return apiAccessLogMapper.selectPage(pageReqVO); | 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,6 +20,14 @@ public interface ApiErrorLogService { | ||
| 20 | void createApiErrorLog(ApiErrorLogCreateReqDTO createReqDTO); | 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 | * 获得 API 错误日志分页 | 31 | * 获得 API 错误日志分页 |
| 24 | * | 32 | * |
| 25 | * @param pageReqVO 分页查询 | 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,6 +59,11 @@ public class ApiErrorLogServiceImpl implements ApiErrorLogService { | ||
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | @Override | 61 | @Override |
| 62 | + public ApiErrorLogDO getApiErrorLog(Long id) { | ||
| 63 | + return apiErrorLogMapper.selectById(id); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + @Override | ||
| 62 | public void updateApiErrorLogProcess(Long id, Integer processStatus, Long processUserId) { | 67 | public void updateApiErrorLogProcess(Long id, Integer processStatus, Long processUserId) { |
| 63 | ApiErrorLogDO errorLog = apiErrorLogMapper.selectById(id); | 68 | ApiErrorLogDO errorLog = apiErrorLogMapper.selectById(id); |
| 64 | if (errorLog == null) { | 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,6 +13,7 @@ import cn.iocoder.yudao.module.system.dal.dataobject.logger.OperateLogDO; | ||
| 13 | import cn.iocoder.yudao.module.system.service.logger.OperateLogService; | 13 | import cn.iocoder.yudao.module.system.service.logger.OperateLogService; |
| 14 | import com.fhs.core.trans.anno.TransMethodResult; | 14 | import com.fhs.core.trans.anno.TransMethodResult; |
| 15 | import io.swagger.v3.oas.annotations.Operation; | 15 | import io.swagger.v3.oas.annotations.Operation; |
| 16 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 16 | import io.swagger.v3.oas.annotations.tags.Tag; | 17 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 17 | import jakarta.annotation.Resource; | 18 | import jakarta.annotation.Resource; |
| 18 | import jakarta.servlet.http.HttpServletResponse; | 19 | import jakarta.servlet.http.HttpServletResponse; |
| @@ -21,6 +22,7 @@ import org.springframework.security.access.prepost.PreAuthorize; | @@ -21,6 +22,7 @@ import org.springframework.security.access.prepost.PreAuthorize; | ||
| 21 | import org.springframework.validation.annotation.Validated; | 22 | import org.springframework.validation.annotation.Validated; |
| 22 | import org.springframework.web.bind.annotation.GetMapping; | 23 | import org.springframework.web.bind.annotation.GetMapping; |
| 23 | import org.springframework.web.bind.annotation.RequestMapping; | 24 | import org.springframework.web.bind.annotation.RequestMapping; |
| 25 | +import org.springframework.web.bind.annotation.RequestParam; | ||
| 24 | import org.springframework.web.bind.annotation.RestController; | 26 | import org.springframework.web.bind.annotation.RestController; |
| 25 | 27 | ||
| 26 | import java.io.IOException; | 28 | import java.io.IOException; |
| @@ -38,6 +40,15 @@ public class OperateLogController { | @@ -38,6 +40,15 @@ public class OperateLogController { | ||
| 38 | @Resource | 40 | @Resource |
| 39 | private OperateLogService operateLogService; | 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 | @GetMapping("/page") | 52 | @GetMapping("/page") |
| 42 | @Operation(summary = "查看操作日志分页列表") | 53 | @Operation(summary = "查看操作日志分页列表") |
| 43 | @PreAuthorize("@ss.hasPermission('system:operate-log:query')") | 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,6 +21,14 @@ public interface OperateLogService { | ||
| 21 | void createOperateLog(OperateLogCreateReqDTO createReqDTO); | 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 | * @param pageReqVO 分页条件 | 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,6 +32,11 @@ public class OperateLogServiceImpl implements OperateLogService { | ||
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | @Override | 34 | @Override |
| 35 | + public OperateLogDO getOperateLog(Long id) { | ||
| 36 | + return operateLogMapper.selectById(id); | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + @Override | ||
| 35 | public PageResult<OperateLogDO> getOperateLogPage(OperateLogPageReqVO pageReqVO) { | 40 | public PageResult<OperateLogDO> getOperateLogPage(OperateLogPageReqVO pageReqVO) { |
| 36 | return operateLogMapper.selectPage(pageReqVO); | 41 | return operateLogMapper.selectPage(pageReqVO); |
| 37 | } | 42 | } |