提交 | 用户 | 时间
|
722af2
|
1 |
package com.dl.web.controller.monitor; |
X |
2 |
|
|
3 |
import cn.dev33.satoken.annotation.SaCheckPermission; |
|
4 |
import com.dl.common.annotation.Log; |
|
5 |
import com.dl.common.constant.CacheConstants; |
|
6 |
import com.dl.common.core.controller.BaseController; |
|
7 |
import com.dl.common.core.domain.PageQuery; |
|
8 |
import com.dl.common.core.domain.R; |
|
9 |
import com.dl.common.core.page.TableDataInfo; |
|
10 |
import com.dl.common.enums.BusinessType; |
|
11 |
import com.dl.common.utils.poi.ExcelUtil; |
|
12 |
import com.dl.common.utils.redis.RedisUtils; |
|
13 |
import com.dl.system.domain.SysLogininfor; |
|
14 |
import com.dl.system.service.ISysLogininforService; |
|
15 |
import lombok.RequiredArgsConstructor; |
|
16 |
import org.springframework.validation.annotation.Validated; |
|
17 |
import org.springframework.web.bind.annotation.*; |
|
18 |
|
|
19 |
import javax.servlet.http.HttpServletResponse; |
|
20 |
import java.util.List; |
|
21 |
|
|
22 |
/** |
|
23 |
* 系统访问记录 |
|
24 |
* |
|
25 |
* @author Lion Li |
|
26 |
*/ |
|
27 |
@Validated |
|
28 |
@RequiredArgsConstructor |
|
29 |
@RestController |
|
30 |
@RequestMapping("/monitor/logininfor") |
|
31 |
public class SysLogininforController extends BaseController { |
|
32 |
|
|
33 |
private final ISysLogininforService logininforService; |
|
34 |
|
|
35 |
/** |
|
36 |
* 获取系统访问记录列表 |
|
37 |
*/ |
|
38 |
@SaCheckPermission("monitor:logininfor:list") |
|
39 |
@GetMapping("/list") |
|
40 |
public TableDataInfo<SysLogininfor> list(SysLogininfor logininfor, PageQuery pageQuery) { |
|
41 |
return logininforService.selectPageLogininforList(logininfor, pageQuery); |
|
42 |
} |
|
43 |
|
|
44 |
/** |
|
45 |
* 导出系统访问记录列表 |
|
46 |
*/ |
|
47 |
@Log(title = "登录日志", businessType = BusinessType.EXPORT) |
|
48 |
@SaCheckPermission("monitor:logininfor:export") |
|
49 |
@PostMapping("/export") |
|
50 |
public void export(SysLogininfor logininfor, HttpServletResponse response) { |
|
51 |
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor); |
|
52 |
ExcelUtil.exportExcel(list, "登录日志", SysLogininfor.class, response); |
|
53 |
} |
|
54 |
|
|
55 |
/** |
|
56 |
* 批量删除登录日志 |
|
57 |
* @param infoIds 日志ids |
|
58 |
*/ |
|
59 |
@SaCheckPermission("monitor:logininfor:remove") |
|
60 |
@Log(title = "登录日志", businessType = BusinessType.DELETE) |
|
61 |
@DeleteMapping("/{infoIds}") |
|
62 |
public R<Void> remove(@PathVariable String[] infoIds) { |
|
63 |
return toAjax(logininforService.deleteLogininforByIds(infoIds)); |
|
64 |
} |
|
65 |
|
|
66 |
/** |
|
67 |
* 清理系统访问记录 |
|
68 |
*/ |
|
69 |
@SaCheckPermission("monitor:logininfor:remove") |
|
70 |
@Log(title = "登录日志", businessType = BusinessType.CLEAN) |
|
71 |
@DeleteMapping("/clean") |
|
72 |
public R<Void> clean() { |
|
73 |
logininforService.cleanLogininfor(); |
|
74 |
return R.ok(); |
|
75 |
} |
|
76 |
|
|
77 |
@SaCheckPermission("monitor:logininfor:unlock") |
|
78 |
@Log(title = "账户解锁", businessType = BusinessType.OTHER) |
|
79 |
@GetMapping("/unlock/{userName}") |
|
80 |
public R<Void> unlock(@PathVariable("userName") String userName) { |
|
81 |
String loginName = CacheConstants.PWD_ERR_CNT_KEY + userName; |
|
82 |
if (RedisUtils.hasKey(loginName)) { |
|
83 |
RedisUtils.deleteObject(loginName); |
|
84 |
} |
|
85 |
return R.ok(); |
|
86 |
} |
|
87 |
|
|
88 |
} |