From 651255b6aba50e597cb730d33d65da12a31e74ea Mon Sep 17 00:00:00 2001
From: hellohao <923453645@qq.com>
Date: Mon, 28 Oct 2024 14:00:00 +0100
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=83=A8=E5=88=86=E4=BB=A3?=
=?UTF-8?q?=E7=A0=81=E7=BB=93=E6=9E=84?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 4 +-
.../hellohao/auth/filter/xss/XssFilter.java | 4 -
.../hellohao/controller/AdminController.java | 1 -
.../hellohao/controller/IndexController.java | 4 +-
.../java/cn/hellohao/utils/MyStringUtils.java | 81 +++++++++++++++++++
.../java/cn/hellohao/utils/MyVersion.java | 50 ------------
.../java/cn/hellohao/utils/StringUtils.java | 40 ---------
7 files changed, 85 insertions(+), 99 deletions(-)
create mode 100644 src/main/java/cn/hellohao/utils/MyStringUtils.java
delete mode 100644 src/main/java/cn/hellohao/utils/MyVersion.java
delete mode 100644 src/main/java/cn/hellohao/utils/StringUtils.java
diff --git a/README.md b/README.md
index 4bd732c..25aeb0d 100644
--- a/README.md
+++ b/README.md
@@ -13,9 +13,9 @@
>:exclamation: 托管的所有开源代码可能存在作者修改/测试/调整等行为,均为实验性代码,故并不保证程序或功能的可用性,如果你想要部署程序,请下载我们提供的编译整合包进行安装部署。
-### 感谢JetBrains对开发者的大力支持
+### 感谢[JetBrains](https://www.jetbrains.com)对开发者的大力支持
-
+
diff --git a/src/main/java/cn/hellohao/auth/filter/xss/XssFilter.java b/src/main/java/cn/hellohao/auth/filter/xss/XssFilter.java
index 00998c5..a9e1efd 100644
--- a/src/main/java/cn/hellohao/auth/filter/xss/XssFilter.java
+++ b/src/main/java/cn/hellohao/auth/filter/xss/XssFilter.java
@@ -32,8 +32,4 @@ public class XssFilter implements Filter {
filterChain.doFilter(new XssHttpServletRequestWrapper(request),servletResponse);
}
- @Override
- public void destroy() {
-
- }
}
\ No newline at end of file
diff --git a/src/main/java/cn/hellohao/controller/AdminController.java b/src/main/java/cn/hellohao/controller/AdminController.java
index 775fc1b..3141114 100644
--- a/src/main/java/cn/hellohao/controller/AdminController.java
+++ b/src/main/java/cn/hellohao/controller/AdminController.java
@@ -32,7 +32,6 @@ import java.util.*;
/**
* @author Hellohao
* @version 1.0
- * @date 2019-07-17 14:22
*/
@Controller
@RequestMapping("/admin")
diff --git a/src/main/java/cn/hellohao/controller/IndexController.java b/src/main/java/cn/hellohao/controller/IndexController.java
index 8d3197f..2f6b230 100644
--- a/src/main/java/cn/hellohao/controller/IndexController.java
+++ b/src/main/java/cn/hellohao/controller/IndexController.java
@@ -8,7 +8,7 @@ import cn.hellohao.service.impl.UploadServicel;
import cn.hellohao.service.impl.WebDAVImageupload;
import cn.hellohao.service.impl.deleImages;
import cn.hellohao.utils.GetIPS;
-import cn.hellohao.utils.MyVersion;
+import cn.hellohao.utils.MyStringUtils;
import cn.hellohao.utils.SetFiles;
import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.ShearCaptcha;
@@ -418,7 +418,7 @@ public class IndexController {
AppClient app = appClientService.getAppClientData("app");
if (!StringUtils.isBlank(app.getAppupdate())) {
String version = app.getAppupdate().replaceAll("\\.", "");
- if (MyVersion.compareVersion(app.getAppupdate(), appv) == 1) {
+ if (MyStringUtils.compareVersion(app.getAppupdate(), appv) == 1) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("winpackurl", app.getWinpackurl());
jsonObject.put("macpackurl", app.getMacpackurl());
diff --git a/src/main/java/cn/hellohao/utils/MyStringUtils.java b/src/main/java/cn/hellohao/utils/MyStringUtils.java
new file mode 100644
index 0000000..6a6d620
--- /dev/null
+++ b/src/main/java/cn/hellohao/utils/MyStringUtils.java
@@ -0,0 +1,81 @@
+package cn.hellohao.utils;
+
+public class MyStringUtils {
+
+ /**
+ * 版本号比较
+ *
+ * @param v1
+ * @param v2
+ * @return 0代表相等,1代表左边大,-1代表右边大
+ * compareVersion("1.0.358_20180820090554","1.0.358_20180820090553")=1
+ */
+ public static int compareVersion(String v1, String v2) {
+ if (v1.equals(v2)) {
+ return 0;
+ }
+ String[] version1Array = v1.split("[._]");
+ String[] version2Array = v2.split("[._]");
+ int index = 0;
+ int minLen = Math.min(version1Array.length, version2Array.length);
+ long diff = 0;
+
+ while (index < minLen
+ && (diff = Long.parseLong(version1Array[index])
+ - Long.parseLong(version2Array[index])) == 0) {
+ index++;
+ }
+ if (diff == 0) {
+ for (int i = index; i < version1Array.length; i++) {
+ if (Long.parseLong(version1Array[i]) > 0) {
+ return 1;
+ }
+ }
+ for (int i = index; i < version2Array.length; i++) {
+ if (Long.parseLong(version2Array[i]) > 0) {
+ return -1;
+ }
+ }
+ return 0;
+ } else {
+ return diff > 0 ? 1 : -1;
+ }
+ }
+
+ /**
+ * 移除 URL 中的第一个 '/'
+ * @return 如 path = '/folder1/file1', 返回 'folder1/file1'
+ */
+ public static String removeFirstSeparator(String path) {
+ if (!"".equals(path) && path.charAt(0) == '/') {
+ path = path.substring(1);
+ }
+ return path;
+ }
+ /**
+ * 移除 URL 中的最后一个 '/'
+ * @return 如 path = '/folder1/file1/', 返回 '/folder1/file1'
+ */
+ public static String removeLastSeparator(String path) {
+ if (!"".equals(path) && path.charAt(path.length() - 1) == '/') {
+ path = path.substring(0, path.length() - 1);
+ }
+ return path;
+ }
+
+ /**
+ * 将域名和路径组装成 URL, 主要用来处理分隔符 '/'
+ * @param domain 域名
+ * @param path 路径
+ * @return URL
+ */
+ public static String concatDomainAndPath(String domain, String path) {
+ if (path != null && path.length() > 1 && path.charAt(0) != '/') {
+ path = '/' + path;
+ }
+ if (domain.charAt(domain.length() - 1) == '/') {
+ domain = domain.substring(0, domain.length() - 2);
+ }
+ return domain + path;
+ }
+}
diff --git a/src/main/java/cn/hellohao/utils/MyVersion.java b/src/main/java/cn/hellohao/utils/MyVersion.java
deleted file mode 100644
index 3793ca0..0000000
--- a/src/main/java/cn/hellohao/utils/MyVersion.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package cn.hellohao.utils;
-
-/**
- * @author Hellohao
- * @version 1.0
- * @date 2022/7/18 9:49
- */
-public class MyVersion {
- /**
- * 版本号比较
- *
- * @param v1
- * @param v2
- * @return 0代表相等,1代表左边大,-1代表右边大
- * Utils.compareVersion("1.0.358_20180820090554","1.0.358_20180820090553")=1
- */
- public static int compareVersion(String v1, String v2) {
- if (v1.equals(v2)) {
- return 0;
- }
- String[] version1Array = v1.split("[._]");
- String[] version2Array = v2.split("[._]");
- int index = 0;
- int minLen = Math.min(version1Array.length, version2Array.length);
- long diff = 0;
-
- while (index < minLen
- && (diff = Long.parseLong(version1Array[index])
- - Long.parseLong(version2Array[index])) == 0) {
- index++;
- }
- if (diff == 0) {
- for (int i = index; i < version1Array.length; i++) {
- if (Long.parseLong(version1Array[i]) > 0) {
- return 1;
- }
- }
-
- for (int i = index; i < version2Array.length; i++) {
- if (Long.parseLong(version2Array[i]) > 0) {
- return -1;
- }
- }
- return 0;
- } else {
- return diff > 0 ? 1 : -1;
- }
- }
-
-}
diff --git a/src/main/java/cn/hellohao/utils/StringUtils.java b/src/main/java/cn/hellohao/utils/StringUtils.java
deleted file mode 100644
index f2d10e7..0000000
--- a/src/main/java/cn/hellohao/utils/StringUtils.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package cn.hellohao.utils;
-
-public class StringUtils {
- /**
- * 移除 URL 中的第一个 '/'
- * @return 如 path = '/folder1/file1', 返回 'folder1/file1'
- */
- public static String removeFirstSeparator(String path) {
- if (!"".equals(path) && path.charAt(0) == '/') {
- path = path.substring(1);
- }
- return path;
- }
- /**
- * 移除 URL 中的最后一个 '/'
- * @return 如 path = '/folder1/file1/', 返回 '/folder1/file1'
- */
- public static String removeLastSeparator(String path) {
- if (!"".equals(path) && path.charAt(path.length() - 1) == '/') {
- path = path.substring(0, path.length() - 1);
- }
- return path;
- }
-
- /**
- * 将域名和路径组装成 URL, 主要用来处理分隔符 '/'
- * @param domain 域名
- * @param path 路径
- * @return URL
- */
- public static String concatDomainAndPath(String domain, String path) {
- if (path != null && path.length() > 1 && path.charAt(0) != '/') {
- path = '/' + path;
- }
- if (domain.charAt(domain.length() - 1) == '/') {
- domain = domain.substring(0, domain.length() - 2);
- }
- return domain + path;
- }
-}