| | |
| | | import org.springframework.web.bind.annotation.PathVariable;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RestController;
|
| | | import com.ruoyi.common.constant.Constants;
|
| | | import com.ruoyi.common.constant.CacheConstants;
|
| | | import com.ruoyi.common.utils.StringUtils;
|
| | | import com.ruoyi.framework.aspectj.lang.annotation.Log;
|
| | | import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
|
| | |
| | | @GetMapping("/list")
|
| | | public TableDataInfo list(String ipaddr, String userName)
|
| | | {
|
| | | Collection<String> keys = redisCache.keys(Constants.LOGIN_TOKEN_KEY + "*");
|
| | | Collection<String> keys = redisCache.keys(CacheConstants.LOGIN_TOKEN_KEY + "*");
|
| | | List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
|
| | | for (String key : keys)
|
| | | {
|
| | | LoginUser user = redisCache.getCacheObject(key);
|
| | | if (StringUtils.isNotEmpty(ipaddr) && StringUtils.isNotEmpty(userName))
|
| | | {
|
| | | if (StringUtils.equals(ipaddr, user.getIpaddr()) && StringUtils.equals(userName, user.getUsername()))
|
| | | {
|
| | | userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user));
|
| | | }
|
| | | userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user));
|
| | | }
|
| | | else if (StringUtils.isNotEmpty(ipaddr))
|
| | | {
|
| | | if (StringUtils.equals(ipaddr, user.getIpaddr()))
|
| | | {
|
| | | userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user));
|
| | | }
|
| | | userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user));
|
| | | }
|
| | | else if (StringUtils.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser()))
|
| | | {
|
| | | if (StringUtils.equals(userName, user.getUsername()))
|
| | | {
|
| | | userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user));
|
| | | }
|
| | | userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user));
|
| | | }
|
| | | else
|
| | | {
|
| | |
| | | @DeleteMapping("/{tokenId}")
|
| | | public AjaxResult forceLogout(@PathVariable String tokenId)
|
| | | {
|
| | | redisCache.deleteObject(Constants.LOGIN_TOKEN_KEY + tokenId);
|
| | | return AjaxResult.success();
|
| | | redisCache.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId);
|
| | | return success();
|
| | | }
|
| | | }
|