|
@@ -0,0 +1,122 @@
|
|
|
+package com.ozs.web.controller.monitor;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.ozs.common.annotation.Log;
|
|
|
+import com.ozs.common.core.controller.BaseController;
|
|
|
+import com.ozs.common.core.domain.AjaxResult;
|
|
|
+import com.ozs.common.core.domain.vo.SysLoginInfoVo;
|
|
|
+import com.ozs.common.enums.BusinessType;
|
|
|
+import com.ozs.common.utils.poi.ExcelUtil;
|
|
|
+import com.ozs.framework.web.service.SysPasswordService;
|
|
|
+import com.ozs.system.domain.SysLoginInfo;
|
|
|
+import com.ozs.system.service.ISysLoginInfoService;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 系统访问记录
|
|
|
+ *
|
|
|
+ * @author ruoyi
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/monitor/logininfor")
|
|
|
+public class SysLoginInfoController extends BaseController {
|
|
|
+ @Autowired
|
|
|
+ private ISysLoginInfoService logininforService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysPasswordService passwordService;
|
|
|
+
|
|
|
+// @PreAuthorize("@ss.hasPermi('monitor:logininfor:list')")
|
|
|
+// @GetMapping("/list")
|
|
|
+// public TableDataInfo list(SysLoginInfo logininfor) {
|
|
|
+// startPage();
|
|
|
+// List<SysLoginInfo> list = logininforService.selectLogininforList(logininfor);
|
|
|
+// return getDataTable(list);
|
|
|
+// }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取登录日志分页列表
|
|
|
+ *
|
|
|
+ * @param sysLoginInfoVo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "获取登录日志分页列表")
|
|
|
+ @PostMapping("/list")
|
|
|
+ @PreAuthorize("@ss.hasPermi('monitor:logininfor:list')")
|
|
|
+ public AjaxResult list(@RequestBody SysLoginInfoVo sysLoginInfoVo) {
|
|
|
+ LambdaQueryWrapper<SysLoginInfo> wrapper = new LambdaQueryWrapper<SysLoginInfo>();
|
|
|
+ if (!ObjectUtils.isEmpty(sysLoginInfoVo.getIpaddr())) {
|
|
|
+ wrapper.like(SysLoginInfo::getIpaddr, sysLoginInfoVo.getIpaddr());
|
|
|
+ }
|
|
|
+ if (!ObjectUtils.isEmpty(sysLoginInfoVo.getUserName())) {
|
|
|
+ wrapper.like(SysLoginInfo::getUserName, sysLoginInfoVo.getUserName());
|
|
|
+ }
|
|
|
+ if (!ObjectUtils.isEmpty(sysLoginInfoVo.getStatus())) {
|
|
|
+ wrapper.like(SysLoginInfo::getStatus, sysLoginInfoVo.getStatus());
|
|
|
+ }
|
|
|
+ if (!ObjectUtils.isEmpty(sysLoginInfoVo.getLoginTime())) {
|
|
|
+ wrapper.like(SysLoginInfo::getLoginTime, sysLoginInfoVo.getLoginTime());
|
|
|
+ }
|
|
|
+ if (!ObjectUtils.isEmpty(sysLoginInfoVo.getStartTime())) {
|
|
|
+ wrapper.ge(SysLoginInfo::getLoginTime, sysLoginInfoVo.getStartTime());
|
|
|
+ }
|
|
|
+ if (!ObjectUtils.isEmpty(sysLoginInfoVo.getEndTime())) {
|
|
|
+ wrapper.le(SysLoginInfo::getLoginTime, sysLoginInfoVo.getEndTime());
|
|
|
+ }
|
|
|
+ wrapper.orderByDesc(SysLoginInfo::getLoginTime);
|
|
|
+ IPage<SysLoginInfo> page = logininforService.page(new Page<>(sysLoginInfoVo.getPageNum(), sysLoginInfoVo.getPageSize()), wrapper);
|
|
|
+ return AjaxResult.success(page);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "获取登录日志详细")
|
|
|
+ @PreAuthorize("@ss.hasPermi('monitor:logininfor:detail')")
|
|
|
+ @PostMapping("/detail")
|
|
|
+ public AjaxResult remove(Long infoId) {
|
|
|
+ SysLoginInfo info = logininforService.selectLoginLogById(infoId);
|
|
|
+ return AjaxResult.success(info);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Log(title = "登录日志", businessType = BusinessType.EXPORT)
|
|
|
+ @PreAuthorize("@ss.hasPermi('monitor:logininfor:export')")
|
|
|
+ @PostMapping("/export")
|
|
|
+ public void export(HttpServletResponse response, SysLoginInfo logininfor) {
|
|
|
+ List<SysLoginInfo> list = logininforService.selectLogininforList(logininfor);
|
|
|
+ ExcelUtil<SysLoginInfo> util = new ExcelUtil<SysLoginInfo>(SysLoginInfo.class);
|
|
|
+ util.exportExcel(response, list, "登录日志");
|
|
|
+ }
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
|
|
+ @Log(title = "登录日志", businessType = BusinessType.DELETE)
|
|
|
+ @DeleteMapping("/{infoIds}")
|
|
|
+ public AjaxResult remove(@PathVariable Long[] infoIds)
|
|
|
+ {
|
|
|
+ return toAjax(logininforService.deleteLogininforByIds(infoIds));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
|
|
|
+ @Log(title = "登录日志", businessType = BusinessType.CLEAN)
|
|
|
+ @DeleteMapping("/clean")
|
|
|
+ public AjaxResult clean()
|
|
|
+ {
|
|
|
+ logininforService.cleanLogininfor();
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PreAuthorize("@ss.hasPermi('monitor:logininfor:unlock')")
|
|
|
+ @Log(title = "账户解锁", businessType = BusinessType.OTHER)
|
|
|
+ @GetMapping("/unlock/{userName}")
|
|
|
+ public AjaxResult unlock(@PathVariable("userName") String userName)
|
|
|
+ {
|
|
|
+ passwordService.clearLoginRecordCache(userName);
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+}
|