dengzedong
2024-12-24 76743b009ca5ea67557fcab597b332f8d1947813
提交 | 用户 | 时间
e7c126 1 package com.iailab.module.system.controller.admin.logger;
H 2
3 import com.iailab.framework.apilog.core.annotation.ApiAccessLog;
4 import com.iailab.framework.common.pojo.CommonResult;
5 import com.iailab.framework.common.pojo.PageParam;
6 import com.iailab.framework.common.pojo.PageResult;
7 import com.iailab.framework.common.util.object.BeanUtils;
8 import com.iailab.framework.excel.core.util.ExcelUtils;
9 import com.iailab.framework.translate.core.TranslateUtils;
10 import com.iailab.module.system.controller.admin.logger.vo.operatelog.OperateLogPageReqVO;
11 import com.iailab.module.system.controller.admin.logger.vo.operatelog.OperateLogRespVO;
12 import com.iailab.module.system.dal.dataobject.logger.OperateLogDO;
13 import com.iailab.module.system.service.logger.OperateLogService;
14 import io.swagger.v3.oas.annotations.Operation;
15 import io.swagger.v3.oas.annotations.tags.Tag;
16 import org.springframework.security.access.prepost.PreAuthorize;
17 import org.springframework.validation.annotation.Validated;
18 import org.springframework.web.bind.annotation.GetMapping;
19 import org.springframework.web.bind.annotation.RequestMapping;
20 import org.springframework.web.bind.annotation.RestController;
21
22 import javax.annotation.Resource;
23 import javax.servlet.http.HttpServletResponse;
24 import javax.validation.Valid;
25 import java.io.IOException;
26 import java.util.List;
27
28 import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
29 import static com.iailab.framework.common.pojo.CommonResult.success;
30
31 @Tag(name = "管理后台 - 操作日志")
32 @RestController
33 @RequestMapping("/system/operate-log")
34 @Validated
35 public class OperateLogController {
36
37     @Resource
38     private OperateLogService operateLogService;
39
40     @GetMapping("/page")
41     @Operation(summary = "查看操作日志分页列表")
42     @PreAuthorize("@ss.hasPermission('system:operate-log:query')")
43     public CommonResult<PageResult<OperateLogRespVO>> pageOperateLog(@Valid OperateLogPageReqVO pageReqVO) {
44         PageResult<OperateLogDO> pageResult = operateLogService.getOperateLogPage(pageReqVO);
45         return success(BeanUtils.toBean(pageResult, OperateLogRespVO.class));
46     }
47
48     @Operation(summary = "导出操作日志")
49     @GetMapping("/export")
50     @PreAuthorize("@ss.hasPermission('system:operate-log:export')")
51     @ApiAccessLog(operateType = EXPORT)
52     public void exportOperateLog(HttpServletResponse response, @Valid OperateLogPageReqVO exportReqVO) throws IOException {
53         exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
54         List<OperateLogDO> list = operateLogService.getOperateLogPage(exportReqVO).getList();
55         ExcelUtils.write(response, "操作日志.xls", "数据列表", OperateLogRespVO.class,
56                 TranslateUtils.translate(BeanUtils.toBean(list, OperateLogRespVO.class)));
57     }
58
59 }