LoginLogController.java 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. package com.huaxu.controller;
  2. import com.baomidou.mybatisplus.core.metadata.IPage;
  3. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  4. import com.huaxu.common.EasyExcelUtil;
  5. import com.huaxu.dto.LoginLogDto;
  6. import com.huaxu.entity.LoginLogEntity;
  7. import com.huaxu.model.AjaxMessage;
  8. import com.huaxu.model.Pagination;
  9. import com.huaxu.model.ResultStatus;
  10. import com.huaxu.service.LoginLogService;
  11. import io.swagger.annotations.Api;
  12. import io.swagger.annotations.ApiOperation;
  13. import io.swagger.annotations.ApiParam;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.beans.factory.annotation.Value;
  16. import org.springframework.web.bind.annotation.*;
  17. import java.util.List;
  18. /**
  19. * @description 登录日志管理控制层
  20. * @auto wangli
  21. * @data 2020-10-27 9:19
  22. */
  23. @RestController
  24. @RequestMapping("/loginLog")
  25. @Api(tags = "登录日志管理")
  26. public class LoginLogController {
  27. @Autowired
  28. private LoginLogService loginLogService;
  29. @Value("${UMIS.sys_excel_path}")
  30. private String baseDir;
  31. /**
  32. * 通过主键查询单条数据
  33. *
  34. * @param id
  35. * @return 单条数据
  36. */
  37. @RequestMapping(value = "get", method = RequestMethod.POST)
  38. @ApiOperation(value = "根据id查询登录日志")
  39. public AjaxMessage<LoginLogDto> selectOne(
  40. @ApiParam(value = "登录日志信息", required = true) @RequestParam Long id) {
  41. LoginLogDto result = loginLogService.selectById(id);
  42. return new AjaxMessage<>(ResultStatus.OK, result);
  43. }
  44. /**
  45. * 查询登录日志信息
  46. *
  47. * @param loginLogDto 参数对象
  48. * @return 多条数据
  49. */
  50. @RequestMapping(value = "selectList", method = RequestMethod.POST)
  51. @ApiOperation(value = "查询登录日志信息")
  52. public AjaxMessage<List<LoginLogDto>> selectList(
  53. @ApiParam(value = "登录日志信息", required = true) @RequestBody LoginLogDto loginLogDto) {
  54. List<LoginLogDto> result = loginLogService.selectList(loginLogDto);
  55. return new AjaxMessage<>(ResultStatus.OK, result);
  56. }
  57. /**
  58. * 新增一条数据
  59. *
  60. * @param loginLogEntity 实体类
  61. * @return Response对象
  62. */
  63. @RequestMapping(value = "insert", method = RequestMethod.POST)
  64. @ApiOperation(value = "插入登录日志信息")
  65. public AjaxMessage<Integer> insert(@ApiParam(value = "登录日志信息", required = true) @RequestBody LoginLogEntity loginLogEntity) {
  66. int result = loginLogService.insert(loginLogEntity);
  67. return new AjaxMessage<>(ResultStatus.OK, result);
  68. }
  69. /**
  70. * 修改一条数据
  71. *
  72. * @param loginLogEntity 实体类
  73. * @return Response对象
  74. */
  75. @RequestMapping(value = "update", method = RequestMethod.POST)
  76. @ApiOperation(value = "修改登录日志信息")
  77. public AjaxMessage<Integer> update(@ApiParam(value = "登录日志信息", required = true) @RequestBody LoginLogEntity loginLogEntity) {
  78. int result = loginLogService.update(loginLogEntity);
  79. return new AjaxMessage<>(ResultStatus.OK, result);
  80. }
  81. /**
  82. * 单条删除数据
  83. *
  84. * @param id
  85. * @return Response对象
  86. */
  87. @RequestMapping(value = "delete", method = RequestMethod.POST)
  88. @ApiOperation(value = "删除登录日志信息")
  89. public AjaxMessage<Integer> delete(@ApiParam(value = "登录日志信息", required = true) @RequestParam Long id) {
  90. int result = loginLogService.deleteById(id);
  91. return new AjaxMessage<>(ResultStatus.OK, result);
  92. }
  93. /**
  94. * 分页查询
  95. *
  96. * @param pageNum 偏移
  97. * @param pageSize 条数
  98. * @return Response对象
  99. */
  100. @RequestMapping(value = "selectPage", method = RequestMethod.POST)
  101. @ApiOperation(value = "查询登录日志信息列表")
  102. public AjaxMessage<Pagination<LoginLogDto>> selectPage(
  103. @ApiParam(value = "登录日志信息", required = true) @RequestBody LoginLogDto loginLogDto,
  104. @ApiParam(value = "页数,非必传,默认第一页", defaultValue = "1") int pageNum,
  105. @ApiParam(value = "条数,非必传,默认15条", defaultValue = "30") int pageSize
  106. ) {
  107. IPage<LoginLogDto> iPage = new Page<>(pageNum, pageSize);
  108. iPage = loginLogService.selectPage(iPage, loginLogDto);
  109. Pagination<LoginLogDto> pages = new Pagination<>(iPage);
  110. return new AjaxMessage<>(ResultStatus.OK, pages);
  111. }
  112. @RequestMapping(value = "/exportExcel", method = RequestMethod.POST)
  113. @ApiOperation(value = "登录日志导出")
  114. public AjaxMessage<String> exportExcel(@ApiParam(value = "日志IDS", required = true) @RequestParam Long[] ids) {
  115. List<LoginLogDto> result = loginLogService.selectListByIds(ids);
  116. String filePath = EasyExcelUtil.excelWrite(baseDir, LoginLogDto.class, "登录日志", result);
  117. return new AjaxMessage<>(ResultStatus.OK, filePath);
  118. }
  119. }