diff --git a/pom.xml b/pom.xml
index c320b05..ca36c30 100644
--- a/pom.xml
+++ b/pom.xml
@@ -248,7 +248,7 @@
true
-
+ org.apache.maven.pluginsmaven-compiler-plugin88
diff --git a/src/main/java/cn/hellohao/controller/AdminController.java b/src/main/java/cn/hellohao/controller/AdminController.java
index a29f5a4..775fc1b 100644
--- a/src/main/java/cn/hellohao/controller/AdminController.java
+++ b/src/main/java/cn/hellohao/controller/AdminController.java
@@ -7,7 +7,6 @@ import cn.hellohao.service.*;
import cn.hellohao.service.impl.AlbumServiceImpl;
import cn.hellohao.service.impl.UserServiceImpl;
import cn.hellohao.service.impl.deleImages;
-import cn.hellohao.utils.Base64Encryption;
import cn.hellohao.utils.SetFiles;
import cn.hellohao.utils.SetText;
import cn.hellohao.utils.progress.MyProgress;
@@ -28,10 +27,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.UUID;
+import java.util.*;
/**
* @author Hellohao
@@ -444,10 +440,11 @@ public class AdminController {
user.setEmail(email);
}
}
- user.setPassword(Base64Encryption.encryptBASE64(password.getBytes()));
+
+ user.setPassword(Base64.getEncoder().encodeToString(password.getBytes()));
user.setUid(u.getUid());
} else {
- user.setPassword(Base64Encryption.encryptBASE64(password.getBytes()));
+ user.setPassword(Base64.getEncoder().encodeToString(password.getBytes()));
user.setUid(u.getUid());
}
userService.change(user);
diff --git a/src/main/java/cn/hellohao/controller/AdminRootController.java b/src/main/java/cn/hellohao/controller/AdminRootController.java
index 2e6ca46..93f1397 100644
--- a/src/main/java/cn/hellohao/controller/AdminRootController.java
+++ b/src/main/java/cn/hellohao/controller/AdminRootController.java
@@ -47,6 +47,22 @@ public class AdminRootController {
private ImgreviewService imgreviewService;
@Autowired
private AppClientService appClientService;
+ @Autowired
+ private NOSImageupload nOSImageupload;
+ @Autowired
+ private OSSImageupload ossImageupload;
+ @Autowired
+ private USSImageupload ussImageupload;
+ @Autowired
+ private KODOImageupload kodoImageupload;
+ @Autowired
+ private COSImageupload cosImageupload;
+ @Autowired
+ private FtpServiceImpl ftpService;
+ @Autowired
+ private S3Imageupload s3Imageupload;
+ @Autowired
+ private WebDAVImageupload webDAVImageupload;
@PostMapping(value = "/getUserList")
@@ -189,19 +205,21 @@ public class AdminRootController {
Keys key = keysService.selectKeys(keyId);
Integer ret = 0;
if (key.getStorageType() == 1) {
- ret = NOSImageupload.Initialize(key);
+ ret = nOSImageupload.Initialize(key);
} else if (key.getStorageType() == 2) {
- ret = OSSImageupload.Initialize(key);
+ ret = ossImageupload.Initialize(key);
} else if (key.getStorageType() == 3) {
- ret = USSImageupload.Initialize(key);
+ ret = ussImageupload.Initialize(key);
} else if (key.getStorageType() == 4) {
- ret = KODOImageupload.Initialize(key);
+ ret = kodoImageupload.Initialize(key);
} else if (key.getStorageType() == 6) {
- ret = COSImageupload.Initialize(key);
+ ret = cosImageupload.Initialize(key);
} else if (key.getStorageType() == 7) {
- ret = FtpServiceImpl.Initialize(key);
+ ret = ftpService.Initialize(key);
} else if (key.getStorageType() == 8) {
- ret = S3Imageupload.Initialize(key);
+ ret = s3Imageupload.Initialize(key);
+ }else if (key.getStorageType() == 9) {
+ ret = webDAVImageupload.Initialize(key);
}
Long l = imgService.getsourcememory(keyId);
jsonObject.put("isok", ret);
@@ -224,23 +242,6 @@ public class AdminRootController {
@ResponseBody
public Msg updateStorage(@RequestParam(value = "data", defaultValue = "") String data) {
JSONObject jsonObj = JSONObject.parseObject(data);
-// Integer id = jsonObj.getInteger("id");
-// String AccessKey = jsonObj.getString("AccessKey");
-// String AccessSecret = jsonObj.getString("AccessSecret");
-// String Endpoint = jsonObj.getString("Endpoint");
-// String Bucketname = jsonObj.getString("Bucketname");
-// String RequestAddress = jsonObj.getString("RequestAddress");
-// Integer storageType = jsonObj.getInteger("storageType");
-// String keyname = jsonObj.getString("keyname");
-// Keys keys = new Keys();
-// keys.setId(id);
-// keys.setAccessKey(AccessKey);
-// keys.setAccessSecret(AccessSecret);
-// keys.setEndpoint(Endpoint);
-// keys.setBucketname(Bucketname);
-// keys.setRequestAddress(RequestAddress);
-// keys.setStorageType(storageType);
-// keys.setKeyname(keyname);
Keys keys = JSON.toJavaObject(jsonObj,Keys.class);
Msg msg = keysService.updateKey(keys);
return msg;
diff --git a/src/main/java/cn/hellohao/controller/IndexController.java b/src/main/java/cn/hellohao/controller/IndexController.java
index c77116f..99104ac 100644
--- a/src/main/java/cn/hellohao/controller/IndexController.java
+++ b/src/main/java/cn/hellohao/controller/IndexController.java
@@ -5,6 +5,7 @@ import cn.hellohao.config.GlobalConstant;
import cn.hellohao.pojo.*;
import cn.hellohao.service.*;
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;
@@ -19,6 +20,8 @@ import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.core.io.InputStreamResource;
+import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
@@ -43,7 +46,7 @@ public class IndexController {
@Autowired private deleImages deleimages;
@Autowired private IRedisService iRedisService;
@Autowired private AppClientService appClientService;
-
+ @Autowired private WebDAVImageupload webDAVImageupload;
public static String version = "20240111";
@RequestMapping(value = "/")
public String Welcome(Model model, HttpServletRequest httpServletRequest) {
@@ -191,6 +194,14 @@ public class IndexController {
return retMsg;
}
+ //webdav本地托管
+ @GetMapping("/w/{shortuuid}")
+ public ResponseEntity getNextcloudImage(HttpServletRequest request, @PathVariable("shortuuid") String shortuuid) {
+ ResponseEntity webDAV = webDAVImageupload.getWebDAV(shortuuid);
+ return webDAV;
+
+ }
+
@RequestMapping(value = "/getUploadInfo")
@ResponseBody
public Msg getUploadInfo() {
diff --git a/src/main/java/cn/hellohao/controller/UserController.java b/src/main/java/cn/hellohao/controller/UserController.java
index e7d85e5..41cf041 100644
--- a/src/main/java/cn/hellohao/controller/UserController.java
+++ b/src/main/java/cn/hellohao/controller/UserController.java
@@ -5,7 +5,6 @@ import cn.hellohao.auth.token.JWTUtil;
import cn.hellohao.config.SysName;
import cn.hellohao.pojo.*;
import cn.hellohao.service.*;
-import cn.hellohao.utils.Base64Encryption;
import cn.hellohao.utils.NewSendEmail;
import cn.hellohao.utils.Print;
import cn.hellohao.utils.SetText;
@@ -27,6 +26,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.text.SimpleDateFormat;
+import java.util.Base64;
import java.util.Date;
import java.util.UUID;
@@ -55,7 +55,7 @@ public class UserController {
JSONObject jsonObj = JSONObject.parseObject(data);
String username = jsonObj.getString("username");
String email = jsonObj.getString("email");
- String password = Base64Encryption.encryptBASE64(jsonObj.getString("password").getBytes());
+ String password = Base64.getEncoder().encodeToString(jsonObj.getString("password").getBytes());
String verifyCodeForRegister = jsonObj.getString("verifyCode");
Object redis_verifyCodeForRegister = iRedisService.getValue("verifyCodeForRegister_"+httpServletRequest.getHeader("verifyCodeForRegister"));
if(!SetText.checkEmail(email)){
@@ -203,7 +203,7 @@ public class UserController {
Msg msg = new Msg();
JSONObject jsonObj = JSONObject.parseObject(data);
String email = jsonObj.getString("email");
- String password = Base64Encryption.encryptBASE64(jsonObj.getString("password").getBytes());
+ String password = Base64.getEncoder().encodeToString(jsonObj.getString("password").getBytes());
String verifyCode = jsonObj.getString("verifyCode");
if(null == email || null == password || null == verifyCode){
msg.setCode("5000");
@@ -385,7 +385,7 @@ public class UserController {
User user = userService.getUsers(u2);
user.setIsok(1);
String new_pass = HexUtil.decodeHexStr(cip);//解密密码
- user.setPassword(Base64Encryption.encryptBASE64(new_pass.getBytes()));
+ user.setPassword(Base64.getEncoder().encodeToString(new_pass.getBytes()));
String uid = UUID.randomUUID().toString().replace("-", "").toLowerCase();
user.setUid(uid);
if (user != null) {
diff --git a/src/main/java/cn/hellohao/pojo/Keys.java b/src/main/java/cn/hellohao/pojo/Keys.java
index 228b96f..368b327 100644
--- a/src/main/java/cn/hellohao/pojo/Keys.java
+++ b/src/main/java/cn/hellohao/pojo/Keys.java
@@ -16,4 +16,7 @@ public class Keys {
private String RootPath;//存入的目录
private Boolean SysTransmit;
+ public Boolean getSysTransmit() {
+ return SysTransmit==null?false:SysTransmit;
+ }
}
diff --git a/src/main/java/cn/hellohao/quartz/job/FirstJob.java b/src/main/java/cn/hellohao/quartz/job/FirstJob.java
index 113210c..6edf365 100644
--- a/src/main/java/cn/hellohao/quartz/job/FirstJob.java
+++ b/src/main/java/cn/hellohao/quartz/job/FirstJob.java
@@ -34,6 +34,8 @@ public class FirstJob {
@Autowired
private S3Imageupload s3Imageupload;
@Autowired
+ private WebDAVImageupload webDAVImageupload;
+ @Autowired
private FtpServiceImpl ftpService;
@Autowired
ImgTempService imgTempService;
@@ -78,6 +80,8 @@ public class FirstJob {
firstJob.ftpService.delFTP(keys.getId(), images);
}else if(keys.getStorageType()==8){
firstJob.s3Imageupload.deleS3(keys.getId(), images);
+ }else if(keys.getStorageType()==9){
+ firstJob.webDAVImageupload.delWebDAV(keys.getId(), images);
}else{
System.err.println("未获取到对象存储参数,上传失败。");
}
diff --git a/src/main/java/cn/hellohao/service/impl/ClientService.java b/src/main/java/cn/hellohao/service/impl/ClientService.java
index 57c3275..fc1317c 100644
--- a/src/main/java/cn/hellohao/service/impl/ClientService.java
+++ b/src/main/java/cn/hellohao/service/impl/ClientService.java
@@ -67,7 +67,7 @@ public class ClientService {
return msg;
}
u2.setEmail(email);
- u2.setPassword(Base64Encryption.encryptBASE64(pass.getBytes()));
+ u2.setPassword(Base64.getEncoder().encodeToString(pass.getBytes()));
User u = userMapper.getUsers(u2);
if (null == u || u.getIsok() != 1) {
msg.setCode("4006");
@@ -142,8 +142,10 @@ public class ClientService {
imgnameEd = updatePath + "/" + shortUuid_y + "." + prefix;
imgObj.setImgname(imgnameEd);
if (key.getStorageType().equals(5)) {
- imgObj.setImgurl(key.getRequestAddress() + "/ota/" + imgnameEd);
- } else {
+ imgObj.setImgurl(confdata.getString("domain") + "/ota/" + imgnameEd);
+ } else if(key.getStorageType().equals(9) && key.getSysTransmit()){
+ imgObj.setImgurl(confdata.getString("domain") + "/w/" + shortUuid_y);
+ }else {
imgObj.setImgurl(key.getRequestAddress() + "/" + imgnameEd);
}
imgObj.setSizes(Long.toString(file.length()));
diff --git a/src/main/java/cn/hellohao/service/impl/InitializationStorage.java b/src/main/java/cn/hellohao/service/impl/InitializationStorage.java
index eb8eb42..c858187 100644
--- a/src/main/java/cn/hellohao/service/impl/InitializationStorage.java
+++ b/src/main/java/cn/hellohao/service/impl/InitializationStorage.java
@@ -58,6 +58,8 @@ public class InitializationStorage implements CommandLineRunner {
FtpServiceImpl.Initialize(key);
}else if(key.getStorageType()==8){
S3Imageupload.Initialize(key);
+ }else if(key.getStorageType()==9){
+ WebDAVImageupload.Initialize(key);
}
}
}
diff --git a/src/main/java/cn/hellohao/service/impl/KeysServiceImpl.java b/src/main/java/cn/hellohao/service/impl/KeysServiceImpl.java
index 3a1fdc7..2b46ed6 100644
--- a/src/main/java/cn/hellohao/service/impl/KeysServiceImpl.java
+++ b/src/main/java/cn/hellohao/service/impl/KeysServiceImpl.java
@@ -2,6 +2,7 @@ package cn.hellohao.service.impl;
import cn.hellohao.pojo.Msg;
import cn.hellohao.utils.Print;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -30,6 +31,8 @@ public class KeysServiceImpl implements KeysService {
private FtpServiceImpl ftpService;
@Autowired
private S3Imageupload s3Imageupload;
+ @Autowired
+ private WebDAVImageupload webDAVImageupload;
@Override
@@ -51,6 +54,29 @@ public class KeysServiceImpl implements KeysService {
public Msg updateKey(Keys key) {
Msg msg = new Msg();
Integer ret = -2;
+ //修正一边数据格式,去除末尾的斜杠
+ if(key.getStorageType()==9 || key.getStorageType()==8){
+ //s3或者webdav
+ if(!StringUtils.isBlank(key.getRootPath()) && !key.getRootPath().equals("/")){
+ if (key.getRootPath().endsWith("/")) {
+ String rootpath = key.getRootPath();
+ key.setRootPath(rootpath.substring(0, rootpath.length() - 1));
+ }
+ }
+ }
+ if(!StringUtils.isBlank(key.getEndpoint())){
+ final String endpoint = key.getEndpoint();
+ if (endpoint.endsWith("/")) {
+ key.setEndpoint(endpoint.substring(0, endpoint.length() - 1));
+ }
+ }
+ if(!StringUtils.isBlank(key.getRequestAddress())){
+ final String requestAddress = key.getRequestAddress();
+ if (requestAddress.endsWith("/")) {
+ key.setRequestAddress(requestAddress.substring(0, requestAddress.length() - 1));
+ }
+ }
+
if(key.getStorageType()==1){
ret =nOSImageupload.Initialize(key);
}else if (key.getStorageType()==2){
@@ -67,6 +93,8 @@ public class KeysServiceImpl implements KeysService {
ret = ftpService.Initialize(key);
}else if(key.getStorageType()==8){
ret = s3Imageupload.Initialize(key);
+ }else if(key.getStorageType()==9){
+ ret = webDAVImageupload.Initialize(key);
}else{
Print.Normal("为获取到存储参数,或者使用存储源是本地的。");
}
diff --git a/src/main/java/cn/hellohao/service/impl/UploadServicel.java b/src/main/java/cn/hellohao/service/impl/UploadServicel.java
index a8f45ee..e08a6de 100644
--- a/src/main/java/cn/hellohao/service/impl/UploadServicel.java
+++ b/src/main/java/cn/hellohao/service/impl/UploadServicel.java
@@ -148,8 +148,10 @@ public class UploadServicel {
imgnameEd = updatePath + "/" + shortUuid_y + "." + prefix;
imgObj.setImgname(imgnameEd);
if (key.getStorageType().equals(5)) {
- imgObj.setImgurl(key.getRequestAddress() + "/ota/" + imgnameEd);
- } else {
+ imgObj.setImgurl(confdata.getString("domain") + "/ota/" + imgnameEd);
+ } else if(key.getStorageType().equals(9) && key.getSysTransmit()){
+ imgObj.setImgurl(confdata.getString("domain") + "/w/" + shortUuid_y);
+ }else {
imgObj.setImgurl(key.getRequestAddress() + "/" + imgnameEd);
}
imgObj.setSizes(Long.toString(file.length()));
diff --git a/src/main/java/cn/hellohao/service/impl/WebDAVImageupload.java b/src/main/java/cn/hellohao/service/impl/WebDAVImageupload.java
index 71ca7f9..4e62172 100644
--- a/src/main/java/cn/hellohao/service/impl/WebDAVImageupload.java
+++ b/src/main/java/cn/hellohao/service/impl/WebDAVImageupload.java
@@ -48,8 +48,6 @@ public class WebDAVImageupload {
private static Logger logger = LoggerFactory.getLogger(WebDAVImageupload.class);
public ReturnImage ImageuploadWebDAV(Map