SessionController.java
1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package com.bootdo.system.controller;
import java.security.Principal;
import java.util.Collection;
import java.util.List;
import org.apache.shiro.session.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.bootdo.common.utils.R;
import com.bootdo.system.domain.UserOnline;
import com.bootdo.system.service.SessionService;
@RequestMapping("/sys/online")
@Controller
public class SessionController {
@Autowired
SessionService sessionService;
@GetMapping()
public String online() {
return "system/online/online";
}
@ResponseBody
@RequestMapping("/list")
public List<UserOnline> list() {
return sessionService.list();
}
@ResponseBody
@RequestMapping("/forceLogout/{sessionId}")
public R forceLogout(@PathVariable("sessionId") String sessionId, RedirectAttributes redirectAttributes) {
try {
sessionService.forceLogout(sessionId);
return R.ok();
} catch (Exception e) {
e.printStackTrace();
return R.error();
}
}
@ResponseBody
@RequestMapping("/sessionList")
public Collection<Session> sessionList() {
return sessionService.sessionList();
}
}