mirror of
https://github.com/Hello-hao/Tbed.git
synced 2024-04-21 12:32:10 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8542ca2afc | ||
|
|
5feabe5bf3 | ||
|
|
10cafd8add | ||
|
|
e528b75c76 | ||
|
|
9d8827032e | ||
|
|
a190bc5077 | ||
|
|
6083ae97a3 | ||
|
|
95889c42ef | ||
|
|
9a6ce4d5eb | ||
|
|
fdfd8391e3 | ||
|
|
276d329276 | ||
|
|
2997d9ee72 | ||
|
|
c754825b93 | ||
|
|
723a9c15ab | ||
|
|
4c6a19a4ab | ||
|
|
d09b5c2656 | ||
|
|
68f175679f | ||
|
|
43cfc832a8 | ||
|
|
6df3267b18 | ||
|
|
b0562203c2 | ||
|
|
995582f7c6 | ||
|
|
e347ec2367 | ||
|
|
ffcd4dbf40 | ||
|
|
6ee1673d83 | ||
|
|
7b0db6fe16 | ||
|
|
1baed6a29a | ||
|
|
a4855adbe6 | ||
|
|
b0cd5ca51f | ||
|
|
00b2f58916 | ||
|
|
78b3206f65 |
@@ -1,6 +1,7 @@
|
||||
# Hellohao图像托管程序 - 也许这会是最优秀的图床程序
|
||||
|
||||

|
||||

|
||||
|
||||
|
||||

|
||||

