diff --git a/build.xml b/build.xml
deleted file mode 100644
index 46a3afe..0000000
--- a/build.xml
+++ /dev/null
@@ -1,246 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/pom.xml b/pom.xml
index e50ef60..b695b46 100644
--- a/pom.xml
+++ b/pom.xml
@@ -82,6 +82,14 @@
cos_api
5.5.7
+
+
+
+ cn.hutool
+ hutool-all
+ 4.5.16
+
+
diff --git a/sql/picturebed.sql b/sql/picturebed.sql
index ba56266..4b548db 100644
--- a/sql/picturebed.sql
+++ b/sql/picturebed.sql
@@ -11,7 +11,7 @@
Target Server Version : 50720
File Encoding : 65001
- Date: 23/07/2019 20:23:29
+ Date: 26/07/2019 17:38:26
*/
SET NAMES utf8mb4;
@@ -149,13 +149,14 @@ CREATE TABLE `uploadconfig` (
`imgcountuser` int(10) NULL DEFAULT NULL COMMENT '用户文件总数量, 超出则不允许加入队列',
`suffix` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '支持后缀',
`urltype` int(2) NULL DEFAULT NULL,
+ `isupdate` int(2) NULL DEFAULT NULL COMMENT '禁止游客上传',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
-- ----------------------------
-- Records of uploadconfig
-- ----------------------------
-INSERT INTO `uploadconfig` VALUES (1, 3, 5, 1, 5, 'gif,jpg,jpeg,bmp,png', 1);
+INSERT INTO `uploadconfig` VALUES (1, 3, 5, 1, 5, 'gif,jpg,jpeg,bmp,png', 1, 1);
-- ----------------------------
-- Table structure for user
@@ -166,7 +167,7 @@ CREATE TABLE `user` (
`username` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户名',
`password` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '密码',
`email` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '邮箱',
- `birthder` datetime(0) NULL DEFAULT NULL COMMENT '注册时间',
+ `birthder` date NULL DEFAULT NULL COMMENT '注册时间',
`level` int(10) NULL DEFAULT NULL COMMENT '等级',
`uid` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户唯一标识',
`isok` int(2) NOT NULL,
@@ -176,6 +177,6 @@ CREATE TABLE `user` (
-- ----------------------------
-- Records of user
-- ----------------------------
-INSERT INTO `user` VALUES (1, 'admin', 'admin', 'admin', '2019-06-12 00:00:00', 2, 'admin', 1);
+INSERT INTO `user` VALUES (1, 'admin', 'admin', 'admin', '2019-06-12', 2, 'admin', 1);
SET FOREIGN_KEY_CHECKS = 1;
diff --git a/src/main/java/cn/hellohao/controller/AdminController.java b/src/main/java/cn/hellohao/controller/AdminController.java
index 8d533de..8e46bf9 100644
--- a/src/main/java/cn/hellohao/controller/AdminController.java
+++ b/src/main/java/cn/hellohao/controller/AdminController.java
@@ -66,23 +66,11 @@ public class AdminController {
Keys key = keysService.selectKeys(config.getSourcekey());
User u = (User) session.getAttribute("user");
Imgreview imgreview = imgreviewService.selectByPrimaryKey(1);
-// if (u.getLevel() > 1) {
-// //管理员
-// model.addAttribute("counts", imgService.counts(null));
-// } else {
-// //个人用户
-// //model.addAttribute("counts", imgService.countimg(u.getId()));//这个是根据用户id查询他的图片数
-// }
-
- //model.addAttribute("usercount", imgService.countimg(u.getId()));//这个是根据用户id查询他的图片数
- //model.addAttribute("counts", imgService.counts(null) );//总数
- //model.addAttribute("getusertotal", userService.getUserTotal() );
- //model.addAttribute("imgreviewcount", imgreview.getCount());
model.addAttribute("username", u.getUsername());
model.addAttribute("level", u.getLevel());
model.addAttribute("email", u.getEmail());
model.addAttribute("loginid", 100);
- Boolean b = StringUtils.doNull(key);//判断对象是否有空值
+ //Boolean b = StringUtils.doNull(key);//判断对象是否有空值
// if(b){
// model.addAttribute("source", key.getStorageType());
// }else{
@@ -116,7 +104,12 @@ public class AdminController {
jsonObject.put("getusertotal", userService.getUserTotal() );
jsonObject.put("imgreviewcount", imgreview.getCount());
Keys key= keysService.selectKeys(config.getSourcekey());//然后根据类型再查询key
- Boolean b = StringUtils.doNull(key);//判断对象是否有空值
+ Boolean b =false;
+ if(config.getSourcekey()==5){
+ b =true;
+ }else{
+ b = StringUtils.doNull(config.getSourcekey(),key);//判断对象是否有空值
+ }
if(b){
jsonObject.put("source", key.getStorageType());
}else{
@@ -215,7 +208,13 @@ public class AdminController {
User u = (User) session.getAttribute("user");
Images images = imgService.selectByPrimaryKey(id);
Keys key = keysService.selectKeys(sourcekey);
- Boolean b = StringUtils.doNull(key);//判断对象是否有空值
+ Config config = configService.getSourceype();//查询当前系统使用的存储源类型。
+ Boolean b =false;
+ if(config.getSourcekey()==5){
+ b =true;
+ }else{
+ b = StringUtils.doNull(config.getSourcekey(),key);//判断对象是否有空值
+ }
if(b){
ImgServiceImpl de = new ImgServiceImpl();
if (key.getStorageType() == 1) {
@@ -254,13 +253,20 @@ public class AdminController {
@ResponseBody
public String deleallimg(HttpSession session, @RequestParam("ids[]") Integer[] ids) {
JSONObject jsonObject = new JSONObject();
+
Integer v = 0;
ImgServiceImpl de = new ImgServiceImpl();
User u = (User) session.getAttribute("user");
+ Config config = configService.getSourceype();
for (int i = 0; i < ids.length; i++) {
Images images = imgService.selectByPrimaryKey(ids[i]);
Keys key = keysService.selectKeys(images.getSource());
- Boolean b = StringUtils.doNull(key);//判断对象是否有空值
+ Boolean b =false;
+ if(config.getSourcekey()==5){
+ b =true;
+ }else{
+ b = StringUtils.doNull(config.getSourcekey(),key);//判断对象是否有空值
+ }
if(b){
if (key.getStorageType() == 1) {
de.delect(key, images.getImgname());
@@ -299,6 +305,7 @@ public class AdminController {
User u = (User) session.getAttribute("user");
//key信息
model.addAttribute("username", u.getUsername());
+ model.addAttribute("level", u.getLevel());
return "admin/setuser";
}
diff --git a/src/main/java/cn/hellohao/controller/AdminRootController.java b/src/main/java/cn/hellohao/controller/AdminRootController.java
index b49543f..7e997f9 100644
--- a/src/main/java/cn/hellohao/controller/AdminRootController.java
+++ b/src/main/java/cn/hellohao/controller/AdminRootController.java
@@ -1,12 +1,9 @@
package cn.hellohao.controller;
-import cn.hellohao.pojo.Config;
-import cn.hellohao.pojo.EmailConfig;
-import cn.hellohao.pojo.Keys;
-import cn.hellohao.pojo.UploadConfig;
+import cn.hellohao.pojo.*;
import cn.hellohao.service.*;
-import cn.hellohao.utils.Print;
import cn.hellohao.utils.StringUtils;
+import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@@ -16,6 +13,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
+import java.util.HashMap;
@Controller
@RequestMapping("/admin/root")
@@ -31,6 +29,8 @@ public class AdminRootController {
private EmailConfigService emailConfigService;
@Autowired
private UploadConfigService uploadConfigService;
+ @Autowired
+ private NoticeService noticeService;
//返回对象存储界面
@RequestMapping(value = "/touser")
@@ -43,7 +43,7 @@ public class AdminRootController {
public String tostorage(HttpSession session, Model model, HttpServletRequest request) {
Config config = configService.getSourceype();//查询当前系统使用的存储源类型。
Keys key= keysService.selectKeys(config.getSourcekey());//然后根据类型再查询key
- Boolean b = StringUtils.doNull(key);//判断对象是否有空值
+ Boolean b = StringUtils.doNull(config.getSourcekey(),key);//判断对象是否有空值
Integer StorageType = 0;
if(config.getSourcekey()!=5){
if(b){
@@ -80,6 +80,17 @@ public class AdminRootController {
jsonArray.add(key);
return jsonArray.toString();
}
+ //获取当前使用的对象存储
+ @PostMapping("/getkeyourceype")
+ @ResponseBody
+ public Integer getkeyourceype() {
+ Config config = configService.getSourceype();//查询当前系统使用的存储源类型。
+ Integer ret = 0;
+ if(config.getSourcekey()!=null){
+ ret = config.getSourcekey();
+ }
+ return ret;
+ }
@PostMapping("/updatekey")
@ResponseBody
@@ -102,8 +113,14 @@ public class AdminRootController {
@ResponseBody
public String deleuser(HttpSession session, Integer id) {
JSONArray jsonArray = new JSONArray();
- Integer ret = userService.deleuser(id);
- jsonArray.add(ret);
+ User u = (User) session.getAttribute("user");
+ if(u.getId()==id){
+ jsonArray.add("-1");
+ }else{
+ Integer ret = userService.deleuser(id);
+ jsonArray.add(ret);
+ }
+
return jsonArray.toString();
}
@@ -166,4 +183,24 @@ public class AdminRootController {
return ret;
}
+ //关于系统
+ @RequestMapping("/about")
+ public String about(HttpSession session,Model model ) {
+ //Integer ret = uploadConfigService.setUpdateConfig(updateConfig);
+ User u = (User) session.getAttribute("user");
+ model.addAttribute("level",u.getLevel());
+ return "admin/about";
+ }
+ //检查更新
+ @PostMapping("/sysupdate")
+ @ResponseBody
+ public Integer sysupdate(String dates) {
+ HashMap paramMap = new HashMap<>();
+ String urls ="http://tc.hellohao.cn/systemupdate";
+ paramMap.put("dates",dates);
+ String result= HttpUtil.post(urls, paramMap);
+ System.out.println(Integer.parseInt( result ));
+ return Integer.parseInt( result );
+ }
+
}
diff --git a/src/main/java/cn/hellohao/controller/ClientController.java b/src/main/java/cn/hellohao/controller/ClientController.java
index 5ae64d0..a2bc995 100644
--- a/src/main/java/cn/hellohao/controller/ClientController.java
+++ b/src/main/java/cn/hellohao/controller/ClientController.java
@@ -1,10 +1,7 @@
package cn.hellohao.controller;
import cn.hellohao.pojo.*;
-import cn.hellohao.service.ConfigService;
-import cn.hellohao.service.KeysService;
-import cn.hellohao.service.UploadConfigService;
-import cn.hellohao.service.UserService;
+import cn.hellohao.service.*;
import cn.hellohao.service.impl.KODOImageupload;
import cn.hellohao.service.impl.NOSImageupload;
import cn.hellohao.service.impl.OSSImageupload;
@@ -12,6 +9,7 @@ import cn.hellohao.service.impl.USSImageupload;
import cn.hellohao.utils.*;
import com.alibaba.fastjson.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@@ -44,14 +42,18 @@ public class ClientController {
private KODOImageupload kodoImageupload;
@Autowired
private UploadConfigService uploadConfigService;
+ @Autowired
+ private NoticeService noticeService;
- //@PostMapping(value = "/clientupimg")
+ @Value("${systemupdate}")
+ private String systemupdate;
+
+ @PostMapping(value = "/clientupimg")
@ResponseBody
public String clientupimg(@RequestParam("file") List file, String email,String pass) throws Exception {
JSONArray jsonArray = new JSONArray();
UploadConfig uploadConfig = uploadConfigService.getUpdateConfig();
-
- if(email!=null && pass!=null){
+ if(email!=null && pass!=null){
Integer ret = userService.login(email, pass);
if (ret > 0) {
User user = userService.getUsers(email);
@@ -59,7 +61,6 @@ public class ClientController {
User u = userService.getUsers(email);
Config config = configService.getSourceype();//查询当前系统使用的存储源类型。
Keys key = keysService.selectKeys(config.getSourcekey());
-
if(key.getStorageType()!=0 && key.getStorageType()!=null){
if(key.getStorageType()==1){
nOSImageupload.Initialize(key);//实例化网易
@@ -74,10 +75,14 @@ public class ClientController {
}
}
Print.Normal("客户端:初始化上传。");
- Boolean b = StringUtils.doNull(key);//判断对象是否有空值
+ Boolean b =false;
+ if(config.getSourcekey()==5){
+ b =true;
+ }else{
+ b = StringUtils.doNull(config.getSourcekey(),key);//判断对象是否有空值
+ }
if(b){
long stime = System.currentTimeMillis();
-
String userpath = "tourist";
if(uploadConfig.getUrltype()==2){
java.text.DateFormat dateFormat = new java.text.SimpleDateFormat("yyyy/MM/dd");
@@ -178,7 +183,6 @@ public class ClientController {
}
Print.Normal(jsonArray.toString());
}
-
}else{
//邮箱或密码不正确,登录失败
jsonArray.add(-2);
@@ -197,4 +201,13 @@ public class ClientController {
return "-1";//-1就是没有公告,客户端不显示
}
+ //主端接口
+ @PostMapping("/systemupdate")
+ @ResponseBody
+ public String sysupdate(String dates) {
+ Integer i=dates.compareTo(systemupdate);//小于0则需要更新
+ System.out.println(i);
+ return i.toString();
+ }
+
}
diff --git a/src/main/java/cn/hellohao/controller/UpdateImgController.java b/src/main/java/cn/hellohao/controller/UpdateImgController.java
index fae8b46..4a70dbd 100644
--- a/src/main/java/cn/hellohao/controller/UpdateImgController.java
+++ b/src/main/java/cn/hellohao/controller/UpdateImgController.java
@@ -57,30 +57,22 @@ public class UpdateImgController {
if(uploadConfig.getFilesizeuser()!=null){filesizeuser = uploadConfig.getFilesizeuser();}
if(uploadConfig.getImgcounttourists()!=null){imgcounttourists = uploadConfig.getImgcounttourists();}
if(uploadConfig.getImgcountuser()!=null){imgcountuser = uploadConfig.getImgcountuser();}
- Boolean b =false;
+ //Boolean b =false;
Keys key = null;
if(config.getSourcekey()!=0 && config.getSourcekey()!=5){
key= keysService.selectKeys(config.getSourcekey());//然后根据类型再查询key
- b = StringUtils.doNull(key);//判断对象是否有空值
- }
- if(b)
- {
+ //b = StringUtils.doNull(key);//判断对象是否有空值
if(key.getStorageType()!=0 && key.getStorageType()!=null){
if(key.getStorageType()==1){
nOSImageupload.Initialize(key);//实例化网易
- System.out.println("NOS初始化成功。");
}else if (key.getStorageType()==2){
OSSImageupload.Initialize(key);
- System.out.println("OSS初始化成功。");
}else if(key.getStorageType()==3){
USSImageupload.Initialize(key);
- System.out.println("USS初始化成功。");
}else if(key.getStorageType()==4){
KODOImageupload.Initialize(key);
- System.out.println("KODO初始化成功。");
}else if(key.getStorageType()==6){
COSImageupload.Initialize(key);
- System.out.println("COS初始化成功。");
}
else{
Print.Normal("为获取到存储参数,或者使用存储源是本地的。");
@@ -112,8 +104,12 @@ public class UpdateImgController {
model.addAttribute("suffix", uploadConfig.getSuffix());
model.addAttribute("config", config);
model.addAttribute("uploadConfig", uploadConfig);
-
- //return "index_upload";
+ Integer isupdate = 1;
+ if(uploadConfig.getIsupdate()!=1){
+ isupdate = (u == null) ? 0: 1;//如果u等于null那么isupdate就等于0,否则等于1
+ //isupdate=0;
+ }
+ model.addAttribute("ykxz", isupdate);
return "index";
}
@@ -124,95 +120,95 @@ public class UpdateImgController {
, @RequestParam(value = "file", required = false) MultipartFile[] file) throws Exception {
Config config = configService.getSourceype();//查询当前系统使用的存储源类型。
UploadConfig uploadConfig = uploadConfigService.getUpdateConfig();
+ User u = (User) session.getAttribute("user");
JSONArray jsonArray = new JSONArray();
JSONObject jsonObject = new JSONObject();
Keys key = keysService.selectKeys(config.getSourcekey());
- Boolean b = StringUtils.doNull(key);//判断对象是否有空值
-
- if(b){
- long stime = System.currentTimeMillis();
- User u = (User) session.getAttribute("user");
- String userpath = "tourist";
- if(uploadConfig.getUrltype()==2){
- java.text.DateFormat dateFormat = new java.text.SimpleDateFormat("yyyy/MM/dd");
- userpath = dateFormat.format(new Date());
- }else{
- if (u != null) {
- userpath = u.getUsername();
- }
- }
- Map map = new HashMap<>();
- for (MultipartFile multipartFile : file) {
- // 获取ImageReader对象的迭代器
- //获取文件名
- String fileName = multipartFile.getOriginalFilename();
- String lastname = fileName.substring(fileName.lastIndexOf(".") + 1);//获取文件后缀
- if (!multipartFile.isEmpty()) { //判断文件是否为空
- map.put(lastname, multipartFile);
- //multipartFile.getOriginalFilename(); //文件名
- //multipartFile.getSize(); //文件大小
- }
- }
- Map m = null;
- if(key.getStorageType()==1){
- m = nOSImageupload.Imageupload(map, userpath,null);
- }else if (key.getStorageType()==2){
- m = ossImageupload.ImageuploadOSS(map, userpath,null);
- }else if(key.getStorageType()==3){
- m = ussImageupload.ImageuploadUSS(map, userpath,null);
- }else if(key.getStorageType()==4){
- m = kodoImageupload.ImageuploadKODO(map, userpath,null);
- }else if(key.getStorageType()==5){
- m = LocUpdateImg.ImageuploadLOC(map, userpath,null);
- }else if(key.getStorageType()==6){
- m = cosImageupload.ImageuploadCOS(map, userpath,null);
- }
- else{
- System.err.println("未获取到对象存储参数,上传失败。");
- }
- Images img = new Images();
- SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
- String times = df.format(new Date());
- System.out.println("上传图片的时间是:"+times);
- for (Map.Entry entry : m.entrySet()) {
- if(key.getStorageType()==5){
- if(config.getDomain()!=null){
- jsonObject.put("imgurls",config.getDomain()+"/links/"+entry.getKey().getImgurl());
- jsonObject.put("imgnames",entry.getKey().getImgname());
- //jsonArray.add(config.getDomain()+"/links/"+entry.getKey().getImgurl());
- img.setImgurl(config.getDomain()+"/links/"+entry.getKey().getImgurl());//图片链接
- }else{
- jsonObject.put("imgurls",config.getDomain()+"/links/"+entry.getKey().getImgurl());
- jsonObject.put("imgnames",entry.getKey().getImgname());
- //jsonArray.add(config.getDomain()+"/links/"+entry.getKey().getImgurl());
- img.setImgurl("http://"+IPPortUtil.getLocalIP()+":"+IPPortUtil.getLocalPort()+"/links/"+entry.getKey().getImgurl());//图片链接
- }
- }else{
- jsonObject.put("imgurls",entry.getKey().getImgurl());
- jsonObject.put("imgnames",entry.getKey().getImgname());
- //jsonArray.add(entry.getKey());
- img.setImgurl(entry.getKey().getImgurl());//图片链接
- }
- jsonArray.add(jsonObject);
- img.setUpdatetime(times);
- img.setSource(key.getStorageType());
- if (u == null) {
- img.setUserid(0);//用户id
- } else {
- img.setUserid(u.getId());//用户id
- }
- img.setSizes((entry.getValue()) / 1024);
- img.setImgname(SetText.getSubString(entry.getKey().getImgurl(), key.getRequestAddress() + "/", ""));
- img.setAbnormal(0);
- userService.insertimg(img);
- long etime = System.currentTimeMillis();
- System.out.println("上传图片所用时长:" + String.valueOf(etime - stime) + "ms");
- }
-
+ Boolean b =false;
+ if(config.getSourcekey()==5){
+ b =true;
}else{
- //jsonArray.add(-1);
- jsonObject.put("imgurls",-1);
+ b = StringUtils.doNull(config.getSourcekey(),key);//判断对象是否有空值
}
+ if(b){
+ long stime = System.currentTimeMillis();
+ String userpath = "tourist";
+ if(uploadConfig.getUrltype()==2){
+ java.text.DateFormat dateFormat = new java.text.SimpleDateFormat("yyyy/MM/dd");
+ userpath = dateFormat.format(new Date());
+ }else{
+ if (u != null) {
+ userpath = u.getUsername();
+ }
+ }
+ Map map = new HashMap<>();
+ for (MultipartFile multipartFile : file) {
+ // 获取ImageReader对象的迭代器
+ //获取文件名
+ String fileName = multipartFile.getOriginalFilename();
+ String lastname = fileName.substring(fileName.lastIndexOf(".") + 1);//获取文件后缀
+ if (!multipartFile.isEmpty()) { //判断文件是否为空
+ map.put(lastname, multipartFile);
+ //multipartFile.getOriginalFilename(); //文件名
+ //multipartFile.getSize(); //文件大小
+ }
+ }
+ Map m = null;
+ if(key.getStorageType()==1){
+ m = nOSImageupload.Imageupload(map, userpath,null);
+ }else if (key.getStorageType()==2){
+ m = ossImageupload.ImageuploadOSS(map, userpath,null);
+ }else if(key.getStorageType()==3){
+ m = ussImageupload.ImageuploadUSS(map, userpath,null);
+ }else if(key.getStorageType()==4){
+ m = kodoImageupload.ImageuploadKODO(map, userpath,null);
+ }else if(key.getStorageType()==5){
+ m = LocUpdateImg.ImageuploadLOC(map, userpath,null);
+ }else if(key.getStorageType()==6){
+ m = cosImageupload.ImageuploadCOS(map, userpath,null);
+ }
+ else{
+ System.err.println("未获取到对象存储参数,上传失败。");
+ }
+ Images img = new Images();
+ SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
+ String times = df.format(new Date());
+ System.out.println("上传图片的时间是:"+times);
+ for (Map.Entry entry : m.entrySet()) {
+ if(key.getStorageType()==5){
+ if(config.getDomain()!=null){
+ jsonObject.put("imgurls",config.getDomain()+"/links/"+entry.getKey().getImgurl());
+ jsonObject.put("imgnames",entry.getKey().getImgname());
+ img.setImgurl(config.getDomain()+"/links/"+entry.getKey().getImgurl());//图片链接
+ }else{
+ jsonObject.put("imgurls",config.getDomain()+"/links/"+entry.getKey().getImgurl());
+ jsonObject.put("imgnames",entry.getKey().getImgname());
+ img.setImgurl("http://"+IPPortUtil.getLocalIP()+":"+IPPortUtil.getLocalPort()+"/links/"+entry.getKey().getImgurl());//图片链接
+ }
+ }else{
+ jsonObject.put("imgurls",entry.getKey().getImgurl());
+ jsonObject.put("imgnames",entry.getKey().getImgname());
+ img.setImgurl(entry.getKey().getImgurl());//图片链接
+ }
+ jsonArray.add(jsonObject);
+ img.setUpdatetime(times);
+ img.setSource(key.getStorageType());
+ if (u == null) {
+ img.setUserid(0);
+ } else {
+ img.setUserid(u.getId());//用户id
+ }
+ img.setSizes((entry.getValue()) / 1024);
+ img.setImgname(SetText.getSubString(entry.getKey().getImgurl(), key.getRequestAddress() + "/", ""));
+ img.setAbnormal(0);
+ userService.insertimg(img);
+ long etime = System.currentTimeMillis();
+ System.out.println("上传图片所用时长:" + String.valueOf(etime - stime) + "ms");
+ }
+
+ }else{
+ jsonObject.put("imgurls",-1);
+ }
//开辟新进程鉴黄。现在已经改成定时器
//查询鉴黄功能是否启动,1为启用
@@ -223,7 +219,6 @@ public class UpdateImgController {
// thread.start();
// }
System.out.println(jsonArray.toString());
-
return jsonObject.toString();
}
@@ -251,181 +246,187 @@ public class UpdateImgController {
Integer youke = uploadConfig.getFilesizetourists();
Integer yonghu = uploadConfig.getFilesizeuser();
String uuid= UUID.randomUUID().toString().replace("-", "");
- Boolean isnull = StringUtils.doNull(key);//判断对象是否有空值
+ Boolean bo =false;
+ if(config.getSourcekey()==5){
+ bo =true;
+ }else{
+ bo = StringUtils.doNull(config.getSourcekey(),key);//判断对象是否有空值
+ }
//先判断对象存储key是不是null
Print.warning("上传地址是:"+request.getSession().getServletContext().getRealPath("/")+"/hellohaotmp/");
- if(isnull){
- long stime = System.currentTimeMillis();
- //判断是会员还是游客
- if(u!=null){
- //判断文件大小
- if(imgsize>0 && imgsize<=(yonghu*1024*1024)){
- try{
- boolean bl =ImgUrlUtil.downLoadFromUrl(imgurl,
- uuid, request.getSession().getServletContext().getRealPath("/")+"/hellohaotmp/");
- if(bl==true){
- FileInputStream is = new FileInputStream(request.getSession().getServletContext().getRealPath("/")+"/hellohaotmp/"+uuid);
- byte[] b = new byte[3];
- is.read(b, 0, b.length);
- String xxx = ImgUrlUtil.bytesToHexString(b);
- xxx = xxx.toUpperCase();
- System.out.println("头文件是:" + xxx);
- String ooo = TypeDict.checkType(xxx);
- System.out.println("后缀名是:" + ooo);
- if(is!=null){
- is.close();
- }
- //判断文件头是否是图片
- if(!ooo.equals("0000")){
- Map map = new HashMap<>();
- map.put(ooo, request.getSession().getServletContext().getRealPath("/")+"/hellohaotmp/"+uuid);
- Map m = null;
- if(key.getStorageType()==1){
- m = nOSImageupload.Imageupload(null, userpath,map);
- }else if (key.getStorageType()==2){
- m = ossImageupload.ImageuploadOSS(null, userpath,map);
- }else if(key.getStorageType()==3){
- m = ussImageupload.ImageuploadUSS(null, userpath,map);
- }else if(key.getStorageType()==4){
- m = kodoImageupload.ImageuploadKODO(null, userpath,map);
- }else if(key.getStorageType()==5){
- m = LocUpdateImg.ImageuploadLOC(null,userpath,map);
- }else if(key.getStorageType()==6){
- m = cosImageupload.ImageuploadCOS(null,userpath,map);
+ if(bo){
+ long stime = System.currentTimeMillis();
+ //判断是会员还是游客
+ if(u!=null){
+ //判断文件大小
+ if(imgsize>0 && imgsize<=(yonghu*1024*1024)){
+ try{
+ boolean bl =ImgUrlUtil.downLoadFromUrl(imgurl,
+ uuid, request.getSession().getServletContext().getRealPath("/")+"/hellohaotmp/");
+ if(bl==true){
+ FileInputStream is = new FileInputStream(request.getSession().getServletContext().getRealPath("/")+"/hellohaotmp/"+uuid);
+ byte[] b = new byte[3];
+ is.read(b, 0, b.length);
+ String xxx = ImgUrlUtil.bytesToHexString(b);
+ xxx = xxx.toUpperCase();
+ System.out.println("头文件是:" + xxx);
+ String ooo = TypeDict.checkType(xxx);
+ System.out.println("后缀名是:" + ooo);
+ if(is!=null){
+ is.close();
}
- else{
- System.err.println("未获取到对象存储参数,上传失败。");
- }
- Images img = new Images();
- SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
- String times = df.format(new Date());
- System.out.println("上传图片的时间是:"+times);
- for (Map.Entry entry : m.entrySet()) {
- if(key.getStorageType()==5){
- if(config.getDomain()!=null){
- jsonArray.add(config.getDomain()+"/links/"+entry.getKey().getImgurl());
- img.setImgurl(config.getDomain()+"/links/"+entry.getKey().getImgurl());//图片链接
+ //判断文件头是否是图片
+ if(!ooo.equals("0000")){
+ Map map = new HashMap<>();
+ map.put(ooo, request.getSession().getServletContext().getRealPath("/")+"/hellohaotmp/"+uuid);
+ Map m = null;
+ if(key.getStorageType()==1){
+ m = nOSImageupload.Imageupload(null, userpath,map);
+ }else if (key.getStorageType()==2){
+ m = ossImageupload.ImageuploadOSS(null, userpath,map);
+ }else if(key.getStorageType()==3){
+ m = ussImageupload.ImageuploadUSS(null, userpath,map);
+ }else if(key.getStorageType()==4){
+ m = kodoImageupload.ImageuploadKODO(null, userpath,map);
+ }else if(key.getStorageType()==5){
+ m = LocUpdateImg.ImageuploadLOC(null,userpath,map);
+ }else if(key.getStorageType()==6){
+ m = cosImageupload.ImageuploadCOS(null,userpath,map);
+ }
+ else{
+ System.err.println("未获取到对象存储参数,上传失败。");
+ }
+ Images img = new Images();
+ SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
+ String times = df.format(new Date());
+ System.out.println("上传图片的时间是:"+times);
+ for (Map.Entry entry : m.entrySet()) {
+ if(key.getStorageType()==5){
+ if(config.getDomain()!=null){
+ jsonArray.add(config.getDomain()+"/links/"+entry.getKey().getImgurl());
+ img.setImgurl(config.getDomain()+"/links/"+entry.getKey().getImgurl());//图片链接
+ }else{
+ jsonArray.add(config.getDomain()+"/links/"+entry.getKey().getImgurl());
+ img.setImgurl("http://"+IPPortUtil.getLocalIP()+":"+IPPortUtil.getLocalPort()+"/links/"+entry.getKey().getImgurl());//图片链接
+ }
}else{
- jsonArray.add(config.getDomain()+"/links/"+entry.getKey().getImgurl());
- img.setImgurl("http://"+IPPortUtil.getLocalIP()+":"+IPPortUtil.getLocalPort()+"/links/"+entry.getKey().getImgurl());//图片链接
+ jsonArray.add(entry.getKey().getImgurl());
}
- }else{
- jsonArray.add(entry.getKey().getImgurl());
+ //img.setImgurl(entry.getKey());//图片链接
+ img.setUpdatetime(times);
+ img.setSource(key.getStorageType());
+ if (u == null) {
+ img.setUserid(0);//用户id
+ } else {
+ img.setUserid(u.getId());//用户id
+ }
+ img.setSizes((entry.getValue()));
+ img.setImgname(SetText.getSubString(entry.getKey().getImgurl(), key.getRequestAddress() + "/", ""));
+ img.setAbnormal(0);
+ userService.insertimg(img);
+ long etime = System.currentTimeMillis();
+ System.out.println("上传图片所用时长:" + String.valueOf(etime - stime) + "ms");
}
- //img.setImgurl(entry.getKey());//图片链接
- img.setUpdatetime(times);
- img.setSource(key.getStorageType());
- if (u == null) {
- img.setUserid(0);//用户id
- } else {
- img.setUserid(u.getId());//用户id
- }
- img.setSizes((entry.getValue()));
- img.setImgname(SetText.getSubString(entry.getKey().getImgurl(), key.getRequestAddress() + "/", ""));
- img.setAbnormal(0);
- userService.insertimg(img);
- long etime = System.currentTimeMillis();
- System.out.println("上传图片所用时长:" + String.valueOf(etime - stime) + "ms");
+ }else{
+ jsonArray.add(-3);
}
- }else{
- jsonArray.add(-3);
}
+ }catch (Exception e) {
+ // TODO: handle exception
+ Print.warning(e.toString());
+ jsonArray.add(-4);
}
- }catch (Exception e) {
- // TODO: handle exception
- Print.warning(e.toString());
- jsonArray.add(-4);
+ }else{
+ //文件过大
+ jsonArray.add(-2);
}
}else{
- //文件过大
- jsonArray.add(-2);
+ if(imgsize>0 && imgsize<=(youke*1024*1024)){
+ try{
+ boolean bl = ImgUrlUtil.downLoadFromUrl(imgurl,
+ uuid, request.getSession().getServletContext().getRealPath("/")+"/hellohaotmp/");
+ if(bl==true){
+ FileInputStream is = new FileInputStream(request.getSession().getServletContext().getRealPath("/")+"/hellohaotmp/"+uuid);
+ byte[] b = new byte[3];
+ is.read(b, 0, b.length);
+ String xxx = ImgUrlUtil.bytesToHexString(b);
+ xxx = xxx.toUpperCase();
+ //System.out.println("头文件是:" + xxx);
+ String ooo = TypeDict.checkType(xxx);
+ //System.out.println("后缀名是:" + ooo);
+ if(is!=null){
+ is.close();
+ }
+ //判断文件头是否是图片
+ if(!xxx.equals("0000")){
+ Map map = new HashMap<>();
+ map.put(ooo, request.getSession().getServletContext().getRealPath("/")+"/hellohaotmp/"+uuid);
+ Map m = null;
+ if(key.getStorageType()==1){
+ m = nOSImageupload.Imageupload(null, userpath,map);
+ }else if (key.getStorageType()==2){
+ m = ossImageupload.ImageuploadOSS(null, userpath,map);
+ }else if(key.getStorageType()==3){
+ m = ussImageupload.ImageuploadUSS(null, userpath,map);
+ }else if(key.getStorageType()==4){
+ m = kodoImageupload.ImageuploadKODO(null, userpath,map);
+ }else if(key.getStorageType()==5){
+ m =LocUpdateImg.ImageuploadLOC(null,userpath, map);
+ }else if(key.getStorageType()==6){
+ m =cosImageupload.ImageuploadCOS(null,userpath, map);
+ }
+ else{
+ System.err.println("未获取到对象存储参数,上传失败。");
+ }
+ Images img = new Images();
+ SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
+ String times = df.format(new Date());
+ System.out.println("上传图片的时间是:"+times);
+ for (Map.Entry entry : m.entrySet()) {
+ if(key.getStorageType()==5){
+ if(config.getDomain()!=null){
+ jsonArray.add(config.getDomain()+"/links/"+entry.getKey().getImgurl());
+ img.setImgurl(config.getDomain()+"/links/"+entry.getKey().getImgurl());//图片链接
+ }else{
+ jsonArray.add(config.getDomain()+"/links/"+entry.getKey().getImgurl());
+ img.setImgurl("http://"+IPPortUtil.getLocalIP()+":"+IPPortUtil.getLocalPort()+"/links/"+entry.getKey().getImgurl());//图片链接
+ }
+ }else{
+ jsonArray.add(entry.getKey().getImgurl());
+ }
+ //img.setImgurl(entry.getKey());//图片链接
+ img.setUpdatetime(times);
+ img.setSource(key.getStorageType());
+ if (u == null) {
+ img.setUserid(0);//用户id
+ } else {
+ img.setUserid(u.getId());//用户id
+ }
+ img.setSizes((entry.getValue()));
+ img.setImgname(SetText.getSubString(entry.getKey().getImgurl(), key.getRequestAddress() + "/", ""));
+ img.setAbnormal(0);
+ userService.insertimg(img);
+ long etime = System.currentTimeMillis();
+ System.out.println("上传图片所用时长:" + String.valueOf(etime - stime) + "ms");
+ }
+ }else{
+ jsonArray.add(-3);
+ }
+ }
+ }catch (Exception e) {
+ // TODO: handle exception
+ Print.warning(e.toString());
+ jsonArray.add(-4);
+ }
+ }else{
+ //文件过大
+ jsonArray.add(-2);
+ }
}
}else{
- if(imgsize>0 && imgsize<=(youke*1024*1024)){
- try{
- boolean bl = ImgUrlUtil.downLoadFromUrl(imgurl,
- uuid, request.getSession().getServletContext().getRealPath("/")+"/hellohaotmp/");
- if(bl==true){
- FileInputStream is = new FileInputStream(request.getSession().getServletContext().getRealPath("/")+"/hellohaotmp/"+uuid);
- byte[] b = new byte[3];
- is.read(b, 0, b.length);
- String xxx = ImgUrlUtil.bytesToHexString(b);
- xxx = xxx.toUpperCase();
- //System.out.println("头文件是:" + xxx);
- String ooo = TypeDict.checkType(xxx);
- //System.out.println("后缀名是:" + ooo);
- if(is!=null){
- is.close();
- }
- //判断文件头是否是图片
- if(!xxx.equals("0000")){
- Map map = new HashMap<>();
- map.put(ooo, request.getSession().getServletContext().getRealPath("/")+"/hellohaotmp/"+uuid);
- Map m = null;
- if(key.getStorageType()==1){
- m = nOSImageupload.Imageupload(null, userpath,map);
- }else if (key.getStorageType()==2){
- m = ossImageupload.ImageuploadOSS(null, userpath,map);
- }else if(key.getStorageType()==3){
- m = ussImageupload.ImageuploadUSS(null, userpath,map);
- }else if(key.getStorageType()==4){
- m = kodoImageupload.ImageuploadKODO(null, userpath,map);
- }else if(key.getStorageType()==5){
- m =LocUpdateImg.ImageuploadLOC(null,userpath, map);
- }else if(key.getStorageType()==6){
- m =cosImageupload.ImageuploadCOS(null,userpath, map);
- }
- else{
- System.err.println("未获取到对象存储参数,上传失败。");
- }
- Images img = new Images();
- SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
- String times = df.format(new Date());
- System.out.println("上传图片的时间是:"+times);
- for (Map.Entry entry : m.entrySet()) {
- if(key.getStorageType()==5){
- if(config.getDomain()!=null){
- jsonArray.add(config.getDomain()+"/links/"+entry.getKey().getImgurl());
- img.setImgurl(config.getDomain()+"/links/"+entry.getKey().getImgurl());//图片链接
- }else{
- jsonArray.add(config.getDomain()+"/links/"+entry.getKey().getImgurl());
- img.setImgurl("http://"+IPPortUtil.getLocalIP()+":"+IPPortUtil.getLocalPort()+"/links/"+entry.getKey().getImgurl());//图片链接
- }
- }else{
- jsonArray.add(entry.getKey().getImgurl());
- }
- //img.setImgurl(entry.getKey());//图片链接
- img.setUpdatetime(times);
- img.setSource(key.getStorageType());
- if (u == null) {
- img.setUserid(0);//用户id
- } else {
- img.setUserid(u.getId());//用户id
- }
- img.setSizes((entry.getValue()));
- img.setImgname(SetText.getSubString(entry.getKey().getImgurl(), key.getRequestAddress() + "/", ""));
- img.setAbnormal(0);
- userService.insertimg(img);
- long etime = System.currentTimeMillis();
- System.out.println("上传图片所用时长:" + String.valueOf(etime - stime) + "ms");
- }
- }else{
- jsonArray.add(-3);
- }
- }
- }catch (Exception e) {
- // TODO: handle exception
- Print.warning(e.toString());
- jsonArray.add(-4);
- }
- }else{
- //文件过大
- jsonArray.add(-2);
- }
+ jsonArray.add(-1);
}
- }else{
- jsonArray.add(-1);
- }
+
return jsonArray.toString();
/**
* 错误返回值含义:
diff --git a/src/main/java/cn/hellohao/pojo/UploadConfig.java b/src/main/java/cn/hellohao/pojo/UploadConfig.java
index 308b5ee..09fca85 100644
--- a/src/main/java/cn/hellohao/pojo/UploadConfig.java
+++ b/src/main/java/cn/hellohao/pojo/UploadConfig.java
@@ -7,17 +7,19 @@ public class UploadConfig {
private Integer imgcounttourists;
private Integer imgcountuser;
private Integer urltype;
+ private Integer isupdate;
public UploadConfig() {
}
- public UploadConfig(String suffix, Integer filesizetourists, Integer filesizeuser, Integer imgcounttourists, Integer imgcountuser, Integer urltype) {
+ public UploadConfig(String suffix, Integer filesizetourists, Integer filesizeuser, Integer imgcounttourists, Integer imgcountuser, Integer urltype, Integer isupdate) {
this.suffix = suffix;
this.filesizetourists = filesizetourists;
this.filesizeuser = filesizeuser;
this.imgcounttourists = imgcounttourists;
this.imgcountuser = imgcountuser;
this.urltype = urltype;
+ this.isupdate = isupdate;
}
public String getSuffix() {
@@ -67,4 +69,12 @@ public class UploadConfig {
public void setUrltype(Integer urltype) {
this.urltype = urltype;
}
+
+ public Integer getIsupdate() {
+ return isupdate;
+ }
+
+ public void setIsupdate(Integer isupdate) {
+ this.isupdate = isupdate;
+ }
}
diff --git a/src/main/java/cn/hellohao/service/impl/COSImageupload.java b/src/main/java/cn/hellohao/service/impl/COSImageupload.java
index 4fc8e47..723c1f0 100644
--- a/src/main/java/cn/hellohao/service/impl/COSImageupload.java
+++ b/src/main/java/cn/hellohao/service/impl/COSImageupload.java
@@ -111,36 +111,37 @@ public class COSImageupload {
return file;
}
-
-
-
//初始化网易NOS对象存储
public static void Initialize(Keys k) {
+ if(k.getEndpoint()!=null && k.getAccessSecret()!=null && k.getEndpoint()!=null
+ && k.getBucketname()!=null && k.getRequestAddress()!=null ) {
// 1 初始化用户身份信息(secretId, secretKey)。
- String secretId = k.getAccessKey();
- String secretKey = k.getAccessSecret();
- COSCredentials cred = new BasicCOSCredentials(secretId, secretKey);
+ String secretId = k.getAccessKey();
+ String secretKey = k.getAccessSecret();
+ COSCredentials cred = new BasicCOSCredentials(secretId, secretKey);
// 2 设置 bucket 的区域, COS 地域的简称请参照 https://cloud.tencent.com/document/product/436/6224
// clientConfig 中包含了设置 region, https(默认 http), 超时, 代理等 set 方法, 使用可参见源码或者常见问题 Java SDK 部分。
- Region region = new Region(k.getEndpoint());
- ClientConfig clientConfig = new ClientConfig(region);
+ Region region = new Region(k.getEndpoint());
+ ClientConfig clientConfig = new ClientConfig(region);
// 3 生成 cos 客户端。
- cosClient= new COSClient(cred, clientConfig);
+ cosClient = new COSClient(cred, clientConfig);
+ System.out.println("==="+cosClient);
//查询桶
- try {
- List buckets = cosClient.listBuckets();
- for (Bucket bucket : buckets) {
- if(bucket.getName().equals(k.getBucketname())){
- Print.Normal("当前桶名称:"+bucket.getName());
- BarrelName = bucket.getName();
+ try {
+ List buckets = cosClient.listBuckets();
+ for (Bucket bucket : buckets) {
+ if (bucket.getName().equals(k.getBucketname())) {
+ Print.Normal("当前桶名称:" + bucket.getName());
+ BarrelName = bucket.getName();
+ }
}
+ } catch (CosServiceException serverException) {
+ serverException.printStackTrace();
+ } catch (CosClientException clientException) {
+ clientException.printStackTrace();
}
- } catch (CosServiceException serverException) {
- serverException.printStackTrace();
- } catch (CosClientException clientException) {
- clientException.printStackTrace();
+ key = k;
}
- key = k;
}
/**
* 客户端接口
diff --git a/src/main/java/cn/hellohao/service/impl/KODOImageupload.java b/src/main/java/cn/hellohao/service/impl/KODOImageupload.java
index 7700032..8b870e4 100644
--- a/src/main/java/cn/hellohao/service/impl/KODOImageupload.java
+++ b/src/main/java/cn/hellohao/service/impl/KODOImageupload.java
@@ -45,6 +45,7 @@ public class KODOImageupload {
//ossClient.putObject(key.getBucketname(), username + "/" + uuid+times + "." + entry.getKey(),file,meta);
try {
Response response = uploadManager.put(file,username + "/" + uuid+times + "." + entry.getKey(),upToken);
+ System.out.println(response);
//解析上传成功的结果
DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class);
ReturnImage returnImage = new ReturnImage();
@@ -112,19 +113,28 @@ public class KODOImageupload {
//初始化
public static void Initialize(Keys k) {
- // 初始化
- // 创建KODOClient实例。
- Configuration cfg;
- //构造一个带指定Zone对象的配置类
- if(k.getEndpoint().equals("1")){cfg = new Configuration(Zone.zone0());}
- else if(k.getEndpoint().equals("2")){cfg = new Configuration(Zone.zone1());}
- else if(k.getEndpoint().equals("3")){cfg = new Configuration(Zone.zone2());}
- else if(k.getEndpoint().equals("4")){cfg = new Configuration(Zone.zoneNa0());}
- else{cfg = new Configuration(Zone.zoneAs0());}
- uploadManager = new UploadManager(cfg);
- Auth auth = Auth.create(k.getAccessKey(), k.getAccessSecret());
- upToken = auth.uploadToken(k.getBucketname());
- key = k;
+ if (k.getEndpoint() != null && k.getAccessSecret() != null && k.getEndpoint() != null
+ && k.getBucketname() != null && k.getRequestAddress() != null) {
+ // 初始化
+ // 创建KODOClient实例。
+ Configuration cfg;
+ //构造一个带指定Zone对象的配置类
+ if (k.getEndpoint().equals("1")) {
+ cfg = new Configuration(Zone.zone0());
+ } else if (k.getEndpoint().equals("2")) {
+ cfg = new Configuration(Zone.zone1());
+ } else if (k.getEndpoint().equals("3")) {
+ cfg = new Configuration(Zone.zone2());
+ } else if (k.getEndpoint().equals("4")) {
+ cfg = new Configuration(Zone.zoneNa0());
+ } else {
+ cfg = new Configuration(Zone.zoneAs0());
+ }
+ uploadManager = new UploadManager(cfg);
+ Auth auth = Auth.create(k.getAccessKey(), k.getAccessSecret());
+ upToken = auth.uploadToken(k.getBucketname());
+ key = k;
+ }
}
/**
diff --git a/src/main/java/cn/hellohao/service/impl/NOSImageupload.java b/src/main/java/cn/hellohao/service/impl/NOSImageupload.java
index f168d93..8faa0b1 100644
--- a/src/main/java/cn/hellohao/service/impl/NOSImageupload.java
+++ b/src/main/java/cn/hellohao/service/impl/NOSImageupload.java
@@ -125,27 +125,29 @@ public class NOSImageupload {
}
-
-
//初始化网易NOS对象存储
public static void Initialize(Keys k) {
- // 初始化
- Credentials credentials = new BasicCredentials(k.getAccessKey(), k.getAccessSecret());
- nosClient = new NosClient(credentials);
- nosClient.setEndpoint(k.getEndpoint());
- // 初始化TransferManager
- TransferManager transferManager = new TransferManager(nosClient);
- // 列举桶
- ArrayList bucketList = new ArrayList();
- for (Bucket bucket : nosClient.listBuckets()) {
- bucketList.add(bucket.getName());
- }
- for (Object object : bucketList) {
- if (object.toString().equals(k.getBucketname())) {
- BarrelName = object.toString();
+ if(k.getEndpoint()!=null && k.getAccessSecret()!=null && k.getEndpoint()!=null
+ && k.getBucketname()!=null && k.getRequestAddress()!=null ){
+ // 初始化
+ Credentials credentials = new BasicCredentials(k.getAccessKey(), k.getAccessSecret());
+ nosClient = new NosClient(credentials);
+ nosClient.setEndpoint(k.getEndpoint());
+ // 初始化TransferManager
+ TransferManager transferManager = new TransferManager(nosClient);
+ // 列举桶
+ ArrayList bucketList = new ArrayList();
+ for (Bucket bucket : nosClient.listBuckets()) {
+ bucketList.add(bucket.getName());
}
+ for (Object object : bucketList) {
+ if (object.toString().equals(k.getBucketname())) {
+ BarrelName = object.toString();
+ }
+ }
+ key = k;
}
- key = k;
+
}
/**
diff --git a/src/main/java/cn/hellohao/service/impl/OSSImageupload.java b/src/main/java/cn/hellohao/service/impl/OSSImageupload.java
index 9f8ef2a..0baff3e 100644
--- a/src/main/java/cn/hellohao/service/impl/OSSImageupload.java
+++ b/src/main/java/cn/hellohao/service/impl/OSSImageupload.java
@@ -114,10 +114,13 @@ public class OSSImageupload {
//初始化
public static void Initialize(Keys k) {
- // 初始化
- // 创建OSSClient实例。
- ossClient = new OSSClient(k.getEndpoint(), k.getAccessKey(), k.getAccessSecret());
- key = k;
+ if(k.getEndpoint()!=null && k.getAccessSecret()!=null && k.getEndpoint()!=null
+ && k.getBucketname()!=null && k.getRequestAddress()!=null ) {
+ // 初始化
+ // 创建OSSClient实例。
+ ossClient = new OSSClient(k.getEndpoint(), k.getAccessKey(), k.getAccessSecret());
+ key = k;
+ }
}
diff --git a/src/main/java/cn/hellohao/service/impl/USSImageupload.java b/src/main/java/cn/hellohao/service/impl/USSImageupload.java
index daf734e..0c3e850 100644
--- a/src/main/java/cn/hellohao/service/impl/USSImageupload.java
+++ b/src/main/java/cn/hellohao/service/impl/USSImageupload.java
@@ -92,10 +92,13 @@ public class USSImageupload {
//初始化
public static void Initialize(Keys k) {
- // 初始化
- // 创建UpYun实例。
- upyun = new UpYun(k.getBucketname(), k.getAccessKey(), k.getAccessSecret());
- key = k;
+ if(k.getEndpoint()!=null && k.getAccessSecret()!=null
+ && k.getBucketname()!=null && k.getRequestAddress()!=null ) {
+ // 初始化
+ // 创建UpYun实例。
+ upyun = new UpYun(k.getBucketname(), k.getAccessKey(), k.getAccessSecret());
+ key = k;
+ }
}
diff --git a/src/main/java/cn/hellohao/utils/StringUtils.java b/src/main/java/cn/hellohao/utils/StringUtils.java
index f37f98c..f3cb8ab 100644
--- a/src/main/java/cn/hellohao/utils/StringUtils.java
+++ b/src/main/java/cn/hellohao/utils/StringUtils.java
@@ -7,128 +7,42 @@ import java.util.Collection;
import java.util.Map;
public class StringUtils {
- public static Boolean doNull(Object objs){
- Field[] fields = objs.getClass().getDeclaredFields();
- //用于判断所有属性是否为空,如果参数为空则不查询
- boolean flag = true;
- for (Field field : fields) {
- //不检查 直接取值
- field.setAccessible(true);
+ //接受当前使用的存储源id,在根据id进行非空判断
+ public static Boolean doNull(Integer sourcekey,Keys k) {
+ if(sourcekey==1){
+ //网易
+ if(k.getEndpoint()!=null && k.getAccessSecret()!=null && k.getEndpoint()!=null
+ && k.getBucketname()!=null && k.getRequestAddress()!=null ){
+ return true;
+ }
+ }else if(sourcekey==2){
+ //阿里
+ if(k.getEndpoint()!=null && k.getAccessSecret()!=null && k.getEndpoint()!=null
+ && k.getBucketname()!=null && k.getRequestAddress()!=null ) {
+ return true;
+ }
+ }else if(sourcekey==3){
+ //又拍
+ if(k.getEndpoint()!=null && k.getAccessSecret()!=null
+ && k.getBucketname()!=null && k.getRequestAddress()!=null ) {
+ return true;
+ }
- try {
- if(StringUtils.isNull(field.get(objs))) {
- //不为空
- flag = false;
- //当有任何一个参数不为空的时候则跳出判断直接查询
- //break;
- }
- } catch (IllegalArgumentException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
+ }else if(sourcekey==4){
+ //七牛
+ if (k.getEndpoint() != null && k.getAccessSecret() != null && k.getEndpoint() != null
+ && k.getBucketname() != null && k.getRequestAddress() != null) {
+ return true;
+ }
+
+ }else if(sourcekey==6){
+ //腾讯
+ if(k.getEndpoint()!=null && k.getAccessSecret()!=null && k.getEndpoint()!=null
+ && k.getBucketname()!=null && k.getRequestAddress()!=null ) {
+ return true;
}
}
- return flag;
- }
- public final static boolean isNull(Object[] objs) {
- if (objs == null || objs.length == 0)
- return true;
-
-
- return false;
-
- }
-
-
- public final static boolean isNull(Object obj) {
- if (obj == null || isNull(obj.toString())) {
- return true;
- }
-
-
return false;
}
-
- public final static boolean isNull(Integer integer) {
- if (integer == null || integer == 0)
- return true;
-
-
- return false;
-
- }
-
-
- public final static boolean isNull(Collection collection) {
- if (collection == null || collection.size() == 0)
- return true;
-
-
- return false;
- }
-
-
- public final static boolean isNull(Map map) {
- if (map == null || map.size() == 0)
- return true;
-
-
- return false;
- }
-
-
- public final static boolean isNull(String str) {
- return str == null || "".equals(str.trim()) || "null".equals(str.toLowerCase());
- }
-
-
- public final static boolean isNull(Long longs) {
- if (longs == null || longs == 0)
- return true;
-
-
- return false;
- }
-
-
- public final static boolean isNotNull(Long longs) {
- return !isNull(longs);
-
- }
-
-
- public final static boolean isNotNull(String str) {
- return !isNull(str);
- }
-
-
- public final static boolean isNotNull(Collection collection) {
- return !isNull(collection);
- }
-
-
- public final static boolean isNotNull(Map map) {
- return !isNull(map);
- }
-
-
- public final static boolean isNotNull(Integer integer) {
- return !isNull(integer);
-
- }
-
-
- public final static boolean isNotNull(Object[] objs) {
- return !isNull(objs);
-
- }
-
-
- public final static boolean isNotNull(Object obj) {
- return !isNull(obj);
-
- }
-
-
}
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 48911a9..cdefae1 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -1,4 +1,4 @@
-#ݿ˺picturebed
+#ݿ˺
spring.datasource.username=root
#ݿ
spring.datasource.password=root
@@ -24,6 +24,7 @@ multipart.maxFileSize=10240KB
multipart.maxRequestSize=10240KB
spring.thymeleaf.mode = LEGACYHTML5
spring.http.multipart.location=/data/upload_tmp
+systemupdate=2019-07-26
diff --git a/src/main/resources/mapper/UploadConfigMapper.xml b/src/main/resources/mapper/UploadConfigMapper.xml
index 2564389..269e8e8 100644
--- a/src/main/resources/mapper/UploadConfigMapper.xml
+++ b/src/main/resources/mapper/UploadConfigMapper.xml
@@ -25,7 +25,10 @@
`suffix` = #{suffix},
- `urltype` = #{urltype}
+ `urltype` = #{urltype},
+
+
+ `isupdate` = #{isupdate}
diff --git a/src/main/resources/static/static/js/jquery-3.4.1.min.js b/src/main/resources/static/static/js/jquery-3.4.1.min.js
index be18fb4..dc4391d 100644
--- a/src/main/resources/static/static/js/jquery-3.4.1.min.js
+++ b/src/main/resources/static/static/js/jquery-3.4.1.min.js
@@ -5,4 +5,5 @@
*/
$.ajaxSetup({
cache: false
-});
\ No newline at end of file
+});
+
diff --git a/src/main/resources/static/webuploade/js/upload.js b/src/main/resources/static/webuploade/js/upload.js
index 180601a..8115ed6 100644
--- a/src/main/resources/static/webuploade/js/upload.js
+++ b/src/main/resources/static/webuploade/js/upload.js
@@ -140,37 +140,38 @@
}
// 实例化
- uploader = WebUploader.create({
- pick: {
- id: '#filePicker',
- label: '点击选择文件'
- },
- formData: {
- uid: 123
- },
- dnd: '#wrapper',
- paste: '#wrapper',
- swf: 'https://hellohao-cloud.oss-cn-beijing.aliyuncs.com/Uploader.swf',
- chunked: false,//分片上传
- chunkSize: 512 * 1024,
- server: '/upimg',
- method:'POST',
- // runtimeOrder: 'flash',
- compress: false,//不启用压缩
- resize: false,//尺寸不改变
- accept: {
- title: 'Images',
- //extensions: 'gif,jpg,jpeg,bmp,png',
- extensions:suffix,
- mimeTypes: 'image/*'
- },
+ if(ykxz==1){
+ uploader = WebUploader.create({
+ pick: {
+ id: '#filePicker',
+ label: '点击选择文件'
+ },
+ formData: {
+ uid: 123
+ },
+ dnd: '#wrapper',
+ paste: '#wrapper',
+ swf: 'https://hellohao-cloud.oss-cn-beijing.aliyuncs.com/Uploader.swf',
+ chunked: false,//分片上传
+ chunkSize: 512 * 1024,
+ server: '/upimg',
+ method:'POST',
+ // runtimeOrder: 'flash',
+ compress: false,//不启用压缩
+ resize: false,//尺寸不改变
+ accept: {
+ title: 'Images',
+ //extensions: 'gif,jpg,jpeg,bmp,png',
+ extensions:suffix,
+ mimeTypes: 'image/*'
+ },
- // 禁掉全局的拖拽功能。这样不会出现图片拖进页面的时候,把图片打开。
- disableGlobalDnd: true,
- fileNumLimit: imgcount, //做多允许上传几个
- //fileSizeLimit: 2000 * 1024 * 1024, // 200 M 文件总大小
- fileSingleSizeLimit: filesize // 50 M 单文件大小
- });
+ // 禁掉全局的拖拽功能。这样不会出现图片拖进页面的时候,把图片打开。
+ disableGlobalDnd: true,
+ fileNumLimit: imgcount, //做多允许上传几个
+ //fileSizeLimit: 2000 * 1024 * 1024, // 200 M 文件总大小
+ fileSingleSizeLimit: filesize // 50 M 单文件大小
+ });
// 拖拽时不接受 js, txt 文件。
uploader.on( 'dndAccept', function( items ) {
@@ -198,11 +199,20 @@
//alert(response.length);
//console.log(response.imgurls)
$("#address").css('display', 'block');
- if(response==-1){
- arr_url += '未配置存储源,请先后台配置存储源\r\n';
- arr_markdown += '未配置存储源,请先后台配置存储源\r\n';
- arr_html += '未配置存储源,请先后台配置存储源\r\n';
- }else{
+ if(response.imgurls==-100){
+ layui.use('layer', function () {
+ layer = layui.layer;
+ layer.msg("本站已禁用游客上传,请登录本站。", {icon: 2});
+ });
+ // arr_url += '未配置存储源,请先后台配置存储源\r\n';
+ // arr_markdown += '未配置存储源,请先后台配置存储源\r\n';
+ // arr_html += '未配置存储源,请先后台配置存储源\r\n';
+ }else if(response.imgurls==-1){
+ layui.use('layer', function () {
+ layer = layui.layer;
+ layer.msg("未配置存储源,或存储源配置不正确。", {icon: 2});
+ });
+ } else{
arr_url += response.imgurls + '\r\n';
arr_markdown += '\r\n';
arr_html += '
\r\n';
@@ -218,7 +228,11 @@
// 文件上传失败,显示上传出错
uploader.on( 'uploadError', function( file ) {
- alert("文件上传失败")
+ //alert("文件上传失败")
+ layui.use('layer', function () {
+ layer = layui.layer;
+ layer.msg("文件上传失败", {icon: 2});
+ });
});
// uploader.on('filesQueued', function() {
@@ -244,7 +258,10 @@
uploader.on('ready', function() {
window.uploader = uploader;
});
-
+ }
+ else{
+ $('#urlsc').html('已禁止游客上传,请登陆后使用')
+ }
// 当有文件添加进来时执行,负责view的创建
function addFile( file ) {
var $li = $( '' +
@@ -581,9 +598,27 @@
});
uploader.onError = function( code ) {
- if(code=='F_DUPLICATE'){alert('复制速度过快')}
- else if(code=='Q_EXCEED_NUM_LIMIT'){alert('单次上传数量受限制')}
- else if(code=='F_EXCEED_SIZE'){alert('图片大小受限制')}
+ if(code=='F_DUPLICATE'){
+ //alert('复制速度过快')
+ layui.use('layer', function () {
+ layer = layui.layer;
+ layer.msg("复制速度过快", {icon: 2});
+ });
+ }
+ else if(code=='Q_EXCEED_NUM_LIMIT'){
+ //alert('单次上传数量受限制')
+ layui.use('layer', function () {
+ layer = layui.layer;
+ layer.msg("单次上传数量受限制", {icon: 2});
+ });
+ }
+ else if(code=='F_EXCEED_SIZE'){
+ //alert('图片大小受限制')
+ layui.use('layer', function () {
+ layer = layui.layer;
+ layer.msg("图片大小受限制", {icon: 2});
+ });
+ }
else{alert( 'Eroor: ' + code );}
};
diff --git a/src/main/resources/templates/admin/about.html b/src/main/resources/templates/admin/about.html
new file mode 100644
index 0000000..3a6da6a
--- /dev/null
+++ b/src/main/resources/templates/admin/about.html
@@ -0,0 +1,73 @@
+
+
+
+
+ 关于系统
+
+
+
+
+
+
+
+
+
+
+
+
开发者:Hellohao
+
+
+
+
+
+
开发者交流群:32452345342
+
+
当前系统版本:2019-07-25 检查更新
+
+
支持一下作者吧:
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/resources/templates/admin/emailconfig.html b/src/main/resources/templates/admin/emailconfig.html
index 29a00cb..689c459 100644
--- a/src/main/resources/templates/admin/emailconfig.html
+++ b/src/main/resources/templates/admin/emailconfig.html
@@ -90,7 +90,16 @@
form.on('switch(switchTest)', function (data) {
if (this.checked == true) {
- emailconfig(1);
+ var emailname = $("#emailname").val();
+ var emails = $("#emails").val();
+ var emailkey = $("#emailkey").val();
+ var port = $("#port").val();
+ var emailurl = $("#emailurl").val();
+ if (emailname != "" && emails != "" && emailkey != "" && port !="" && emailurl !="") {
+ emailconfig(1);
+ }else{
+ layer.msg("开启失败,各项内容均不能为空", {icon: 2});
+ }
} else {
emailconfig(0);
}
diff --git a/src/main/resources/templates/admin/imageIdentify.html b/src/main/resources/templates/admin/imageIdentify.html
index be27d80..c0b9c53 100644
--- a/src/main/resources/templates/admin/imageIdentify.html
+++ b/src/main/resources/templates/admin/imageIdentify.html
@@ -71,7 +71,14 @@
// offset: '6px'
// });
if (this.checked == true) {
- imgreview(1);
+ var appid = $("#appid").val();
+ var apikey = $("#apikey").val();
+ var secretkey = $("#secretkey").val();
+ if (appid != "" && apikey != "" && secretkey != "") {
+ imgreview(1);
+ }else{
+ layer.msg("开启失败,各项内容不能为空", {icon: 2});
+ }
} else {
imgreview(0);
}
diff --git a/src/main/resources/templates/admin/index.html b/src/main/resources/templates/admin/index.html
index d377b16..5d472e8 100644
--- a/src/main/resources/templates/admin/index.html
+++ b/src/main/resources/templates/admin/index.html
@@ -94,7 +94,7 @@
- 系统功能
+ 开发者设置
-
@@ -135,6 +135,21 @@
+
+
+
+ 更 多
+
+
+ -
+
+ 关于系统
+
+
+
+
+
+
diff --git a/src/main/resources/templates/admin/setuser.html b/src/main/resources/templates/admin/setuser.html
index 8f29798..1a53799 100644
--- a/src/main/resources/templates/admin/setuser.html
+++ b/src/main/resources/templates/admin/setuser.html
@@ -19,9 +19,9 @@
用户名只可是英文或数字
@@ -47,6 +47,7 @@