解决升级springboot3.2.x的bug
This commit is contained in:
parent
1d2a8c608d
commit
16fcd9d44b
@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.DeleteMapping;
|
|||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
@ -32,8 +33,7 @@ import com.ruoyi.system.service.ISysUserOnlineService;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/monitor/online")
|
@RequestMapping("/monitor/online")
|
||||||
public class SysUserOnlineController extends BaseController
|
public class SysUserOnlineController extends BaseController {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysUserOnlineService userOnlineService;
|
private ISysUserOnlineService userOnlineService;
|
||||||
|
|
||||||
@ -42,27 +42,19 @@ public class SysUserOnlineController extends BaseController
|
|||||||
|
|
||||||
@PreAuthorize("@ss.hasPermi('monitor:online:list')")
|
@PreAuthorize("@ss.hasPermi('monitor:online:list')")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(String ipaddr, String userName)
|
public TableDataInfo list(@RequestParam(name = "ipaddr", required = false) String ipaddr,
|
||||||
{
|
@RequestParam(name = "userName", required = false) String userName) {
|
||||||
Collection<String> keys = redisCache.keys(CacheConstants.LOGIN_TOKEN_KEY + "*");
|
Collection<String> keys = redisCache.keys(CacheConstants.LOGIN_TOKEN_KEY + "*");
|
||||||
List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
|
List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
|
||||||
for (String key : keys)
|
for (String key : keys) {
|
||||||
{
|
|
||||||
LoginUser user = redisCache.getCacheObject(key);
|
LoginUser user = redisCache.getCacheObject(key);
|
||||||
if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName))
|
if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName)) {
|
||||||
{
|
|
||||||
userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user));
|
userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user));
|
||||||
}
|
} else if (StringUtils.isNotEmpty(ipaddr)) {
|
||||||
else if (StringUtils.isNotEmpty(ipaddr))
|
|
||||||
{
|
|
||||||
userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user));
|
userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user));
|
||||||
}
|
} else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser())) {
|
||||||
else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser()))
|
|
||||||
{
|
|
||||||
userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user));
|
userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
userOnlineList.add(userOnlineService.loginUserToUserOnline(user));
|
userOnlineList.add(userOnlineService.loginUserToUserOnline(user));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -77,8 +69,7 @@ public class SysUserOnlineController extends BaseController
|
|||||||
@PreAuthorize("@ss.hasPermi('monitor:online:forceLogout')")
|
@PreAuthorize("@ss.hasPermi('monitor:online:forceLogout')")
|
||||||
@Log(title = "在线用户", businessType = BusinessType.FORCE)
|
@Log(title = "在线用户", businessType = BusinessType.FORCE)
|
||||||
@DeleteMapping("/{tokenId}")
|
@DeleteMapping("/{tokenId}")
|
||||||
public AjaxResult forceLogout(@PathVariable( name = "tokenId" ) String tokenId)
|
public AjaxResult forceLogout(@PathVariable(name = "tokenId") String tokenId) {
|
||||||
{
|
|
||||||
redisCache.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId);
|
redisCache.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId);
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user