From 83a5abea31bf14c78572d3a4c5fdf14afb97c82f Mon Sep 17 00:00:00 2001
From: czt <czt18638530771@163.com>
Date: 星期六, 11 一月 2025 10:58:15 +0800
Subject: [PATCH] 增加登录日志和错误次数校验
---
src/main/java/com/fzzy/sys/LogLoginService.java | 219 ++++++++++
src/main/java/com/fzzy/api/lic/LicenseCheckModel.java | 77 +++
src/main/java/com/fzzy/sys/entity/LogLogin.java | 78 +++
src/main/java/com/fzzy/api/lic/LinuxServerInfos.java | 97 ++++
src/main/java/com/fzzy/sys/LogLoginPR.java | 78 +++
src/main/resources/application-pro.yml | 23
src/main/java/com/fzzy/api/lic/WindowsServerInfos.java | 89 ++++
src/main/java/com/fzzy/sys/repository/LogLoginRep.java | 9
src/main/java/com/fzzy/sys/LogLogin.view.xml | 169 ++++++++
src/main/resources/templates/home/home.html | 3
src/main/java/com/fzzy/push/sx2024/SX2024ApiRemoteService.java | 16
src/main/java/com/fzzy/push/gd2023/GD2023ApiRemoteService2023.java | 3
src/main/java/com/fzzy/api/utils/SystemUtil.java | 211 ++++++++++
src/main/java/com/fzzy/api/lic/AbstractServerInfos.java | 143 ++++++
src/main/java/com/fzzy/web/LoginController.java | 25 +
src/main/resources/application.yml | 2
16 files changed, 1,217 insertions(+), 25 deletions(-)
diff --git a/src/main/java/com/fzzy/api/lic/AbstractServerInfos.java b/src/main/java/com/fzzy/api/lic/AbstractServerInfos.java
new file mode 100644
index 0000000..18d26fa
--- /dev/null
+++ b/src/main/java/com/fzzy/api/lic/AbstractServerInfos.java
@@ -0,0 +1,143 @@
+package com.fzzy.api.lic;
+
+import lombok.extern.slf4j.Slf4j;
+
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+
+/**
+ * 鐢ㄤ簬鑾峰彇瀹㈡埛鏈嶅姟鍣ㄧ殑鍩烘湰淇℃伅锛屽锛欼P銆丮ac鍦板潃銆丆PU搴忓垪鍙枫�佷富鏉垮簭鍒楀彿绛�
+ *
+ * @author zifangsky
+ * @date 2018/4/23
+ * @since 1.0.0
+ */
+@Slf4j
+public abstract class AbstractServerInfos {
+
+ /**
+ * 缁勮闇�瑕侀澶栨牎楠岀殑License鍙傛暟
+ * @author zifangsky
+ * @date 2018/4/23 14:23
+ * @since 1.0.0
+ * @return demo.LicenseCheckModel
+ */
+ public LicenseCheckModel getServerInfos(){
+ LicenseCheckModel result = new LicenseCheckModel();
+
+ try {
+ result.setIpAddress(this.getIpAddress());
+ result.setMacAddress(this.getMacAddress());
+ result.setCpuSerial(this.getCPUSerial());
+ result.setMainBoardSerial(this.getMainBoardSerial());
+ }catch (Exception e){
+ log.error("鑾峰彇鏈嶅姟鍣ㄧ‖浠朵俊鎭け璐�",e);
+ }
+
+ return result;
+ }
+
+ /**
+ * 鑾峰彇IP鍦板潃
+ * @author zifangsky
+ * @date 2018/4/23 11:32
+ * @since 1.0.0
+ * @return java.util.List<java.lang.String>
+ */
+ protected abstract List<String> getIpAddress() throws Exception;
+
+ /**
+ * 鑾峰彇Mac鍦板潃
+ * @author zifangsky
+ * @date 2018/4/23 11:32
+ * @since 1.0.0
+ * @return java.util.List<java.lang.String>
+ */
+ protected abstract List<String> getMacAddress() throws Exception;
+
+ /**
+ * 鑾峰彇CPU搴忓垪鍙�
+ * @author zifangsky
+ * @date 2018/4/23 11:35
+ * @since 1.0.0
+ * @return java.lang.String
+ */
+ protected abstract String getCPUSerial() throws Exception;
+
+ /**
+ * 鑾峰彇涓绘澘搴忓垪鍙�
+ * @author zifangsky
+ * @date 2018/4/23 11:35
+ * @since 1.0.0
+ * @return java.lang.String
+ */
+ protected abstract String getMainBoardSerial() throws Exception;
+
+ /**
+ * 鑾峰彇褰撳墠鏈嶅姟鍣ㄦ墍鏈夌鍚堟潯浠剁殑InetAddress
+ * @author zifangsky
+ * @date 2018/4/23 17:38
+ * @since 1.0.0
+ * @return java.util.List<java.net.InetAddress>
+ */
+ protected List<InetAddress> getLocalAllInetAddress() throws Exception {
+ List<InetAddress> result = new ArrayList<>(4);
+
+ // 閬嶅巻鎵�鏈夌殑缃戠粶鎺ュ彛
+ for (Enumeration networkInterfaces = NetworkInterface.getNetworkInterfaces(); networkInterfaces.hasMoreElements(); ) {
+ NetworkInterface iface = (NetworkInterface) networkInterfaces.nextElement();
+ // 鍦ㄦ墍鏈夌殑鎺ュ彛涓嬪啀閬嶅巻IP
+ for (Enumeration inetAddresses = iface.getInetAddresses(); inetAddresses.hasMoreElements(); ) {
+ InetAddress inetAddr = (InetAddress) inetAddresses.nextElement();
+
+ //鎺掗櫎LoopbackAddress銆丼iteLocalAddress銆丩inkLocalAddress銆丮ulticastAddress绫诲瀷鐨処P鍦板潃
+ if(!inetAddr.isLoopbackAddress() /*&& !inetAddr.isSiteLocalAddress()*/
+ && !inetAddr.isLinkLocalAddress() && !inetAddr.isMulticastAddress()){
+ result.add(inetAddr);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * 鑾峰彇鏌愪釜缃戠粶鎺ュ彛鐨凪ac鍦板潃
+ * @author zifangsky
+ * @date 2018/4/23 18:08
+ * @since 1.0.0
+ * @param
+ * @return void
+ */
+ protected String getMacByInetAddress(InetAddress inetAddr){
+ try {
+ byte[] mac = NetworkInterface.getByInetAddress(inetAddr).getHardwareAddress();
+ StringBuffer stringBuffer = new StringBuffer();
+
+ for(int i=0;i<mac.length;i++){
+ if(i != 0) {
+ stringBuffer.append("-");
+ }
+
+ //灏嗗崄鍏繘鍒禸yte杞寲涓哄瓧绗︿覆
+ String temp = Integer.toHexString(mac[i] & 0xff);
+ if(temp.length() == 1){
+ stringBuffer.append("0" + temp);
+ }else{
+ stringBuffer.append(temp);
+ }
+ }
+
+ return stringBuffer.toString().toUpperCase();
+ } catch (SocketException e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+}
diff --git a/src/main/java/com/fzzy/api/lic/LicenseCheckModel.java b/src/main/java/com/fzzy/api/lic/LicenseCheckModel.java
new file mode 100644
index 0000000..62a4009
--- /dev/null
+++ b/src/main/java/com/fzzy/api/lic/LicenseCheckModel.java
@@ -0,0 +1,77 @@
+package com.fzzy.api.lic;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 鑷畾涔夐渶瑕佹牎楠岀殑License鍙傛暟
+ *
+ * @author zifangsky
+ * @date 2018/4/23
+ * @since 1.0.0
+ */
+public class LicenseCheckModel implements Serializable{
+
+ private static final long serialVersionUID = 8600137500316662317L;
+ /**
+ * 鍙鍏佽鐨処P鍦板潃
+ */
+ private List<String> ipAddress;
+
+ /**
+ * 鍙鍏佽鐨凪AC鍦板潃
+ */
+ private List<String> macAddress;
+
+ /**
+ * 鍙鍏佽鐨凜PU搴忓垪鍙�
+ */
+ private String cpuSerial;
+
+ /**
+ * 鍙鍏佽鐨勪富鏉垮簭鍒楀彿
+ */
+ private String mainBoardSerial;
+
+ public List<String> getIpAddress() {
+ return ipAddress;
+ }
+
+ public void setIpAddress(List<String> ipAddress) {
+ this.ipAddress = ipAddress;
+ }
+
+ public List<String> getMacAddress() {
+ return macAddress;
+ }
+
+ public void setMacAddress(List<String> macAddress) {
+ this.macAddress = macAddress;
+ }
+
+ public String getCpuSerial() {
+ return cpuSerial;
+ }
+
+ public void setCpuSerial(String cpuSerial) {
+ this.cpuSerial = cpuSerial;
+ }
+
+ public String getMainBoardSerial() {
+ return mainBoardSerial;
+ }
+
+ public void setMainBoardSerial(String mainBoardSerial) {
+ this.mainBoardSerial = mainBoardSerial;
+ }
+
+ @Override
+ public String toString() {
+ return "LicenseCheckModel{" +
+ "ipAddress=" + ipAddress +
+ ", macAddress=" + macAddress +
+ ", cpuSerial='" + cpuSerial + '\'' +
+ ", mainBoardSerial='" + mainBoardSerial + '\'' +
+ '}';
+ }
+}
diff --git a/src/main/java/com/fzzy/api/lic/LinuxServerInfos.java b/src/main/java/com/fzzy/api/lic/LinuxServerInfos.java
new file mode 100644
index 0000000..89b28c7
--- /dev/null
+++ b/src/main/java/com/fzzy/api/lic/LinuxServerInfos.java
@@ -0,0 +1,97 @@
+package com.fzzy.api.lic;
+
+import org.apache.commons.lang.StringUtils;
+
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+import java.net.InetAddress;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 鐢ㄤ簬鑾峰彇瀹㈡埛Linux鏈嶅姟鍣ㄧ殑鍩烘湰淇℃伅
+ *
+ * @author zifangsky
+ * @date 2018/4/23
+ * @since 1.0.0
+ */
+public class LinuxServerInfos extends AbstractServerInfos {
+
+ @Override
+ protected List<String> getIpAddress() throws Exception {
+ List<String> result = null;
+
+ //鑾峰彇鎵�鏈夌綉缁滄帴鍙�
+ List<InetAddress> inetAddresses = getLocalAllInetAddress();
+
+ if(inetAddresses != null && inetAddresses.size() > 0){
+ result = inetAddresses.stream().map(InetAddress::getHostAddress).distinct().map(String::toLowerCase).collect(Collectors.toList());
+ }
+
+ return result;
+ }
+
+ @Override
+ protected List<String> getMacAddress() throws Exception {
+ List<String> result = null;
+
+ //1. 鑾峰彇鎵�鏈夌綉缁滄帴鍙�
+ List<InetAddress> inetAddresses = getLocalAllInetAddress();
+
+ if(inetAddresses != null && inetAddresses.size() > 0){
+ //2. 鑾峰彇鎵�鏈夌綉缁滄帴鍙g殑Mac鍦板潃
+ result = inetAddresses.stream().map(this::getMacByInetAddress).distinct().collect(Collectors.toList());
+ }
+
+ return result;
+ }
+
+ @Override
+ protected String getCPUSerial() throws Exception {
+ //搴忓垪鍙�
+ String serialNumber = "";
+
+ //浣跨敤dmidecode鍛戒护鑾峰彇CPU搴忓垪鍙�
+ String[] shell = {"/bin/bash","-c","dmidecode -t processor | grep 'ID' | awk -F ':' '{print $2}' | head -n 1"};
+ Process process = Runtime.getRuntime().exec(shell);
+ process.getOutputStream().close();
+
+ BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
+
+ String readLine = reader.readLine();
+ if(StringUtils.isNotEmpty(readLine)){
+ String line = readLine.trim();
+ if(StringUtils.isNotBlank(line)){
+ serialNumber = line;
+ }
+ }
+
+ reader.close();
+
+ return serialNumber;
+ }
+
+ @Override
+ protected String getMainBoardSerial() throws Exception {
+ //搴忓垪鍙�
+ String serialNumber = "";
+
+ //浣跨敤dmidecode鍛戒护鑾峰彇涓绘澘搴忓垪鍙�
+ String[] shell = {"/bin/bash","-c","dmidecode | grep 'Serial Number' | awk -F ':' '{print $2}' | head -n 1"};
+ Process process = Runtime.getRuntime().exec(shell);
+ process.getOutputStream().close();
+
+ BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
+
+ String readLine = reader.readLine();
+ if(StringUtils.isNotEmpty(readLine)){
+ String line = readLine.trim();
+ if(StringUtils.isNotBlank(line)){
+ serialNumber = line;
+ }
+ }
+
+ reader.close();
+ return serialNumber;
+ }
+}
diff --git a/src/main/java/com/fzzy/api/lic/WindowsServerInfos.java b/src/main/java/com/fzzy/api/lic/WindowsServerInfos.java
new file mode 100644
index 0000000..14eb93d
--- /dev/null
+++ b/src/main/java/com/fzzy/api/lic/WindowsServerInfos.java
@@ -0,0 +1,89 @@
+package com.fzzy.api.lic;
+
+import java.net.InetAddress;
+import java.util.List;
+import java.util.Scanner;
+import java.util.stream.Collectors;
+
+/**
+ * 鐢ㄤ簬鑾峰彇瀹㈡埛Windows鏈嶅姟鍣ㄧ殑鍩烘湰淇℃伅
+ *
+ * @author zifangsky
+ * @date 2018/4/23
+ * @since 1.0.0
+ */
+public class WindowsServerInfos extends AbstractServerInfos {
+
+ @Override
+ protected List<String> getIpAddress() throws Exception {
+ List<String> result = null;
+
+ //鑾峰彇鎵�鏈夌綉缁滄帴鍙�
+ List<InetAddress> inetAddresses = getLocalAllInetAddress();
+
+ if(inetAddresses != null && inetAddresses.size() > 0){
+ result = inetAddresses.stream().map(InetAddress::getHostAddress).distinct().map(String::toLowerCase).collect(Collectors.toList());
+ }
+
+ return result;
+ }
+
+ @Override
+ protected List<String> getMacAddress() throws Exception {
+ List<String> result = null;
+
+ //1. 鑾峰彇鎵�鏈夌綉缁滄帴鍙�
+ List<InetAddress> inetAddresses = getLocalAllInetAddress();
+
+ if(inetAddresses != null && inetAddresses.size() > 0){
+ //2. 鑾峰彇鎵�鏈夌綉缁滄帴鍙g殑Mac鍦板潃
+ result = inetAddresses.stream().map(this::getMacByInetAddress).distinct().collect(Collectors.toList());
+ }
+
+ return result;
+ }
+
+ @Override
+ protected String getCPUSerial() throws Exception {
+ //搴忓垪鍙�
+ String serialNumber = "";
+
+ //浣跨敤WMIC鑾峰彇CPU搴忓垪鍙�
+ Process process = Runtime.getRuntime().exec("wmic cpu get processorid");
+ process.getOutputStream().close();
+ Scanner scanner = new Scanner(process.getInputStream());
+
+ if(scanner != null && scanner.hasNext()){
+ scanner.next();
+ }
+
+ if(scanner.hasNext()){
+ serialNumber = scanner.next().trim();
+ }
+
+ scanner.close();
+ return serialNumber;
+ }
+
+ @Override
+ protected String getMainBoardSerial() throws Exception {
+ //搴忓垪鍙�
+ String serialNumber = "";
+
+ //浣跨敤WMIC鑾峰彇涓绘澘搴忓垪鍙�
+ Process process = Runtime.getRuntime().exec("wmic baseboard get serialnumber");
+ process.getOutputStream().close();
+ Scanner scanner = new Scanner(process.getInputStream());
+
+ if(scanner != null && scanner.hasNext()){
+ scanner.next();
+ }
+
+ if(scanner.hasNext()){
+ serialNumber = scanner.next().trim();
+ }
+
+ scanner.close();
+ return serialNumber;
+ }
+}
diff --git a/src/main/java/com/fzzy/api/utils/SystemUtil.java b/src/main/java/com/fzzy/api/utils/SystemUtil.java
new file mode 100644
index 0000000..ba11605
--- /dev/null
+++ b/src/main/java/com/fzzy/api/utils/SystemUtil.java
@@ -0,0 +1,211 @@
+package com.fzzy.api.utils;
+
+import com.alibaba.fastjson.JSON;
+import com.fzzy.api.lic.AbstractServerInfos;
+import com.fzzy.api.lic.LicenseCheckModel;
+import com.fzzy.api.lic.LinuxServerInfos;
+import com.fzzy.api.lic.WindowsServerInfos;
+import javax.servlet.http.HttpServletRequest;
+import java.net.InetAddress;
+import java.net.NetworkInterface;
+import java.net.UnknownHostException;
+import java.util.*;
+
+/**
+ * @Desc: 鑾峰彇瀹㈡埛鐧婚檰淇℃伅
+ * @author: andy.jia
+ * @update-time: 2022/11/10 19:55
+ */
+public class SystemUtil {
+
+ /***
+ * 鑾峰彇瀹㈡埛绔疘P鍦板潃
+ * @param request
+ */
+ public static String getIP(HttpServletRequest request) {
+ if (request == null) {
+ return "127.0.0.1";
+ }
+ String ip = request.getHeader("X-Real-IP");
+ if (ip != null && !"".equals(ip) && !"unknown".equalsIgnoreCase(ip)) {
+ return ip;
+ }
+ ip = request.getHeader("X-Forwarded-For");
+ if (ip != null && !"".equals(ip) && !"unknown".equalsIgnoreCase(ip)) {
+ // 澶氭鍙嶅悜浠g悊鍚庝細鏈夊涓狪P鍊硷紝绗竴涓负鐪熷疄IP銆�
+ int index = ip.indexOf(',');
+ if (index != -1) {
+ return ip.substring(0, index);
+ } else {
+ return ip;
+ }
+ } else {
+ return request.getRemoteAddr();
+ }
+ }
+
+
+ /**
+ * 鑾峰彇鏉ヨ鑰呯殑娴忚鍣ㄧ増鏈�
+ *
+ * @param request
+ * @return
+ */
+ public static String getBrowserInfo(HttpServletRequest request) {
+ String browserVersion = null;
+ String header = request.getHeader("user-agent");
+ if (header == null || header.equals("")) {
+ return "";
+ }
+ if (header.indexOf("MSIE 6.0") > 0) {
+ browserVersion = "IE 6";
+ } else if (header.indexOf("MSIE 7.0") > 0) {
+ browserVersion = "IE 7";
+ } else if (header.indexOf("MSIE 8.0") > 0) {
+ browserVersion = "IE 8";
+ } else if (header.indexOf("MSIE 9.0") > 0) {
+ browserVersion = "IE 9";
+ } else if (header.indexOf("MSIE 10.0") > 0) {
+ browserVersion = "IE 10";
+ } else if (header.indexOf("rv:11.0") > 0) {
+ browserVersion = "IE 11";
+ } else if (header.indexOf("Firefox") > 0) {
+ browserVersion = "Firefox";
+ } else if (header.indexOf("Chrome") > 0) {
+ browserVersion = "Chrome";
+ } else if (header.indexOf("Safari") > 0) {
+ browserVersion = "Safari";
+ } else if (header.indexOf("Camino") > 0) {
+ browserVersion = "Camino";
+ } else if (header.indexOf("Konqueror") > 0) {
+ browserVersion = "Konqueror";
+ }
+ return browserVersion;
+ }
+
+
+ /**
+ * 鑾峰彇绯荤粺鐗堟湰淇℃伅
+ *
+ * @param request
+ * @return
+ */
+ public static String getSystemInfo(HttpServletRequest request) {
+ String systenInfo = null;
+ String header = request.getHeader("user-agent");
+ if (header == null || header.equals("")) {
+ return "";
+ }
+ // 寰楀埌鐢ㄦ埛鐨勬搷浣滅郴缁�
+ if (header.indexOf("NT 6.0") > 0) {
+ systenInfo = "Windows Vista/Server 2008";
+ } else if (header.indexOf("NT 5.2") > 0) {
+ systenInfo = "Windows Server 2003";
+ } else if (header.indexOf("NT 5.1") > 0) {
+ systenInfo = "Windows XP";
+ } else if (header.indexOf("NT 6.0") > 0) {
+ systenInfo = "Windows Vista";
+ } else if (header.indexOf("NT 6.1") > 0) {
+ systenInfo = "Windows 7";
+ } else if (header.indexOf("NT 6.2") > 0) {
+ systenInfo = "Windows Slate";
+ } else if (header.indexOf("NT 6.3") > 0) {
+ systenInfo = "Windows 9";
+ } else if (header.indexOf("NT 10.0") > 0) {
+ systenInfo = "Windows 10";
+ } else if (header.indexOf("NT 5") > 0) {
+ systenInfo = "Windows 2000";
+ } else if (header.indexOf("NT 4") > 0) {
+ systenInfo = "Windows NT4";
+ } else if (header.indexOf("Me") > 0) {
+ systenInfo = "Windows Me";
+ } else if (header.indexOf("Mac") > 0) {
+ systenInfo = "Mac";
+ } else if (header.indexOf("Unix") > 0) {
+ systenInfo = "UNIX";
+ } else if (header.indexOf("Linux") > 0) {
+ systenInfo = "Linux";
+ } else if (header.indexOf("SunOS") > 0) {
+ systenInfo = "SunOS";
+ }
+ return systenInfo;
+ }
+
+
+ /**
+ * 鑾峰彇鏉ヨ鑰呯殑涓绘満鍚嶇О
+ *
+ * @param ip
+ * @return
+ */
+ public static String getHostName(String ip) {
+ InetAddress inet;
+ try {
+ inet = InetAddress.getByName(ip);
+ return inet.getHostName();
+ } catch (UnknownHostException e) {
+ e.printStackTrace();
+ }
+ return "鏈煡";
+ }
+
+
+ public static String getSystemInfo() throws Exception {
+ String os = System.getProperty("os.name").toLowerCase();
+ Map<String ,Object> param =null;
+ AbstractServerInfos abstractServerInfos = null;
+
+ if (os.indexOf("win") >= 0) {
+ param = new HashMap<>();
+ abstractServerInfos = new WindowsServerInfos(); // Windows绯荤粺
+ LicenseCheckModel data = abstractServerInfos.getServerInfos();
+ //param.put("macAddress",data.getMacAddress());
+ param.put("cpuSerial",data.getCpuSerial());
+ param.put("mainBoardSerial",data.getMainBoardSerial());
+ } else if (os.indexOf("mac") >= 0) {
+ // Mac绯荤粺
+ } else if (os.indexOf("nix") >= 0 || os.indexOf("nux") >= 0 || os.indexOf("aix") >= 0) {
+ // Unix/Linux绯荤粺
+ param = new HashMap<>();
+ abstractServerInfos = new LinuxServerInfos();
+ LicenseCheckModel data = abstractServerInfos.getServerInfos();
+ //param.put("macAddress",data.getMacAddress()) ;
+ param.put("cpuSerial",data.getCpuSerial()) ;
+ param.put("mainBoardSerial",data.getMainBoardSerial());
+ } else if (os.indexOf("sunos") >= 0) {
+ // Solaris绯荤粺
+ } else {
+ // 鏈煡鐨勬搷浣滅郴缁�
+ }
+ if(null == param){
+ return "";
+ }else {
+ return JSON.toJSONString(param);
+ }
+
+ }
+
+ /**
+ * 鑾峰彇褰撳墠鏈嶅姟鍣ㄦ墍鏈夌鍚堟潯浠剁殑InetAddress
+ */
+ protected static List<InetAddress> getLocalAllInetAddress() throws Exception {
+ List<InetAddress> result = new ArrayList<>(4);
+
+ // 閬嶅巻鎵�鏈夌殑缃戠粶鎺ュ彛
+ for (Enumeration networkInterfaces = NetworkInterface.getNetworkInterfaces(); networkInterfaces.hasMoreElements(); ) {
+ NetworkInterface iface = (NetworkInterface) networkInterfaces.nextElement();
+ // 鍦ㄦ墍鏈夌殑鎺ュ彛涓嬪啀閬嶅巻IP
+ for (Enumeration inetAddresses = iface.getInetAddresses(); inetAddresses.hasMoreElements(); ) {
+ InetAddress inetAddr = (InetAddress) inetAddresses.nextElement();
+
+ //鎺掗櫎LoopbackAddress銆丼iteLocalAddress銆丩inkLocalAddress銆丮ulticastAddress绫诲瀷鐨処P鍦板潃
+ if(!inetAddr.isLoopbackAddress() /*&& !inetAddr.isSiteLocalAddress()*/
+ && !inetAddr.isLinkLocalAddress() && !inetAddr.isMulticastAddress()){
+ result.add(inetAddr);
+ }
+ }
+ }
+
+ return result;
+ }
+}
diff --git a/src/main/java/com/fzzy/push/gd2023/GD2023ApiRemoteService2023.java b/src/main/java/com/fzzy/push/gd2023/GD2023ApiRemoteService2023.java
index d9d12df..5775db7 100644
--- a/src/main/java/com/fzzy/push/gd2023/GD2023ApiRemoteService2023.java
+++ b/src/main/java/com/fzzy/push/gd2023/GD2023ApiRemoteService2023.java
@@ -315,8 +315,7 @@
BeanUtils.copyProperties(data, api1102);
//鏍¢獙缁熶竴缂栫爜鏄惁涓虹┖锛屼负绌哄垯鏌ヨ搴撳尯淇℃伅杩涜璧嬪��
if (StringUtils.isEmpty(api1102.getTydwbm())) {
- String tydwbm = apiCommonService.getTydwbm(api1102.getDwdm());
- api1102.setTydwbm(tydwbm);
+ api1102.setTydwbm(api1102.getTykqbm().substring(0, 20));
}
api1102.setZhgxsj(DateUtils.addSeconds(new Date(), -10));
return JSON.toJSONString(api1102);
diff --git a/src/main/java/com/fzzy/push/sx2024/SX2024ApiRemoteService.java b/src/main/java/com/fzzy/push/sx2024/SX2024ApiRemoteService.java
index 629b77c..ed126b8 100644
--- a/src/main/java/com/fzzy/push/sx2024/SX2024ApiRemoteService.java
+++ b/src/main/java/com/fzzy/push/sx2024/SX2024ApiRemoteService.java
@@ -100,14 +100,14 @@
//鑾峰彇鎸囦护id
String key = RedisConst.buildKey(RedisConst.KYE_ORDER, conf.getKqdm());
String orderId = (String) redisUtil.get(key);
- if (StringUtils.isEmpty(orderId)) {
- log.error("鎸囦护id澶辨晥");
- ResponseDto responseDto = new ResponseDto(99, "鎸囦护id澶辨晥");
- apiLog.setStatus(99);
- apiLog.setResult("鎸囦护id澶辨晥");
- apiLogRep.save(apiLog);
- return responseDto;
- }
+// if (StringUtils.isEmpty(orderId)) {
+// log.error("鎸囦护id澶辨晥");
+// ResponseDto responseDto = new ResponseDto(99, "鎸囦护id澶辨晥");
+// apiLog.setStatus(99);
+// apiLog.setResult("鎸囦护id澶辨晥");
+// apiLogRep.save(apiLog);
+// return responseDto;
+// }
//灏佽鎺ㄩ�佹暟鎹�
SX2024ReqDto reqData = new SX2024ReqDto();
diff --git a/src/main/java/com/fzzy/sys/LogLogin.view.xml b/src/main/java/com/fzzy/sys/LogLogin.view.xml
new file mode 100644
index 0000000..06c7a43
--- /dev/null
+++ b/src/main/java/com/fzzy/sys/LogLogin.view.xml
@@ -0,0 +1,169 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ViewConfig>
+ <Arguments/>
+ <Context/>
+ <Model>
+ <DataType name="dtMain">
+ <Property name="creationType">com.fzzy.sys.entity.LogLogin</Property>
+ <PropertyDef name="id">
+ <Property></Property>
+ <Property name="label">ID</Property>
+ </PropertyDef>
+ <PropertyDef name="companyId">
+ <Property></Property>
+ <Property name="label">缁勭粐缂栫爜</Property>
+ </PropertyDef>
+ <PropertyDef name="loginId">
+ <Property></Property>
+ <Property name="label">鐧婚檰ID</Property>
+ </PropertyDef>
+ <PropertyDef name="loginName">
+ <Property></Property>
+ <Property name="label">鐧婚檰鐢ㄦ埛</Property>
+ </PropertyDef>
+ <PropertyDef name="loginTime">
+ <Property name="dataType">DateTime</Property>
+ <Property name="label">鐧婚檰鏃堕棿</Property>
+ </PropertyDef>
+ <PropertyDef name="errorNum">
+ <Property name="dataType">Integer</Property>
+ <Property name="label">閿欒娆℃暟</Property>
+ <Property name="displayFormat">#0 娆�</Property>
+ </PropertyDef>
+ <PropertyDef name="ip">
+ <Property name="label">鐧婚檰鑰匢P</Property>
+ </PropertyDef>
+ <PropertyDef name="browser">
+ <Property name="label">娴忚鍣�</Property>
+ </PropertyDef>
+ <PropertyDef name="sysName">
+ <Property name="label">鎿嶄綔绯荤粺</Property>
+ </PropertyDef>
+ <PropertyDef name="hostName">
+ <Property name="label">鐧婚檰涓绘満</Property>
+ </PropertyDef>
+ <PropertyDef name="netInfo">
+ <Property name="label">缃戠粶鐘跺喌</Property>
+ </PropertyDef>
+ <PropertyDef name="lastLoginTime">
+ <Property name="dataType">Date</Property>
+ <Property name="label">涓婃鐧婚檰鏃堕棿</Property>
+ </PropertyDef>
+ <PropertyDef name="loginInfo">
+ <Property name="label">鐧婚檰璇存槑</Property>
+ </PropertyDef>
+ </DataType>
+ <DataType name="dtParam">
+ <PropertyDef name="start">
+ <Property name="dataType">Date</Property>
+ <Property name="label">寮�濮嬫棩鏈�</Property>
+ </PropertyDef>
+ <PropertyDef name="end">
+ <Property name="dataType">Date</Property>
+ <Property name="label">鎴鏃ユ湡</Property>
+ </PropertyDef>
+ </DataType>
+ </Model>
+ <View layout="regionPadding:10">
+ <ClientEvent name="onReady">view.get("#dsParam").insert({});</ClientEvent>
+ <Property name="packages">font-awesome,css-common</Property>
+ <DataSet id="dsMain">
+ <Property name="dataProvider">logLoginPR#pageLogLogin</Property>
+ <Property name="dataType">[dtMain]</Property>
+ <Property name="pageSize">15</Property>
+ </DataSet>
+ <DataSet id="dsParam">
+ <Property name="dataType">dtParam</Property>
+ </DataSet>
+ <Container layout="regionPadding:10" layoutConstraint="center">
+ <Property name="exClassName">bg-color</Property>
+ <AutoForm>
+ <Property name="dataSet">dsParam</Property>
+ <Property name="cols">*,*,*,*</Property>
+ <AutoFormElement>
+ <Property name="name">start</Property>
+ <Property name="property">start</Property>
+ <Editor/>
+ </AutoFormElement>
+ <AutoFormElement>
+ <Property name="name">end</Property>
+ <Property name="property">end</Property>
+ <Editor/>
+ </AutoFormElement>
+ <Container layout="regionPadding:10">
+ <Button layoutConstraint="left">
+ <ClientEvent name="onClick">var param = view.get("#dsParam.data");
+view.get("#dsMain").set("parameter",param).flushAsync();</ClientEvent>
+ <Property name="caption">鏌ヨ</Property>
+ <Property name="exClassName">btn-normal</Property>
+ <Property name="iconClass">fa fa-search</Property>
+ </Button>
+ <Button layoutConstraint="left">
+ <ClientEvent name="onClick">view.get("#dsParam").flushAsync();</ClientEvent>
+ <Property name="caption">閲嶇疆</Property>
+ <Property name="iconClass">fa fa-refresh</Property>
+ <Property name="exClassName">btn-default</Property>
+ </Button>
+ </Container>
+ </AutoForm>
+ <DataGrid id="dgMain">
+ <ClientEvent name="onDataRowDoubleClick">var dialog= view.get("#dialogMain");
+dialog.show();</ClientEvent>
+ <Property name="dataSet">dsMain</Property>
+ <Property name="readOnly">true</Property>
+ <RowNumColumn/>
+ <DataColumn name="loginName">
+ <Property name="property">loginName</Property>
+ <Property name="align">center</Property>
+ </DataColumn>
+ <DataColumn name="loginId">
+ <Property name="property">loginId</Property>
+ <Property name="align">center</Property>
+ </DataColumn>
+ <DataColumn name="loginTime">
+ <Property name="property">loginTime</Property>
+ <Property name="align">center</Property>
+ </DataColumn>
+ <DataColumn name="errorNum">
+ <Property name="property">errorNum</Property>
+ <Property name="align">center</Property>
+ </DataColumn>
+ <DataColumn name="ip">
+ <Property name="property">ip</Property>
+ <Property name="align">center</Property>
+ </DataColumn>
+ <DataColumn name="browser">
+ <Property name="property">browser</Property>
+ <Property name="align">center</Property>
+ </DataColumn>
+ <DataColumn name="sysName">
+ <Property name="property">sysName</Property>
+ <Property name="align">center</Property>
+ </DataColumn>
+ <DataColumn name="hostName">
+ <Property name="property">hostName</Property>
+ <Property name="align">center</Property>
+ </DataColumn>
+ <DataColumn name="netInfo">
+ <Property name="property">netInfo</Property>
+ <Property name="align">center</Property>
+ </DataColumn>
+ <DataColumn name="loginInfo">
+ <Property name="property">loginInfo</Property>
+ <Property name="align">center</Property>
+ </DataColumn>
+ <DataColumn name="lastLoginTime">
+ <Property name="property">lastLoginTime</Property>
+ <Property name="align">center</Property>
+ </DataColumn>
+ </DataGrid>
+ </Container>
+ <Container layoutConstraint="bottom">
+ <Property name="exClassName">bg-color</Property>
+ <DataPilot layoutConstraint="right">
+ <Property name="dataSet">dsMain</Property>
+ <Property name="itemCodes">pageSize,pages</Property>
+ </DataPilot>
+ </Container>
+ </View>
+</ViewConfig>
diff --git a/src/main/java/com/fzzy/sys/LogLoginPR.java b/src/main/java/com/fzzy/sys/LogLoginPR.java
new file mode 100644
index 0000000..f44a61e
--- /dev/null
+++ b/src/main/java/com/fzzy/sys/LogLoginPR.java
@@ -0,0 +1,78 @@
+package com.fzzy.sys;
+
+import com.bstek.dorado.annotation.DataProvider;
+import com.fzzy.sys.entity.LogLogin;
+import com.fzzy.api.utils.ContextUtil;
+import com.fzzy.sys.repository.LogLoginRep;
+import org.springframework.beans.factory.annotation.Autowired;
+import com.bstek.dorado.data.provider.Page;
+import org.springframework.data.domain.PageRequest;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.jpa.domain.Specification;
+import org.springframework.stereotype.Component;
+import javax.persistence.criteria.CriteriaBuilder;
+import javax.persistence.criteria.CriteriaQuery;
+import javax.persistence.criteria.Predicate;
+import javax.persistence.criteria.Root;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description 鐧诲綍鏃ュ織
+ * @Author CZT
+ * @Date 2024/5/30 15:53
+ */
+@Component
+public class LogLoginPR {
+
+ @Autowired
+ private LogLoginRep logLoginRep;
+
+ /**
+ * logLoginPR#pageLogLogin
+ *
+ * @param page
+ * @param param
+ * @throws Exception
+ */
+ @DataProvider
+ public void pageLogLogin(Page<LogLogin> page, Map<String, Object> param) {
+ //澶氬弬鏁板垎椤垫煡璇�
+ Pageable pageable = PageRequest.of(page.getPageNo() - 1, page.getPageSize(), Sort.Direction.DESC, LogLogin.SORT_PROP);
+
+ if (null == param) {
+ org.springframework.data.domain.Page<LogLogin> japPage = logLoginRep.findAll(pageable);
+ page.setEntityCount((int) japPage.getTotalElements());
+ page.setEntities(japPage.getContent());
+
+ return;
+ }
+
+ Specification<LogLogin> specification = new Specification<LogLogin>() {
+ private static final long serialVersionUID = 1L;
+
+ public Predicate toPredicate(Root<LogLogin> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
+ List<Predicate> predicates = new ArrayList<>(); //鎵�鏈夌殑鏂█
+
+ Date date = (Date) param.get("start");
+ if (null != date) {
+ Predicate predicate3 = cb.greaterThan(root.get("loginTime"), ContextUtil.getCurZero(date));
+ predicates.add(predicate3);
+ }
+ date = (Date) param.get("end");
+ if (null != date) {
+ Predicate predicate4 = cb.lessThan(root.get("loginTime"), ContextUtil.getNextZero(date));
+ predicates.add(predicate4);
+ }
+ return cb.and(predicates.toArray(new Predicate[0]));
+ }
+ };
+
+ org.springframework.data.domain.Page<LogLogin> japPage = logLoginRep.findAll(specification, pageable);
+ page.setEntityCount((int) japPage.getTotalElements());
+ page.setEntities(japPage.getContent());
+ }
+}
diff --git a/src/main/java/com/fzzy/sys/LogLoginService.java b/src/main/java/com/fzzy/sys/LogLoginService.java
new file mode 100644
index 0000000..73523a0
--- /dev/null
+++ b/src/main/java/com/fzzy/sys/LogLoginService.java
@@ -0,0 +1,219 @@
+package com.fzzy.sys;
+
+import com.fzzy.api.utils.ContextUtil;
+import com.fzzy.sys.entity.LogLogin;
+import com.fzzy.api.utils.RedisConst;
+import com.fzzy.api.utils.RedisUtil;
+import com.fzzy.api.utils.SystemUtil;
+import com.fzzy.sys.repository.LogLoginRep;
+import com.fzzy.sys.entity.SysUser;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import javax.servlet.http.HttpServletRequest;
+import java.util.Date;
+
+/**
+ * @Desc: 鐧婚檰鏃ュ織璁板綍淇℃伅
+ * @author: andy.jia
+ * @update-time: 2023/4/28 8:32
+ */
+@Component
+public class LogLoginService{
+
+ private String KEY_LOGON_LOG = "LOGIN_LOG";
+ private int TIME_ERROR_MIN = 60;
+
+ @Autowired
+ private RedisUtil redisUtil;
+ @Autowired
+ private LogLoginRep logLoginRep;
+
+ /**
+ * 鍒ゆ柇褰撳墠鐧婚檰鏄惁琚檺鍒�
+ *
+ * @param request
+ * @param username
+ * @return
+ */
+ public int checkLoginLimit(HttpServletRequest request, String username) {
+
+ //鑾峰彇閿欒璁板綍缂撳瓨
+ LogLogin errorLog = this.getFromCacheError(username, SystemUtil.getIP(request));
+
+ if (null == errorLog) return 0;
+
+ return errorLog.getErrorNum();
+ }
+
+
+ /**
+ * 瀵嗙爜杈撳叆閿欒璁板綍锛岃繑鍥炶緭鍏ラ敊璇鏁�
+ *
+ * @param request
+ * @param user
+ * @return
+ */
+ public int addPwdError(HttpServletRequest request, SysUser user) {
+ LogLogin log = new LogLogin();
+ log.setCompanyId(user.getCompanyId());
+ log.setLoginId(user.getUsername());
+ log.setLoginName(user.getName());
+ log.setLoginTime(new Date());
+ log.setIp(SystemUtil.getIP(request));
+ log.setBrowser(SystemUtil.getBrowserInfo(request));
+ log.setSysName(SystemUtil.getSystemInfo(request));
+ log.setHostName(SystemUtil.getHostName(log.getIp()));
+ log.setLastLoginTime(new Date());
+ log.setErrorNum(1);
+ log.setLoginInfo("澶辫触锛氬瘑鐮侀敊璇�");
+
+ // 鑾峰彇涓婃閿欒璁板綍
+ LogLogin errorLog = this.getFromCacheError(user.getUsername(), log.getIp());
+ if (null != errorLog) {
+ log.setErrorNum(errorLog.getErrorNum() + 1);
+ }
+
+ //淇濆瓨鏃ュ織
+ addLog(log);
+
+ //淇濆瓨鍒扮紦瀛�
+ addToCacheError(log);
+
+ return log.getErrorNum();
+ }
+
+
+ /**
+ * 鐧婚檰鐢ㄦ埛涓嶅瓨鍦ㄩ敊璇紝杩斿洖杈撳叆涓嶅瓨鍦ㄨ处鍙锋鏁帮紝鐢ㄦ埛涓嶅瓨鍦ㄧ殑璐﹀彿锛屼娇鐢↖P浣滀负鍒ゆ柇鏍囧噯锛岄伩鍏嶆伓鎰忓皾璇�
+ *
+ * @param request
+ * @param username
+ * @return
+ */
+ public int addNoUser(HttpServletRequest request, String username) {
+
+ LogLogin log = new LogLogin();
+ log.setLoginName(username);
+ log.setLoginTime(new Date());
+ log.setIp(SystemUtil.getIP(request));
+ log.setBrowser(SystemUtil.getBrowserInfo(request));
+ log.setSysName(SystemUtil.getSystemInfo(request));
+ log.setHostName(SystemUtil.getHostName(log.getIp()));
+ log.setLastLoginTime(new Date());
+ log.setErrorNum(1);
+ log.setLoginId(log.getIp());
+ log.setLoginInfo("澶辫触锛氭棤鏁堣处鍙�");
+
+ // 鑾峰彇涓婃閿欒璁板綍
+ LogLogin errorLog = this.getFromCacheError(log.getIp(), log.getIp());
+ if (null != errorLog) {
+ log.setErrorNum(errorLog.getErrorNum() + 1);
+ }
+
+ //淇濆瓨鍒扮紦瀛�
+ addToCache(log);
+
+
+ //淇濆瓨鏃ュ織
+ log.setLoginId(username);
+ addLog(log);
+
+ return log.getErrorNum();
+ }
+
+ /**
+ * 澧炲姞鐧婚檰鏃ュ織淇℃伅
+ *
+ * @param request
+ * @param user
+ */
+ public void addLoginInfo(HttpServletRequest request, SysUser user) {
+ LogLogin log = new LogLogin();
+ log.setCompanyId(user.getCompanyId());
+ log.setLoginId(user.getUsername());
+ log.setLoginName(user.getName());
+ log.setLoginTime(new Date());
+ log.setIp(SystemUtil.getIP(request));
+ log.setBrowser(SystemUtil.getBrowserInfo(request));
+ log.setSysName(SystemUtil.getSystemInfo(request));
+ log.setHostName(SystemUtil.getHostName(log.getIp()));
+ log.setErrorNum(0);
+ log.setLoginInfo("鎴愬姛锛氭甯哥櫥闄�");
+
+ // 鑾峰彇涓婃鐧婚檰淇℃伅
+ LogLogin lastLog = this.getFromCache(log.getLoginId());
+ if (null != lastLog) {
+ log.setLastLoginTime(lastLog.getLoginTime());
+ }
+
+ //淇濆瓨缂撳瓨
+ addToCache(log);
+
+ //淇濆瓨鏃ュ織
+ addLog(log);
+ }
+
+ /**
+ * @param log
+ */
+ private void addToCache(LogLogin log) {
+
+ String key = RedisConst.buildKey(KEY_LOGON_LOG, log.getLoginId());
+
+ redisUtil.set(key, log);
+
+
+ this.removeCacheError(log.getLoginId(), log.getIp());
+
+ }
+
+
+ private LogLogin getFromCache(String loginId) {
+ if (null == loginId) return null;
+ try {
+ String key = RedisConst.buildKey(KEY_LOGON_LOG, loginId);
+ return (LogLogin) redisUtil.get(key);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ private void removeCacheError(String loginId, String ip) {
+ String key = RedisConst.buildKey(KEY_LOGON_LOG, loginId, ip);
+
+ redisUtil.del(key);
+ }
+
+ private void addToCacheError(LogLogin log) {
+ String key = RedisConst.buildKey(KEY_LOGON_LOG, log.getLoginId(), log.getIp());
+ redisUtil.set(key, log, (TIME_ERROR_MIN + 1) * 60);
+ }
+
+ private LogLogin getFromCacheError(String loginId, String ip) {
+ if (null == loginId) return null;
+ if (null == ip) return null;
+ try {
+ String key = RedisConst.buildKey(KEY_LOGON_LOG, loginId, ip);
+ return (LogLogin) redisUtil.get(key);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+
+ /**
+ * @Desc: 淇濆瓨鏃ュ織
+ * @author: Andy
+ * @update-time: 2023/4/28
+ */
+ public void addLog(LogLogin log) {
+
+ if (null == log) return;
+
+ if (null == log.getId()) {
+ log.setId(ContextUtil.getUUID());
+ }
+ logLoginRep.save(log);
+ }
+
+}
diff --git a/src/main/java/com/fzzy/sys/entity/LogLogin.java b/src/main/java/com/fzzy/sys/entity/LogLogin.java
new file mode 100644
index 0000000..bb482d6
--- /dev/null
+++ b/src/main/java/com/fzzy/sys/entity/LogLogin.java
@@ -0,0 +1,78 @@
+package com.fzzy.sys.entity;
+
+import com.bstek.dorado.annotation.PropertyDef;
+import lombok.Data;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @Desc: 绯荤粺鐧婚檰鏃ュ織
+ * @author: Andy
+ * @update-time: 2023/4/27
+ */
+@Data
+@Entity
+@Table(name = "D_LOG_LOGIN")
+public class LogLogin implements Serializable {
+
+ public static String SORT_PROP = "id";
+
+ @Id
+ @Column(name = "ID_", unique = true, length = 40)
+ @PropertyDef(label = "ID")
+ private String id;
+
+ @Column(name = "COMPANY_ID", length = 10)
+ @PropertyDef(label = "缁勭粐缂栫爜")
+ private String companyId;
+
+ @Column(name = "LOGIN_ID", length = 40)
+ @PropertyDef(label = "鐧婚檰ID")
+ private String loginId;
+
+ @Column(name = "LOGIN_NAME", length = 40)
+ @PropertyDef(label = "鐧婚檰鐢ㄦ埛")
+ private String loginName;
+
+ @Column(name = "LOGIN_TIME")
+ @PropertyDef(label = "鐧婚檰鏃堕棿")
+ private Date loginTime;
+
+ @Column(name = "ERROR_NUM")
+ @PropertyDef(label = "閿欒娆℃暟")
+ private int errorNum;
+
+ @Column(name = "IP_", length = 20)
+ @PropertyDef(label = "鐧婚檰鑰匢P")
+ private String ip;
+
+ @Column(name = "BROSWER_", length = 50)
+ @PropertyDef(label = "娴忚鍣�")
+ private String browser;
+
+ @Column(name = "SYS_NAME", length = 50)
+ @PropertyDef(label = "鎿嶄綔绯荤粺")
+ private String sysName;
+
+ @Column(name = "HOST_NAME", length = 50)
+ @PropertyDef(label = "鐧婚檰涓绘満")
+ private String hostName;
+
+ @Column(name = "NET_INFO", length = 50)
+ @PropertyDef(label = "缃戠粶鐘跺喌")
+ private String netInfo = "姝e父";
+
+ @Column(name = "LAST_LOGIN_TIME")
+ @PropertyDef(label = "涓婃鐧婚檰鏃堕棿")
+ private Date lastLoginTime;
+
+ @Column(name = "LOGIN_INFO")
+ @PropertyDef(label = "鐧婚檰璇存槑")
+ private String loginInfo;
+
+}
diff --git a/src/main/java/com/fzzy/sys/repository/LogLoginRep.java b/src/main/java/com/fzzy/sys/repository/LogLoginRep.java
new file mode 100644
index 0000000..7461a1a
--- /dev/null
+++ b/src/main/java/com/fzzy/sys/repository/LogLoginRep.java
@@ -0,0 +1,9 @@
+package com.fzzy.sys.repository;
+
+import com.fzzy.sys.entity.LogLogin;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+public interface LogLoginRep extends JpaRepository<LogLogin, String>, JpaSpecificationExecutor<LogLogin> {
+
+}
diff --git a/src/main/java/com/fzzy/web/LoginController.java b/src/main/java/com/fzzy/web/LoginController.java
index 7edaff0..09be401 100644
--- a/src/main/java/com/fzzy/web/LoginController.java
+++ b/src/main/java/com/fzzy/web/LoginController.java
@@ -1,5 +1,6 @@
package com.fzzy.web;
+import com.fzzy.sys.LogLoginService;
import com.fzzy.sys.UserPR;
import com.fzzy.sys.entity.SysUser;
import com.wf.captcha.ArithmeticCaptcha;
@@ -26,6 +27,8 @@
@Autowired
private UserPR userPR;
+ @Autowired
+ private LogLoginService logLoginService;
/**
* 鐧诲綍楠岃瘉鍏ュ彛
@@ -54,16 +57,32 @@
return "redirect:/login?tag=04&username=" + username;
}
+ //鍒ゆ柇闄愬埗鐧婚檰
+ int num = logLoginService.checkLoginLimit(request, username);
+ if (num >= 3) {
+ return "redirect:/login?tag=11&username=" + username;
+ }
+
SysUser user = userPR.listById(username);
if (null == user) {
+ num = logLoginService.addNoUser(request, username);
+ if (num >= 3) {
+ return "redirect:/login?tag=12&username=" + username;
+ }
return "redirect:/login?tag=05&username=" + username;
}
boolean tag = userPR.checkPassword(password, user);
if (!tag){
+ num = logLoginService.addPwdError(request, user);
+ if (num >= 3) {
+ return "redirect:/login?tag=11&username=" + username;
+ }
return "redirect:/login?tag=06&username=" + username;
}
request.getSession().setAttribute("user", user);
+ //澧炲姞鐧诲綍鏃ュ織
+ logLoginService.addLoginInfo(request, user);
return "redirect:/home";
}
@@ -103,6 +122,12 @@
if ("10".equals(tag)) {
tag = "鎮ㄧ殑璐﹀彿鍦ㄥ叾浠栧湴鏂圭櫥褰曪紝琚揩涓嬬嚎";
}
+ if ("11".equals(tag)) {
+ tag = "杩炵画3娆¢敊璇紝闄愬埗鐧婚檰60鍒嗛挓";
+ }
+ if ("12".equals(tag)) {
+ tag = "杩炵画3娆¤緭鍏ヤ笉瀛樺湪璐﹀彿锛岄檺鍒剁櫥闄�60鍒嗛挓";
+ }
view.addObject("TAG", tag);
view.addObject("USERNAME", username);
}
diff --git a/src/main/resources/application-pro.yml b/src/main/resources/application-pro.yml
index 3625350..d5033e8 100644
--- a/src/main/resources/application-pro.yml
+++ b/src/main/resources/application-pro.yml
@@ -1,6 +1,6 @@
-########################## 瀹佸鐭冲槾灞辩孩鏋滃瓙绮簱 ##########################
+########################## 闄曡タ鏌炴按鍘� ##########################
server:
- port: 8090
+ port: 8091
jetty:
max-http-post-size: 209715200
tomcat:
@@ -9,16 +9,16 @@
datasource:
#涓绘暟鎹簮
primary:
- url: jdbc:mysql://127.0.0.1:3306/igds_api?useUnicode=true&characterEncoding=utf-8
+ url: jdbc:mysql://127.0.0.1:3306/igds_api_2024?useUnicode=true&characterEncoding=utf-8&useSSL=false
driver-class-name: com.mysql.jdbc.Driver
username: root
- password: Abc123..
+ password: Fzzy@#$%5432..K
#娆℃暟鎹簮
secondary:
- url: jdbc:mysql://127.0.0.1:3306/igds_master?useUnicode=true&characterEncoding=utf-8
+ url: jdbc:mysql://127.0.0.1:3306/igds_master?useUnicode=true&characterEncoding=utf-8&useSSL=false
driver-class-name: com.mysql.jdbc.Driver
username: root
- password: Abc123..
+ password: Fzzy@#$%5432..K
jpa:
#涓籮pa閰嶇疆
primary:
@@ -41,7 +41,7 @@
database: 1
host: 127.0.0.1
port: 6379
- password: Abc123..
+ password: Redispwd..
# 杩炴帴姹犳渶澶ц繛鎺ユ暟锛堜娇鐢ㄨ礋鍊艰〃绀烘病鏈夐檺鍒讹級
pool:
max-active: 200
@@ -51,11 +51,6 @@
timeout: 6000
igds:
default:
- companyId: 5306
+ companyId: 5348
file-path: D:/IGDS-API/FILE/
- img-path: D:/IGDS/FILE/
- # 鐪佸钩鍙癛SA瀵嗛挜瀵逛俊鎭�
- #鍏挜锛歁IGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCsoiS5Q5CKAT9w5EbZXCxJO/5J2iV3i2HrTW/YcGs2EGeQsQc97EWPdFE1SPXGH5p9TO8nCFRJScj4WeeKUVcuRpzR7czQQ+c6kf6cR9LLQrAiGEMQSk13j/5UsJho23IQDGKWoH18f5aPdX8tJn/o4aR6mMxUY9jdaSKEBck1TQIDAQAB
- # 鍖虹骇骞冲彴RSA瀵嗛挜瀵逛俊鎭�
- #鍏挜锛歁IGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCMsCJyl6EkjUEfB9Otl0bNmFD0Gr3g/v8DYnoq66EIviDNKT+bo5Aj6BRFngns1aCy1uyWgC5/+PIQ3sxs25nWXxFBYXy7cTiGwCCPfnmmI3rkXRGqRo6uh9K3BsucSE0kyhB8Eq76bQ6BPa5XpMyyq8V2oN2i0LLYpDhV97j3BwIDAQAB
- #绉侀挜锛歁IICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAIywInKXoSSNQR8H062XRs2YUPQaveD+/wNieirroQi+IM0pP5ujkCPoFEWeCezVoLLW7JaALn/48hDezGzbmdZfEUFhfLtxOIbAII9+eaYjeuRdEapGjq6H0rcGy5xITSTKEHwSrvptDoE9rlekzLKrxXag3aLQstikOFX3uPcHAgMBAAECgYAOZvWPz4/ygvdYqt9zlNntsBsRci9f+hq3CPzCqg55K6WF+yQE1dCqrFZu7gfME+54gGIF4idgeGanbXd16WEtFslEJlFKGk3cF62gaX5Y/nZ4zS65CLTjQ650j6SJ7OC2QYjIejTWhJD0k1tSazXdzV70nP+X3DbGyyO3Rm+juQJBANMCi+9RnzcGvltN/AdWD0DgshRBNrqrHtDkmzRFSkFwIqVSL5J7qRvntjhSstQIBB5KCosCmwRYKxGWQ9Ou420CQQCqrz2byBz3w2pkEfPY3rv7T4zE/2CHC74XtW9sEUTieYaxqIKlnwJacactzx4ZOAg21dGCoqOG9Y9RIpH2mMfDAkEAlAucXIt61qOfmPXtFsSVrSI5LybWHEAFPfC2yAS5ZZIkbLNt9ytV6eM3oOq81zDMmue93+wzEOg/R3aTHgj9PQJALNGxUsu8V473y+ku596s6/PamgwZE70QoHcjF/R86x9QMCx4ifb0Dj3T0WKWm7ar6YJB7pS4bgLjLEHwpBlAMwJAUUG2NhfGXFxfyFOC+5BzFTEr7EdSeHPXJl7dIWmRHncHsv8Nl2yvWsIOfDOYKS3ynptMgeSZaJPnXhvFdX0TnQ==
+ img-path: D:/IGDS/FILE/
\ No newline at end of file
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 86a70b3..bbeeabd 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -1,7 +1,7 @@
########################## Server ##########################
spring:
profiles:
- active: pro
+ active: dev
application:
name: igds-api
main:
diff --git a/src/main/resources/templates/home/home.html b/src/main/resources/templates/home/home.html
index 692acde..42e9954 100644
--- a/src/main/resources/templates/home/home.html
+++ b/src/main/resources/templates/home/home.html
@@ -101,6 +101,9 @@
<dd>
<a lay-href="com.fzzy.api.view.GbUnifiedCoding.d">缁熶竴缂栫爜绠$悊</a>
</dd>
+ <dd>
+ <a lay-href="com.fzzy.sys.LogLogin.d">鐧诲綍鏃ュ織</a>
+ </dd>
</dl>
</li>
--
Gitblit v1.9.3