mirror of
https://github.com/Hello-hao/Tbed.git
synced 2024-04-21 12:32:10 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cec4db6947 | ||
|
|
dc3736b4ce | ||
|
|
071eeaa3e7 | ||
|
|
a71ca1c1e9 | ||
|
|
133540874c | ||
|
|
cc683b7921 | ||
|
|
cea9823899 | ||
|
|
486cb48c81 | ||
|
|
ce333b790b | ||
|
|
c53634ee9b | ||
|
|
2ababe7beb | ||
|
|
aa7da62b35 | ||
|
|
91936fcb22 | ||
|
|
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 |
@@ -1,12 +1,17 @@
|
||||
# Hellohao图像托管程序 - 也许这会是最优秀的图床程序
|
||||
|
||||

|
||||

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

|
||||

|
||||

|
||||
|
||||
|
||||
### 引导
|
||||
|
||||
[官网](https://tbed.hellohao.cn) | [宣传视频](https://www.bilibili.com/video/BV11r4y1y7mH/) | [文档](https://doc.hellohao.cn) | [演示站](https://pic.hellohao.cn) | [前端源码](https://github.com/Hello-hao/tbed-web)
|
||||
|
||||
|
||||
### 前言
|
||||
|
||||
@@ -14,101 +19,102 @@
|
||||
|
||||
程序主要使用领域:`个人照片存储`,`团队共享图像`,`博客/商城等网站图片托管`,`图像批量云分享`等。具备优秀的多用户图像上传功能和完善的图像查询管理逻辑,同时支持对接多家对象存储。
|
||||
|
||||
> 无论你使用开源版或者Core版,都希望你能给我点个赞,你的`star`是对一名开发者最大的支持
|
||||
|
||||
**存储源支持:**
|
||||
|
||||
开源版:`本地`,`阿里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`
|
||||
|
||||
|
||||
### 更新日志 `20211229`
|
||||
### 更新日志 `20220506`
|
||||
|
||||
- [x] 优化上传图片的响应头和返回值判断逻辑
|
||||
- [x] 后台菜单添加返回首页项
|
||||
- [x] 优化了页面组件显示问题
|
||||
- [x] 新增个人相册复制链接功能可选链接格式
|
||||
- [x] 修复了系统已知安全隐患
|
||||
- [x] 优化重写删除图像功能,修复部分场景下图像删除失败的问题(支持进度展示)
|
||||
- [x] 优化多个页面细节
|
||||
|
||||
### 引导
|
||||
|
||||
> 目前`*.hellohao.cn`在国内多个省被运营商劫持,部分省市打不开,恢复时间尚不明确。
|
||||
> 迫于无奈,我已经准备了备用域名,后续陆续添加备用域名。
|
||||
> 如:`xxx.hellohao.cn`打不开,请尝试访问`xxx.wwery.com`
|
||||
[^_^]:程序宣传视频:[自制宣传视频](https://www.bilibili.com/video/BV11r4y1y7mH/)
|
||||
|
||||
程序宣传视频:[自制宣传视频](https://www.bilibili.com/video/BV11r4y1y7mH/)
|
||||
[^_^]:官网(含Core版):[https://tbed.hellohao.cn](https://tbed.hellohao.cn)
|
||||
|
||||
开源版编译包下载: [下载开源版程序包](https://github.com/Hello-hao/Tbed/releases/)
|
||||
[^_^]:前端源码:[https://github.com/Hello-hao/tbed-web](https://github.com/Hello-hao/tbed-web)
|
||||
|
||||
官网(含Core版):[http://Tbed.wwery.com](http://Tbed.wwery.com)
|
||||
[^_^]:文档地址:[https://doc.hellohao.cn](https://doc.hellohao.cn)
|
||||
|
||||
前端源码:[https://github.com/Hello-hao/tbed-web](https://github.com/Hello-hao/tbed-web)
|
||||
[^_^]:程序展示:[https://tc.hellohao.cn](https://tc.hellohao.cn)
|
||||
|
||||
文档地址:[http://doc.hellohao.cn](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://doc.wwery.com](http://doc.wwery.cn)
|
||||
[^_^]:程序展示(备用):[http://tc.wwery.com](http://tc.wwery.com)
|
||||
|
||||
官网(含Core版)(备用):[http://Tbed.wwery.com](http://Tbed.wwery.com)
|
||||
|
||||
程序展示(备用):[http://tc.wwery.com](http://tc.wwery.com)
|
||||
|
||||
作者博客(备用):[http://www.wwery.com](http://www.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] 图像直链二维码生成
|
||||
|
||||
|
||||
|
||||
### 系统预览
|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||

|
||||

|
||||
|
||||
[^_^]: 
|
||||
[^_^]: 
|
||||
[^_^]: 
|
||||
[^_^]: 
|
||||
[^_^]: 
|
||||
|
||||
|
||||
### 运行环境
|
||||
@@ -143,17 +149,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客户端
|
||||
### 微信小程序
|
||||
> 目前已有测试版,更多功能开发中,开发进度的快慢要根据作者的工作压力、心情状况等自身情况进行评估。
|
||||
> 暂时无法给出具体发布小程序的时间。大家期待吧。
|
||||
|
||||
作者精力不够,工作繁忙,暂停更新
|
||||

|
||||
|
||||
[^_^]: 
|
||||
|
||||
### 声明
|
||||
|
||||
@@ -163,8 +173,7 @@ Core版:`本地`,`阿里OSS`,`又拍USS`,`七牛KODO`,`腾讯COS`,`网易NOS`,
|
||||
|
||||
### 反馈交流
|
||||
|
||||
**如果你遇到BUG可以去我的博客反馈**
|
||||
Hellohao博客: [http://www.hellohao.cn/](http://www.hellohao.cn/)
|
||||
**如果你遇到BUG欢迎反馈**
|
||||
|
||||
欢迎加入Hellohao开发者交流群,群聊号码:**864800972**
|
||||
|
||||
@@ -172,5 +181,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)
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.shiro</groupId>
|
||||
<artifactId>shiro-spring</artifactId>
|
||||
<version>1.7.1</version>
|
||||
<version>1.9.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.auth0</groupId>
|
||||
@@ -108,7 +108,7 @@
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>1.2.76</version>
|
||||
<version>2.0.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
|
||||
@@ -32,9 +32,10 @@ public class SubjectFilter extends BasicHttpAuthenticationFilter {
|
||||
HttpServletResponse httpServletResponse =(HttpServletResponse) response;
|
||||
String serviceName = httpServletRequest.getServletPath();//获取接口
|
||||
String Users_Origin = httpServletRequest.getHeader("usersOrigin");
|
||||
|
||||
String token = httpServletRequest.getHeader("Authorization");
|
||||
//验证前端域名
|
||||
if(httpServletRequest.getMethod().equals("POST") && !serviceName.contains("/api") && !serviceName.contains("/verifyCode")){
|
||||
if(httpServletRequest.getMethod().equals("POST") && !serviceName.contains("/api")
|
||||
&& !serviceName.contains("/verifyCode") && !serviceName.contains("/client")){
|
||||
try{
|
||||
if(Users_Origin.compareTo(SecureUtil.md5(WEBHOST))!=0){
|
||||
System.out.println("前端域名校验未通过");
|
||||
@@ -50,10 +51,40 @@ public class SubjectFilter extends BasicHttpAuthenticationFilter {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
String token = httpServletRequest.getHeader("Authorization");
|
||||
|
||||
if(serviceName.contains("/client")){
|
||||
token = httpServletRequest.getHeader("jwttoken");
|
||||
String userToken = httpServletRequest.getHeader("userToken");
|
||||
User user = new User();
|
||||
user.setToken(userToken);
|
||||
User userData = userService.loginByToken(userToken);
|
||||
if(null==userData){
|
||||
this.CODE = "110404";
|
||||
return false;
|
||||
}else{
|
||||
if(userData.getIsok()<1){
|
||||
this.CODE = "110403";
|
||||
return false;
|
||||
}
|
||||
Subject sub = SecurityUtils.getSubject();
|
||||
User u = (User) sub.getPrincipal();
|
||||
if(null==u){
|
||||
httpServletRequest.getSession().setAttribute("user",userData);
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
UsernamePasswordToken tokenOBJ = new UsernamePasswordToken(userData.getEmail(),userData.getPassword());
|
||||
tokenOBJ.setRememberMe(true);
|
||||
//执行登录方法,如果没有异常,说明登录成功
|
||||
subject.login(tokenOBJ);
|
||||
SecurityUtils.getSubject().getSession().setTimeout(3600000);
|
||||
User loginUser = (User) SecurityUtils.getSubject().getPrincipal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// String token = httpServletRequest.getHeader("Authorization");
|
||||
JSONObject jsonObject = JWTUtil.checkToken(token);
|
||||
if(!jsonObject.getBoolean("check")){
|
||||
if(!serviceName.contains("admin")){
|
||||
if(!serviceName.contains("admin") || serviceName.contains("admin/client")){
|
||||
return true;
|
||||
}else{
|
||||
this.CODE = "403";
|
||||
@@ -102,6 +133,10 @@ public class SubjectFilter extends BasicHttpAuthenticationFilter {
|
||||
info = "当前用户无权访问该请求";
|
||||
}else if(this.CODE.equals("402")){
|
||||
info = "当前web请求不合规";
|
||||
}else if(this.CODE.equals("110403")){
|
||||
info = "该账户暂时无法使用";
|
||||
}else if(this.CODE.equals("110404")){
|
||||
info = "用户未找到";
|
||||
}
|
||||
System.err.println("拦截器False-"+info);
|
||||
response.setContentType("application/json;charset=UTF-8");
|
||||
|
||||
@@ -6,6 +6,7 @@ import cn.hellohao.pojo.vo.PageResultBean;
|
||||
import cn.hellohao.service.*;
|
||||
import cn.hellohao.service.impl.*;
|
||||
import cn.hellohao.utils.*;
|
||||
import cn.hellohao.utils.progress.MyProgress;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
@@ -15,7 +16,7 @@ import org.apache.shiro.subject.Subject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
@@ -38,35 +39,18 @@ public class AdminController {
|
||||
@Autowired
|
||||
private ImgreviewService imgreviewService;
|
||||
@Autowired
|
||||
private ImgTempService imgTempService;
|
||||
@Autowired
|
||||
private UploadConfigService uploadConfigService;
|
||||
@Autowired
|
||||
private CodeService codeService;
|
||||
@Autowired
|
||||
private ImgAndAlbumService imgAndAlbumService;
|
||||
@Autowired
|
||||
private AlbumService albumService;
|
||||
@Autowired
|
||||
AlbumServiceImpl albumServiceI;
|
||||
|
||||
@Autowired
|
||||
private NOSImageupload nosImageupload;
|
||||
@Autowired
|
||||
private OSSImageupload ossImageupload;
|
||||
@Autowired
|
||||
private COSImageupload cosImageupload;
|
||||
@Autowired
|
||||
private KODOImageupload kodoImageupload;
|
||||
@Autowired
|
||||
private USSImageupload ussImageupload;
|
||||
@Autowired
|
||||
private UFileImageupload uFileImageupload;
|
||||
@Autowired
|
||||
private FTPImageupload ftpImageupload;
|
||||
private deleImages deleimages;
|
||||
|
||||
|
||||
@PostMapping(value = "/overviewData") //new
|
||||
@PostMapping(value = "/overviewData")
|
||||
@ResponseBody
|
||||
public Msg overviewData(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
@@ -75,12 +59,13 @@ public class AdminController {
|
||||
user = userService.getUsers(user);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
UploadConfig uploadConfig = uploadConfigService.getUpdateConfig();
|
||||
Imgreview imgreview = imgreviewService.selectByPrimaryKey(1);//查询非法个数
|
||||
Imgreview isImgreviewOK = imgreviewService.selectByusing(1);//查询有没有启动鉴别功能
|
||||
Imgreview imgreview = imgreviewService.selectByPrimaryKey(1);
|
||||
Imgreview isImgreviewOK = imgreviewService.selectByusing(1);
|
||||
String ok = "false";
|
||||
jsonObject.put("myImgTotal", imgService.countimg(user.getId())); //我的图片数
|
||||
jsonObject.put("myAlbumTitle", albumService.selectAlbumCount(user.getId()));//我的画廊数量
|
||||
long memory = Long.valueOf(user.getMemory());//分配量
|
||||
jsonObject.put("myToken", user.getToken());
|
||||
jsonObject.put("myImgTotal", imgService.countimg(user.getId()));
|
||||
jsonObject.put("myAlbumTitle", albumService.selectAlbumCount(user.getId()));
|
||||
long memory = Long.valueOf(user.getMemory());
|
||||
Long usermemory = imgService.getusermemory(user.getId())==null?0L:imgService.getusermemory(user.getId());
|
||||
if(memory==0){
|
||||
jsonObject.put("myMemory","无容量");
|
||||
@@ -95,32 +80,31 @@ public class AdminController {
|
||||
jsonObject.put("myMemorySum",SetFiles.readableFileSize(memory));
|
||||
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("VisitorUpload", uploadConfig.getIsupdate());//是否禁用了游客上传
|
||||
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){
|
||||
jsonObject.put("VisitorUpload", 0);//是否禁用了游客上传
|
||||
jsonObject.put("VisitorProportion",100.00);//游客用量%占比
|
||||
jsonObject.put("VisitorMemory", "禁用");//访客共大小
|
||||
jsonObject.put("VisitorUpload", 0);
|
||||
jsonObject.put("VisitorProportion",100.00);
|
||||
jsonObject.put("VisitorMemory", "禁用");
|
||||
}else{
|
||||
Long temp = imgService.getusermemory(0)==null?0:imgService.getusermemory(0);
|
||||
jsonObject.put("UsedMemory", (temp == null ? 0 : SetFiles.readableFileSize(temp)));//访客已用大小
|
||||
jsonObject.put("UsedMemory", (temp == null ? 0 : SetFiles.readableFileSize(temp)));
|
||||
if(Long.valueOf(uploadConfig.getVisitormemory())==0){
|
||||
jsonObject.put("VisitorProportion",100.00);//游客用量%占比
|
||||
jsonObject.put("VisitorProportion",100.00);
|
||||
}else if(Long.valueOf(uploadConfig.getVisitormemory())==-1){
|
||||
jsonObject.put("VisitorProportion",0);//游客用量%占比
|
||||
jsonObject.put("VisitorMemory", "无限");//访客共大小
|
||||
jsonObject.put("VisitorProportion",0);
|
||||
jsonObject.put("VisitorMemory", "无限");
|
||||
}else{
|
||||
double sum = Double.valueOf(uploadConfig.getVisitormemory());
|
||||
Double aDouble = Double.valueOf(String.format("%.2f", ((double) temp / sum) * 100));
|
||||
if(aDouble>=999){
|
||||
jsonObject.put("VisitorProportion",999);//游客用量%占比
|
||||
jsonObject.put("VisitorProportion",999);
|
||||
}else{
|
||||
jsonObject.put("VisitorProportion",aDouble);//游客用量%占比
|
||||
jsonObject.put("VisitorProportion",aDouble);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,8 +114,7 @@ public class AdminController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/SpaceExpansion")//new
|
||||
@PostMapping(value = "/SpaceExpansion")
|
||||
@ResponseBody
|
||||
public Msg SpaceExpansion(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
final Msg msg = new Msg();
|
||||
@@ -167,10 +150,9 @@ public class AdminController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/getRecently")//new
|
||||
@PostMapping("/getRecently")
|
||||
@ResponseBody
|
||||
public Msg getRecently(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
public Msg getRecently() {
|
||||
Msg msg = new Msg();
|
||||
final JSONObject jsonObject = new JSONObject();
|
||||
try {
|
||||
@@ -193,9 +175,32 @@ public class AdminController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping("/getYyyy")//new
|
||||
@PostMapping("/updateToken")
|
||||
@ResponseBody
|
||||
public Msg getYyyy(@RequestParam(value = "data", defaultValue = "") String data){
|
||||
public Msg updateToken() {
|
||||
Msg msg = new Msg();
|
||||
try{
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
User user = (User) subject.getPrincipal();
|
||||
User u = new User();
|
||||
u.setId(user.getId());
|
||||
u.setToken(UUID.randomUUID().toString().replace("-", ""));
|
||||
userService.changeUser(u);
|
||||
user.setToken(u.getToken());
|
||||
msg.setData(u.getToken());
|
||||
msg.setInfo("Token更新成功,即可生效");
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
msg.setCode("500");
|
||||
msg.setInfo("Token更新失败");
|
||||
}
|
||||
return msg;
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/getYyyy")
|
||||
@ResponseBody
|
||||
public Msg getYyyy(){
|
||||
final Msg msg = new Msg();
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
User u = (User) subject.getPrincipal();
|
||||
@@ -206,14 +211,13 @@ public class AdminController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping("/getChart")//new
|
||||
@PostMapping("/getChart")
|
||||
@ResponseBody
|
||||
public Msg getChart(@RequestParam(value = "data", defaultValue = "") String data){
|
||||
Msg msg = new Msg();
|
||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||
String yyyy = jsonObject.getString("yyyy");
|
||||
Integer type = jsonObject.getInteger("type");
|
||||
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
User u = (User) subject.getPrincipal();
|
||||
List<Images> list =null;
|
||||
@@ -249,7 +253,7 @@ public class AdminController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping("/getStorage")//new
|
||||
@PostMapping("/getStorage")
|
||||
@ResponseBody
|
||||
public Msg getStorage() {
|
||||
Msg msg = new Msg();
|
||||
@@ -258,7 +262,7 @@ public class AdminController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping("/getStorageName")//new
|
||||
@PostMapping("/getStorageName")
|
||||
@ResponseBody
|
||||
public Msg getStorageName() {
|
||||
Msg msg = new Msg();
|
||||
@@ -267,7 +271,7 @@ public class AdminController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/selectPhoto")//new
|
||||
@PostMapping(value = {"/selectPhoto","/client/selectPhoto"})
|
||||
@ResponseBody
|
||||
public Msg selectPhoto(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
@@ -276,12 +280,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 +311,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());
|
||||
@@ -329,8 +334,7 @@ public class AdminController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/getUserInfo") //new
|
||||
@PostMapping(value = "/getUserInfo")
|
||||
@ResponseBody
|
||||
public Msg getUserInfo() {
|
||||
Msg msg = new Msg();
|
||||
@@ -352,7 +356,7 @@ public class AdminController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping("/setUserInfo") //new
|
||||
@PostMapping("/setUserInfo")
|
||||
@ResponseBody
|
||||
public Msg setUserInfo(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
@@ -415,84 +419,77 @@ public class AdminController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/deleImages") //new
|
||||
@PostMapping({"/deleImages","/client/deleImages"})
|
||||
@ResponseBody
|
||||
public Msg deleImages(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
public Msg deleImages(HttpSession httpSession, @RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||
JSONArray images = jsonObj.getJSONArray("images");
|
||||
final String images = jsonObj.getString("images");
|
||||
if(images==null){
|
||||
msg.setCode("404");
|
||||
msg.setInfo("为获取到图像信息");
|
||||
return msg;
|
||||
}
|
||||
final String[] split = images.split(",");
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
User user = (User) subject.getPrincipal();
|
||||
|
||||
if(null == user){
|
||||
msg.setCode("500");
|
||||
msg.setInfo("当前用户信息不存在");
|
||||
return msg;
|
||||
}
|
||||
if(images.size()==0){
|
||||
if(split.length==0){
|
||||
msg.setCode("404");
|
||||
msg.setInfo("为获取到图像信息");
|
||||
return msg;
|
||||
}
|
||||
for (int i = 0; i < images.size(); i++) {
|
||||
Integer imgid = images.getInteger(i);
|
||||
List<Integer> imgIds = new ArrayList<Integer>();
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
Integer imgid = Integer.valueOf(split[i]);
|
||||
Images image = imgService.selectByPrimaryKey(imgid);
|
||||
Integer keyid = image.getSource();
|
||||
String imgname = image.getImgname();
|
||||
Keys key = keysService.selectKeys(keyid);
|
||||
|
||||
if(!subject.hasRole("admin")){
|
||||
if(image.getUserid()!=user.getId()){
|
||||
if(!image.getUserid().equals(user.getId())){
|
||||
break;
|
||||
}
|
||||
}
|
||||
boolean isDele = false;
|
||||
try{
|
||||
if (key.getStorageType() == 1) {
|
||||
isDele = nosImageupload.delNOS(key.getId(), imgname);
|
||||
} else if (key.getStorageType() == 2) {
|
||||
isDele = ossImageupload.delOSS(key.getId(), imgname);
|
||||
} else if (key.getStorageType() == 3) {
|
||||
isDele = ussImageupload.delUSS(key.getId(), imgname);
|
||||
} else if (key.getStorageType() == 4) {
|
||||
isDele = kodoImageupload.delKODO(key.getId(), imgname);
|
||||
} else if (key.getStorageType() == 5) {
|
||||
isDele = LocUpdateImg.deleteLOCImg(imgname);
|
||||
}else if (key.getStorageType() == 6) {
|
||||
isDele = cosImageupload.delCOS(key.getId(), imgname);
|
||||
}else if (key.getStorageType() == 7) {
|
||||
isDele = ftpImageupload.delFTP(key.getId(), imgname);
|
||||
}else if (key.getStorageType() == 8) {
|
||||
isDele = uFileImageupload.delUFile(key.getId(), imgname);
|
||||
}else {
|
||||
System.err.println("未获取到对象存储参数,删除失败。");
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
if(isDele){
|
||||
try {
|
||||
imgTempService.delImgAndExp(image.getImguid());
|
||||
imgService.deleimg(imgid);
|
||||
imgAndAlbumService.deleteImgAndAlbum(imgname);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
msg.setInfo("图片记录删除失败,请重试");
|
||||
msg.setCode("500");
|
||||
return msg;
|
||||
}
|
||||
msg.setInfo("删除成功");
|
||||
}else{
|
||||
imgTempService.delImgAndExp(image.getImguid());
|
||||
imgService.deleimg(imgid);
|
||||
imgAndAlbumService.deleteImgAndAlbum(imgname);
|
||||
msg.setInfo("图片记录已删除,但是图片源删除失败");
|
||||
}
|
||||
imgIds.add(imgid);
|
||||
}
|
||||
if(imgIds.size()==0){
|
||||
msg.setCode("110404");
|
||||
}else{
|
||||
deleimages.dele(httpSession,imgIds.stream().toArray(Integer[]::new));
|
||||
msg.setCode("200");
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping({"/GetDelprogress","/client/GetDelprogress"})
|
||||
@ResponseBody
|
||||
public Msg GetDelprogress(HttpSession httpSession) {
|
||||
Msg msg =new Msg();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
MyProgress myProgress = (MyProgress)httpSession.getAttribute("myProgressForDel");
|
||||
if(null==myProgress){
|
||||
jsonObject.put("succ",myProgress.getDelSuccessCount());
|
||||
jsonObject.put("errorlist",new ArrayList<String>());
|
||||
jsonObject.put("oklist",new ArrayList<Long>());
|
||||
jsonObject.put("delover",false);
|
||||
}else{
|
||||
jsonObject.put("succ",myProgress.getDelSuccessCount());
|
||||
jsonObject.put("errorlist",myProgress.getDelErrorImgListt());
|
||||
jsonObject.put("oklist",myProgress.getDelSuccessImgList());
|
||||
jsonObject.put("delover",myProgress.getDelOCT());
|
||||
}
|
||||
msg.setData(jsonObject);
|
||||
if(myProgress.getDelOCT()){
|
||||
System.out.println("循环遍历的值:"+myProgress.getDelOCT());
|
||||
msg.setCode("100");
|
||||
}else{
|
||||
msg.setCode("110666");
|
||||
msg.setInfo("正在执行");
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
//工具函数
|
||||
private static String getChinaes(int v){
|
||||
@@ -537,9 +534,7 @@ public class AdminController {
|
||||
default : ch = "";//可选
|
||||
//语句
|
||||
}
|
||||
|
||||
return ch;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,8 +3,8 @@ package cn.hellohao.controller;
|
||||
import cn.hellohao.pojo.*;
|
||||
import cn.hellohao.service.*;
|
||||
import cn.hellohao.service.impl.*;
|
||||
import cn.hellohao.utils.*;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hellohao.utils.NewSendEmail;
|
||||
import cn.hellohao.utils.SetFiles;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
@@ -13,19 +13,13 @@ import com.github.pagehelper.PageInfo;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.subject.Subject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/admin/root")
|
||||
@@ -46,31 +40,35 @@ public class AdminRootController {
|
||||
private ImgService imgService;
|
||||
@Autowired
|
||||
private ImgreviewService imgreviewService;
|
||||
@Autowired
|
||||
private AppClientService appClientService;
|
||||
|
||||
|
||||
@PostMapping(value = "/getUserList")//new
|
||||
@PostMapping(value = "/getUserList")
|
||||
@ResponseBody
|
||||
public Map<String, Object> getUserList(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||
Integer pageNum = jsonObj.getInteger("pageNum");
|
||||
Integer pageSize = jsonObj.getInteger("pageSize");
|
||||
String queryText = jsonObj.getString("queryText");
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<User> users = userService.getuserlist(queryText);
|
||||
PageInfo<User> rolePageInfo = new PageInfo<>(users);
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("count", rolePageInfo.getTotal());
|
||||
map.put("users", rolePageInfo.getList());
|
||||
return map;
|
||||
|
||||
public Msg getUserList(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
try{
|
||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||
Integer pageNum = jsonObj.getInteger("pageNum");
|
||||
Integer pageSize = jsonObj.getInteger("pageSize");
|
||||
String queryText = jsonObj.getString("queryText");
|
||||
PageHelper.startPage(pageNum, pageSize);
|
||||
List<User> users = userService.getuserlist(queryText);
|
||||
PageInfo<User> rolePageInfo = new PageInfo<>(users);
|
||||
msg.setData(rolePageInfo);
|
||||
}catch (Exception e){
|
||||
msg.setCode("500");
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/updateUserInfo")//new
|
||||
@PostMapping(value = "/updateUserInfo")
|
||||
@ResponseBody
|
||||
public Msg updateUserInfo(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
final Msg msg = new Msg();
|
||||
try{
|
||||
try {
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
User u = (User) subject.getPrincipal();
|
||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||
@@ -79,7 +77,7 @@ public class AdminRootController {
|
||||
Long memory = jsonObj.getLong("memory");
|
||||
Integer groupid = jsonObj.getInteger("groupid");
|
||||
Integer isok = jsonObj.getInteger("isok");
|
||||
if(memory<0 || memory>1048576L){
|
||||
if (memory < 0 || memory > 1048576L) {
|
||||
msg.setCode("500");
|
||||
msg.setInfo("容量不得超过1048576");
|
||||
return msg;
|
||||
@@ -90,14 +88,14 @@ public class AdminRootController {
|
||||
User userInfo = userService.getUsers(user2);
|
||||
user.setId(id);
|
||||
user.setEmail(email);
|
||||
user.setMemory(Long.toString(memory*1024*1024));
|
||||
user.setMemory(Long.toString(memory * 1024 * 1024));
|
||||
user.setGroupid(groupid);
|
||||
if(userInfo.getLevel()==1){
|
||||
user.setIsok(isok==1?1:-1);
|
||||
if (userInfo.getLevel() == 1) {
|
||||
user.setIsok(isok == 1 ? 1 : -1);
|
||||
}
|
||||
userService.changeUser(user);
|
||||
msg.setInfo("修改成功");
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
msg.setCode("500");
|
||||
msg.setInfo("修改失败");
|
||||
e.printStackTrace();
|
||||
@@ -106,7 +104,7 @@ public class AdminRootController {
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/disableUser")//new
|
||||
@PostMapping("/disableUser")
|
||||
@ResponseBody
|
||||
public Msg disableUser(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
@@ -117,7 +115,7 @@ public class AdminRootController {
|
||||
User u = new User();
|
||||
u.setId(userIdList.getInteger(i));
|
||||
User u2 = userService.getUsers(u);
|
||||
if(u2.getLevel()==1){
|
||||
if (u2.getLevel() == 1) {
|
||||
User user = new User();
|
||||
user.setId(userIdList.getInteger(i));
|
||||
user.setIsok(-1);
|
||||
@@ -126,7 +124,7 @@ public class AdminRootController {
|
||||
|
||||
}
|
||||
msg.setInfo("所选用户已被禁用");
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
msg.setInfo("系统错误");
|
||||
msg.setCode("500");
|
||||
@@ -134,7 +132,7 @@ public class AdminRootController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping("/deleUser")//new
|
||||
@PostMapping("/deleUser")
|
||||
@ResponseBody
|
||||
public Msg deleuser(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
@@ -146,18 +144,18 @@ public class AdminRootController {
|
||||
User u = new User();
|
||||
u.setId(userIdList.getInteger(i));
|
||||
User user = userService.getUsers(u);
|
||||
if(user.getLevel()==1){
|
||||
if (user.getLevel() == 1) {
|
||||
userService.deleuser(userIdList.getInteger(i));
|
||||
}else{
|
||||
} else {
|
||||
b = true;
|
||||
}
|
||||
}
|
||||
if(b && userIdList.size()==1){
|
||||
if (b && userIdList.size() == 1) {
|
||||
msg.setInfo("管理员账户不可删除");
|
||||
}else {
|
||||
} else {
|
||||
msg.setInfo("用户已删除成功");
|
||||
}
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
msg.setInfo("系统错误");
|
||||
msg.setCode("500");
|
||||
@@ -165,7 +163,7 @@ public class AdminRootController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping("/getKeysList") //new
|
||||
@PostMapping("/getKeysList")
|
||||
@ResponseBody
|
||||
public Msg getKeysList() {
|
||||
Msg msg = new Msg();
|
||||
@@ -174,7 +172,7 @@ public class AdminRootController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping("/LoadInfo")//new
|
||||
@PostMapping("/LoadInfo")
|
||||
@ResponseBody
|
||||
public Msg LoadInfo(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
@@ -182,34 +180,34 @@ public class AdminRootController {
|
||||
JSONObject jsonData = JSONObject.parseObject(data);
|
||||
Integer keyId = jsonData.getInteger("keyId");
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("id",keyId);
|
||||
jsonObject.put("id", keyId);
|
||||
Keys key = keysService.selectKeys(keyId);
|
||||
Integer ret = 0;
|
||||
if(key.getStorageType()==1){
|
||||
if (key.getStorageType() == 1) {
|
||||
ret = NOSImageupload.Initialize(key);
|
||||
}else if (key.getStorageType()==2){
|
||||
} else if (key.getStorageType() == 2) {
|
||||
ret = OSSImageupload.Initialize(key);
|
||||
}else if(key.getStorageType()==3){
|
||||
} else if (key.getStorageType() == 3) {
|
||||
ret = USSImageupload.Initialize(key);
|
||||
}else if(key.getStorageType()==4){
|
||||
} else if (key.getStorageType() == 4) {
|
||||
ret = KODOImageupload.Initialize(key);
|
||||
}else if(key.getStorageType()==6){
|
||||
} else if (key.getStorageType() == 6) {
|
||||
ret = COSImageupload.Initialize(key);
|
||||
}else if(key.getStorageType()==7){
|
||||
} else if (key.getStorageType() == 7) {
|
||||
ret = FTPImageupload.Initialize(key);
|
||||
}else if(key.getStorageType()==8){
|
||||
} else if (key.getStorageType() == 8) {
|
||||
ret = UFileImageupload.Initialize(key);
|
||||
}
|
||||
Long l = imgService.getsourcememory(keyId);
|
||||
jsonObject.put("isok",ret);
|
||||
jsonObject.put("storagetype",key.getStorageType());
|
||||
if(l==null){
|
||||
jsonObject.put("usedCapacity",0);
|
||||
}else{
|
||||
jsonObject.put("isok", ret);
|
||||
jsonObject.put("storagetype", key.getStorageType());
|
||||
if (l == null) {
|
||||
jsonObject.put("usedCapacity", 0);
|
||||
} else {
|
||||
jsonObject.put("usedCapacity", SetFiles.readableFileSize(l));
|
||||
}
|
||||
msg.setData(jsonObject);
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
msg.setCode("500");
|
||||
}
|
||||
@@ -217,7 +215,7 @@ public class AdminRootController {
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/updateStorage") //new
|
||||
@PostMapping("/updateStorage")
|
||||
@ResponseBody
|
||||
public Msg updateStorage(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||
@@ -242,7 +240,7 @@ public class AdminRootController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping("/getStorageById")//new
|
||||
@PostMapping("/getStorageById")
|
||||
@ResponseBody
|
||||
public Msg getselectkey(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
@@ -253,8 +251,7 @@ public class AdminRootController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/getSettingConfig") //new
|
||||
@PostMapping("/getSettingConfig")
|
||||
@ResponseBody
|
||||
public Msg getSettingConfig(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
final Msg msg = new Msg();
|
||||
@@ -265,13 +262,15 @@ public class AdminRootController {
|
||||
UploadConfig uploadConfig = uploadConfigService.getUpdateConfig();
|
||||
Config config = configService.getSourceype();
|
||||
SysConfig sysConfig = sysConfigService.getstate();
|
||||
uploadConfig.setUsermemory(Long.toString(Long.valueOf(uploadConfig.getUsermemory())/1024/1024));
|
||||
uploadConfig.setVisitormemory(Long.toString(Long.valueOf(uploadConfig.getVisitormemory())/1024/1024));
|
||||
uploadConfig.setFilesizetourists(Long.toString(Long.valueOf(uploadConfig.getFilesizetourists())/1024/1024));
|
||||
uploadConfig.setFilesizeuser(Long.toString(Long.valueOf(uploadConfig.getFilesizeuser())/1024/1024));
|
||||
jsonObject.put("uploadConfig",uploadConfig);
|
||||
jsonObject.put("config",config);
|
||||
jsonObject.put("sysConfig",sysConfig);
|
||||
AppClient appClientData = appClientService.getAppClientData("app");
|
||||
uploadConfig.setUsermemory(Long.toString(Long.valueOf(uploadConfig.getUsermemory()) / 1024 / 1024));
|
||||
uploadConfig.setVisitormemory(Long.toString(Long.valueOf(uploadConfig.getVisitormemory()) / 1024 / 1024));
|
||||
uploadConfig.setFilesizetourists(Long.toString(Long.valueOf(uploadConfig.getFilesizetourists()) / 1024 / 1024));
|
||||
uploadConfig.setFilesizeuser(Long.toString(Long.valueOf(uploadConfig.getFilesizeuser()) / 1024 / 1024));
|
||||
jsonObject.put("uploadConfig", uploadConfig);
|
||||
jsonObject.put("config", config);
|
||||
jsonObject.put("sysConfig", sysConfig);
|
||||
jsonObject.put("appClient", appClientData);
|
||||
msg.setData(jsonObject);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -282,36 +281,44 @@ public class AdminRootController {
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/updateConfig")//new
|
||||
@PostMapping("/updateConfig")
|
||||
@ResponseBody
|
||||
public Msg updateConfig(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
try {
|
||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||
UploadConfig uploadConfig = JSON.toJavaObject((JSON) jsonObject.get("uploadConfig"),UploadConfig.class);
|
||||
String vm = uploadConfig.getVisitormemory();
|
||||
if((Long.valueOf(vm)<-1) || Long.valueOf(vm) > 104857600 || Long.valueOf(uploadConfig.getFilesizetourists())<0 || Long.valueOf(uploadConfig.getFilesizetourists()) > 5120
|
||||
|| Long.valueOf(uploadConfig.getUsermemory())<0 || Long.valueOf(uploadConfig.getUsermemory())>1048576
|
||||
|| Long.valueOf(uploadConfig.getFilesizeuser())<0 || Long.valueOf(uploadConfig.getFilesizeuser())>5120 ){
|
||||
UploadConfig uploadConfig = JSON.toJavaObject((JSON) jsonObject.get("uploadConfig"), UploadConfig.class);
|
||||
String vm = uploadConfig.getVisitormemory();
|
||||
if ((Long.valueOf(vm) < -1) || Long.valueOf(vm) > 104857600 || Long.valueOf(uploadConfig.getFilesizetourists()) < 0 || Long.valueOf(uploadConfig.getFilesizetourists()) > 5120
|
||||
|| Long.valueOf(uploadConfig.getUsermemory()) < 0 || Long.valueOf(uploadConfig.getUsermemory()) > 1048576
|
||||
|| Long.valueOf(uploadConfig.getFilesizeuser()) < 0 || Long.valueOf(uploadConfig.getFilesizeuser()) > 5120) {
|
||||
msg.setInfo("你输入的值不正确");
|
||||
msg.setCode("500");
|
||||
return msg;
|
||||
return msg;
|
||||
}
|
||||
Config config = JSON.toJavaObject((JSON) jsonObject.get("config"),Config.class);
|
||||
SysConfig sysConfig = JSON.toJavaObject((JSON) jsonObject.get("sysConfig"),SysConfig.class);
|
||||
if(Integer.valueOf(vm)==-1){
|
||||
Config config = JSON.toJavaObject((JSON) jsonObject.get("config"), Config.class);
|
||||
SysConfig sysConfig = JSON.toJavaObject((JSON) jsonObject.get("sysConfig"), SysConfig.class);
|
||||
AppClient appClient = JSON.toJavaObject((JSON) jsonObject.get("appClient"), AppClient.class);
|
||||
if (Integer.valueOf(vm) == -1) {
|
||||
uploadConfig.setVisitormemory("-1");
|
||||
}else{
|
||||
uploadConfig.setVisitormemory(Long.toString(Long.valueOf(uploadConfig.getVisitormemory())*1024*1024));
|
||||
} else {
|
||||
uploadConfig.setVisitormemory(Long.toString(Long.valueOf(uploadConfig.getVisitormemory()) * 1024 * 1024));
|
||||
}
|
||||
uploadConfig.setFilesizetourists(Long.toString(Long.valueOf(uploadConfig.getFilesizetourists())*1024*1024));
|
||||
uploadConfig.setUsermemory(Long.toString(Long.valueOf(uploadConfig.getUsermemory())*1024*1024));
|
||||
uploadConfig.setFilesizeuser(Long.toString(Long.valueOf(uploadConfig.getFilesizeuser())*1024*1024));
|
||||
uploadConfig.setFilesizetourists(Long.toString(Long.valueOf(uploadConfig.getFilesizetourists()) * 1024 * 1024));
|
||||
uploadConfig.setUsermemory(Long.toString(Long.valueOf(uploadConfig.getUsermemory()) * 1024 * 1024));
|
||||
uploadConfig.setFilesizeuser(Long.toString(Long.valueOf(uploadConfig.getFilesizeuser()) * 1024 * 1024));
|
||||
uploadConfigService.setUpdateConfig(uploadConfig);
|
||||
configService.setSourceype(config);
|
||||
sysConfigService.setstate(sysConfig);
|
||||
if (!appClient.getIsuse().equals("on")) {
|
||||
appClient.setIsuse("off");
|
||||
}
|
||||
if (!appClient.getAppupdate().equals("on")) {
|
||||
appClient.setAppupdate("off");
|
||||
}
|
||||
appClientService.editAppClientData(appClient);
|
||||
msg.setInfo("配置保存成功");
|
||||
}catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
msg.setInfo("操作出现异常");
|
||||
msg.setCode("500");
|
||||
@@ -320,7 +327,7 @@ public class AdminRootController {
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/getOrderConfig")//new
|
||||
@PostMapping(value = "/getOrderConfig")
|
||||
@ResponseBody
|
||||
public Msg emailconfig() {
|
||||
final Msg msg = new Msg();
|
||||
@@ -330,8 +337,8 @@ public class AdminRootController {
|
||||
final JSONObject jsonObject = new JSONObject();
|
||||
emailConfig = emailConfigService.getemail();
|
||||
imgreview = imgreviewService.selectByPrimaryKey(1);
|
||||
jsonObject.put("emailConfig",emailConfig);
|
||||
jsonObject.put("imgreview",imgreview);
|
||||
jsonObject.put("emailConfig", emailConfig);
|
||||
jsonObject.put("imgreview", imgreview);
|
||||
msg.setData(jsonObject);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -342,17 +349,17 @@ public class AdminRootController {
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/updateEmailConfig") //new
|
||||
@PostMapping("/updateEmailConfig")
|
||||
@ResponseBody
|
||||
public Msg updateemail(@RequestParam(value = "data", defaultValue = "") String data ) {
|
||||
public Msg updateemail(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
final Msg msg = new Msg();
|
||||
try {
|
||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||
EmailConfig emailConfig = JSON.toJavaObject(jsonObj,EmailConfig.class);
|
||||
if(null==emailConfig.getId() || null==emailConfig.getEmailname() || null==emailConfig.getEmailurl() || null==emailConfig.getEmails()
|
||||
|| null==emailConfig.getEmailkey() || null==emailConfig.getPort() || null==emailConfig.getUsing()
|
||||
|| emailConfig.getEmailname().equals("") || emailConfig.getEmailurl().equals("") || emailConfig.getEmails().equals("")
|
||||
|| emailConfig.getEmailkey().equals("") || emailConfig.getPort().equals("")){
|
||||
EmailConfig emailConfig = JSON.toJavaObject(jsonObj, EmailConfig.class);
|
||||
if (null == emailConfig.getId() || null == emailConfig.getEmailname() || null == emailConfig.getEmailurl() || null == emailConfig.getEmails()
|
||||
|| null == emailConfig.getEmailkey() || null == emailConfig.getPort() || null == emailConfig.getUsing()
|
||||
|| emailConfig.getEmailname().equals("") || emailConfig.getEmailurl().equals("") || emailConfig.getEmails().equals("")
|
||||
|| emailConfig.getEmailkey().equals("") || emailConfig.getPort().equals("")) {
|
||||
msg.setCode("110400");
|
||||
msg.setInfo("各参数不能为空");
|
||||
return msg;
|
||||
@@ -367,19 +374,18 @@ public class AdminRootController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping("/mailTest") //new
|
||||
@PostMapping("/mailTest")
|
||||
@ResponseBody
|
||||
public Msg mailTest(@RequestParam(value = "data", defaultValue = "") String data ) {
|
||||
public Msg mailTest(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||
String tomail = jsonObj.getString("tomail");
|
||||
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){
|
||||
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) {
|
||||
msg.setCode("110400");
|
||||
msg.setInfo("邮箱配置参数不能为空");
|
||||
}else{
|
||||
} else {
|
||||
msg = NewSendEmail.sendTestEmail(emailConfig, tomail);
|
||||
}
|
||||
return msg;
|
||||
|
||||
@@ -35,13 +35,13 @@ public class AlbumController {
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@PostMapping("/admin/getGalleryList") //new
|
||||
@PostMapping("/admin/getGalleryList")
|
||||
@ResponseBody
|
||||
public Map<String, Object> getGalleryList (@RequestParam(value = "data", defaultValue = "") String data){
|
||||
public Msg getGalleryList (@RequestParam(value = "data", defaultValue = "") String data){
|
||||
Msg msg = new Msg();
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
User user = (User) subject.getPrincipal();
|
||||
user = userService.getUsers(user);
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
Album album = new Album();
|
||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||
Integer pageNum = jsonObj.getInteger("pageNum");
|
||||
@@ -56,20 +56,17 @@ public class AlbumController {
|
||||
try {
|
||||
albums = albumServiceImpl.selectAlbumURLList(album);
|
||||
PageInfo<Album> rolePageInfo = new PageInfo<>(albums);
|
||||
map.put("code", 200);
|
||||
map.put("info", "");
|
||||
map.put("count", rolePageInfo.getTotal());
|
||||
map.put("data", rolePageInfo.getList());
|
||||
msg.setData(rolePageInfo);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
map.put("code", 500);
|
||||
map.put("info", "获取数据异常");
|
||||
msg.setInfo("获取数据异常");
|
||||
msg.setCode("500");
|
||||
}
|
||||
return map;
|
||||
return msg;
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/admin/deleGallery") //new 删除画廊
|
||||
@PostMapping("/admin/deleGallery")
|
||||
@ResponseBody
|
||||
public Msg deleGallery (@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
@@ -100,7 +97,39 @@ public class AlbumController {
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/getAlbumImgList") //new
|
||||
//后台列表要修改时的查询表单
|
||||
@PostMapping("/admin/getAlbumListForKey")
|
||||
@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")
|
||||
@ResponseBody
|
||||
public Msg getAlbumImgList(@RequestParam("data") String data) {
|
||||
Msg msg = new Msg();
|
||||
@@ -111,7 +140,7 @@ public class AlbumController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping("/SaveForAlbum")//new
|
||||
@PostMapping("/SaveForAlbum")
|
||||
@ResponseBody
|
||||
public Msg SaveForAlbum(@RequestParam(value = "data", defaultValue = "") String data){
|
||||
data = StringEscapeUtils.unescapeHtml4(data);
|
||||
@@ -136,7 +165,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,7 +202,66 @@ public class AlbumController {
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/checkPass")//new
|
||||
@PostMapping("/admin/UpdateForAlbum")
|
||||
@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")
|
||||
@ResponseBody
|
||||
public Msg checkPass(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
@@ -207,7 +295,7 @@ public class AlbumController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping("/getAlbumList") //new
|
||||
@PostMapping("/getAlbumList")
|
||||
@ResponseBody
|
||||
public Msg getAlbumList(@RequestParam(value = "data", defaultValue = "") String data){
|
||||
Msg msg = new Msg();
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
package cn.hellohao.controller;
|
||||
|
||||
import cn.hellohao.auth.token.JWTUtil;
|
||||
import cn.hellohao.pojo.AppClient;
|
||||
import cn.hellohao.pojo.Msg;
|
||||
import cn.hellohao.pojo.UploadConfig;
|
||||
import cn.hellohao.pojo.User;
|
||||
import cn.hellohao.service.AppClientService;
|
||||
import cn.hellohao.service.ImgService;
|
||||
import cn.hellohao.service.UploadConfigService;
|
||||
import cn.hellohao.service.impl.UserServiceImpl;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @author Hellohao
|
||||
* @version 1.0
|
||||
* @date 2022-05-16 32:45
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/client")
|
||||
public class ClientAppController {
|
||||
|
||||
@Autowired
|
||||
private ImgService imgService;
|
||||
@Autowired
|
||||
private AppClientService appClientService;
|
||||
@Autowired
|
||||
private UserServiceImpl userService;
|
||||
@Autowired
|
||||
private UploadConfigService uploadConfigService;
|
||||
|
||||
@PostMapping("/loginByToken")
|
||||
@ResponseBody
|
||||
public Msg loginByToken(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
try{
|
||||
User newUser = new User();
|
||||
String userToken = jsonObj.getString("userToken");
|
||||
newUser.setToken(userToken);
|
||||
User userData = userService.loginByToken(userToken);
|
||||
if(userData.getIsok()<1){
|
||||
SecurityUtils.getSubject().logout();
|
||||
msg.setInfo("账号暂时无法使用,请咨询管理员");
|
||||
msg.setCode("110403");
|
||||
return msg;
|
||||
}
|
||||
String jwtToken = JWTUtil.createToken(userData);
|
||||
UploadConfig uploadConfig = uploadConfigService.getUpdateConfig();
|
||||
jsonObject.put("username", userData.getUsername());
|
||||
jsonObject.put("jwttoken", jwtToken);
|
||||
jsonObject.put("suffix",uploadConfig.getSuffix().split(","));
|
||||
jsonObject.put("myImgTotal", imgService.countimg(userData.getId()));
|
||||
jsonObject.put("filesize",Integer.valueOf(uploadConfig.getFilesizeuser())/1024);
|
||||
jsonObject.put("imgcount",uploadConfig.getImgcountuser());
|
||||
jsonObject.put("uploadSwitch",uploadConfig.getUserclose());
|
||||
long memory = Long.valueOf(userData.getMemory());
|
||||
Long usermemory = imgService.getusermemory(userData.getId())==null?0L:imgService.getusermemory(userData.getId());
|
||||
if(memory==0){
|
||||
jsonObject.put("myMemory","无容量");
|
||||
}else{
|
||||
Double aDouble = Double.valueOf(String.format("%.2f", (((double)usermemory/(double)memory)*100)));
|
||||
if(aDouble>=999){
|
||||
jsonObject.put("myMemory",999);
|
||||
}else{
|
||||
jsonObject.put("myMemory",aDouble);
|
||||
}
|
||||
}
|
||||
msg.setData(jsonObject);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
msg.setCode("110500");
|
||||
msg.setInfo("未获取到用户,请先在设置中添加Token");
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping("/getVersion")
|
||||
@ResponseBody
|
||||
public Msg getVersion() {
|
||||
Msg msg = new Msg();
|
||||
try {
|
||||
AppClient app = appClientService.getAppClientData("app");
|
||||
if(app.getAppupdate().equals("on")){
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("winpackurl",app.getWinpackurl());
|
||||
jsonObject.put("macpackurl",app.getMacpackurl());
|
||||
msg.setData(jsonObject);
|
||||
}else{
|
||||
msg.setCode("000");
|
||||
}
|
||||
}catch (Exception e){
|
||||
msg.setCode("000");
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -26,10 +26,10 @@ public class CodeController {
|
||||
@Autowired
|
||||
private CodeService codeService;
|
||||
|
||||
@RequestMapping(value = "/selectCodeList")//new
|
||||
@RequestMapping(value = "/selectCodeList")
|
||||
@ResponseBody
|
||||
public Map<String, Object> selectCodeList(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
public Msg selectCodeList(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||
Integer pageNum = jsonObj.getInteger("pageNum");
|
||||
Integer pageSize = jsonObj.getInteger("pageSize");
|
||||
@@ -38,19 +38,16 @@ public class CodeController {
|
||||
try {
|
||||
codes = codeService.selectCode(null);
|
||||
PageInfo<Code> rolePageInfo = new PageInfo<>(codes);
|
||||
map.put("code", 200);
|
||||
map.put("info", "");
|
||||
map.put("count", rolePageInfo.getTotal());
|
||||
map.put("data", rolePageInfo.getList());
|
||||
msg.setData(rolePageInfo);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
map.put("code", 500);
|
||||
map.put("info", "获取数据异常");
|
||||
msg.setCode("500");
|
||||
msg.setInfo("获取数据异常");
|
||||
}
|
||||
return map;
|
||||
return msg;
|
||||
}
|
||||
|
||||
@RequestMapping("/deleteCodes")//new
|
||||
@RequestMapping("/deleteCodes")
|
||||
@ResponseBody
|
||||
public Msg deletecodes(@RequestParam(value = "data", defaultValue = "") String data){
|
||||
final Msg msg = new Msg();
|
||||
@@ -72,7 +69,7 @@ public class CodeController {
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/addCode")//new
|
||||
@RequestMapping("/addCode")
|
||||
@ResponseBody
|
||||
public Msg addcode(@RequestParam(value = "data", defaultValue = "") String data){
|
||||
final Msg msg = new Msg();
|
||||
|
||||
@@ -12,9 +12,8 @@ import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import java.util.HashMap;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Hellohao
|
||||
@@ -28,7 +27,7 @@ public class GroupController {
|
||||
private GroupService groupService;
|
||||
|
||||
|
||||
@PostMapping("/getGrouplistForUsers") //new
|
||||
@PostMapping("/getGrouplistForUsers")
|
||||
@ResponseBody
|
||||
public Msg getGrouplistForUsers() {
|
||||
Msg msg = new Msg();
|
||||
@@ -37,10 +36,10 @@ public class GroupController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/getGroupList")//new
|
||||
@PostMapping(value = "/getGroupList")
|
||||
@ResponseBody
|
||||
public Map<String, Object> getgrouplist(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
public Msg getgrouplist(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||
Integer pageNum = jsonObj.getInteger("pageNum");
|
||||
Integer pageSize = jsonObj.getInteger("pageSize");
|
||||
@@ -49,19 +48,16 @@ public class GroupController {
|
||||
try {
|
||||
group = groupService.grouplist(null);
|
||||
PageInfo<Group> rolePageInfo = new PageInfo<>(group);
|
||||
map.put("code", 200);
|
||||
map.put("info", "");
|
||||
map.put("count", rolePageInfo.getTotal());
|
||||
map.put("data", rolePageInfo.getList());
|
||||
msg.setData(rolePageInfo);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
map.put("code", 500);
|
||||
map.put("info", "获取数据异常");
|
||||
msg.setCode("500");
|
||||
msg.setInfo("获取数据异常");
|
||||
}
|
||||
return map;
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/addGroup")//new
|
||||
@PostMapping(value = "/addGroup")
|
||||
@ResponseBody
|
||||
public Msg addisgroup(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||
@@ -74,7 +70,7 @@ public class GroupController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping("/updateGroup")//new
|
||||
@PostMapping("/updateGroup")
|
||||
@ResponseBody
|
||||
public Msg updategroup(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||
@@ -93,7 +89,7 @@ public class GroupController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/deleGroup")//new
|
||||
@PostMapping(value = "/deleGroup")
|
||||
@ResponseBody
|
||||
public Msg delegroup(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||
|
||||
@@ -3,11 +3,14 @@ package cn.hellohao.controller;
|
||||
import cn.hellohao.auth.token.JWTUtil;
|
||||
import cn.hellohao.pojo.*;
|
||||
import cn.hellohao.service.*;
|
||||
import cn.hellohao.service.impl.*;
|
||||
import cn.hellohao.utils.*;
|
||||
import cn.hellohao.service.impl.AlbumServiceImpl;
|
||||
import cn.hellohao.service.impl.UploadServicel;
|
||||
import cn.hellohao.service.impl.deleImages;
|
||||
import cn.hellohao.utils.verifyCode.IVerifyCodeGen;
|
||||
import cn.hellohao.utils.verifyCode.SimpleCharVerifyCodeGenImpl;
|
||||
import cn.hellohao.utils.verifyCode.VerifyCode;
|
||||
import cn.hutool.captcha.CaptchaUtil;
|
||||
import cn.hutool.captcha.ShearCaptcha;
|
||||
import cn.hutool.captcha.generator.MathGenerator;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
@@ -17,10 +20,14 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.io.*;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
|
||||
@Controller
|
||||
public class IndexController {
|
||||
@@ -29,35 +36,17 @@ public class IndexController {
|
||||
@Autowired
|
||||
private SysConfigService sysConfigService;
|
||||
@Autowired
|
||||
IRedisService iRedisService;
|
||||
@Autowired
|
||||
private ConfigService configService;
|
||||
@Autowired
|
||||
private UploadConfigService uploadConfigService;
|
||||
@Autowired
|
||||
private UploadServicel uploadServicel;
|
||||
@Autowired
|
||||
private NOSImageupload nosImageupload;
|
||||
@Autowired
|
||||
private OSSImageupload ossImageupload;
|
||||
@Autowired
|
||||
private COSImageupload cosImageupload;
|
||||
@Autowired
|
||||
private KODOImageupload kodoImageupload;
|
||||
@Autowired
|
||||
private USSImageupload ussImageupload;
|
||||
@Autowired
|
||||
private UFileImageupload uFileImageupload;
|
||||
@Autowired
|
||||
private FTPImageupload ftpImageupload;
|
||||
private deleImages deleimages;
|
||||
@Autowired
|
||||
AlbumServiceImpl albumService;
|
||||
@Autowired
|
||||
private KeysService keysService;
|
||||
@Autowired
|
||||
private ImgTempService imgTempService;
|
||||
@Autowired
|
||||
private ImgAndAlbumService imgAndAlbumService;
|
||||
AppClientService appClientService;
|
||||
|
||||
|
||||
@RequestMapping(value = "/webInfo")
|
||||
@@ -68,6 +57,7 @@ public class IndexController {
|
||||
UploadConfig updateConfig = uploadConfigService.getUpdateConfig();
|
||||
SysConfig sysConfig = sysConfigService.getstate();
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
AppClient appClient = appClientService.getAppClientData("app");
|
||||
jsonObject.put("webname",config.getWebname());
|
||||
jsonObject.put("websubtitle",config.getWebsubtitle());
|
||||
jsonObject.put("keywords",config.getWebkeywords());
|
||||
@@ -80,42 +70,62 @@ public class IndexController {
|
||||
jsonObject.put("logo",config.getLogo());
|
||||
jsonObject.put("api",updateConfig.getApi());
|
||||
jsonObject.put("register",sysConfig.getRegister());
|
||||
jsonObject.put("isuse",appClient.getIsuse());
|
||||
// jsonObject.put("packurl",appClient.getPackurl());
|
||||
jsonObject.put("clientname",appClient.getAppname());
|
||||
jsonObject.put("clientlogo",appClient.getApplogo());
|
||||
jsonObject.put("appupdate",appClient.getAppupdate());
|
||||
msg.setData(jsonObject);
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/upload")//upimg new
|
||||
@PostMapping(value = {"/upload","/client/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);
|
||||
public Msg upimg(HttpServletRequest request, @RequestParam(value = "file", required = false) MultipartFile multipartFile,Integer day) {
|
||||
return uploadServicel.uploadForLoc(request,multipartFile,day,null);
|
||||
}
|
||||
|
||||
//根据网络图片url上传
|
||||
@PostMapping(value = "/uploadForUrl") //new
|
||||
@PostMapping(value = {"/uploadForUrl","/client/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 +146,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 +156,6 @@ public class IndexController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/checkStatus")
|
||||
@ResponseBody
|
||||
public Msg checkStatus(HttpServletRequest request) {
|
||||
@@ -182,22 +193,26 @@ 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);
|
||||
iRedisService.setValue(userIP+"_hellohao_verifyCode",code);
|
||||
ShearCaptcha captcha = CaptchaUtil.createShearCaptcha(90, 35, 2, 2);
|
||||
captcha.setGenerator(new MathGenerator(1));
|
||||
httpSession.setAttribute("_hellohao_verifyCode",captcha);
|
||||
response.setHeader("Pragma", "no-cache");
|
||||
response.setHeader("Cache-Control", "no-cache");
|
||||
response.setDateHeader("Expires", 0);
|
||||
response.setContentType("image/jpeg");
|
||||
response.getOutputStream().write(verifyCode.getImgBytes());
|
||||
captcha.write(response.getOutputStream());
|
||||
final Timer timer=new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
httpSession.removeAttribute("_hellohao_verifyCode");
|
||||
timer.cancel();
|
||||
}
|
||||
},5*60*1000);
|
||||
response.getOutputStream().flush();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@@ -208,15 +223,21 @@ public class IndexController {
|
||||
public void verifyCodeForRegister(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);
|
||||
iRedisService.setValue(userIP+"_hellohao_verifyCodeForRegister",code);
|
||||
ShearCaptcha captcha = CaptchaUtil.createShearCaptcha(90, 35, 2, 2);
|
||||
httpSession.setAttribute("_hellohao_verifyCodeForRegister",captcha);
|
||||
response.setHeader("Pragma", "no-cache");
|
||||
response.setHeader("Cache-Control", "no-cache");
|
||||
response.setDateHeader("Expires", 0);
|
||||
response.setContentType("image/jpeg");
|
||||
response.getOutputStream().write(verifyCode.getImgBytes());
|
||||
captcha.write(response.getOutputStream());
|
||||
final Timer timer=new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
httpSession.removeAttribute("_hellohao_verifyCodeForRegister");
|
||||
timer.cancel();
|
||||
}
|
||||
},5*60*1000);
|
||||
response.getOutputStream().flush();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
@@ -227,89 +248,62 @@ public class IndexController {
|
||||
public void verifyCodeForRetrieve(HttpServletRequest request, HttpServletResponse response,HttpSession httpSession) {
|
||||
IVerifyCodeGen iVerifyCodeGen = new SimpleCharVerifyCodeGenImpl();
|
||||
try {
|
||||
VerifyCode verifyCode = iVerifyCodeGen.generate(80, 38);
|
||||
String code = verifyCode.getCode();
|
||||
System.out.println("verifyCodeForRetrieve-zhaoHui httpSession ID==="+httpSession.getId());
|
||||
String userIP = GetIPS.getIpAddr(request);
|
||||
iRedisService.setValue(userIP+"_hellohao_verifyCodeForEmailRetrieve",code);
|
||||
ShearCaptcha captcha = CaptchaUtil.createShearCaptcha(90, 35, 2, 2);
|
||||
httpSession.setAttribute("_hellohao_verifyCodeForEmailRetrieve",captcha);
|
||||
response.setHeader("Pragma", "no-cache");
|
||||
response.setHeader("Cache-Control", "no-cache");
|
||||
response.setDateHeader("Expires", 0);
|
||||
response.setContentType("image/jpeg");
|
||||
response.getOutputStream().write(verifyCode.getImgBytes());
|
||||
captcha.write(response.getOutputStream());
|
||||
final Timer timer=new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
httpSession.removeAttribute("_hellohao_verifyCodeForEmailRetrieve");
|
||||
timer.cancel();
|
||||
}
|
||||
},5*60*1000);
|
||||
response.getOutputStream().flush();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
//删除图像
|
||||
@PostMapping("/deleImagesByUid") //new
|
||||
@PostMapping({"/deleImagesByUid","/client/deleImagesByUid"}) //new
|
||||
@ResponseBody
|
||||
public Msg deleImagesByUid(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||
String imguid = jsonObj.getString("imguid");
|
||||
Images image = imgService.selectImgUrlByImgUID(imguid);
|
||||
if(null==image){
|
||||
msg.setInfo("图像已不存在,删除成功");
|
||||
return msg;
|
||||
}
|
||||
//判断是不是自己的图片 因为这里的删除功能只能是首页上传后才会调用的接口 能删除的图片只能是自己的
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
User user = (User) subject.getPrincipal();
|
||||
if(null!=user){
|
||||
if(user.getId()!=image.getUserid()){
|
||||
//由于integer类型的==比较方式适用于-128~127之间,所以超过这个范围就会不对
|
||||
// if(user.getId()!=image.getUserid()){
|
||||
if(!user.getId().equals(image.getUserid())){
|
||||
msg.setInfo("删除失败,该图片不允许你执行操作");
|
||||
msg.setCode("100403");
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
Integer keyid = image.getSource();
|
||||
String imgname = image.getImgname();
|
||||
Keys key = keysService.selectKeys(keyid);
|
||||
//删除图片
|
||||
boolean isDele = false;
|
||||
if (key.getStorageType() == 1) {
|
||||
isDele = nosImageupload.delNOS(key.getId(), imgname);
|
||||
} else if (key.getStorageType() == 2) {
|
||||
isDele = ossImageupload.delOSS(key.getId(), imgname);
|
||||
} else if (key.getStorageType() == 3) {
|
||||
isDele = ussImageupload.delUSS(key.getId(), imgname);
|
||||
} else if (key.getStorageType() == 4) {
|
||||
isDele = kodoImageupload.delKODO(key.getId(), imgname);
|
||||
} else if (key.getStorageType() == 5) {
|
||||
isDele = LocUpdateImg.deleteLOCImg(imgname);
|
||||
}else if (key.getStorageType() == 6) {
|
||||
isDele = cosImageupload.delCOS(key.getId(), imgname);
|
||||
}else if (key.getStorageType() == 7) {
|
||||
isDele = ftpImageupload.delFTP(key.getId(), imgname);
|
||||
}else if (key.getStorageType() == 8) {
|
||||
isDele = uFileImageupload.delUFile(key.getId(), imgname);
|
||||
}else {
|
||||
System.err.println("未获取到对象存储参数,删除失败。");
|
||||
}
|
||||
//删除库
|
||||
if(isDele){
|
||||
try {
|
||||
imgAndAlbumService.deleteImgAndAlbum(imgname);
|
||||
imgTempService.delImgAndExp(image.getImguid());
|
||||
imgService.deleimg(image.getId());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
msg.setInfo("图片记录时发生错误");
|
||||
msg.setCode("500");
|
||||
return msg;
|
||||
}
|
||||
msg.setInfo("删除成功");
|
||||
}else{
|
||||
imgAndAlbumService.deleteImgAndAlbum(imgname);
|
||||
imgTempService.delImgAndExp(image.getImguid());
|
||||
imgService.deleimg(image.getId());
|
||||
msg.setInfo("图片记录已删除,但是图片源删除失败");
|
||||
msg = deleimages.dele(null,image.getId());
|
||||
List<Long> Delids = (List<Long>)msg.getData();
|
||||
if(!Delids.contains(image.getId())){
|
||||
msg.setCode("500");
|
||||
msg.setInfo("图像删除失败");
|
||||
}else{
|
||||
msg.setCode("200");
|
||||
msg.setInfo("图像已成功删除");
|
||||
}
|
||||
System.out.println("返回的值:"+msg.toString());
|
||||
return msg;
|
||||
}
|
||||
|
||||
|
||||
//没有权限
|
||||
@RequestMapping("/authError")
|
||||
@ResponseBody
|
||||
public Msg authError(HttpServletRequest request){
|
||||
@@ -319,7 +313,6 @@ public class IndexController {
|
||||
return msg;
|
||||
}
|
||||
|
||||
//认证失败
|
||||
@RequestMapping("/jurisError")
|
||||
@ResponseBody
|
||||
public Msg jurisError(HttpServletRequest request){
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
package cn.hellohao.controller;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import cn.hellohao.auth.filter.SubjectFilter;
|
||||
import cn.hellohao.auth.token.JWTUtil;
|
||||
import cn.hellohao.config.SysName;
|
||||
import cn.hellohao.pojo.*;
|
||||
import cn.hellohao.service.*;
|
||||
import cn.hellohao.utils.*;
|
||||
import cn.hutool.captcha.ShearCaptcha;
|
||||
import cn.hutool.core.util.HexUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authc.IncorrectCredentialsException;
|
||||
import org.apache.shiro.authc.UnknownAccountException;
|
||||
@@ -21,9 +17,15 @@ import org.apache.shiro.subject.Subject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/user")
|
||||
@@ -39,21 +41,18 @@ public class UserController {
|
||||
@Autowired
|
||||
private SysConfigService sysConfigService;
|
||||
@Autowired
|
||||
private UserGroupService userGroupService;
|
||||
@Autowired
|
||||
IRedisService iRedisService;
|
||||
|
||||
@PostMapping("/register")
|
||||
@ResponseBody
|
||||
public Msg Register(HttpServletRequest request, @RequestParam(value = "data", defaultValue = "") String data) {//Validated
|
||||
public Msg Register(HttpSession httpSession, @RequestParam(value = "data", defaultValue = "") String data) {//Validated
|
||||
Msg msg = new Msg();
|
||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||
String username = jsonObj.getString("username");
|
||||
String email = jsonObj.getString("email");
|
||||
String password = Base64Encryption.encryptBASE64(jsonObj.getString("password").getBytes());
|
||||
String userIP = GetIPS.getIpAddr(request);
|
||||
String verifyCodeForRegister = jsonObj.getString("verifyCode");
|
||||
Object redis_verifyCodeForRegister = iRedisService.getValue(userIP+"_hellohao_verifyCodeForRegister");
|
||||
ShearCaptcha redis_verifyCodeForRegister = (ShearCaptcha) httpSession.getAttribute("_hellohao_verifyCodeForRegister");//iRedisService.getValue(userIP+"_verifyCodeForRegister");
|
||||
if(!SetText.checkEmail(email)){
|
||||
msg.setCode("110403");
|
||||
msg.setInfo("邮箱格式不正确");
|
||||
@@ -74,7 +73,7 @@ public class UserController {
|
||||
msg.setInfo("验证码不能为空。");
|
||||
return msg;
|
||||
}
|
||||
if((redis_verifyCodeForRegister.toString().toLowerCase()).compareTo((verifyCodeForRegister.toLowerCase()))==0){
|
||||
if(redis_verifyCodeForRegister.verify(verifyCodeForRegister.toLowerCase())){
|
||||
User user = new User();
|
||||
UploadConfig updateConfig = uploadConfigService.getUpdateConfig();
|
||||
EmailConfig emailConfig = emailConfigService.getemail();
|
||||
@@ -132,14 +131,13 @@ public class UserController {
|
||||
|
||||
@PostMapping("/login")//new
|
||||
@ResponseBody
|
||||
public Msg login(HttpServletRequest request,@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
public Msg login(HttpServletRequest request,HttpSession httpSession,@RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||
String email = jsonObj.getString("email");
|
||||
String password = Base64Encryption.encryptBASE64(jsonObj.getString("password").getBytes());
|
||||
String verifyCode = jsonObj.getString("verifyCode");
|
||||
String userIP = GetIPS.getIpAddr(request);
|
||||
Object redis_VerifyCode = iRedisService.getValue(userIP+"_hellohao_verifyCode");
|
||||
ShearCaptcha redis_VerifyCode = (ShearCaptcha)httpSession.getAttribute("_hellohao_verifyCode");
|
||||
if(null==redis_VerifyCode){
|
||||
msg.setCode("4035");
|
||||
msg.setInfo("验证码已失效,请重新弄获取。");
|
||||
@@ -149,7 +147,7 @@ public class UserController {
|
||||
msg.setInfo("验证码不能为空。");
|
||||
return msg;
|
||||
}
|
||||
if((redis_VerifyCode.toString().toLowerCase()).compareTo((verifyCode.toLowerCase()))==0){
|
||||
if(redis_VerifyCode.verify(verifyCode.toLowerCase())){
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
UsernamePasswordToken tokenOBJ = new UsernamePasswordToken(email,password);
|
||||
tokenOBJ.setRememberMe(true);
|
||||
@@ -240,15 +238,13 @@ public class UserController {
|
||||
|
||||
@PostMapping("/retrievePass") //new
|
||||
@ResponseBody
|
||||
public Msg retrievePass(HttpServletRequest request, @RequestParam(value = "data", defaultValue = "") String data) {
|
||||
public Msg retrievePass(HttpServletRequest request,HttpSession httpSession, @RequestParam(value = "data", defaultValue = "") String data) {
|
||||
Msg msg = new Msg();
|
||||
try {
|
||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||
String email = jsonObj.getString("email");
|
||||
String retrieveCode = jsonObj.getString("retrieveCode");
|
||||
String userIP = GetIPS.getIpAddr(request);
|
||||
Object redis_verifyCodeForEmailRetrieve = iRedisService.getValue(userIP+"_hellohao_verifyCodeForEmailRetrieve");
|
||||
|
||||
ShearCaptcha redis_verifyCodeForEmailRetrieve =(ShearCaptcha) httpSession.getAttribute("_hellohao_verifyCodeForEmailRetrieve");// iRedisService.getValue(userIP+"_verifyCodeForEmailRetrieve");
|
||||
EmailConfig emailConfig = emailConfigService.getemail();
|
||||
if(null==redis_verifyCodeForEmailRetrieve){
|
||||
msg.setCode("4035");
|
||||
@@ -259,7 +255,7 @@ public class UserController {
|
||||
msg.setInfo("验证码不能为空。");
|
||||
return msg;
|
||||
}
|
||||
if((redis_verifyCodeForEmailRetrieve.toString().toLowerCase()).compareTo((retrieveCode.toLowerCase()))!=0){
|
||||
if(!redis_verifyCodeForEmailRetrieve.verify(retrieveCode.toLowerCase())){
|
||||
msg.setCode("40034");
|
||||
msg.setInfo("验证码不正确");
|
||||
return msg;
|
||||
@@ -279,7 +275,7 @@ public class UserController {
|
||||
Config config = configService.getSourceype();
|
||||
Thread thread = new Thread() {
|
||||
public void run() {
|
||||
Integer a = NewSendEmail.sendEmailFindPass(emailConfig,user.getUsername(), user.getUid(), user.getEmail(),config);//SendEmail.sendEmailT(message, user.getUsername(), user.getUid(), user.getEmail(),emailConfig,config);
|
||||
Integer a = NewSendEmail.sendEmailFindPass(emailConfig,user.getUsername(), user.getUid(), user.getEmail(),config);//SendEmail.sendEmailT(message, user.getUsername(), user.getUid(), user.getEmail(),emailConfig,config);
|
||||
}
|
||||
};
|
||||
thread.start();
|
||||
|
||||
@@ -23,4 +23,6 @@ public interface AlbumMapper {
|
||||
List<Album> selectAlbumURLList(Album album);
|
||||
|
||||
Integer selectAlbumCount(@Param("userid") Integer userid);
|
||||
|
||||
Integer updateAlbum(Album album);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package cn.hellohao.dao;
|
||||
|
||||
import cn.hellohao.pojo.AppClient;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* @author Hellohao
|
||||
* @version 1.0
|
||||
* @date 2022-06-10 18:33
|
||||
*/
|
||||
|
||||
@Mapper
|
||||
public interface AppClientMapper {
|
||||
AppClient getAppClientData(@Param("id") String id);
|
||||
|
||||
Integer editAppClientData(AppClient appClient);
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -10,45 +10,24 @@ import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface UserMapper {
|
||||
//注册
|
||||
Integer register(User user);
|
||||
|
||||
//登录
|
||||
Integer login(@Param("email") String email, @Param("password") String password,@Param("uid") String uid);
|
||||
|
||||
//获取用户信息
|
||||
User getUsers(User user);
|
||||
|
||||
//插入图片
|
||||
User loginByToken (@Param("token") String token);
|
||||
Integer insertimg(Images img);
|
||||
|
||||
//修改资料
|
||||
Integer change(User user);
|
||||
|
||||
Integer changeUser(User user);
|
||||
//检查用户名是否重复
|
||||
Integer checkUsername(@Param("username") String username);
|
||||
|
||||
Integer getUserTotal();
|
||||
|
||||
List<User> getuserlist(String username);
|
||||
|
||||
//刪除用戶
|
||||
Integer deleuser(@Param("id") Integer id);
|
||||
|
||||
//查询用户名或者邮箱是否存在
|
||||
Integer countusername(@Param("username") String username);
|
||||
|
||||
Integer countmail(@Param("email") String email);
|
||||
|
||||
Integer uiduser(@Param("uid") String uid);
|
||||
|
||||
User getUsersMail(@Param("uid") String uid);
|
||||
Integer setisok (User user);
|
||||
|
||||
Integer setmemory(User user);
|
||||
User getUsersid(@Param("id") Integer id);
|
||||
|
||||
List<User> getuserlistforgroupid(@Param("groupid") Integer groupid);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package cn.hellohao.pojo;
|
||||
|
||||
public class AppClient {
|
||||
|
||||
private String id;
|
||||
private String isuse;
|
||||
private String winpackurl;
|
||||
private String macpackurl;
|
||||
private String appname;
|
||||
private String applogo;
|
||||
private String appupdate;
|
||||
|
||||
public AppClient(){}
|
||||
|
||||
public AppClient(String id, String isuse, String winpackurl, String macpackurl, String appname, String applogo, String appupdate) {
|
||||
this.id = id;
|
||||
this.isuse = isuse;
|
||||
this.winpackurl = winpackurl;
|
||||
this.macpackurl = macpackurl;
|
||||
this.appname = appname;
|
||||
this.applogo = applogo;
|
||||
this.appupdate = appupdate;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getIsuse() {
|
||||
return isuse;
|
||||
}
|
||||
|
||||
public void setIsuse(String isuse) {
|
||||
this.isuse = isuse;
|
||||
}
|
||||
|
||||
public String getWinpackurl() {
|
||||
return winpackurl;
|
||||
}
|
||||
|
||||
public void setWinpackurl(String winpackurl) {
|
||||
this.winpackurl = winpackurl;
|
||||
}
|
||||
|
||||
public String getMacpackurl() {
|
||||
return macpackurl;
|
||||
}
|
||||
|
||||
public void setMacpackurl(String macpackurl) {
|
||||
this.macpackurl = macpackurl;
|
||||
}
|
||||
|
||||
public String getAppname() {
|
||||
return appname;
|
||||
}
|
||||
|
||||
public void setAppname(String appname) {
|
||||
this.appname = appname;
|
||||
}
|
||||
|
||||
public String getApplogo() {
|
||||
return applogo;
|
||||
}
|
||||
|
||||
public void setApplogo(String applogo) {
|
||||
this.applogo = applogo;
|
||||
}
|
||||
|
||||
public String getAppupdate() {
|
||||
return appupdate;
|
||||
}
|
||||
|
||||
public void setAppupdate(String isupdate) {
|
||||
this.appupdate = isupdate;
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ public class User {
|
||||
private String memory;
|
||||
private Integer groupid;
|
||||
private String groupname;
|
||||
private String token;
|
||||
|
||||
private Long counts;//用户img counts
|
||||
|
||||
@@ -25,7 +26,7 @@ public class User {
|
||||
}
|
||||
|
||||
public User(Integer id, String username, String password, String email, String birthder, Integer level, String uid,
|
||||
Integer isok, String memory, Integer groupid,String groupname,Long counts) {
|
||||
Integer isok, String memory, Integer groupid,String groupname,Long counts,String token) {
|
||||
this.id = id;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
@@ -38,6 +39,7 @@ public class User {
|
||||
this.groupid = groupid;
|
||||
this.groupname = groupname;
|
||||
this.counts = counts;
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
@@ -135,4 +137,12 @@ public class User {
|
||||
public void setCounts(Long counts) {
|
||||
this.counts = counts;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(String token) {
|
||||
this.token = token;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,21 +63,21 @@ public class FirstJob {
|
||||
imgService.deleimgForImgUid(images.getImguid());
|
||||
Keys keys = keysService.selectKeys(images.getSource());
|
||||
if(keys.getStorageType()==1){
|
||||
firstJob.nosImageupload.delNOS(keys.getId(),images.getImgname());
|
||||
firstJob.nosImageupload.delNOS(keys.getId(),images);
|
||||
}else if (keys.getStorageType()==2){
|
||||
firstJob.ossImageupload.delOSS(keys.getId(), images.getImgname());
|
||||
firstJob.ossImageupload.delOSS(keys.getId(), images);
|
||||
}else if(keys.getStorageType()==3){
|
||||
firstJob.ussImageupload.delUSS(keys.getId(), images.getImgname());
|
||||
firstJob.ussImageupload.delUSS(keys.getId(), images);
|
||||
}else if(keys.getStorageType()==4){
|
||||
firstJob.kodoImageupload.delKODO(keys.getId(), images.getImgname());
|
||||
firstJob.kodoImageupload.delKODO(keys.getId(), images);
|
||||
}else if(keys.getStorageType()==5){
|
||||
LocUpdateImg.deleteLOCImg(images.getImgname());
|
||||
LocUpdateImg.deleteLOCImg(images);
|
||||
}else if(keys.getStorageType()==6){
|
||||
firstJob.cosImageupload.delCOS(keys.getId(),images.getImgname());
|
||||
firstJob.cosImageupload.delCOS(keys.getId(),images);
|
||||
}else if(keys.getStorageType()==7){
|
||||
firstJob.ftpImageupload.delFTP(keys.getId(), images.getImgname());
|
||||
firstJob.ftpImageupload.delFTP(keys.getId(), images);
|
||||
}else if(keys.getStorageType()==8){
|
||||
firstJob.uFileImageupload.delUFile(keys.getId(), images.getImgname());
|
||||
firstJob.uFileImageupload.delUFile(keys.getId(), images);
|
||||
}else{
|
||||
System.err.println("未获取到对象存储参数,上传失败。");
|
||||
}
|
||||
|
||||
@@ -26,4 +26,6 @@ public interface AlbumService {
|
||||
List<Album> selectAlbumURLList(Album album);
|
||||
|
||||
Integer selectAlbumCount(Integer userid);
|
||||
|
||||
Integer updateAlbum(Album album);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
package cn.hellohao.service;
|
||||
|
||||
import cn.hellohao.pojo.AppClient;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public interface AppClientService {
|
||||
|
||||
AppClient getAppClientData( String id);
|
||||
|
||||
Integer editAppClientData(AppClient appClient);
|
||||
}
|
||||
@@ -13,12 +13,9 @@ import java.util.List;
|
||||
*/
|
||||
@Service
|
||||
public interface CodeService {
|
||||
//查询扩容码
|
||||
List<Code> selectCode(String value);
|
||||
Code selectCodekey(String code);
|
||||
//添加
|
||||
Integer addCode(Code code);
|
||||
//删除扩容码
|
||||
Integer deleteCode(String code);
|
||||
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ import java.util.List;
|
||||
@Service
|
||||
public interface ImgTempService {
|
||||
List<Images> selectDelImgUidList(String datatime);
|
||||
|
||||
Integer delImgAndExp(String imguid);
|
||||
|
||||
Integer insertImgExp(ImgTemp imgDataExp);
|
||||
}
|
||||
|
||||
@@ -9,11 +9,13 @@ import java.util.List;
|
||||
|
||||
@Service
|
||||
public interface KeysService {
|
||||
//查询密钥
|
||||
Keys selectKeys(Integer id);
|
||||
|
||||
List<Keys> getStorageName();
|
||||
|
||||
List<Keys> getStorage();
|
||||
//修改key
|
||||
|
||||
Msg updateKey(Keys key);
|
||||
|
||||
List<Keys> getKeys();
|
||||
}
|
||||
|
||||
@@ -11,5 +11,6 @@ import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public interface SysConfigService {
|
||||
SysConfig getstate();
|
||||
|
||||
Integer setstate(SysConfig sysConfig);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public interface UploadConfigService {
|
||||
|
||||
UploadConfig getUpdateConfig();
|
||||
|
||||
Integer setUpdateConfig(UploadConfig updateConfig);
|
||||
}
|
||||
|
||||
@@ -10,10 +10,17 @@ import org.springframework.stereotype.Service;
|
||||
*/
|
||||
@Service
|
||||
public interface UserGroupService {
|
||||
|
||||
UserGroup useridgetusergroup(Integer userid);
|
||||
|
||||
UserGroup idgetusergroup(Integer id);
|
||||
|
||||
Integer addusergroup(UserGroup userGroup);
|
||||
|
||||
Integer updateusergroup(UserGroup userGroup);
|
||||
|
||||
Integer updateusergroupdefault(Integer groupid);
|
||||
|
||||
Integer deleusergroup(Integer userid);
|
||||
|
||||
}
|
||||
|
||||
@@ -2,31 +2,26 @@ package cn.hellohao.service;
|
||||
|
||||
import cn.hellohao.pojo.Images;
|
||||
import cn.hellohao.pojo.User;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public interface UserService {
|
||||
//注册
|
||||
Integer register(User user);
|
||||
|
||||
//登录
|
||||
Integer login(String email, String password,String uid);
|
||||
|
||||
//获取用户信息
|
||||
User loginByToken (String token);
|
||||
|
||||
User getUsers(User user);
|
||||
|
||||
//插入图片
|
||||
Integer insertimg(Images img);
|
||||
|
||||
//修改资料
|
||||
Integer change(User user);
|
||||
|
||||
Integer changeUser(User user);
|
||||
|
||||
//检查用户名是否重复
|
||||
Integer checkUsername(String username);
|
||||
|
||||
Integer getUserTotal();
|
||||
@@ -35,7 +30,6 @@ public interface UserService {
|
||||
|
||||
Integer deleuser(Integer id);
|
||||
|
||||
//查询用户名或者邮箱是否存在
|
||||
Integer countusername(String username);
|
||||
|
||||
Integer countmail(String email);
|
||||
@@ -43,8 +37,12 @@ public interface UserService {
|
||||
Integer uiduser(String uid);
|
||||
|
||||
User getUsersMail(String uid);
|
||||
|
||||
Integer setisok (User user);
|
||||
|
||||
Integer setmemory(User user);
|
||||
|
||||
User getUsersid(Integer id);
|
||||
|
||||
List<User> getuserlistforgroupid(Integer groupid);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ public class AlbumServiceImpl implements AlbumService {
|
||||
@Autowired
|
||||
ImgMapper imgMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public JSONArray getAlbumList(JSONArray array) {
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
@@ -84,6 +83,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 +112,6 @@ public class AlbumServiceImpl implements AlbumService {
|
||||
}
|
||||
return ret1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.hellohao.service.impl;
|
||||
|
||||
import cn.hellohao.dao.AppClientMapper;
|
||||
import cn.hellohao.pojo.AppClient;
|
||||
import cn.hellohao.service.AppClientService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class AppClientServiceImpl implements AppClientService {
|
||||
|
||||
@Autowired
|
||||
AppClientMapper appClientMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public AppClient getAppClientData(String id) {
|
||||
return appClientMapper.getAppClientData(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer editAppClientData(AppClient appClient) {
|
||||
return appClientMapper.editAppClientData(appClient);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,9 @@
|
||||
package cn.hellohao.service.impl;
|
||||
|
||||
import cn.hellohao.pojo.Images;
|
||||
import cn.hellohao.pojo.Keys;
|
||||
import cn.hellohao.pojo.ReturnImage;
|
||||
import cn.hellohao.pojo.UploadConfig;
|
||||
import cn.hellohao.utils.*;
|
||||
import com.netease.cloud.auth.BasicCredentials;
|
||||
import com.netease.cloud.auth.Credentials;
|
||||
import com.netease.cloud.services.nos.NosClient;
|
||||
import com.netease.cloud.services.nos.model.ObjectMetadata;
|
||||
import com.netease.cloud.services.nos.transfer.TransferManager;
|
||||
import com.qcloud.cos.COSClient;
|
||||
import com.qcloud.cos.ClientConfig;
|
||||
import com.qcloud.cos.auth.BasicCOSCredentials;
|
||||
@@ -18,10 +13,8 @@ import com.qcloud.cos.exception.CosServiceException;
|
||||
import com.qcloud.cos.model.*;
|
||||
import com.qcloud.cos.region.Region;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
@@ -73,16 +66,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");
|
||||
@@ -93,10 +86,10 @@ public class COSImageupload {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Boolean delCOS(Integer keyID, String fileName) {
|
||||
public Boolean delCOS(Integer keyID, Images images) {
|
||||
boolean b = true;
|
||||
try {
|
||||
cosClient.deleteObject(key.getBucketname(), fileName);
|
||||
cosClient.deleteObject(key.getBucketname(), images.getImgname());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
b = false;
|
||||
|
||||
@@ -2,24 +2,16 @@ package cn.hellohao.service.impl;
|
||||
|
||||
import cn.hellohao.dao.*;
|
||||
import cn.hellohao.pojo.*;
|
||||
import cn.hellohao.pojo.vo.PageResultBean;
|
||||
import cn.hellohao.service.ImgAndAlbumService;
|
||||
import cn.hellohao.service.SysConfigService;
|
||||
import cn.hellohao.utils.*;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baidu.aip.contentcensor.AipContentCensor;
|
||||
import com.baidu.aip.contentcensor.EImgType;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import net.coobird.thumbnailator.filters.Watermark;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@@ -34,25 +26,9 @@ import java.util.*;
|
||||
@Service
|
||||
public class ClientService {
|
||||
|
||||
@Autowired
|
||||
private ImgAndAlbumService imgAndAlbumService;
|
||||
@Autowired
|
||||
private NOSImageupload nOSImageupload;
|
||||
@Autowired
|
||||
private OSSImageupload ossImageupload;
|
||||
@Autowired
|
||||
private USSImageupload ussImageupload;
|
||||
@Autowired
|
||||
private KODOImageupload kodoImageupload;
|
||||
@Autowired
|
||||
private COSImageupload cosImageupload;
|
||||
@Autowired
|
||||
private SysConfigService sysConfigService;
|
||||
@Autowired
|
||||
private FTPImageupload ftpImageupload;
|
||||
@Autowired
|
||||
private UFileImageupload uFileImageupload;
|
||||
@Autowired
|
||||
private UserMapper userMapper;
|
||||
@Autowired
|
||||
private KeysMapper keysMapper;
|
||||
@@ -74,7 +50,6 @@ public class ClientService {
|
||||
String md5key = null;
|
||||
Integer setday = 0;
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
Config config = configMapper.getSourceype();
|
||||
String userip = GetIPS.getIpAddr(request);
|
||||
UploadConfig uploadConfig = uploadConfigMapper.getUpdateConfig();
|
||||
if (uploadConfig.getApi() != 1) {
|
||||
@@ -92,14 +67,12 @@ public class ClientService {
|
||||
u2.setEmail(email);
|
||||
u2.setPassword(Base64Encryption.encryptBASE64(pass.getBytes()));
|
||||
User u = userMapper.getUsers(u2);
|
||||
//判断用户的账号密码是否存在(正确)
|
||||
if (null == u || u.getIsok() != 1) {
|
||||
msg.setCode("4006");
|
||||
msg.setInfo("用户信息不正确,账号异常");
|
||||
return msg;
|
||||
}
|
||||
String imguid = UUID.randomUUID().toString().replace("-", "");
|
||||
//判断上传前的一些用户限制信息
|
||||
Msg msg1 = updateImgCheck(u, uploadConfig);
|
||||
if (!msg1.getCode().equals("300")) {
|
||||
return msg1;
|
||||
@@ -128,7 +101,6 @@ public class ClientService {
|
||||
}
|
||||
Msg fileMiME = TypeDict.FileMiME(file);
|
||||
if (!fileMiME.getCode().equals("200")) {
|
||||
//非图像文本
|
||||
msg.setCode("4009");
|
||||
msg.setInfo(fileMiME.getInfo());
|
||||
return msg;
|
||||
@@ -147,22 +119,20 @@ public class ClientService {
|
||||
}
|
||||
}
|
||||
}
|
||||
//判断图片是否存在
|
||||
if(Integer.valueOf(sysConfigService.getstate().getCheckduplicate())==1) {
|
||||
Images imaOBJ = new Images();
|
||||
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;
|
||||
}
|
||||
}
|
||||
Map<String, File> map = new HashMap<>();
|
||||
String fileName = file.getName();
|
||||
if (file.exists()) {
|
||||
map.put(prefix, file);
|
||||
}
|
||||
@@ -196,7 +166,6 @@ public class ClientService {
|
||||
jsonObject.put("url", img.getImgurl());
|
||||
jsonObject.put("name", imgname);
|
||||
jsonObject.put("size", img.getSizes());
|
||||
//启动鉴黄线程
|
||||
new Thread(() -> {
|
||||
LegalImageCheck(img);
|
||||
}).start();
|
||||
@@ -207,7 +176,6 @@ public class ClientService {
|
||||
}
|
||||
file.delete();
|
||||
msg.setData(jsonObject);
|
||||
// 新代码结束=========
|
||||
return msg;
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
@@ -251,7 +219,7 @@ public class ClientService {
|
||||
}
|
||||
updatePath = user.getUsername();
|
||||
group= GetCurrentSource.GetSource(user.getId());
|
||||
memory = Long.valueOf(user.getMemory())*1024*1024;//单位 B
|
||||
memory = Long.valueOf(user.getMemory());//单位 B
|
||||
TotleMemory = Long.valueOf(uploadConfig.getFilesizeuser());//单位 B
|
||||
UsedTotleMemory = imgMapper.getusermemory(user.getId())==null?0L:imgMapper.getusermemory(user.getId());//单位 B
|
||||
}
|
||||
@@ -268,7 +236,6 @@ public class ClientService {
|
||||
}
|
||||
|
||||
//图片鉴黄
|
||||
|
||||
private synchronized void LegalImageCheck(Images images){
|
||||
System.out.println("非法图像鉴别进程启动");
|
||||
Imgreview imgreview = null;
|
||||
@@ -301,7 +268,7 @@ public class ClientService {
|
||||
if (imgdata.getInteger("type") == 1) {
|
||||
Images img = new Images();
|
||||
img.setImgname(images.getImgname());
|
||||
img.setViolation("1[1]");//数字是鉴别平台的主键ID,括号是非法的类型,参考上面的注释
|
||||
img.setViolation("1[1]");
|
||||
imgMapper.setImg(img);
|
||||
Imgreview imgv = new Imgreview();
|
||||
imgv.setId(1);
|
||||
|
||||
@@ -19,7 +19,6 @@ public class CodeServiceImpl implements CodeService {
|
||||
@Autowired
|
||||
private CodeMapper codeMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public List<Code> selectCode(String value) {
|
||||
return codeMapper.selectCode(value);
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.springframework.stereotype.Service;
|
||||
public class ConfigServiceImpl implements ConfigService {
|
||||
@Autowired
|
||||
private ConfigMapper configMapper;
|
||||
|
||||
@Override
|
||||
public Config getSourceype() {
|
||||
return configMapper.getSourceype();
|
||||
|
||||
@@ -10,6 +10,7 @@ import org.springframework.stereotype.Service;
|
||||
public class EmailServiceImpl implements EmailConfigService {
|
||||
@Autowired
|
||||
EmailConfigMapper emailConfigMapper;
|
||||
|
||||
@Override
|
||||
public EmailConfig getemail() {
|
||||
return emailConfigMapper.getemail();
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
package cn.hellohao.service.impl;
|
||||
|
||||
import cn.hellohao.pojo.Images;
|
||||
import cn.hellohao.pojo.Keys;
|
||||
import cn.hellohao.pojo.ReturnImage;
|
||||
import cn.hellohao.pojo.UploadConfig;
|
||||
import cn.hellohao.utils.*;
|
||||
import cn.hellohao.utils.FTPUtils;
|
||||
import cn.hellohao.utils.Print;
|
||||
import cn.hellohao.utils.SetText;
|
||||
import org.apache.commons.net.ftp.FTPClient;
|
||||
import org.apache.commons.net.ftp.FTPReply;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class FTPImageupload {
|
||||
static FTPClient ftpClient1 ;
|
||||
static Keys key;
|
||||
|
||||
public ReturnImage ImageuploadFTP(Map<String, File> fileMap, String username,Integer keyID) {
|
||||
@@ -51,13 +51,10 @@ public class FTPImageupload {
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
returnImage.setCode("500");
|
||||
// ImgUrl.put(null, 500);
|
||||
}
|
||||
return returnImage;
|
||||
|
||||
}
|
||||
|
||||
//初始化FTP对象存储
|
||||
public static Integer Initialize(Keys k) {
|
||||
int ret = -1;
|
||||
if(k.getEndpoint()!=null && k.getAccessSecret()!=null && k.getEndpoint()!=null && k.getRequestAddress()!=null ) {
|
||||
@@ -82,7 +79,6 @@ public class FTPImageupload {
|
||||
}
|
||||
ret = 1;
|
||||
key = k;
|
||||
// KeyObjectMap objectMap = new KeyObjectMap(ftp,k);
|
||||
} catch (IOException e) {
|
||||
System.out.println("FTP Object Is null");
|
||||
return -1;
|
||||
@@ -98,12 +94,12 @@ public class FTPImageupload {
|
||||
try{
|
||||
File afile=new File(a);
|
||||
File bfile=new File(p2);//定义一个复制后的文件路径
|
||||
bfile.createNewFile();//新建文件
|
||||
FileInputStream c=new FileInputStream(afile);//定义FileInputStream对象
|
||||
FileOutputStream d=new FileOutputStream(bfile);//定义FileOutputStream对象
|
||||
byte[] date=new byte[512];//定义一个byte数组
|
||||
bfile.createNewFile();
|
||||
FileInputStream c=new FileInputStream(afile);
|
||||
FileOutputStream d=new FileOutputStream(bfile);
|
||||
byte[] date=new byte[512];
|
||||
int i=0;
|
||||
while((i=c.read(date))>0){//判断有没有读取到文件末尾
|
||||
while((i=c.read(date))>0){
|
||||
d.write(date);
|
||||
}
|
||||
c.close();
|
||||
@@ -114,7 +110,7 @@ public class FTPImageupload {
|
||||
}
|
||||
}
|
||||
|
||||
public Boolean delFTP(Integer keyID, String fileName) {
|
||||
public Boolean delFTP(Integer keyID, Images images) {
|
||||
boolean b = true;
|
||||
try {
|
||||
String[] host = key.getEndpoint().split("\\:");
|
||||
@@ -123,7 +119,7 @@ public class FTPImageupload {
|
||||
//创建FTP客户端,所有的操作都基于FTPClinet
|
||||
FTPUtils ftps = new FTPUtils(h, p, key.getAccessKey(), key.getAccessSecret());
|
||||
ftps.open();
|
||||
b = ftps.deleteFile(fileName);
|
||||
b = ftps.deleteFile(images.getImgname());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
b = false;
|
||||
|
||||
@@ -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{
|
||||
|
||||
@@ -1,48 +1,17 @@
|
||||
package cn.hellohao.service.impl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import cn.hellohao.pojo.User;
|
||||
import cn.hellohao.utils.Print;
|
||||
import com.UpYun;
|
||||
import com.aliyun.oss.OSSClient;
|
||||
import com.qcloud.cos.COSClient;
|
||||
import com.qcloud.cos.ClientConfig;
|
||||
import com.qcloud.cos.auth.BasicCOSCredentials;
|
||||
import com.qcloud.cos.auth.COSCredentials;
|
||||
import com.qcloud.cos.exception.CosClientException;
|
||||
import com.qcloud.cos.exception.CosServiceException;
|
||||
import com.qcloud.cos.region.Region;
|
||||
import com.qiniu.common.QiniuException;
|
||||
import com.qiniu.common.Zone;
|
||||
import com.qiniu.storage.BucketManager;
|
||||
import com.qiniu.storage.Configuration;
|
||||
import com.qiniu.util.Auth;
|
||||
import com.upyun.UpException;
|
||||
import org.apache.commons.net.ftp.FTPClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.netease.cloud.auth.BasicCredentials;
|
||||
import com.netease.cloud.auth.Credentials;
|
||||
import com.netease.cloud.services.nos.NosClient;
|
||||
import com.netease.cloud.services.nos.model.Bucket;
|
||||
import com.netease.cloud.services.nos.model.CannedAccessControlList;
|
||||
import com.netease.cloud.services.nos.transfer.TransferManager;
|
||||
|
||||
import cn.hellohao.dao.ImgMapper;
|
||||
import cn.hellohao.pojo.Images;
|
||||
import cn.hellohao.pojo.Keys;
|
||||
import cn.hellohao.pojo.User;
|
||||
import cn.hellohao.service.ImgService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class ImgServiceImpl implements ImgService {
|
||||
@Autowired
|
||||
//@Resource
|
||||
private ImgMapper imgMapper;
|
||||
|
||||
@Override
|
||||
@@ -65,113 +34,7 @@ public class ImgServiceImpl implements ImgService {
|
||||
public Images selectByPrimaryKey(Integer id) {
|
||||
return imgMapper.selectByPrimaryKey(id);
|
||||
}
|
||||
//删除对象存储的图片文件
|
||||
public void delect(Keys key, String fileName) {
|
||||
// 初始化
|
||||
Credentials credentials = new BasicCredentials(key.getAccessKey(), key.getAccessSecret());
|
||||
NosClient nosClient = new NosClient(credentials);
|
||||
nosClient.setEndpoint(key.getEndpoint());
|
||||
// 初始化TransferManager
|
||||
TransferManager transferManager = new TransferManager(nosClient);
|
||||
//列举桶
|
||||
ArrayList bucketList = new ArrayList();
|
||||
String tname = "";
|
||||
for (Bucket bucket : nosClient.listBuckets()) {
|
||||
bucketList.add(bucket.getName());
|
||||
}
|
||||
for (Object object : bucketList) {
|
||||
tname = object.toString();
|
||||
//查看桶的ACL
|
||||
CannedAccessControlList acl = nosClient.getBucketAcl(object.toString());
|
||||
}
|
||||
//这种方法不能删除指定文件夹下的文件
|
||||
boolean isExist = nosClient.doesObjectExist(tname, fileName, null);
|
||||
System.out.println("文件是否存在:" + isExist);
|
||||
if (isExist) {
|
||||
nosClient.deleteObject(tname, fileName);
|
||||
}
|
||||
}
|
||||
public void delectOSS(Keys key, String fileName) {
|
||||
String endpoint = key.getEndpoint();
|
||||
String accessKeyId = key.getAccessKey();
|
||||
String accessKeySecret = key.getAccessSecret();
|
||||
String bucketName = key.getBucketname();
|
||||
String objectName = fileName;
|
||||
OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);
|
||||
ossClient.deleteObject(bucketName, objectName);
|
||||
ossClient.shutdown();
|
||||
}
|
||||
//删除USS对象存储的图片文件
|
||||
public void delectUSS(Keys key, String fileName) {
|
||||
UpYun upyun = new UpYun(key.getBucketname(), key.getAccessKey(), key.getAccessSecret());
|
||||
try {
|
||||
boolean result = upyun.deleteFile(fileName, null);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (UpException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void delectUFile(Keys key, String fileName) {
|
||||
UpYun upyun = new UpYun(key.getBucketname(), key.getAccessKey(), key.getAccessSecret());
|
||||
try {
|
||||
boolean result = upyun.deleteFile(fileName, null);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (UpException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void delectKODO(Keys key, String fileName) {
|
||||
Configuration cfg;
|
||||
if(key.getEndpoint().equals("1")){cfg = new Configuration(Zone.zone0());}
|
||||
else if(key.getEndpoint().equals("2")){cfg = new Configuration(Zone.zone1());}
|
||||
else if(key.getEndpoint().equals("3")){cfg = new Configuration(Zone.zone2());}
|
||||
else if(key.getEndpoint().equals("4")){cfg = new Configuration(Zone.zoneNa0());}
|
||||
else{cfg = new Configuration(Zone.zoneAs0());}
|
||||
Auth auth = Auth.create(key.getAccessKey(), key.getAccessSecret());
|
||||
BucketManager bucketManager = new BucketManager(auth, cfg);
|
||||
try {
|
||||
bucketManager.delete(key.getBucketname(), fileName);
|
||||
} catch (QiniuException ex) {
|
||||
//如果遇到异常,说明删除失败
|
||||
System.err.println(ex.code());
|
||||
System.err.println(ex.response.toString());
|
||||
}
|
||||
}
|
||||
//删除COS对象存储的图片文件
|
||||
public void delectCOS(Keys key, String fileName) {
|
||||
COSCredentials cred = new BasicCOSCredentials(key.getAccessKey(), key.getAccessSecret());
|
||||
Region region = new Region(key.getEndpoint());
|
||||
ClientConfig clientConfig = new ClientConfig(region);
|
||||
COSClient cosClient= new COSClient(cred, clientConfig);
|
||||
try {
|
||||
String bucketName = key.getBucketname();
|
||||
String userkey = fileName;
|
||||
cosClient.deleteObject(key.getBucketname(), userkey);
|
||||
} catch (CosServiceException serverException) {
|
||||
serverException.printStackTrace();
|
||||
} catch (CosClientException clientException) {
|
||||
clientException.printStackTrace();
|
||||
}
|
||||
}
|
||||
public void delectFTP(Keys key, String fileName) {
|
||||
FTPClient ftp = new FTPClient();
|
||||
String[] host = key.getEndpoint().split("\\:");
|
||||
String h = host[0];
|
||||
Integer p = Integer.parseInt(host[1]);
|
||||
try {
|
||||
if(!ftp.isConnected()){
|
||||
ftp.connect(h,p);
|
||||
}
|
||||
ftp.login(key.getAccessKey(), key.getAccessSecret());
|
||||
ftp.deleteFile(fileName);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Print.warning("删除FTP存储的图片失败");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Integer counts(Integer userid) {
|
||||
// TODO Auto-generated method stub
|
||||
@@ -220,7 +83,7 @@ public class ImgServiceImpl implements ImgService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Images selectImgUrlByMD5(String md5key) {
|
||||
public List<Images> selectImgUrlByMD5(String md5key) {
|
||||
return imgMapper.selectImgUrlByMD5(md5key);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package cn.hellohao.service.impl;
|
||||
|
||||
import cn.hellohao.config.GlobalConstant;
|
||||
import cn.hellohao.pojo.Images;
|
||||
import cn.hellohao.pojo.Keys;
|
||||
import cn.hellohao.pojo.ReturnImage;
|
||||
import cn.hellohao.pojo.UploadConfig;
|
||||
@@ -33,7 +35,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());
|
||||
@@ -99,14 +100,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){
|
||||
@@ -118,10 +119,10 @@ public class KODOImageupload {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Boolean delKODO(Integer keyID, String fileName) {
|
||||
public Boolean delKODO(Integer keyID, Images images) {
|
||||
boolean b = true;
|
||||
try {
|
||||
bucketManager.delete(key.getBucketname(), fileName);
|
||||
bucketManager.delete(key.getBucketname(), images.getImgname());
|
||||
} catch (Exception ex) {
|
||||
b = false;
|
||||
}
|
||||
|
||||
@@ -52,9 +52,8 @@ public class KeysServiceImpl implements KeysService {
|
||||
public Msg updateKey(Keys key) {
|
||||
Msg msg = new Msg();
|
||||
Integer ret = -2;
|
||||
//修改完初始化
|
||||
if(key.getStorageType()==1){
|
||||
ret =nOSImageupload.Initialize(key);//实例化网易
|
||||
ret =nOSImageupload.Initialize(key);
|
||||
}else if (key.getStorageType()==2){
|
||||
ret = ossImageupload.Initialize(key);
|
||||
}else if(key.getStorageType()==3 ){
|
||||
|
||||
@@ -1,26 +1,17 @@
|
||||
package cn.hellohao.service.impl;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.*;
|
||||
|
||||
import cn.hellohao.exception.StorageSourceInitException;
|
||||
import cn.hellohao.pojo.Images;
|
||||
import cn.hellohao.pojo.Keys;
|
||||
import cn.hellohao.pojo.ReturnImage;
|
||||
import cn.hellohao.pojo.UploadConfig;
|
||||
import cn.hellohao.utils.*;
|
||||
import com.netease.cloud.services.nos.model.NOSObjectSummary;
|
||||
import com.netease.cloud.services.nos.model.ObjectListing;
|
||||
import com.netease.cloud.services.nos.model.ObjectMetadata;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import cn.hellohao.utils.SetText;
|
||||
import com.netease.cloud.auth.BasicCredentials;
|
||||
import com.netease.cloud.auth.Credentials;
|
||||
import com.netease.cloud.services.nos.NosClient;
|
||||
import com.netease.cloud.services.nos.model.Bucket;
|
||||
import com.netease.cloud.services.nos.transfer.TransferManager;
|
||||
import com.netease.cloud.services.nos.model.ObjectListing;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import cn.hellohao.pojo.Keys;
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class NOSImageupload {
|
||||
@@ -49,7 +40,6 @@ public class NOSImageupload {
|
||||
}
|
||||
|
||||
|
||||
//初始化网易NOS对象存储
|
||||
public static Integer Initialize(Keys k) {
|
||||
int ret = -1;
|
||||
if(k.getEndpoint()!=null && k.getAccessSecret()!=null && k.getEndpoint()!=null
|
||||
@@ -58,13 +48,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");
|
||||
@@ -72,19 +62,13 @@ public class NOSImageupload {
|
||||
}
|
||||
}
|
||||
}
|
||||
//throw new StorageSourceInitException("当前数据源配置不完整,请管理员前往后台配置。");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
public Boolean delNOS(Integer keyID, String fileName) {
|
||||
public Boolean delNOS(Integer keyID, Images images) {
|
||||
boolean b =true;
|
||||
try {
|
||||
//这种方法不能删除指定文件夹下的文件
|
||||
boolean isExist = nosClient.doesObjectExist(key.getBucketname(), fileName, null);
|
||||
if (isExist) {
|
||||
nosClient.deleteObject(key.getBucketname(), fileName);
|
||||
}
|
||||
nosClient.deleteObject(key.getBucketname(), images.getImgname());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
b =false;
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
package cn.hellohao.service.impl;
|
||||
|
||||
import cn.hellohao.pojo.Images;
|
||||
import cn.hellohao.pojo.Keys;
|
||||
import cn.hellohao.pojo.Msg;
|
||||
import cn.hellohao.pojo.ReturnImage;
|
||||
import cn.hellohao.utils.*;
|
||||
import cn.hellohao.utils.SetText;
|
||||
import cn.hellohao.utils.TypeDict;
|
||||
import com.aliyun.oss.OSS;
|
||||
import com.aliyun.oss.OSSClient;
|
||||
import com.aliyun.oss.OSSClientBuilder;
|
||||
import com.aliyun.oss.model.ObjectListing;
|
||||
import com.aliyun.oss.model.ObjectMetadata;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class OSSImageupload {
|
||||
static OSSClient ossClient;
|
||||
static OSS ossClient;
|
||||
static Keys key;
|
||||
|
||||
public ReturnImage ImageuploadOSS(Map<String, File> fileMap, String username,Integer keyID){
|
||||
@@ -52,11 +54,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");
|
||||
@@ -67,10 +69,10 @@ public class OSSImageupload {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public boolean delOSS(Integer keyID, String fileName){
|
||||
public boolean delOSS(Integer keyID, Images images){
|
||||
boolean b =true;
|
||||
try {
|
||||
ossClient.deleteObject(key.getBucketname(), fileName);
|
||||
ossClient.deleteObject(key.getBucketname(), images.getImgname());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
b = false;
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
package cn.hellohao.service.impl;
|
||||
|
||||
import cn.hellohao.pojo.Images;
|
||||
import cn.hellohao.pojo.Keys;
|
||||
import cn.hellohao.pojo.Msg;
|
||||
import cn.hellohao.pojo.ReturnImage;
|
||||
import cn.hellohao.pojo.UploadConfig;
|
||||
import cn.hellohao.utils.*;
|
||||
import cn.hellohao.utils.SetText;
|
||||
import cn.hellohao.utils.TypeDict;
|
||||
import com.UpYun;
|
||||
import com.aliyun.oss.model.ObjectMetadata;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class UFileImageupload {
|
||||
@@ -49,20 +49,18 @@ public class UFileImageupload {
|
||||
|
||||
}
|
||||
|
||||
//ufile初始化
|
||||
public static Integer Initialize(Keys k) {
|
||||
int ret = -1;
|
||||
if(k.getAccessSecret()!=null && k.getAccessKey()!=null
|
||||
&& k.getBucketname()!=null && k.getRequestAddress()!=null ) {
|
||||
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");
|
||||
@@ -73,10 +71,10 @@ public class UFileImageupload {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Boolean delUFile(Integer keyID, String fileName) {
|
||||
public Boolean delUFile(Integer keyID, Images images) {
|
||||
boolean b = true;
|
||||
try {
|
||||
boolean result = uFile.deleteFile(fileName, null);
|
||||
boolean result = uFile.deleteFile(images.getImgname(), null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
b = false;
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
package cn.hellohao.service.impl;
|
||||
|
||||
import cn.hellohao.pojo.Images;
|
||||
import cn.hellohao.pojo.Keys;
|
||||
import cn.hellohao.pojo.Msg;
|
||||
import cn.hellohao.pojo.ReturnImage;
|
||||
import cn.hellohao.pojo.UploadConfig;
|
||||
import cn.hellohao.utils.*;
|
||||
import cn.hellohao.utils.SetText;
|
||||
import cn.hellohao.utils.TypeDict;
|
||||
import com.UpYun;
|
||||
import com.aliyun.oss.OSSClient;
|
||||
import com.aliyun.oss.model.ObjectMetadata;
|
||||
import com.upyun.UpException;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class USSImageupload {
|
||||
@@ -61,12 +58,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");
|
||||
@@ -77,10 +74,10 @@ public class USSImageupload {
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Boolean delUSS(Integer keyID, String fileName) {
|
||||
public Boolean delUSS(Integer keyID, Images images) {
|
||||
boolean b = true;
|
||||
try {
|
||||
boolean result = upyun.deleteFile(fileName, null);
|
||||
boolean result = upyun.deleteFile(images.getImgname(), null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
b=false;
|
||||
|
||||
@@ -5,10 +5,7 @@ import cn.hellohao.pojo.*;
|
||||
import cn.hellohao.service.ImgTempService;
|
||||
import cn.hellohao.service.SysConfigService;
|
||||
import cn.hellohao.utils.*;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baidu.aip.contentcensor.AipContentCensor;
|
||||
import com.baidu.aip.contentcensor.EImgType;
|
||||
@@ -20,7 +17,8 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
@@ -50,9 +48,8 @@ public class UploadServicel {
|
||||
ImgTempService imgTempService;
|
||||
|
||||
|
||||
|
||||
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();
|
||||
@@ -70,7 +67,6 @@ public class UploadServicel {
|
||||
if(imgUrl==null){
|
||||
file = SetFiles.changeFile_new(multipartFile);
|
||||
}else{
|
||||
//说明是URL上传
|
||||
Msg imgData = uploadForURL(request, imgUrl);
|
||||
if(imgData.getCode().equals("200")){
|
||||
file = new File((String) imgData.getData());
|
||||
@@ -79,13 +75,10 @@ public class UploadServicel {
|
||||
}
|
||||
}
|
||||
String imguid = UUID.randomUUID().toString().replace("-", "");
|
||||
//判断上传前的一些用户限制信息
|
||||
Msg msg1 = updateImgCheck(u,uploadConfig);
|
||||
if(!msg1.getCode().equals("300")){
|
||||
return msg1;
|
||||
}
|
||||
|
||||
//判断可用容量
|
||||
sourceKeyId = group.getKeyid();
|
||||
Keys key = keysMapper.selectKeys(sourceKeyId);
|
||||
Long tmp = (memory == -1 ? -2 : UsedTotleMemory);
|
||||
@@ -94,8 +87,6 @@ public class UploadServicel {
|
||||
msg.setInfo(u==null?"游客空间已用尽":"您的可用空间不足");
|
||||
return msg;
|
||||
}
|
||||
|
||||
//判断图片有没有超出设定大小
|
||||
if (file.length() > TotleMemory) {
|
||||
System.err.println("文件大小:"+file.length());
|
||||
System.err.println("最大限制:"+TotleMemory);
|
||||
@@ -112,7 +103,6 @@ public class UploadServicel {
|
||||
}
|
||||
Msg fileMiME = TypeDict.FileMiME(file);
|
||||
if(!fileMiME.getCode().equals("200")) {
|
||||
//非图像文本
|
||||
msg.setCode("4000");
|
||||
msg.setInfo(fileMiME.getInfo());
|
||||
return msg;
|
||||
@@ -120,24 +110,19 @@ public class UploadServicel {
|
||||
if(md5key==null || md5key.equals("")){
|
||||
md5key = UUID.randomUUID().toString().replace("-", "");
|
||||
}
|
||||
|
||||
//判断图片是否存在
|
||||
if(Integer.valueOf(sysConfigService.getstate().getCheckduplicate())==1){
|
||||
Images imaOBJ = new Images();
|
||||
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("shortLink",images.getShortlink());
|
||||
jsonObject.put("imguid",images.get(0).getImguid());
|
||||
msg.setData(jsonObject);
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String prefix = file.getName().substring(file.getName().lastIndexOf(".")+1);
|
||||
//判断黑名单
|
||||
if (uploadConfig.getBlacklist() != null) {
|
||||
@@ -151,7 +136,6 @@ public class UploadServicel {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, File> map = new HashMap<>();
|
||||
if (file.exists()) {
|
||||
map.put(prefix, file);//prefix
|
||||
@@ -194,7 +178,6 @@ public class UploadServicel {
|
||||
jsonObject.put("url", img.getImgurl());
|
||||
jsonObject.put("name", imgname);
|
||||
jsonObject.put("imguid",img.getImguid());
|
||||
// jsonObject.put("shortLink", img.getShortlink());
|
||||
new Thread(()->{LegalImageCheck(img);}).start();
|
||||
}else{
|
||||
msg.setCode("5001");
|
||||
@@ -213,25 +196,18 @@ public class UploadServicel {
|
||||
|
||||
}
|
||||
|
||||
|
||||
//通过图片Url上传图片
|
||||
public static Msg uploadForURL(HttpServletRequest request, String imgurl){
|
||||
final Msg msg = new Msg();
|
||||
//先判断是不是有效链接
|
||||
// final boolean valid = ImgUrlUtil.isValid(imgurl);
|
||||
if(true){
|
||||
Long imgsize = null;
|
||||
Long imgsize = 0L;
|
||||
try {
|
||||
imgsize = ImgUrlUtil.getFileLength(imgurl);
|
||||
if(imgsize>0){
|
||||
// String uuid= UUID.randomUUID().toString().replace("-", "");
|
||||
if(imgsize==0){
|
||||
String ShortUID = SetText.getShortUuid();
|
||||
String savePath = request.getSession().getServletContext().getRealPath("/")+File.separator+"hellohaotmp"+File.separator;
|
||||
Map<String ,Object> bl =ImgUrlUtil.downLoadFromUrl (imgurl, ShortUID, savePath);
|
||||
if((Boolean) bl.get("res")==true){
|
||||
// File file = new File();
|
||||
msg.setCode("200");
|
||||
msg.setData(bl.get("imgPath"));//savePath + File.separator + ShortUID
|
||||
msg.setData(bl.get("imgPath"));
|
||||
return msg;
|
||||
}else{
|
||||
if(bl.get("StatusCode").equals("110403")){
|
||||
@@ -245,7 +221,7 @@ public class UploadServicel {
|
||||
msg.setCode("500");
|
||||
msg.setInfo("获取资源失败");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
msg.setCode("500");
|
||||
msg.setInfo("获取资源失败");
|
||||
}
|
||||
@@ -253,15 +229,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){
|
||||
@@ -270,18 +246,17 @@ public class UploadServicel {
|
||||
try {
|
||||
dateFormat = new SimpleDateFormat("yyyy/MM/dd");
|
||||
if (user == null) {
|
||||
//用户没有登陆,值判断游客能不能上传即可
|
||||
if(uploadConfig.getIsupdate()!=1){
|
||||
msg.setCode("1000");
|
||||
msg.setInfo("系统已禁用游客上传");
|
||||
return msg;
|
||||
}
|
||||
updatePath="tourist";
|
||||
group = GetCurrentSource.GetSource(null);
|
||||
memory = Long.valueOf(uploadConfig.getVisitormemory());//单位 B 游客设置总量
|
||||
TotleMemory = Long.valueOf(uploadConfig.getFilesizetourists());//单位 B 游客单文件大小
|
||||
UsedTotleMemory = imgMapper.getusermemory(0)==null?0L : imgMapper.getusermemory(0);//单位 B
|
||||
} else {
|
||||
//判断用户能不能上传
|
||||
if(uploadConfig.getUserclose()!=1){
|
||||
msg.setCode("1001");
|
||||
msg.setInfo("系统已禁用上传功能");
|
||||
@@ -289,7 +264,7 @@ public class UploadServicel {
|
||||
}
|
||||
updatePath = user.getUsername();
|
||||
group= GetCurrentSource.GetSource(user.getId());
|
||||
memory = Long.valueOf(user.getMemory())*1024*1024;//单位 B
|
||||
memory = Long.valueOf(user.getMemory());//单位 B *1024*1024
|
||||
TotleMemory = Long.valueOf(uploadConfig.getFilesizeuser());//单位 B
|
||||
UsedTotleMemory = imgMapper.getusermemory(user.getId())==null?0L:imgMapper.getusermemory(user.getId());//单位 B
|
||||
}
|
||||
@@ -365,7 +340,6 @@ public class UploadServicel {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//计算时间
|
||||
public static String plusDay(int setday){
|
||||
Date d = new Date();
|
||||
|
||||
@@ -31,6 +31,11 @@ public class UserServiceImpl implements UserService {
|
||||
return userMapper.login(email, password,uid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public User loginByToken(String token) {
|
||||
return userMapper.loginByToken(token);
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getUsers(User user) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
package cn.hellohao.service.impl;
|
||||
|
||||
import cn.hellohao.pojo.Images;
|
||||
import cn.hellohao.pojo.Keys;
|
||||
import cn.hellohao.pojo.Msg;
|
||||
import cn.hellohao.service.ImgAndAlbumService;
|
||||
import cn.hellohao.service.ImgService;
|
||||
import cn.hellohao.service.ImgTempService;
|
||||
import cn.hellohao.utils.LocUpdateImg;
|
||||
import cn.hellohao.utils.progress.MyProgress;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class deleImages {
|
||||
|
||||
|
||||
@Autowired
|
||||
private NOSImageupload nosImageupload;
|
||||
@Autowired
|
||||
private OSSImageupload ossImageupload;
|
||||
@Autowired
|
||||
private COSImageupload cosImageupload;
|
||||
@Autowired
|
||||
private KODOImageupload kodoImageupload;
|
||||
@Autowired
|
||||
private USSImageupload ussImageupload;
|
||||
@Autowired
|
||||
private UFileImageupload uFileImageupload;
|
||||
@Autowired
|
||||
private FTPImageupload ftpImageupload;
|
||||
@Autowired
|
||||
private ImgAndAlbumService imgAndAlbumService;
|
||||
@Autowired
|
||||
private ImgTempService imgTempService;
|
||||
@Autowired
|
||||
private ImgService imgService;
|
||||
@Autowired
|
||||
private KeysServiceImpl keysService;
|
||||
|
||||
|
||||
public Msg dele(HttpSession httpSession,Integer... imgIds) {
|
||||
Msg msg = new Msg();
|
||||
MyProgress myProgress = new MyProgress();
|
||||
myProgress.InitializeDelImg();
|
||||
List<Integer> ids = new ArrayList<>();
|
||||
int successCount = 0;
|
||||
List<String> errorIds = new ArrayList<>();
|
||||
for (Integer id : imgIds) {
|
||||
//删除图片
|
||||
boolean isDele = false;
|
||||
try {
|
||||
Images image = imgService.selectByPrimaryKey(id);
|
||||
Keys key = keysService.selectKeys(image.getSource());
|
||||
if (key.getStorageType() == 1) {
|
||||
isDele = nosImageupload.delNOS(key.getId(), image);
|
||||
} else if (key.getStorageType() == 2) {
|
||||
isDele = ossImageupload.delOSS(key.getId(), image);
|
||||
} else if (key.getStorageType() == 3) {
|
||||
isDele = ussImageupload.delUSS(key.getId(), image);
|
||||
} else if (key.getStorageType() == 4) {
|
||||
isDele = kodoImageupload.delKODO(key.getId(), image);
|
||||
} else if (key.getStorageType() == 5) {
|
||||
isDele = LocUpdateImg.deleteLOCImg(image);
|
||||
} else if (key.getStorageType() == 6) {
|
||||
isDele = cosImageupload.delCOS(key.getId(), image);
|
||||
} else if (key.getStorageType() == 7) {
|
||||
isDele = ftpImageupload.delFTP(key.getId(), image);
|
||||
} else if (key.getStorageType() == 8) {
|
||||
isDele = uFileImageupload.delUFile(key.getId(), image);
|
||||
} else {
|
||||
System.err.println("未获取到对象存储参数,删除失败。");
|
||||
}
|
||||
if(isDele){
|
||||
try {
|
||||
imgAndAlbumService.deleteImgAndAlbum(image.getImgurl());
|
||||
imgTempService.delImgAndExp(image.getImguid());
|
||||
imgService.deleimg(image.getId());
|
||||
ids.add(image.getId());
|
||||
successCount++;
|
||||
System.out.println("删除成功加一个"+image.getId());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.err.println(image.getImgname()+":图片数据库记录时发生错误");
|
||||
errorIds.add(image.getImgurl());
|
||||
}
|
||||
}
|
||||
myProgress.setDelSuccessCount(successCount);
|
||||
myProgress.setDelSuccessImgList(ids);
|
||||
myProgress.setDelErrorImgListt(errorIds);
|
||||
if(null !=httpSession){
|
||||
httpSession.setAttribute("myProgressForDel",myProgress);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
System.err.println("删除的时候发生了一些异常");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
myProgress.setDelOCT(true);
|
||||
msg.setData(ids);
|
||||
return msg;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,11 @@
|
||||
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;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Properties;
|
||||
import java.util.UUID;
|
||||
|
||||
@@ -46,8 +43,6 @@ public class FirstRun implements InitializingBean {
|
||||
if(ret1==0){
|
||||
Print.Normal("In execution...");
|
||||
RunSqlScript.RunInsert(sql2);
|
||||
;
|
||||
|
||||
}else{
|
||||
if(ret1>0){
|
||||
Print.Normal("Stage 1");
|
||||
@@ -85,11 +80,21 @@ public class FirstRun implements InitializingBean {
|
||||
RunSqlScript.RunInsert(sql9);
|
||||
Print.Normal("Stage 7");
|
||||
}
|
||||
|
||||
// Integer ret6 = RunSqlScript.RunSelectCount(judgeTable+"'imgandalbum' and column_name = 'notes' and TABLE_SCHEMA='picturebed'");
|
||||
Integer ret6 = RunSqlScript.RunSelectCount(judgeTable+" 'user' and column_name = 'token'");
|
||||
if(ret6==0){
|
||||
RunSqlScript.RunInsert(sql12);
|
||||
Print.Normal("Add user.token");
|
||||
}
|
||||
Integer isappclient = RunSqlScript.RunSelectCount(isTableName+"'appclient'");
|
||||
if(isappclient==0){
|
||||
Integer integer = RunSqlScript.RunInsert(createAppclient);
|
||||
RunSqlScript.RunInsert(instartAppclient);
|
||||
Print.Normal("Add table.appclient");
|
||||
}
|
||||
// Integer ret6 = RunSqlScript.RunSelectCount(judgeTable+" 'imgdata' and column_name = 'idname'");
|
||||
// if(ret6==0){
|
||||
// RunSqlScript.RunInsert(sql11);
|
||||
// Print.Normal("Stage 8");
|
||||
// Print.Normal("Add imgdata.idname");
|
||||
// }
|
||||
|
||||
RunSqlScript.RunInsert(sql10);
|
||||
@@ -103,11 +108,12 @@ public class FirstRun implements InitializingBean {
|
||||
}
|
||||
|
||||
//检查表是否存在,后边加'imgdata' and column_name = 'explains' 检查字段是否存在
|
||||
private String judgeTable = "select count(*) from information_schema.columns where table_name = ";
|
||||
private String isTableName = "SELECT count(table_name) FROM information_schema.TABLES WHERE TABLE_SCHEMA='tbed' and table_name =";
|
||||
private String judgeTable = "select count(*) from information_schema.columns where TABLE_SCHEMA='tbed' and table_name = ";
|
||||
//创建blacklist 2019-11-29
|
||||
private String sql1 = "select count(*) from information_schema.columns where table_name = 'uploadconfig' and column_name = 'blacklist'";
|
||||
private String sql2 = "alter table uploadconfig add blacklist varchar(500);";
|
||||
//创建imgandalbum和album 添加imgdata表字段explain 2019-12-20
|
||||
//创建imgandalbum和album 添加imgdata表字段explain 2019-12-20
|
||||
private String sql3 ="CREATE TABLE `imgandalbum` (`imgname` varchar(5000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,`albumkey` varchar(5000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic";
|
||||
private String sql4 ="CREATE TABLE `album` (`albumkey` varchar(5000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,`albumtitle` varchar(5000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,`createdate` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `password` varchar(5000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic";
|
||||
private String sql6 = "alter table imgdata add explains varchar(5000)";
|
||||
@@ -116,11 +122,16 @@ public class FirstRun implements InitializingBean {
|
||||
//添加imgdata表字段md5key
|
||||
private String sql8 = "alter table imgdata add md5key varchar(5000)";
|
||||
private String sql9 = "ALTER TABLE config ADD theme int(4) DEFAULT '1' COMMENT '主题' ";
|
||||
//修改字段长度
|
||||
//修改字段长度
|
||||
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)";
|
||||
// 图片标识名字段
|
||||
private String sql11 = "alter table `imgdata` add idname varchar(255) DEFAULT '未命名' ;";
|
||||
|
||||
private String sql12 = "alter table tbed.user add `token` varchar(255)";
|
||||
//创建客户端程序相关表
|
||||
private String createAppclient = "CREATE TABLE `appclient` (`id` varchar(10) NOT NULL,`isuse` varchar(10) NOT NULL,`winpackurl` varchar(255) NULL DEFAULT NULL,`macpackurl` varchar(255) NULL DEFAULT NULL,`appname` varchar(20) NULL,`applogo` varchar(255) NULL,`appupdate` varchar(10) NOT NULL) ";
|
||||
private String instartAppclient = "INSERT INTO `appclient` VALUES ('app', 'on', NULL, NULL, 'Hellohao图像托管', 'https://hellohao.nos-eastchina1.126.net/TbedClient/app.png', 'off');";
|
||||
|
||||
//添加imgandalbum字段notes(添加画廊图片说明)
|
||||
// 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));
|
||||
|
||||
@@ -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;
|
||||
@@ -135,6 +134,7 @@ public class ImgUrlUtil {
|
||||
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,6 +1,7 @@
|
||||
package cn.hellohao.utils;
|
||||
|
||||
import cn.hellohao.config.GlobalConstant;
|
||||
import cn.hellohao.pojo.Images;
|
||||
import cn.hellohao.pojo.Keys;
|
||||
import cn.hellohao.pojo.ReturnImage;
|
||||
import cn.hellohao.pojo.UploadConfig;
|
||||
@@ -14,10 +15,10 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class LocUpdateImg {
|
||||
public static boolean deleteLOCImg(String imagename){
|
||||
public static boolean deleteLOCImg(Images images){
|
||||
boolean isDele = false;
|
||||
try {
|
||||
String filePath = GlobalConstant.LOCPATH + File.separator+imagename;
|
||||
String filePath = GlobalConstant.LOCPATH + File.separator+images.getImgname();
|
||||
File file = new File(filePath);
|
||||
isDele = file.delete();
|
||||
}catch (Exception e){
|
||||
|
||||
@@ -9,64 +9,6 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class TypeDict {
|
||||
/**
|
||||
常用文件的文件头如下:(以前六位为准)
|
||||
JPEG (jpg),文件头:FFD8FF
|
||||
PNG (png),文件头:89504E47
|
||||
GIF (gif),文件头:47494638
|
||||
TIFF (tif),文件头:49492A00
|
||||
Windows Bitmap (bmp),文件头:424D
|
||||
CAD (dwg),文件头:41433130
|
||||
Adobe Photoshop (psd),文件头:38425053
|
||||
Rich Text Format (rtf),文件头:7B5C727466
|
||||
XML (xml),文件头:3C3F786D6C
|
||||
HTML (html),文件头:68746D6C3E
|
||||
Email [thorough only] (eml),文件头:44656C69766572792D646174653A
|
||||
Outlook Express (dbx),文件头:CFAD12FEC5FD746F
|
||||
Outlook (pst),文件头:2142444E
|
||||
MS Word/Excel (xls.or.doc),文件头:D0CF11E0
|
||||
MS Access (mdb),文件头:5374616E64617264204A
|
||||
WordPerfect (wpd),文件头:FF575043
|
||||
Postscript (eps.or.ps),文件头:252150532D41646F6265
|
||||
Adobe Acrobat (pdf),文件头:255044462D312E
|
||||
Quicken (qdf),文件头:AC9EBD8F
|
||||
Windows Password (pwl),文件头:E3828596
|
||||
ZIP Archive (zip),文件头:504B0304
|
||||
RAR Archive (rar),文件头:52617221
|
||||
Wave (wav),文件头:57415645
|
||||
AVI (avi),文件头:41564920
|
||||
Real Audio (ram),文件头:2E7261FD
|
||||
Real Media (rm),文件头:2E524D46
|
||||
MPEG (mpg),文件头:000001BA
|
||||
MPEG (mpg),文件头:000001B3
|
||||
Quicktime (mov),文件头:6D6F6F76
|
||||
Windows Media (asf),文件头:3026B2758E66CF11
|
||||
MIDI (mid),文件头:4D546864
|
||||
*/
|
||||
public static String checkType(String xxxx) {
|
||||
|
||||
switch (xxxx) {
|
||||
case "FFD8FF": return "jpg";
|
||||
case "89504E": return "png";
|
||||
case "474946": return "jif";
|
||||
case "47494638": return "gif";
|
||||
case "424D": return "bmp";
|
||||
case "424D36": return "bmp";
|
||||
default: return "0000";
|
||||
}
|
||||
}
|
||||
|
||||
public static Boolean checkImgType(File file) {
|
||||
try {
|
||||
// 通过ImageReader来解码这个file并返回一个BufferedImage对象
|
||||
// 如果找不到合适的ImageReader则会返回null,我们可以认为这不是图片文件
|
||||
// 或者在解析过程中报错,也返回false
|
||||
Image image = ImageIO.read(file);
|
||||
return image != null;
|
||||
} catch(IOException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//apache大法
|
||||
public static Msg FileMiME(File file ){
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
package cn.hellohao.utils.progress;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MyProgress {
|
||||
|
||||
//删除图片时候的数据
|
||||
private int delSuccessCount=0;//已经成功的个数
|
||||
private List<String> delErrorImgListt = new ArrayList<>();//已经失败的图片
|
||||
private boolean delOCT=false; //控制开关
|
||||
private List<Integer> delSuccessImgList = new ArrayList<>(); //删除成功的图片
|
||||
|
||||
public void InitializeDelImg(){
|
||||
//删除图片时候的数据
|
||||
this.delSuccessCount=0;//已经成功的个数
|
||||
this.delErrorImgListt = new ArrayList<>();//已经失败的图片
|
||||
this.delOCT=false; //控制开关
|
||||
this.delSuccessImgList = new ArrayList<>(); //删除成功的图片
|
||||
}
|
||||
|
||||
public MyProgress() {
|
||||
}
|
||||
|
||||
public MyProgress(int delSuccessCount, List<String> delErrorImgListt, boolean delOCT, List<Integer> delSuccessImgList) {
|
||||
|
||||
this.delSuccessCount = delSuccessCount;
|
||||
this.delErrorImgListt = delErrorImgListt;
|
||||
this.delOCT = delOCT;
|
||||
this.delSuccessImgList = delSuccessImgList;
|
||||
}
|
||||
|
||||
public int getDelSuccessCount() {
|
||||
return delSuccessCount;
|
||||
}
|
||||
|
||||
public void setDelSuccessCount(int delSuccessCount) {
|
||||
this.delSuccessCount = delSuccessCount;
|
||||
}
|
||||
|
||||
public List<String> getDelErrorImgListt() {
|
||||
return delErrorImgListt;
|
||||
}
|
||||
|
||||
public void setDelErrorImgListt(List<String> delErrorImgListt) {
|
||||
this.delErrorImgListt = delErrorImgListt;
|
||||
}
|
||||
|
||||
public boolean getDelOCT() {
|
||||
return delOCT;
|
||||
}
|
||||
|
||||
public void setDelOCT(boolean delOCT) {
|
||||
this.delOCT = delOCT;
|
||||
}
|
||||
|
||||
public List<Integer> getDelSuccessImgList() {
|
||||
return delSuccessImgList;
|
||||
}
|
||||
|
||||
public void setDelSuccessImgList(List<Integer> delSuccessImgList) {
|
||||
this.delSuccessImgList = delSuccessImgList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MyProgress{" +
|
||||
", delSuccessCount=" + delSuccessCount +
|
||||
", delErrorImgListt=" + delErrorImgListt +
|
||||
", delOCT=" + delOCT +
|
||||
", delSuccessImgList=" + delSuccessImgList +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package cn.hellohao.utils.test;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
class counts {
|
||||
public static Long i = 5000L;
|
||||
}
|
||||
//1.创建一个实现了Runnable接口的类
|
||||
class Demo implements Runnable {
|
||||
//2.实现类去实现(重写)Runnable中的抽象方法:run()
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
while (true){
|
||||
try{
|
||||
String uuid = UUID.randomUUID().toString().replace("-", "").toLowerCase();
|
||||
HashMap<String, Object> paramMap = new HashMap<>();
|
||||
paramMap.put("email", uuid.substring(0,10)+"@163.com");
|
||||
paramMap.put("pwd", uuid+uuid+uuid);
|
||||
String result1 = HttpUtil.post("http://39.107.115.48/og/v1/user/login/email", paramMap);
|
||||
JSONObject jsonObject = JSONObject.parseObject(result1);
|
||||
System.out.println("执行第"+counts.i+"次:响应代码:"+jsonObject.getInteger("c")+","+jsonObject.getString("m"));
|
||||
System.out.println("用户UUID:"+jsonObject.getJSONObject("d").getJSONObject("user").getString("object_id"));
|
||||
if(jsonObject.getInteger("c")==200){
|
||||
String uuid2 = UUID.randomUUID().toString().replace("-", "").toLowerCase();
|
||||
HashMap<String, Object> paramMap2 = new HashMap<>();
|
||||
paramMap2.put("order_id", uuid2);
|
||||
paramMap2.put("email", uuid.substring(0,10)+"@163.com");
|
||||
paramMap2.put("info", "pay&money=永久会员 ¥12 (随功能增多会涨价)");
|
||||
paramMap2.put("product_id", "beetodo");
|
||||
paramMap2.put("pay_channel", "unkown");
|
||||
paramMap2.put("click_pay_time", "unkown");
|
||||
paramMap2.put("version", "21/1.2.6");
|
||||
String result2 = HttpUtil.post("http://39.107.115.48/og/v1/user/login/email", paramMap);
|
||||
JSONObject jsonObject2 = JSONObject.parseObject(result2);
|
||||
System.out.println("提交订单的:"+jsonObject2.getInteger("c"));
|
||||
}
|
||||
counts.i++;
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
System.err.println("报错了");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//测试类:
|
||||
class ThreadTest {
|
||||
public static void main(String[] args) {
|
||||
|
||||
//同样为了展示多线程效果,我们在main主线程中也遍历输出一下作为对比
|
||||
for (int i = 0; i < 10; i++) {
|
||||
//3.创建实现类的对象
|
||||
Demo d1 = new Demo();
|
||||
//4.将此对象作为参数传递到Thread类的构造器中,创建Thread类的对象
|
||||
Thread thread = new Thread(d1);
|
||||
//5.通过Thread类的对象调用start()
|
||||
thread.start();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,6 @@ spring.datasource.druid.filter.config.enabled=false
|
||||
spring.datasource.druid.web-stat-filter.enabled=false
|
||||
spring.datasource.druid.web-stat-filter.session-stat-enable=false
|
||||
spring.datasource.druid.stat-view-servlet.reset-enable=false
|
||||
|
||||
spring.datasource.druid.filter.stat.enabled=false
|
||||
spring.datasource.druid.filter.wall.enabled=false
|
||||
spring.datasource.druid.filter.slf4j.enabled=false
|
||||
@@ -44,3 +43,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>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.hellohao.dao.AppClientMapper">
|
||||
<select id="getAppClientData" resultType="cn.hellohao.pojo.AppClient" parameterType="string">
|
||||
select * from appclient where id = #{id}
|
||||
</select>
|
||||
|
||||
<update id="editAppClientData" parameterType="cn.hellohao.pojo.AppClient">
|
||||
UPDATE `appclient`
|
||||
<set>
|
||||
<if test="isuse != null and isuse != ''">
|
||||
isuse = #{isuse},
|
||||
</if>
|
||||
<if test="winpackurl != null">
|
||||
winpackurl = #{winpackurl},
|
||||
</if>
|
||||
<if test="macpackurl != null">
|
||||
macpackurl = #{macpackurl},
|
||||
</if>
|
||||
<if test="appname != null">
|
||||
appname = #{appname},
|
||||
</if>
|
||||
<if test="applogo != null">
|
||||
`applogo` = #{applogo},
|
||||
</if>
|
||||
<if test="appupdate != null">
|
||||
`appupdate` = #{appupdate},
|
||||
</if>
|
||||
|
||||
</set>
|
||||
where id=#{id}
|
||||
</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>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
<!-- 查询对象存储有多少种-->
|
||||
<select id="getStorage" resultType="cn.hellohao.pojo.Keys">
|
||||
SELECT id,storageType,
|
||||
SELECT storageType,id,
|
||||
CASE WHEN storageType=1 THEN '网易云'
|
||||
WHEN storageType=2 THEN '阿里云'
|
||||
WHEN storageType=3 THEN '又拍云'
|
||||
@@ -30,7 +30,7 @@
|
||||
WHEN storageType=8 THEN 'UFile'
|
||||
ELSE '未知' END AS storageName,
|
||||
keyname
|
||||
FROM `keys` GROUP BY storageType
|
||||
FROM `keys` GROUP BY storageType,id,storageName,keyname
|
||||
|
||||
</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>
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
<!-- 用户注册 -->
|
||||
<insert id="register" parameterType="cn.hellohao.pojo.User">
|
||||
INSERT INTO user (id, username, PASSWORD, email, birthder, LEVEL,uid,isok,memory,groupid)
|
||||
VALUES (NULL, #{username}, #{password}, #{email}, #{birthder}, #{level},#{uid},#{isok},#{memory},#{groupid} )
|
||||
INSERT INTO user (id, username, PASSWORD, email, birthder, LEVEL,uid,isok,memory,groupid,token)
|
||||
VALUES (NULL, #{username}, #{password}, #{email}, #{birthder}, #{level},#{uid},#{isok},#{memory},#{groupid},#{token})
|
||||
</insert>
|
||||
<!-- 查询是否有username -->
|
||||
<select id="countusername" parameterType="string" resultType="integer">
|
||||
@@ -22,7 +22,6 @@
|
||||
</select>
|
||||
<!-- uid查询用户并修改 -->
|
||||
<update id="uiduser" parameterType="cn.hellohao.pojo.User">
|
||||
<!-- UPDATE `user` set username=#{username},`password`=#{password} where email=#{email} -->
|
||||
UPDATE `user` set `isok`=1 where uid=#{uid}
|
||||
</update>
|
||||
|
||||
@@ -30,8 +29,6 @@
|
||||
<select id="login" parameterType="string" resultType="integer">
|
||||
select COUNT(*)
|
||||
from user
|
||||
<!-- where email = #{email}-->
|
||||
<!-- and password = #{password}-->
|
||||
<where>
|
||||
1=1
|
||||
<if test="email != null">
|
||||
@@ -47,6 +44,15 @@
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- Token登录 -->
|
||||
<select id="loginByToken" parameterType="string" resultType="cn.hellohao.pojo.User">
|
||||
select *
|
||||
from user
|
||||
<where>
|
||||
token = #{token}
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 查询当前用户:根据邮箱,根据id -->
|
||||
<select id="getUsers" parameterType="cn.hellohao.pojo.User" resultType="cn.hellohao.pojo.User">
|
||||
SELECT id,
|
||||
@@ -58,7 +64,8 @@
|
||||
uid,
|
||||
isok,
|
||||
memory,
|
||||
groupid
|
||||
groupid,
|
||||
token
|
||||
FROM user
|
||||
<where>
|
||||
<if test="id != null">
|
||||
@@ -70,6 +77,9 @@
|
||||
<if test="uid != null">
|
||||
and uid = #{uid}
|
||||
</if>
|
||||
<if test="token != null">
|
||||
and token = #{token}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<!-- 查询当前用户:根据id -->
|
||||
@@ -83,7 +93,8 @@
|
||||
uid,
|
||||
isok,
|
||||
memory,
|
||||
groupid
|
||||
groupid,
|
||||
token
|
||||
FROM user
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
@@ -98,7 +109,8 @@
|
||||
uid,
|
||||
isok,
|
||||
memory,
|
||||
groupid
|
||||
groupid,
|
||||
token
|
||||
FROM user
|
||||
WHERE uid = #{uid}
|
||||
</select>
|
||||
@@ -111,7 +123,6 @@
|
||||
|
||||
<!-- 修改资料 -->
|
||||
<update id="change" parameterType="cn.hellohao.pojo.User">
|
||||
<!-- UPDATE `user` set username=#{username},`password`=#{password} where email=#{email} -->
|
||||
UPDATE `user`
|
||||
<set>
|
||||
<if test="email != null">
|
||||
@@ -129,6 +140,9 @@
|
||||
<if test="groupid != null">
|
||||
`groupid` = #{groupid}
|
||||
</if>
|
||||
<if test="token != null">
|
||||
`token` = #{token},
|
||||
</if>
|
||||
</set>
|
||||
where uid=#{uid}
|
||||
</update>
|
||||
@@ -157,6 +171,9 @@
|
||||
<if test="uid != null">
|
||||
`uid` = #{uid},
|
||||
</if>
|
||||
<if test="token != null">
|
||||
`token` = #{token},
|
||||
</if>
|
||||
</set>
|
||||
where id=#{id}
|
||||
</update>
|
||||
@@ -183,6 +200,7 @@
|
||||
isok,
|
||||
ceil((memory/1024/1024)) as memory,
|
||||
groupid,
|
||||
token,
|
||||
(select groupname from `group` where id = groupid) as groupname
|
||||
FROM
|
||||
user
|
||||
@@ -203,11 +221,9 @@
|
||||
</delete>
|
||||
|
||||
<update id="setisok" parameterType="cn.hellohao.pojo.User">
|
||||
<!-- UPDATE `user` set username=#{username},`password`=#{password} where email=#{email} -->
|
||||
UPDATE `user` set `isok`=#{isok} where id=#{id}
|
||||
</update>
|
||||
<update id="setmemory" parameterType="cn.hellohao.pojo.User">
|
||||
<!-- UPDATE `user` set username=#{username},`password`=#{password} where email=#{email} -->
|
||||
UPDATE `user` set `memory`=#{memory} where id=#{id}
|
||||
</update>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user