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.module.system.controller.admin.logger.vo.loginlog.LoginLogPageReqVO;
10 import com.iailab.module.system.controller.admin.logger.vo.loginlog.LoginLogRespVO;
11 import com.iailab.module.system.dal.dataobject.logger.LoginLogDO;
12 import com.iailab.module.system.service.logger.LoginLogService;
13 import io.swagger.v3.oas.annotations.Operation;
14 import io.swagger.v3.oas.annotations.tags.Tag;
15 import org.springframework.security.access.prepost.PreAuthorize;
16 import org.springframework.validation.annotation.Validated;
17 import org.springframework.web.bind.annotation.GetMapping;
18 import org.springframework.web.bind.annotation.RequestMapping;
19 import org.springframework.web.bind.annotation.RestController;
20
21 import javax.annotation.Resource;
22 import javax.servlet.http.HttpServletResponse;
23 import javax.validation.Valid;
24 import java.io.IOException;
25 import java.util.List;
26
27 import static com.iailab.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
28 import static com.iailab.framework.common.pojo.CommonResult.success;
29
30 @Tag(name = "管理后台 - 登录日志")
31 @RestController
32 @RequestMapping("/system/login-log")
33 @Validated
34 public class LoginLogController {
35
36     @Resource
37     private LoginLogService loginLogService;
38
39     @GetMapping("/page")
40     @Operation(summary = "获得登录日志分页列表")
41     @PreAuthorize("@ss.hasPermission('system:login-log:query')")
42     public CommonResult<PageResult<LoginLogRespVO>> getLoginLogPage(@Valid LoginLogPageReqVO pageReqVO) {
43         PageResult<LoginLogDO> pageResult = loginLogService.getLoginLogPage(pageReqVO);
44         return success(BeanUtils.toBean(pageResult, LoginLogRespVO.class));
45     }
46
47     @GetMapping("/export")
48     @Operation(summary = "导出登录日志 Excel")
49     @PreAuthorize("@ss.hasPermission('system:login-log:export')")
50     @ApiAccessLog(operateType = EXPORT)
51     public void exportLoginLog(HttpServletResponse response, @Valid LoginLogPageReqVO exportReqVO) throws IOException {
52         exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
53         List<LoginLogDO> list = loginLogService.getLoginLogPage(exportReqVO).getList();
54         // 输出
55         ExcelUtils.write(response, "登录日志.xls", "数据列表", LoginLogRespVO.class,
56                 BeanUtils.toBean(list, LoginLogRespVO.class));
57     }
58
59 }