|
@@ -1,16 +1,42 @@
|
|
|
package com.ozs.web.filter;
|
|
|
|
|
|
import com.ozs.common.constant.Constants;
|
|
|
+import com.ozs.common.core.domain.entity.SysUser;
|
|
|
+import com.ozs.common.core.domain.model.LoginUser;
|
|
|
import com.ozs.common.utils.SecurityUtils;
|
|
|
+import com.ozs.common.utils.ServletUtils;
|
|
|
+import com.ozs.common.utils.ip.AddressUtils;
|
|
|
+import com.ozs.common.utils.ip.IpUtils;
|
|
|
+import eu.bitwalker.useragentutils.UserAgent;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
+import java.util.Set;
|
|
|
+
|
|
|
|
|
|
@Slf4j
|
|
|
public class LogOutUtil {
|
|
|
|
|
|
+ static {
|
|
|
+ LoginUser loginUser = new LoginUser();
|
|
|
+ SysUser user = new SysUser();
|
|
|
+ user.setUserId(-1L);
|
|
|
+ user.setUserName("purchase");
|
|
|
+ loginUser.setUser(user);
|
|
|
+ loginUser.setUserId(-1L);
|
|
|
+ loginUser.setToken(Constants.PRUCHASE_TOKEN);
|
|
|
+ UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getRequest().getHeader("User-Agent"));
|
|
|
+ String ip = IpUtils.getIpAddr(ServletUtils.getRequest());
|
|
|
+ loginUser.setIpaddr(ip);
|
|
|
+ loginUser.setLoginLocation(AddressUtils.getRealAddressByIP(ip));
|
|
|
+ loginUser.setBrowser(userAgent.getBrowser().getName());
|
|
|
+ loginUser.setOs(userAgent.getOperatingSystem().getName());
|
|
|
+ Constants.map.put(Constants.PRUCHASE_TOKEN, loginUser);
|
|
|
+ }
|
|
|
+
|
|
|
public static boolean getFlay() {
|
|
|
- if (!ObjectUtils.isEmpty(Constants.map.keySet())) {
|
|
|
+ Set<String> strings = Constants.map.keySet();
|
|
|
+ if (!ObjectUtils.isEmpty(strings)) {
|
|
|
Long userId = SecurityUtils.getUserId();
|
|
|
if (!ObjectUtils.isEmpty(userId)) {
|
|
|
if (userId.equals(Long.parseLong("-1"))) {
|