mirror of
https://github.com/Hello-hao/Tbed.git
synced 2024-04-21 12:32:10 +00:00
Compare commits
34
Commits
hellohao-dev
...
20240102
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e2e723eb52 | ||
|
|
60db6036a5 | ||
|
|
790fded8ca | ||
|
|
fc53e4c8ac | ||
|
|
86ae47e632 | ||
|
|
241ab625c0 | ||
|
|
19c2b3ce9f | ||
|
|
c5b800ad56 | ||
|
|
c960d2a812 | ||
|
|
7906948ab7 | ||
|
|
3fce125334 | ||
|
|
062823ae53 | ||
|
|
349845e6f1 | ||
|
|
f40f4177f7 | ||
|
|
17c49157c2 | ||
|
|
e9d1d2205e | ||
|
|
422cfbb724 | ||
|
|
e65b79ab33 | ||
|
|
4e1bc1fc84 | ||
|
|
96b323e1e9 | ||
|
|
64bc91247c | ||
|
|
d2f1d75413 | ||
|
|
be8e51cd47 | ||
|
|
1d0337f725 | ||
|
|
f8d082e8bf | ||
|
|
b6c2dee9e5 | ||
|
|
603e94bdb1 | ||
|
|
646a181d03 | ||
|
|
c6c5cad4fc | ||
|
|
44b527dabd | ||
|
|
dd11dd2589 | ||
|
|
c2b4527c48 | ||
|
|
57b6c4ae72 | ||
|
|
538482a73b |
@@ -7,10 +7,12 @@
|
|||||||

|

|
||||||

|

