cigs4/ym-admin/src/main/java/com/cnbm/admin/controller/SysLogLoginController.java
2023-03-24 11:54:31 +08:00

68 lines
3.3 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.cnbm.admin.controller;
import com.cnbm.admin.annotation.LogOperation;
import com.cnbm.admin.dto.SysLogLoginDTO;
import com.cnbm.admin.execl.SysLogLoginExcel;
import com.cnbm.admin.service.SysLogLoginService;
import com.cnbm.common.constant.Constant;
import com.cnbm.common.page.PageData;
import com.cnbm.common.utils.ExcelUtils;
import com.cnbm.common.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
@RestController
@RequestMapping("sys/log/login")
@Api(tags="登录日志")
@Log4j2
public class SysLogLoginController {
@Autowired
private SysLogLoginService sysLogLoginService;
@GetMapping("page")
@ApiOperation("分页")
@ApiImplicitParams({
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码从1开始", paramType = "query", required = true, dataTypeClass=Integer.class) ,
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataTypeClass=Integer.class) ,
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) ,
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataTypeClass=String.class) ,
@ApiImplicitParam(name = "status", value = "状态 0失败 1成功 2账号已锁定", paramType = "query", dataTypeClass=Integer.class),
@ApiImplicitParam(name = "creatorName", value = "用户名", paramType = "query", dataTypeClass=String.class)
})
@PreAuthorize("@ex.hasAuthority('sys:log:login')")
public Result<PageData<SysLogLoginDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
PageData<SysLogLoginDTO> page = sysLogLoginService.page(params);
return new Result<PageData<SysLogLoginDTO>>().ok(page);
}
@GetMapping("export")
@ApiOperation("导出")
@LogOperation("导出")
@ApiImplicitParams({
@ApiImplicitParam(name = "status", value = "状态 0失败 1成功 2账号已锁定", paramType = "query", dataTypeClass=Integer.class),
@ApiImplicitParam(name = "creatorName", value = "用户名", paramType = "query", dataTypeClass=String.class)
})
@PreAuthorize("@ex.hasAuthority('sys:log:login')")
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
List<SysLogLoginDTO> list = sysLogLoginService.list(params);
ExcelUtils.exportExcelToTarget(response, "登入登出日志导出", list, SysLogLoginExcel.class);
}
}