解决升级springboot3.2.x的bug

This commit is contained in:
D 2024-01-13 14:10:22 +08:00
parent 1d2a8c608d
commit 16fcd9d44b

View File

@ -11,6 +11,7 @@ import org.springframework.web.bind.annotation.DeleteMapping;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
@ -32,8 +33,7 @@ import com.ruoyi.system.service.ISysUserOnlineService;
*/
@RestController
@RequestMapping("/monitor/online")
public class SysUserOnlineController extends BaseController
{
public class SysUserOnlineController extends BaseController {
@Autowired
private ISysUserOnlineService userOnlineService;
@ -42,27 +42,19 @@ public class SysUserOnlineController extends BaseController
@PreAuthorize("@ss.hasPermi('monitor:online: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 + "*");
List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
for (String key : keys)
{
for (String key : keys) {
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));
}
else if (StringUtils.isNotEmpty(ipaddr))
{
} else if (StringUtils.isNotEmpty(ipaddr)) {
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));
}
else
{
} else {
userOnlineList.add(userOnlineService.loginUserToUserOnline(user));
}
}
@ -77,8 +69,7 @@ public class SysUserOnlineController extends BaseController
@PreAuthorize("@ss.hasPermi('monitor:online:forceLogout')")
@Log(title = "在线用户", businessType = BusinessType.FORCE)
@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);
return success();
}