|
||||||
|
|
||||||
|
>:exclamation: 托管的所有开源代码可能存在作者修改/测试/调整等行为,均为实验性代码,故并不保证程序或功能的可用性,如果你想要部署程序,请下载我们提供的编译整合包进行安装部署。
|
||||||
|
|
||||||
|
|
||||||
### 引导
|
### 引导
|
||||||
|
|
||||||
[官网](https://tbed.hellohao.cn) | [论坛](http://bbs.hellohao.cn) | [文档](https://doc.hellohao.cn) | [演示站](https://pic.hellohao.cn) | [桌面客户端](https://tbed.hellohao.cn/app) | [前端源码](https://github.com/Hello-hao/tbed-web)
|
[官网](https://tbed.hellohao.cn) | [文档](https://doc.hellohao.cn) | [演示站](https://pic.hellohao.cn) | [桌面客户端](https://tbed.hellohao.cn/app) | [微信小程序](https://tbed.hellohao.cn/wechat) | [前端源码](https://github.com/Hello-hao/tbed-web)
|
||||||
|
|
||||||
|
|
||||||
### 前言
|
### 前言
|
||||||
@@ -21,46 +23,17 @@
|
|||||||
|
|
||||||
**存储源支持:**
|
**存储源支持:**
|
||||||
|
|
||||||
开源版:`本地`,`阿里OSS`,`又拍USS`,`七牛KODO`,`腾讯COS`,`网易NOS`,~~`U-File`~~,`FTP`
|
开源版:`本地`,`阿里OSS`,`又拍USS`,`七牛KODO`,`腾讯COS`,`网易NOS`,`FTP`,`AWS S3协议`(`百度云BOS`,`青云Qingstor`,`Ucloud US3`,`Minio`等兼容S3协议)
|
||||||
|
|
||||||
Core版:`本地`,`阿里OSS`,`又拍USS`,`七牛KODO`,`腾讯COS`,`网易NOS`,~~`U-File`~~,`FTP`,`Backblaze(B2)`,`百度云BOS`,`青云Qingstor`,`Ucloud US3`,`Minio`,`AWS S3`等通用S3协议
|
[Core版](https://hellohao.cn):开源版的基础上增加`Backblaze(B2)` 并且可`同个对象存储商家`可开多个存储源(可添加至90+存储源)
|
||||||
|
|
||||||
|
|
||||||
|
### 更新日志 `20230925`
|
||||||
|
|
||||||
### 更新日志 `20230101`
|
- 修复一些sql异常错误的问题
|
||||||
|
|
||||||
- 优化个人相册,适配右键菜单功能。
|
|
||||||
- 修复筛选全部图片时候出现重复的问题。
|
|
||||||
- 修复上传图片后不记录图片原始名称
|
|
||||||
- 调整了上传图像的代码逻辑
|
|
||||||
- 优化 ftp 上传逻辑
|
|
||||||
- 优化多线程上传图像的查重逻辑
|
|
||||||
- 新增用户协议相关协议内容展示
|
|
||||||
- 提高系统安全性
|
|
||||||
- 优化多个页面异常问题
|
|
||||||
|
|
||||||
|
|
||||||
[^_^]:程序宣传视频:[自制宣传视频](https://www.bilibili.com/video/BV11r4y1y7mH/)
|
|
||||||
|
|
||||||
[^_^]:官网(含Core版):[https://tbed.hellohao.cn](https://tbed.hellohao.cn)
|
|
||||||
|
|
||||||
[^_^]:前端源码:[https://github.com/Hello-hao/tbed-web](https://github.com/Hello-hao/tbed-web)
|
|
||||||
|
|
||||||
[^_^]:文档地址:[https://doc.hellohao.cn](https://doc.hellohao.cn)
|
|
||||||
|
|
||||||
[^_^]:程序展示:[https://tc.hellohao.cn](https://tc.hellohao.cn)
|
|
||||||
|
|
||||||
[^_^]:作者博客:[https://www.hellohao.cn](https://www.hellohao.cn)
|
|
||||||
|
|
||||||
|
|
||||||
[^_^]:官网(含Core版)(备用):[http://tbed.wwery.com](http://tbed.wwery.com)
|
|
||||||
|
|
||||||
[^_^]:文档地址(备用):[http://doc.wwery.com](http://doc.wwery.com)
|
|
||||||
|
|
||||||
[^_^]:程序展示(备用):[http://tc.wwery.com](http://tc.wwery.com)
|
|
||||||
|
|
||||||
[^_^]:作者博客(备用):[http://www.wwery.com](http://www.wwery.com)
|
|
||||||
|
|
||||||
|
|
||||||
|
[^_^]: 程序宣传视频:[自制宣传视频](https://www.bilibili.com/video/BV11r4y1y7mH/)
|
||||||
|
|
||||||
|
|
||||||
### 主要功能
|
### 主要功能
|
||||||
@@ -105,11 +78,81 @@ Core版:`本地`,`阿里OSS`,`又拍USS`,`七牛KODO`,`腾讯COS`,`网易NOS`,
|
|||||||
|
|
||||||
- [x] 图像直链二维码生成
|
- [x] 图像直链二维码生成
|
||||||
|
|
||||||
|
### 快速开始
|
||||||
|
|
||||||
|
**Docker-compose部署:**
|
||||||
|
|
||||||
|
1. 创建`docker-compose.yml`文件
|
||||||
|
|
||||||
|
> 在服务器的任意目录创建的文件夹中创建`docker-compose.yml`文件,内容如下:
|
||||||
|
>
|
||||||
|
> (修改下方前`端域名`,`后端域名`,`数据库密码`等注释的信息,特别要注意文件格式缩进不可以乱改)
|
||||||
|
|
||||||
|
```yml
|
||||||
|
version: "3"
|
||||||
|
services:
|
||||||
|
tbed-free:
|
||||||
|
# 具体版本号需要填写目前发行的最新版本
|
||||||
|
image: hellohao/tbed-free:2023xxxx
|
||||||
|
networks:
|
||||||
|
hellohao_network:
|
||||||
|
ports:
|
||||||
|
- "10088:10088"
|
||||||
|
- "10089:10089"
|
||||||
|
volumes:
|
||||||
|
- /HellohaoData/:/HellohaoData/
|
||||||
|
environment:
|
||||||
|
MYSQL_URL: jdbc:mysql://hellohaodb/tbed?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai
|
||||||
|
# 数据库用户名(一般使用本镜像数据库无需修改,如果使用外部三方数据库自行修改自己的用户名)
|
||||||
|
MYSQL_USERNAME: root
|
||||||
|
# 自定设置一个MySQL的密码,请保证与下方 POSTGRES_PASSWORD 的变量值一致
|
||||||
|
MYSQL_PASS: tIaNGg@SHa&hIo56
|
||||||
|
# 前端域名(反代10089端口的域名)
|
||||||
|
HELLOHAO_WEB_HOST: http://pic.example.com
|
||||||
|
# 后端域名(反代10088端口的域名)
|
||||||
|
HELLOHAO_SERVER_HOST: http://server.example.com
|
||||||
|
hellohaodb:
|
||||||
|
image: hellohao/mysql-free:1.0
|
||||||
|
networks:
|
||||||
|
hellohao_network:
|
||||||
|
command:
|
||||||
|
- --default-authentication-plugin=mysql_native_password
|
||||||
|
- --character-set-server=utf8mb4
|
||||||
|
- --collation-server=utf8mb4_general_ci
|
||||||
|
- --explicit_defaults_for_timestamp=true
|
||||||
|
ports:
|
||||||
|
- "3307:3306"
|
||||||
|
volumes:
|
||||||
|
- /HellohaoData/mysql:/var/lib/mysql
|
||||||
|
environment:
|
||||||
|
# MySQL的密码
|
||||||
|
MYSQL_ROOT_PASSWORD: tIaNGg@SHa&hIo56
|
||||||
|
networks:
|
||||||
|
hellohao_network:
|
||||||
|
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 启动 Hellohao 服务
|
||||||
|
|
||||||
|
```shell
|
||||||
|
docker-compose up -d
|
||||||
|
```
|
||||||
|
|
||||||
|
更多部署教程参考程序[相关文档](http://doc.hellohao.cn)
|
||||||
|
|
||||||
|
|
||||||
|
### 启动项目
|
||||||
|
> 访问你的前端域名即可
|
||||||
|
|
||||||
|
初始用户名:`admin`
|
||||||
|
初始邮箱:`admin`
|
||||||
|
初始密码:`admin`
|
||||||
|
|
||||||
|
|
||||||
### 系统预览
|
### 系统预览
|
||||||
|
|
||||||

|

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

|

|
||||||
|
|
||||||
@@ -125,11 +168,27 @@ Core版:`本地`,`阿里OSS`,`又拍USS`,`七牛KODO`,`腾讯COS`,`网易NOS`,
|
|||||||
[^_^]: 
|
[^_^]: 
|
||||||
[^_^]: 
|
[^_^]: 
|
||||||
|
|
||||||
|
### 桌面客户端(win/mac)
|
||||||
|
> 获取地址:[官网获取](https://www.hellohao.cn/app)
|
||||||
|
|
||||||
|
> `开源版`/`Core版` 都可以使用
|
||||||
|
> 
|
||||||
|
|
||||||
|
### 微信小程序
|
||||||
|
|
||||||
|
> 仅适用于对接`Core付费版`,开源版暂不可对接使用。
|
||||||
|
> 获取地址:[官网获取](https://www.hellohao.cn/pay)
|
||||||
|
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
[//]: # ()
|
||||||
|
|
||||||
|
|
||||||
### 运行环境
|
### 运行环境
|
||||||
|
|
||||||
- JDK 1.8
|
- JDK 1.8
|
||||||
- MySQL5.5+
|
- MySQL5.7+
|
||||||
- Redis
|
- Redis
|
||||||
|
|
||||||
### 所用技术
|
### 所用技术
|
||||||
@@ -150,36 +209,9 @@ Core版:`本地`,`阿里OSS`,`又拍USS`,`七牛KODO`,`腾讯COS`,`网易NOS`,
|
|||||||
- JWT认证
|
- JWT认证
|
||||||
- Shiro
|
- Shiro
|
||||||
|
|
||||||
|
|
||||||
### 部署
|
|
||||||
|
|
||||||
> 部署方式分为两种:
|
|
||||||
> 1.一键脚本部署:`Tbed-together.zip`(操作简单)
|
|
||||||
> 2.自定义部署 前后端分离式部署:`Tbed.zip`(拓展性高适合有一定java前后端分离部署经验的人)
|
|
||||||
> 需要注意:一键部署的端口为:服务器:`10088` 前端:`10089`
|
|
||||||
|
|
||||||
详细部署教程参考程序[相关文档](http://doc.hellohao.cn)
|
|
||||||
|
|
||||||
### 启动项目
|
|
||||||
|
|
||||||
初始用户名:`admin`
|
|
||||||
初始邮箱:`admin`
|
|
||||||
初始密码:`admin`
|
|
||||||
|
|
||||||
### 客户端(win64/mac)
|
|
||||||
> 目前已经正式上线
|
|
||||||

|
|
||||||
|
|
||||||
|
|
||||||
### 微信小程序
|
|
||||||
> 目前已有测试版,更多功能开发中,开发进度的快慢要根据作者的工作压力、心情状况等自身情况进行评估。
|
|
||||||
> 暂时无法给出具体发布小程序的时间。大家期待吧。
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
[^_^]: 
|
|
||||||
|
|
||||||
### 声明
|
### 声明
|
||||||
|
Hellohao图像托管已申请[**中国国家版权局计算机软件著作权**](https://register.ccopyright.com.cn/query.html)登记,受法律法规保护。
|
||||||
|
> 登记号:2023SR1210640
|
||||||
|
|
||||||
本项目遵循[GNU Affero General Public License v3.0](https://choosealicense.com/licenses/agpl-3.0/#)开源协议,使用前请悉知。
|
本项目遵循[GNU Affero General Public License v3.0](https://choosealicense.com/licenses/agpl-3.0/#)开源协议,使用前请悉知。
|
||||||
如果你想商用或程序定制,请先与我们联系,分享你的利益。
|
如果你想商用或程序定制,请先与我们联系,分享你的利益。
|
||||||
@@ -188,12 +220,13 @@ Core版:`本地`,`阿里OSS`,`又拍USS`,`七牛KODO`,`腾讯COS`,`网易NOS`,
|
|||||||
### 反馈交流
|
### 反馈交流
|
||||||
|
|
||||||
**如果你遇到BUG欢迎反馈**
|
**如果你遇到BUG欢迎反馈**
|
||||||
|
|
||||||
- 前往论坛发帖反馈、求助:[Hellohao开发者交流论坛](http://bbs.hellohao.cn)
|
- 前往论坛发帖反馈、求助:[Hellohao开发者交流论坛](http://bbs.hellohao.cn)
|
||||||
- 也可加QQ群探讨(目前已满):864800972
|
- 也可加QQ群探讨:864800972
|
||||||
|
|
||||||
### 捐赠开发者
|
### 更多
|
||||||
|
|
||||||
**如果你也支持Hellohao图床,可以请我喝杯咖啡。我会持续更新Hellohao图床**
|
**如需程序定制或其他业务,请与我们取得联系**
|
||||||
|
[Hellohao图像托管官网](http://hellohao.cn)
|
||||||
|
|
||||||
**捐赠地址:** [**https://tbed.hellohao.cn/pay**](https://tbed.hellohao.cn/pay)
|
|
||||||
|
|
||||||
|
|||||||
@@ -196,7 +196,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.qiniu</groupId>
|
<groupId>com.qiniu</groupId>
|
||||||
<artifactId>qiniu-java-sdk</artifactId>
|
<artifactId>qiniu-java-sdk</artifactId>
|
||||||
<version>7.2.22</version>
|
<version>7.14.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.qcloud</groupId>
|
<groupId>com.qcloud</groupId>
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ public static void main(String[] args) {
|
|||||||
Stream.of(jpa)
|
Stream.of(jpa)
|
||||||
.map(bf::getBeanDefinition)
|
.map(bf::getBeanDefinition)
|
||||||
.forEach(it -> it.setDependsOn("databaseStartupValidator"));
|
.forEach(it -> it.setDependsOn("databaseStartupValidator"));
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -10,10 +10,12 @@ import org.apache.shiro.SecurityUtils;
|
|||||||
import org.apache.shiro.authc.UsernamePasswordToken;
|
import org.apache.shiro.authc.UsernamePasswordToken;
|
||||||
import org.apache.shiro.subject.Subject;
|
import org.apache.shiro.subject.Subject;
|
||||||
import org.apache.shiro.web.filter.authc.BasicHttpAuthenticationFilter;
|
import org.apache.shiro.web.filter.authc.BasicHttpAuthenticationFilter;
|
||||||
|
|
||||||
import javax.servlet.ServletRequest;
|
import javax.servlet.ServletRequest;
|
||||||
import javax.servlet.ServletResponse;
|
import javax.servlet.ServletResponse;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Hellohao
|
* @author Hellohao
|
||||||
@@ -139,11 +141,16 @@ public class SubjectFilter extends BasicHttpAuthenticationFilter {
|
|||||||
info = "用户未找到";
|
info = "用户未找到";
|
||||||
}
|
}
|
||||||
System.err.println("拦截器False-"+info);
|
System.err.println("拦截器False-"+info);
|
||||||
response.setContentType("application/json;charset=UTF-8");
|
HttpServletResponse httpServletResponse = (HttpServletResponse) response;
|
||||||
final JSONObject jsonObject = new JSONObject();
|
httpServletResponse.setStatus(HttpServletResponse.SC_OK);
|
||||||
|
httpServletResponse.setCharacterEncoding("UTF-8");
|
||||||
|
httpServletResponse.setContentType("application/json");
|
||||||
|
PrintWriter writer = httpServletResponse.getWriter();
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
jsonObject.put("code",this.CODE);
|
jsonObject.put("code",this.CODE);
|
||||||
jsonObject.put("info",info);
|
jsonObject.put("info",info);
|
||||||
response.getWriter().write(jsonObject.toJSONString());
|
writer.write(jsonObject.toJSONString());
|
||||||
|
writer.flush();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("返回token验证失败403请求,报异常了");
|
System.out.println("返回token验证失败403请求,报异常了");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ public class ShiroConfig {
|
|||||||
filterMap.put("/verifyCode","anon");
|
filterMap.put("/verifyCode","anon");
|
||||||
filterMap.put("/verifyCodeForRegister","anon");
|
filterMap.put("/verifyCodeForRegister","anon");
|
||||||
filterMap.put("/verifyCodeForRetrieve","anon");
|
filterMap.put("/verifyCodeForRetrieve","anon");
|
||||||
|
filterMap.put("/verifyCodeFortowSendEmail","anon");
|
||||||
filterMap.put("/api/**","anon");
|
filterMap.put("/api/**","anon");
|
||||||
filterMap.put("/user/**","anon");
|
filterMap.put("/user/**","anon");
|
||||||
filterMap.put("/ota/**","anon");
|
filterMap.put("/ota/**","anon");
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package cn.hellohao.auth.shiro;
|
|||||||
|
|
||||||
import cn.hellohao.pojo.User;
|
import cn.hellohao.pojo.User;
|
||||||
import cn.hellohao.service.UserService;
|
import cn.hellohao.service.UserService;
|
||||||
|
import cn.hellohao.utils.SetText;
|
||||||
import org.apache.shiro.SecurityUtils;
|
import org.apache.shiro.SecurityUtils;
|
||||||
import org.apache.shiro.authc.*;
|
import org.apache.shiro.authc.*;
|
||||||
import org.apache.shiro.authz.AuthorizationInfo;
|
import org.apache.shiro.authz.AuthorizationInfo;
|
||||||
@@ -46,7 +47,11 @@ public class UserRealm extends AuthorizingRealm {
|
|||||||
UsernamePasswordToken userToken = null;
|
UsernamePasswordToken userToken = null;
|
||||||
userToken = (UsernamePasswordToken)tokenOBJ;
|
userToken = (UsernamePasswordToken)tokenOBJ;
|
||||||
User user = new User();
|
User user = new User();
|
||||||
user.setEmail(userToken.getUsername());
|
if(SetText.checkEmail(userToken.getUsername())){
|
||||||
|
user.setEmail(userToken.getUsername());
|
||||||
|
}else{
|
||||||
|
user.setUsername(userToken.getUsername());
|
||||||
|
}
|
||||||
User u = userService.getUsers(user);
|
User u = userService.getUsers(user);
|
||||||
if(u==null){
|
if(u==null){
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import com.auth0.jwt.algorithms.Algorithm;
|
|||||||
import com.auth0.jwt.exceptions.TokenExpiredException;
|
import com.auth0.jwt.exceptions.TokenExpiredException;
|
||||||
import com.auth0.jwt.interfaces.DecodedJWT;
|
import com.auth0.jwt.interfaces.DecodedJWT;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@@ -24,7 +23,7 @@ public class JWTUtil {
|
|||||||
|
|
||||||
public static String createToken(User user){
|
public static String createToken(User user){
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
calendar.add(Calendar.SECOND,604800 );//单位秒,604800 为7天
|
calendar.add(Calendar.SECOND,2592000 );//单位秒
|
||||||
Algorithm algorithm = Algorithm.HMAC256(SECRET);
|
Algorithm algorithm = Algorithm.HMAC256(SECRET);
|
||||||
String token = JWT.create()
|
String token = JWT.create()
|
||||||
.withClaim("email", user.getEmail())
|
.withClaim("email", user.getEmail())
|
||||||
|
|||||||
@@ -10,4 +10,7 @@ import java.io.File;
|
|||||||
public class GlobalConstant {
|
public class GlobalConstant {
|
||||||
public static String SYSTYPE = "LINUX";
|
public static String SYSTYPE = "LINUX";
|
||||||
public static String LOCPATH = File.separator + "HellohaoData";
|
public static String LOCPATH = File.separator + "HellohaoData";
|
||||||
|
|
||||||
|
public static final String HELLOHAOTEMPIMG_PATH = File.separator + "HellohaoData"+File.separator+"hellohaotempimg";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import com.alibaba.fastjson.JSONArray;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.shiro.SecurityUtils;
|
import org.apache.shiro.SecurityUtils;
|
||||||
import org.apache.shiro.subject.Subject;
|
import org.apache.shiro.subject.Subject;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -312,7 +313,9 @@ public class AdminController {
|
|||||||
String starttime = jsonObj.getString("starttime");
|
String starttime = jsonObj.getString("starttime");
|
||||||
String stoptime = jsonObj.getString("stoptime");
|
String stoptime = jsonObj.getString("stoptime");
|
||||||
String selectUserType = jsonObj.getString("selectUserType"); // me/all
|
String selectUserType = jsonObj.getString("selectUserType"); // me/all
|
||||||
|
String order = jsonObj.getString("order");
|
||||||
String username = jsonObj.getString("username");
|
String username = jsonObj.getString("username");
|
||||||
|
String searchname = jsonObj.getString("searchname");
|
||||||
Integer selecttype = jsonObj.getInteger("selecttype");
|
Integer selecttype = jsonObj.getInteger("selecttype");
|
||||||
boolean violation = jsonObj.getBoolean("violation");
|
boolean violation = jsonObj.getBoolean("violation");
|
||||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
@@ -354,6 +357,10 @@ public class AdminController {
|
|||||||
} else {
|
} else {
|
||||||
img.setUserid(user.getId());
|
img.setUserid(user.getId());
|
||||||
}
|
}
|
||||||
|
if(!StringUtils.isBlank(searchname)){
|
||||||
|
img.setSearchname(searchname);
|
||||||
|
}
|
||||||
|
img.setOrder(StringUtils.isBlank(order)?"desc":order);
|
||||||
List<Images> images = imgService.selectimg(img);
|
List<Images> images = imgService.selectimg(img);
|
||||||
PageInfo<Images> rolePageInfo = new PageInfo<>(images);
|
PageInfo<Images> rolePageInfo = new PageInfo<>(images);
|
||||||
PageResultBean<Images> pageResultBean =
|
PageResultBean<Images> pageResultBean =
|
||||||
@@ -402,9 +409,15 @@ public class AdminController {
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
String regex = "^\\w+$";
|
String regex = "^\\w+$";
|
||||||
if (username.length() > 20 || !username.matches(regex)) {
|
if (username.length() > 30) {
|
||||||
msg.setCode("110403");
|
msg.setCode("110403");
|
||||||
msg.setInfo("用户名不得超过20位字符");
|
msg.setInfo("用户名不得超过30位字符");
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
if(!username.matches (regex)){
|
||||||
|
//用户名格式不正确
|
||||||
|
msg.setCode("110403");
|
||||||
|
msg.setInfo("用户名不得含有特殊字符");
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
if (subject.hasRole("admin")) {
|
if (subject.hasRole("admin")) {
|
||||||
@@ -454,6 +467,7 @@ public class AdminController {
|
|||||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||||
String images = jsonObj.getString("images");
|
String images = jsonObj.getString("images");
|
||||||
String uuid = jsonObj.getString("uuid");
|
String uuid = jsonObj.getString("uuid");
|
||||||
|
Boolean forceDel = jsonObj.getBoolean("forceDel")==null?false:jsonObj.getBoolean("forceDel");
|
||||||
if (images == null) {
|
if (images == null) {
|
||||||
msg.setCode("404");
|
msg.setCode("404");
|
||||||
msg.setInfo("为获取到图像信息");
|
msg.setInfo("为获取到图像信息");
|
||||||
@@ -486,7 +500,7 @@ public class AdminController {
|
|||||||
if (imgIds.size() == 0) {
|
if (imgIds.size() == 0) {
|
||||||
msg.setCode("110404");
|
msg.setCode("110404");
|
||||||
} else {
|
} else {
|
||||||
deleimages.dele(uuid, imgIds.stream().toArray(Long[]::new));
|
deleimages.dele(forceDel,uuid, imgIds.stream().toArray(Long[]::new));
|
||||||
msg.setCode("200");
|
msg.setCode("200");
|
||||||
}
|
}
|
||||||
return msg;
|
return msg;
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import cn.hellohao.pojo.*;
|
|||||||
import cn.hellohao.service.*;
|
import cn.hellohao.service.*;
|
||||||
import cn.hellohao.service.impl.*;
|
import cn.hellohao.service.impl.*;
|
||||||
import cn.hellohao.utils.NewSendEmail;
|
import cn.hellohao.utils.NewSendEmail;
|
||||||
|
import cn.hellohao.utils.Print;
|
||||||
import cn.hellohao.utils.SetFiles;
|
import cn.hellohao.utils.SetFiles;
|
||||||
|
import cn.hutool.http.HttpUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
@@ -19,6 +21,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
@@ -392,5 +397,50 @@ public class AdminRootController {
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/sysVersion")
|
||||||
|
@ResponseBody
|
||||||
|
public Msg sysupdate(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||||
|
final Msg msg = new Msg();
|
||||||
|
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||||
|
String dates = jsonObj.getString("dates");
|
||||||
|
HashMap<String, Object> paramMap = new HashMap<>();
|
||||||
|
String urls = "http://check.hellohao.cn:8090/getNoticeText";
|
||||||
|
JSONObject jsonObject =null;
|
||||||
|
try {
|
||||||
|
URL u = new URL(urls);
|
||||||
|
HttpURLConnection uConnection = (HttpURLConnection) u.openConnection();
|
||||||
|
uConnection.connect();
|
||||||
|
if(uConnection.getResponseCode()==200){
|
||||||
|
jsonObject =JSONObject.parseObject(HttpUtil.get(urls));
|
||||||
|
String openv = jsonObject.getString("openv");
|
||||||
|
String opentext = jsonObject.getString("opentext");
|
||||||
|
JSONObject versionJson = new JSONObject();
|
||||||
|
if(Double.valueOf(openv)>Double.valueOf(dates)){
|
||||||
|
versionJson.put("code","110200");
|
||||||
|
versionJson.put("newVersion",openv);
|
||||||
|
versionJson.put("versionMsg",opentext);
|
||||||
|
msg.setCode("110200");
|
||||||
|
msg.setData(versionJson);
|
||||||
|
}else{
|
||||||
|
versionJson.put("code","110300");
|
||||||
|
versionJson.put("newVersion",openv);
|
||||||
|
versionJson.put("versionMsg","当前已是最新版本");
|
||||||
|
msg.setCode("110300");
|
||||||
|
msg.setData(versionJson);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
msg.setCode("110500");
|
||||||
|
msg.setData("未获取到更新状态");
|
||||||
|
}
|
||||||
|
uConnection.disconnect();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Print.warning("connect failed");
|
||||||
|
msg.setCode("110500");
|
||||||
|
msg.setData("未获取到更新状态");
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,13 +10,16 @@ import cn.hellohao.service.UploadConfigService;
|
|||||||
import cn.hellohao.service.impl.UploadServicel;
|
import cn.hellohao.service.impl.UploadServicel;
|
||||||
import cn.hellohao.service.impl.UserServiceImpl;
|
import cn.hellohao.service.impl.UserServiceImpl;
|
||||||
import cn.hellohao.utils.Base64ToMultipartFile;
|
import cn.hellohao.utils.Base64ToMultipartFile;
|
||||||
|
import cn.hellohao.utils.SetFiles;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.shiro.SecurityUtils;
|
import org.apache.shiro.SecurityUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Hellohao
|
* @author Hellohao
|
||||||
@@ -86,12 +89,17 @@ public class ClientAppController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/imgUpload")
|
@PostMapping("/imgUpload")
|
||||||
public Msg imgUpload(HttpServletRequest request, @RequestParam(required = true, value = "file") MultipartFile file,
|
public Msg imgUpload(HttpServletRequest request, @RequestParam(required = true, value = "file") MultipartFile multipartFile,
|
||||||
@RequestParam(required = true, value = "days") String days) {
|
@RequestParam(required = true, value = "days") String days) {
|
||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
try{
|
try{
|
||||||
if (null != file) {
|
if (null != multipartFile) {
|
||||||
msg = uploadServicel.uploadForLoc(request,file,Integer.valueOf(days),null);
|
String originalFilename = multipartFile.getOriginalFilename();
|
||||||
|
if(StringUtils.isBlank(originalFilename)){
|
||||||
|
originalFilename = "未命名图像";
|
||||||
|
}
|
||||||
|
File file = SetFiles.changeFile_new(multipartFile);
|
||||||
|
msg = uploadServicel.uploadForLoc(request,file,originalFilename,Integer.valueOf(days),null,null);
|
||||||
}else{
|
}else{
|
||||||
msg.setCode("500");
|
msg.setCode("500");
|
||||||
}
|
}
|
||||||
@@ -109,9 +117,11 @@ public class ClientAppController {
|
|||||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||||
String imgstr = jsonObj.getString("imgstr");
|
String imgstr = jsonObj.getString("imgstr");
|
||||||
Integer days = jsonObj.getInteger("days");
|
Integer days = jsonObj.getInteger("days");
|
||||||
|
String md5 = jsonObj.getString("md5");
|
||||||
if (null != imgstr && !imgstr.isEmpty()) {
|
if (null != imgstr && !imgstr.isEmpty()) {
|
||||||
MultipartFile multipartFile = Base64ToMultipartFile.base64Convert(imgstr);
|
MultipartFile multipartFile = Base64ToMultipartFile.base64Convert(imgstr);
|
||||||
msg = uploadServicel.uploadForLoc(request, multipartFile, days, null);
|
File file = SetFiles.changeFile_new(multipartFile);
|
||||||
|
msg = uploadServicel.uploadForLoc(request, file,"未命名图像", days, null,md5);
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -1,12 +1,14 @@
|
|||||||
package cn.hellohao.controller;
|
package cn.hellohao.controller;
|
||||||
|
|
||||||
import cn.hellohao.auth.token.JWTUtil;
|
import cn.hellohao.auth.token.JWTUtil;
|
||||||
|
import cn.hellohao.config.GlobalConstant;
|
||||||
import cn.hellohao.pojo.*;
|
import cn.hellohao.pojo.*;
|
||||||
import cn.hellohao.service.*;
|
import cn.hellohao.service.*;
|
||||||
import cn.hellohao.service.impl.UploadServicel;
|
import cn.hellohao.service.impl.UploadServicel;
|
||||||
import cn.hellohao.service.impl.deleImages;
|
import cn.hellohao.service.impl.deleImages;
|
||||||
import cn.hellohao.utils.GetIPS;
|
import cn.hellohao.utils.GetIPS;
|
||||||
import cn.hellohao.utils.MyVersion;
|
import cn.hellohao.utils.MyVersion;
|
||||||
|
import cn.hellohao.utils.SetFiles;
|
||||||
import cn.hutool.captcha.CaptchaUtil;
|
import cn.hutool.captcha.CaptchaUtil;
|
||||||
import cn.hutool.captcha.ShearCaptcha;
|
import cn.hutool.captcha.ShearCaptcha;
|
||||||
import cn.hutool.captcha.generator.MathGenerator;
|
import cn.hutool.captcha.generator.MathGenerator;
|
||||||
@@ -19,15 +21,17 @@ import org.apache.shiro.subject.Subject;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class IndexController {
|
public class IndexController {
|
||||||
@@ -40,10 +44,11 @@ public class IndexController {
|
|||||||
@Autowired private IRedisService iRedisService;
|
@Autowired private IRedisService iRedisService;
|
||||||
@Autowired private AppClientService appClientService;
|
@Autowired private AppClientService appClientService;
|
||||||
|
|
||||||
|
public static String version = "20230925";
|
||||||
@RequestMapping(value = "/")
|
@RequestMapping(value = "/")
|
||||||
public String Welcome(Model model, HttpServletRequest httpServletRequest) {
|
public String Welcome(Model model, HttpServletRequest httpServletRequest) {
|
||||||
model.addAttribute("name", "服务端程序(开源版)");
|
model.addAttribute("name", "服务端程序(开源版)");
|
||||||
model.addAttribute("version", "20230320");
|
model.addAttribute("version", version);
|
||||||
model.addAttribute("ip", GetIPS.getIpAddr(httpServletRequest));
|
model.addAttribute("ip", GetIPS.getIpAddr(httpServletRequest));
|
||||||
model.addAttribute("links", "https://github.com/Hello-hao/tbed");
|
model.addAttribute("links", "https://github.com/Hello-hao/tbed");
|
||||||
return "welcome";
|
return "welcome";
|
||||||
@@ -60,9 +65,10 @@ public class IndexController {
|
|||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
AppClient appClient = appClientService.getAppClientData("app");
|
AppClient appClient = appClientService.getAppClientData("app");
|
||||||
jsonObject.put("webname", cd.getString("webname"));
|
jsonObject.put("webname", cd.getString("webname"));
|
||||||
|
jsonObject.put("version",version);
|
||||||
jsonObject.put("websubtitle", cd.getString("websubtitle"));
|
jsonObject.put("websubtitle", cd.getString("websubtitle"));
|
||||||
jsonObject.put("keywords", cd.getString("keywords"));
|
jsonObject.put("keywords", cd.getString("keywords"));
|
||||||
jsonObject.put("description", cd.getString("description"));
|
jsonObject.put("webms", cd.getString("webms"));
|
||||||
jsonObject.put("explain", cd.getString("explain"));
|
jsonObject.put("explain", cd.getString("explain"));
|
||||||
jsonObject.put("baidu", cd.getString("baidu"));
|
jsonObject.put("baidu", cd.getString("baidu"));
|
||||||
jsonObject.put("links", cd.getString("links"));
|
jsonObject.put("links", cd.getString("links"));
|
||||||
@@ -75,17 +81,65 @@ public class IndexController {
|
|||||||
jsonObject.put("clientname", appClient.getAppname());
|
jsonObject.put("clientname", appClient.getAppname());
|
||||||
jsonObject.put("clientlogo", appClient.getApplogo());
|
jsonObject.put("clientlogo", appClient.getApplogo());
|
||||||
jsonObject.put("appupdate", appClient.getAppupdate());
|
jsonObject.put("appupdate", appClient.getAppupdate());
|
||||||
|
jsonObject.put("serverVersion",version);
|
||||||
msg.setData(jsonObject);
|
msg.setData(jsonObject);
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
@PostMapping("/uploadChunkFile")
|
||||||
|
@ResponseBody
|
||||||
|
@CrossOrigin
|
||||||
|
public Msg uploadChunk(HttpServletRequest request,Chunk chunk) {
|
||||||
|
Msg msg = new Msg();
|
||||||
|
MultipartFile file = chunk.getFile();
|
||||||
|
try {
|
||||||
|
byte[] bytes = file.getBytes();
|
||||||
|
Path path = Paths.get(SetFiles.generatePath(GlobalConstant.HELLOHAOTEMPIMG_PATH+ File.separator+chunk.getUuid(), chunk));
|
||||||
|
java.nio.file.Files.write(path, bytes);
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("chunkNumber",chunk.getChunkNumber());
|
||||||
|
jsonObject.put("totalChunks",chunk.getTotalChunks());
|
||||||
|
msg.setData(jsonObject);
|
||||||
|
msg.setCode("200");
|
||||||
|
return msg;
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
msg.setCode("500");
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/processFile")
|
||||||
|
@ResponseBody
|
||||||
|
@CrossOrigin
|
||||||
|
public Msg processFile(HttpServletRequest request,@RequestParam(value = "data", defaultValue = "") String data){
|
||||||
|
Msg msg = new Msg();
|
||||||
|
try{
|
||||||
|
Subject subject = SecurityUtils.getSubject();
|
||||||
|
User user = (User) subject.getPrincipal();
|
||||||
|
CompletableFuture<Msg> ret = uploadServicel.mergeFile(request,data,user);
|
||||||
|
msg = ret.get();
|
||||||
|
}catch (Exception e){
|
||||||
|
msg.setCode("500");
|
||||||
|
msg.setInfo("处理文件错误,上传失败");
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping(value = {"/upload", "/client/upload"})
|
@PostMapping(value = {"/upload", "/client/upload"})
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg upimg(
|
public Msg upimg(
|
||||||
HttpServletRequest request,
|
HttpServletRequest request,
|
||||||
@RequestParam(value = "file", required = false) MultipartFile multipartFile,
|
@RequestParam(value = "file", required = false) MultipartFile multipartFile,
|
||||||
Integer day) {
|
Integer day,@RequestParam(value = "md5",required = false) String md5) {
|
||||||
return uploadServicel.uploadForLoc(request, multipartFile, day, null);
|
JSONArray jsonArray = new JSONArray();
|
||||||
|
Subject subject = SecurityUtils.getSubject();
|
||||||
|
User user = (User) subject.getPrincipal();
|
||||||
|
String originalFilename = multipartFile.getOriginalFilename();
|
||||||
|
if(StringUtils.isBlank(originalFilename)){
|
||||||
|
originalFilename = "未命名图像";
|
||||||
|
}
|
||||||
|
File file = SetFiles.changeFile_new(multipartFile);
|
||||||
|
return uploadServicel.uploadForLoc(request, file,originalFilename, day, null,md5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = {"/uploadForUrl", "/client/uploadForUrl"})
|
@PostMapping(value = {"/uploadForUrl", "/client/uploadForUrl"})
|
||||||
@@ -95,6 +149,7 @@ public class IndexController {
|
|||||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||||
Integer setday = jsonObj.getInteger("day");
|
Integer setday = jsonObj.getInteger("day");
|
||||||
String imgUrl = jsonObj.getString("imgUrl");
|
String imgUrl = jsonObj.getString("imgUrl");
|
||||||
|
String referer = jsonObj.getString("referer");
|
||||||
String[] URLArr = imgUrl.split("\n");
|
String[] URLArr = imgUrl.split("\n");
|
||||||
|
|
||||||
Subject subject = SecurityUtils.getSubject();
|
Subject subject = SecurityUtils.getSubject();
|
||||||
@@ -114,7 +169,10 @@ public class IndexController {
|
|||||||
for (int i = 0; i < URLArr.length; i++) {
|
for (int i = 0; i < URLArr.length; i++) {
|
||||||
int temp = i + 1;
|
int temp = i + 1;
|
||||||
if (syscounts >= temp) {
|
if (syscounts >= temp) {
|
||||||
Msg msg = uploadServicel.uploadForLoc(request, null, setday, URLArr[i]);
|
JSONObject imgJson = new JSONObject();
|
||||||
|
imgJson.put("imgUrl",URLArr[i]);
|
||||||
|
imgJson.put("referer",referer);
|
||||||
|
Msg msg = uploadServicel.uploadForLoc(request, null,"URL转存图像", setday, imgJson,null);
|
||||||
if (!msg.getCode().equals("200")) {
|
if (!msg.getCode().equals("200")) {
|
||||||
errcounts++;
|
errcounts++;
|
||||||
} else {
|
} else {
|
||||||
@@ -265,6 +323,29 @@ public class IndexController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = {"/verifyCodeFortowSendEmail","/wechat/verifyCodeFortowSendEmail"})
|
||||||
|
@ResponseBody
|
||||||
|
public Msg verifyCodeFortowSendEmail() {
|
||||||
|
Msg msg = new Msg();
|
||||||
|
try {
|
||||||
|
ShearCaptcha captcha = CaptchaUtil.createShearCaptcha(90, 35, 2, 2);
|
||||||
|
// 自定义验证码内容为四则运算方式
|
||||||
|
captcha.setGenerator(new MathGenerator(1));
|
||||||
|
String code = getVerifyCodeOperator(captcha.getCode());
|
||||||
|
String uid = UUID.randomUUID().toString().replace("-", "").toLowerCase();
|
||||||
|
iRedisService.setValue("verifyCodeFortowSendEmail_"+uid,code);
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("codeKey",uid);
|
||||||
|
jsonObject.put("codeImg",captcha.getImageBase64());
|
||||||
|
msg.setData(jsonObject);
|
||||||
|
return msg;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
msg.setCode("500");
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static String getVerifyCodeOperator(String str) {
|
public static String getVerifyCodeOperator(String str) {
|
||||||
int a = Integer.valueOf(str.substring(0, 1));
|
int a = Integer.valueOf(str.substring(0, 1));
|
||||||
String yxf = str.substring(1, 2);
|
String yxf = str.substring(1, 2);
|
||||||
@@ -302,7 +383,7 @@ public class IndexController {
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
msg = deleimages.dele(null, image.getId());
|
msg = deleimages.dele(false,null, image.getId());
|
||||||
List<Long> Delids = (List<Long>) msg.getData();
|
List<Long> Delids = (List<Long>) msg.getData();
|
||||||
if (!Delids.contains(image.getId())) {
|
if (!Delids.contains(image.getId())) {
|
||||||
msg.setCode("500");
|
msg.setCode("500");
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import org.apache.shiro.authc.IncorrectCredentialsException;
|
|||||||
import org.apache.shiro.authc.UnknownAccountException;
|
import org.apache.shiro.authc.UnknownAccountException;
|
||||||
import org.apache.shiro.authc.UsernamePasswordToken;
|
import org.apache.shiro.authc.UsernamePasswordToken;
|
||||||
import org.apache.shiro.subject.Subject;
|
import org.apache.shiro.subject.Subject;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.ui.Model;
|
import org.springframework.ui.Model;
|
||||||
@@ -44,6 +46,7 @@ public class UserController {
|
|||||||
private SysConfigService sysConfigService;
|
private SysConfigService sysConfigService;
|
||||||
@Autowired
|
@Autowired
|
||||||
IRedisService iRedisService;
|
IRedisService iRedisService;
|
||||||
|
private Logger logger = LoggerFactory.getLogger(UserController.class);
|
||||||
|
|
||||||
@PostMapping("/register")
|
@PostMapping("/register")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@@ -62,10 +65,16 @@ public class UserController {
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
String regex = "^\\w+$";
|
String regex = "^\\w+$";
|
||||||
if(username.length()>20 || !username.matches (regex)){
|
if(username.length()>30){
|
||||||
//用户名格式不正确
|
//用户名格式不正确
|
||||||
msg.setCode("110403");
|
msg.setCode("110403");
|
||||||
msg.setInfo("用户名不得超过20位字符");
|
msg.setInfo("用户名不得超过30位字符");
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
if(!username.matches (regex)){
|
||||||
|
//用户名格式不正确
|
||||||
|
msg.setCode("110403");
|
||||||
|
msg.setInfo("用户名不得含有特殊字符");
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
if(null==redis_verifyCodeForRegister){
|
if(null==redis_verifyCodeForRegister){
|
||||||
@@ -137,6 +146,57 @@ public class UserController {
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping(value = {"/validateEmail","/wechat/validateEmail"})
|
||||||
|
@ResponseBody
|
||||||
|
public Msg validateEmail(HttpServletRequest httpServletRequest,@RequestParam(value = "data", defaultValue = "") String data) {
|
||||||
|
Msg msg = new Msg();
|
||||||
|
try {
|
||||||
|
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||||
|
String email = jsonObj.getString("email");
|
||||||
|
String towSendEmailCode = jsonObj.getString("towSendEmailCode");
|
||||||
|
Object verifyCodeFortowSendEmail =iRedisService.getValue("verifyCodeFortowSendEmail_"+httpServletRequest.getHeader("verifyCodeFortowSendEmail"));
|
||||||
|
User u = new User();
|
||||||
|
u.setEmail(email);
|
||||||
|
User user = userService.getUsers(u);
|
||||||
|
if(user.getIsok()!=0){
|
||||||
|
msg.setInfo("不知细叶谁裁出,二月春风似剪刀");
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
if(null==verifyCodeFortowSendEmail){
|
||||||
|
msg.setCode("4035");
|
||||||
|
msg.setInfo("验证码已失效,请重新弄获取。");
|
||||||
|
return msg;
|
||||||
|
}else if(null==towSendEmailCode){
|
||||||
|
msg.setCode("4036");
|
||||||
|
msg.setInfo("验证码不能为空。");
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
if((verifyCodeFortowSendEmail.toString().toLowerCase()).compareTo((towSendEmailCode.toLowerCase()))==0){
|
||||||
|
//注册完发激活链接
|
||||||
|
final Confdata dataJson = confdataService.selectConfdata("config");
|
||||||
|
JSONObject confdata = JSONObject.parseObject(dataJson.getJsondata());
|
||||||
|
EmailConfig emailConfig = emailConfigService.getemail();
|
||||||
|
Thread thread = new Thread() {
|
||||||
|
public void run() {
|
||||||
|
Integer a = NewSendEmail.sendEmail(emailConfig,user.getUsername(), user.getUid(), user.getEmail(),confdata);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
thread.start();
|
||||||
|
msg.setInfo("邮件已发送,请注意查收邮箱尽快激活账户(如果没收到,请检查垃圾邮件)");
|
||||||
|
}else{
|
||||||
|
msg.setCode("110408");
|
||||||
|
msg.setInfo("验证码不正确");
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch (Exception e){
|
||||||
|
logger.error("报错位置:/validateEmail",e);
|
||||||
|
msg.setCode("500");
|
||||||
|
msg.setInfo("邮件发送失败");
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/login")//new
|
@PostMapping("/login")//new
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg login(HttpServletRequest httpServletRequest,@RequestParam(value = "data", defaultValue = "") String data) {
|
public Msg login(HttpServletRequest httpServletRequest,@RequestParam(value = "data", defaultValue = "") String data) {
|
||||||
@@ -178,7 +238,8 @@ public class UserController {
|
|||||||
User user = (User) SecurityUtils.getSubject().getPrincipal();
|
User user = (User) SecurityUtils.getSubject().getPrincipal();
|
||||||
if(user.getIsok()==0){
|
if(user.getIsok()==0){
|
||||||
msg.setInfo("你的账号暂未激活");
|
msg.setInfo("你的账号暂未激活");
|
||||||
msg.setCode("110403");
|
msg.setData(user.getEmail());
|
||||||
|
msg.setCode("110402");
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
if(user.getIsok()<0){
|
if(user.getIsok()<0){
|
||||||
@@ -198,15 +259,15 @@ public class UserController {
|
|||||||
} catch (UnknownAccountException e) {
|
} catch (UnknownAccountException e) {
|
||||||
//此异常说明用户名不存在
|
//此异常说明用户名不存在
|
||||||
msg.setCode("4000");
|
msg.setCode("4000");
|
||||||
msg.setInfo("登录邮箱不存在");
|
msg.setInfo("登录账号不存在");
|
||||||
System.err.println("邮箱不存在");
|
System.err.println("邮箱/用户名不存在");
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
return msg;
|
return msg;
|
||||||
}catch (IncorrectCredentialsException e) {
|
}catch (IncorrectCredentialsException e) {
|
||||||
msg.setCode("4000");
|
msg.setCode("4000");
|
||||||
msg.setInfo("登录密码错误");
|
msg.setInfo("登录密码错误");
|
||||||
System.err.println("密码不存在");
|
System.err.println("密码不存在");
|
||||||
e.printStackTrace();
|
// e.printStackTrace();
|
||||||
return msg;
|
return msg;
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
msg.setCode("5000");
|
msg.setCode("5000");
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public interface ImgMapper {
|
|||||||
|
|
||||||
Integer md5Count(Images images);
|
Integer md5Count(Images images);
|
||||||
|
|
||||||
List<Images> selectImgUrlByMD5(@Param("md5key") String md5key);
|
List<Images> selectImgUrlByMD5(Images images);
|
||||||
|
|
||||||
List<Images> RecentlyUploaded(@Param("userid") Integer userid);
|
List<Images> RecentlyUploaded(@Param("userid") Integer userid);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package cn.hellohao.pojo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.data.annotation.Id;
|
||||||
|
import org.springframework.data.annotation.Transient;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Chunk implements Serializable {
|
||||||
|
@Id
|
||||||
|
private String uid;
|
||||||
|
/**
|
||||||
|
* 当前文件块,从1开始
|
||||||
|
*/
|
||||||
|
private Integer chunkNumber;
|
||||||
|
/**
|
||||||
|
* 分块大小
|
||||||
|
*/
|
||||||
|
private Long chunkSize;
|
||||||
|
/**
|
||||||
|
* 当前分块大小
|
||||||
|
*/
|
||||||
|
private Long currentChunkSize;
|
||||||
|
/**
|
||||||
|
* 总大小
|
||||||
|
*/
|
||||||
|
private Long totalSize;
|
||||||
|
/**
|
||||||
|
* 文件标识
|
||||||
|
*/
|
||||||
|
private String identifier;
|
||||||
|
/**
|
||||||
|
* 文件名
|
||||||
|
*/
|
||||||
|
private String filename;
|
||||||
|
/**
|
||||||
|
* 相对路径
|
||||||
|
*/
|
||||||
|
private String relativePath;
|
||||||
|
/**
|
||||||
|
* 总块数
|
||||||
|
*/
|
||||||
|
private Integer totalChunks;
|
||||||
|
/**
|
||||||
|
* 文件类型
|
||||||
|
*/
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 前台创建的随机UID,用作创建合并文件的唯一标识目录名
|
||||||
|
*/
|
||||||
|
private String uuid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 归类
|
||||||
|
*/
|
||||||
|
private String classifications;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 天数
|
||||||
|
*/
|
||||||
|
private Integer day;
|
||||||
|
|
||||||
|
|
||||||
|
@Transient
|
||||||
|
private MultipartFile file;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package cn.hellohao.pojo;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class Config {
|
|
||||||
private Integer id;
|
|
||||||
private Integer sourcekey;
|
|
||||||
private Integer emails;
|
|
||||||
private String webname;
|
|
||||||
private String explain;
|
|
||||||
private String video;
|
|
||||||
private Integer backtype;
|
|
||||||
private String links;
|
|
||||||
private String notice;
|
|
||||||
private String baidu;
|
|
||||||
private String domain;
|
|
||||||
private String background1;
|
|
||||||
private String background2;
|
|
||||||
private String sett;
|
|
||||||
private String webms;
|
|
||||||
private String webkeywords;
|
|
||||||
private String webfavicons;
|
|
||||||
private Integer theme;
|
|
||||||
private String websubtitle;
|
|
||||||
private String logo;
|
|
||||||
private String aboutinfo;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
package cn.hellohao.pojo;
|
package cn.hellohao.pojo;
|
||||||
|
|
||||||
public class Images {
|
import lombok.Data;
|
||||||
// 默认的时间字符串格式
|
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Images {
|
||||||
//id, imgname, imgurl, userid
|
//id, imgname, imgurl, userid
|
||||||
private Long id;
|
private Long id;
|
||||||
private String imgname;
|
private String imgname;
|
||||||
@@ -37,318 +38,8 @@ public class Images {
|
|||||||
private String classificationuid; //类别uid集合
|
private String classificationuid; //类别uid集合
|
||||||
private String idname;
|
private String idname;
|
||||||
private Integer isRepeat;//如果没有开启查重的时候他是0,开启为1
|
private Integer isRepeat;//如果没有开启查重的时候他是0,开启为1
|
||||||
|
private String searchname;
|
||||||
public Images() {
|
private String order;
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Images(String imgurl, String sizes, String abnormal, String updatetime, String username, String md5key, String imguid) {
|
|
||||||
this.imgurl = imgurl;
|
|
||||||
this.sizes = sizes;
|
|
||||||
this.abnormal = abnormal;
|
|
||||||
this.updatetime = updatetime;
|
|
||||||
this.username = username;
|
|
||||||
this.md5key = md5key;
|
|
||||||
this.imguid = imguid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Images(Long id, String imgname, String imgurl, Integer userid, String sizes, String abnormal, Integer source,
|
|
||||||
Integer imgtype, String updatetime, String username, Integer storageType, String starttime, String stoptime,
|
|
||||||
String explains, String md5key, String notes, String useridlist, String imguid, String albumtitle,
|
|
||||||
String password, Integer selecttype,Long countNum,Integer monthNum,String yyyy,
|
|
||||||
String format,String about,Integer great,String[] classifuidlist,String classificationuid,String violation,
|
|
||||||
String idname,Integer isRepeat) {
|
|
||||||
this.id = id;
|
|
||||||
this.imgname = imgname;
|
|
||||||
this.imgurl = imgurl;
|
|
||||||
this.userid = userid;
|
|
||||||
this.sizes = sizes;
|
|
||||||
this.abnormal = abnormal;
|
|
||||||
this.source = source;
|
|
||||||
this.imgtype = imgtype;
|
|
||||||
this.updatetime = updatetime;
|
|
||||||
this.username = username;
|
|
||||||
this.storageType = storageType;
|
|
||||||
this.starttime = starttime;
|
|
||||||
this.stoptime = stoptime;
|
|
||||||
this.explains = explains;
|
|
||||||
this.md5key = md5key;
|
|
||||||
this.notes = notes;
|
|
||||||
this.useridlist = useridlist;
|
|
||||||
this.imguid = imguid;
|
|
||||||
this.albumtitle = albumtitle;
|
|
||||||
this.password = password;
|
|
||||||
this.selecttype = selecttype;
|
|
||||||
this.countNum = countNum;
|
|
||||||
this.monthNum = monthNum;
|
|
||||||
this.yyyy = yyyy;
|
|
||||||
this.format = format;
|
|
||||||
this.about = about;
|
|
||||||
this.great = great;
|
|
||||||
this.classifuidlist = classifuidlist;
|
|
||||||
this.classificationuid = classificationuid;
|
|
||||||
this.violation = violation;
|
|
||||||
this.idname = idname;
|
|
||||||
this.isRepeat = isRepeat;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getImgname() {
|
|
||||||
return imgname;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setImgname(String imgname) {
|
|
||||||
this.imgname = imgname;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getImgurl() {
|
|
||||||
return imgurl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setImgurl(String imgurl) {
|
|
||||||
this.imgurl = imgurl;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getUserid() {
|
|
||||||
return userid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUserid(Integer userid) {
|
|
||||||
this.userid = userid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSizes() {
|
|
||||||
return sizes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSizes(String sizes) {
|
|
||||||
this.sizes = sizes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAbnormal() {
|
|
||||||
return abnormal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAbnormal(String abnormal) {
|
|
||||||
this.abnormal = abnormal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getSource() {
|
|
||||||
return source;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSource(Integer source) {
|
|
||||||
this.source = source;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getImgtype() {
|
|
||||||
return imgtype;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setImgtype(Integer imgtype) {
|
|
||||||
this.imgtype = imgtype;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUpdatetime() {
|
|
||||||
return updatetime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUpdatetime(String updatetime) {
|
|
||||||
this.updatetime = updatetime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUsername() {
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUsername(String username) {
|
|
||||||
this.username = username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getStorageType() {
|
|
||||||
return storageType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStorageType(Integer storageType) {
|
|
||||||
this.storageType = storageType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStarttime() {
|
|
||||||
return starttime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStarttime(String starttime) {
|
|
||||||
this.starttime = starttime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getStoptime() {
|
|
||||||
return stoptime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStoptime(String stoptime) {
|
|
||||||
this.stoptime = stoptime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getExplains() {
|
|
||||||
return explains;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExplains(String explains) {
|
|
||||||
this.explains = explains;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMd5key() {
|
|
||||||
return md5key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMd5key(String md5key) {
|
|
||||||
this.md5key = md5key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNotes() {
|
|
||||||
return notes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNotes(String notes) {
|
|
||||||
this.notes = notes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUseridlist() {
|
|
||||||
return useridlist;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUseridlist(String useridlist) {
|
|
||||||
this.useridlist = useridlist;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getImguid() {
|
|
||||||
return imguid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setImguid(String imguid) {
|
|
||||||
this.imguid = imguid;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public String getAlbumtitle() {
|
|
||||||
return albumtitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAlbumtitle(String albumtitle) {
|
|
||||||
this.albumtitle = albumtitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPassword() {
|
|
||||||
return password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPassword(String password) {
|
|
||||||
this.password = password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getSelecttype() {
|
|
||||||
return selecttype;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelecttype(Integer selecttype) {
|
|
||||||
this.selecttype = selecttype;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getCountNum() {
|
|
||||||
return countNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setCountNum(Long countNum) {
|
|
||||||
this.countNum = countNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getMonthNum() {
|
|
||||||
return monthNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMonthNum(Integer monthNum) {
|
|
||||||
this.monthNum = monthNum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getYyyy() {
|
|
||||||
return yyyy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setYyyy(String yyyy) {
|
|
||||||
this.yyyy = yyyy;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getFormat() {
|
|
||||||
return format;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFormat(String format) {
|
|
||||||
this.format = format;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAbout() {
|
|
||||||
return about;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAbout(String about) {
|
|
||||||
this.about = about;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getGreat() {
|
|
||||||
return great;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGreat(Integer great) {
|
|
||||||
this.great = great;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String[] getClassifuidlist() {
|
|
||||||
return classifuidlist;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setClassifuidlist(String[] classifuidlist ) {
|
|
||||||
this.classifuidlist = classifuidlist;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getClassificationuid() {
|
|
||||||
return classificationuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setClassificationuid(String classificationuid) {
|
|
||||||
this.classificationuid = classificationuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getViolation() {
|
|
||||||
return violation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setViolation(String violation) {
|
|
||||||
this.violation = violation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getIdname() {
|
|
||||||
return idname;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIdname(String idname) {
|
|
||||||
this.idname = idname;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getIsRepeat() {
|
|
||||||
return isRepeat;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setIsRepeat(Integer isRepeat) {
|
|
||||||
this.isRepeat = isRepeat;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public interface ImgService {
|
|||||||
|
|
||||||
Integer md5Count(Images images);
|
Integer md5Count(Images images);
|
||||||
|
|
||||||
List<Images> selectImgUrlByMD5(String md5key);
|
List<Images> selectImgUrlByMD5(Images images);
|
||||||
|
|
||||||
List<Images> RecentlyUploaded(Integer userid);
|
List<Images> RecentlyUploaded(Integer userid);
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,14 @@ package cn.hellohao.service.impl;
|
|||||||
|
|
||||||
import cn.hellohao.dao.*;
|
import cn.hellohao.dao.*;
|
||||||
import cn.hellohao.pojo.*;
|
import cn.hellohao.pojo.*;
|
||||||
|
import cn.hellohao.service.ConfdataService;
|
||||||
import cn.hellohao.service.ImgTempService;
|
import cn.hellohao.service.ImgTempService;
|
||||||
|
import cn.hellohao.service.SysConfigService;
|
||||||
import cn.hellohao.utils.*;
|
import cn.hellohao.utils.*;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
@@ -23,12 +27,15 @@ import java.util.*;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class ClientService {
|
public class ClientService {
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(ClientService.class);
|
||||||
|
@Autowired
|
||||||
|
ConfdataService confdataService;
|
||||||
|
@Autowired
|
||||||
|
SysConfigService sysConfigService;
|
||||||
@Autowired private UserMapper userMapper;
|
@Autowired private UserMapper userMapper;
|
||||||
@Autowired private KeysMapper keysMapper;
|
@Autowired private KeysMapper keysMapper;
|
||||||
@Autowired private UploadConfigMapper uploadConfigMapper;
|
@Autowired private UploadConfigMapper uploadConfigMapper;
|
||||||
@Autowired private ImgMapper imgMapper;
|
@Autowired private ImgServiceImpl imgServiceImpl;
|
||||||
@Autowired private ImgreviewMapper imgreviewMapper;
|
|
||||||
@Autowired private ImgTempService imgTempService;
|
@Autowired private ImgTempService imgTempService;
|
||||||
@Autowired private GetSource getSource;
|
@Autowired private GetSource getSource;
|
||||||
@Autowired private ImgViolationJudgeServiceImpl imgViolationJudgeService;
|
@Autowired private ImgViolationJudgeServiceImpl imgViolationJudgeService;
|
||||||
@@ -37,10 +44,11 @@ public class ClientService {
|
|||||||
HttpServletRequest request, MultipartFile multipartFile, String email, String pass,Integer setday) {
|
HttpServletRequest request, MultipartFile multipartFile, String email, String pass,Integer setday) {
|
||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
try {
|
try {
|
||||||
|
Confdata dataJson = confdataService.selectConfdata("config");
|
||||||
|
JSONObject confdata = JSONObject.parseObject(dataJson.getJsondata());
|
||||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
String imageFileName = "未命名图像";
|
String imageFileName = "未命名图像";
|
||||||
Integer sourceKeyId = 0;
|
Integer sourceKeyId = 0;
|
||||||
FileInputStream fis = null;
|
|
||||||
String md5key = null;
|
String md5key = null;
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
String userip = GetIPS.getIpAddr(request);
|
String userip = GetIPS.getIpAddr(request);
|
||||||
@@ -86,12 +94,20 @@ public class ClientService {
|
|||||||
msg.setInfo("图像超出系统限制大小");
|
msg.setInfo("图像超出系统限制大小");
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
FileInputStream fis = null;
|
||||||
try {
|
try {
|
||||||
fis = new FileInputStream(file);
|
fis = new FileInputStream(file);
|
||||||
md5key = DigestUtils.md5Hex(fis);
|
md5key = DigestUtils.md5Hex(fis);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.out.println("未获取到图片的MD5,成成UUID");
|
System.out.println("未获取到图片的MD5,成成UUID");
|
||||||
|
}finally{
|
||||||
|
try {
|
||||||
|
if (null != fis)
|
||||||
|
fis.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Msg fileMiME = TypeDict.FileMiME(file);
|
Msg fileMiME = TypeDict.FileMiME(file);
|
||||||
if (!fileMiME.getCode().equals("200")) {
|
if (!fileMiME.getCode().equals("200")) {
|
||||||
@@ -152,35 +168,21 @@ public class ClientService {
|
|||||||
imgObj.setImguid(imguid);
|
imgObj.setImguid(imguid);
|
||||||
imgObj.setFormat(fileMiME.getData().toString());
|
imgObj.setFormat(fileMiME.getData().toString());
|
||||||
imgObj.setIdname(imageFileName);
|
imgObj.setIdname(imageFileName);
|
||||||
Integer insertRet = imgMapper.insertImgData(imgObj);
|
Msg insertRet = imgServiceImpl.insertImgDataForCheck(imgObj,u,confdata,file.getName());
|
||||||
if (insertRet == 0) {
|
if (insertRet.getCode().equals("000")) {
|
||||||
Images imaOBJ = new Images();
|
return insertRet;
|
||||||
imaOBJ.setMd5key(md5key);
|
|
||||||
imaOBJ.setUserid(u == null ? 0 : u.getId());
|
|
||||||
List<Images> images = imgMapper.selectImgUrlByMD5(md5key);
|
|
||||||
if (images.size() > 0) {
|
|
||||||
jsonObject.put("url", images.get(0).getImgurl());
|
|
||||||
jsonObject.put("name", file.getName());
|
|
||||||
jsonObject.put("size", images.get(0).getSizes());
|
|
||||||
msg.setData(jsonObject);
|
|
||||||
return msg;
|
|
||||||
} else {
|
|
||||||
msg.setInfo("未获取到指定图像");
|
|
||||||
msg.setCode("110501");
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
long stime = System.currentTimeMillis();
|
long stime = System.currentTimeMillis();
|
||||||
ReturnImage returnImage = getSource.storageSource(key.getStorageType(), map, updatePath, key.getId());
|
ReturnImage returnImage = getSource.storageSource(key.getStorageType(), map, updatePath, key.getId());
|
||||||
if (returnImage.getCode().equals("200")) {
|
if (returnImage.getCode().equals("200")) {
|
||||||
long etime = System.currentTimeMillis();
|
long etime = System.currentTimeMillis();
|
||||||
Print.Normal("上传图片所用总时长:" + String.valueOf(etime - stime) + "ms");
|
logger.info("上传图片所用总时长:" + String.valueOf(etime - stime) + "ms");
|
||||||
jsonObject.put("url", imgObj.getImgurl());
|
jsonObject.put("url", imgObj.getImgurl());
|
||||||
jsonObject.put("name", imgObj.getImgname());
|
jsonObject.put("name", imgObj.getImgname());
|
||||||
jsonObject.put("size", imgObj.getSizes());
|
jsonObject.put("size", imgObj.getSizes());
|
||||||
imgViolationJudgeService.LegalImageCheck(imgObj,key);
|
imgViolationJudgeService.LegalImageCheck(imgObj,key);
|
||||||
} else {
|
} else {
|
||||||
imgMapper.deleimgForImgUid(imgObj.getImguid());
|
imgServiceImpl.deleimgForImgUid(imgObj.getImguid());
|
||||||
msg.setCode("5001");
|
msg.setCode("5001");
|
||||||
msg.setInfo("上传服务内部错误");
|
msg.setInfo("上传服务内部错误");
|
||||||
return msg;
|
return msg;
|
||||||
@@ -217,9 +219,9 @@ public class ClientService {
|
|||||||
memory = Long.valueOf(uploadConfig.getVisitormemory()); // 单位 B 游客设置总量
|
memory = Long.valueOf(uploadConfig.getVisitormemory()); // 单位 B 游客设置总量
|
||||||
TotleMemory = Long.valueOf(uploadConfig.getFilesizetourists()); // 单位 B 游客单文件大小
|
TotleMemory = Long.valueOf(uploadConfig.getFilesizetourists()); // 单位 B 游客单文件大小
|
||||||
UsedTotleMemory =
|
UsedTotleMemory =
|
||||||
imgMapper.getusermemory(0) == null
|
imgServiceImpl.getusermemory(0) == null
|
||||||
? 0L
|
? 0L
|
||||||
: imgMapper.getusermemory(0); // 单位 B
|
: imgServiceImpl.getusermemory(0); // 单位 B
|
||||||
} else {
|
} else {
|
||||||
// 判断用户能不能上传
|
// 判断用户能不能上传
|
||||||
if (uploadConfig.getUserclose() != 1) {
|
if (uploadConfig.getUserclose() != 1) {
|
||||||
@@ -232,9 +234,9 @@ public class ClientService {
|
|||||||
memory = Long.valueOf(user.getMemory()); // 单位 B
|
memory = Long.valueOf(user.getMemory()); // 单位 B
|
||||||
TotleMemory = Long.valueOf(uploadConfig.getFilesizeuser()); // 单位 B
|
TotleMemory = Long.valueOf(uploadConfig.getFilesizeuser()); // 单位 B
|
||||||
UsedTotleMemory =
|
UsedTotleMemory =
|
||||||
imgMapper.getusermemory(user.getId()) == null
|
imgServiceImpl.getusermemory(user.getId()) == null
|
||||||
? 0L
|
? 0L
|
||||||
: imgMapper.getusermemory(user.getId()); // 单位 B
|
: imgServiceImpl.getusermemory(user.getId()); // 单位 B
|
||||||
}
|
}
|
||||||
// 判断上传的图片目录结构类型
|
// 判断上传的图片目录结构类型
|
||||||
if (uploadConfig.getUrltype() == 2) {
|
if (uploadConfig.getUrltype() == 2) {
|
||||||
|
|||||||
@@ -1,11 +1,16 @@
|
|||||||
package cn.hellohao.service.impl;
|
package cn.hellohao.service.impl;
|
||||||
|
|
||||||
import cn.hellohao.dao.ImgMapper;
|
import cn.hellohao.dao.ImgMapper;
|
||||||
|
import cn.hellohao.dao.SysConfigMapper;
|
||||||
import cn.hellohao.pojo.Images;
|
import cn.hellohao.pojo.Images;
|
||||||
|
import cn.hellohao.pojo.Msg;
|
||||||
|
import cn.hellohao.pojo.SysConfig;
|
||||||
import cn.hellohao.pojo.User;
|
import cn.hellohao.pojo.User;
|
||||||
import cn.hellohao.service.ImgService;
|
import cn.hellohao.service.ImgService;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -13,7 +18,8 @@ import java.util.List;
|
|||||||
public class ImgServiceImpl implements ImgService {
|
public class ImgServiceImpl implements ImgService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ImgMapper imgMapper;
|
private ImgMapper imgMapper;
|
||||||
|
@Autowired
|
||||||
|
SysConfigMapper sysConfigMapper;
|
||||||
@Override
|
@Override
|
||||||
public List<Images> selectimg(Images images) {
|
public List<Images> selectimg(Images images) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
@@ -88,8 +94,8 @@ public class ImgServiceImpl implements ImgService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Images> selectImgUrlByMD5(String md5key) {
|
public List<Images> selectImgUrlByMD5(Images images) {
|
||||||
return imgMapper.selectImgUrlByMD5(md5key);
|
return imgMapper.selectImgUrlByMD5(images);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -117,4 +123,38 @@ public class ImgServiceImpl implements ImgService {
|
|||||||
return imgMapper.selectImgUrlByImgUID(imguid);
|
return imgMapper.selectImgUrlByImgUID(imguid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public Msg insertImgDataForCheck(Images images, User user, JSONObject confdata, String flilename)throws Exception {
|
||||||
|
Msg msg = new Msg();
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
SysConfig sysConfig = sysConfigMapper.getstate();
|
||||||
|
if(sysConfig.getCheckduplicate().equals("1")){
|
||||||
|
//查重
|
||||||
|
Images img = new Images();
|
||||||
|
img.setUserid(user.getId());
|
||||||
|
img.setMd5key(images.getMd5key());
|
||||||
|
List<Images> list = imgMapper.selectImgUrlByMD5(img);
|
||||||
|
jsonObject.put("url", list.get(0).getImgurl());
|
||||||
|
if (list.size() > 0) {
|
||||||
|
jsonObject.put("url", list.get(0).getImgurl());
|
||||||
|
jsonObject.put("name", flilename);
|
||||||
|
jsonObject.put("imguid", list.get(0).getImguid());
|
||||||
|
System.err.println(jsonObject.toJSONString());
|
||||||
|
msg.setData(jsonObject);
|
||||||
|
msg.setCode("000");
|
||||||
|
return msg;
|
||||||
|
}else{
|
||||||
|
imgMapper.insertImgData(images);
|
||||||
|
msg.setCode("200");
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
//不查重
|
||||||
|
imgMapper.insertImgData(images);
|
||||||
|
msg.setCode("200");
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,10 @@ import cn.hellohao.pojo.Keys;
|
|||||||
import cn.hellohao.pojo.ReturnImage;
|
import cn.hellohao.pojo.ReturnImage;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.qiniu.common.QiniuException;
|
import com.qiniu.common.QiniuException;
|
||||||
import com.qiniu.common.Zone;
|
|
||||||
import com.qiniu.http.Response;
|
import com.qiniu.http.Response;
|
||||||
import com.qiniu.storage.BucketManager;
|
import com.qiniu.storage.BucketManager;
|
||||||
import com.qiniu.storage.Configuration;
|
import com.qiniu.storage.Configuration;
|
||||||
|
import com.qiniu.storage.Region;
|
||||||
import com.qiniu.storage.UploadManager;
|
import com.qiniu.storage.UploadManager;
|
||||||
import com.qiniu.storage.model.DefaultPutRet;
|
import com.qiniu.storage.model.DefaultPutRet;
|
||||||
import com.qiniu.storage.model.FileInfo;
|
import com.qiniu.storage.model.FileInfo;
|
||||||
@@ -28,18 +28,7 @@ public class KODOImageupload {
|
|||||||
public ReturnImage ImageuploadKODO(
|
public ReturnImage ImageuploadKODO(
|
||||||
Map<Map<String, String>, File> fileMap, String username, Integer keyID) {
|
Map<Map<String, String>, File> fileMap, String username, Integer keyID) {
|
||||||
ReturnImage returnImage = new ReturnImage();
|
ReturnImage returnImage = new ReturnImage();
|
||||||
Configuration cfg;
|
Configuration cfg = new Configuration(Region.autoRegion());
|
||||||
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());
|
|
||||||
}
|
|
||||||
UploadManager uploadManager = new UploadManager(cfg);
|
UploadManager uploadManager = new UploadManager(cfg);
|
||||||
Auth auth = Auth.create(key.getAccessKey(), key.getAccessSecret());
|
Auth auth = Auth.create(key.getAccessKey(), key.getAccessSecret());
|
||||||
String upToken = auth.uploadToken(key.getBucketname(), null, 7200, null);
|
String upToken = auth.uploadToken(key.getBucketname(), null, 7200, null);
|
||||||
@@ -76,41 +65,25 @@ public class KODOImageupload {
|
|||||||
|
|
||||||
public static Integer Initialize(Keys k) {
|
public static Integer Initialize(Keys k) {
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
if (org.apache.commons.lang3.StringUtils.isBlank(k.getAccessKey())
|
if (StringUtils.isBlank(k.getAccessKey())
|
||||||
|| org.apache.commons.lang3.StringUtils.isBlank(k.getAccessSecret())
|
|| StringUtils.isBlank(k.getAccessSecret())
|
||||||
|| org.apache.commons.lang3.StringUtils.isBlank(k.getEndpoint())
|
|| StringUtils.isBlank(k.getEndpoint())
|
||||||
|| org.apache.commons.lang3.StringUtils.isBlank(k.getBucketname())
|
|| StringUtils.isBlank(k.getBucketname())
|
||||||
|| StringUtils.isBlank(k.getRequestAddress())) {
|
|| StringUtils.isBlank(k.getRequestAddress())) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
Configuration cfg;
|
Configuration cfg = new Configuration(Region.autoRegion());
|
||||||
if (k.getEndpoint().equals("1")) {
|
|
||||||
cfg = new Configuration(Zone.zone0());
|
|
||||||
} else if (k.getEndpoint().equals("2")) {
|
|
||||||
cfg = new Configuration(Zone.zone1());
|
|
||||||
} else if (k.getEndpoint().equals("3")) {
|
|
||||||
cfg = new Configuration(Zone.zone2());
|
|
||||||
} else if (k.getEndpoint().equals("4")) {
|
|
||||||
cfg = new Configuration(Zone.zoneNa0());
|
|
||||||
} else {
|
|
||||||
cfg = new Configuration(Zone.zoneAs0());
|
|
||||||
}
|
|
||||||
UploadManager uploadManager = new UploadManager(cfg);
|
UploadManager uploadManager = new UploadManager(cfg);
|
||||||
Auth auth = Auth.create(k.getAccessKey(), k.getAccessSecret());
|
Auth auth = Auth.create(k.getAccessKey(), k.getAccessSecret());
|
||||||
String upToken =
|
String upToken = auth.uploadToken(k.getBucketname(), null, 7200, null);
|
||||||
auth.uploadToken(
|
BucketManager BM = new BucketManager(auth, cfg);
|
||||||
k.getBucketname(),
|
|
||||||
null,
|
|
||||||
7200,
|
|
||||||
null); // auth.uploadToken(k.getBucketname());
|
|
||||||
BucketManager bmObj = new BucketManager(auth, cfg);
|
|
||||||
BucketManager.FileListIterator fileListIterator = null;
|
BucketManager.FileListIterator fileListIterator = null;
|
||||||
try {
|
try {
|
||||||
fileListIterator = bmObj.createFileListIterator(k.getBucketname(), "", 1, "/");
|
fileListIterator = BM.createFileListIterator(k.getBucketname(), "", 1, "/");
|
||||||
FileInfo[] items = fileListIterator.next();
|
FileInfo[] items = fileListIterator.next();
|
||||||
if (items != null) {
|
if (items != null) {
|
||||||
ret = 1;
|
ret = 1;
|
||||||
bucketManager = bmObj;
|
bucketManager = BM;
|
||||||
key = k;
|
key = k;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -116,7 +116,6 @@ public class S3Imageupload {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Integer Initialize_Tow(Keys k) {
|
public static Integer Initialize_Tow(Keys k) {
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,24 +1,31 @@
|
|||||||
package cn.hellohao.service.impl;
|
package cn.hellohao.service.impl;
|
||||||
|
|
||||||
import cn.hellohao.dao.*;
|
import cn.hellohao.config.GlobalConstant;
|
||||||
|
import cn.hellohao.dao.KeysMapper;
|
||||||
|
import cn.hellohao.dao.UploadConfigMapper;
|
||||||
|
import cn.hellohao.dao.UserMapper;
|
||||||
import cn.hellohao.pojo.*;
|
import cn.hellohao.pojo.*;
|
||||||
|
import cn.hellohao.service.ConfdataService;
|
||||||
import cn.hellohao.service.ImgTempService;
|
import cn.hellohao.service.ImgTempService;
|
||||||
|
import cn.hellohao.service.SysConfigService;
|
||||||
import cn.hellohao.utils.*;
|
import cn.hellohao.utils.*;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import org.apache.commons.codec.digest.DigestUtils;
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.shiro.SecurityUtils;
|
import org.apache.shiro.SecurityUtils;
|
||||||
import org.apache.shiro.subject.Subject;
|
import org.apache.shiro.subject.Subject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Hellohao
|
* @author Hellohao
|
||||||
@@ -27,11 +34,14 @@ import java.util.*;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class UploadServicel {
|
public class UploadServicel {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(UploadServicel.class);
|
private static Logger logger = LoggerFactory.getLogger(UploadServicel.class);
|
||||||
|
@Autowired
|
||||||
|
ConfdataService confdataService;
|
||||||
|
@Autowired
|
||||||
|
SysConfigService sysConfigService;
|
||||||
@Autowired private UploadConfigMapper uploadConfigMapper;
|
@Autowired private UploadConfigMapper uploadConfigMapper;
|
||||||
@Autowired private KeysMapper keysMapper;
|
@Autowired private KeysMapper keysMapper;
|
||||||
@Autowired private ImgMapper imgMapper;
|
@Autowired private ImgServiceImpl imgServiceImpl;
|
||||||
@Autowired private UserMapper userMapper;
|
@Autowired private UserMapper userMapper;
|
||||||
@Autowired private ImgTempService imgTempService;
|
@Autowired private ImgTempService imgTempService;
|
||||||
@Autowired private GetSource getSource;
|
@Autowired private GetSource getSource;
|
||||||
@@ -40,13 +50,16 @@ public class UploadServicel {
|
|||||||
|
|
||||||
public Msg uploadForLoc(
|
public Msg uploadForLoc(
|
||||||
HttpServletRequest request,
|
HttpServletRequest request,
|
||||||
MultipartFile multipartFile,
|
File file,
|
||||||
|
String imgName,
|
||||||
Integer setday,
|
Integer setday,
|
||||||
String imgUrl) {
|
JSONObject imgJson,
|
||||||
|
String md5key) {
|
||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
try {
|
try {
|
||||||
|
Confdata dataJson = confdataService.selectConfdata("config");
|
||||||
|
JSONObject confdata = JSONObject.parseObject(dataJson.getJsondata());
|
||||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
String imageFileName = "未命名图像";
|
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
UploadConfig uploadConfig = uploadConfigMapper.getUpdateConfig();
|
UploadConfig uploadConfig = uploadConfigMapper.getUpdateConfig();
|
||||||
String userip = GetIPS.getIpAddr(request);
|
String userip = GetIPS.getIpAddr(request);
|
||||||
@@ -56,15 +69,8 @@ public class UploadServicel {
|
|||||||
u = userMapper.getUsers(u);
|
u = userMapper.getUsers(u);
|
||||||
}
|
}
|
||||||
Integer sourceKeyId = 0;
|
Integer sourceKeyId = 0;
|
||||||
String md5key = null;
|
if (imgJson != null) {
|
||||||
FileInputStream fis = null;
|
Msg imgData = uploadForURL(request, imgJson.getString("imgUrl"),imgJson.getString("referer"));
|
||||||
File file = null;
|
|
||||||
if (imgUrl == null) {
|
|
||||||
imageFileName = multipartFile.getOriginalFilename();
|
|
||||||
file = SetFiles.changeFile_new(multipartFile);
|
|
||||||
} else {
|
|
||||||
imageFileName = "URL转存图像";
|
|
||||||
Msg imgData = uploadForURL(request, imgUrl);
|
|
||||||
if (imgData.getCode().equals("200")) {
|
if (imgData.getCode().equals("200")) {
|
||||||
file = new File((String) imgData.getData());
|
file = new File((String) imgData.getData());
|
||||||
} else {
|
} else {
|
||||||
@@ -85,19 +91,10 @@ public class UploadServicel {
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
if (file.length() > TotleMemory) {
|
if (file.length() > TotleMemory) {
|
||||||
System.err.println("文件大小:" + file.length());
|
|
||||||
System.err.println("最大限制:" + TotleMemory);
|
|
||||||
msg.setCode("4006");
|
msg.setCode("4006");
|
||||||
msg.setInfo("图像超出系统限制大小");
|
msg.setInfo("图像超出系统限制大小");
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
fis = new FileInputStream(file);
|
|
||||||
md5key = DigestUtils.md5Hex(fis);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
System.out.println("未获取到图片的MD5,成成UUID");
|
|
||||||
}
|
|
||||||
Msg fileMiME = TypeDict.FileMiME(file);
|
Msg fileMiME = TypeDict.FileMiME(file);
|
||||||
if (!fileMiME.getCode().equals("200")) {
|
if (!fileMiME.getCode().equals("200")) {
|
||||||
msg.setCode("4000");
|
msg.setCode("4000");
|
||||||
@@ -105,10 +102,22 @@ public class UploadServicel {
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
if (md5key == null || md5key.equals("")) {
|
if (md5key == null || md5key.equals("")) {
|
||||||
md5key = UUID.randomUUID().toString().replace("-", "");
|
FileInputStream fis = null;
|
||||||
|
try {
|
||||||
|
fis = new FileInputStream(file);
|
||||||
|
md5key = DigestUtils.md5Hex(fis);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("获取MD5错误",e);
|
||||||
|
}finally{
|
||||||
|
try {
|
||||||
|
if (null != fis)
|
||||||
|
fis.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
String prefix = file.getName().substring(file.getName().lastIndexOf(".") + 1);
|
String prefix = file.getName().substring(file.getName().lastIndexOf(".") + 1);
|
||||||
// 判断黑名单
|
|
||||||
if (uploadConfig.getBlacklist() != null) {
|
if (uploadConfig.getBlacklist() != null) {
|
||||||
String[] iparr = uploadConfig.getBlacklist().split(";");
|
String[] iparr = uploadConfig.getBlacklist().split(";");
|
||||||
for (String s : iparr) {
|
for (String s : iparr) {
|
||||||
@@ -159,35 +168,13 @@ public class UploadServicel {
|
|||||||
imgObj.setMd5key(md5key);
|
imgObj.setMd5key(md5key);
|
||||||
imgObj.setImguid(imguid);
|
imgObj.setImguid(imguid);
|
||||||
imgObj.setFormat(fileMiME.getData().toString());
|
imgObj.setFormat(fileMiME.getData().toString());
|
||||||
imgObj.setIdname(imageFileName);
|
imgObj.setIdname(imgName);
|
||||||
Integer insertRet = imgMapper.insertImgData(imgObj);
|
// Integer insertRet = imgMapper.insertImgData(imgObj);
|
||||||
if (insertRet == 0) {
|
Msg insertRet = imgServiceImpl.insertImgDataForCheck(imgObj,u,confdata,file.getName());
|
||||||
Images imaOBJ = new Images();
|
if (insertRet.getCode().equals("000")) {
|
||||||
imaOBJ.setMd5key(md5key);
|
return insertRet;
|
||||||
imaOBJ.setUserid(u == null ? 0 : u.getId());
|
|
||||||
List<Images> images = imgMapper.selectImgUrlByMD5(md5key);
|
|
||||||
if (images.size() > 0) {
|
|
||||||
jsonObject.put("url", images.get(0).getImgurl());
|
|
||||||
// Keys imgFromKey = keysService.selectKeys(images.get(0).getSource());
|
|
||||||
// if (imgFromKey.getStorageType().equals(5)) {
|
|
||||||
// jsonObject.put(
|
|
||||||
// "url",
|
|
||||||
// imgFromKey.getRequestAddress()
|
|
||||||
// + "/ota/"
|
|
||||||
// + images.get(0).getImgname());
|
|
||||||
// } else {
|
|
||||||
// jsonObject.put("url", images.get(0).getImgurl());
|
|
||||||
// }
|
|
||||||
jsonObject.put("name", file.getName());
|
|
||||||
jsonObject.put("imguid", images.get(0).getImguid());
|
|
||||||
msg.setData(jsonObject);
|
|
||||||
return msg;
|
|
||||||
} else {
|
|
||||||
msg.setInfo("未获取到指定图像");
|
|
||||||
msg.setCode("110501");
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long stime = System.currentTimeMillis();
|
long stime = System.currentTimeMillis();
|
||||||
ReturnImage returnImage = getSource.storageSource(key.getStorageType(), map, updatePath, key.getId());
|
ReturnImage returnImage = getSource.storageSource(key.getStorageType(), map, updatePath, key.getId());
|
||||||
if (returnImage.getCode().equals("200")) {
|
if (returnImage.getCode().equals("200")) {
|
||||||
@@ -203,7 +190,7 @@ public class UploadServicel {
|
|||||||
// })
|
// })
|
||||||
// .start();
|
// .start();
|
||||||
} else {
|
} else {
|
||||||
imgMapper.deleimgForImgUid(imgObj.getImguid());
|
imgServiceImpl.deleimgForImgUid(imgObj.getImguid());
|
||||||
msg.setCode("5001");
|
msg.setCode("5001");
|
||||||
msg.setInfo("上传服务内部错误");
|
msg.setInfo("上传服务内部错误");
|
||||||
return msg;
|
return msg;
|
||||||
@@ -219,42 +206,97 @@ public class UploadServicel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Msg uploadForURL(HttpServletRequest request, String imgurl) {
|
public CompletableFuture<Msg> mergeFile(HttpServletRequest request, String data, User user){
|
||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
if (true) {
|
try{
|
||||||
Long imgsize = 0L;
|
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||||
try {
|
String filename = jsonObj.getString("filename");
|
||||||
if (imgsize == 0) {
|
String uuid = jsonObj.getString("uuid");
|
||||||
String ShortUID = SetText.getShortUuid();
|
String md5 = jsonObj.getString("md5");
|
||||||
String savePath =
|
String classifications = jsonObj.getString("classifications");
|
||||||
request.getSession().getServletContext().getRealPath("/")
|
Integer day = jsonObj.getInteger("day");
|
||||||
+ File.separator
|
String source = jsonObj.getString("source");
|
||||||
+ "hellohaotmp"
|
String imgIdentifier = jsonObj.getString("imgIdentifier");
|
||||||
+ File.separator;
|
JSONArray jsonArray = new JSONArray();
|
||||||
Map<String, Object> bl = ImgUrlUtil.downLoadFromUrl(imgurl, ShortUID, savePath);
|
classifications = classifications==null?"":classifications;
|
||||||
if ((Boolean) bl.get("res") == true) {
|
if(!org.apache.commons.lang3.StringUtils.isBlank(classifications)){
|
||||||
msg.setCode("200");
|
String[] calssif = classifications.split(",");
|
||||||
msg.setData(bl.get("imgPath"));
|
for (int i = 0; i < calssif.length; i++) {
|
||||||
return msg;
|
jsonArray.add(calssif[i]);
|
||||||
} else {
|
|
||||||
if (bl.get("StatusCode").equals("110403")) {
|
|
||||||
msg.setInfo("该链接非图像文件,无法上传");
|
|
||||||
} else {
|
|
||||||
msg.setInfo("该链接暂时无法上传");
|
|
||||||
}
|
|
||||||
msg.setCode("500");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
msg.setCode("500");
|
|
||||||
msg.setInfo("获取资源失败");
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
}
|
||||||
|
String path = GlobalConstant.HELLOHAOTEMPIMG_PATH+File.separator+uuid+File.separator+imgIdentifier+File.separator+filename;
|
||||||
|
// if(new File(path).exists()){
|
||||||
|
// path = GlobalConstant.HELLOHAOTEMPIMG_PATH+File.separator+UUID.randomUUID().toString().replace("-", "").toLowerCase()+filename;
|
||||||
|
// }
|
||||||
|
String folder = GlobalConstant.HELLOHAOTEMPIMG_PATH+File.separator+uuid+File.separator+imgIdentifier;
|
||||||
|
String delFolder = GlobalConstant.HELLOHAOTEMPIMG_PATH+File.separator+uuid;
|
||||||
|
String originalFilename = filename;
|
||||||
|
if(StringUtils.isBlank(originalFilename)){
|
||||||
|
originalFilename = "未命名图像";
|
||||||
|
}
|
||||||
|
Msg merge = SetFiles.merge(path, folder, filename);
|
||||||
|
if(merge.getCode().equals("200")){
|
||||||
|
File file = new File(path);
|
||||||
|
// CompletableFuture<Msg> ret =
|
||||||
|
msg = uploadForLoc(request, file,originalFilename, day, null,md5);
|
||||||
|
// msg = ret.get();
|
||||||
|
}else{
|
||||||
|
msg = merge;
|
||||||
|
}
|
||||||
|
SetFiles.delFileFolder(new File(delFolder));
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
msg.setCode("500");
|
||||||
|
msg.setInfo("文件上传时发生错误");
|
||||||
|
}
|
||||||
|
return CompletableFuture.completedFuture(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Msg uploadForURL(HttpServletRequest request, String imgurls,String referer) {
|
||||||
|
final Msg msg = new Msg();
|
||||||
|
String url = imgurls;
|
||||||
|
// 先判断是不是有效链接 并且自动判断协议头http(s)://
|
||||||
|
GetProtocol getProtocol = new GetProtocol();
|
||||||
|
String protocol = getProtocol.getProtocol(url,referer);
|
||||||
|
if (protocol == null) {
|
||||||
|
msg.setInfo("服务器解析该链接失败");
|
||||||
|
msg.setCode("500");
|
||||||
|
return msg;
|
||||||
|
} else {
|
||||||
|
url = protocol;
|
||||||
|
}
|
||||||
|
Long imgsize = 0L;
|
||||||
|
try {
|
||||||
|
if (imgsize == 0) {
|
||||||
|
String ShortUID = SetText.getShortUuid();
|
||||||
|
String savePath =
|
||||||
|
request.getSession().getServletContext().getRealPath("/")
|
||||||
|
+ File.separator
|
||||||
|
+ "hellohaotmp"
|
||||||
|
+ File.separator;
|
||||||
|
Map<String, Object> bl = ImgUrlUtil.downLoadFromUrl(url,referer, ShortUID, savePath);
|
||||||
|
if ((Boolean) bl.get("res") == true) {
|
||||||
|
// File file = new File();
|
||||||
|
msg.setCode("200");
|
||||||
|
msg.setData(bl.get("imgPath")); // savePath + File.separator + ShortUID
|
||||||
|
return msg;
|
||||||
|
} else {
|
||||||
|
if (bl.get("StatusCode").equals("110403")) {
|
||||||
|
msg.setInfo("该链接非图像文件,无法上传");
|
||||||
|
} else {
|
||||||
|
msg.setInfo("该链接暂时无法上传");
|
||||||
|
}
|
||||||
|
msg.setCode("500");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
msg.setCode("500");
|
msg.setCode("500");
|
||||||
msg.setInfo("获取资源失败");
|
msg.setInfo("获取资源失败");
|
||||||
}
|
}
|
||||||
} else {
|
} catch (Exception e) {
|
||||||
msg.setCode("500");
|
msg.setCode("500");
|
||||||
msg.setInfo("该链接无效");
|
msg.setInfo("获取资源失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
return msg;
|
return msg;
|
||||||
@@ -283,9 +325,9 @@ public class UploadServicel {
|
|||||||
memory = Long.valueOf(uploadConfig.getVisitormemory()); // 单位 B 游客设置总量
|
memory = Long.valueOf(uploadConfig.getVisitormemory()); // 单位 B 游客设置总量
|
||||||
TotleMemory = Long.valueOf(uploadConfig.getFilesizetourists()); // 单位 B 游客单文件大小
|
TotleMemory = Long.valueOf(uploadConfig.getFilesizetourists()); // 单位 B 游客单文件大小
|
||||||
UsedTotleMemory =
|
UsedTotleMemory =
|
||||||
imgMapper.getusermemory(0) == null
|
imgServiceImpl.getusermemory(0) == null
|
||||||
? 0L
|
? 0L
|
||||||
: imgMapper.getusermemory(0); // 单位 B
|
: imgServiceImpl.getusermemory(0); // 单位 B
|
||||||
} else {
|
} else {
|
||||||
if (uploadConfig.getUserclose() != 1) {
|
if (uploadConfig.getUserclose() != 1) {
|
||||||
msg.setCode("1001");
|
msg.setCode("1001");
|
||||||
@@ -297,9 +339,9 @@ public class UploadServicel {
|
|||||||
memory = Long.valueOf(user.getMemory()); // 单位 B *1024*1024
|
memory = Long.valueOf(user.getMemory()); // 单位 B *1024*1024
|
||||||
TotleMemory = Long.valueOf(uploadConfig.getFilesizeuser()); // 单位 B
|
TotleMemory = Long.valueOf(uploadConfig.getFilesizeuser()); // 单位 B
|
||||||
UsedTotleMemory =
|
UsedTotleMemory =
|
||||||
imgMapper.getusermemory(user.getId()) == null
|
imgServiceImpl.getusermemory(user.getId()) == null
|
||||||
? 0L
|
? 0L
|
||||||
: imgMapper.getusermemory(user.getId()); // 单位 B
|
: imgServiceImpl.getusermemory(user.getId()); // 单位 B
|
||||||
}
|
}
|
||||||
if (uploadConfig.getUrltype() == 2) {
|
if (uploadConfig.getUrltype() == 2) {
|
||||||
updatePath = dateFormat.format(new Date());
|
updatePath = dateFormat.format(new Date());
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class deleImages {
|
|||||||
@Autowired private KeysServiceImpl keysService;
|
@Autowired private KeysServiceImpl keysService;
|
||||||
@Autowired private IRedisService iRedisService;
|
@Autowired private IRedisService iRedisService;
|
||||||
|
|
||||||
public Msg dele(String uuid, Long... imgIds) {
|
public Msg dele(boolean forceDel,String uuid, Long... imgIds) {
|
||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
MyProgress myProgress = new MyProgress();
|
MyProgress myProgress = new MyProgress();
|
||||||
myProgress.InitializeDelImg();
|
myProgress.InitializeDelImg();
|
||||||
@@ -44,6 +44,20 @@ public class deleImages {
|
|||||||
boolean isDele = false;
|
boolean isDele = false;
|
||||||
try {
|
try {
|
||||||
Images image = imgService.selectByPrimaryKey(imgIds[i]);
|
Images image = imgService.selectByPrimaryKey(imgIds[i]);
|
||||||
|
if (!forceDel) {
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
Keys key = keysService.selectKeys(image.getSource());
|
Keys key = keysService.selectKeys(image.getSource());
|
||||||
if (key.getStorageType() == 1) {
|
if (key.getStorageType() == 1) {
|
||||||
isDele = nosImageupload.delNOS(key.getId(), image);
|
isDele = nosImageupload.delNOS(key.getId(), image);
|
||||||
@@ -64,20 +78,21 @@ public class deleImages {
|
|||||||
} else {
|
} else {
|
||||||
System.err.println("未获取到对象存储参数,删除失败。");
|
System.err.println("未获取到对象存储参数,删除失败。");
|
||||||
}
|
}
|
||||||
// if (isDele) {
|
if (!forceDel) {
|
||||||
try {
|
try {
|
||||||
imgAndAlbumService.deleteImgAndAlbum(image.getImgurl());
|
imgAndAlbumService.deleteImgAndAlbum(image.getImgurl());
|
||||||
imgTempService.delImgAndExp(image.getImguid());
|
imgTempService.delImgAndExp(image.getImguid());
|
||||||
imgService.deleimg(image.getId());
|
imgService.deleimg(image.getId());
|
||||||
ids.add(image.getId());
|
ids.add(image.getId());
|
||||||
successCount++;
|
successCount++;
|
||||||
System.out.println("删除成功加一个" + image.getId());
|
System.out.println("删除成功加一个" + image.getId());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.err.println(image.getImgname() + ":图片数据库记录时发生错误");
|
System.err.println(image.getImgname() + ":图片数据库记录时发生错误");
|
||||||
errorIds.add(image.getImgurl());
|
errorIds.add(image.getImgurl());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
if(uuid!=null){
|
if(uuid!=null){
|
||||||
myProgress.setDelSuccessCount(successCount);
|
myProgress.setDelSuccessCount(successCount);
|
||||||
myProgress.setDelSuccessImgList(ids);
|
myProgress.setDelSuccessImgList(ids);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package cn.hellohao.utils;
|
package cn.hellohao.utils;
|
||||||
|
|
||||||
import cn.hellohao.config.GlobalConstant;
|
import cn.hellohao.config.GlobalConstant;
|
||||||
import org.slf4j.Logger;
|
import cn.hutool.core.io.FileUtil;import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.InitializingBean;
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
@@ -111,7 +111,7 @@ public class FirstRun implements InitializingBean {
|
|||||||
RunSqlScript.RunInsert(instartConfdata);
|
RunSqlScript.RunInsert(instartConfdata);
|
||||||
Print.Normal("Add table.confdata");
|
Print.Normal("Add table.confdata");
|
||||||
}
|
}
|
||||||
// RunSqlScript.RunInsert(inddx_md5key);
|
RunSqlScript.RunInsert(index_imgdata);
|
||||||
RunSqlScript.RunInsert("ALTER TABLE tbed.`user` MODIFY id int auto_increment;");
|
RunSqlScript.RunInsert("ALTER TABLE tbed.`user` MODIFY id int auto_increment;");
|
||||||
Print.Normal("Stage success");
|
Print.Normal("Stage success");
|
||||||
|
|
||||||
@@ -143,11 +143,10 @@ public class FirstRun implements InitializingBean {
|
|||||||
private String instartAppclient = "INSERT INTO `appclient` VALUES ('app', 'on', NULL, NULL, 'Hellohao图像托管', 'https://hellohao.nos-eastchina1.126.net/TbedClient/app.png', '1.0.1');";
|
private String instartAppclient = "INSERT INTO `appclient` VALUES ('app', 'on', NULL, NULL, 'Hellohao图像托管', 'https://hellohao.nos-eastchina1.126.net/TbedClient/app.png', '1.0.1');";
|
||||||
//创建confdata表
|
//创建confdata表
|
||||||
private String createConfdata = "CREATE TABLE tbed.confdata ( `key` varchar(100) NULL, jsondata LONGTEXT NULL )";
|
private String createConfdata = "CREATE TABLE tbed.confdata ( `key` varchar(100) NULL, jsondata LONGTEXT NULL )";
|
||||||
private String instartConfdata =
|
private String instartConfdata =
|
||||||
"INSERT INTO `confdata` VALUES ('config', '{\\\"sourcekey\\\":7,\\\"emails\\\":1,\\\"webname\\\":\\\"Hellohao图床\\\",\\\"explain\\\":\\\"Hellohao图像托管,是一家免费开源的图像托管,即时分享你的美好瞬间。\\\",\\\"links\\\":\\\"<p style=\\\\\\\"color:#7c7c88;\\\\\\\">© 2019 <a href=\\\\\\\"http://www.Hellohao.cn/\\\\\\\" target=\\\\\\\"_blank\\\\\\\" title=\\\\\\\"Hellohao\\\\\\\">Hellohao</a><span> - All Rights Reserved</span> </p>\\\",\\\"notice\\\":\\\"也许...|这将是最好用的图床|为了更好的用户体验,建议您注册本站继续免费使用Hellohao图床。本站不得上传任何形式的非法图片,一旦发现,永久删除并禁封账户。情节严重者将相关资料交于相关部门处理。\\\",\\\"domain\\\":\\\"http://127.0.0.1:10088\\\",\\\"background1\\\":\\\"\\\",\\\"sett\\\":\\\"1\\\",\\\"webms\\\":\\\"Hellohao图像托管,是一家免费开源的图像托管,即时分享你的美好瞬间。\\\",\\\"webkeywords\\\":\\\"hellohao图床,图床,图片上传,开源图床,hellohao,图像托管,图片分享\\\",\\\"theme\\\":2,\\\"websubtitle\\\":\\\"这将是你用过最优秀的图像托管程序\\\",\\\"logo\\\":null,\\\"aboutinfo\\\":\\\"<img width=\\\\\\\"300px\\\\\\\" src=\\\\\\\"http://img.wwery.com/hellohao/rPscRYwz.png\\\\\\\"> <br /> <br /> <p>也许,这将是你用到最优秀的图像托管程序</p> <p>本程序为Hellohao图象托管程序</p> <br/> <p style=\\\\\\\"color: #656565;\\\\\\\">作者:hellohao独立开发</p> <p style=\\\\\\\"color: #656565;\\\\\\\">www.hellohao.cn</p>\\\"}');";
|
"INSERT INTO tbed.confdata VALUES ('config', '{\\\"sourcekey\\\":7,\\\"emails\\\":1,\\\"webname\\\":\\\"Hellohao图床\\\",\\\"explain\\\":\\\"Hellohao图像托管,是一家免费开源的图像托管,即时分享你的美好瞬间。\\\",\\\"links\\\":\\\"<p style=\\\\\\\"color:#7c7c88;\\\\\\\">© 2019 <a href=\\\\\\\"http://www.Hellohao.cn/\\\\\\\" target=\\\\\\\"_blank\\\\\\\" title=\\\\\\\"Hellohao\\\\\\\">Hellohao</a><span> - All Rights Reserved</span> </p>\\\",\\\"notice\\\":\\\"也许...|这将是最好用的图床|为了更好的用户体验,建议您注册本站继续免费使用Hellohao图床。本站不得上传任何形式的非法图片,一旦发现,永久删除并禁封账户。情节严重者将相关资料交于相关部门处理。\\\",\\\"domain\\\":\\\"http://127.0.0.1:10088\\\",\\\"background1\\\":\\\"\\\",\\\"sett\\\":\\\"1\\\",\\\"webms\\\":\\\"Hellohao图像托管,是一家免费开源的图像托管,即时分享你的美好瞬间。\\\",\\\"webkeywords\\\":\\\"hellohao图床,图床,图片上传,开源图床,hellohao,图像托管,图片分享\\\",\\\"theme\\\":2,\\\"websubtitle\\\":\\\"这将是你用过最优秀的图像托管程序\\\",\\\"logo\\\":null,\\\"aboutinfo\\\":\\\"<img width=\\\\\\\"300px\\\\\\\" src=\\\\\\\"http://img.wwery.com/hellohao/rPscRYwz.png\\\\\\\"> <br /> <br /> <p>也许,这将是你用到最优秀的图像托管程序</p> <p>本程序为Hellohao图象托管程序</p> <br/> <p style=\\\\\\\"color: #656565;\\\\\\\">作者:hellohao独立开发</p> <p style=\\\\\\\"color: #656565;\\\\\\\">www.hellohao.cn</p>\\\"}');";
|
||||||
|
|
||||||
private String inddx_md5key = "ALTER TABLE imgdata ADD INDEX index_md5key_url ( md5key,imgurl)";
|
private String index_imgdata = "ALTER TABLE imgdata ADD INDEX index_md5key_url ( id,md5key,imgname,imgurl,idname,imguid)";
|
||||||
// create index yarn_app_result_i4 on yarn_app_result (flow_exec_id(100), another_column(50));
|
|
||||||
|
|
||||||
private String dynamic = "alter table imgdata row_format=dynamic";
|
private String dynamic = "alter table imgdata row_format=dynamic";
|
||||||
private String compressed = "alter table imgdata row_format=compressed";
|
private String compressed = "alter table imgdata row_format=compressed";
|
||||||
@@ -159,14 +158,15 @@ public class FirstRun implements InitializingBean {
|
|||||||
//判断目录有没有创建
|
//判断目录有没有创建
|
||||||
File file = new File(GlobalConstant.LOCPATH);
|
File file = new File(GlobalConstant.LOCPATH);
|
||||||
if(!file.exists()){
|
if(!file.exists()){
|
||||||
file.mkdirs();
|
FileUtil.mkdir(file);
|
||||||
file1.mkdirs();
|
FileUtil.mkdir(file1);
|
||||||
file2.mkdirs();
|
FileUtil.mkdir(file2);
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
if(!file1.exists()){
|
if(!file1.exists()){
|
||||||
file1.mkdirs();
|
FileUtil.mkdir(file1);
|
||||||
}else if(!file2.exists()){
|
}else if(!file2.exists()){
|
||||||
file2.mkdirs();
|
FileUtil.mkdir(file2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -191,7 +191,8 @@ public class FirstRun implements InitializingBean {
|
|||||||
System.out.print("文件存在");
|
System.out.print("文件存在");
|
||||||
} else {
|
} else {
|
||||||
System.out.print("文件不存在");
|
System.out.print("文件不存在");
|
||||||
f.createNewFile();// 不存在则创建
|
// f.createNewFile();// 不存在则创建
|
||||||
|
FileUtil.createTempFile(f);
|
||||||
}
|
}
|
||||||
// BufferedReader input = new BufferedReader(new FileReader(f));
|
// BufferedReader input = new BufferedReader(new FileReader(f));
|
||||||
// while ((str = input.readLine()) != null) {
|
// while ((str = input.readLine()) != null) {
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
package cn.hellohao.utils;
|
||||||
|
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
public class GetProtocol {
|
||||||
|
private final static String HTTP= "http://";
|
||||||
|
private final static String HTTPS = "https://";
|
||||||
|
private String newurl;
|
||||||
|
|
||||||
|
//判断协议 能连接上则协议正确
|
||||||
|
public String getProtocol(String url,String referer) {
|
||||||
|
newurl = clearUrl(url);
|
||||||
|
url = HTTP + newurl;
|
||||||
|
if (exists(url,referer)) {
|
||||||
|
return url;
|
||||||
|
} else {
|
||||||
|
url = HTTPS + newurl;
|
||||||
|
if (exists(url,referer)) {
|
||||||
|
return url;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
//清除URL里多余的符号
|
||||||
|
private String clearUrl(String url) {
|
||||||
|
if (url.contains(HTTP)) {
|
||||||
|
url = url.substring(url.lastIndexOf(HTTP) + HTTP.length());
|
||||||
|
for (int i = 0; i < url.length(); i++) {
|
||||||
|
if (url.charAt(i) == '/' || url.charAt(i) == '.'
|
||||||
|
|| url.charAt(i) == '\\') {
|
||||||
|
} else {
|
||||||
|
url = url.substring(i);
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (url.contains(HTTPS)) {
|
||||||
|
url = url.substring(url.lastIndexOf(HTTPS) + HTTPS.length());
|
||||||
|
for (int i = 0; i < url.length(); i++) {
|
||||||
|
if (url.charAt(i) == '/' || url.charAt(i) == '.'
|
||||||
|
|| url.charAt(i) == '\\') {
|
||||||
|
} else {
|
||||||
|
url = url.substring(i);
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
for (int i = 0; i < url.length(); i++) {
|
||||||
|
if (url.charAt(i) == '/' || url.charAt(i) == '.'
|
||||||
|
|| url.charAt(i) == '\\') {
|
||||||
|
} else {
|
||||||
|
url = url.substring(i);
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
//是否能连接上
|
||||||
|
private boolean exists(String url,String referer) {
|
||||||
|
try {
|
||||||
|
HttpURLConnection con = (HttpURLConnection) new URL(url).openConnection();
|
||||||
|
con.setConnectTimeout(3000);
|
||||||
|
con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36");
|
||||||
|
con.setRequestProperty("referer", StringUtils.isBlank(referer)?"no-referrer":referer);
|
||||||
|
System.out.println(con.getResponseCode() );
|
||||||
|
return (con.getResponseCode() == 200);
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args){
|
||||||
|
|
||||||
|
try {
|
||||||
|
String url = "https://img-blog.csdnimg.cn/cbf3201a3cfe4fc38a7cef006487158c.png";
|
||||||
|
URL obj = new URL(url);
|
||||||
|
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
|
||||||
|
String referer = con.getRequestProperty("Referer");
|
||||||
|
System.out.println("Referer: " + referer);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,6 +2,7 @@ package cn.hellohao.utils;
|
|||||||
|
|
||||||
import cn.hellohao.TbedApplication;
|
import cn.hellohao.TbedApplication;
|
||||||
import cn.hellohao.pojo.Msg;
|
import cn.hellohao.pojo.Msg;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
@@ -83,14 +84,7 @@ public class ImgUrlUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
public static Map<String ,Object> downLoadFromUrl(String urlStr,String referer,String fileName,String savePath){
|
||||||
* 从网络Url中下载文件
|
|
||||||
* @param urlStr
|
|
||||||
* @param fileName
|
|
||||||
* @param savePath
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
|
||||||
public static Map<String ,Object> downLoadFromUrl(String urlStr,String fileName,String savePath){
|
|
||||||
|
|
||||||
Map<String ,Object> resmap = new HashMap<>();
|
Map<String ,Object> resmap = new HashMap<>();
|
||||||
Map<String ,String> map = checkURLStatusCode(urlStr);
|
Map<String ,String> map = checkURLStatusCode(urlStr);
|
||||||
@@ -102,11 +96,11 @@ public class ImgUrlUtil {
|
|||||||
try {
|
try {
|
||||||
URL url = new URL(urlStr);
|
URL url = new URL(urlStr);
|
||||||
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
|
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
|
||||||
|
conn.setRequestProperty("referer", StringUtils.isBlank(referer) ? "no-referrer" : referer);
|
||||||
//设置超时间为3秒
|
//设置超时间为3秒
|
||||||
conn.setConnectTimeout(5*1000);
|
conn.setConnectTimeout(5*1000);
|
||||||
//防止屏蔽程序抓取而返回403错误
|
//防止屏蔽程序抓取而返回403错误
|
||||||
conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
|
conn.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36");
|
||||||
|
|
||||||
//得到输入流
|
//得到输入流
|
||||||
InputStream inputStream = conn.getInputStream();
|
InputStream inputStream = conn.getInputStream();
|
||||||
//获取自己数组
|
//获取自己数组
|
||||||
@@ -125,7 +119,6 @@ public class ImgUrlUtil {
|
|||||||
inputStream.close();
|
inputStream.close();
|
||||||
}
|
}
|
||||||
//下载并且保存成功后 判断格式 如果不是图像格式 就删除
|
//下载并且保存成功后 判断格式 如果不是图像格式 就删除
|
||||||
//
|
|
||||||
if(new File(saveDir+File.separator+fileName).exists()){
|
if(new File(saveDir+File.separator+fileName).exists()){
|
||||||
Msg msg = TypeDict.FileMiME(file);
|
Msg msg = TypeDict.FileMiME(file);
|
||||||
if(msg.getCode().equals("200")){
|
if(msg.getCode().equals("200")){
|
||||||
@@ -144,8 +137,6 @@ public class ImgUrlUtil {
|
|||||||
resmap.put("res",false);
|
resmap.put("res",false);
|
||||||
resmap.put("StatusCode","500");
|
resmap.put("StatusCode","500");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return resmap;
|
return resmap;
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -155,7 +146,6 @@ public class ImgUrlUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从输入流中获取字节数组
|
* 从输入流中获取字节数组
|
||||||
* @param inputStream
|
* @param inputStream
|
||||||
|
|||||||
@@ -1,9 +1,16 @@
|
|||||||
package cn.hellohao.utils;
|
package cn.hellohao.utils;
|
||||||
|
|
||||||
|
import cn.hellohao.pojo.Chunk;
|
||||||
|
import cn.hellohao.pojo.Msg;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.nio.file.StandardOpenOption;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
public class SetFiles {
|
public class SetFiles {
|
||||||
// 转换文件方法
|
// 转换文件方法
|
||||||
@@ -78,7 +85,73 @@ public class SetFiles {
|
|||||||
return fileSizeString;
|
return fileSizeString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String generatePath(String uploadFolder, Chunk chunk) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(uploadFolder+File.separator).append("/").append(chunk.getIdentifier());
|
||||||
|
if (!Files.isWritable(Paths.get(sb.toString()))) {
|
||||||
|
System.err.println("path not exist,create path");
|
||||||
|
System.err.println(sb.toString());
|
||||||
|
try {
|
||||||
|
Files.createDirectories(Paths.get(sb.toString()));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.append("/")
|
||||||
|
.append(chunk.getFilename())
|
||||||
|
.append("-")
|
||||||
|
.append(chunk.getChunkNumber()).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Msg merge(String targetFile, String folder, String filename) {
|
||||||
|
Msg msg = new Msg();
|
||||||
|
try {
|
||||||
|
final File file = new File(targetFile);
|
||||||
|
if (file.exists()){
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
Files.createFile(Paths.get(targetFile));
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.out.println("这是一个无伤大雅的错:IOException");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
try (Stream<Path> stream = Files.list(Paths.get(folder))) {
|
||||||
|
stream.filter(path -> !path.getFileName().toString().equals(filename))
|
||||||
|
.sorted((o1, o2) -> {
|
||||||
|
String p1 = o1.getFileName().toString();
|
||||||
|
String p2 = o2.getFileName().toString();
|
||||||
|
int i1 = p1.lastIndexOf("-");
|
||||||
|
int i2 = p2.lastIndexOf("-");
|
||||||
|
return Integer.valueOf(p2.substring(i2)).compareTo(Integer.valueOf(p1.substring(i1)));
|
||||||
|
})
|
||||||
|
.forEach(path -> {
|
||||||
|
try {
|
||||||
|
//以追加的形式写入文件
|
||||||
|
Files.write(Paths.get(targetFile), Files.readAllBytes(path), StandardOpenOption.APPEND);
|
||||||
|
//合并后删除该块
|
||||||
|
Files.delete(path);
|
||||||
|
} catch (IOException e) {
|
||||||
|
msg.setCode("500");
|
||||||
|
msg.setInfo("合并文件时发生了错误");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (IOException e) {
|
||||||
|
msg.setCode("500");
|
||||||
|
msg.setInfo("合并文件时发生了错误");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void delFileFolder(File file){
|
||||||
|
if (file.isDirectory()){
|
||||||
|
File[] files = file.listFiles();
|
||||||
|
for (File in: files) {
|
||||||
|
delFileFolder(in);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ public class SetText {
|
|||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
try {
|
try {
|
||||||
String check = "^\\w+@[a-zA-Z0-9]{2,10}(?:\\.[a-z]{2,4}){1,3}$";
|
String check = "^\\w+@[a-zA-Z0-9]{2,10}(?:\\.[a-z]{2,4}){1,3}$";
|
||||||
|
// String regex = "\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*"; //这个也可以用
|
||||||
Pattern regex = Pattern.compile(check);
|
Pattern regex = Pattern.compile(check);
|
||||||
Matcher matcher = regex.matcher(email);
|
Matcher matcher = regex.matcher(email);
|
||||||
flag = matcher.matches();
|
flag = matcher.matches();
|
||||||
@@ -66,6 +67,5 @@ public class SetText {
|
|||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ server.port=10088
|
|||||||
#前端域名需要带协议头http(s)://
|
#前端域名需要带协议头http(s)://
|
||||||
CROS_ALLOWED_ORIGINS=${HELLOHAO_WEB_HOST:http://127.0.0.1:8080}
|
CROS_ALLOWED_ORIGINS=${HELLOHAO_WEB_HOST:http://127.0.0.1:8080}
|
||||||
#数据库账号
|
#数据库账号
|
||||||
spring.datasource.username=root
|
spring.datasource.username=${MYSQL_NAME:root}
|
||||||
#数据库密码test
|
#数据库密码test
|
||||||
spring.datasource.password=${MYSQL_PASS:root}
|
spring.datasource.password=${MYSQL_PASS:root}
|
||||||
#数据库链接地址
|
#数据库链接地址
|
||||||
spring.datasource.url=${MYSQL_URL:jdbc:mysql://127.0.0.1:3306/tbed?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8}
|
spring.datasource.url=${MYSQL_URL:jdbc:mysql://localhost:3306/tbed?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8}
|
||||||
#MySQL Driver 无需修改
|
#MySQL Driver 无需修改
|
||||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||||
|
|
||||||
@@ -49,4 +49,10 @@ spring.datasource.druid.stat-view-servlet.login-password=52BNmXPJL0rQQ3CU
|
|||||||
spring.datasource.druid.stat-view-servlet.allow=127.0.0.1
|
spring.datasource.druid.stat-view-servlet.allow=127.0.0.1
|
||||||
spring.datasource.druid.web-stat-filter.exclusions=false
|
spring.datasource.druid.web-stat-filter.exclusions=false
|
||||||
#log4j.logger.cn.hellohao.dao=DEBUG
|
#log4j.logger.cn.hellohao.dao=DEBUG
|
||||||
log4j2.formatMsgNoLookups=True
|
log4j2.formatMsgNoLookups=True
|
||||||
|
logging.level.cn.hellohao=DEBUG
|
||||||
|
logging.file.name=/HellohaoData/tbedlog/tbed.log
|
||||||
|
logging.pattern.console=%blue(%d{yyyy-MM-dd HH:mm:ss,SSS}) [%cyan(%t)] [%yellow(%c)]-[%highlight(%p)] %msg%n
|
||||||
|
logging.pattern.file=%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
|
||||||
|
logging.logback.rollingpolicy.clean-history-on-start=true
|
||||||
|
logging.logback.rollingpolicy.max-history=7
|
||||||
|
|||||||
@@ -9,11 +9,12 @@
|
|||||||
FROM
|
FROM
|
||||||
`album`
|
`album`
|
||||||
<where>
|
<where>
|
||||||
|
1=1
|
||||||
<if test="albumkey != null">
|
<if test="albumkey != null">
|
||||||
`albumkey` = #{albumkey}
|
and `albumkey` = #{albumkey}
|
||||||
</if>
|
</if>
|
||||||
<if test="userid != null">
|
<if test="userid != null">
|
||||||
`userid` = #{userid}
|
and `userid` = #{userid}
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
@@ -38,14 +39,15 @@
|
|||||||
u.username
|
u.username
|
||||||
FROM `album` a LEFT JOIN user u on a.userid = u.id
|
FROM `album` a LEFT JOIN user u on a.userid = u.id
|
||||||
<where>
|
<where>
|
||||||
|
1=1
|
||||||
<if test="albumkey != null">
|
<if test="albumkey != null">
|
||||||
`albumkey` like '%${albumkey}%'
|
and `albumkey` like '%${albumkey}%'
|
||||||
</if>
|
</if>
|
||||||
<if test="username != null">
|
<if test="username != null">
|
||||||
`username` like '%${username}%'
|
and `username` like '%${username}%'
|
||||||
</if>
|
</if>
|
||||||
<if test="userid != null">
|
<if test="userid != null">
|
||||||
a.userid = #{userid}
|
and a.userid = #{userid}
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
order by a.createdate
|
order by a.createdate
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
FROM
|
FROM
|
||||||
`imgandalbum`
|
`imgandalbum`
|
||||||
<where>
|
<where>
|
||||||
|
1=1
|
||||||
<if test="albumkey != null">
|
<if test="albumkey != null">
|
||||||
`albumkey` = #{albumkey}
|
`albumkey` = #{albumkey}
|
||||||
</if>
|
</if>
|
||||||
@@ -21,6 +22,7 @@
|
|||||||
FROM
|
FROM
|
||||||
`imgandalbum`
|
`imgandalbum`
|
||||||
<where>
|
<where>
|
||||||
|
1=1
|
||||||
<if test="imgname != null">
|
<if test="imgname != null">
|
||||||
`imgname` = #{imgname}
|
`imgname` = #{imgname}
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
@@ -67,10 +67,46 @@
|
|||||||
and
|
and
|
||||||
a.imguid = #{imguid}
|
a.imguid = #{imguid}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="searchname != null">
|
||||||
|
and CONCAT(
|
||||||
|
imgurl,
|
||||||
|
idname
|
||||||
|
) LIKE '%${searchname}%'
|
||||||
|
</if>
|
||||||
<if test="idname != null and idname !=''">
|
<if test="idname != null and idname !=''">
|
||||||
and idname LIKE '%${idname}%'
|
and idname LIKE '%${idname}%'
|
||||||
</if>
|
</if>
|
||||||
order by a.id desc
|
order by
|
||||||
|
<choose>
|
||||||
|
<when test="order == 'desc'">
|
||||||
|
a.updatetime desc
|
||||||
|
</when>
|
||||||
|
<when test="order == 'asc'">
|
||||||
|
a.updatetime asc
|
||||||
|
</when>
|
||||||
|
<when test="order == 'sizeAsc'">
|
||||||
|
CONVERT(a.sizes,SIGNED) asc
|
||||||
|
</when>
|
||||||
|
<when test="order == 'sizeDesc'">
|
||||||
|
CONVERT(a.sizes,SIGNED) desc
|
||||||
|
</when>
|
||||||
|
<otherwise>
|
||||||
|
a.updatetime desc
|
||||||
|
</otherwise>
|
||||||
|
</choose>
|
||||||
|
<!-- <if test="order == 'desc'">-->
|
||||||
|
<!-- a.updatetime desc-->
|
||||||
|
<!-- </if>-->
|
||||||
|
<!-- <if test="order == 'asc'">-->
|
||||||
|
<!-- a.updatetime asc-->
|
||||||
|
<!-- </if>-->
|
||||||
|
<!-- <if test="order == 'sizeAsc'">-->
|
||||||
|
<!-- CONVERT(a.sizes,SIGNED) asc-->
|
||||||
|
<!-- </if>-->
|
||||||
|
<!-- <if test="order == 'sizeDesc'">-->
|
||||||
|
<!-- CONVERT(a.sizes,SIGNED) desc-->
|
||||||
|
<!-- </if>-->
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertImgData" parameterType="cn.hellohao.pojo.Images">
|
<insert id="insertImgData" parameterType="cn.hellohao.pojo.Images">
|
||||||
@@ -92,27 +128,8 @@
|
|||||||
violation,
|
violation,
|
||||||
idname
|
idname
|
||||||
)
|
)
|
||||||
select * from (
|
VALUES (null, #{imgname}, #{imgurl}, #{userid}, #{updatetime},#{sizes},#{abnormal},#{source},#{imgtype},
|
||||||
SELECT NULL id,
|
#{explains},#{md5key},#{imguid},#{format},#{about},null,#{idname})
|
||||||
#{imgname} imgname,
|
|
||||||
#{imgurl} imgurl,
|
|
||||||
#{userid} userid,
|
|
||||||
#{updatetime} updatetime,
|
|
||||||
#{sizes} sizes,
|
|
||||||
#{abnormal} abnormal,
|
|
||||||
#{source} `source`,
|
|
||||||
#{imgtype} imgtype,
|
|
||||||
#{explains} explains,
|
|
||||||
#{md5key} md5key,
|
|
||||||
#{imguid} imguid,
|
|
||||||
#{format} `format`,
|
|
||||||
#{about} about,
|
|
||||||
null violation,
|
|
||||||
#{idname} idname
|
|
||||||
) temp_t
|
|
||||||
where
|
|
||||||
IF((select (select checkduplicate from sysconfig where id =1)=1),
|
|
||||||
not exists (select md5key from imgdata img_t where temp_t.md5key = img_t.md5key),true)
|
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
|
||||||
@@ -190,6 +207,9 @@
|
|||||||
|
|
||||||
<select id="selectImgUrlByMD5" parameterType="string" resultType="cn.hellohao.pojo.Images">
|
<select id="selectImgUrlByMD5" parameterType="string" resultType="cn.hellohao.pojo.Images">
|
||||||
select imgname,imgurl from imgdata where md5key = #{md5key}
|
select imgname,imgurl from imgdata where md5key = #{md5key}
|
||||||
|
<if test="userid != null">
|
||||||
|
and userid = #{userid}
|
||||||
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 查询当前用户的近20条数据-->
|
<!-- 查询当前用户的近20条数据-->
|
||||||
|
|||||||
@@ -74,6 +74,9 @@
|
|||||||
<if test="email != null">
|
<if test="email != null">
|
||||||
and email = #{email}
|
and email = #{email}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="username != null">
|
||||||
|
and username = #{username}
|
||||||
|
</if>
|
||||||
<if test="uid != null">
|
<if test="uid != null">
|
||||||
and uid = #{uid}
|
and uid = #{uid}
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
Reference in New Issue
Block a user