systemLogDO.setTotalTime(String.valueOf(totalTime));
systemLogDO.setGmtCreateUser(userInfo.getUserName());
systemLogDO.setGmtModifiedUser(userInfo.getUserName());
systemLogDO.setIsDelete(0);
systemLogDAO.insert(systemLogDO);
return result;
}
}
5、IPUtil工具类
package com.gcloud.common;
import javax.servlet.http.HttpServletRequest;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.Enumeration;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
-
@Description: IP工具类
-
@Author: zhangzhixiang
-
@CreateDate: 2018/11/08 16:08:54
-
@Version: 1.0
*/
public class IPUtil {
/**
-
检查IP是否合法
-
@param ip
-
@return
*/
public static boolean ipValid(String ip) {
String regex0 = “(2[0-4]\d)” + “|(25[0-5])”;
String regex1 = “1\d{2}”;
String regex2 = “[1-9]\d”;
String regex3 = “\d”;
String regex = “(” + regex0 + “)|(” + regex1 + “)|(” + regex2 + “)|(” + regex3 + “)”;
regex = “(” + regex + “).(” + regex + “).(” + regex + “).(” + regex + “)”;
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(ip);