|
||||
@@ -18,88 +19,101 @@
|
||||
|
||||
**存储源支持:**
|
||||
|
||||
开源版:`本地`,`阿里OSS`,`又拍USS`,`七牛KODO`,`腾讯COS`,`网易NOS`,`U-File`,`FTP`
|
||||
开源版:`本地`,`阿里OSS`,`又拍USS`,`七牛KODO`,`腾讯COS`,`网易NOS`,~~`U-File`~~,`FTP`
|
||||
|
||||
Core版:`本地`,`阿里OSS`,`又拍USS`,`七牛KODO`,`腾讯COS`,`网易NOS`,`U-File`,`FTP`,`Backblaze(B2)`,`百度云BOS`,`青云Qingstor`,`Ucloud US3`,`Minio`,`AWS S3`
|
||||
Core版:`本地`,`阿里OSS`,`又拍USS`,`七牛KODO`,`腾讯COS`,`网易NOS`,~~`U-File`~~,`FTP`,`Backblaze(B2)`,`百度云BOS`,`青云Qingstor`,`Ucloud US3`,`Minio`,`AWS S3`
|
||||
|
||||
|
||||
### 更新日志
|
||||
> `20211129`
|
||||
- 修复FTP存储源上传失败的问题
|
||||
- 修复MAC系统下路径问题
|
||||
- 优化系统部分代码
|
||||
### 更新日志 `20220407`
|
||||
- **修复** 修复了用户数据量较大时进行操作的一些异常表现
|
||||
- **提高** 系统稳定性
|
||||
- **优化** 页面显示
|
||||
|
||||
### 引导
|
||||
|
||||
> 目前`*.hellohao.cn`在国内多个省被运营商劫持,部分省市打不开,恢复时间尚不明确。
|
||||
> 迫于无奈,我已经准备了备用域名,后续陆续添加备用域名。
|
||||
> 如:`xxx.hellohao.cn`打不开,请尝试访问`xxx.wwery.com`
|
||||
[官网](https://tbed.hellohao.cn) | [宣传视频](https://www.bilibili.com/video/BV11r4y1y7mH/) | [文档](http://doc.wwery.com) | [演示站](http://tc.wwery.com)
|
||||
|
||||
程序宣传视频:[自制宣传视频](https://www.bilibili.com/video/BV11r4y1y7mH/)
|
||||
[^_^]:程序宣传视频:[自制宣传视频](https://www.bilibili.com/video/BV11r4y1y7mH/)
|
||||
|
||||
开源版编译包下载: [下载开源版程序包](https://github.com/Hello-hao/Tbed/releases/)
|
||||
[^_^]:官网(含Core版):[https://tbed.hellohao.cn](https://tbed.hellohao.cn)
|
||||
|
||||
官网(含Core版):[http://Tbed.wwery.com](http://Tbed.wwery.com)
|
||||
[^_^]:前端源码:[https://github.com/Hello-hao/tbed-web](https://github.com/Hello-hao/tbed-web)
|
||||
|
||||
前端源码:[https://github.com/Hello-hao/tbed-web](https://github.com/Hello-hao/tbed-web)
|
||||
[^_^]:文档地址:[https://doc.hellohao.cn](https://doc.hellohao.cn)
|
||||
|
||||
文档地址:[http://doc.hellohao.cn](http://doc.hellohao.cn)
|
||||
[^_^]:程序展示:[https://tc.hellohao.cn](https://tc.hellohao.cn)
|
||||
|
||||
文档地址(备用):[http://doc.wwery.com](http://doc.hellohao.cn)
|
||||
[^_^]:作者博客:[https://www.hellohao.cn](https://www.hellohao.cn)
|
||||
|
||||
程序展示:[http://tc.hellohao.cn](http://tc.hellohao.cn)
|
||||
|
||||
作者博客:[http://www.hellohao.cn](http://www.hellohao.cn)
|
||||
[^_^]:官网(含Core版)(备用):[http://tbed.wwery.com](http://tbed.wwery.com)
|
||||
|
||||
[^_^]:文档地址(备用):[http://doc.wwery.com](http://doc.wwery.com)
|
||||
|
||||
[^_^]:程序展示(备用):[http://tc.wwery.com](http://tc.wwery.com)
|
||||
|
||||
[^_^]:作者博客(备用):[http://www.wwery.com](http://www.wwery.com)
|
||||
|
||||
|
||||
|
||||
|
||||
### 主要功能
|
||||
|
||||
- 前后端分离式架构设计,部署更方便
|
||||
- [x] 前后端分离式架构设计,部署更方便
|
||||
|
||||
- 个人相册浏览,图像详细资料展示卡片
|
||||
- [x] 个人相册浏览,图像详细资料展示卡片
|
||||
|
||||
- 支持 图片拖拽、截图直接(Ctrl+V)和URL地址上传
|
||||
- [x] 支持 图片拖拽、截图直接(Ctrl+V)
|
||||
|
||||
- 对接邮箱服务,注册/找回密码等功能
|
||||
- [x] 支持URL地址批量上传
|
||||
|
||||
- 违规图像实时多线程鉴别
|
||||
- [x] 一键复制嵌入式链接代码,也可以自定义嵌入式代码格式
|
||||
|
||||
- 图片定期暂存
|
||||
- [x] 对接邮箱服务,注册/找回密码等功能
|
||||
|
||||
- 支持多种图像格式如:`jfif`,`webp`,`ico`,`svg`等
|
||||
- [x] 违规图像实时多线程鉴别
|
||||
|
||||
- 支持画廊批量分享模式
|
||||
- [x] 图片定期暂存
|
||||
|
||||
- 账户图像查重上传
|
||||
- [x] 支持多种图像格式如:`jfif`,`webp`,`ico`,`svg`等
|
||||
|
||||
- 配置IP黑名单操作
|
||||
- [x] 支持画廊批量分享模式
|
||||
|
||||
- 站点上传可控API接口
|
||||
- [x] 账户图像查重上传
|
||||
|
||||
- 设置用户可用容量
|
||||
- [x] 配置IP黑名单操作
|
||||
|
||||
- 账户扩容码批量生成
|
||||
- [x] 站点上传可控API接口
|
||||
|
||||
- 细致的上传分发配置,分发群组功能
|
||||
- [x] 设置用户可用容量
|
||||
|
||||
- 游客、用户的上传管理
|
||||
- [x] 账户扩容码批量生成
|
||||
|
||||
- 图像直链二维码生成
|
||||
- [x] 细致的上传分发配置,分发群组功能
|
||||
|
||||
- [x] 游客、用户的上传管理
|
||||
|
||||
- [x] 图像直链二维码生成
|
||||
|
||||
|
||||
|
||||
### 系统预览
|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||
[^_^]: 
|
||||
[^_^]: 
|
||||
[^_^]: 
|
||||
[^_^]: 
|
||||
[^_^]: 
|
||||
|
||||
|
||||
### 运行环境
|
||||
@@ -134,17 +148,21 @@ Core版:`本地`,`阿里OSS`,`又拍USS`,`七牛KODO`,`腾讯COS`,`网易NOS`,
|
||||
> 2.自定义部署 前后端分离式部署:`Tbed.zip`(拓展性高适合有一定java前后端分离部署经验的人)
|
||||
> 需要注意:一键部署的端口为:服务器:`10088` 前端:`10089`
|
||||
|
||||
详细部署教程参考程序文档:[开源版部署教程](http://doc.hellohao.cn/#/opensource)
|
||||
详细部署教程参考程序[相关文档](http://doc.hellohao.cn)
|
||||
|
||||
### 启动项目
|
||||
|
||||
初始用户名:`admin`
|
||||
初始邮箱:`admin`
|
||||
初始密码`admin`
|
||||
初始密码:`admin`
|
||||
|
||||
### PC客户端
|
||||
### 微信小程序
|
||||
> 目前已有测试版,更多功能开发中,开发进度的快慢要根据作者的工作压力、心情状况等自身情况进行评估。
|
||||
> 暂时无法给出具体发布小程序的时间。大家期待吧。
|
||||
|
||||
作者精力不够,工作繁忙,暂停更新
|
||||

|
||||
|
||||
[^_^]: 
|
||||
|
||||
### 声明
|
||||
|
||||
@@ -154,8 +172,7 @@ Core版:`本地`,`阿里OSS`,`又拍USS`,`七牛KODO`,`腾讯COS`,`网易NOS`,
|
||||
|
||||
### 反馈交流
|
||||
|
||||
**如果你遇到BUG可以去我的博客反馈**
|
||||
Hellohao博客: [http://www.hellohao.cn/](http://www.hellohao.cn/)
|
||||
**如果你遇到BUG欢迎反馈**
|
||||
|
||||
欢迎加入Hellohao开发者交流群,群聊号码:**864800972**
|
||||
|
||||
@@ -163,5 +180,5 @@ Hellohao博客: [http://www.hellohao.cn/](http://www.hellohao.cn/)
|
||||
|
||||
**如果你也支持Hellohao图床,可以请我喝杯咖啡。我会持续更新Hellohao图床**
|
||||
|
||||
**捐赠地址:** [**http://tbed.hellohao.cn/pay**](http://tbed.hellohao.cn/pay)
|
||||
**捐赠地址:** [**https://tbed.hellohao.cn/pay**](https://tbed.hellohao.cn/pay)
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package cn.hellohao.config;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author Hellohao
|
||||
* @version 1.0
|
||||
* @date 29/11/2021 上午 10:35
|
||||
*/
|
||||
public class GlobalConstant {
|
||||
public static String SYSTYPE = "LINUX";
|
||||
public static String LOCPATH = File.separator + "HellohaoData";
|
||||
}
|
||||
@@ -12,7 +12,7 @@ public class WebImgConfigurer implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
String filePath = File.separator + "HellohaoData" + File.separator;
|
||||
String filePath = GlobalConstant.LOCPATH + File.separator;
|
||||
registry.addResourceHandler("/ota/**").addResourceLocations("file:"+filePath);
|
||||
}
|
||||
|
||||
|
||||
@@ -96,10 +96,10 @@ public class AdminController {
|
||||
if(user.getLevel()>1){
|
||||
ok = "true";
|
||||
//管理员
|
||||
jsonObject.put("imgTotal", imgService.counts(null) ); //admin 站点图片数
|
||||
jsonObject.put("userTotal", userService.getUserTotal()); //admin 用户个数
|
||||
jsonObject.put("ViolationImgTotal", imgreview.getCount()); //admin 非法图片
|
||||
jsonObject.put("ViolationSwitch", isImgreviewOK==null?0:isImgreviewOK.getId()); //admin 非法图片开关
|
||||
jsonObject.put("imgTotal", imgService.counts(null) ); //站点图片数
|
||||
jsonObject.put("userTotal", userService.getUserTotal());
|
||||
jsonObject.put("ViolationImgTotal", imgreview.getCount()); //非法图片
|
||||
jsonObject.put("ViolationSwitch", isImgreviewOK==null?0:isImgreviewOK.getId()); //非法图片开关
|
||||
jsonObject.put("VisitorUpload", uploadConfig.getIsupdate());//是否禁用了游客上传
|
||||
jsonObject.put("VisitorMemory", SetFiles.readableFileSize(Long.valueOf(uploadConfig.getVisitormemory())));//访客共大小
|
||||
if(uploadConfig.getIsupdate()!=1){
|
||||
@@ -130,7 +130,6 @@ public class AdminController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/SpaceExpansion")//new
|
||||
@ResponseBody
|
||||
public Msg SpaceExpansion(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
@@ -167,7 +166,6 @@ public class AdminController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/getRecently")//new
|
||||
@ResponseBody
|
||||
public Msg getRecently(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
@@ -276,12 +274,12 @@ public class AdminController {
|
||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||
Integer pageNum = jsonObj.getInteger("pageNum");
|
||||
Integer pageSize = jsonObj.getInteger("pageSize");
|
||||
String username = jsonObj.getString("username");
|
||||
Integer source = jsonObj.getInteger("source");
|
||||
String starttime = jsonObj.getString("starttime");
|
||||
String stoptime = jsonObj.getString("stoptime");
|
||||
String selectUserType = jsonObj.getString("selectUserType");//me/all
|
||||
String username = jsonObj.getString("username");
|
||||
Integer selecttype = jsonObj.getInteger("selecttype");
|
||||
String classifuids = jsonObj.getString("classifuids");
|
||||
boolean violation = jsonObj.getBoolean("violation");
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
if(starttime!=null){
|
||||
@@ -307,17 +305,18 @@ public class AdminController {
|
||||
if(violation){
|
||||
img.setViolation("true");
|
||||
}
|
||||
img.setUsername(username);
|
||||
img.setSource(source);
|
||||
img.setSelecttype(selecttype);
|
||||
img.setStarttime(starttime);
|
||||
img.setStoptime(stoptime);
|
||||
if(classifuids!=null){
|
||||
String[] calssif = classifuids.split(",");
|
||||
img.setClassifuidlist(calssif);
|
||||
}
|
||||
if(subject.hasRole("admin")){
|
||||
img.setUserid(null);
|
||||
img.setSource(source);
|
||||
if(selectUserType.equals("me")){
|
||||
img.setUserid(user.getId());
|
||||
img.setUsername(null);
|
||||
img.setSelecttype(null);
|
||||
}else{
|
||||
img.setUsername(username);
|
||||
img.setSelecttype(selecttype);
|
||||
}
|
||||
}else{
|
||||
//普通用户
|
||||
img.setUserid(user.getId());
|
||||
@@ -415,7 +414,6 @@ public class AdminController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/deleImages") //new
|
||||
@ResponseBody
|
||||
public Msg deleImages(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
@@ -443,7 +441,7 @@ public class AdminController {
|
||||
Keys key = keysService.selectKeys(keyid);
|
||||
|
||||
if(!subject.hasRole("admin")){
|
||||
if(image.getUserid()!=user.getId()){
|
||||
if(!image.getUserid().equals(user.getId())){
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -466,7 +464,7 @@ public class AdminController {
|
||||
}else if (key.getStorageType() == 8) {
|
||||
isDele = uFileImageupload.delUFile(key.getId(), imgname);
|
||||
}else {
|
||||
System.err.println("未获取到对象存储参数,删除失败。");
|
||||
System.err.println("未获取到对象存储参数,删除失败");
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
@@ -475,7 +473,7 @@ public class AdminController {
|
||||
try {
|
||||
imgTempService.delImgAndExp(image.getImguid());
|
||||
imgService.deleimg(imgid);
|
||||
imgAndAlbumService.deleteImgAndAlbum(imgname);
|
||||
imgAndAlbumService.deleteImgAndAlbum(image.getImgurl());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
msg.setInfo("图片记录删除失败,请重试");
|
||||
@@ -486,14 +484,13 @@ public class AdminController {
|
||||
}else{
|
||||
imgTempService.delImgAndExp(image.getImguid());
|
||||
imgService.deleimg(imgid);
|
||||
imgAndAlbumService.deleteImgAndAlbum(imgname);
|
||||
imgAndAlbumService.deleteImgAndAlbum(image.getImgurl());
|
||||
msg.setInfo("图片记录已删除,但是图片源删除失败");
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
//工具函数
|
||||
private static String getChinaes(int v){
|
||||
String ch = "";
|
||||
|
||||
@@ -62,7 +62,6 @@ public class AdminRootController {
|
||||
map.put("count", rolePageInfo.getTotal());
|
||||
map.put("users", rolePageInfo.getList());
|
||||
return map;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -253,7 +252,6 @@ public class AdminRootController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/getSettingConfig") //new
|
||||
@ResponseBody
|
||||
public Msg getSettingConfig(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
@@ -376,7 +374,6 @@ public class AdminRootController {
|
||||
EmailConfig emailConfig = JSON.toJavaObject(jsonObj,EmailConfig.class);
|
||||
if(null==emailConfig.getEmails() || null==emailConfig.getEmailkey() || null==emailConfig.getEmailurl()
|
||||
|| null==emailConfig.getPort() || null==emailConfig.getEmailname() || null==tomail){
|
||||
// if(jsonObj.size()==0){
|
||||
msg.setCode("110400");
|
||||
msg.setInfo("邮箱配置参数不能为空");
|
||||
}else{
|
||||
|
||||
@@ -100,6 +100,38 @@ public class AlbumController {
|
||||
|
||||
}
|
||||
|
||||
//后台列表要修改时的查询表单
|
||||
@PostMapping("/admin/getAlbumListForKey") //new
|
||||
@ResponseBody
|
||||
public Msg getAlbumListForKey(@RequestParam(value = "data", defaultValue = "") String data){
|
||||
Msg msg = new Msg();
|
||||
try{
|
||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||
String key = jsonObject.getString("key");
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
User user = (User) subject.getPrincipal();
|
||||
Album album = new Album();
|
||||
album.setAlbumkey(key);
|
||||
if(subject.hasRole("admin")){
|
||||
album.setUserid(null);
|
||||
}else{
|
||||
album.setUserid(user.getId());
|
||||
}
|
||||
JSONObject jsonObj = new JSONObject();
|
||||
Album album1 = albumServiceImpl.selectAlbum(album);
|
||||
List<Images> imagesList = imgAndAlbumService.selectImgForAlbumkey(key);
|
||||
jsonObj.put("album",album1);
|
||||
jsonObj.put("imagesList",imagesList);
|
||||
msg.setData(jsonObj);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
msg.setCode("500");
|
||||
msg.setInfo("获取画廊数据错误");
|
||||
}
|
||||
return msg;
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/getAlbumImgList") //new
|
||||
@ResponseBody
|
||||
public Msg getAlbumImgList(@RequestParam("data") String data) {
|
||||
@@ -136,7 +168,7 @@ public class AlbumController {
|
||||
}
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
User u = (User) subject.getPrincipal();
|
||||
String uuid = "TOALBUM"+ UUID.randomUUID().toString().replace("-", "").toLowerCase().substring(0,5)+"N";
|
||||
String uuid = "TOALBUM"+ UUID.randomUUID().toString().replace("-", "").toLowerCase().substring(0,7)+"N";
|
||||
SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
Album album = new Album();
|
||||
album.setAlbumtitle(albumtitle);
|
||||
@@ -173,6 +205,65 @@ public class AlbumController {
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/admin/UpdateForAlbum")//new
|
||||
@ResponseBody
|
||||
public Msg UpdateForAlbum(@RequestParam(value = "data", defaultValue = "") String data){
|
||||
data = StringEscapeUtils.unescapeHtml4(data);
|
||||
Msg msg = new Msg();
|
||||
try {
|
||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||
String albumkey = jsonObject.getString("albumkey");
|
||||
String albumtitle = jsonObject.getString("albumtitle");
|
||||
String password = jsonObject.getString("password");
|
||||
JSONArray jsonArray = JSONArray.parseArray(jsonObject.getString("albumlist"));
|
||||
if(null!=password){
|
||||
// String regex = "^[a-z0-9A-Z\u4e00-\u9fa5]+$";
|
||||
// return str.matches(regex);
|
||||
password = password.replace(" ", "");
|
||||
if(password.replace(" ", "").equals("") || password.length()<3){
|
||||
msg.setCode("110403");
|
||||
msg.setInfo("密码长度不得小于三位有效字符");
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
if(albumtitle==null || jsonArray.size()==0){
|
||||
msg.setCode("110404");
|
||||
msg.setInfo("标题和图片参数不能为空");
|
||||
return msg;
|
||||
}
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
User u = (User) subject.getPrincipal();
|
||||
Album album = new Album();
|
||||
album.setAlbumtitle(albumtitle);
|
||||
album.setPassword(password);
|
||||
album.setAlbumkey(albumkey);
|
||||
|
||||
albumServiceImpl.updateAlbum(album);
|
||||
imgAndAlbumService.deleteImgAndAlbumForKey(albumkey);
|
||||
for (int i = 0; i < jsonArray.size(); i++) {
|
||||
JSONObject img = jsonArray.getJSONObject(i);
|
||||
ImgAndAlbum imgAndAlbum = new ImgAndAlbum();
|
||||
imgAndAlbum.setImgname(img.getString("imgurl"));
|
||||
imgAndAlbum.setAlbumkey(albumkey);
|
||||
imgAndAlbum.setNotes(img.getString("notes"));
|
||||
albumServiceImpl.addAlbumForImgAndAlbumMapper(imgAndAlbum);
|
||||
}
|
||||
final JSONObject json = new JSONObject();
|
||||
json.put("url",albumkey);
|
||||
json.put("title",albumtitle);
|
||||
json.put("password",password);
|
||||
msg.setCode("200");
|
||||
msg.setInfo("画廊修改成功");
|
||||
msg.setData(json);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
msg.setCode("500");
|
||||
msg.setInfo("修改画廊失败");
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/checkPass")//new
|
||||
@ResponseBody
|
||||
public Msg checkPass(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
|
||||
@@ -84,38 +84,54 @@ public class IndexController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/upload")//upimg new
|
||||
@PostMapping(value = "/upload")// new
|
||||
@ResponseBody
|
||||
public Msg upimg(HttpServletRequest request,HttpSession httpSession
|
||||
, @RequestParam(value = "file", required = false) MultipartFile multipartFile,Integer day,
|
||||
@RequestParam(value = "classifications", defaultValue = "" ) String classifications) {
|
||||
final JSONArray jsonArray = new JSONArray();
|
||||
if(!classifications.equals("")){
|
||||
String[] calssif = classifications.split(",");
|
||||
for (int i = 0; i < calssif.length; i++) {
|
||||
jsonArray.add(calssif[i]);
|
||||
}
|
||||
}
|
||||
return uploadServicel.uploadForLoc(request,multipartFile,day,null,jsonArray);
|
||||
, @RequestParam(value = "file", required = false) MultipartFile multipartFile,Integer day) {
|
||||
return uploadServicel.uploadForLoc(request,multipartFile,day,null);
|
||||
}
|
||||
|
||||
//根据网络图片url上传
|
||||
@PostMapping(value = "/uploadForUrl") //new
|
||||
@ResponseBody
|
||||
public Msg upurlimg(HttpServletRequest request,@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||
final JSONArray jsonArray = new JSONArray();
|
||||
Integer setday = jsonObj.getInteger("day");
|
||||
String imgUrl = jsonObj.getString("imgUrl");
|
||||
String selectTreeListStr = jsonObj.getString("classifications");
|
||||
if(null != selectTreeListStr){
|
||||
String[] calssif = selectTreeListStr.split(",");
|
||||
for (int i = 0; i < calssif.length; i++) {
|
||||
jsonArray.add(calssif[i]);
|
||||
String[] URLArr = imgUrl.split("\n");
|
||||
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
User user = (User) subject.getPrincipal();
|
||||
UploadConfig updateConfig = uploadConfigService.getUpdateConfig();
|
||||
int syscounts = 0;
|
||||
if(null==user){
|
||||
syscounts = updateConfig.getImgcounttourists();
|
||||
}else{
|
||||
syscounts = updateConfig.getImgcountuser();
|
||||
}
|
||||
Msg retMsg = new Msg();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
JSONArray retArray = new JSONArray();
|
||||
int errcounts = 0;
|
||||
int excess = 0;
|
||||
for (int i = 0; i < URLArr.length; i++) {
|
||||
int temp = i+1;
|
||||
if(syscounts>=temp){
|
||||
Msg msg = uploadServicel.uploadForLoc(request, null, setday, URLArr[i]);
|
||||
if(!msg.getCode().equals("200")){
|
||||
errcounts++;
|
||||
}else{
|
||||
retArray.add(msg);
|
||||
}
|
||||
}else{
|
||||
excess++;
|
||||
}
|
||||
}
|
||||
return uploadServicel.uploadForLoc(request,null,setday,imgUrl,jsonArray);
|
||||
jsonObject.put("counts",URLArr.length);
|
||||
jsonObject.put("errcounts",errcounts);
|
||||
jsonObject.put("excess",excess);
|
||||
jsonObject.put("urls",retArray);
|
||||
retMsg.setData(jsonObject);
|
||||
return retMsg;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/getUploadInfo")//new
|
||||
@@ -136,6 +152,8 @@ public class IndexController {
|
||||
}else{
|
||||
jsonObject.put("filesize",Integer.valueOf(updateConfig.getFilesizeuser())/1024);
|
||||
jsonObject.put("imgcount",updateConfig.getImgcountuser());
|
||||
jsonObject.put("uploadSwitch",updateConfig.getUserclose());
|
||||
jsonObject.put("uploadInfo","系统暂时关闭了用户上传功能");
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
@@ -144,7 +162,6 @@ public class IndexController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/checkStatus")
|
||||
@ResponseBody
|
||||
public Msg checkStatus(HttpServletRequest request) {
|
||||
@@ -182,13 +199,10 @@ public class IndexController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/verifyCode")
|
||||
public void verifyCode(HttpServletRequest request, HttpServletResponse response,HttpSession httpSession) {
|
||||
IVerifyCodeGen iVerifyCodeGen = new SimpleCharVerifyCodeGenImpl();
|
||||
try {
|
||||
//登录页面验证码
|
||||
VerifyCode verifyCode = iVerifyCodeGen.generate(80, 38);
|
||||
String code = verifyCode.getCode();
|
||||
String userIP = GetIPS.getIpAddr(request);
|
||||
@@ -243,7 +257,6 @@ public class IndexController {
|
||||
}
|
||||
}
|
||||
|
||||
//删除图像
|
||||
@PostMapping("/deleImagesByUid") //new
|
||||
@ResponseBody
|
||||
public Msg deleImagesByUid(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
@@ -254,7 +267,7 @@ public class IndexController {
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
User user = (User) subject.getPrincipal();
|
||||
if(null!=user){
|
||||
if(user.getId()!=image.getUserid()){
|
||||
if(!user.getId().equals(image.getUserid())){
|
||||
msg.setInfo("删除失败,该图片不允许你执行操作");
|
||||
msg.setCode("100403");
|
||||
return msg;
|
||||
@@ -287,7 +300,7 @@ public class IndexController {
|
||||
//删除库
|
||||
if(isDele){
|
||||
try {
|
||||
imgAndAlbumService.deleteImgAndAlbum(imgname);
|
||||
imgAndAlbumService.deleteImgAndAlbum(image.getImgurl());
|
||||
imgTempService.delImgAndExp(image.getImguid());
|
||||
imgService.deleimg(image.getId());
|
||||
} catch (Exception e) {
|
||||
@@ -298,7 +311,7 @@ public class IndexController {
|
||||
}
|
||||
msg.setInfo("删除成功");
|
||||
}else{
|
||||
imgAndAlbumService.deleteImgAndAlbum(imgname);
|
||||
imgAndAlbumService.deleteImgAndAlbum(image.getImgurl());
|
||||
imgTempService.delImgAndExp(image.getImguid());
|
||||
imgService.deleimg(image.getId());
|
||||
msg.setInfo("图片记录已删除,但是图片源删除失败");
|
||||
@@ -308,8 +321,6 @@ public class IndexController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
//没有权限
|
||||
@RequestMapping("/authError")
|
||||
@ResponseBody
|
||||
public Msg authError(HttpServletRequest request){
|
||||
@@ -319,7 +330,6 @@ public class IndexController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
//认证失败
|
||||
@RequestMapping("/jurisError")
|
||||
@ResponseBody
|
||||
public Msg jurisError(HttpServletRequest request){
|
||||
|
||||
@@ -39,8 +39,6 @@ public class UserController {
|
||||
@Autowired
|
||||
private SysConfigService sysConfigService;
|
||||
@Autowired
|
||||
private UserGroupService userGroupService;
|
||||
@Autowired
|
||||
IRedisService iRedisService;
|
||||
|
||||
@PostMapping("/register")
|
||||
|
||||
@@ -23,4 +23,6 @@ public interface AlbumMapper {
|
||||
List<Album> selectAlbumURLList(Album album);
|
||||
|
||||
Integer selectAlbumCount(@Param("userid") Integer userid);
|
||||
|
||||
Integer updateAlbum(Album album);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public interface ImgMapper {
|
||||
|
||||
Integer md5Count(Images images);
|
||||
|
||||
Images selectImgUrlByMD5(@Param("md5key") String md5key);
|
||||
List<Images> selectImgUrlByMD5(@Param("md5key") String md5key);
|
||||
|
||||
List<Images> RecentlyUploaded(@Param("userid") Integer userid);
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
package cn.hellohao.pojo;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author Hellohao
|
||||
* @version 1.0
|
||||
* @date 2020-04-04 2:12
|
||||
*/
|
||||
public class FixedResources {
|
||||
public static final String LOCPATH = File.separator + "HellohaoData";
|
||||
}
|
||||
@@ -26,4 +26,6 @@ public interface AlbumService {
|
||||
List<Album> selectAlbumURLList(Album album);
|
||||
|
||||
Integer selectAlbumCount(Integer userid);
|
||||
|
||||
Integer updateAlbum(Album album);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public interface ImgService {
|
||||
|
||||
Integer md5Count(Images images);
|
||||
|
||||
Images selectImgUrlByMD5(String md5key);
|
||||
List<Images> selectImgUrlByMD5(String md5key);
|
||||
|
||||
List<Images> RecentlyUploaded(Integer userid);
|
||||
|
||||
|
||||
@@ -84,6 +84,11 @@ public class AlbumServiceImpl implements AlbumService {
|
||||
return albumMapper.selectAlbumCount(userid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer updateAlbum(Album album) {
|
||||
return albumMapper.updateAlbum(album);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public Integer delete(String albumkey) {
|
||||
Integer ret1 = albumMapper.deleteAlbum(albumkey);
|
||||
@@ -108,4 +113,6 @@ public class AlbumServiceImpl implements AlbumService {
|
||||
}
|
||||
return ret1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -47,14 +47,16 @@ public class COSImageupload {
|
||||
returnImage.setImgSize(entry.getValue().length());
|
||||
returnImage.setCode("200");
|
||||
} catch (CosServiceException serverException) {
|
||||
returnImage.setCode("400");
|
||||
serverException.printStackTrace();
|
||||
} catch (CosClientException clientException) {
|
||||
returnImage.setCode("400");
|
||||
clientException.printStackTrace();
|
||||
}
|
||||
}
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
returnImage.setCode("200");
|
||||
returnImage.setCode("500");
|
||||
}
|
||||
return returnImage;
|
||||
}
|
||||
@@ -71,16 +73,16 @@ public class COSImageupload {
|
||||
COSCredentials cred = new BasicCOSCredentials(secretId, secretKey);
|
||||
Region region = new Region(k.getEndpoint());
|
||||
ClientConfig clientConfig = new ClientConfig(region);
|
||||
COSClient cosClient = new COSClient(cred, clientConfig);
|
||||
COSClient cos = new COSClient(cred, clientConfig);
|
||||
ListObjectsRequest listObjectsRequest = new ListObjectsRequest();
|
||||
listObjectsRequest.setBucketName(k.getBucketname());
|
||||
listObjectsRequest.setDelimiter("/");
|
||||
listObjectsRequest.setMaxKeys(1);
|
||||
ObjectListing objectListing = null;
|
||||
try {
|
||||
objectListing = cosClient.listObjects(listObjectsRequest);
|
||||
objectListing = cos.listObjects(listObjectsRequest);
|
||||
ret = 1;
|
||||
cosClient = cosClient;
|
||||
cosClient = cos;
|
||||
key = k;
|
||||
} catch (Exception e) {
|
||||
System.out.println("COS Object Is null");
|
||||
|
||||
@@ -126,7 +126,7 @@ public class ClientService {
|
||||
e.printStackTrace();
|
||||
System.out.println("未获取到图片的MD5,成成UUID");
|
||||
}
|
||||
Msg fileMiME = TypeDict.FileMiME(file, uploadConfig.getSuffix());
|
||||
Msg fileMiME = TypeDict.FileMiME(file);
|
||||
if (!fileMiME.getCode().equals("200")) {
|
||||
//非图像文本
|
||||
msg.setCode("4009");
|
||||
@@ -153,10 +153,10 @@ public class ClientService {
|
||||
imaOBJ.setMd5key(md5key);
|
||||
imaOBJ.setUserid(u.getId());
|
||||
if (imgMapper.md5Count(imaOBJ) > 0) {
|
||||
Images images = imgMapper.selectImgUrlByMD5(md5key);
|
||||
jsonObject.put("url", images.getImgurl());
|
||||
List<Images> images = imgMapper.selectImgUrlByMD5(md5key);
|
||||
jsonObject.put("url", images.get(0).getImgurl());
|
||||
jsonObject.put("name", file.getName());
|
||||
jsonObject.put("size", images.getSizes());
|
||||
jsonObject.put("size", images.get(0).getSizes());
|
||||
msg.setData(jsonObject);
|
||||
return msg;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ public class FTPImageupload {
|
||||
|
||||
public ReturnImage ImageuploadFTP(Map<String, File> fileMap, String username,Integer keyID) {
|
||||
ReturnImage returnImage = new ReturnImage();
|
||||
Keys key = null;
|
||||
String[] host = key.getEndpoint().split("\\:");
|
||||
String h = host[0];
|
||||
Integer p = Integer.parseInt(host[1]);
|
||||
|
||||
@@ -88,8 +88,8 @@ public class GroupServiceImpl implements GroupService {
|
||||
if(group.getUsertype()!=0){
|
||||
Group groupFroUserType = groupMapper.getGroupFroUserType(group.getUsertype());
|
||||
if(groupFroUserType!=null){
|
||||
if(groupFroUserType.getUsertype()==group.getUsertype()){
|
||||
if(groupFroUserType.getId()==group.getId()){
|
||||
if(groupFroUserType.getUsertype().equals(group.getUsertype())){
|
||||
if(groupFroUserType.getId().equals(group.getId())){
|
||||
groupMapper.setgroup(group);
|
||||
msg.setInfo("修改成功");
|
||||
}else{
|
||||
|
||||
@@ -220,7 +220,7 @@ public class ImgServiceImpl implements ImgService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Images selectImgUrlByMD5(String md5key) {
|
||||
public List<Images> selectImgUrlByMD5(String md5key) {
|
||||
return imgMapper.selectImgUrlByMD5(md5key);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,6 @@ public class KODOImageupload {
|
||||
|
||||
public ReturnImage ImageuploadKODO(Map<String, File> fileMap, String username, Integer keyID){
|
||||
ReturnImage returnImage = new ReturnImage();
|
||||
Keys key = null;
|
||||
Configuration cfg;
|
||||
if (key.getEndpoint().equals("1")) {
|
||||
cfg = new Configuration(Zone.zone0());
|
||||
@@ -53,7 +52,6 @@ public class KODOImageupload {
|
||||
try {
|
||||
for (Map.Entry<String, File> entry : fileMap.entrySet()) {
|
||||
String ShortUID = SetText.getShortUuid();
|
||||
java.text.DateFormat format1 = new java.text.SimpleDateFormat("MMddhhmmss");
|
||||
file = entry.getValue();
|
||||
try {
|
||||
Response response = uploadManager.put(file,username + "/" + ShortUID + "." + entry.getKey(),upToken);
|
||||
@@ -63,6 +61,7 @@ public class KODOImageupload {
|
||||
returnImage.setImgSize(entry.getValue().length());
|
||||
returnImage.setCode("200");
|
||||
} catch (QiniuException ex) {
|
||||
returnImage.setCode("400");
|
||||
Response r = ex.response;
|
||||
System.err.println(r.toString());
|
||||
try {
|
||||
@@ -99,14 +98,14 @@ public class KODOImageupload {
|
||||
UploadManager uploadManager = new UploadManager(cfg);
|
||||
Auth auth = Auth.create(k.getAccessKey(), k.getAccessSecret());
|
||||
String upToken = auth.uploadToken(k.getBucketname(),null,7200,null);//auth.uploadToken(k.getBucketname());
|
||||
BucketManager bucketManager = new BucketManager(auth, cfg);
|
||||
BucketManager bmObj = new BucketManager(auth, cfg);
|
||||
BucketManager.FileListIterator fileListIterator = null;
|
||||
try {
|
||||
fileListIterator = bucketManager.createFileListIterator(k.getBucketname(), "", 1, "/");
|
||||
fileListIterator = bmObj.createFileListIterator(k.getBucketname(), "", 1, "/");
|
||||
FileInfo[] items = fileListIterator.next();
|
||||
if(items!=null){
|
||||
ret = 1;
|
||||
bucketManager = bucketManager;
|
||||
bucketManager = bmObj;
|
||||
key = k;
|
||||
}
|
||||
}catch (Exception e){
|
||||
|
||||
@@ -58,13 +58,13 @@ public class NOSImageupload {
|
||||
&& !k.getBucketname().equals("") && !k.getRequestAddress().equals("") ){
|
||||
// 初始化
|
||||
Credentials credentials = new BasicCredentials(k.getAccessKey(), k.getAccessSecret());
|
||||
NosClient nosClient = new NosClient(credentials);
|
||||
nosClient.setEndpoint(k.getEndpoint());
|
||||
NosClient nosObj = new NosClient(credentials);
|
||||
nosObj.setEndpoint(k.getEndpoint());
|
||||
ObjectListing objectListing = null;
|
||||
try {
|
||||
objectListing = nosClient.listObjects(k.getBucketname());
|
||||
objectListing = nosObj.listObjects(k.getBucketname());
|
||||
ret = 1;
|
||||
nosClient = nosClient;
|
||||
nosClient = nosObj;
|
||||
key = k;
|
||||
}catch (Exception e){
|
||||
System.out.println("NOS Object Is null");
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cn.hellohao.service.impl;
|
||||
|
||||
import cn.hellohao.pojo.Keys;
|
||||
import cn.hellohao.pojo.Msg;
|
||||
import cn.hellohao.pojo.ReturnImage;
|
||||
import cn.hellohao.utils.*;
|
||||
import com.aliyun.oss.OSS;
|
||||
@@ -14,7 +15,7 @@ import java.util.*;
|
||||
|
||||
@Service
|
||||
public class OSSImageupload {
|
||||
static OSSClient ossClient;
|
||||
static OSS ossClient;
|
||||
static Keys key;
|
||||
|
||||
public ReturnImage ImageuploadOSS(Map<String, File> fileMap, String username,Integer keyID){
|
||||
@@ -27,6 +28,8 @@ public class OSSImageupload {
|
||||
String ShortUID = SetText.getShortUuid();
|
||||
java.text.DateFormat format1 = new java.text.SimpleDateFormat("MMddhhmmss");
|
||||
file = entry.getValue();
|
||||
Msg fileMiME = TypeDict.FileMiME(file);
|
||||
meta.setHeader("content-type", fileMiME.getData().toString());
|
||||
System.out.println("待上传的图片:"+username + "/" + ShortUID + "." + entry.getKey());
|
||||
ossClient.putObject(key.getBucketname(), username + "/" + ShortUID + "." + entry.getKey(),file);
|
||||
returnImage.setImgname(username + "/" + ShortUID + "." + entry.getKey());//entry.getValue().getOriginalFilename()
|
||||
@@ -49,11 +52,11 @@ public class OSSImageupload {
|
||||
&& k.getBucketname()!=null && k.getRequestAddress()!=null ) {
|
||||
if(!k.getEndpoint().equals("") && !k.getAccessSecret().equals("") && !k.getAccessKey().equals("") && !k.getEndpoint().equals("")
|
||||
&& !k.getBucketname().equals("") && !k.getRequestAddress().equals("") ) {
|
||||
OSS ossClient = new OSSClientBuilder().build(k.getEndpoint(), k.getAccessKey(), k.getAccessSecret());
|
||||
OSS ossObj = new OSSClientBuilder().build(k.getEndpoint(), k.getAccessKey(), k.getAccessSecret());
|
||||
try {
|
||||
objectListing = ossClient.listObjects(k.getBucketname());
|
||||
objectListing = ossObj.listObjects(k.getBucketname());
|
||||
ret=1;
|
||||
ossClient = ossClient;
|
||||
ossClient = ossObj;
|
||||
key = k;
|
||||
} catch (Exception e) {
|
||||
System.out.println("OSS Object Is null");
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cn.hellohao.service.impl;
|
||||
|
||||
import cn.hellohao.pojo.Keys;
|
||||
import cn.hellohao.pojo.Msg;
|
||||
import cn.hellohao.pojo.ReturnImage;
|
||||
import cn.hellohao.pojo.UploadConfig;
|
||||
import cn.hellohao.utils.*;
|
||||
@@ -26,6 +27,8 @@ public class UFileImageupload {
|
||||
for (Map.Entry<String, File> entry : fileMap.entrySet()) {
|
||||
String ShortUID = SetText.getShortUuid();
|
||||
file = entry.getValue();
|
||||
Msg fileMiME = TypeDict.FileMiME(file);
|
||||
meta.setHeader("content-type", fileMiME.getData().toString());
|
||||
uFile.setContentMD5(UpYun.md5(file));
|
||||
boolean result = uFile.writeFile(username + "/" + ShortUID + "." + entry.getKey(), file, true);
|
||||
if(result){
|
||||
@@ -34,6 +37,7 @@ public class UFileImageupload {
|
||||
returnImage.setImgSize(entry.getValue().length());
|
||||
returnImage.setCode("200");
|
||||
}else{
|
||||
returnImage.setCode("400");
|
||||
System.err.println("上传失败");
|
||||
}
|
||||
}
|
||||
@@ -53,12 +57,12 @@ public class UFileImageupload {
|
||||
if(!k.getAccessSecret().equals("") && !k.getAccessKey().equals("")
|
||||
&& !k.getBucketname().equals("") && !k.getRequestAddress().equals("") ) {
|
||||
// 创建UpYun实例。
|
||||
UpYun uFile = new UpYun(k.getBucketname(), k.getAccessKey(), k.getAccessSecret());
|
||||
UpYun ufObj = new UpYun(k.getBucketname(), k.getAccessKey(), k.getAccessSecret());
|
||||
List<UpYun.FolderItem> items = null;
|
||||
try {
|
||||
items = uFile.readDir("/",null);
|
||||
items = ufObj.readDir("/",null);
|
||||
ret = 1;
|
||||
uFile = uFile;
|
||||
uFile = ufObj;
|
||||
key = k;
|
||||
} catch (Exception e) {
|
||||
System.out.println("UFile Object Is null");
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cn.hellohao.service.impl;
|
||||
|
||||
import cn.hellohao.pojo.Keys;
|
||||
import cn.hellohao.pojo.Msg;
|
||||
import cn.hellohao.pojo.ReturnImage;
|
||||
import cn.hellohao.pojo.UploadConfig;
|
||||
import cn.hellohao.utils.*;
|
||||
@@ -29,6 +30,8 @@ public class USSImageupload {
|
||||
for (Map.Entry<String, File> entry : fileMap.entrySet()) {
|
||||
String ShortUID = SetText.getShortUuid();
|
||||
file = entry.getValue();
|
||||
Msg fileMiME = TypeDict.FileMiME(file);
|
||||
meta.setHeader("content-type", fileMiME.getData().toString());
|
||||
upyun.setContentMD5(UpYun.md5(file));
|
||||
boolean result = upyun.writeFile(username + "/" + ShortUID + "." + entry.getKey(), file, true);
|
||||
if(result){
|
||||
@@ -37,6 +40,7 @@ public class USSImageupload {
|
||||
returnImage.setImgSize(entry.getValue().length());
|
||||
returnImage.setCode("200");
|
||||
}else{
|
||||
returnImage.setCode("400");
|
||||
System.err.println("上传失败");
|
||||
}
|
||||
}
|
||||
@@ -57,12 +61,12 @@ public class USSImageupload {
|
||||
&& !k.getRequestAddress().equals("") ) {
|
||||
// 初始化
|
||||
// 创建UpYun实例。
|
||||
UpYun upyun = new UpYun(k.getBucketname(), k.getAccessKey(), k.getAccessSecret());
|
||||
UpYun upObj= new UpYun(k.getBucketname(), k.getAccessKey(), k.getAccessSecret());
|
||||
List<UpYun.FolderItem> items = null;
|
||||
try {
|
||||
items = upyun.readDir("/",null);
|
||||
items = upObj.readDir("/",null);
|
||||
ret = 1;
|
||||
upyun = upyun;
|
||||
upyun = upObj;
|
||||
key = k;
|
||||
} catch (Exception e) {
|
||||
System.out.println("USS Object Is null");
|
||||
|
||||
@@ -52,7 +52,7 @@ public class UploadServicel {
|
||||
|
||||
|
||||
public Msg uploadForLoc(HttpServletRequest request,
|
||||
MultipartFile multipartFile, Integer setday, String imgUrl, JSONArray selectTreeList) {
|
||||
MultipartFile multipartFile, Integer setday, String imgUrl) {
|
||||
Msg msg = new Msg();
|
||||
try{
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
@@ -110,7 +110,7 @@ public class UploadServicel {
|
||||
e.printStackTrace();
|
||||
System.out.println("未获取到图片的MD5,成成UUID");
|
||||
}
|
||||
Msg fileMiME = TypeDict.FileMiME(file, uploadConfig.getSuffix());
|
||||
Msg fileMiME = TypeDict.FileMiME(file);
|
||||
if(!fileMiME.getCode().equals("200")) {
|
||||
//非图像文本
|
||||
msg.setCode("4000");
|
||||
@@ -127,10 +127,10 @@ public class UploadServicel {
|
||||
imaOBJ.setMd5key(md5key);
|
||||
imaOBJ.setUserid(u==null?0:u.getId());
|
||||
if(imgMapper.md5Count(imaOBJ)>0){
|
||||
Images images = imgMapper.selectImgUrlByMD5(md5key);
|
||||
jsonObject.put("url", images.getImgurl());
|
||||
List<Images> images = imgMapper.selectImgUrlByMD5(md5key);
|
||||
jsonObject.put("url", images.get(0).getImgurl());
|
||||
jsonObject.put("name",file.getName());
|
||||
jsonObject.put("imguid",images.getImguid());
|
||||
jsonObject.put("imguid",images.get(0).getImguid());
|
||||
// jsonObject.put("shortLink",images.getShortlink());
|
||||
msg.setData(jsonObject);
|
||||
return msg;
|
||||
@@ -220,10 +220,10 @@ public class UploadServicel {
|
||||
//先判断是不是有效链接
|
||||
// final boolean valid = ImgUrlUtil.isValid(imgurl);
|
||||
if(true){
|
||||
Long imgsize = null;
|
||||
Long imgsize = 0L;
|
||||
try {
|
||||
imgsize = ImgUrlUtil.getFileLength(imgurl);
|
||||
if(imgsize>0){
|
||||
// imgsize = ImgUrlUtil.getFileLength(imgurl);
|
||||
if(imgsize==0){
|
||||
// String uuid= UUID.randomUUID().toString().replace("-", "");
|
||||
String ShortUID = SetText.getShortUuid();
|
||||
String savePath = request.getSession().getServletContext().getRealPath("/")+File.separator+"hellohaotmp"+File.separator;
|
||||
@@ -245,7 +245,7 @@ public class UploadServicel {
|
||||
msg.setCode("500");
|
||||
msg.setInfo("获取资源失败");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
msg.setCode("500");
|
||||
msg.setInfo("获取资源失败");
|
||||
}
|
||||
@@ -253,15 +253,15 @@ public class UploadServicel {
|
||||
msg.setCode("500");
|
||||
msg.setInfo("该链接无效");
|
||||
}
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
public static Group group; //上传用户或游客的所属分组
|
||||
public static Long memory;//上传用户或者游客的分配容量 memory
|
||||
public static Long TotleMemory;//用户或者游客下可使用的总容量 //maxsize
|
||||
public static Long UsedTotleMemory;//用户或者游客已经用掉的总容量 //usermemory
|
||||
public static String updatePath="tourist";
|
||||
private static Group group; //上传用户或游客的所属分组
|
||||
private static Long memory;//上传用户或者游客的分配容量 memory
|
||||
private static Long TotleMemory;//用户或者游客下可使用的总容量 //maxsize
|
||||
private static Long UsedTotleMemory;//用户或者游客已经用掉的总容量 //usermemory
|
||||
private static String updatePath="tourist";
|
||||
|
||||
//判断用户 或 游客 当前上传图片的一系列校验
|
||||
private Msg updateImgCheck(User user, UploadConfig uploadConfig){
|
||||
@@ -276,6 +276,7 @@ public class UploadServicel {
|
||||
msg.setInfo("系统已禁用游客上传");
|
||||
return msg;
|
||||
}
|
||||
updatePath="tourist";
|
||||
group = GetCurrentSource.GetSource(null);
|
||||
memory = Long.valueOf(uploadConfig.getVisitormemory());//单位 B 游客设置总量
|
||||
TotleMemory = Long.valueOf(uploadConfig.getFilesizetourists());//单位 B 游客单文件大小
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
package cn.hellohao.utils;
|
||||
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class DeleImg {
|
||||
public static void charu(String imgUrlText) {
|
||||
String filePath =File.separator + "HellohaoData" ;
|
||||
File file = new File(filePath);
|
||||
File file1 = new File(filePath+File.separator+"img.ini");
|
||||
if(!file.exists()){
|
||||
file.mkdirs();
|
||||
}
|
||||
if(!file1.exists()){
|
||||
try {
|
||||
file1.createNewFile();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
FileWriter fw = null;
|
||||
try {
|
||||
//如果文件存在,则追加内容;如果文件不存在,则创建文件
|
||||
fw = new FileWriter(file1, true);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
PrintWriter pw = new PrintWriter(fw);
|
||||
pw.println(imgUrlText);
|
||||
pw.flush();
|
||||
try {
|
||||
fw.flush();
|
||||
pw.close();
|
||||
fw.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 读取文件内容
|
||||
public static String readFile(String path) {//路径
|
||||
File file = new File(path);
|
||||
StringBuilder result = new StringBuilder();
|
||||
try {
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file), "GBK"));//构造一个BufferedReader类来读取文件
|
||||
String s = null;
|
||||
while ((s = br.readLine()) != null) {//使用readLine方法,一次读一行
|
||||
result.append(System.lineSeparator() + s);
|
||||
Print.Normal( s);
|
||||
}
|
||||
br.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.hellohao.utils;
|
||||
|
||||
import cn.hellohao.config.GlobalConstant;
|
||||
import org.omg.CORBA.Environment;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -8,6 +9,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@@ -28,7 +30,8 @@ public class FirstRun implements InitializingBean {
|
||||
private String jdbcurl;
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
public void afterPropertiesSet() {
|
||||
isWindows();
|
||||
RunSqlScript.USERNAME = jdbcusername;
|
||||
RunSqlScript.PASSWORD = jdbcpass;
|
||||
RunSqlScript.DBURL = jdbcurl;
|
||||
@@ -83,11 +86,11 @@ public class FirstRun implements InitializingBean {
|
||||
Print.Normal("Stage 7");
|
||||
}
|
||||
|
||||
Integer ret6 = RunSqlScript.RunSelectCount(judgeTable+"'imgandalbum' and column_name = 'notes' and TABLE_SCHEMA='picturebed'");
|
||||
if(ret6==0){
|
||||
RunSqlScript.RunInsert(sql11);
|
||||
Print.Normal("Stage 8");
|
||||
}
|
||||
// Integer ret6 = RunSqlScript.RunSelectCount(judgeTable+"'imgandalbum' and column_name = 'notes' and TABLE_SCHEMA='picturebed'");
|
||||
// if(ret6==0){
|
||||
// RunSqlScript.RunInsert(sql11);
|
||||
// Print.Normal("Stage 8");
|
||||
// }
|
||||
|
||||
RunSqlScript.RunInsert(sql10);
|
||||
|
||||
@@ -95,6 +98,8 @@ public class FirstRun implements InitializingBean {
|
||||
RunSqlScript.RunInsert(inddx_md5key);
|
||||
RunSqlScript.RunInsert("UPDATE `keys` SET `Endpoint` = '0' WHERE `id` = 8");
|
||||
Print.Normal("Stage success");
|
||||
|
||||
clears();
|
||||
}
|
||||
|
||||
//检查表是否存在,后边加'imgdata' and column_name = 'explains' 检查字段是否存在
|
||||
@@ -115,7 +120,7 @@ public class FirstRun implements InitializingBean {
|
||||
private String sql10 = "alter table config modify column `explain` varchar(1000),modify column links varchar(1000),modify column notice varchar(1000),modify column baidu varchar(1000)";
|
||||
|
||||
//添加imgandalbum字段notes(添加画廊图片说明)
|
||||
private String sql11 = "alter table imgandalbum add notes varchar(1000) DEFAULT ' '";
|
||||
// private String sql11 = "alter table imgandalbum add notes varchar(1000) DEFAULT ' '";
|
||||
|
||||
private String inddx_md5key = "ALTER TABLE imgdata ADD INDEX index_md5key_url ( md5key,imgurl)";
|
||||
// create index yarn_app_result_i4 on yarn_app_result (flow_exec_id(100), another_column(50));
|
||||
@@ -124,11 +129,11 @@ public class FirstRun implements InitializingBean {
|
||||
private String compressed = "alter table imgdata row_format=compressed";
|
||||
|
||||
private void clears(){
|
||||
File file1 = new File(File.separator+"HellohaoData"+File.separator+"hellohaotempimg");
|
||||
File file2 = new File(File.separator+"HellohaoData"+File.separator+"hellohaotempwatermarimg");
|
||||
File file1 = new File(GlobalConstant.LOCPATH+File.separator+"hellohaotempimg");
|
||||
File file2 = new File(GlobalConstant.LOCPATH+File.separator+"hellohaotempwatermarimg");
|
||||
|
||||
//判断目录有没有创建
|
||||
File file = new File(File.separator+"HellohaoData");
|
||||
File file = new File(GlobalConstant.LOCPATH);
|
||||
if(!file.exists()){
|
||||
file.mkdirs();
|
||||
file1.mkdirs();
|
||||
@@ -143,4 +148,14 @@ public class FirstRun implements InitializingBean {
|
||||
}
|
||||
|
||||
|
||||
public boolean isWindows() {
|
||||
System.out.println("当前系统类型:"+System.getProperties().getProperty("os.name").toUpperCase());
|
||||
if(System.getProperties().getProperty("os.name").toUpperCase().contains("MAC")){
|
||||
GlobalConstant.SYSTYPE = "MAC";
|
||||
Properties props=System.getProperties();
|
||||
GlobalConstant.LOCPATH = props.getProperty("user.home")+File.separator+".HellohaoData";
|
||||
}
|
||||
return System.getProperties().getProperty("os.name").toUpperCase().indexOf("WINDOWS") != -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package cn.hellohao.utils;
|
||||
|
||||
import cn.hellohao.service.impl.ImgServiceImpl;
|
||||
import cn.hellohao.service.impl.ImgreviewServiceImpl;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
@@ -27,9 +25,6 @@ public class GetIPS implements Runnable {
|
||||
thread.start();
|
||||
}
|
||||
|
||||
|
||||
/*** * 用于测试跨域 * @author huangweii * 2015年5月29日 */
|
||||
|
||||
public static String getIpAddr(HttpServletRequest request){
|
||||
String ip = request.getHeader("X-Forwarded-For");
|
||||
if(org.apache.commons.lang3.StringUtils.isNotEmpty(ip) && !"unKnown".equalsIgnoreCase(ip)){
|
||||
|
||||
@@ -90,12 +90,11 @@ public class ImgUrlUtil {
|
||||
* @param savePath
|
||||
* @throws IOException
|
||||
*/
|
||||
public static Map<String ,Object> downLoadFromUrl(String urlStr, String fileName, String savePath){
|
||||
public static Map<String ,Object> downLoadFromUrl(String urlStr,String fileName,String savePath){
|
||||
|
||||
Map<String ,Object> resmap = new HashMap<>();
|
||||
Map<String ,String> map = checkURLStatusCode(urlStr);
|
||||
if(map.get("Check").equals("false")){
|
||||
// StatusCode
|
||||
if(map.size()==0 || map.get("Check").equals("false")){
|
||||
resmap.put("res",false);
|
||||
resmap.put("StatusCode",map.get("StatusCode"));
|
||||
return resmap;
|
||||
@@ -128,13 +127,14 @@ public class ImgUrlUtil {
|
||||
//下载并且保存成功后 判断格式 如果不是图像格式 就删除
|
||||
//
|
||||
if(new File(saveDir+File.separator+fileName).exists()){
|
||||
Msg msg = TypeDict.FileMiME(file,null);
|
||||
Msg msg = TypeDict.FileMiME(file);
|
||||
if(msg.getCode().equals("200")){
|
||||
File f = new File(saveDir+File.separator+fileName);
|
||||
String imgPath = saveDir+File.separator+fileName+"."+(msg.getData().toString().replace("image/",""));
|
||||
f.renameTo(new File(imgPath));
|
||||
resmap.put("res",true);
|
||||
resmap.put("imgPath",imgPath);
|
||||
resmap.put("imgsize",new File(imgPath).length());
|
||||
}else{
|
||||
new File(saveDir+File.separator+fileName).delete();
|
||||
resmap.put("res",false);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.hellohao.utils;
|
||||
|
||||
import cn.hellohao.config.GlobalConstant;
|
||||
import cn.hellohao.pojo.Keys;
|
||||
import cn.hellohao.pojo.ReturnImage;
|
||||
import cn.hellohao.pojo.UploadConfig;
|
||||
@@ -16,7 +17,7 @@ public class LocUpdateImg {
|
||||
public static boolean deleteLOCImg(String imagename){
|
||||
boolean isDele = false;
|
||||
try {
|
||||
String filePath =File.separator + "HellohaoData" + File.separator+imagename;
|
||||
String filePath = GlobalConstant.LOCPATH + File.separator+imagename;
|
||||
File file = new File(filePath);
|
||||
isDele = file.delete();
|
||||
}catch (Exception e){
|
||||
@@ -30,7 +31,7 @@ public class LocUpdateImg {
|
||||
KeysServiceImpl keysService = SpringContextHolder.getBean(KeysServiceImpl.class);
|
||||
final Keys key = keysService.selectKeys(keyID);
|
||||
ReturnImage returnImage = new ReturnImage();
|
||||
String filePath =File.separator + "HellohaoData" + File.separator;
|
||||
String filePath =GlobalConstant.LOCPATH + File.separator;
|
||||
File file = null;
|
||||
for (Map.Entry<String, File> entry : fileMap.entrySet()) {
|
||||
String ShortUID = SetText.getShortUuid();
|
||||
|
||||
@@ -69,7 +69,7 @@ MIDI (mid),文件头:4D546864
|
||||
}
|
||||
|
||||
//apache大法
|
||||
public static Msg FileMiME(File file, String suffix){
|
||||
public static Msg FileMiME(File file ){
|
||||
final Msg msg = new Msg();
|
||||
try {
|
||||
Tika tika = new Tika();
|
||||
|
||||
@@ -7,12 +7,12 @@ spring.datasource.url=jdbc:mysql://localhost:3306/tbed?useUnicode=true&character
|
||||
#端口
|
||||
server.port=8089
|
||||
#前端域名需要带协议头http(s)://
|
||||
CROS_ALLOWED_ORIGINS=http://localhost:8080
|
||||
CROS_ALLOWED_ORIGINS=http://127.0.0.1:8080
|
||||
|
||||
|
||||
#下边的配置项不需要修改。
|
||||
logging.config=classpath:logback-spring.xml
|
||||
logging.file.path=/HellohaoData/tbedlog
|
||||
#logging.config=classpath:logback-spring.xml
|
||||
#logging.file.path=/HellohaoData/tbedlog
|
||||
spring.thymeleaf.suffix=.html
|
||||
mybatis.configuration.map-underscore-to-camel-case=true
|
||||
mybatis.mapper-locations=classpath:mapper/*.xml
|
||||
@@ -44,3 +44,4 @@ spring.datasource.druid.stat-view-servlet.login-username=hellohao@dealer
|
||||
spring.datasource.druid.stat-view-servlet.login-password=52BNmXPJL0rQQ3CU
|
||||
spring.datasource.druid.stat-view-servlet.allow=127.0.0.1
|
||||
spring.datasource.druid.web-stat-filter.exclusions=false
|
||||
log4j2.formatMsgNoLookups=True
|
||||
@@ -63,5 +63,18 @@
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<update id="updateAlbum" parameterType="cn.hellohao.pojo.Album">
|
||||
UPDATE `album`
|
||||
<set>
|
||||
<if test="albumtitle != null">
|
||||
albumtitle = #{albumtitle},
|
||||
</if>
|
||||
<if test="password != null">
|
||||
password = #{password},
|
||||
</if>
|
||||
</set>
|
||||
WHERE
|
||||
albumkey = #{albumkey}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -10,7 +10,6 @@
|
||||
<!-- `group`-->
|
||||
<!-- </select>-->
|
||||
|
||||
|
||||
<select id="grouplist" resultType="cn.hellohao.pojo.Group" parameterType="integer">
|
||||
SELECT
|
||||
g.id,g.groupname,g.keyid,g.usertype,g.compress,k.storageType,k.keyname
|
||||
@@ -33,7 +32,7 @@
|
||||
</select>
|
||||
|
||||
<insert id="addgroup" parameterType="cn.hellohao.pojo.Group">
|
||||
insert into `group` (id,groupname,keyid) values (null,#{groupname},#{keyid})
|
||||
insert into `group` (id,groupname,keyid,usertype,compress) values (null,#{groupname},#{keyid},#{usertype},#{compress})
|
||||
</insert>
|
||||
|
||||
<select id="GetCountFroUserType" parameterType="integer" resultType="integer">
|
||||
@@ -49,7 +48,7 @@
|
||||
</delete>
|
||||
|
||||
<update id="setgroup" parameterType="cn.hellohao.pojo.Group">
|
||||
UPDATE `group` SET groupname=#{groupname},keyid=#{keyid} where id = #{id};
|
||||
UPDATE `group` SET groupname=#{groupname},keyid=#{keyid},usertype=#{usertype},compress=#{compress} where id = #{id};
|
||||
</update>
|
||||
|
||||
<select id="getGroupFroUserType" parameterType="integer" resultType="cn.hellohao.pojo.Group">
|
||||
|
||||
@@ -37,20 +37,35 @@
|
||||
and
|
||||
a.updatetime <= #{stoptime}
|
||||
</if>
|
||||
|
||||
<if test="userid != null">
|
||||
<choose>
|
||||
<when test="selecttype != null">
|
||||
and
|
||||
a.userid not in (#{userid})
|
||||
</when>
|
||||
<otherwise>
|
||||
and
|
||||
a.userid = #{userid}
|
||||
</otherwise>
|
||||
</choose>
|
||||
<if test="violation == 'true'">
|
||||
and
|
||||
a.violation !=""
|
||||
</if>
|
||||
|
||||
<choose>
|
||||
<when test="userid!=null and userid!=''">
|
||||
and
|
||||
a.userid = #{userid}
|
||||
</when>
|
||||
<otherwise>
|
||||
<if test="username != null and username != ''">
|
||||
<choose>
|
||||
<when test="selecttype==1">
|
||||
and
|
||||
a.userid in ( SELECT id from `user` where username LIKE '%${username}%')
|
||||
</when>
|
||||
<otherwise>
|
||||
and
|
||||
a.userid not in ( SELECT id from `user` where username LIKE '%${username}%')
|
||||
</otherwise>
|
||||
</choose>
|
||||
</if>
|
||||
</otherwise>
|
||||
</choose>
|
||||
<if test="imguid != null">
|
||||
and
|
||||
a.imguid = #{imguid}
|
||||
</if>
|
||||
|
||||
order by a.id desc
|
||||
</select>
|
||||
|
||||
@@ -40,7 +40,10 @@
|
||||
`usermemory` = #{usermemory},
|
||||
</if>
|
||||
<if test="blacklist != null">
|
||||
`blacklist` = #{blacklist}
|
||||
`blacklist` = #{blacklist},
|
||||
</if>
|
||||
<if test="userclose != null">
|
||||
`userclose` = #{userclose}
|
||||
</if>
|
||||
|
||||
</set>
|
||||
|
||||
Reference in New Issue
Block a user