mirror of
https://github.com/Hello-hao/Tbed.git
synced 2024-04-21 12:32:10 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75d753c53c | ||
|
|
677c53104a | ||
|
|
113e69fff2 | ||
|
|
0ede684acb | ||
|
|
f0dd1d0db8 | ||
|
|
59aaaa1c82 | ||
|
|
f990c4cd80 | ||
|
|
369b88ffb3 | ||
|
|
bfa41ac049 | ||
|
|
ca0da1dd06 | ||
|
|
44814e79b0 | ||
|
|
f02d865389 | ||
|
|
48b0e1c5ca | ||
|
|
a04bbc1ea6 | ||
|
|
31b4426c10 | ||
|
|
766c125673 | ||
|
|
0de7e0e0fc | ||
|
|
f24a2d5557 | ||
|
|
87394258ad | ||
|
|
89a66a17b3 | ||
|
|
3e4c90c8d9 | ||
|
|
fb9f2a896e | ||
|
|
9ca8695cfd | ||
|
|
33d4990ded | ||
|
|
679ada60bc | ||
|
|
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 | ||
|
|
733ec3e6f9 | ||
|
|
c3e91f3593 | ||
|
|
8ebdbf6cee | ||
|
|
393ad3138e | ||
|
|
6f6166275a | ||
|
|
cc05712906 | ||
|
|
538482a73b | ||
|
|
e61b7ce10d | ||
|
|
1408b9c029 | ||
|
|
f56bc84d29 | ||
|
|
f8a712e601 | ||
|
|
4ca9159956 | ||
|
|
2048660b64 | ||
|
|
2ee49dcae2 | ||
|
|
b978f33aba | ||
|
|
d8bb6c1738 | ||
|
|
e1018bde75 | ||
|
|
8c8e44f82c | ||
|
|
f61e672e54 | ||
|
|
4a5147b862 | ||
|
|
f9374cbc0e |
@@ -1,6 +0,0 @@
|
|||||||
*.js linguist-language=java
|
|
||||||
|
|
||||||
*.css linguist-language=java
|
|
||||||
|
|
||||||
*.html linguist-language=java
|
|
||||||
|
|
||||||
@@ -1,16 +1,29 @@
|
|||||||
# Hellohao图像托管程序 - 也许这会是最优秀的图床程序
|
# Hellohao图像托管 - 也许这会是最优秀的图像托管程序
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://www.hellohao.cn/" target="_blank">
|
||||||
|
<img width="1920px" src="https://upload.cc/i1/2022/02/11/HSg5tX.png">
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||

|

|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
|
<h3 align="center">赞助商</h3>
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<a href="https://www.eltyun.com/" target="_blank">
|
||||||
|
<img width="350px" src="https://t.tdo.ink/hellohao/s9ugmihq.png">
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
>:exclamation: 托管的所有开源代码可能存在作者修改/测试/调整等行为,均为实验性代码,故并不保证程序或功能的可用性,如果你想要部署程序,请下载我们提供的编译整合包进行安装部署。
|
||||||
|
|
||||||
|
|
||||||
### 引导
|
### 引导
|
||||||
|
|
||||||
[官网](https://tbed.hellohao.cn) | [宣传视频](https://www.bilibili.com/video/BV11r4y1y7mH/) | [文档](https://doc.hellohao.cn) | [演示站](https://pic.hellohao.cn) | [前端源码](https://github.com/Hello-hao/tbed-web)
|
[官网](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 +34,21 @@
|
|||||||
|
|
||||||
**存储源支持:**
|
**存储源支持:**
|
||||||
|
|
||||||
开源版:`本地`,`阿里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+存储源)
|
||||||
|
|
||||||
|
|
||||||
### 更新日志 `20220901`
|
### 更新日志 `20240319`
|
||||||
|
|
||||||
- `增加`图片名称显示/编辑功能(为后续图像精准搜索打基础)
|
|
||||||
- `增加`数据库命名检测(数据库名称必须为:tbed)
|
|
||||||
- `调整`站点设置表单的部分字段字符数限制
|
|
||||||
- `调整`页面部分表单的文字显示
|
|
||||||
|
|
||||||
|
|
||||||
[^_^]:程序宣传视频:[自制宣传视频](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)
|
|
||||||
|
|
||||||
|
- 修复部分部署场景部署不成功的问题
|
||||||
|
- 提高系统稳定性
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
### 主要功能
|
### 主要功能
|
||||||
|
|
||||||
- [x] 全端支持,不限于(web/windows/mac/移动小程序)
|
- [x] 全端支持,不限于(`web端`/`桌面端Windows/Mac`/`移动端小程序`)
|
||||||
|
|
||||||
- [x] 前后端分离式架构设计,部署更方便
|
- [x] 前后端分离式架构设计,部署更方便
|
||||||
|
|
||||||
@@ -100,11 +88,83 @@ 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)
|
||||||
|
|
||||||
|
更强大的功能可[购买Core版](http://tbed.hellohao.cn/pay)程序
|
||||||
|
|
||||||
|
|
||||||
|
### 启动项目
|
||||||
|
> 访问你的前端域名即可
|
||||||
|
|
||||||
|
初始用户名:`admin`
|
||||||
|
初始邮箱:`admin`
|
||||||
|
初始密码:`admin`
|
||||||
|
|
||||||
|
|
||||||
### 系统预览
|
### 系统预览
|
||||||
|
|
||||||

|

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

|

|
||||||
|
|
||||||
@@ -114,17 +174,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
|
||||||
|
|
||||||
### 所用技术
|
### 所用技术
|
||||||
@@ -145,36 +215,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/#)开源协议,使用前请悉知。
|
||||||
如果你想商用或程序定制,请先与我们联系,分享你的利益。
|
如果你想商用或程序定制,请先与我们联系,分享你的利益。
|
||||||
@@ -184,11 +227,11 @@ Core版:`本地`,`阿里OSS`,`又拍USS`,`七牛KODO`,`腾讯COS`,`网易NOS`,
|
|||||||
|
|
||||||
**如果你遇到BUG欢迎反馈**
|
**如果你遇到BUG欢迎反馈**
|
||||||
|
|
||||||
欢迎加入Hellohao开发者交流群,群聊号码:**864800972**
|
- 前往论坛发帖反馈、求助:[Hellohao开发者交流论坛](http://bbs.hellohao.cn)
|
||||||
|
- 也可加QQ群探讨:864800972
|
||||||
|
|
||||||
### 捐赠开发者
|
### 更多
|
||||||
|
|
||||||
**如果你也支持Hellohao图床,可以请我喝杯咖啡。我会持续更新Hellohao图床**
|
**如需程序定制或其他业务,请与我们取得联系**
|
||||||
|
[Hellohao图像托管官网](http://hellohao.cn)
|
||||||
**捐赠地址:** [**https://tbed.hellohao.cn/pay**](https://tbed.hellohao.cn/pay)
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
FROM openjdk:8
|
||||||
|
|
||||||
|
MAINTAINER 923453645@qq.com
|
||||||
|
|
||||||
|
ADD hellohaotbed/ /hellohaotbed
|
||||||
|
|
||||||
|
COPY appstart.sh /appstart.sh
|
||||||
|
|
||||||
|
COPY application.properties /application.properties
|
||||||
|
|
||||||
|
COPY Tbed.jar /Tbed.jar
|
||||||
|
|
||||||
|
EXPOSE 10088
|
||||||
|
|
||||||
|
EXPOSE 10089
|
||||||
|
|
||||||
|
CMD ["/bin/bash","/appstart.sh"]
|
||||||
@@ -90,11 +90,11 @@
|
|||||||
<artifactId>spring-boot-starter-validation</artifactId>
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<!-- <dependency>-->
|
||||||
<groupId>commons-logging</groupId>
|
<!-- <groupId>commons-logging</groupId>-->
|
||||||
<artifactId>commons-logging</artifactId>
|
<!-- <artifactId>commons-logging</artifactId>-->
|
||||||
<version>1.2</version>
|
<!-- <version>1.2</version>-->
|
||||||
</dependency>
|
<!-- </dependency>-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.pagehelper</groupId>
|
<groupId>com.github.pagehelper</groupId>
|
||||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||||
@@ -120,17 +120,31 @@
|
|||||||
<artifactId>pebble</artifactId>
|
<artifactId>pebble</artifactId>
|
||||||
<version>3.1.5</version>
|
<version>3.1.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.amazonaws</groupId>
|
||||||
|
<artifactId>aws-java-sdk-s3</artifactId>
|
||||||
|
<version>1.12.334</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-mail</artifactId>
|
<artifactId>spring-boot-starter-mail</artifactId>
|
||||||
<version>2.5.1</version>
|
<version>2.5.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!-- webdav-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpclient</artifactId>
|
||||||
|
<version>4.5.14</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.lookfirst</groupId>
|
||||||
|
<artifactId>sardine</artifactId>
|
||||||
|
<version>5.10</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baidu.aip</groupId>
|
<groupId>com.baidu.aip</groupId>
|
||||||
<artifactId>java-sdk</artifactId>
|
<artifactId>java-sdk</artifactId>
|
||||||
<version>4.11.0</version>
|
<version>4.16.14</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.coobird</groupId>
|
<groupId>net.coobird</groupId>
|
||||||
@@ -192,7 +206,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>
|
||||||
@@ -234,7 +248,7 @@
|
|||||||
<configuration>
|
<configuration>
|
||||||
<testFailureIgnore>true</testFailureIgnore>
|
<testFailureIgnore>true</testFailureIgnore>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><configuration><source>8</source><target>8</target></configuration></plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -11,7 +11,7 @@
|
|||||||
Target Server Version : 80028
|
Target Server Version : 80028
|
||||||
File Encoding : 65001
|
File Encoding : 65001
|
||||||
|
|
||||||
Date: 01/09/2022 00:28:28
|
Date: 01/01/2023 23:02:40
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SET NAMES utf8mb4;
|
SET NAMES utf8mb4;
|
||||||
@@ -99,7 +99,7 @@ CREATE TABLE `config` (
|
|||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of config
|
-- Records of config
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
INSERT INTO `config` VALUES (1, 7, 1, 'Hellohao图床', 'Hellohao图像托管,是一家免费开源的图像托管,即时分享你的美好瞬间。', 'https://hellohao-cloud.oss-cn-beijing.aliyuncs.com/books_x264.mp4http://cdn.wwery.com/Hellohao/439550606022825.jpg', '1', '<p style=\"color:#7c7c88;\">© 2019 <a href=\"http://www.Hellohao.cn/\" target=\"_blank\" title=\"Hellohao\">Hellohao</a><span> - All Rights Reserved</span> </p>', '也许...|这将是最好用的图床|为了更好的用户体验,建议您注册本站继续免费使用Hellohao图床。本站不得上传任何形式的非法图片,一旦发现,永久删除并禁封账户。情节严重者将相关资料交于相关部门处理。', 'var _hmt = _hmt || [];\n(function() {\n var hm = document.createElement(\"script\");\n hm.src = \"https://hm.baidu.com/hm.js?16c326e608c984c9bae6a63eda861888\";\n var s = document.getElementsByTagName(\"script\")[0]; \n s.parentNode.insertBefore(hm, s);\n})();\n\n', 'http://api.hellohao.cn', '', 'http://cdn.wwery.com/Hellohao/3e1901120091153.jpg', 1, 'Hellohao图像托管,是一家免费开源的图像托管,即时分享你的美好瞬间。', 'hellohao图床,图床,图片上传,开源图床,hellohao,图像托管,图片分享', 'https://hellohao.nos-eastchina1.126.net/BlogImg/favicon.ico', 2, '这将是你用过最优秀的图像托管程序', NULL, '<img width=\"300px\" src=\"http://img.wwery.com/Hellohao/rPscRYwz.png\">\n <br />\n <br />\n <p>也许,这将是你用到最优秀的图像托管程序</p>\n <p>本程序为Hellohao图象托管程序</p>\n <br/>\n <p style=\"color: #656565;\">作者:hellohao独立开发</p>\n <p style=\"color: #656565;\">www.hellohao.cn</p>');
|
INSERT INTO `config` VALUES (1, 7, 1, 'Hellohao图床', 'Hellohao图像托管,是一家免费开源的图像托管,即时分享你的美好瞬间。', 'https://hellohao-cloud.oss-cn-beijing.aliyuncs.com/books_x264.mp4http://cdn.wwery.com/Hellohao/439550606022825.jpg', '1', '<p style=\"color:#7c7c88;\">版权所有©<a href=\"http://tbed.Hellohao.cn/\" target=\"_blank\" title=\"Hellohao\">Hellohao图像托管</a><span> 2019- 2023 </span> </p>', '也许...|这将是最好用的图床|为了更好的用户体验,建议您注册本站继续免费使用Hellohao图床。本站不得上传任何形式的非法图片,一旦发现,永久删除并禁封账户。情节严重者将相关资料交于相关部门处理。', 'var _hmt = _hmt || [];\n(function() {\n var hm = document.createElement(\"script\");\n hm.src = \"https://hm.baidu.com/hm.js?16c326e608c984c9bae6a63eda861888\";\n var s = document.getElementsByTagName(\"script\")[0]; \n s.parentNode.insertBefore(hm, s);\n})();\n\n', 'http://api.hellohao.cn', '', 'http://cdn.wwery.com/Hellohao/3e1901120091153.jpg', 1, 'Hellohao图像托管,是一家免费开源的图像托管,即时分享你的美好瞬间。', 'hellohao图床,图床,图片上传,开源图床,hellohao,图像托管,图片分享', 'https://hellohao.nos-eastchina1.126.net/BlogImg/favicon.ico', 2, '这将是你用过最优秀的图像托管程序', NULL, '<img width=\"300px\" src=\"http://img.wwery.com/Hellohao/rPscRYwz.png\">\n <br />\n <br />\n <p>也许,这将是你用到最优秀的图像托管程序</p>\n <p>本程序为Hellohao图象托管程序</p>\n <br/>\n <p style=\"color: #656565;\">作者:hellohao独立开发</p>\n <p style=\"color: #656565;\">www.hellohao.cn</p>');
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for emailconfig
|
-- Table structure for emailconfig
|
||||||
@@ -292,7 +292,7 @@ INSERT INTO `uploadconfig` VALUES (1, '10485760', '20971520', 5, 10, 'gif,jpg,jp
|
|||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
DROP TABLE IF EXISTS `user`;
|
DROP TABLE IF EXISTS `user`;
|
||||||
CREATE TABLE `user` (
|
CREATE TABLE `user` (
|
||||||
`id` int(0) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
`id` int(0) NOT NULL AUTO_INCREMENT,
|
||||||
`username` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户名',
|
`username` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '用户名',
|
||||||
`password` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '密码',
|
`password` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '密码',
|
||||||
`email` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
`email` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
|
||||||
@@ -309,7 +309,7 @@ CREATE TABLE `user` (
|
|||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of user
|
-- Records of user
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
INSERT INTO `user` VALUES (1, 'admin', 'YWRtaW4=', 'admin', '2019-01-10', 2, '9b76655b2706483780bf54988ca12531', 1, '2147483648', 1, '');
|
INSERT INTO `user` VALUES (1, 'admin', 'YWRtaW4=', 'admin', '2019-01-10', 2, '05bc9cdc2d454ab59e9cd7eaa9ed296a', 1, '2147483648', 1, '');
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for usergroup
|
-- Table structure for usergroup
|
||||||
@@ -320,7 +320,7 @@ CREATE TABLE `usergroup` (
|
|||||||
`userid` int(0) NULL DEFAULT NULL,
|
`userid` int(0) NULL DEFAULT NULL,
|
||||||
`groupid` int(0) NULL DEFAULT NULL,
|
`groupid` int(0) NULL DEFAULT NULL,
|
||||||
PRIMARY KEY (`id`) USING BTREE
|
PRIMARY KEY (`id`) USING BTREE
|
||||||
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Records of usergroup
|
-- Records of usergroup
|
||||||
|
|||||||
@@ -1,24 +1,25 @@
|
|||||||
package cn.hellohao;
|
package cn.hellohao;
|
||||||
|
|
||||||
import javax.servlet.MultipartConfigElement;
|
import cn.hellohao.dao.KeysMapper;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import cn.hellohao.utils.FirstRun;
|
||||||
|
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||||
import cn.hellohao.utils.Print;
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.jdbc.DatabaseDriver;
|
||||||
import org.springframework.boot.web.servlet.MultipartConfigFactory;
|
import org.springframework.boot.web.servlet.MultipartConfigFactory;
|
||||||
import org.springframework.boot.web.servlet.ServletComponentScan;
|
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.annotation.PropertySource;
|
import org.springframework.jdbc.support.DatabaseStartupValidator;
|
||||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||||
import org.springframework.util.unit.DataSize;
|
import org.springframework.util.unit.DataSize;
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
|
||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
||||||
|
|
||||||
|
import javax.servlet.MultipartConfigElement;
|
||||||
|
import javax.sql.DataSource;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.util.Scanner;
|
import java.net.Socket;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@Configuration
|
@Configuration
|
||||||
@@ -30,6 +31,31 @@ public class TbedApplication {
|
|||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(TbedApplication.class, args);
|
SpringApplication.run(TbedApplication.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//延缓Spring Boot启动时间直到数据库启动的方法
|
||||||
|
@Bean
|
||||||
|
public DatabaseStartupValidator databaseStartupValidator(DataSource dataSource) {
|
||||||
|
DatabaseStartupValidator databaseStartupValidator = new DatabaseStartupValidator();
|
||||||
|
databaseStartupValidator.setDataSource(dataSource);
|
||||||
|
databaseStartupValidator.setValidationQuery(DatabaseDriver.POSTGRESQL.getValidationQuery());
|
||||||
|
return databaseStartupValidator;
|
||||||
|
}
|
||||||
|
@Bean
|
||||||
|
public static BeanFactoryPostProcessor dependsOnPostProcessor() {
|
||||||
|
return bf -> {
|
||||||
|
// Let beans that need the database depend on the DatabaseStartupValidator
|
||||||
|
// like the JPA EntityManagerFactory or Flyway
|
||||||
|
String[] flyway = bf.getBeanNamesForType(FirstRun.class);
|
||||||
|
Stream.of(flyway)
|
||||||
|
.map(bf::getBeanDefinition)
|
||||||
|
.forEach(it -> it.setDependsOn("databaseStartupValidator"));
|
||||||
|
|
||||||
|
String[] jpa = bf.getBeanNamesForType(KeysMapper.class);
|
||||||
|
Stream.of(jpa)
|
||||||
|
.map(bf::getBeanDefinition)
|
||||||
|
.forEach(it -> it.setDependsOn("databaseStartupValidator"));
|
||||||
|
};
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 文件上传配置
|
* 文件上传配置
|
||||||
* @return
|
* @return
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -25,6 +27,7 @@ public class SubjectFilter extends BasicHttpAuthenticationFilter {
|
|||||||
|
|
||||||
public static String WEBHOST = null;
|
public static String WEBHOST = null;
|
||||||
private String CODE ="000";
|
private String CODE ="000";
|
||||||
|
|
||||||
protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) {
|
protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object mappedValue) {
|
||||||
UserServiceImpl userService = SpringContextHolder.getBean(UserServiceImpl.class);
|
UserServiceImpl userService = SpringContextHolder.getBean(UserServiceImpl.class);
|
||||||
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
|
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
|
||||||
@@ -32,7 +35,6 @@ public class SubjectFilter extends BasicHttpAuthenticationFilter {
|
|||||||
String serviceName = httpServletRequest.getServletPath();//获取接口
|
String serviceName = httpServletRequest.getServletPath();//获取接口
|
||||||
String Users_Origin = httpServletRequest.getHeader("usersOrigin");
|
String Users_Origin = httpServletRequest.getHeader("usersOrigin");
|
||||||
String token = httpServletRequest.getHeader("Authorization");
|
String token = httpServletRequest.getHeader("Authorization");
|
||||||
//验证前端域名
|
|
||||||
if(httpServletRequest.getMethod().equals("POST") && !serviceName.contains("/api") && !serviceName.contains("/verifyCode")
|
if(httpServletRequest.getMethod().equals("POST") && !serviceName.contains("/api") && !serviceName.contains("/verifyCode")
|
||||||
&& !serviceName.contains("/getClientVersion") && !serviceName.contains("/client")){
|
&& !serviceName.contains("/getClientVersion") && !serviceName.contains("/client")){
|
||||||
try{
|
try{
|
||||||
@@ -78,6 +80,8 @@ public class SubjectFilter extends BasicHttpAuthenticationFilter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// String token = httpServletRequest.getHeader("Authorization");
|
||||||
JSONObject jsonObject = JWTUtil.checkToken(token);
|
JSONObject jsonObject = JWTUtil.checkToken(token);
|
||||||
if(!jsonObject.getBoolean("check")){
|
if(!jsonObject.getBoolean("check")){
|
||||||
if(!serviceName.contains("admin") || serviceName.contains("admin/client")){
|
if(!serviceName.contains("admin") || serviceName.contains("admin/client")){
|
||||||
@@ -134,11 +138,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,7 +31,9 @@ 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("/w/**","anon");
|
||||||
filterMap.put("/user/**","anon");
|
filterMap.put("/user/**","anon");
|
||||||
filterMap.put("/ota/**","anon");
|
filterMap.put("/ota/**","anon");
|
||||||
filterMap.put("/admin/root/**","roles[admin]");
|
filterMap.put("/admin/root/**","roles[admin]");
|
||||||
|
|||||||
@@ -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,11 +47,16 @@ 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;
|
||||||
}
|
}
|
||||||
|
//密码认证(防止泄露,不需要我们做)
|
||||||
return new SimpleAuthenticationInfo(u,u.getPassword(),"");
|
return new SimpleAuthenticationInfo(u,u.getPassword(),"");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package cn.hellohao.config;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class LogSystemProxy {
|
||||||
|
|
||||||
|
private final static Logger log = LoggerFactory.getLogger("proxy.system.log");
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void initProxy(){
|
||||||
|
log.debug("LogSystemProxy init .....");
|
||||||
|
System.setOut(getLoggerProxy(StdType.OUT));
|
||||||
|
System.setErr(getLoggerProxy(StdType.ERR));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private enum StdType{
|
||||||
|
OUT(System.out, log::info),
|
||||||
|
ERR(System.err, log::error),
|
||||||
|
;
|
||||||
|
PrintStream stream;
|
||||||
|
Consumer<String> consumer;
|
||||||
|
StdType(PrintStream stream,Consumer<String> consumer){
|
||||||
|
this.stream = stream;
|
||||||
|
this.consumer = consumer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private PrintStream getLoggerProxy(StdType stdType){
|
||||||
|
return new PrintStream(stdType.stream){
|
||||||
|
@Override
|
||||||
|
public void print(String s) {
|
||||||
|
stdType.stream.print(s);
|
||||||
|
stdType.consumer.accept(s);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package cn.hellohao.config;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||||
|
|
||||||
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
|
||||||
|
//线程池
|
||||||
|
@Configuration
|
||||||
|
@EnableAsync
|
||||||
|
public class PoolConfig {
|
||||||
|
ThreadPoolProperties properties = new ThreadPoolProperties();
|
||||||
|
@Bean(name = "taskExecutor")
|
||||||
|
public ThreadPoolTaskExecutor taskExecutor() {
|
||||||
|
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||||
|
executor.setCorePoolSize(properties.getCorePoolSize()); //设置核心线程数
|
||||||
|
executor.setMaxPoolSize(properties.getMaxPoolSize()); //设置最大线程数
|
||||||
|
executor.setQueueCapacity(properties.getQueueCapacity()); //设置队列容量
|
||||||
|
executor.setThreadNamePrefix(properties.getThreadNamePrefix());
|
||||||
|
executor.setKeepAliveSeconds(properties.getKeepAliveTime());
|
||||||
|
executor.setWaitForTasksToCompleteOnShutdown(properties.isWaitForTasksToCompleteOnShutdown());
|
||||||
|
executor.setAwaitTerminationSeconds(properties.getAwaitTerminationSeconds());
|
||||||
|
// 设置任务拒绝策略
|
||||||
|
/**
|
||||||
|
* 4种
|
||||||
|
* ThreadPoolExecutor类有几个内部实现类来处理这类情况:
|
||||||
|
- AbortPolicy 丢弃任务,抛RejectedExecutionException
|
||||||
|
- CallerRunsPolicy 由该线程调用线程运行。直接调用Runnable的run方法运行。
|
||||||
|
- DiscardPolicy 抛弃策略,直接丢弃这个新提交的任务
|
||||||
|
- DiscardOldestPolicy 抛弃旧任务策略,从队列中踢出最先进入队列(最后一个执行)的任务
|
||||||
|
* 实现RejectedExecutionHandler接口,可自定义处理器
|
||||||
|
*/
|
||||||
|
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||||
|
return executor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
class ThreadPoolProperties {
|
||||||
|
private int corePoolSize = 5;
|
||||||
|
private int maxPoolSize = 50;
|
||||||
|
private int keepAliveTime = 15;
|
||||||
|
private int queueCapacity = 10;
|
||||||
|
private String threadNamePrefix = "Tbed-Thread";
|
||||||
|
private boolean allowCoreThreadTimeout = false;
|
||||||
|
private boolean waitForTasksToCompleteOnShutdown = false;
|
||||||
|
private int awaitTerminationSeconds;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,19 +4,27 @@ import cn.hellohao.config.SysName;
|
|||||||
import cn.hellohao.pojo.*;
|
import cn.hellohao.pojo.*;
|
||||||
import cn.hellohao.pojo.vo.PageResultBean;
|
import cn.hellohao.pojo.vo.PageResultBean;
|
||||||
import cn.hellohao.service.*;
|
import cn.hellohao.service.*;
|
||||||
import cn.hellohao.service.impl.*;
|
import cn.hellohao.service.impl.AlbumServiceImpl;
|
||||||
import cn.hellohao.utils.*;
|
import cn.hellohao.service.impl.UserServiceImpl;
|
||||||
|
import cn.hellohao.service.impl.deleImages;
|
||||||
|
import cn.hellohao.utils.SetFiles;
|
||||||
|
import cn.hellohao.utils.SetText;
|
||||||
import cn.hellohao.utils.progress.MyProgress;
|
import cn.hellohao.utils.progress.MyProgress;
|
||||||
|
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;
|
||||||
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;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import javax.servlet.http.HttpSession;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -30,25 +38,16 @@ import java.util.*;
|
|||||||
@RequestMapping("/admin")
|
@RequestMapping("/admin")
|
||||||
public class AdminController {
|
public class AdminController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired private ImgService imgService;
|
||||||
private ImgService imgService;
|
@Autowired private KeysService keysService;
|
||||||
@Autowired
|
@Autowired private UserServiceImpl userService;
|
||||||
private KeysService keysService;
|
@Autowired private ImgreviewService imgreviewService;
|
||||||
@Autowired
|
@Autowired private UploadConfigService uploadConfigService;
|
||||||
private UserServiceImpl userService;
|
@Autowired private CodeService codeService;
|
||||||
@Autowired
|
@Autowired private AlbumService albumService;
|
||||||
private ImgreviewService imgreviewService;
|
@Autowired AlbumServiceImpl albumServiceI;
|
||||||
@Autowired
|
@Autowired private deleImages deleimages;
|
||||||
private UploadConfigService uploadConfigService;
|
@Autowired private IRedisService iRedisService;
|
||||||
@Autowired
|
|
||||||
private CodeService codeService;
|
|
||||||
@Autowired
|
|
||||||
private AlbumService albumService;
|
|
||||||
@Autowired
|
|
||||||
AlbumServiceImpl albumServiceI;
|
|
||||||
@Autowired
|
|
||||||
private deleImages deleimages;
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping(value = "/overviewData")
|
@PostMapping(value = "/overviewData")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
@@ -56,7 +55,7 @@ public class AdminController {
|
|||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
Subject subject = SecurityUtils.getSubject();
|
Subject subject = SecurityUtils.getSubject();
|
||||||
User user = (User) subject.getPrincipal();
|
User user = (User) subject.getPrincipal();
|
||||||
user = userService.getUsers(user);
|
user = userService.getUsers(user);
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
UploadConfig uploadConfig = uploadConfigService.getUpdateConfig();
|
UploadConfig uploadConfig = uploadConfigService.getUpdateConfig();
|
||||||
Imgreview imgreview = imgreviewService.selectByPrimaryKey(1);
|
Imgreview imgreview = imgreviewService.selectByPrimaryKey(1);
|
||||||
@@ -66,45 +65,51 @@ public class AdminController {
|
|||||||
jsonObject.put("myImgTotal", imgService.countimg(user.getId()));
|
jsonObject.put("myImgTotal", imgService.countimg(user.getId()));
|
||||||
jsonObject.put("myAlbumTitle", albumService.selectAlbumCount(user.getId()));
|
jsonObject.put("myAlbumTitle", albumService.selectAlbumCount(user.getId()));
|
||||||
long memory = Long.valueOf(user.getMemory());
|
long memory = Long.valueOf(user.getMemory());
|
||||||
Long usermemory = imgService.getusermemory(user.getId())==null?0L:imgService.getusermemory(user.getId());
|
Long usermemory =
|
||||||
if(memory==0){
|
imgService.getusermemory(user.getId()) == null
|
||||||
jsonObject.put("myMemory","无容量");
|
? 0L
|
||||||
}else{
|
: imgService.getusermemory(user.getId());
|
||||||
Double aDouble = Double.valueOf(String.format("%.2f", (((double)usermemory/(double)memory)*100)));
|
if (memory == 0) {
|
||||||
if(aDouble>=999){
|
jsonObject.put("myMemory", "无容量");
|
||||||
jsonObject.put("myMemory",999);
|
} else {
|
||||||
}else{
|
Double aDouble =
|
||||||
jsonObject.put("myMemory",aDouble);
|
Double.valueOf(String.format("%.2f", (((double) usermemory / (double) memory) * 100)));
|
||||||
|
if (aDouble >= 999) {
|
||||||
|
jsonObject.put("myMemory", 999);
|
||||||
|
} else {
|
||||||
|
jsonObject.put("myMemory", aDouble);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jsonObject.put("myMemorySum",SetFiles.readableFileSize(memory));
|
jsonObject.put("myMemorySum", SetFiles.readableFileSize(memory));
|
||||||
if(user.getLevel()>1){
|
if (user.getLevel() > 1) {
|
||||||
ok = "true";
|
ok = "true";
|
||||||
jsonObject.put("imgTotal", imgService.counts(null) );
|
jsonObject.put("imgTotal", imgService.counts(null));
|
||||||
jsonObject.put("userTotal", userService.getUserTotal());
|
jsonObject.put("userTotal", userService.getUserTotal());
|
||||||
jsonObject.put("ViolationImgTotal", imgreview.getCount());
|
jsonObject.put("ViolationImgTotal", imgreview.getCount());
|
||||||
jsonObject.put("ViolationSwitch", isImgreviewOK==null?0:isImgreviewOK.getId());
|
jsonObject.put("ViolationSwitch", isImgreviewOK == null ? 0 : isImgreviewOK.getId());
|
||||||
jsonObject.put("VisitorUpload", uploadConfig.getIsupdate());
|
jsonObject.put("VisitorUpload", uploadConfig.getIsupdate());
|
||||||
jsonObject.put("VisitorMemory", SetFiles.readableFileSize(Long.valueOf(uploadConfig.getVisitormemory())));//访客共大小
|
jsonObject.put(
|
||||||
if(uploadConfig.getIsupdate()!=1){
|
"VisitorMemory",
|
||||||
|
SetFiles.readableFileSize(Long.valueOf(uploadConfig.getVisitormemory()))); // 访客共大小
|
||||||
|
if (uploadConfig.getIsupdate() != 1) {
|
||||||
jsonObject.put("VisitorUpload", 0);
|
jsonObject.put("VisitorUpload", 0);
|
||||||
jsonObject.put("VisitorProportion",100.00);
|
jsonObject.put("VisitorProportion", 100.00);
|
||||||
jsonObject.put("VisitorMemory", "禁用");
|
jsonObject.put("VisitorMemory", "禁用");
|
||||||
}else{
|
} else {
|
||||||
Long temp = imgService.getusermemory(0)==null?0:imgService.getusermemory(0);
|
Long temp = imgService.getusermemory(0) == null ? 0 : imgService.getusermemory(0);
|
||||||
jsonObject.put("UsedMemory", (temp == null ? 0 : SetFiles.readableFileSize(temp)));
|
jsonObject.put("UsedMemory", (temp == null ? 0 : SetFiles.readableFileSize(temp)));
|
||||||
if(Long.valueOf(uploadConfig.getVisitormemory())==0){
|
if (Long.valueOf(uploadConfig.getVisitormemory()) == 0) {
|
||||||
jsonObject.put("VisitorProportion",100.00);
|
jsonObject.put("VisitorProportion", 100.00);
|
||||||
}else if(Long.valueOf(uploadConfig.getVisitormemory())==-1){
|
} else if (Long.valueOf(uploadConfig.getVisitormemory()) == -1) {
|
||||||
jsonObject.put("VisitorProportion",0);
|
jsonObject.put("VisitorProportion", 0);
|
||||||
jsonObject.put("VisitorMemory", "无限");
|
jsonObject.put("VisitorMemory", "无限");
|
||||||
}else{
|
} else {
|
||||||
double sum = Double.valueOf(uploadConfig.getVisitormemory());
|
double sum = Double.valueOf(uploadConfig.getVisitormemory());
|
||||||
Double aDouble = Double.valueOf(String.format("%.2f", ((double) temp / sum) * 100));
|
Double aDouble = Double.valueOf(String.format("%.2f", ((double) temp / sum) * 100));
|
||||||
if(aDouble>=999){
|
if (aDouble >= 999) {
|
||||||
jsonObject.put("VisitorProportion",999);
|
jsonObject.put("VisitorProportion", 999);
|
||||||
}else{
|
} else {
|
||||||
jsonObject.put("VisitorProportion",aDouble);
|
jsonObject.put("VisitorProportion", aDouble);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -117,40 +122,40 @@ public class AdminController {
|
|||||||
@PostMapping(value = "/SpaceExpansion")
|
@PostMapping(value = "/SpaceExpansion")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg SpaceExpansion(@RequestParam(value = "data", defaultValue = "") String data) {
|
public Msg SpaceExpansion(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||||
final Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
final JSONObject jsonObject = JSONObject.parseObject(data);
|
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||||
Subject subject = SecurityUtils.getSubject();
|
Subject subject = SecurityUtils.getSubject();
|
||||||
User user = (User) subject.getPrincipal();
|
User user = (User) subject.getPrincipal();
|
||||||
user = userService.getUsers(user);
|
user = userService.getUsers(user);
|
||||||
if(user.getIsok()==0){
|
if (user.getIsok() == 0) {
|
||||||
msg.setCode("100403");
|
msg.setCode("100403");
|
||||||
msg.setInfo("你暂时无法使用此功能");
|
msg.setInfo("你暂时无法使用此功能");
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
if(null==user){
|
if (null == user) {
|
||||||
msg.setCode("100405");
|
msg.setCode("100405");
|
||||||
msg.setInfo("用户信息不存在");
|
msg.setInfo("用户信息不存在");
|
||||||
return msg;
|
return msg;
|
||||||
}else{
|
} else {
|
||||||
long sizes = 0;
|
long sizes = 0;
|
||||||
Code code = codeService.selectCodekey(jsonObject.getString("code"));
|
Code code = codeService.selectCodekey(jsonObject.getString("code"));
|
||||||
if(null==code){
|
if (null == code) {
|
||||||
msg.setCode("100404");
|
msg.setCode("100404");
|
||||||
msg.setInfo("扩容码不存在,请重新填写");
|
msg.setInfo("扩容码不存在,请重新填写");
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
Long userMemory = Long.valueOf(user.getMemory());
|
Long userMemory = Long.valueOf(user.getMemory());
|
||||||
sizes = Long.valueOf(code.getValue())+ userMemory;
|
sizes = Long.valueOf(code.getValue()) + userMemory;
|
||||||
User newMemoryUser = new User();
|
User newMemoryUser = new User();
|
||||||
newMemoryUser.setMemory(Long.toString(sizes));
|
newMemoryUser.setMemory(Long.toString(sizes));
|
||||||
newMemoryUser.setId(user.getId());
|
newMemoryUser.setId(user.getId());
|
||||||
userService.usersetmemory(newMemoryUser,jsonObject.getString("code"));
|
userService.usersetmemory(newMemoryUser, jsonObject.getString("code"));
|
||||||
msg.setInfo("你已成功扩容"+SetFiles.readableFileSize(sizes));
|
msg.setInfo("你已成功扩容" + SetFiles.readableFileSize(sizes));
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value={"/setImgFileName","/client/setImgFileName"})
|
@PostMapping(value = {"/setImgFileName", "/client/setImgFileName"})
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg setImgFileName(@RequestParam(value = "data", defaultValue = "") String data) {
|
public Msg setImgFileName(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
@@ -162,7 +167,7 @@ public class AdminController {
|
|||||||
images.setIdname(name.replaceAll(" ", ""));
|
images.setIdname(name.replaceAll(" ", ""));
|
||||||
images.setImgname(imgname);
|
images.setImgname(imgname);
|
||||||
imgService.setImg(images);
|
imgService.setImg(images);
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
msg.setCode("500");
|
msg.setCode("500");
|
||||||
}
|
}
|
||||||
@@ -173,18 +178,18 @@ public class AdminController {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg getRecently() {
|
public Msg getRecently() {
|
||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
final JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
try {
|
try {
|
||||||
Subject subject = SecurityUtils.getSubject();
|
Subject subject = SecurityUtils.getSubject();
|
||||||
User user = (User) subject.getPrincipal();
|
User user = (User) subject.getPrincipal();
|
||||||
user = userService.getUsers(user);
|
user = userService.getUsers(user);
|
||||||
if(user.getLevel()>1){
|
if (user.getLevel() > 1) {
|
||||||
jsonObject.put("RecentlyUser",imgService.RecentlyUser());
|
jsonObject.put("RecentlyUser", imgService.RecentlyUser());
|
||||||
jsonObject.put("RecentlyUploaded",imgService.RecentlyUploaded(user.getId()));
|
jsonObject.put("RecentlyUploaded", imgService.RecentlyUploaded(user.getId()));
|
||||||
}else{
|
} else {
|
||||||
jsonObject.put("RecentlyUploaded",imgService.RecentlyUploaded(user.getId()));
|
jsonObject.put("RecentlyUploaded", imgService.RecentlyUploaded(user.getId()));
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
msg.setInfo("系统内部错误");
|
msg.setInfo("系统内部错误");
|
||||||
msg.setCode("500");
|
msg.setCode("500");
|
||||||
@@ -198,7 +203,7 @@ public class AdminController {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg updateToken() {
|
public Msg updateToken() {
|
||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
try{
|
try {
|
||||||
Subject subject = SecurityUtils.getSubject();
|
Subject subject = SecurityUtils.getSubject();
|
||||||
User user = (User) subject.getPrincipal();
|
User user = (User) subject.getPrincipal();
|
||||||
User u = new User();
|
User u = new User();
|
||||||
@@ -208,63 +213,64 @@ public class AdminController {
|
|||||||
user.setToken(u.getToken());
|
user.setToken(u.getToken());
|
||||||
msg.setData(u.getToken());
|
msg.setData(u.getToken());
|
||||||
msg.setInfo("Token更新成功,即可生效");
|
msg.setInfo("Token更新成功,即可生效");
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
msg.setCode("500");
|
msg.setCode("500");
|
||||||
msg.setInfo("Token更新失败");
|
msg.setInfo("Token更新失败");
|
||||||
}
|
}
|
||||||
return msg;
|
return msg;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/getYyyy")
|
@PostMapping("/getYyyy")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg getYyyy(){
|
public Msg getYyyy() {
|
||||||
final Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
Subject subject = SecurityUtils.getSubject();
|
Subject subject = SecurityUtils.getSubject();
|
||||||
User u = (User) subject.getPrincipal();
|
User u = (User) subject.getPrincipal();
|
||||||
final JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
jsonObject.put("allYyyy",imgService.getyyyy(null));
|
jsonObject.put("allYyyy", imgService.getyyyy(null));
|
||||||
jsonObject.put("userYyyy",imgService.getyyyy(u.getId()));
|
jsonObject.put("userYyyy", imgService.getyyyy(u.getId()));
|
||||||
msg.setData(jsonObject);
|
msg.setData(jsonObject);
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/getChart")
|
@PostMapping("/getChart")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg getChart(@RequestParam(value = "data", defaultValue = "") String data){
|
public Msg getChart(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
JSONObject jsonObject = JSONObject.parseObject(data);
|
JSONObject jsonObject = JSONObject.parseObject(data);
|
||||||
String yyyy = jsonObject.getString("yyyy");
|
String yyyy = jsonObject.getString("yyyy");
|
||||||
Integer type = jsonObject.getInteger("type");
|
Integer type = jsonObject.getInteger("type");
|
||||||
Subject subject = SecurityUtils.getSubject();
|
Subject subject = SecurityUtils.getSubject();
|
||||||
User u = (User) subject.getPrincipal();
|
User u = (User) subject.getPrincipal();
|
||||||
List<Images> list =null;
|
List<Images> list = null;
|
||||||
if(u.getLevel()>1){
|
if (u.getLevel() > 1) {
|
||||||
if(type==2){
|
if (type == 2) {
|
||||||
Images images = new Images();
|
Images images = new Images();
|
||||||
images.setYyyy(yyyy);
|
images.setYyyy(yyyy);
|
||||||
list = imgService.countByM(images);
|
list = imgService.countByM(images);
|
||||||
}else{
|
} else {
|
||||||
Images images = new Images();
|
Images images = new Images();
|
||||||
images.setYyyy(yyyy);
|
images.setYyyy(yyyy);
|
||||||
images.setUserid(u.getId());
|
images.setUserid(u.getId());
|
||||||
list = imgService.countByM(images);
|
list = imgService.countByM(images);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
Images images = new Images();
|
Images images = new Images();
|
||||||
images.setYyyy(yyyy);
|
images.setYyyy(yyyy);
|
||||||
images.setUserid(u.getId());
|
images.setUserid(u.getId());
|
||||||
list = imgService.countByM(images);
|
list = imgService.countByM(images);
|
||||||
}
|
}
|
||||||
JSONArray json = JSONArray.parseArray("[{\"id\":1,\"monthNum\":\"一月\",\"countNum\":0},{\"id\":2,\"monthNum\":\"二月\",\"countNum\":0},{\"id\":3,\"monthNum\":\"三月\",\"countNum\":0},{\"id\":4,\"monthNum\":\"四月\",\"countNum\":0},{\"id\":5,\"monthNum\":\"五月\",\"countNum\":0},{\"id\":6,\"monthNum\":\"六月\",\"countNum\":0},{\"id\":7,\"monthNum\":\"七月\",\"countNum\":0},{\"id\":8,\"monthNum\":\"八月\",\"countNum\":0},{\"id\":9,\"monthNum\":\"九月\",\"countNum\":0},{\"id\":10,\"monthNum\":\"十月\",\"countNum\":0},{\"id\":11,\"monthNum\":\"十一月\",\"countNum\":0},{\"id\":12,\"monthNum\":\"十二月\",\"countNum\":0}]");
|
JSONArray json =
|
||||||
|
JSONArray.parseArray(
|
||||||
|
"[{\"id\":1,\"monthNum\":\"一月\",\"countNum\":0},{\"id\":2,\"monthNum\":\"二月\",\"countNum\":0},{\"id\":3,\"monthNum\":\"三月\",\"countNum\":0},{\"id\":4,\"monthNum\":\"四月\",\"countNum\":0},{\"id\":5,\"monthNum\":\"五月\",\"countNum\":0},{\"id\":6,\"monthNum\":\"六月\",\"countNum\":0},{\"id\":7,\"monthNum\":\"七月\",\"countNum\":0},{\"id\":8,\"monthNum\":\"八月\",\"countNum\":0},{\"id\":9,\"monthNum\":\"九月\",\"countNum\":0},{\"id\":10,\"monthNum\":\"十月\",\"countNum\":0},{\"id\":11,\"monthNum\":\"十一月\",\"countNum\":0},{\"id\":12,\"monthNum\":\"十二月\",\"countNum\":0}]");
|
||||||
JSONArray jsonArray = new JSONArray();
|
JSONArray jsonArray = new JSONArray();
|
||||||
for (int j = 0; j < list.size(); j++) {
|
for (int j = 0; j < list.size(); j++) {
|
||||||
for (int i = 0; i < json.size(); i++) {
|
for (int i = 0; i < json.size(); i++) {
|
||||||
JSONObject jobj = json.getJSONObject(i);
|
JSONObject jobj = json.getJSONObject(i);
|
||||||
if(jobj.getInteger("id")==list.get(j).getMonthNum()){
|
if (jobj.getInteger("id") == list.get(j).getMonthNum()) {
|
||||||
jobj.put("monthNum",getChinaes(list.get(j).getMonthNum()));
|
jobj.put("monthNum", getChinaes(list.get(j).getMonthNum()));
|
||||||
jobj.put("countNum",list.get(j).getCountNum());
|
jobj.put("countNum", list.get(j).getCountNum());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -272,7 +278,7 @@ public class AdminController {
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/getStorage")
|
@PostMapping("/getStorage")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg getStorage() {
|
public Msg getStorage() {
|
||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
@@ -281,7 +287,7 @@ public class AdminController {
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/getStorageName")
|
@PostMapping("/getStorageName")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg getStorageName() {
|
public Msg getStorageName() {
|
||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
@@ -290,7 +296,7 @@ public class AdminController {
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = {"/selectPhoto","/client/selectPhoto"})
|
@PostMapping(value = {"/selectPhoto", "/client/selectPhoto"})
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg selectPhoto(@RequestParam(value = "data", defaultValue = "") String data) {
|
public Msg selectPhoto(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
@@ -302,18 +308,20 @@ public class AdminController {
|
|||||||
Integer source = jsonObj.getInteger("source");
|
Integer source = jsonObj.getInteger("source");
|
||||||
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");
|
||||||
if(starttime!=null){
|
if (starttime != null) {
|
||||||
try {
|
try {
|
||||||
Date date1 = format.parse(starttime);
|
Date date1 = format.parse(starttime);
|
||||||
Date date2 = format.parse(stoptime==null?format.format(new Date()):stoptime);
|
Date date2 = format.parse(stoptime == null ? format.format(new Date()) : stoptime);
|
||||||
int compareTo = date1.compareTo(date2);
|
int compareTo = date1.compareTo(date2);
|
||||||
System.out.println(compareTo);
|
System.out.println(compareTo);
|
||||||
if(compareTo==1){
|
if (compareTo == 1) {
|
||||||
msg.setCode("110500");
|
msg.setCode("110500");
|
||||||
msg.setInfo("起始日期不能大于结束日期");
|
msg.setInfo("起始日期不能大于结束日期");
|
||||||
return msg;
|
return msg;
|
||||||
@@ -327,44 +335,49 @@ public class AdminController {
|
|||||||
}
|
}
|
||||||
Images img = new Images();
|
Images img = new Images();
|
||||||
PageHelper.startPage(pageNum, pageSize);
|
PageHelper.startPage(pageNum, pageSize);
|
||||||
if(violation){
|
if (violation) {
|
||||||
img.setViolation("true");
|
img.setViolation("true");
|
||||||
}
|
}
|
||||||
img.setStarttime(starttime);
|
img.setStarttime(starttime);
|
||||||
img.setStoptime(stoptime);
|
img.setStoptime(stoptime);
|
||||||
if(subject.hasRole("admin")){
|
if (subject.hasRole("admin")) {
|
||||||
img.setSource(source);
|
img.setSource(source);
|
||||||
if(selectUserType.equals("me")){
|
if (selectUserType.equals("me")) {
|
||||||
img.setUserid(user.getId());
|
img.setUserid(user.getId());
|
||||||
img.setUsername(null);
|
img.setUsername(null);
|
||||||
img.setSelecttype(null);
|
img.setSelecttype(null);
|
||||||
}else{
|
} else {
|
||||||
img.setUsername(username);
|
img.setUsername(username);
|
||||||
img.setSelecttype(selecttype);
|
img.setSelecttype(selecttype);
|
||||||
}
|
}
|
||||||
}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 = new PageResultBean<>(rolePageInfo.getTotal(), rolePageInfo.getList());
|
PageResultBean<Images> pageResultBean =
|
||||||
|
new PageResultBean<>(rolePageInfo.getTotal(), rolePageInfo.getList());
|
||||||
msg.setData(pageResultBean);
|
msg.setData(pageResultBean);
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/getUserInfo")
|
@PostMapping(value = "/getUserInfo")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg getUserInfo() {
|
public Msg getUserInfo() {
|
||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
try {
|
try {
|
||||||
Subject subject = SecurityUtils.getSubject();
|
Subject subject = SecurityUtils.getSubject();
|
||||||
User user = (User) subject.getPrincipal();
|
User user = (User) subject.getPrincipal();
|
||||||
final User u = new User();
|
User u = new User();
|
||||||
u.setId(user.getId());
|
u.setId(user.getId());
|
||||||
User userInfo = userService.getUsers(u);
|
User userInfo = userService.getUsers(u);
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
jsonObject.put("username",userInfo.getUsername());
|
jsonObject.put("username", userInfo.getUsername());
|
||||||
jsonObject.put("email",userInfo.getEmail());
|
jsonObject.put("email", userInfo.getEmail());
|
||||||
msg.setData(jsonObject);
|
msg.setData(jsonObject);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -374,7 +387,7 @@ public class AdminController {
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/setUserInfo")
|
@PostMapping("/setUserInfo")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg setUserInfo(@RequestParam(value = "data", defaultValue = "") String data) {
|
public Msg setUserInfo(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
@@ -386,45 +399,52 @@ public class AdminController {
|
|||||||
Subject subject = SecurityUtils.getSubject();
|
Subject subject = SecurityUtils.getSubject();
|
||||||
User u = (User) subject.getPrincipal();
|
User u = (User) subject.getPrincipal();
|
||||||
User user = new User();
|
User user = new User();
|
||||||
if(!SetText.checkEmail(email)){
|
if (!SetText.checkEmail(email)) {
|
||||||
msg.setCode("110403");
|
msg.setCode("110403");
|
||||||
msg.setInfo("邮箱格式不正确");
|
msg.setInfo("邮箱格式不正确");
|
||||||
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;
|
return msg;
|
||||||
}
|
}
|
||||||
if(subject.hasRole("admin")){
|
if(!username.matches (regex)){
|
||||||
final User userOld = new User();
|
//用户名格式不正确
|
||||||
|
msg.setCode("110403");
|
||||||
|
msg.setInfo("用户名不得含有特殊字符");
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
if (subject.hasRole("admin")) {
|
||||||
|
User userOld = new User();
|
||||||
userOld.setId(u.getId());
|
userOld.setId(u.getId());
|
||||||
User userInfo = userService.getUsers(userOld);
|
User userInfo = userService.getUsers(userOld);
|
||||||
if(!userInfo.getUsername().equals(username)){
|
if (!userInfo.getUsername().equals(username)) {
|
||||||
Integer countusername = userService.countusername(username);
|
Integer countusername = userService.countusername(username);
|
||||||
if(countusername == 1 || !SysName.CheckSysName(username)){
|
if (countusername == 1 || !SysName.CheckSysName(username)) {
|
||||||
msg.setCode("110406");
|
msg.setCode("110406");
|
||||||
msg.setInfo("此用户名已存在");
|
msg.setInfo("此用户名已存在");
|
||||||
return msg;
|
return msg;
|
||||||
}else {
|
} else {
|
||||||
user.setUsername(username);
|
user.setUsername(username);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(!userInfo.getEmail().equals(email)){
|
if (!userInfo.getEmail().equals(email)) {
|
||||||
Integer countmail = userService.countmail(email);
|
Integer countmail = userService.countmail(email);
|
||||||
if(countmail == 1){
|
if (countmail == 1) {
|
||||||
msg.setCode("110407");
|
msg.setCode("110407");
|
||||||
msg.setInfo("此邮箱已被注册");
|
msg.setInfo("此邮箱已被注册");
|
||||||
return msg;
|
return msg;
|
||||||
}else{
|
} else {
|
||||||
user.setEmail(email);
|
user.setEmail(email);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
user.setPassword(Base64Encryption.encryptBASE64(password.getBytes()));
|
|
||||||
|
user.setPassword(Base64.getEncoder().encodeToString(password.getBytes()));
|
||||||
user.setUid(u.getUid());
|
user.setUid(u.getUid());
|
||||||
}else{
|
} else {
|
||||||
user.setPassword(Base64Encryption.encryptBASE64(password.getBytes()));
|
user.setPassword(Base64.getEncoder().encodeToString(password.getBytes()));
|
||||||
user.setUid(u.getUid());
|
user.setUid(u.getUid());
|
||||||
}
|
}
|
||||||
userService.change(user);
|
userService.change(user);
|
||||||
@@ -437,121 +457,134 @@ public class AdminController {
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping({"/deleImages","/client/deleImages"})
|
@PostMapping({"/deleImages", "/client/deleImages"})
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg deleImages(HttpSession httpSession, @RequestParam(value = "data", defaultValue = "") String data) {
|
public Msg deleImages(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||||
final String images = jsonObj.getString("images");
|
String images = jsonObj.getString("images");
|
||||||
if(images==null){
|
String uuid = jsonObj.getString("uuid");
|
||||||
|
Boolean forceDel = jsonObj.getBoolean("forceDel")==null?false:jsonObj.getBoolean("forceDel");
|
||||||
|
if (images == null) {
|
||||||
msg.setCode("404");
|
msg.setCode("404");
|
||||||
msg.setInfo("为获取到图像信息");
|
msg.setInfo("为获取到图像信息");
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
final String[] split = images.split(",");
|
String[] split = images.split(",");
|
||||||
Subject subject = SecurityUtils.getSubject();
|
Subject subject = SecurityUtils.getSubject();
|
||||||
User user = (User) subject.getPrincipal();
|
User user = (User) subject.getPrincipal();
|
||||||
if(null == user){
|
if (null == user) {
|
||||||
msg.setCode("500");
|
msg.setCode("500");
|
||||||
msg.setInfo("当前用户信息不存在");
|
msg.setInfo("当前用户信息不存在");
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
if(split.length==0){
|
if (split.length == 0) {
|
||||||
msg.setCode("404");
|
msg.setCode("404");
|
||||||
msg.setInfo("为获取到图像信息");
|
msg.setInfo("为获取到图像信息");
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
List<Integer> imgIds = new ArrayList<Integer>();
|
List<Long> imgIds = new ArrayList<Long>();
|
||||||
for (int i = 0; i < split.length; i++) {
|
for (int i = 0; i < split.length; i++) {
|
||||||
Integer imgid = Integer.valueOf(split[i]);
|
Long imgid = Long.valueOf(split[i]);
|
||||||
Images image = imgService.selectByPrimaryKey(imgid);
|
Images image = imgService.selectByPrimaryKey(imgid);
|
||||||
if(!subject.hasRole("admin")){
|
if (!subject.hasRole("admin")) {
|
||||||
if(!image.getUserid().equals(user.getId())){
|
if (!image.getUserid().equals(user.getId())) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
imgIds.add(imgid);
|
imgIds.add(imgid);
|
||||||
}
|
}
|
||||||
if(imgIds.size()==0){
|
if (imgIds.size() == 0) {
|
||||||
msg.setCode("110404");
|
msg.setCode("110404");
|
||||||
}else{
|
} else {
|
||||||
deleimages.dele(httpSession,imgIds.stream().toArray(Integer[]::new));
|
deleimages.dele(forceDel,uuid, imgIds.stream().toArray(Long[]::new));
|
||||||
msg.setCode("200");
|
msg.setCode("200");
|
||||||
}
|
}
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping({"/GetDelprogress","/client/GetDelprogress"})
|
@PostMapping({"/GetDelprogress", "/client/GetDelprogress"})
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg GetDelprogress(HttpSession httpSession) {
|
public Msg GetDelprogress(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||||
Msg msg =new Msg();
|
Msg msg = new Msg();
|
||||||
JSONObject jsonObject = new JSONObject();
|
try {
|
||||||
MyProgress myProgress = (MyProgress)httpSession.getAttribute("myProgressForDel");
|
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||||
if(null==myProgress){
|
String uuid = jsonObj.getString("uuid");
|
||||||
jsonObject.put("succ",myProgress.getDelSuccessCount());
|
JSONObject jsonObject = new JSONObject();
|
||||||
jsonObject.put("errorlist",new ArrayList<String>());
|
MyProgress myProgress = null;
|
||||||
jsonObject.put("oklist",new ArrayList<Long>());
|
try{
|
||||||
jsonObject.put("delover",false);
|
myProgress = JSON.parseObject(iRedisService.getValue(uuid).toString(), MyProgress.class);
|
||||||
}else{
|
}catch (Exception e){ }
|
||||||
jsonObject.put("succ",myProgress.getDelSuccessCount());
|
|
||||||
jsonObject.put("errorlist",myProgress.getDelErrorImgListt());
|
|
||||||
jsonObject.put("oklist",myProgress.getDelSuccessImgList());
|
|
||||||
jsonObject.put("delover",myProgress.getDelOCT());
|
|
||||||
}
|
|
||||||
msg.setData(jsonObject);
|
|
||||||
if(myProgress.getDelOCT()){
|
|
||||||
System.out.println("循环遍历的值:"+myProgress.getDelOCT());
|
|
||||||
msg.setCode("100");
|
|
||||||
}else{
|
|
||||||
msg.setCode("110666");
|
msg.setCode("110666");
|
||||||
msg.setInfo("正在执行");
|
msg.setInfo("正在执行");
|
||||||
|
if (null == myProgress) {
|
||||||
|
jsonObject.put("succ", 0);
|
||||||
|
jsonObject.put("errorlist", new ArrayList<String>());
|
||||||
|
jsonObject.put("oklist", new ArrayList<Long>());
|
||||||
|
jsonObject.put("delover", false);
|
||||||
|
} else {
|
||||||
|
jsonObject.put("succ", myProgress.getDelSuccessCount());
|
||||||
|
jsonObject.put("errorlist", myProgress.getDelErrorImgListt());
|
||||||
|
jsonObject.put("oklist", myProgress.getDelSuccessImgList());
|
||||||
|
jsonObject.put("delover", myProgress.getDelOCT());
|
||||||
|
if(myProgress.getDelOCT()==1){
|
||||||
|
System.out.println("循环遍历的值:"+myProgress.getDelOCT());
|
||||||
|
msg.setCode("100");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
msg.setData(jsonObject);
|
||||||
|
return msg;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
msg.setCode("110500");
|
||||||
|
msg.setInfo("正在执行过程中发生错误");
|
||||||
|
return msg;
|
||||||
}
|
}
|
||||||
return msg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getChinaes(int v){
|
private static String getChinaes(int v) {
|
||||||
String ch = "";
|
String ch = "";
|
||||||
switch(v){
|
switch (v) {
|
||||||
case 1 :
|
case 1:
|
||||||
ch = "一月";
|
ch = "一月";
|
||||||
break; //可选
|
break; // 可选
|
||||||
case 2 :
|
case 2:
|
||||||
ch = "二月";
|
ch = "二月";
|
||||||
break; //可选
|
break; // 可选
|
||||||
case 3 :
|
case 3:
|
||||||
ch = "三月";
|
ch = "三月";
|
||||||
break; //可选
|
break; // 可选
|
||||||
case 4 :
|
case 4:
|
||||||
ch = "四月";
|
ch = "四月";
|
||||||
break; //可选
|
break; // 可选
|
||||||
case 5 :
|
case 5:
|
||||||
ch = "五月";
|
ch = "五月";
|
||||||
break; //可选
|
break; // 可选
|
||||||
case 6 :
|
case 6:
|
||||||
ch = "六月";
|
ch = "六月";
|
||||||
break; //可选
|
break; // 可选
|
||||||
case 7 :
|
case 7:
|
||||||
ch = "七月";
|
ch = "七月";
|
||||||
break; //可选
|
break; // 可选
|
||||||
case 8 :
|
case 8:
|
||||||
ch = "八月";
|
ch = "八月";
|
||||||
break; //可选
|
break; // 可选
|
||||||
case 9 :
|
case 9:
|
||||||
ch = "九月";
|
ch = "九月";
|
||||||
break; //可选
|
break; // 可选
|
||||||
case 10 :
|
case 10:
|
||||||
ch = "十月";
|
ch = "十月";
|
||||||
break; //可选
|
break; // 可选
|
||||||
case 11 :
|
case 11:
|
||||||
ch = "十一月";
|
ch = "十一月";
|
||||||
break; //可选
|
break; // 可选
|
||||||
case 12 :
|
case 12:
|
||||||
ch = "十二月";
|
ch = "十二月";
|
||||||
break; //可选
|
break; // 可选
|
||||||
default : ch = "";//可选
|
default:
|
||||||
//语句
|
ch = ""; // 可选
|
||||||
|
// 语句
|
||||||
}
|
}
|
||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,13 +21,16 @@ 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
|
||||||
@RequestMapping("/admin/root")
|
@RequestMapping("/admin/root")
|
||||||
public class AdminRootController {
|
public class AdminRootController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ConfigService configService;
|
private ConfdataService confdataService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private KeysService keysService;
|
private KeysService keysService;
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -42,6 +47,22 @@ public class AdminRootController {
|
|||||||
private ImgreviewService imgreviewService;
|
private ImgreviewService imgreviewService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private AppClientService appClientService;
|
private AppClientService appClientService;
|
||||||
|
@Autowired
|
||||||
|
private NOSImageupload nOSImageupload;
|
||||||
|
@Autowired
|
||||||
|
private OSSImageupload ossImageupload;
|
||||||
|
@Autowired
|
||||||
|
private USSImageupload ussImageupload;
|
||||||
|
@Autowired
|
||||||
|
private KODOImageupload kodoImageupload;
|
||||||
|
@Autowired
|
||||||
|
private COSImageupload cosImageupload;
|
||||||
|
@Autowired
|
||||||
|
private FtpServiceImpl ftpService;
|
||||||
|
@Autowired
|
||||||
|
private S3Imageupload s3Imageupload;
|
||||||
|
@Autowired
|
||||||
|
private WebDAVImageupload webDAVImageupload;
|
||||||
|
|
||||||
|
|
||||||
@PostMapping(value = "/getUserList")
|
@PostMapping(value = "/getUserList")
|
||||||
@@ -184,19 +205,21 @@ public class AdminRootController {
|
|||||||
Keys key = keysService.selectKeys(keyId);
|
Keys key = keysService.selectKeys(keyId);
|
||||||
Integer ret = 0;
|
Integer ret = 0;
|
||||||
if (key.getStorageType() == 1) {
|
if (key.getStorageType() == 1) {
|
||||||
ret = NOSImageupload.Initialize(key);
|
ret = nOSImageupload.Initialize(key);
|
||||||
} else if (key.getStorageType() == 2) {
|
} else if (key.getStorageType() == 2) {
|
||||||
ret = OSSImageupload.Initialize(key);
|
ret = ossImageupload.Initialize(key);
|
||||||
} else if (key.getStorageType() == 3) {
|
} else if (key.getStorageType() == 3) {
|
||||||
ret = USSImageupload.Initialize(key);
|
ret = ussImageupload.Initialize(key);
|
||||||
} else if (key.getStorageType() == 4) {
|
} else if (key.getStorageType() == 4) {
|
||||||
ret = KODOImageupload.Initialize(key);
|
ret = kodoImageupload.Initialize(key);
|
||||||
} else if (key.getStorageType() == 6) {
|
} else if (key.getStorageType() == 6) {
|
||||||
ret = COSImageupload.Initialize(key);
|
ret = cosImageupload.Initialize(key);
|
||||||
} else if (key.getStorageType() == 7) {
|
} else if (key.getStorageType() == 7) {
|
||||||
ret = FTPImageupload.Initialize(key);
|
ret = ftpService.Initialize(key);
|
||||||
} else if (key.getStorageType() == 8) {
|
} else if (key.getStorageType() == 8) {
|
||||||
ret = UFileImageupload.Initialize(key);
|
ret = s3Imageupload.Initialize(key);
|
||||||
|
}else if (key.getStorageType() == 9) {
|
||||||
|
ret = webDAVImageupload.Initialize(key);
|
||||||
}
|
}
|
||||||
Long l = imgService.getsourcememory(keyId);
|
Long l = imgService.getsourcememory(keyId);
|
||||||
jsonObject.put("isok", ret);
|
jsonObject.put("isok", ret);
|
||||||
@@ -219,23 +242,7 @@ public class AdminRootController {
|
|||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg updateStorage(@RequestParam(value = "data", defaultValue = "") String data) {
|
public Msg updateStorage(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||||
Integer id = jsonObj.getInteger("id");
|
Keys keys = JSON.toJavaObject(jsonObj,Keys.class);
|
||||||
String AccessKey = jsonObj.getString("AccessKey");
|
|
||||||
String AccessSecret = jsonObj.getString("AccessSecret");
|
|
||||||
String Endpoint = jsonObj.getString("Endpoint");
|
|
||||||
String Bucketname = jsonObj.getString("Bucketname");
|
|
||||||
String RequestAddress = jsonObj.getString("RequestAddress");
|
|
||||||
Integer storageType = jsonObj.getInteger("storageType");
|
|
||||||
String keyname = jsonObj.getString("keyname");
|
|
||||||
Keys keys = new Keys();
|
|
||||||
keys.setId(id);
|
|
||||||
keys.setAccessKey(AccessKey);
|
|
||||||
keys.setAccessSecret(AccessSecret);
|
|
||||||
keys.setEndpoint(Endpoint);
|
|
||||||
keys.setBucketname(Bucketname);
|
|
||||||
keys.setRequestAddress(RequestAddress);
|
|
||||||
keys.setStorageType(storageType);
|
|
||||||
keys.setKeyname(keyname);
|
|
||||||
Msg msg = keysService.updateKey(keys);
|
Msg msg = keysService.updateKey(keys);
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
@@ -260,7 +267,7 @@ public class AdminRootController {
|
|||||||
User u = (User) subject.getPrincipal();
|
User u = (User) subject.getPrincipal();
|
||||||
try {
|
try {
|
||||||
UploadConfig uploadConfig = uploadConfigService.getUpdateConfig();
|
UploadConfig uploadConfig = uploadConfigService.getUpdateConfig();
|
||||||
Config config = configService.getSourceype();
|
final Confdata confdata = confdataService.selectConfdata("config");
|
||||||
SysConfig sysConfig = sysConfigService.getstate();
|
SysConfig sysConfig = sysConfigService.getstate();
|
||||||
AppClient appClientData = appClientService.getAppClientData("app");
|
AppClient appClientData = appClientService.getAppClientData("app");
|
||||||
uploadConfig.setUsermemory(Long.toString(Long.valueOf(uploadConfig.getUsermemory()) / 1024 / 1024));
|
uploadConfig.setUsermemory(Long.toString(Long.valueOf(uploadConfig.getUsermemory()) / 1024 / 1024));
|
||||||
@@ -268,7 +275,7 @@ public class AdminRootController {
|
|||||||
uploadConfig.setFilesizetourists(Long.toString(Long.valueOf(uploadConfig.getFilesizetourists()) / 1024 / 1024));
|
uploadConfig.setFilesizetourists(Long.toString(Long.valueOf(uploadConfig.getFilesizetourists()) / 1024 / 1024));
|
||||||
uploadConfig.setFilesizeuser(Long.toString(Long.valueOf(uploadConfig.getFilesizeuser()) / 1024 / 1024));
|
uploadConfig.setFilesizeuser(Long.toString(Long.valueOf(uploadConfig.getFilesizeuser()) / 1024 / 1024));
|
||||||
jsonObject.put("uploadConfig", uploadConfig);
|
jsonObject.put("uploadConfig", uploadConfig);
|
||||||
jsonObject.put("config", config);
|
jsonObject.put("config", JSONObject.parseObject(confdata.getJsondata()));
|
||||||
jsonObject.put("sysConfig", sysConfig);
|
jsonObject.put("sysConfig", sysConfig);
|
||||||
jsonObject.put("appClient", appClientData);
|
jsonObject.put("appClient", appClientData);
|
||||||
msg.setData(jsonObject);
|
msg.setData(jsonObject);
|
||||||
@@ -296,7 +303,7 @@ public class AdminRootController {
|
|||||||
msg.setCode("500");
|
msg.setCode("500");
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
Config config = JSON.toJavaObject((JSON) jsonObject.get("config"), Config.class);
|
// Config config = JSON.toJavaObject((JSON) jsonObject.get("config"), Config.class);
|
||||||
SysConfig sysConfig = JSON.toJavaObject((JSON) jsonObject.get("sysConfig"), SysConfig.class);
|
SysConfig sysConfig = JSON.toJavaObject((JSON) jsonObject.get("sysConfig"), SysConfig.class);
|
||||||
AppClient appClient = JSON.toJavaObject((JSON) jsonObject.get("appClient"), AppClient.class);
|
AppClient appClient = JSON.toJavaObject((JSON) jsonObject.get("appClient"), AppClient.class);
|
||||||
if (Integer.valueOf(vm) == -1) {
|
if (Integer.valueOf(vm) == -1) {
|
||||||
@@ -308,7 +315,10 @@ public class AdminRootController {
|
|||||||
uploadConfig.setUsermemory(Long.toString(Long.valueOf(uploadConfig.getUsermemory()) * 1024 * 1024));
|
uploadConfig.setUsermemory(Long.toString(Long.valueOf(uploadConfig.getUsermemory()) * 1024 * 1024));
|
||||||
uploadConfig.setFilesizeuser(Long.toString(Long.valueOf(uploadConfig.getFilesizeuser()) * 1024 * 1024));
|
uploadConfig.setFilesizeuser(Long.toString(Long.valueOf(uploadConfig.getFilesizeuser()) * 1024 * 1024));
|
||||||
uploadConfigService.setUpdateConfig(uploadConfig);
|
uploadConfigService.setUpdateConfig(uploadConfig);
|
||||||
configService.setSourceype(config);
|
Confdata confdata = new Confdata();
|
||||||
|
confdata.setKey("config");
|
||||||
|
confdata.setJsondata(jsonObject.getJSONObject("config").toJSONString());
|
||||||
|
confdataService.updateConfdata(confdata);
|
||||||
sysConfigService.setstate(sysConfig);
|
sysConfigService.setstate(sysConfig);
|
||||||
if (!appClient.getIsuse().equals("on")) {
|
if (!appClient.getIsuse().equals("on")) {
|
||||||
appClient.setIsuse("off");
|
appClient.setIsuse("off");
|
||||||
@@ -388,5 +398,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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,7 +97,8 @@ public class AlbumController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/admin/getAlbumListForKey")
|
//后台列表要修改时的查询表单
|
||||||
|
@PostMapping("/admin/getAlbumListForKey")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg getAlbumListForKey(@RequestParam(value = "data", defaultValue = "") String data){
|
public Msg getAlbumListForKey(@RequestParam(value = "data", defaultValue = "") String data){
|
||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
@@ -213,6 +214,8 @@ public class AlbumController {
|
|||||||
String password = jsonObject.getString("password");
|
String password = jsonObject.getString("password");
|
||||||
JSONArray jsonArray = JSONArray.parseArray(jsonObject.getString("albumlist"));
|
JSONArray jsonArray = JSONArray.parseArray(jsonObject.getString("albumlist"));
|
||||||
if(null!=password){
|
if(null!=password){
|
||||||
|
// String regex = "^[a-z0-9A-Z\u4e00-\u9fa5]+$";
|
||||||
|
// return str.matches(regex);
|
||||||
password = password.replace(" ", "");
|
password = password.replace(" ", "");
|
||||||
if(password.replace(" ", "").equals("") || password.length()<3){
|
if(password.replace(" ", "").equals("") || password.length()<3){
|
||||||
msg.setCode("110403");
|
msg.setCode("110403");
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -85,17 +88,40 @@ public class ClientAppController {
|
|||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/imgUploading")
|
@PostMapping("/imgUpload")
|
||||||
public Msg imgUploading(@RequestParam(required = true, value = "data") String data, HttpServletRequest request) {
|
public Msg imgUpload(HttpServletRequest request, @RequestParam(required = true, value = "file") MultipartFile multipartFile,
|
||||||
|
@RequestParam(required = true, value = "days") String days) {
|
||||||
|
Msg msg = new Msg();
|
||||||
|
try{
|
||||||
|
if (null != multipartFile) {
|
||||||
|
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{
|
||||||
|
msg.setCode("500");
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
msg.setCode("500");
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/imgUploadForCopy")
|
||||||
|
public Msg imgUploadForCopy(@RequestParam(required = true, value = "data") String data, HttpServletRequest request) {
|
||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
try{
|
try{
|
||||||
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 imgclass = jsonObj.getString("imgclass");
|
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();
|
||||||
|
|||||||
@@ -2,11 +2,9 @@ package cn.hellohao.controller;
|
|||||||
|
|
||||||
import cn.hellohao.pojo.Msg;
|
import cn.hellohao.pojo.Msg;
|
||||||
import cn.hellohao.service.impl.ClientService;
|
import cn.hellohao.service.impl.ClientService;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
@@ -17,18 +15,30 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
* @date 2019-07-18 17:22
|
* @date 2019-07-18 17:22
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
|
@RequestMapping("/api")
|
||||||
public class ClientController {
|
public class ClientController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired private ClientService clientService;
|
||||||
private ClientService clientService;
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping(value = "/uploadbymail")
|
@PostMapping(value = "/uploadbymail")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg uploadbymail(HttpServletRequest request, @RequestParam("file") MultipartFile file, String mail, String pass) {
|
public Msg uploadbymail(
|
||||||
Msg resultBean = clientService.uploadImg(request, file, mail, pass);
|
HttpServletRequest request,
|
||||||
|
@RequestParam(value = "file") MultipartFile file,
|
||||||
|
@RequestParam(value = "mail", defaultValue = "") String mail,
|
||||||
|
@RequestParam(value = "pass", defaultValue = "") String pass,
|
||||||
|
@RequestParam(value = "days", defaultValue = "0") String days) {
|
||||||
|
if (file == null
|
||||||
|
|| StringUtils.isBlank(mail)
|
||||||
|
|| StringUtils.isBlank(pass)) {
|
||||||
|
Msg msg = new Msg();
|
||||||
|
msg.setCode("400");
|
||||||
|
msg.setInfo("相关参数不能为空");
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
Msg resultBean =
|
||||||
|
clientService.uploadImg(
|
||||||
|
request, file, mail, pass, Integer.valueOf(days.toString()));
|
||||||
return resultBean;
|
return resultBean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ public class ExceptionHandling {
|
|||||||
ModelAndView modelAndView = new ModelAndView("index");
|
ModelAndView modelAndView = new ModelAndView("index");
|
||||||
Print.Normal("异常拦截成功:"+ ssie.getMessage());
|
Print.Normal("异常拦截成功:"+ ssie.getMessage());
|
||||||
modelAndView.addObject("error",ssie.getMessage());
|
modelAndView.addObject("error",ssie.getMessage());
|
||||||
|
//返回错误信息,并显示给用户
|
||||||
return modelAndView;
|
return modelAndView;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
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.AlbumServiceImpl;
|
|
||||||
import cn.hellohao.service.impl.UploadServicel;
|
import cn.hellohao.service.impl.UploadServicel;
|
||||||
|
import cn.hellohao.service.impl.WebDAVImageupload;
|
||||||
import cn.hellohao.service.impl.deleImages;
|
import cn.hellohao.service.impl.deleImages;
|
||||||
|
import cn.hellohao.utils.GetIPS;
|
||||||
import cn.hellohao.utils.MyVersion;
|
import cn.hellohao.utils.MyVersion;
|
||||||
import cn.hellohao.utils.verifyCode.IVerifyCodeGen;
|
import cn.hellohao.utils.SetFiles;
|
||||||
import cn.hellohao.utils.verifyCode.SimpleCharVerifyCodeGenImpl;
|
|
||||||
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,88 +20,149 @@ 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.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.core.io.InputStreamResource;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.ui.Model;
|
||||||
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 javax.servlet.http.HttpServletResponse;
|
import java.io.File;
|
||||||
import javax.servlet.http.HttpSession;
|
|
||||||
import java.io.IOException;
|
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.Timer;
|
import java.util.UUID;
|
||||||
import java.util.TimerTask;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class IndexController {
|
public class IndexController {
|
||||||
@Autowired
|
@Autowired private ImgService imgService;
|
||||||
private ImgService imgService;
|
@Autowired private SysConfigService sysConfigService;
|
||||||
@Autowired
|
@Autowired private ConfdataService confdataService;
|
||||||
private SysConfigService sysConfigService;
|
@Autowired private UploadConfigService uploadConfigService;
|
||||||
@Autowired
|
@Autowired private UploadServicel uploadServicel;
|
||||||
private ConfigService configService;
|
@Autowired private deleImages deleimages;
|
||||||
@Autowired
|
@Autowired private IRedisService iRedisService;
|
||||||
private UploadConfigService uploadConfigService;
|
@Autowired private AppClientService appClientService;
|
||||||
@Autowired
|
@Autowired private WebDAVImageupload webDAVImageupload;
|
||||||
private UploadServicel uploadServicel;
|
public static String version = "20240319";
|
||||||
@Autowired
|
@RequestMapping(value = "/")
|
||||||
private deleImages deleimages;
|
public String Welcome(Model model, HttpServletRequest httpServletRequest) {
|
||||||
@Autowired
|
model.addAttribute("name", "服务端程序(开源版)");
|
||||||
AlbumServiceImpl albumService;
|
model.addAttribute("version", version);
|
||||||
@Autowired
|
model.addAttribute("ip", GetIPS.getIpAddr(httpServletRequest));
|
||||||
AppClientService appClientService;
|
model.addAttribute("links", "https://github.com/Hello-hao/tbed");
|
||||||
|
return "welcome";
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/webInfo")
|
@RequestMapping(value = "/webInfo")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg webInfo() {
|
public Msg webInfo() {
|
||||||
final Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
Config config = configService.getSourceype();
|
final Confdata confdata = confdataService.selectConfdata("config");
|
||||||
|
JSONObject cd = JSONObject.parseObject(confdata.getJsondata());
|
||||||
UploadConfig updateConfig = uploadConfigService.getUpdateConfig();
|
UploadConfig updateConfig = uploadConfigService.getUpdateConfig();
|
||||||
SysConfig sysConfig = sysConfigService.getstate();
|
SysConfig sysConfig = sysConfigService.getstate();
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
AppClient appClient = appClientService.getAppClientData("app");
|
AppClient appClient = appClientService.getAppClientData("app");
|
||||||
jsonObject.put("webname",config.getWebname());
|
jsonObject.put("webname", cd.getString("webname"));
|
||||||
jsonObject.put("websubtitle",config.getWebsubtitle());
|
jsonObject.put("systype","free");
|
||||||
jsonObject.put("keywords",config.getWebkeywords());
|
jsonObject.put("version",version);
|
||||||
jsonObject.put("description",config.getWebms());
|
jsonObject.put("websubtitle", cd.getString("websubtitle"));
|
||||||
jsonObject.put("explain",config.getExplain());
|
jsonObject.put("keywords", cd.getString("keywords"));
|
||||||
jsonObject.put("favicon",config.getWebfavicons());
|
jsonObject.put("webms", cd.getString("webms"));
|
||||||
jsonObject.put("baidu",config.getBaidu());
|
jsonObject.put("explain", cd.getString("explain"));
|
||||||
jsonObject.put("links",config.getLinks());
|
jsonObject.put("baidu", cd.getString("baidu"));
|
||||||
jsonObject.put("aboutinfo",config.getAboutinfo());
|
jsonObject.put("links", cd.getString("links"));
|
||||||
jsonObject.put("logo",config.getLogo());
|
jsonObject.put("aboutinfo", cd.getString("aboutinfo"));
|
||||||
jsonObject.put("api",updateConfig.getApi());
|
jsonObject.put("logo", cd.getString("logo"));
|
||||||
jsonObject.put("register",sysConfig.getRegister());
|
jsonObject.put("webfavicons", cd.getString("webfavicons"));
|
||||||
jsonObject.put("isuse",appClient.getIsuse());
|
jsonObject.put("api", updateConfig.getApi());
|
||||||
jsonObject.put("clientname",appClient.getAppname());
|
jsonObject.put("register", sysConfig.getRegister());
|
||||||
jsonObject.put("clientlogo",appClient.getApplogo());
|
jsonObject.put("isuse", appClient.getIsuse());
|
||||||
jsonObject.put("appupdate",appClient.getAppupdate());
|
jsonObject.put("clientname", appClient.getAppname());
|
||||||
|
jsonObject.put("clientlogo", appClient.getApplogo());
|
||||||
|
jsonObject.put("appupdate", appClient.getAppupdate());
|
||||||
|
jsonObject.put("serverVersion",version);
|
||||||
msg.setData(jsonObject);
|
msg.setData(jsonObject);
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
@PostMapping(value = {"/uploadChunkFile","/client/uploadChunkFile"})
|
||||||
@PostMapping(value = {"/upload","/client/upload"})
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg upimg(HttpServletRequest request, @RequestParam(value = "file", required = false) MultipartFile multipartFile,Integer day) {
|
@CrossOrigin
|
||||||
return uploadServicel.uploadForLoc(request,multipartFile,day,null);
|
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(value = {"/uploadForUrl","/client/uploadForUrl"})
|
@PostMapping(value = {"/processFile","/client/processFile"})
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg upurlimg(HttpServletRequest request,@RequestParam(value = "data", defaultValue = "") String data) {
|
@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"})
|
||||||
|
@ResponseBody
|
||||||
|
public Msg upimg(
|
||||||
|
HttpServletRequest request,
|
||||||
|
@RequestParam(value = "file", required = false) MultipartFile multipartFile,
|
||||||
|
Integer day,@RequestParam(value = "md5",required = false) String md5) {
|
||||||
|
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"})
|
||||||
|
@ResponseBody
|
||||||
|
public Msg upurlimg(
|
||||||
|
HttpServletRequest request, @RequestParam(value = "data", defaultValue = "") String data) {
|
||||||
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();
|
||||||
User user = (User) subject.getPrincipal();
|
User user = (User) subject.getPrincipal();
|
||||||
UploadConfig updateConfig = uploadConfigService.getUpdateConfig();
|
UploadConfig updateConfig = uploadConfigService.getUpdateConfig();
|
||||||
int syscounts = 0;
|
int syscounts = 0;
|
||||||
if(null==user){
|
if (null == user) {
|
||||||
syscounts = updateConfig.getImgcounttourists();
|
syscounts = updateConfig.getImgcounttourists();
|
||||||
}else{
|
} else {
|
||||||
syscounts = updateConfig.getImgcountuser();
|
syscounts = updateConfig.getImgcountuser();
|
||||||
}
|
}
|
||||||
Msg retMsg = new Msg();
|
Msg retMsg = new Msg();
|
||||||
@@ -109,26 +171,37 @@ public class IndexController {
|
|||||||
int errcounts = 0;
|
int errcounts = 0;
|
||||||
int excess = 0;
|
int excess = 0;
|
||||||
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();
|
||||||
if(!msg.getCode().equals("200")){
|
imgJson.put("imgUrl",URLArr[i]);
|
||||||
|
imgJson.put("referer",referer);
|
||||||
|
Msg msg = uploadServicel.uploadForLoc(request, null,"URL转存图像", setday, imgJson,null);
|
||||||
|
if (!msg.getCode().equals("200")) {
|
||||||
errcounts++;
|
errcounts++;
|
||||||
}else{
|
} else {
|
||||||
retArray.add(msg);
|
retArray.add(msg);
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
excess++;
|
excess++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
jsonObject.put("counts",URLArr.length);
|
jsonObject.put("counts", URLArr.length);
|
||||||
jsonObject.put("errcounts",errcounts);
|
jsonObject.put("errcounts", errcounts);
|
||||||
jsonObject.put("excess",excess);
|
jsonObject.put("excess", excess);
|
||||||
jsonObject.put("urls",retArray);
|
jsonObject.put("urls", retArray);
|
||||||
retMsg.setData(jsonObject);
|
retMsg.setData(jsonObject);
|
||||||
return retMsg;
|
return retMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//webdav本地托管
|
||||||
|
@GetMapping("/w/{shortuuid}")
|
||||||
|
public ResponseEntity<InputStreamResource> getNextcloudImage(HttpServletRequest request, @PathVariable("shortuuid") String shortuuid) {
|
||||||
|
ResponseEntity<InputStreamResource> webDAV = webDAVImageupload.getWebDAV(shortuuid);
|
||||||
|
return webDAV;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/getUploadInfo")
|
@RequestMapping(value = "/getUploadInfo")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg getUploadInfo() {
|
public Msg getUploadInfo() {
|
||||||
@@ -138,19 +211,19 @@ public class IndexController {
|
|||||||
User user = (User) subject.getPrincipal();
|
User user = (User) subject.getPrincipal();
|
||||||
try {
|
try {
|
||||||
UploadConfig updateConfig = uploadConfigService.getUpdateConfig();
|
UploadConfig updateConfig = uploadConfigService.getUpdateConfig();
|
||||||
jsonObject.put("suffix",updateConfig.getSuffix().split(","));
|
jsonObject.put("suffix", updateConfig.getSuffix().split(","));
|
||||||
if(null==user){
|
if (null == user) {
|
||||||
jsonObject.put("filesize",Integer.valueOf(updateConfig.getFilesizetourists())/1024);
|
jsonObject.put("filesize", Integer.valueOf(updateConfig.getFilesizetourists()) / 1024);
|
||||||
jsonObject.put("imgcount",updateConfig.getImgcounttourists());
|
jsonObject.put("imgcount", updateConfig.getImgcounttourists());
|
||||||
jsonObject.put("uploadSwitch",updateConfig.getIsupdate());
|
jsonObject.put("uploadSwitch", updateConfig.getIsupdate());
|
||||||
jsonObject.put("uploadInfo","您登陆后才能使用此功能哦");
|
jsonObject.put("uploadInfo", "您登陆后才能使用此功能哦");
|
||||||
}else{
|
} else {
|
||||||
jsonObject.put("filesize",Integer.valueOf(updateConfig.getFilesizeuser())/1024);
|
jsonObject.put("filesize", Integer.valueOf(updateConfig.getFilesizeuser()) / 1024);
|
||||||
jsonObject.put("imgcount",updateConfig.getImgcountuser());
|
jsonObject.put("imgcount", updateConfig.getImgcountuser());
|
||||||
jsonObject.put("uploadSwitch",updateConfig.getUserclose());
|
jsonObject.put("uploadSwitch", updateConfig.getUserclose());
|
||||||
jsonObject.put("uploadInfo","系统暂时关闭了用户上传功能");
|
jsonObject.put("uploadInfo", "系统暂时关闭了用户上传功能");
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
msg.setData(jsonObject);
|
msg.setData(jsonObject);
|
||||||
@@ -162,19 +235,21 @@ public class IndexController {
|
|||||||
public Msg checkStatus(HttpServletRequest request) {
|
public Msg checkStatus(HttpServletRequest request) {
|
||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
String token = request.getHeader("Authorization");
|
String token = request.getHeader("Authorization");
|
||||||
if(token != null) {
|
if (token != null) {
|
||||||
JSONObject tokenJson = JWTUtil.checkToken(token);
|
JSONObject tokenJson = JWTUtil.checkToken(token);
|
||||||
if(tokenJson.getBoolean("check")){
|
if (tokenJson.getBoolean("check")) {
|
||||||
Subject subject = SecurityUtils.getSubject();
|
Subject subject = SecurityUtils.getSubject();
|
||||||
UsernamePasswordToken tokenOBJ = new UsernamePasswordToken(tokenJson.getString("email"),tokenJson.getString("password"));
|
UsernamePasswordToken tokenOBJ =
|
||||||
|
new UsernamePasswordToken(
|
||||||
|
tokenJson.getString("email"), tokenJson.getString("password"));
|
||||||
tokenOBJ.setRememberMe(true);
|
tokenOBJ.setRememberMe(true);
|
||||||
try {
|
try {
|
||||||
subject.login(tokenOBJ);
|
subject.login(tokenOBJ);
|
||||||
SecurityUtils.getSubject().getSession().setTimeout(3600000);
|
SecurityUtils.getSubject().getSession().setTimeout(3600000);
|
||||||
User u = (User) subject.getPrincipal();
|
User u = (User) subject.getPrincipal();
|
||||||
final JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
jsonObject.put("RoleLevel",u.getLevel()==2?"admin":"user");
|
jsonObject.put("RoleLevel", u.getLevel() == 2 ? "admin" : "user");
|
||||||
jsonObject.put("userName",u.getUsername());
|
jsonObject.put("userName", u.getUsername());
|
||||||
msg.setCode("200");
|
msg.setCode("200");
|
||||||
msg.setData(jsonObject);
|
msg.setData(jsonObject);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -183,119 +258,149 @@ public class IndexController {
|
|||||||
System.err.println("登录失效,请重新登录");
|
System.err.println("登录失效,请重新登录");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
msg.setCode("40041");
|
msg.setCode("40041");
|
||||||
msg.setInfo("登录失效,请重新登录");
|
msg.setInfo("登录失效,请重新登录");
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
msg.setCode("40040");
|
msg.setCode("40040");
|
||||||
msg.setInfo("当前未登录,请先登录");
|
msg.setInfo("当前未登录,请先登录");
|
||||||
}
|
}
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/verifyCode")
|
@PostMapping("/verifyCode")
|
||||||
public void verifyCode(HttpServletRequest request, HttpServletResponse response,HttpSession httpSession) {
|
@ResponseBody
|
||||||
IVerifyCodeGen iVerifyCodeGen = new SimpleCharVerifyCodeGenImpl();
|
public Msg verifyCode() {
|
||||||
|
Msg msg = new Msg();
|
||||||
try {
|
try {
|
||||||
ShearCaptcha captcha = CaptchaUtil.createShearCaptcha(90, 35, 2, 2);
|
ShearCaptcha captcha = CaptchaUtil.createShearCaptcha(90, 35, 2, 2);
|
||||||
captcha.setGenerator(new MathGenerator(1));
|
captcha.setGenerator(new MathGenerator(1));
|
||||||
httpSession.setAttribute("_hellohao_verifyCode",captcha);
|
String code = getVerifyCodeOperator(captcha.getCode());
|
||||||
response.setHeader("Pragma", "no-cache");
|
String uid = UUID.randomUUID().toString().replace("-", "").toLowerCase();
|
||||||
response.setHeader("Cache-Control", "no-cache");
|
iRedisService.setValue("verifyCode_" + uid, code);
|
||||||
response.setDateHeader("Expires", 0);
|
JSONObject jsonObject = new JSONObject();
|
||||||
response.setContentType("image/jpeg");
|
jsonObject.put("codeKey", uid);
|
||||||
captcha.write(response.getOutputStream());
|
jsonObject.put("codeImg", captcha.getImageBase64());
|
||||||
final Timer timer=new Timer();
|
msg.setData(jsonObject);
|
||||||
timer.schedule(new TimerTask() {
|
return msg;
|
||||||
@Override
|
} catch (Exception e) {
|
||||||
public void run() {
|
|
||||||
httpSession.removeAttribute("_hellohao_verifyCode");
|
|
||||||
timer.cancel();
|
|
||||||
}
|
|
||||||
},5*60*1000);
|
|
||||||
response.getOutputStream().flush();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
msg.setCode("500");
|
||||||
|
return msg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/verifyCodeForRegister")
|
@PostMapping("/verifyCodeForRegister")
|
||||||
public void verifyCodeForRegister(HttpServletRequest request, HttpServletResponse response,HttpSession httpSession) {
|
@ResponseBody
|
||||||
IVerifyCodeGen iVerifyCodeGen = new SimpleCharVerifyCodeGenImpl();
|
public Msg verifyCodeForRegister() {
|
||||||
|
Msg msg = new Msg();
|
||||||
try {
|
try {
|
||||||
ShearCaptcha captcha = CaptchaUtil.createShearCaptcha(90, 35, 2, 2);
|
ShearCaptcha captcha = CaptchaUtil.createShearCaptcha(90, 35, 2, 2);
|
||||||
httpSession.setAttribute("_hellohao_verifyCodeForRegister",captcha);
|
captcha.setGenerator(new MathGenerator(1));
|
||||||
response.setHeader("Pragma", "no-cache");
|
String code = getVerifyCodeOperator(captcha.getCode());
|
||||||
response.setHeader("Cache-Control", "no-cache");
|
String uid = UUID.randomUUID().toString().replace("-", "").toLowerCase();
|
||||||
response.setDateHeader("Expires", 0);
|
iRedisService.setValue("verifyCodeForRegister_" + uid, code);
|
||||||
response.setContentType("image/jpeg");
|
JSONObject jsonObject = new JSONObject();
|
||||||
captcha.write(response.getOutputStream());
|
jsonObject.put("codeKey", uid);
|
||||||
final Timer timer=new Timer();
|
jsonObject.put("codeImg", captcha.getImageBase64());
|
||||||
timer.schedule(new TimerTask() {
|
msg.setData(jsonObject);
|
||||||
@Override
|
return msg;
|
||||||
public void run() {
|
} catch (Exception e) {
|
||||||
httpSession.removeAttribute("_hellohao_verifyCodeForRegister");
|
|
||||||
timer.cancel();
|
|
||||||
}
|
|
||||||
},5*60*1000);
|
|
||||||
response.getOutputStream().flush();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
msg.setCode("500");
|
||||||
|
return msg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/verifyCodeForRetrieve")
|
@PostMapping("/verifyCodeForRetrieve")
|
||||||
public void verifyCodeForRetrieve(HttpServletRequest request, HttpServletResponse response,HttpSession httpSession) {
|
@ResponseBody
|
||||||
IVerifyCodeGen iVerifyCodeGen = new SimpleCharVerifyCodeGenImpl();
|
public Msg verifyCodeForRetrieve() {
|
||||||
|
Msg msg = new Msg();
|
||||||
try {
|
try {
|
||||||
ShearCaptcha captcha = CaptchaUtil.createShearCaptcha(90, 35, 2, 2);
|
ShearCaptcha captcha = CaptchaUtil.createShearCaptcha(90, 35, 2, 2);
|
||||||
httpSession.setAttribute("_hellohao_verifyCodeForEmailRetrieve",captcha);
|
captcha.setGenerator(new MathGenerator(1));
|
||||||
response.setHeader("Pragma", "no-cache");
|
String code = getVerifyCodeOperator(captcha.getCode());
|
||||||
response.setHeader("Cache-Control", "no-cache");
|
String uid = UUID.randomUUID().toString().replace("-", "").toLowerCase();
|
||||||
response.setDateHeader("Expires", 0);
|
iRedisService.setValue("verifyCodeForRetrieve_" + uid, code);
|
||||||
response.setContentType("image/jpeg");
|
JSONObject jsonObject = new JSONObject();
|
||||||
captcha.write(response.getOutputStream());
|
jsonObject.put("codeKey", uid);
|
||||||
final Timer timer=new Timer();
|
jsonObject.put("codeImg", captcha.getImageBase64());
|
||||||
timer.schedule(new TimerTask() {
|
msg.setData(jsonObject);
|
||||||
@Override
|
return msg;
|
||||||
public void run() {
|
} catch (Exception e) {
|
||||||
httpSession.removeAttribute("_hellohao_verifyCodeForEmailRetrieve");
|
|
||||||
timer.cancel();
|
|
||||||
}
|
|
||||||
},5*60*1000);
|
|
||||||
response.getOutputStream().flush();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
msg.setCode("500");
|
||||||
|
return msg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping({"/deleImagesByUid","/client/deleImagesByUid"}) //new
|
@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) {
|
||||||
|
int a = Integer.valueOf(str.substring(0, 1));
|
||||||
|
String yxf = str.substring(1, 2);
|
||||||
|
int b = Integer.valueOf(str.substring(2, 3));
|
||||||
|
switch (yxf) {
|
||||||
|
case "*":
|
||||||
|
return Integer.toString(a * b);
|
||||||
|
case "+":
|
||||||
|
return Integer.toString(a + b);
|
||||||
|
case ",":
|
||||||
|
default:
|
||||||
|
return Integer.toString(82);
|
||||||
|
case "-":
|
||||||
|
return Integer.toString(a - b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping({"/deleImagesByUid", "/client/deleImagesByUid"})
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg deleImagesByUid(@RequestParam(value = "data", defaultValue = "") String data) {
|
public Msg deleImagesByUid(@RequestParam(value = "data", defaultValue = "") String data) {
|
||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||||
String imguid = jsonObj.getString("imguid");
|
String imguid = jsonObj.getString("imguid");
|
||||||
Images image = imgService.selectImgUrlByImgUID(imguid);
|
Images image = imgService.selectImgUrlByImgUID(imguid);
|
||||||
if(null==image){
|
if (null == image) {
|
||||||
msg.setInfo("图像已不存在,删除成功");
|
msg.setInfo("图像已不存在,删除成功");
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
Subject subject = SecurityUtils.getSubject();
|
Subject subject = SecurityUtils.getSubject();
|
||||||
User user = (User) subject.getPrincipal();
|
User user = (User) subject.getPrincipal();
|
||||||
if(null!=user){
|
if (null != user) {
|
||||||
if(!user.getId().equals(image.getUserid())){
|
if (!user.getId().equals(image.getUserid())) {
|
||||||
msg.setInfo("删除失败,该图片不允许你执行操作");
|
msg.setInfo("删除失败,该图片不允许你执行操作");
|
||||||
msg.setCode("100403");
|
msg.setCode("100403");
|
||||||
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");
|
||||||
msg.setInfo("图像删除失败");
|
msg.setInfo("图像删除失败");
|
||||||
}else{
|
} else {
|
||||||
msg.setCode("200");
|
msg.setCode("200");
|
||||||
msg.setInfo("图像已成功删除");
|
msg.setInfo("图像已成功删除");
|
||||||
}
|
}
|
||||||
@@ -311,26 +416,25 @@ public class IndexController {
|
|||||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||||
String appv = jsonObj.getString("version");
|
String appv = jsonObj.getString("version");
|
||||||
AppClient app = appClientService.getAppClientData("app");
|
AppClient app = appClientService.getAppClientData("app");
|
||||||
if(!StringUtils.isBlank(app.getAppupdate())){
|
if (!StringUtils.isBlank(app.getAppupdate())) {
|
||||||
String version = app.getAppupdate().replaceAll("\\.","");
|
String version = app.getAppupdate().replaceAll("\\.", "");
|
||||||
if(MyVersion.compareVersion(app.getAppupdate(),appv)==1){
|
if (MyVersion.compareVersion(app.getAppupdate(), appv) == 1) {
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
jsonObject.put("winpackurl",app.getWinpackurl());
|
jsonObject.put("winpackurl", app.getWinpackurl());
|
||||||
jsonObject.put("macpackurl",app.getMacpackurl());
|
jsonObject.put("macpackurl", app.getMacpackurl());
|
||||||
msg.setCode("200");
|
msg.setCode("200");
|
||||||
msg.setData(jsonObject);
|
msg.setData(jsonObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
msg.setCode("000");
|
msg.setCode("000");
|
||||||
}
|
}
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping("/authError")
|
@RequestMapping("/authError")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg authError(HttpServletRequest request){
|
public Msg authError(HttpServletRequest request) {
|
||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
msg.setCode("4031");
|
msg.setCode("4031");
|
||||||
msg.setInfo("You don't have authority");
|
msg.setInfo("You don't have authority");
|
||||||
@@ -339,13 +443,10 @@ public class IndexController {
|
|||||||
|
|
||||||
@RequestMapping("/jurisError")
|
@RequestMapping("/jurisError")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg jurisError(HttpServletRequest request){
|
public Msg jurisError(HttpServletRequest request) {
|
||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
msg.setCode("4031");
|
msg.setCode("4031");
|
||||||
msg.setInfo("Authentication request failed");
|
msg.setInfo("Authentication request failed");
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,8 +5,9 @@ import cn.hellohao.auth.token.JWTUtil;
|
|||||||
import cn.hellohao.config.SysName;
|
import cn.hellohao.config.SysName;
|
||||||
import cn.hellohao.pojo.*;
|
import cn.hellohao.pojo.*;
|
||||||
import cn.hellohao.service.*;
|
import cn.hellohao.service.*;
|
||||||
import cn.hellohao.utils.*;
|
import cn.hellohao.utils.NewSendEmail;
|
||||||
import cn.hutool.captcha.ShearCaptcha;
|
import cn.hellohao.utils.Print;
|
||||||
|
import cn.hellohao.utils.SetText;
|
||||||
import cn.hutool.core.util.HexUtil;
|
import cn.hutool.core.util.HexUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import org.apache.shiro.SecurityUtils;
|
import org.apache.shiro.SecurityUtils;
|
||||||
@@ -14,6 +15,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;
|
||||||
@@ -23,6 +26,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Base64;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@@ -35,33 +39,42 @@ public class UserController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private EmailConfigService emailConfigService;
|
private EmailConfigService emailConfigService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ConfigService configService;
|
private ConfdataService confdataService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private UploadConfigService uploadConfigService;
|
private UploadConfigService uploadConfigService;
|
||||||
@Autowired
|
@Autowired
|
||||||
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
|
||||||
public Msg Register(HttpSession httpSession, @RequestParam(value = "data", defaultValue = "") String data) {//Validated
|
public Msg Register(HttpServletRequest httpServletRequest, @RequestParam(value = "data", defaultValue = "") String data) {
|
||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||||
String username = jsonObj.getString("username");
|
String username = jsonObj.getString("username");
|
||||||
String email = jsonObj.getString("email");
|
String email = jsonObj.getString("email");
|
||||||
String password = Base64Encryption.encryptBASE64(jsonObj.getString("password").getBytes());
|
String password = Base64.getEncoder().encodeToString(jsonObj.getString("password").getBytes());
|
||||||
String verifyCodeForRegister = jsonObj.getString("verifyCode");
|
String verifyCodeForRegister = jsonObj.getString("verifyCode");
|
||||||
ShearCaptcha redis_verifyCodeForRegister = (ShearCaptcha) httpSession.getAttribute("_hellohao_verifyCodeForRegister");//iRedisService.getValue(userIP+"_verifyCodeForRegister");
|
Object redis_verifyCodeForRegister = iRedisService.getValue("verifyCodeForRegister_"+httpServletRequest.getHeader("verifyCodeForRegister"));
|
||||||
if(!SetText.checkEmail(email)){
|
if(!SetText.checkEmail(email)){
|
||||||
|
//邮箱格式不正确
|
||||||
msg.setCode("110403");
|
msg.setCode("110403");
|
||||||
msg.setInfo("邮箱格式不正确");
|
msg.setInfo("邮箱格式不正确");
|
||||||
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){
|
||||||
@@ -73,7 +86,7 @@ public class UserController {
|
|||||||
msg.setInfo("验证码不能为空。");
|
msg.setInfo("验证码不能为空。");
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
if(redis_verifyCodeForRegister.verify(verifyCodeForRegister.toLowerCase())){
|
if((redis_verifyCodeForRegister.toString().toLowerCase()).compareTo((verifyCodeForRegister.toLowerCase()))==0){
|
||||||
User user = new User();
|
User user = new User();
|
||||||
UploadConfig updateConfig = uploadConfigService.getUpdateConfig();
|
UploadConfig updateConfig = uploadConfigService.getUpdateConfig();
|
||||||
EmailConfig emailConfig = emailConfigService.getemail();
|
EmailConfig emailConfig = emailConfigService.getemail();
|
||||||
@@ -106,38 +119,105 @@ public class UserController {
|
|||||||
user.setEmail(email);
|
user.setEmail(email);
|
||||||
user.setUsername(username);
|
user.setUsername(username);
|
||||||
user.setPassword(password);
|
user.setPassword(password);
|
||||||
Config config = configService.getSourceype();
|
user.setToken(UUID.randomUUID().toString().replace("-", ""));
|
||||||
|
final Confdata confdata = confdataService.selectConfdata("config");
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(confdata.getJsondata());
|
||||||
Integer type = 0;
|
Integer type = 0;
|
||||||
if(emailConfig.getUsing()==1){
|
if(emailConfig.getUsing()==1){
|
||||||
user.setIsok(0);
|
user.setIsok(0);
|
||||||
|
//注册完发激活链接
|
||||||
Thread thread = new Thread() {
|
Thread thread = new Thread() {
|
||||||
public void run() {
|
public void run() {
|
||||||
Integer a = NewSendEmail.sendEmail(emailConfig,user.getUsername(), uid, user.getEmail(),config);
|
Integer a = NewSendEmail.sendEmail(emailConfig,user.getUsername(), uid, user.getEmail(),jsonObject);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
thread.start();
|
thread.start();
|
||||||
msg.setInfo("注册成功,请注意查收邮箱尽快激活账户");
|
msg.setInfo("注册成功,请注意查收邮箱尽快激活账户");
|
||||||
}else{
|
}else{
|
||||||
|
//直接注册
|
||||||
user.setIsok(1);
|
user.setIsok(1);
|
||||||
msg.setInfo("注册成功,快去登陆吧");
|
msg.setInfo("注册成功,快去登陆吧");
|
||||||
}
|
}
|
||||||
userService.register(user);
|
userService.register(user);
|
||||||
}else{
|
}else{
|
||||||
msg.setCode("110408");
|
msg.setCode("110408");
|
||||||
msg.setInfo("验证码不正确");
|
msg.setInfo("验证码不正确");//失效也要处理。
|
||||||
}
|
}
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/login")
|
@PostMapping(value = {"/validateEmail","/wechat/validateEmail"})
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg login(HttpServletRequest request,HttpSession httpSession,@RequestParam(value = "data", defaultValue = "") String data) {
|
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
|
||||||
|
@ResponseBody
|
||||||
|
public Msg login(HttpServletRequest httpServletRequest,@RequestParam(value = "data", defaultValue = "") String data) {
|
||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||||
String email = jsonObj.getString("email");
|
String email = jsonObj.getString("email");
|
||||||
String password = Base64Encryption.encryptBASE64(jsonObj.getString("password").getBytes());
|
String password = Base64.getEncoder().encodeToString(jsonObj.getString("password").getBytes());
|
||||||
String verifyCode = jsonObj.getString("verifyCode");
|
String verifyCode = jsonObj.getString("verifyCode");
|
||||||
ShearCaptcha redis_VerifyCode = (ShearCaptcha)httpSession.getAttribute("_hellohao_verifyCode");
|
if(null == email || null == password || null == verifyCode){
|
||||||
|
msg.setCode("5000");
|
||||||
|
msg.setInfo("登录信息不正确");
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
if(email.replace(" ","").equals("") || password.replace(" ","").equals("")
|
||||||
|
|| verifyCode.replace(" ","").equals("")){
|
||||||
|
msg.setCode("5000");
|
||||||
|
msg.setInfo("登录信息不正确");
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object redis_VerifyCode = iRedisService.getValue("verifyCode_"+httpServletRequest.getHeader("verifyCode"));
|
||||||
if(null==redis_VerifyCode){
|
if(null==redis_VerifyCode){
|
||||||
msg.setCode("4035");
|
msg.setCode("4035");
|
||||||
msg.setInfo("验证码已失效,请重新弄获取。");
|
msg.setInfo("验证码已失效,请重新弄获取。");
|
||||||
@@ -147,18 +227,19 @@ public class UserController {
|
|||||||
msg.setInfo("验证码不能为空。");
|
msg.setInfo("验证码不能为空。");
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
if(redis_VerifyCode.verify(verifyCode.toLowerCase())){
|
if((redis_VerifyCode.toString().toLowerCase()).compareTo((verifyCode.toLowerCase()))==0){
|
||||||
Subject subject = SecurityUtils.getSubject();
|
Subject subject = SecurityUtils.getSubject();
|
||||||
UsernamePasswordToken tokenOBJ = new UsernamePasswordToken(email,password);
|
UsernamePasswordToken tokenOBJ = new UsernamePasswordToken(email,password);
|
||||||
tokenOBJ.setRememberMe(true);
|
tokenOBJ.setRememberMe(true);
|
||||||
try {
|
try {
|
||||||
subject.login(tokenOBJ);
|
subject.login(tokenOBJ);
|
||||||
SecurityUtils.getSubject().getSession().setTimeout(3600000);//一小时
|
SecurityUtils.getSubject().getSession().setTimeout(3600000);
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
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){
|
||||||
@@ -176,16 +257,17 @@ public class UserController {
|
|||||||
msg.setData(jsonObject);
|
msg.setData(jsonObject);
|
||||||
return msg;
|
return msg;
|
||||||
} 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");
|
||||||
@@ -196,7 +278,7 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
msg.setCode("40034");
|
msg.setCode("40034");
|
||||||
msg.setInfo("验证码不正确");//失效也要处理。
|
msg.setInfo("验证码不正确");
|
||||||
}
|
}
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
@@ -204,7 +286,6 @@ public class UserController {
|
|||||||
|
|
||||||
@RequestMapping(value = "/activation", method = RequestMethod.GET)
|
@RequestMapping(value = "/activation", method = RequestMethod.GET)
|
||||||
public String activation(Model model, HttpServletRequest request, HttpSession session, String activation, String username) {
|
public String activation(Model model, HttpServletRequest request, HttpSession session, String activation, String username) {
|
||||||
Config config = configService.getSourceype();
|
|
||||||
Integer ret = 0;
|
Integer ret = 0;
|
||||||
User u2 = new User();
|
User u2 = new User();
|
||||||
u2.setUid(activation);
|
u2.setUid(activation);
|
||||||
@@ -224,7 +305,7 @@ public class UserController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/logout")
|
@PostMapping(value = "/logout")//new
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg exit(Model model, HttpServletRequest request, HttpServletResponse response, HttpSession session) {
|
public Msg exit(Model model, HttpServletRequest request, HttpServletResponse response, HttpSession session) {
|
||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
@@ -237,13 +318,13 @@ public class UserController {
|
|||||||
|
|
||||||
@PostMapping("/retrievePass")
|
@PostMapping("/retrievePass")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public Msg retrievePass(HttpServletRequest request,HttpSession httpSession, @RequestParam(value = "data", defaultValue = "") String data) {
|
public Msg retrievePass(HttpServletRequest httpServletRequest, @RequestParam(value = "data", defaultValue = "") String data) {
|
||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
try {
|
try {
|
||||||
JSONObject jsonObj = JSONObject.parseObject(data);
|
JSONObject jsonObj = JSONObject.parseObject(data);
|
||||||
String email = jsonObj.getString("email");
|
String email = jsonObj.getString("email");
|
||||||
String retrieveCode = jsonObj.getString("retrieveCode");
|
String retrieveCode = jsonObj.getString("retrieveCode");
|
||||||
ShearCaptcha redis_verifyCodeForEmailRetrieve =(ShearCaptcha) httpSession.getAttribute("_hellohao_verifyCodeForEmailRetrieve");// iRedisService.getValue(userIP+"_verifyCodeForEmailRetrieve");
|
Object redis_verifyCodeForEmailRetrieve =iRedisService.getValue("verifyCodeForRetrieve_"+httpServletRequest.getHeader("verifyCodeForRetrieve"));
|
||||||
EmailConfig emailConfig = emailConfigService.getemail();
|
EmailConfig emailConfig = emailConfigService.getemail();
|
||||||
if(null==redis_verifyCodeForEmailRetrieve){
|
if(null==redis_verifyCodeForEmailRetrieve){
|
||||||
msg.setCode("4035");
|
msg.setCode("4035");
|
||||||
@@ -254,12 +335,11 @@ public class UserController {
|
|||||||
msg.setInfo("验证码不能为空。");
|
msg.setInfo("验证码不能为空。");
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
if(!redis_verifyCodeForEmailRetrieve.verify(retrieveCode.toLowerCase())){
|
if((redis_verifyCodeForEmailRetrieve.toString().toLowerCase()).compareTo((retrieveCode.toLowerCase()))!=0){
|
||||||
msg.setCode("40034");
|
msg.setCode("40034");
|
||||||
msg.setInfo("验证码不正确");
|
msg.setInfo("验证码不正确");
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer ret = userService.countmail(email);
|
Integer ret = userService.countmail(email);
|
||||||
if(ret>0){
|
if(ret>0){
|
||||||
if(emailConfig.getUsing()==1){
|
if(emailConfig.getUsing()==1){
|
||||||
@@ -271,10 +351,11 @@ public class UserController {
|
|||||||
msg.setInfo("当前用户已被冻结,禁止操作");
|
msg.setInfo("当前用户已被冻结,禁止操作");
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
Config config = configService.getSourceype();
|
final Confdata confdata = confdataService.selectConfdata("config");
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(confdata.getJsondata());
|
||||||
Thread thread = new Thread() {
|
Thread thread = new Thread() {
|
||||||
public void run() {
|
public void run() {
|
||||||
Integer a = NewSendEmail.sendEmailFindPass(emailConfig,user.getUsername(), user.getUid(), user.getEmail(),config);//SendEmail.sendEmailT(message, user.getUsername(), user.getUid(), user.getEmail(),emailConfig,config);
|
Integer a = NewSendEmail.sendEmailFindPass(emailConfig,user.getUsername(), user.getUid(), user.getEmail(),jsonObject);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
thread.start();
|
thread.start();
|
||||||
@@ -304,7 +385,7 @@ public class UserController {
|
|||||||
User user = userService.getUsers(u2);
|
User user = userService.getUsers(u2);
|
||||||
user.setIsok(1);
|
user.setIsok(1);
|
||||||
String new_pass = HexUtil.decodeHexStr(cip);//解密密码
|
String new_pass = HexUtil.decodeHexStr(cip);//解密密码
|
||||||
user.setPassword(Base64Encryption.encryptBASE64(new_pass.getBytes()));
|
user.setPassword(Base64.getEncoder().encodeToString(new_pass.getBytes()));
|
||||||
String uid = UUID.randomUUID().toString().replace("-", "").toLowerCase();
|
String uid = UUID.randomUUID().toString().replace("-", "").toLowerCase();
|
||||||
user.setUid(uid);
|
user.setUid(uid);
|
||||||
if (user != null) {
|
if (user != null) {
|
||||||
|
|||||||
@@ -9,13 +9,9 @@ import java.util.List;
|
|||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface CodeMapper {
|
public interface CodeMapper {
|
||||||
//查询扩容码
|
|
||||||
List<Code> selectCode(@Param("code") String code);
|
List<Code> selectCode(@Param("code") String code);
|
||||||
Code selectCodekey(@Param("code") String code);
|
Code selectCodekey(@Param("code") String code);
|
||||||
//Integer selectCodekey(@Param("value") String value);
|
|
||||||
//添加
|
|
||||||
Integer addCode(Code code);
|
Integer addCode(Code code);
|
||||||
//删除扩容码
|
|
||||||
Integer deleteCode(@Param("code") String code);
|
Integer deleteCode(@Param("code") String code);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package cn.hellohao.dao;
|
||||||
|
|
||||||
|
import cn.hellohao.pojo.Confdata;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface ConfdataMapper {
|
||||||
|
Confdata selectConfdata(@Param("key") String key);
|
||||||
|
Integer updateConfdata(Confdata confdata);
|
||||||
|
}
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
package cn.hellohao.dao;
|
|
||||||
|
|
||||||
import cn.hellohao.pojo.Config;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface ConfigMapper {
|
|
||||||
Config getSourceype();
|
|
||||||
Integer setSourceype(Config config);
|
|
||||||
}
|
|
||||||
@@ -1,32 +1,37 @@
|
|||||||
package cn.hellohao.dao;
|
package cn.hellohao.dao;
|
||||||
|
|
||||||
import java.util.List;
|
import cn.hellohao.pojo.Images;
|
||||||
|
|
||||||
import cn.hellohao.pojo.User;
|
import cn.hellohao.pojo.User;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import cn.hellohao.pojo.Images;
|
import java.util.List;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface ImgMapper {
|
public interface ImgMapper {
|
||||||
|
|
||||||
List<Images> selectimg(Images images);
|
List<Images> selectimg(Images images);
|
||||||
|
|
||||||
|
Integer insertImgData(Images images);
|
||||||
|
|
||||||
Integer countimg(@Param("userid") Integer userid);
|
Integer countimg(@Param("userid") Integer userid);
|
||||||
|
|
||||||
Integer deleimg(@Param("id") Integer id);
|
Integer deleimg(@Param("id") Long id);
|
||||||
|
|
||||||
Integer deleimgForImgUid(@Param("imguid") String imguid);
|
Integer deleimgForImgUid(@Param("imguid") String imguid);
|
||||||
|
|
||||||
Images selectByPrimaryKey(@Param("id") Integer id);
|
Images selectByPrimaryKey(@Param("id") Long id);
|
||||||
|
|
||||||
|
Images selectImgByBrieflink(@Param("brieflink") String brieflink);
|
||||||
|
|
||||||
|
Images selectImgByShortlink(@Param("shortlink") String shortlink);
|
||||||
|
|
||||||
Integer counts(@Param("userid") Integer userid);
|
Integer counts(@Param("userid") Integer userid);
|
||||||
|
|
||||||
Integer setImg(Images images);
|
Integer setImg(Images images);
|
||||||
|
|
||||||
Integer deleimgname(@Param("imgname") String imgname);
|
Integer deleimgname(@Param("imgname") String imgname);
|
||||||
Integer deleall(@Param("id") Integer id);
|
Integer deleall(@Param("id") Long id);
|
||||||
|
|
||||||
List<Images> gettimeimg(@Param("time") String time);
|
List<Images> gettimeimg(@Param("time") String time);
|
||||||
|
|
||||||
@@ -36,7 +41,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);
|
||||||
|
|
||||||
|
|||||||
@@ -9,11 +9,9 @@ import java.util.List;
|
|||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface KeysMapper {
|
public interface KeysMapper {
|
||||||
//查询密钥
|
|
||||||
Keys selectKeys(@Param("id") Integer id);
|
Keys selectKeys(@Param("id") Integer id);
|
||||||
List<Keys> getStorageName();
|
List<Keys> getStorageName();
|
||||||
List<Keys> getStorage();
|
List<Keys> getStorage();
|
||||||
//修改key
|
|
||||||
Integer updateKey(Keys key);
|
Integer updateKey(Keys key);
|
||||||
List<Keys> getKeys();
|
List<Keys> getKeys();
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
package cn.hellohao.dao;
|
package cn.hellohao.dao;
|
||||||
|
|
||||||
|
import cn.hellohao.pojo.User;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import cn.hellohao.pojo.Images;
|
|
||||||
import cn.hellohao.pojo.User;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
@@ -14,7 +12,6 @@ public interface UserMapper {
|
|||||||
Integer login(@Param("email") String email, @Param("password") String password,@Param("uid") String uid);
|
Integer login(@Param("email") String email, @Param("password") String password,@Param("uid") String uid);
|
||||||
User getUsers(User user);
|
User getUsers(User user);
|
||||||
User loginByToken (@Param("token") String token);
|
User loginByToken (@Param("token") String token);
|
||||||
Integer insertimg(Images img);
|
|
||||||
Integer change(User user);
|
Integer change(User user);
|
||||||
Integer changeUser(User user);
|
Integer changeUser(User user);
|
||||||
Integer checkUsername(@Param("username") String username);
|
Integer checkUsername(@Param("username") String username);
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package cn.hellohao.pojo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Hellohao
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2023/3/2 10:21
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class Confdata {
|
||||||
|
|
||||||
|
private String key;
|
||||||
|
private String jsondata;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,223 +0,0 @@
|
|||||||
package cn.hellohao.pojo;
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
public Config() {
|
|
||||||
}
|
|
||||||
|
|
||||||
public Config(Integer id, Integer sourcekey, Integer emails, String webname, String explain, String video, Integer backtype,
|
|
||||||
String links, String notice, String baidu, String domain, String background1, String background2, String sett,
|
|
||||||
String webms, String webkeywords, String webfavicons, Integer theme,String websubtitle,String logo,String aboutinfo) {
|
|
||||||
this.id = id;
|
|
||||||
this.sourcekey = sourcekey;
|
|
||||||
this.emails = emails;
|
|
||||||
this.webname = webname;
|
|
||||||
this.explain = explain;
|
|
||||||
this.video = video;
|
|
||||||
this.backtype = backtype;
|
|
||||||
this.links = links;
|
|
||||||
this.notice = notice;
|
|
||||||
this.baidu = baidu;
|
|
||||||
this.domain = domain;
|
|
||||||
this.background1 = background1;
|
|
||||||
this.background2 = background2;
|
|
||||||
this.sett = sett;
|
|
||||||
this.webms = webms;
|
|
||||||
this.webkeywords = webkeywords;
|
|
||||||
this.webfavicons = webfavicons;
|
|
||||||
this.theme = theme;
|
|
||||||
this.websubtitle = websubtitle;
|
|
||||||
this.logo = logo;
|
|
||||||
this.aboutinfo = aboutinfo;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Integer id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getSourcekey() {
|
|
||||||
return sourcekey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSourcekey(Integer sourcekey) {
|
|
||||||
this.sourcekey = sourcekey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getEmails() {
|
|
||||||
return emails;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEmails(Integer emails) {
|
|
||||||
this.emails = emails;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getWebname() {
|
|
||||||
return webname;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWebname(String webname) {
|
|
||||||
this.webname = webname;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getExplain() {
|
|
||||||
return explain;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setExplain(String explain) {
|
|
||||||
this.explain = explain;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getVideo() {
|
|
||||||
return video;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVideo(String video) {
|
|
||||||
this.video = video;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getBacktype() {
|
|
||||||
return backtype;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBacktype(Integer backtype) {
|
|
||||||
this.backtype = backtype;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLinks() {
|
|
||||||
return links;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLinks(String links) {
|
|
||||||
this.links = links;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNotice() {
|
|
||||||
return notice;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNotice(String notice) {
|
|
||||||
this.notice = notice;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBaidu() {
|
|
||||||
return baidu;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBaidu(String baidu) {
|
|
||||||
this.baidu = baidu;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDomain() {
|
|
||||||
return domain;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDomain(String domain) {
|
|
||||||
this.domain = domain;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBackground1() {
|
|
||||||
return background1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBackground1(String background1) {
|
|
||||||
this.background1 = background1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBackground2() {
|
|
||||||
return background2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBackground2(String background2) {
|
|
||||||
this.background2 = background2;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSett() {
|
|
||||||
return sett;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSett(String sett) {
|
|
||||||
this.sett = sett;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getWebms() {
|
|
||||||
return webms;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWebms(String webms) {
|
|
||||||
this.webms = webms;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getWebkeywords() {
|
|
||||||
return webkeywords;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWebkeywords(String webkeywords) {
|
|
||||||
this.webkeywords = webkeywords;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getWebfavicons() {
|
|
||||||
return webfavicons;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWebfavicons(String webfavicons) {
|
|
||||||
this.webfavicons = webfavicons;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getTheme() {
|
|
||||||
return theme;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTheme(Integer theme) {
|
|
||||||
this.theme = theme;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getWebsubtitle() {
|
|
||||||
return websubtitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setWebsubtitle(String websubtitle) {
|
|
||||||
this.websubtitle = websubtitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLogo() {
|
|
||||||
return logo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLogo(String logo) {
|
|
||||||
this.logo = logo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAboutinfo() {
|
|
||||||
return aboutinfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAboutinfo(String aboutinfo) {
|
|
||||||
this.aboutinfo = aboutinfo;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
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 Integer id;
|
private Long id;
|
||||||
private String imgname;
|
private String imgname;
|
||||||
private String imgurl;
|
private String imgurl;
|
||||||
private Integer userid;
|
private Integer userid;
|
||||||
@@ -35,310 +36,12 @@ public class Images {
|
|||||||
private String yyyy;
|
private String yyyy;
|
||||||
private String[] classifuidlist; //类别uid集合
|
private String[] classifuidlist; //类别uid集合
|
||||||
private String classificationuid; //类别uid集合
|
private String classificationuid; //类别uid集合
|
||||||
|
|
||||||
private String idname;
|
private String idname;
|
||||||
|
private Integer isRepeat;//如果没有开启查重的时候他是0,开启为1
|
||||||
public Images() {
|
private String searchname;
|
||||||
super();
|
private String brieflink;
|
||||||
}
|
private String shortlink;
|
||||||
|
private String order;
|
||||||
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(Integer 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) {
|
|
||||||
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;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Integer 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,94 +1,22 @@
|
|||||||
package cn.hellohao.pojo;
|
package cn.hellohao.pojo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
public class Keys {
|
public class Keys {
|
||||||
private Integer id;
|
private Integer id;
|
||||||
private String AccessKey;
|
private String AccessKey;
|
||||||
private String AccessSecret;
|
private String AccessSecret;
|
||||||
private String Endpoint;
|
private String Endpoint;
|
||||||
|
private String Region;
|
||||||
private String Bucketname;
|
private String Bucketname;
|
||||||
private String RequestAddress;
|
private String RequestAddress;
|
||||||
private Integer storageType;
|
private Integer storageType;
|
||||||
private String keyname;
|
private String keyname;
|
||||||
|
private String RootPath;//存入的目录
|
||||||
|
private Boolean SysTransmit;
|
||||||
|
|
||||||
public Keys() {
|
public Boolean getSysTransmit() {
|
||||||
super();
|
return SysTransmit==null?false:SysTransmit;
|
||||||
}
|
|
||||||
|
|
||||||
public Keys(Integer id, String accessKey, String accessSecret, String endpoint, String bucketname,
|
|
||||||
String requestAddress, Integer storageType,String keyname) {
|
|
||||||
super();
|
|
||||||
this.id = id;
|
|
||||||
this.AccessKey = accessKey;
|
|
||||||
this.AccessSecret = accessSecret;
|
|
||||||
this.Endpoint = endpoint;
|
|
||||||
this.Bucketname = bucketname;
|
|
||||||
this.RequestAddress = requestAddress;
|
|
||||||
this.storageType = storageType;
|
|
||||||
this.keyname = keyname;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Integer id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAccessKey() {
|
|
||||||
return AccessKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAccessKey(String accessKey) {
|
|
||||||
AccessKey = accessKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getAccessSecret() {
|
|
||||||
return AccessSecret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAccessSecret(String accessSecret) {
|
|
||||||
AccessSecret = accessSecret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getEndpoint() {
|
|
||||||
return Endpoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setEndpoint(String endpoint) {
|
|
||||||
Endpoint = endpoint;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBucketname() {
|
|
||||||
return Bucketname;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBucketname(String bucketname) {
|
|
||||||
Bucketname = bucketname;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRequestAddress() {
|
|
||||||
return RequestAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setRequestAddress(String requestAddress) {
|
|
||||||
RequestAddress = requestAddress;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getStorageType() {
|
|
||||||
return storageType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStorageType(Integer storageType) {
|
|
||||||
this.storageType = storageType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getKeyname() {
|
|
||||||
return keyname;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setKeyname(String keyname) {
|
|
||||||
this.keyname = keyname;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,16 +11,12 @@ public class Msg implements Serializable {
|
|||||||
|
|
||||||
private static final long serialVersionUID = 5196249482551119279L;
|
private static final long serialVersionUID = 5196249482551119279L;
|
||||||
|
|
||||||
//返回码
|
|
||||||
private String code ="200";
|
private String code ="200";
|
||||||
|
|
||||||
//提示信息
|
|
||||||
private String info="操作成功";
|
private String info="操作成功";
|
||||||
|
|
||||||
//返回数据
|
|
||||||
private Object data;
|
private Object data;
|
||||||
|
|
||||||
//异常
|
|
||||||
private String exceptions;
|
private String exceptions;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -32,9 +32,11 @@ public class FirstJob {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private USSImageupload ussImageupload;
|
private USSImageupload ussImageupload;
|
||||||
@Autowired
|
@Autowired
|
||||||
private UFileImageupload uFileImageupload;
|
private S3Imageupload s3Imageupload;
|
||||||
@Autowired
|
@Autowired
|
||||||
private FTPImageupload ftpImageupload;
|
private WebDAVImageupload webDAVImageupload;
|
||||||
|
@Autowired
|
||||||
|
private FtpServiceImpl ftpService;
|
||||||
@Autowired
|
@Autowired
|
||||||
ImgTempService imgTempService;
|
ImgTempService imgTempService;
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -75,9 +77,11 @@ public class FirstJob {
|
|||||||
}else if(keys.getStorageType()==6){
|
}else if(keys.getStorageType()==6){
|
||||||
firstJob.cosImageupload.delCOS(keys.getId(),images);
|
firstJob.cosImageupload.delCOS(keys.getId(),images);
|
||||||
}else if(keys.getStorageType()==7){
|
}else if(keys.getStorageType()==7){
|
||||||
firstJob.ftpImageupload.delFTP(keys.getId(), images);
|
firstJob.ftpService.delFTP(keys.getId(), images);
|
||||||
}else if(keys.getStorageType()==8){
|
}else if(keys.getStorageType()==8){
|
||||||
firstJob.uFileImageupload.delUFile(keys.getId(), images);
|
firstJob.s3Imageupload.deleS3(keys.getId(), images);
|
||||||
|
}else if(keys.getStorageType()==9){
|
||||||
|
firstJob.webDAVImageupload.delWebDAV(keys.getId(), images);
|
||||||
}else{
|
}else{
|
||||||
System.err.println("未获取到对象存储参数,上传失败。");
|
System.err.println("未获取到对象存储参数,上传失败。");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package cn.hellohao.service;
|
||||||
|
|
||||||
|
import cn.hellohao.pojo.Confdata;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public interface ConfdataService {
|
||||||
|
Confdata selectConfdata(String key);
|
||||||
|
Integer updateConfdata(Confdata confdata);
|
||||||
|
}
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
package cn.hellohao.service;
|
|
||||||
|
|
||||||
import cn.hellohao.pojo.Config;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public interface ConfigService {
|
|
||||||
Config getSourceype();
|
|
||||||
Integer setSourceype(Config config);
|
|
||||||
}
|
|
||||||
@@ -4,14 +4,16 @@ import java.util.Map;
|
|||||||
|
|
||||||
public interface IRedisService {
|
public interface IRedisService {
|
||||||
|
|
||||||
// 加入元素
|
// 加入元素
|
||||||
void setValue(String key, Map<String, Object> value);
|
void setValue(String key, Map<String, Object> value);
|
||||||
// 加入元素
|
// 加入元素
|
||||||
void setValue(String key, String value);
|
void setValue(String key, String value);
|
||||||
// 加入元素
|
// 加入元素
|
||||||
void setValue(String key, Object value);
|
void setTimeValue(String key, Object value,Long time);
|
||||||
// 获取元素
|
// 获取元素
|
||||||
Object getMapValue(String key);
|
Object getMapValue(String key);
|
||||||
// 获取元素
|
// 获取元素
|
||||||
Object getValue(String key);
|
Object getValue(String key);
|
||||||
}
|
// 删除某个值
|
||||||
|
Boolean removeValue(String key);
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,25 +1,30 @@
|
|||||||
package cn.hellohao.service;
|
package cn.hellohao.service;
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
import cn.hellohao.pojo.Images;
|
||||||
|
|
||||||
import cn.hellohao.pojo.User;
|
import cn.hellohao.pojo.User;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import cn.hellohao.pojo.Images;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public interface ImgService {
|
public interface ImgService {
|
||||||
List<Images> selectimg(Images images);
|
List<Images> selectimg(Images images);
|
||||||
|
|
||||||
Integer deleimg(Integer id);
|
Integer insertImgData(Images images);
|
||||||
|
|
||||||
|
Integer deleimg(Long id);
|
||||||
|
|
||||||
Integer deleimgForImgUid(String imguid);
|
Integer deleimgForImgUid(String imguid);
|
||||||
|
|
||||||
Integer countimg(Integer userid);
|
Integer countimg(Integer userid);
|
||||||
|
|
||||||
Images selectByPrimaryKey(Integer id);
|
Images selectByPrimaryKey(Long id);
|
||||||
|
|
||||||
|
Images selectImgByBrieflink(String brieflink);
|
||||||
|
|
||||||
|
Images selectImgByShortlink(String shortlink);
|
||||||
|
|
||||||
Integer counts(Integer userid);
|
Integer counts(Integer userid);
|
||||||
|
|
||||||
@@ -27,7 +32,7 @@ public interface ImgService {
|
|||||||
|
|
||||||
Integer deleimgname(String imgname);
|
Integer deleimgname(String imgname);
|
||||||
|
|
||||||
Integer deleall(Integer id);
|
Integer deleall(Long id);
|
||||||
|
|
||||||
List<Images> gettimeimg(String time);
|
List<Images> gettimeimg(String time);
|
||||||
|
|
||||||
@@ -37,7 +42,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);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package cn.hellohao.service;
|
package cn.hellohao.service;
|
||||||
|
|
||||||
import cn.hellohao.pojo.Images;
|
|
||||||
import cn.hellohao.pojo.User;
|
import cn.hellohao.pojo.User;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -16,8 +15,6 @@ public interface UserService {
|
|||||||
|
|
||||||
User getUsers(User user);
|
User getUsers(User user);
|
||||||
|
|
||||||
Integer insertimg(Images img);
|
|
||||||
|
|
||||||
Integer change(User user);
|
Integer change(User user);
|
||||||
|
|
||||||
Integer changeUser(User user);
|
Integer changeUser(User user);
|
||||||
|
|||||||
@@ -1,23 +1,19 @@
|
|||||||
package cn.hellohao.service.impl;
|
package cn.hellohao.service.impl;
|
||||||
|
|
||||||
import cn.hellohao.dao.AlbumMapper;
|
import cn.hellohao.dao.AlbumMapper;
|
||||||
import cn.hellohao.dao.ConfigMapper;
|
|
||||||
import cn.hellohao.dao.ImgAndAlbumMapper;
|
import cn.hellohao.dao.ImgAndAlbumMapper;
|
||||||
import cn.hellohao.dao.ImgMapper;
|
import cn.hellohao.dao.ImgMapper;
|
||||||
import cn.hellohao.exception.CodeException;
|
import cn.hellohao.exception.CodeException;
|
||||||
import cn.hellohao.pojo.Album;
|
import cn.hellohao.pojo.Album;
|
||||||
import cn.hellohao.pojo.Images;
|
import cn.hellohao.pojo.Images;
|
||||||
import cn.hellohao.pojo.ImgAndAlbum;
|
import cn.hellohao.pojo.ImgAndAlbum;
|
||||||
import cn.hellohao.pojo.Msg;
|
|
||||||
import cn.hellohao.service.AlbumService;
|
import cn.hellohao.service.AlbumService;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
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 org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Hellohao
|
* @author Hellohao
|
||||||
@@ -26,92 +22,85 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class AlbumServiceImpl implements AlbumService {
|
public class AlbumServiceImpl implements AlbumService {
|
||||||
@Autowired
|
@Autowired AlbumMapper albumMapper;
|
||||||
AlbumMapper albumMapper;
|
@Autowired ImgAndAlbumMapper andAlbumMapper;
|
||||||
@Autowired
|
@Autowired ImgMapper imgMapper;
|
||||||
ImgAndAlbumMapper andAlbumMapper;
|
|
||||||
@Autowired
|
|
||||||
ConfigMapper configMapper;
|
|
||||||
@Autowired
|
|
||||||
ImgMapper imgMapper;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONArray getAlbumList(JSONArray array) {
|
public JSONArray getAlbumList(JSONArray array) {
|
||||||
JSONArray jsonArray = new JSONArray();
|
JSONArray jsonArray = new JSONArray();
|
||||||
for (int i = 0; i < array.size(); i++) {
|
for (int i = 0; i < array.size(); i++) {
|
||||||
Images images = new Images();
|
Images images = new Images();
|
||||||
images.setImguid(array.getString(i));
|
images.setImguid(array.getString(i));
|
||||||
jsonArray.add(imgMapper.selectimg(images).get(0));
|
jsonArray.add(imgMapper.selectimg(images).get(0));
|
||||||
}
|
|
||||||
return jsonArray;
|
|
||||||
}
|
}
|
||||||
|
return jsonArray;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Album selectAlbum(Album album) {
|
public Album selectAlbum(Album album) {
|
||||||
return albumMapper.selectAlbum(album);
|
return albumMapper.selectAlbum(album);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer addAlbum(Album album) {
|
||||||
|
return albumMapper.addAlbum(album);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public Integer addAlbumForImgAndAlbumMapper(ImgAndAlbum imgAndAlbum) {
|
||||||
|
Integer tem = 0;
|
||||||
|
Integer r2 = andAlbumMapper.addImgAndAlbum(imgAndAlbum);
|
||||||
|
if (r2 > 0) {
|
||||||
|
tem = 1;
|
||||||
|
} else {
|
||||||
|
throw new CodeException("插入画廊数据失败,回滚");
|
||||||
}
|
}
|
||||||
|
return tem;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer addAlbum(Album album) {
|
public Integer deleteAlbum(String albumkey) {
|
||||||
return albumMapper.addAlbum(album);
|
return albumMapper.deleteAlbum(albumkey);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Album> selectAlbumURLList(Album album) {
|
||||||
|
return albumMapper.selectAlbumURLList(album);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer selectAlbumCount(Integer userid) {
|
||||||
|
return albumMapper.selectAlbumCount(userid);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer updateAlbum(Album album) {
|
||||||
|
return albumMapper.updateAlbum(album);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public Integer delete(String albumkey) {
|
||||||
|
Integer ret1 = albumMapper.deleteAlbum(albumkey);
|
||||||
|
if (ret1 > 0) {
|
||||||
|
ret1 = andAlbumMapper.deleteImgAndAlbumForKey(albumkey);
|
||||||
|
} else {
|
||||||
|
throw new CodeException("删除画廊失败。");
|
||||||
}
|
}
|
||||||
|
return ret1;
|
||||||
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public Integer addAlbumForImgAndAlbumMapper(ImgAndAlbum imgAndAlbum) {
|
public Integer deleteAll(String[] albumkeyArr) {
|
||||||
Integer tem = 0;
|
Integer ret1 = 0;
|
||||||
Integer r2 = andAlbumMapper.addImgAndAlbum(imgAndAlbum);
|
for (String s : albumkeyArr) {
|
||||||
if(r2>0){
|
ret1 = albumMapper.deleteAlbum(s);
|
||||||
tem = 1;
|
if (ret1 > 0) {
|
||||||
}else{
|
ret1 = andAlbumMapper.deleteImgAndAlbumForKey(s);
|
||||||
throw new CodeException("插入画廊数据失败,回滚");
|
} else {
|
||||||
}
|
throw new CodeException("删除画廊失败。");
|
||||||
return tem;
|
}
|
||||||
}
|
}
|
||||||
|
return ret1;
|
||||||
@Override
|
}
|
||||||
public Integer deleteAlbum(String albumkey) {
|
|
||||||
return albumMapper.deleteAlbum(albumkey);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Album> selectAlbumURLList(Album album) {
|
|
||||||
return albumMapper.selectAlbumURLList(album);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer selectAlbumCount(Integer userid) {
|
|
||||||
return albumMapper.selectAlbumCount(userid);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer updateAlbum(Album album) {
|
|
||||||
return albumMapper.updateAlbum(album);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public Integer delete(String albumkey) {
|
|
||||||
Integer ret1 = albumMapper.deleteAlbum(albumkey);
|
|
||||||
if(ret1>0){
|
|
||||||
ret1 = andAlbumMapper.deleteImgAndAlbumForKey(albumkey);
|
|
||||||
}else{
|
|
||||||
throw new CodeException("删除画廊失败。");
|
|
||||||
}
|
|
||||||
return ret1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public Integer deleteAll(String[] albumkeyArr) {
|
|
||||||
Integer ret1 = 0 ;
|
|
||||||
for (String s : albumkeyArr) {
|
|
||||||
ret1 = albumMapper.deleteAlbum(s);
|
|
||||||
if(ret1>0){
|
|
||||||
ret1 = andAlbumMapper.deleteImgAndAlbumForKey(s);
|
|
||||||
}else{
|
|
||||||
throw new CodeException("删除画廊失败。");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,42 +3,49 @@ package cn.hellohao.service.impl;
|
|||||||
import cn.hellohao.pojo.Images;
|
import cn.hellohao.pojo.Images;
|
||||||
import cn.hellohao.pojo.Keys;
|
import cn.hellohao.pojo.Keys;
|
||||||
import cn.hellohao.pojo.ReturnImage;
|
import cn.hellohao.pojo.ReturnImage;
|
||||||
import cn.hellohao.utils.*;
|
|
||||||
import com.qcloud.cos.COSClient;
|
import com.qcloud.cos.COSClient;
|
||||||
import com.qcloud.cos.ClientConfig;
|
import com.qcloud.cos.ClientConfig;
|
||||||
import com.qcloud.cos.auth.BasicCOSCredentials;
|
import com.qcloud.cos.auth.BasicCOSCredentials;
|
||||||
import com.qcloud.cos.auth.COSCredentials;
|
import com.qcloud.cos.auth.COSCredentials;
|
||||||
import com.qcloud.cos.exception.CosClientException;
|
import com.qcloud.cos.exception.CosClientException;
|
||||||
import com.qcloud.cos.exception.CosServiceException;
|
import com.qcloud.cos.exception.CosServiceException;
|
||||||
import com.qcloud.cos.model.*;
|
import com.qcloud.cos.model.ListObjectsRequest;
|
||||||
|
import com.qcloud.cos.model.ObjectListing;
|
||||||
|
import com.qcloud.cos.model.PutObjectRequest;
|
||||||
|
import com.qcloud.cos.model.PutObjectResult;
|
||||||
import com.qcloud.cos.region.Region;
|
import com.qcloud.cos.region.Region;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.io.FileInputStream;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class COSImageupload {
|
public class COSImageupload {
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(COSImageupload.class);
|
||||||
static COSClient cosClient;
|
static COSClient cosClient;
|
||||||
static Keys key;
|
static Keys key;
|
||||||
|
|
||||||
public ReturnImage ImageuploadCOS(Map<String, File> fileMap, String username,Integer keyID) {
|
public ReturnImage ImageuploadCOS(
|
||||||
|
Map<Map<String, String>, File> fileMap, String username, Integer keyID) {
|
||||||
ReturnImage returnImage = new ReturnImage();
|
ReturnImage returnImage = new ReturnImage();
|
||||||
File file = null;
|
File file = null;
|
||||||
Map<ReturnImage, Integer> ImgUrl = new HashMap<>();
|
FileInputStream stream = null;
|
||||||
try {
|
try {
|
||||||
for (Map.Entry<String, File> entry : fileMap.entrySet()) {
|
for (Map.Entry<Map<String, String>, File> entry : fileMap.entrySet()) {
|
||||||
String ShortUID = SetText.getShortUuid();
|
String prefix = entry.getKey().get("prefix");
|
||||||
|
String ShortUIDName = entry.getKey().get("name");
|
||||||
file = entry.getValue();
|
file = entry.getValue();
|
||||||
|
stream = new FileInputStream(file);
|
||||||
try {
|
try {
|
||||||
String bucketName = key.getBucketname();
|
String bucketName = key.getBucketname();
|
||||||
String userkey =username + "/" + ShortUID + "." + entry.getKey();
|
String userkey = username + "/" + ShortUIDName + "." + prefix;
|
||||||
PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, userkey, file);
|
PutObjectRequest putObjectRequest =
|
||||||
|
new PutObjectRequest(bucketName, userkey, stream,null);
|
||||||
PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
|
PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
|
||||||
returnImage.setImgname(userkey);
|
|
||||||
returnImage.setImgurl(key.getRequestAddress() + "/" + userkey);
|
|
||||||
returnImage.setImgSize(entry.getValue().length());
|
|
||||||
returnImage.setCode("200");
|
|
||||||
} catch (CosServiceException serverException) {
|
} catch (CosServiceException serverException) {
|
||||||
returnImage.setCode("400");
|
returnImage.setCode("400");
|
||||||
serverException.printStackTrace();
|
serverException.printStackTrace();
|
||||||
@@ -46,42 +53,45 @@ public class COSImageupload {
|
|||||||
returnImage.setCode("400");
|
returnImage.setCode("400");
|
||||||
clientException.printStackTrace();
|
clientException.printStackTrace();
|
||||||
}
|
}
|
||||||
|
try {if(stream!=null){stream.close();}} catch (Exception ex) { }
|
||||||
}
|
}
|
||||||
}catch(Exception e){
|
returnImage.setCode("200");
|
||||||
e.printStackTrace();
|
} catch (Exception e) {
|
||||||
|
try {if(stream!=null){stream.close();}} catch (Exception ex) { }
|
||||||
|
logger.error("COS协议上传时发生异常:",e);
|
||||||
returnImage.setCode("500");
|
returnImage.setCode("500");
|
||||||
}
|
}
|
||||||
return returnImage;
|
return returnImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Integer Initialize(Keys k) {
|
public static Integer Initialize(Keys k) {
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
if(k.getEndpoint()!=null && k.getAccessSecret()!=null && k.getEndpoint()!=null
|
if (StringUtils.isBlank(k.getAccessKey())
|
||||||
&& k.getBucketname()!=null && k.getRequestAddress()!=null ) {
|
|| StringUtils.isBlank(k.getAccessSecret())
|
||||||
if (!k.getEndpoint().equals("") && !k.getAccessSecret().equals("") && !k.getEndpoint().equals("")
|
|| StringUtils.isBlank(k.getEndpoint())
|
||||||
&& !k.getBucketname().equals("") && !k.getRequestAddress().equals("")) {
|
|| StringUtils.isBlank(k.getBucketname())
|
||||||
String secretId = k.getAccessKey();
|
|| StringUtils.isBlank(k.getRequestAddress())) {
|
||||||
String secretKey = k.getAccessSecret();
|
return -1;
|
||||||
COSCredentials cred = new BasicCOSCredentials(secretId, secretKey);
|
}
|
||||||
Region region = new Region(k.getEndpoint());
|
String secretId = k.getAccessKey();
|
||||||
ClientConfig clientConfig = new ClientConfig(region);
|
String secretKey = k.getAccessSecret();
|
||||||
COSClient cos = new COSClient(cred, clientConfig);
|
COSCredentials cred = new BasicCOSCredentials(secretId, secretKey);
|
||||||
ListObjectsRequest listObjectsRequest = new ListObjectsRequest();
|
Region region = new Region(k.getEndpoint());
|
||||||
listObjectsRequest.setBucketName(k.getBucketname());
|
ClientConfig clientConfig = new ClientConfig(region);
|
||||||
listObjectsRequest.setDelimiter("/");
|
COSClient cos = new COSClient(cred, clientConfig);
|
||||||
listObjectsRequest.setMaxKeys(1);
|
ListObjectsRequest listObjectsRequest = new ListObjectsRequest();
|
||||||
ObjectListing objectListing = null;
|
listObjectsRequest.setBucketName(k.getBucketname());
|
||||||
try {
|
listObjectsRequest.setDelimiter("/");
|
||||||
objectListing = cos.listObjects(listObjectsRequest);
|
listObjectsRequest.setMaxKeys(1);
|
||||||
ret = 1;
|
ObjectListing objectListing = null;
|
||||||
cosClient = cos;
|
try {
|
||||||
key = k;
|
objectListing = cos.listObjects(listObjectsRequest);
|
||||||
} catch (Exception e) {
|
ret = 1;
|
||||||
System.out.println("COS Object Is null");
|
cosClient = cos;
|
||||||
ret = -1;
|
key = k;
|
||||||
}
|
} catch (Exception e) {
|
||||||
}
|
System.out.println("COS Object Is null");
|
||||||
|
ret = -1;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -94,10 +104,6 @@ public class COSImageupload {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
b = false;
|
b = false;
|
||||||
}
|
}
|
||||||
return b ;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,16 +2,20 @@ 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.SysConfigService;
|
import cn.hellohao.service.SysConfigService;
|
||||||
import cn.hellohao.utils.*;
|
import cn.hellohao.utils.*;
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baidu.aip.contentcensor.AipContentCensor;
|
|
||||||
import com.baidu.aip.contentcensor.EImgType;
|
|
||||||
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.scheduling.annotation.Async;
|
||||||
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
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.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@@ -25,30 +29,27 @@ import java.util.*;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class ClientService {
|
public class ClientService {
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(ClientService.class);
|
||||||
|
@Autowired private ConfdataService confdataService;
|
||||||
|
@Autowired private SysConfigService sysConfigService;
|
||||||
|
@Autowired private UserMapper userMapper;
|
||||||
|
@Autowired private KeysMapper keysMapper;
|
||||||
|
@Autowired private UploadConfigMapper uploadConfigMapper;
|
||||||
|
@Autowired private ImgServiceImpl imgServiceImpl;
|
||||||
|
@Autowired private ImgTempService imgTempService;
|
||||||
|
@Autowired private GetSource getSource;
|
||||||
|
@Autowired private ImgViolationJudgeServiceImpl imgViolationJudgeService;
|
||||||
|
|
||||||
@Autowired
|
public Msg uploadImg(
|
||||||
private SysConfigService sysConfigService;
|
HttpServletRequest request, MultipartFile multipartFile, String email, String pass,Integer setday) {
|
||||||
@Autowired
|
|
||||||
private UserMapper userMapper;
|
|
||||||
@Autowired
|
|
||||||
private KeysMapper keysMapper;
|
|
||||||
@Autowired
|
|
||||||
private ConfigMapper configMapper;
|
|
||||||
@Autowired
|
|
||||||
private UploadConfigMapper uploadConfigMapper;
|
|
||||||
@Autowired
|
|
||||||
private ImgMapper imgMapper;
|
|
||||||
@Autowired
|
|
||||||
ImgreviewMapper imgreviewMapper;
|
|
||||||
|
|
||||||
|
|
||||||
public Msg uploadImg(HttpServletRequest request, MultipartFile multipartFile, String email, String pass ){
|
|
||||||
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");
|
||||||
|
String imageFileName = "未命名图像";
|
||||||
Integer sourceKeyId = 0;
|
Integer sourceKeyId = 0;
|
||||||
FileInputStream fis = null;
|
|
||||||
String md5key = null;
|
String md5key = null;
|
||||||
Integer setday = 0;
|
|
||||||
JSONObject jsonObject = new JSONObject();
|
JSONObject jsonObject = new JSONObject();
|
||||||
String userip = GetIPS.getIpAddr(request);
|
String userip = GetIPS.getIpAddr(request);
|
||||||
UploadConfig uploadConfig = uploadConfigMapper.getUpdateConfig();
|
UploadConfig uploadConfig = uploadConfigMapper.getUpdateConfig();
|
||||||
@@ -57,32 +58,72 @@ public class ClientService {
|
|||||||
msg.setInfo("管理员关闭了API接口");
|
msg.setInfo("管理员关闭了API接口");
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
imageFileName = multipartFile.getOriginalFilename();
|
||||||
File file = SetFiles.changeFile_new(multipartFile);
|
File file = SetFiles.changeFile_new(multipartFile);
|
||||||
|
FileInputStream stream = new FileInputStream(file);
|
||||||
User u2 = new User();
|
User u2 = new User();
|
||||||
if (!file.exists() || email == null || pass == null) {
|
if (!file.exists() || email == null || pass == null) {
|
||||||
msg.setCode("4005");
|
msg.setCode("4005");
|
||||||
msg.setInfo("必要参数不能为空");
|
msg.setInfo("必要参数不能为空");
|
||||||
|
try {
|
||||||
|
if(stream!=null){stream.close();}
|
||||||
|
file.delete();
|
||||||
|
} catch (Exception e) { }
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
if (uploadConfig.getBlacklist() != null) {
|
||||||
|
String[] iparr = uploadConfig.getBlacklist().split(";");
|
||||||
|
for (String s : iparr) {
|
||||||
|
if (s.equals(userip)) {
|
||||||
|
msg.setCode("4010");
|
||||||
|
msg.setInfo("你暂时不能上传");
|
||||||
|
try {
|
||||||
|
if(stream!=null){stream.close();}
|
||||||
|
file.delete();
|
||||||
|
} catch (Exception e) { }
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
u2.setEmail(email);
|
u2.setEmail(email);
|
||||||
u2.setPassword(Base64Encryption.encryptBASE64(pass.getBytes()));
|
u2.setPassword(Base64.getEncoder().encodeToString(pass.getBytes()));
|
||||||
User u = userMapper.getUsers(u2);
|
User u = userMapper.getUsers(u2);
|
||||||
if (null == u || u.getIsok() != 1) {
|
if (null == u || u.getIsok() != 1) {
|
||||||
msg.setCode("4006");
|
msg.setCode("4006");
|
||||||
msg.setInfo("用户信息不正确,账号异常");
|
msg.setInfo("用户信息不正确,账号异常");
|
||||||
|
try {
|
||||||
|
if(stream!=null){stream.close();}
|
||||||
|
file.delete();
|
||||||
|
} catch (Exception e) { }
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
String imguid = UUID.randomUUID().toString().replace("-", "");
|
String imguid = UUID.randomUUID().toString().replace("-", "");
|
||||||
Msg msg1 = updateImgCheck(u, uploadConfig);
|
Msg msg1 = updateImgCheck(u, uploadConfig);
|
||||||
if (!msg1.getCode().equals("300")) {
|
if (!msg1.getCode().equals("300")) {
|
||||||
|
try {
|
||||||
|
if(stream!=null){stream.close();}
|
||||||
|
file.delete();
|
||||||
|
} catch (Exception e) { }
|
||||||
return msg1;
|
return msg1;
|
||||||
}
|
}
|
||||||
|
JSONObject updateJson = JSONObject.parseObject(msg1.getData().toString());
|
||||||
|
final JSONObject groupJson = updateJson.getJSONObject("group");
|
||||||
|
final Group group = groupJson.toJavaObject(Group.class);
|
||||||
|
Long memory = updateJson.getLong("memory");
|
||||||
|
Long UsedTotleMemory = updateJson.getLong("UsedTotleMemory");
|
||||||
|
Long TotleMemory = updateJson.getLong("TotleMemory");
|
||||||
|
String updatePath = updateJson.getString("updatePath");
|
||||||
|
|
||||||
sourceKeyId = group.getKeyid();
|
sourceKeyId = group.getKeyid();
|
||||||
Keys key = keysMapper.selectKeys(sourceKeyId);
|
Keys key = keysMapper.selectKeys(sourceKeyId);
|
||||||
Long tmp = (memory == -1 ? -2 : UsedTotleMemory);
|
Long tmp = (memory == -1 ? -2 : UsedTotleMemory);
|
||||||
if (tmp >= memory) {
|
if (tmp >= memory) {
|
||||||
msg.setCode("4007");
|
msg.setCode("4007");
|
||||||
msg.setInfo(u == null ? "游客空间已用尽" : "您的可用空间不足");
|
msg.setInfo(u == null ? "游客空间已用尽" : "您的可用空间不足");
|
||||||
|
try {
|
||||||
|
if(stream!=null){stream.close();}
|
||||||
|
file.delete();
|
||||||
|
} catch (Exception e) { }
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
if (file.length() > TotleMemory) {
|
if (file.length() > TotleMemory) {
|
||||||
@@ -90,207 +131,177 @@ public class ClientService {
|
|||||||
System.err.println("最大限制:" + TotleMemory);
|
System.err.println("最大限制:" + TotleMemory);
|
||||||
msg.setCode("4008");
|
msg.setCode("4008");
|
||||||
msg.setInfo("图像超出系统限制大小");
|
msg.setInfo("图像超出系统限制大小");
|
||||||
|
try {
|
||||||
|
if(stream!=null){stream.close();}
|
||||||
|
file.delete();
|
||||||
|
} catch (Exception e) { }
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
try {
|
md5key = DigestUtils.md5Hex(stream);
|
||||||
fis = new FileInputStream(file);
|
// FileInputStream fis = null;
|
||||||
md5key = DigestUtils.md5Hex(fis);
|
// try {
|
||||||
} catch (Exception e) {
|
// fis = new FileInputStream(file);
|
||||||
e.printStackTrace();
|
// md5key = DigestUtils.md5Hex(fis);
|
||||||
System.out.println("未获取到图片的MD5,成成UUID");
|
// } catch (Exception e) {
|
||||||
}
|
// logger.error("未获取到图片的MD5,成成UUID异常:",e);
|
||||||
Msg fileMiME = TypeDict.FileMiME(file);
|
// }finally{
|
||||||
|
// try {
|
||||||
|
// if (null != fis)
|
||||||
|
// fis.close();
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// logger.error("ClientService-110异常",e);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
Msg fileMiME = TypeDict.FileMiME(stream);
|
||||||
if (!fileMiME.getCode().equals("200")) {
|
if (!fileMiME.getCode().equals("200")) {
|
||||||
msg.setCode("4009");
|
msg.setCode("4009");
|
||||||
msg.setInfo(fileMiME.getInfo());
|
msg.setInfo(fileMiME.getInfo());
|
||||||
|
try {
|
||||||
|
if(stream!=null){stream.close();}
|
||||||
|
file.delete();
|
||||||
|
} catch (Exception e) { }
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
if (md5key == null || md5key.equals("")) {
|
if (md5key == null || md5key.equals("")) {
|
||||||
md5key = UUID.randomUUID().toString().replace("-", "");
|
md5key = UUID.randomUUID().toString().replace("-", "");
|
||||||
}
|
}
|
||||||
String prefix = file.getName().substring(file.getName().lastIndexOf(".") + 1);
|
String prefix = file.getName().substring(file.getName().lastIndexOf(".") + 1);
|
||||||
if (uploadConfig.getBlacklist() != null) {
|
try {if(stream!=null){stream.close();}} catch (Exception ex) { }
|
||||||
String[] iparr = uploadConfig.getBlacklist().split(";");
|
|
||||||
for (String s : iparr) {
|
Images imgObj = new Images();
|
||||||
if (s.equals(userip)) {
|
String imgnameEd = null;
|
||||||
msg.setCode("4010");
|
Map<Map<String, String>, File> map = new HashMap<>();
|
||||||
msg.setInfo("你暂时不能上传");
|
String shortUuid_y = SetText.getShortUuid();
|
||||||
return msg;
|
String shortUuid_s = SetText.getShortUuid();
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(Integer.valueOf(sysConfigService.getstate().getCheckduplicate())==1) {
|
|
||||||
Images imaOBJ = new Images();
|
|
||||||
imaOBJ.setMd5key(md5key);
|
|
||||||
imaOBJ.setUserid(u.getId());
|
|
||||||
if (imgMapper.md5Count(imaOBJ) > 0) {
|
|
||||||
List<Images> images = imgMapper.selectImgUrlByMD5(md5key);
|
|
||||||
jsonObject.put("url", images.get(0).getImgurl());
|
|
||||||
jsonObject.put("name", file.getName());
|
|
||||||
jsonObject.put("size", images.get(0).getSizes());
|
|
||||||
msg.setData(jsonObject);
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Map<String, File> map = new HashMap<>();
|
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
map.put(prefix, file);
|
Map<String, String> m1 = new HashMap<>();
|
||||||
|
m1.put("prefix", prefix);
|
||||||
|
m1.put("name", shortUuid_y);
|
||||||
|
map.put(m1, file);
|
||||||
|
imgnameEd = updatePath + "/" + shortUuid_y + "." + prefix;
|
||||||
|
imgObj.setImgname(imgnameEd);
|
||||||
|
if (key.getStorageType().equals(5)) {
|
||||||
|
imgObj.setImgurl(confdata.getString("domain") + "/ota/" + imgnameEd);
|
||||||
|
} else if(key.getStorageType().equals(9) && key.getSysTransmit()){
|
||||||
|
imgObj.setImgurl(confdata.getString("domain") + "/w/" + shortUuid_y);
|
||||||
|
}else {
|
||||||
|
imgObj.setImgurl(key.getRequestAddress() + "/" + imgnameEd);
|
||||||
|
}
|
||||||
|
imgObj.setSizes(Long.toString(file.length()));
|
||||||
|
}else{
|
||||||
|
msg.setInfo("未获取到指定图像:110503");
|
||||||
|
msg.setCode("110503");
|
||||||
|
file.delete();
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
imgObj.setUpdatetime(df.format(new Date()));
|
||||||
|
imgObj.setSource(key.getId());
|
||||||
|
imgObj.setUserid(u == null ? 0 : u.getId());
|
||||||
|
if (setday == 1 || setday == 3 || setday == 7 || setday == 30) {
|
||||||
|
imgObj.setImgtype(1);
|
||||||
|
ImgTemp imgDataExp = new ImgTemp();
|
||||||
|
imgDataExp.setDeltime(UploadServicel.plusDay(setday));
|
||||||
|
imgDataExp.setImguid(imguid);
|
||||||
|
imgTempService.insertImgExp(imgDataExp);
|
||||||
|
} else {
|
||||||
|
imgObj.setImgtype(0);
|
||||||
|
}
|
||||||
|
imgObj.setAbnormal(userip);
|
||||||
|
imgObj.setMd5key(md5key);
|
||||||
|
imgObj.setImguid(imguid);
|
||||||
|
imgObj.setFormat(fileMiME.getData().toString());
|
||||||
|
imgObj.setShortlink(shortUuid_y);
|
||||||
|
imgObj.setBrieflink(shortUuid_s);
|
||||||
|
imgObj.setIdname(imageFileName);
|
||||||
|
Msg insertRet = imgServiceImpl.insertImgDataForCheck(imgObj,u,confdata,file.getName());
|
||||||
|
if (insertRet.getCode().equals("000")) {
|
||||||
|
file.delete();
|
||||||
|
return insertRet;
|
||||||
}
|
}
|
||||||
long stime = System.currentTimeMillis();
|
long stime = System.currentTimeMillis();
|
||||||
Map<ReturnImage, Integer> m = null;
|
ReturnImage returnImage = getSource.storageSource(key.getStorageType(), map, updatePath, key.getId());
|
||||||
ReturnImage returnImage = GetSource.storageSource(key.getStorageType(), map, updatePath, key.getId());
|
|
||||||
Images img = new Images();
|
|
||||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
||||||
if (returnImage.getCode().equals("200")) {
|
if (returnImage.getCode().equals("200")) {
|
||||||
String imgurl = returnImage.getImgurl();
|
|
||||||
Long imgsize = returnImage.getImgSize();
|
|
||||||
String imgname = returnImage.getImgname();
|
|
||||||
img.setImgurl(imgurl);
|
|
||||||
img.setUpdatetime(df.format(new Date()));
|
|
||||||
img.setSource(key.getId());
|
|
||||||
img.setUserid(u == null ? 0 : u.getId());
|
|
||||||
img.setSizes(imgsize.toString());
|
|
||||||
if (uploadConfig.getUrltype() == 2) {
|
|
||||||
img.setImgname(imgname);
|
|
||||||
} else {
|
|
||||||
img.setImgname(SetText.getSubString(imgname, key.getRequestAddress() + "/", ""));
|
|
||||||
}
|
|
||||||
img.setImgtype(setday > 0 ? 1 : 0);
|
|
||||||
img.setAbnormal(userip);
|
|
||||||
img.setMd5key(md5key);
|
|
||||||
img.setImguid(imguid);
|
|
||||||
img.setFormat(fileMiME.getData().toString());
|
|
||||||
userMapper.insertimg(img);
|
|
||||||
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", img.getImgurl());
|
jsonObject.put("url", imgObj.getImgurl());
|
||||||
jsonObject.put("name", imgname);
|
jsonObject.put("name", imgObj.getImgname());
|
||||||
jsonObject.put("size", img.getSizes());
|
jsonObject.put("size", imgObj.getSizes());
|
||||||
new Thread(() -> {
|
imgViolationJudgeService.LegalImageCheck(imgObj,key);
|
||||||
LegalImageCheck(img);
|
|
||||||
}).start();
|
|
||||||
} else {
|
} else {
|
||||||
|
imgServiceImpl.deleimgForImgUid(imgObj.getImguid());
|
||||||
msg.setCode("5001");
|
msg.setCode("5001");
|
||||||
msg.setInfo("上传服务内部错误");
|
msg.setInfo("上传服务内部错误");
|
||||||
|
file.delete();
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
file.delete();
|
file.delete();
|
||||||
msg.setData(jsonObject);
|
msg.setData(jsonObject);
|
||||||
return msg;
|
return msg;
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
|
||||||
msg.setCode("5001");
|
msg.setCode("5001");
|
||||||
msg.setInfo("Error for server:500");
|
msg.setInfo("Error for server:500");
|
||||||
|
logger.error("ClientService:Error for server-202行异常",e);
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public static Group group;
|
||||||
|
// public static Long memory;
|
||||||
|
// public static Long TotleMemory;
|
||||||
|
// public static Long UsedTotleMemory;
|
||||||
|
// public static String updatePath = "tourist";
|
||||||
|
|
||||||
public static Group group; //上传用户或游客的所属分组
|
private Msg updateImgCheck(User user, UploadConfig uploadConfig) {
|
||||||
public static Long memory;//上传用户或者游客的分配容量 memory
|
Msg msg = new Msg();
|
||||||
public static Long TotleMemory;//用户或者游客下可使用的总容量 //maxsize
|
JSONObject jsonObject = new JSONObject();
|
||||||
public static Long UsedTotleMemory;//用户或者游客已经用掉的总容量 //usermemory
|
String updatePath = "tourist";
|
||||||
public static String updatePath="tourist";
|
|
||||||
|
|
||||||
//判断用户 或 游客 当前上传图片的一系列校验
|
|
||||||
private Msg updateImgCheck(User user, UploadConfig uploadConfig){
|
|
||||||
final Msg msg = new Msg();
|
|
||||||
java.text.DateFormat dateFormat = null;
|
|
||||||
try {
|
try {
|
||||||
dateFormat = new SimpleDateFormat("yyyy/MM/dd");
|
Group group = GetCurrentSource.GetSource(user == null ? null : user.getId());
|
||||||
|
jsonObject.put("group",group);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
//用户没有登陆,值判断游客能不能上传即可
|
if (uploadConfig.getIsupdate() != 1) {
|
||||||
if(uploadConfig.getIsupdate()!=1){
|
|
||||||
msg.setCode("1000");
|
msg.setCode("1000");
|
||||||
msg.setInfo("系统已禁用游客上传");
|
msg.setInfo("系统已禁用游客上传");
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
group = GetCurrentSource.GetSource(null);
|
Long memory = Long.valueOf(uploadConfig.getVisitormemory()); // 单位 B 游客设置总量
|
||||||
memory = Long.valueOf(uploadConfig.getVisitormemory());//单位 B 游客设置总量
|
Long TotleMemory = Long.valueOf(uploadConfig.getFilesizetourists()); // 单位 B 游客单文件大小
|
||||||
TotleMemory = Long.valueOf(uploadConfig.getFilesizetourists());//单位 B 游客单文件大小
|
Long UsedTotleMemory =
|
||||||
UsedTotleMemory = imgMapper.getusermemory(0)==null?0L : imgMapper.getusermemory(0);//单位 B
|
imgServiceImpl.getusermemory(0) == null
|
||||||
|
? 0L
|
||||||
|
: imgServiceImpl.getusermemory(0); // 单位 B
|
||||||
|
jsonObject.put("memory",memory);
|
||||||
|
jsonObject.put("TotleMemory",TotleMemory);
|
||||||
|
jsonObject.put("UsedTotleMemory",UsedTotleMemory);
|
||||||
} else {
|
} else {
|
||||||
//判断用户能不能上传
|
// 判断用户能不能上传
|
||||||
if(uploadConfig.getUserclose()!=1){
|
if (uploadConfig.getUserclose() != 1) {
|
||||||
msg.setCode("1001");
|
msg.setCode("1001");
|
||||||
msg.setInfo("系统已禁用上传功能");
|
msg.setInfo("系统已禁用上传功能");
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
updatePath = user.getUsername();
|
updatePath = user.getUsername();
|
||||||
group= GetCurrentSource.GetSource(user.getId());
|
Long memory = Long.valueOf(user.getMemory()); // 单位 B
|
||||||
memory = Long.valueOf(user.getMemory());//单位 B
|
Long TotleMemory = Long.valueOf(uploadConfig.getFilesizeuser()); // 单位 B
|
||||||
TotleMemory = Long.valueOf(uploadConfig.getFilesizeuser());//单位 B
|
Long UsedTotleMemory =
|
||||||
UsedTotleMemory = imgMapper.getusermemory(user.getId())==null?0L:imgMapper.getusermemory(user.getId());//单位 B
|
imgServiceImpl.getusermemory(user.getId()) == null
|
||||||
|
? 0L
|
||||||
|
: imgServiceImpl.getusermemory(user.getId()); // 单位 B
|
||||||
|
jsonObject.put("memory",memory);
|
||||||
|
jsonObject.put("TotleMemory",TotleMemory);
|
||||||
|
jsonObject.put("UsedTotleMemory",UsedTotleMemory);
|
||||||
}
|
}
|
||||||
//判断上传的图片目录结构类型
|
// 判断上传的图片目录结构类型
|
||||||
if (uploadConfig.getUrltype() == 2) {
|
if (uploadConfig.getUrltype() == 2) {
|
||||||
updatePath = dateFormat.format(new Date());
|
jsonObject.put("updatePath",updatePath);
|
||||||
|
msg.setData(jsonObject);
|
||||||
}
|
}
|
||||||
msg.setCode("300");
|
msg.setCode("300");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
logger.error("ClientService-异常",e);
|
||||||
msg.setCode("500");
|
msg.setCode("500");
|
||||||
}
|
}
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
//图片鉴黄
|
|
||||||
private synchronized void LegalImageCheck(Images images){
|
|
||||||
System.out.println("非法图像鉴别进程启动");
|
|
||||||
Imgreview imgreview = null;
|
|
||||||
try {
|
|
||||||
imgreview = imgreviewMapper.selectByusing(1);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Print.warning("获取鉴别程序的时候发生错误");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
LegalImageCheckForBaiDu(imgreview,images);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LegalImageCheckForBaiDu(Imgreview imgreview,Images images){
|
|
||||||
if(imgreview.getUsing()==1){
|
|
||||||
try {
|
|
||||||
AipContentCensor client = new AipContentCensor(imgreview.getAppId(), imgreview.getApiKey(), imgreview.getSecretKey());
|
|
||||||
client.setConnectionTimeoutInMillis(5000);
|
|
||||||
client.setSocketTimeoutInMillis(30000);
|
|
||||||
org.json.JSONObject res = client.antiPorn(images.getImgurl());
|
|
||||||
res = client.imageCensorUserDefined(images.getImgurl(), EImgType.URL, null);
|
|
||||||
com.alibaba.fastjson.JSONArray jsonArray = JSON.parseArray("[" + res.toString() + "]");
|
|
||||||
for (Object o : jsonArray) {
|
|
||||||
JSONObject jsonObject = (JSONObject) o;
|
|
||||||
com.alibaba.fastjson.JSONArray data = jsonObject.getJSONArray("data");
|
|
||||||
Integer conclusionType = jsonObject.getInteger("conclusionType");
|
|
||||||
if(conclusionType!=null){
|
|
||||||
if (conclusionType == 2) {
|
|
||||||
for (Object datum : data) {
|
|
||||||
JSONObject imgdata = (JSONObject) datum;
|
|
||||||
if (imgdata.getInteger("type") == 1) {
|
|
||||||
Images img = new Images();
|
|
||||||
img.setImgname(images.getImgname());
|
|
||||||
img.setViolation("1[1]");
|
|
||||||
imgMapper.setImg(img);
|
|
||||||
Imgreview imgv = new Imgreview();
|
|
||||||
imgv.setId(1);
|
|
||||||
Integer count = imgreview.getCount();
|
|
||||||
System.out.println("违法图片总数:" + count);
|
|
||||||
imgv.setCount(count + 1);
|
|
||||||
imgreviewMapper.updateByPrimaryKeySelective(imgv);
|
|
||||||
System.err.println("存在非法图片,进行处理操作");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}catch (Exception e){
|
|
||||||
System.out.println("图像鉴黄线程执行过程中出现异常");
|
|
||||||
e.printStackTrace();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package cn.hellohao.service.impl;
|
||||||
|
|
||||||
|
import cn.hellohao.dao.ConfdataMapper;
|
||||||
|
import cn.hellohao.pojo.Confdata;
|
||||||
|
import cn.hellohao.service.ConfdataService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ConfdataServiceImpl implements ConfdataService {
|
||||||
|
@Autowired
|
||||||
|
private ConfdataMapper confdataMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Confdata selectConfdata(String key) {
|
||||||
|
return confdataMapper.selectConfdata(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer updateConfdata(Confdata confdata) {
|
||||||
|
return confdataMapper.updateConfdata(confdata);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
package cn.hellohao.service.impl;
|
|
||||||
|
|
||||||
import cn.hellohao.dao.ConfigMapper;
|
|
||||||
import cn.hellohao.pojo.Config;
|
|
||||||
import cn.hellohao.pojo.Images;
|
|
||||||
import cn.hellohao.service.ConfigService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class ConfigServiceImpl implements ConfigService {
|
|
||||||
@Autowired
|
|
||||||
private ConfigMapper configMapper;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Config getSourceype() {
|
|
||||||
return configMapper.getSourceype();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer setSourceype(Config config) {
|
|
||||||
return configMapper.setSourceype(config);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,131 +0,0 @@
|
|||||||
package cn.hellohao.service.impl;
|
|
||||||
|
|
||||||
import cn.hellohao.pojo.Images;
|
|
||||||
import cn.hellohao.pojo.Keys;
|
|
||||||
import cn.hellohao.pojo.ReturnImage;
|
|
||||||
import cn.hellohao.utils.FTPUtils;
|
|
||||||
import cn.hellohao.utils.Print;
|
|
||||||
import cn.hellohao.utils.SetText;
|
|
||||||
import org.apache.commons.net.ftp.FTPClient;
|
|
||||||
import org.apache.commons.net.ftp.FTPReply;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class FTPImageupload {
|
|
||||||
static Keys key;
|
|
||||||
|
|
||||||
public ReturnImage ImageuploadFTP(Map<String, File> fileMap, String username,Integer keyID) {
|
|
||||||
ReturnImage returnImage = new ReturnImage();
|
|
||||||
String[] host = key.getEndpoint().split("\\:");
|
|
||||||
String h = host[0];
|
|
||||||
Integer p = Integer.parseInt(host[1]);
|
|
||||||
FTPUtils ftps = new FTPUtils(h, p, key.getAccessKey(), key.getAccessSecret());
|
|
||||||
boolean flag = ftps.open();
|
|
||||||
File file = null;
|
|
||||||
Map<ReturnImage, Integer> ImgUrl = new HashMap<>();
|
|
||||||
ftps.mkDir(File.separator+username);
|
|
||||||
try {
|
|
||||||
for (Map.Entry<String, File> entry : fileMap.entrySet()) {
|
|
||||||
String ShortUID = SetText.getShortUuid();
|
|
||||||
file = entry.getValue();
|
|
||||||
String userkey =username + "/"+ ShortUID + "." + entry.getKey();
|
|
||||||
if (flag) {
|
|
||||||
boolean isUpload = ftps.upload(file, "/" + userkey, "");
|
|
||||||
if(isUpload){
|
|
||||||
returnImage.setImgname(userkey);
|
|
||||||
returnImage.setImgurl(key.getRequestAddress() + "/"+ userkey);
|
|
||||||
returnImage.setImgSize(entry.getValue().length());
|
|
||||||
returnImage.setCode("200");
|
|
||||||
}else{
|
|
||||||
returnImage.setCode("500");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Print.Normal("要上传的文件路径:/"+userkey);
|
|
||||||
}
|
|
||||||
}catch (Exception e){
|
|
||||||
e.printStackTrace();
|
|
||||||
returnImage.setCode("500");
|
|
||||||
}
|
|
||||||
return returnImage;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Integer Initialize(Keys k) {
|
|
||||||
int ret = -1;
|
|
||||||
if(k.getEndpoint()!=null && k.getAccessSecret()!=null && k.getEndpoint()!=null && k.getRequestAddress()!=null ) {
|
|
||||||
if(!k.getEndpoint().equals("") && !k.getAccessSecret().equals("") && !k.getEndpoint().equals("") && !k.getRequestAddress().equals("") ) {
|
|
||||||
FTPClient ftp = new FTPClient();
|
|
||||||
ftp.setConnectTimeout(0);
|
|
||||||
int flag = k.getEndpoint().indexOf(":");
|
|
||||||
if(flag>0){
|
|
||||||
String[] host = k.getEndpoint().split("\\:");
|
|
||||||
String h = host[0];
|
|
||||||
Integer p = Integer.parseInt(host[1]);
|
|
||||||
try {
|
|
||||||
if(!ftp.isConnected()){
|
|
||||||
ftp.connect(h,p);
|
|
||||||
}
|
|
||||||
ftp.login(k.getAccessKey(), k.getAccessSecret());
|
|
||||||
int reply = ftp.getReplyCode();
|
|
||||||
if (!FTPReply.isPositiveCompletion(reply)) {
|
|
||||||
System.out.println("FTP Object Is null");
|
|
||||||
ftp.disconnect();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
ret = 1;
|
|
||||||
key = k;
|
|
||||||
} catch (IOException e) {
|
|
||||||
System.out.println("FTP Object Is null");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void fuzhi(String p1,String p2){
|
|
||||||
String a=p1;
|
|
||||||
try{
|
|
||||||
File afile=new File(a);
|
|
||||||
File bfile=new File(p2);//定义一个复制后的文件路径
|
|
||||||
bfile.createNewFile();
|
|
||||||
FileInputStream c=new FileInputStream(afile);
|
|
||||||
FileOutputStream d=new FileOutputStream(bfile);
|
|
||||||
byte[] date=new byte[512];
|
|
||||||
int i=0;
|
|
||||||
while((i=c.read(date))>0){
|
|
||||||
d.write(date);
|
|
||||||
}
|
|
||||||
c.close();
|
|
||||||
d.close();
|
|
||||||
System.out.println("文件复制成功");}
|
|
||||||
catch(IOException e){
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean delFTP(Integer keyID, Images images) {
|
|
||||||
boolean b = true;
|
|
||||||
try {
|
|
||||||
String[] host = key.getEndpoint().split("\\:");
|
|
||||||
String h = host[0];
|
|
||||||
Integer p = Integer.parseInt(host[1]);
|
|
||||||
//创建FTP客户端,所有的操作都基于FTPClinet
|
|
||||||
FTPUtils ftps = new FTPUtils(h, p, key.getAccessKey(), key.getAccessSecret());
|
|
||||||
ftps.open();
|
|
||||||
b = ftps.deleteFile(images.getImgname());
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
b = false;
|
|
||||||
}
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
package cn.hellohao.service.impl;
|
||||||
|
|
||||||
|
import cn.hellohao.pojo.Images;
|
||||||
|
import cn.hellohao.pojo.Keys;
|
||||||
|
import cn.hellohao.pojo.ReturnImage;
|
||||||
|
import cn.hutool.extra.ftp.Ftp;
|
||||||
|
import cn.hutool.extra.ftp.FtpMode;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.commons.net.ftp.FTP;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class FtpServiceImpl {
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(FtpServiceImpl.class);
|
||||||
|
private Keys key;
|
||||||
|
|
||||||
|
public static int Initialize(Keys k) {
|
||||||
|
int ret = -1;
|
||||||
|
try{
|
||||||
|
if (StringUtils.isBlank(k.getAccessKey())
|
||||||
|
|| StringUtils.isBlank(k.getAccessSecret())
|
||||||
|
|| StringUtils.isBlank(k.getEndpoint())
|
||||||
|
|| StringUtils.isBlank(k.getRequestAddress())){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
Charset charset = StandardCharsets.UTF_8;//Charset.forName("UTF-8");
|
||||||
|
String[] hostArr = k.getEndpoint().split("\\:");
|
||||||
|
String host = hostArr[0];
|
||||||
|
Integer port = Integer.parseInt(hostArr[1]);
|
||||||
|
Ftp ftp = new Ftp(host, port, k.getAccessKey(), k.getAccessSecret(), charset);
|
||||||
|
ftp.getClient().type(FTP.BINARY_FILE_TYPE);
|
||||||
|
ftp.setMode(FtpMode.Passive);
|
||||||
|
return 1;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ReturnImage FtpUploadFile(
|
||||||
|
Map<Map<String, String>, File> fileMap, String username, Integer keyID) {
|
||||||
|
ReturnImage returnImage = new ReturnImage();
|
||||||
|
Ftp ftp = null;
|
||||||
|
try {
|
||||||
|
if (null == key) {
|
||||||
|
System.out.println("FTP = 存储源对象为空");
|
||||||
|
returnImage.setCode("500");
|
||||||
|
return returnImage;
|
||||||
|
}
|
||||||
|
Charset charset = StandardCharsets.UTF_8;//Charset.forName("UTF-8");
|
||||||
|
String[] hostArr = key.getEndpoint().split("\\:");
|
||||||
|
String host = hostArr[0];
|
||||||
|
Integer port = Integer.parseInt(hostArr[1]);
|
||||||
|
ftp = new Ftp(host, port, key.getAccessKey(), key.getAccessSecret(), charset);
|
||||||
|
ftp.getClient().type(FTP.BINARY_FILE_TYPE);
|
||||||
|
ftp.setMode(FtpMode.Passive);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
System.out.println("FTP = 存储源对象为空");
|
||||||
|
returnImage.setCode("500");
|
||||||
|
return returnImage;
|
||||||
|
}
|
||||||
|
File file = null;
|
||||||
|
FileInputStream stream = null;
|
||||||
|
try {
|
||||||
|
for (Map.Entry<Map<String, String>, File> entry : fileMap.entrySet()) {
|
||||||
|
String prefix = entry.getKey().get("prefix");
|
||||||
|
String ShortUIDName = entry.getKey().get("name");
|
||||||
|
file = entry.getValue();
|
||||||
|
stream = new FileInputStream(file);
|
||||||
|
boolean isUpload = ftp.upload(
|
||||||
|
"/" + username,
|
||||||
|
ShortUIDName + "." + prefix,
|
||||||
|
stream);
|
||||||
|
if (!isUpload) {
|
||||||
|
returnImage.setCode("400");
|
||||||
|
}
|
||||||
|
try {if(stream!=null){stream.close();}} catch (Exception e) { }
|
||||||
|
}
|
||||||
|
returnImage.setCode("200");
|
||||||
|
} catch (Exception e) {
|
||||||
|
try {if(stream!=null){stream.close();}} catch (Exception ex) { }
|
||||||
|
logger.error("FTP发生异常:",e);
|
||||||
|
returnImage.setCode("500");
|
||||||
|
}
|
||||||
|
return returnImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean delFTP(Integer keyID, Images images) {
|
||||||
|
boolean b = true;
|
||||||
|
Ftp ftp = null;
|
||||||
|
try {
|
||||||
|
Charset charset = StandardCharsets.UTF_8;//Charset.forName("UTF-8");
|
||||||
|
String[] hostArr = key.getEndpoint().split("\\:");
|
||||||
|
String host = hostArr[0];
|
||||||
|
Integer port = Integer.parseInt(hostArr[1]);
|
||||||
|
ftp = new Ftp(host, port, key.getAccessKey(), key.getAccessSecret(), charset);
|
||||||
|
b = ftp.delFile(images.getImgname());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
b = false;
|
||||||
|
}
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -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
|
||||||
@@ -21,7 +27,12 @@ public class ImgServiceImpl implements ImgService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer deleimg(Integer id) {
|
public Integer insertImgData(Images images) {
|
||||||
|
return imgMapper.insertImgData(images);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Integer deleimg(Long id) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return imgMapper.deleimg(id);
|
return imgMapper.deleimg(id);
|
||||||
}
|
}
|
||||||
@@ -31,10 +42,20 @@ public class ImgServiceImpl implements ImgService {
|
|||||||
return imgMapper.deleimgForImgUid(imguid);
|
return imgMapper.deleimgForImgUid(imguid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Images selectByPrimaryKey(Integer id) {
|
public Images selectByPrimaryKey(Long id) {
|
||||||
return imgMapper.selectByPrimaryKey(id);
|
return imgMapper.selectByPrimaryKey(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Images selectImgByBrieflink(String brieflink) {
|
||||||
|
return imgMapper.selectImgByBrieflink(brieflink);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Images selectImgByShortlink(String shortlink) {
|
||||||
|
return imgMapper.selectImgByShortlink(shortlink);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer counts(Integer userid) {
|
public Integer counts(Integer userid) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
@@ -58,7 +79,7 @@ public class ImgServiceImpl implements ImgService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer deleall(Integer id) {
|
public Integer deleall(Long id) {
|
||||||
return imgMapper.deleall(id);
|
return imgMapper.deleall(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,8 +104,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
|
||||||
@@ -112,4 +133,37 @@ 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==null?0:user.getId());
|
||||||
|
img.setMd5key(images.getMd5key());
|
||||||
|
List<Images> list = imgMapper.selectImgUrlByMD5(img);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,116 @@
|
|||||||
|
package cn.hellohao.service.impl;
|
||||||
|
|
||||||
|
import cn.hellohao.dao.ImgMapper;
|
||||||
|
import cn.hellohao.dao.ImgreviewMapper;
|
||||||
|
import cn.hellohao.pojo.Images;
|
||||||
|
import cn.hellohao.pojo.Imgreview;
|
||||||
|
import cn.hellohao.pojo.Keys;
|
||||||
|
import cn.hellohao.pojo.Msg;
|
||||||
|
import cn.hellohao.utils.FirstRun;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.baidu.aip.contentcensor.AipContentCensor;
|
||||||
|
import com.baidu.aip.contentcensor.EImgType;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ImgViolationJudgeServiceImpl {
|
||||||
|
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(FirstRun.class);
|
||||||
|
@Autowired
|
||||||
|
ImgreviewServiceImpl imgreviewService;
|
||||||
|
@Autowired ImgMapper imgMapper;
|
||||||
|
@Autowired deleImages deleimages;
|
||||||
|
@Autowired private ImgreviewMapper imgreviewMapper;
|
||||||
|
|
||||||
|
|
||||||
|
//synchronized
|
||||||
|
@Async("taskExecutor")
|
||||||
|
public void LegalImageCheck(Images images, Keys keys) {
|
||||||
|
Imgreview imgreview = null;
|
||||||
|
try {
|
||||||
|
imgreview = imgreviewService.selectByusing(1);
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("获取鉴别程序的时候发生错误");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
// 判断哪个鉴别平台
|
||||||
|
if (null != imgreview) {
|
||||||
|
LegalImageCheckForBaiDu(imgreview, images, keys);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LegalImageCheckForBaiDu(Imgreview imgreview, Images images, Keys keys) {
|
||||||
|
// Imgreview imgreview = imgreviewService.selectByPrimaryKey(1);
|
||||||
|
if (imgreview.getUsing() == 1) {
|
||||||
|
logger.info("非法图像鉴别进程启动-BaiDu");
|
||||||
|
try {
|
||||||
|
AipContentCensor client =
|
||||||
|
new AipContentCensor(
|
||||||
|
imgreview.getAppId(),
|
||||||
|
imgreview.getApiKey(),
|
||||||
|
imgreview.getSecretKey());
|
||||||
|
client.setConnectionTimeoutInMillis(5000);
|
||||||
|
client.setSocketTimeoutInMillis(30000);
|
||||||
|
// res = client.antiPorn(images.getImgurl());
|
||||||
|
org.json.JSONObject res = client.imageCensorUserDefined(images.getImgurl(), EImgType.URL, null);
|
||||||
|
logger.info("返回的鉴黄json:" + res.toString());
|
||||||
|
com.alibaba.fastjson.JSONArray jsonArray =
|
||||||
|
JSON.parseArray("[" + res.toString() + "]");
|
||||||
|
|
||||||
|
for (Object o : jsonArray) {
|
||||||
|
JSONObject jsonObject =
|
||||||
|
(JSONObject) o;
|
||||||
|
com.alibaba.fastjson.JSONArray data = jsonObject.getJSONArray("data");
|
||||||
|
Integer conclusionType = jsonObject.getInteger("conclusionType");
|
||||||
|
if (conclusionType != null) {
|
||||||
|
if (conclusionType == 2) {
|
||||||
|
// 1:合规,2:不合规,3:疑似,4:审核失败
|
||||||
|
for (Object datum : data) {
|
||||||
|
JSONObject imgdata =
|
||||||
|
(JSONObject) datum;
|
||||||
|
if (imgdata.getInteger("type") == 1) {
|
||||||
|
logger.info("存在非法图片,进行处理操作");
|
||||||
|
// type参数
|
||||||
|
// 0:百度官方违禁图库、1:色情识别、2:暴恐识别、3:恶心图识别、4:广告检测、5:政治敏感识别、6:图像质量检测、7:用户图像黑名单、8:用户图像白名单、10:用户头像审核、11:百度官方违禁词库、12:图文审核、13:自定义文本黑名单、14:自定义文本白名单、15:EasyDL自定义模型、16:敏感旗帜标志识别、21:不良场景识别、24:直播场景审核
|
||||||
|
// 存在非法图片,进行处理操作
|
||||||
|
Images img = new Images();
|
||||||
|
img.setImgname(images.getImgname());
|
||||||
|
img.setViolation("1[1]"); // 数字是鉴别平台的主键ID,括号是非法的类型,参考上面的注释
|
||||||
|
imgMapper.setImg(img);
|
||||||
|
// 计入总数
|
||||||
|
Imgreview imgv = new Imgreview();
|
||||||
|
imgv.setId(1);
|
||||||
|
Integer count = imgreview.getCount();
|
||||||
|
imgv.setCount(count + 1);
|
||||||
|
imgreviewMapper.updateByPrimaryKeySelective(imgv);
|
||||||
|
Images imgObj =
|
||||||
|
imgMapper.selectImgUrlByImgUID(images.getImguid());
|
||||||
|
Msg dele = deleimages.dele2(Long.toString(imgObj.getId()));
|
||||||
|
List<Long> ids = (List<Long>) dele.getData();
|
||||||
|
if (!ids.contains(imgObj.getId())) {
|
||||||
|
logger.error("检测到违规图像,但是数据库删除失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("图像鉴黄线程执行过程中出现异常");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -4,6 +4,8 @@ import cn.hellohao.auth.filter.SubjectFilter;
|
|||||||
import cn.hellohao.dao.KeysMapper;
|
import cn.hellohao.dao.KeysMapper;
|
||||||
import cn.hellohao.pojo.Keys;
|
import cn.hellohao.pojo.Keys;
|
||||||
import cn.hellohao.utils.Print;
|
import cn.hellohao.utils.Print;
|
||||||
|
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.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.CommandLineRunner;
|
import org.springframework.boot.CommandLineRunner;
|
||||||
@@ -23,6 +25,7 @@ import java.util.List;
|
|||||||
@Order(2)
|
@Order(2)
|
||||||
public class InitializationStorage implements CommandLineRunner {
|
public class InitializationStorage implements CommandLineRunner {
|
||||||
|
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(InitializationStorage.class);
|
||||||
@Value("${CROS_ALLOWED_ORIGINS}")
|
@Value("${CROS_ALLOWED_ORIGINS}")
|
||||||
private String allowedOrigins;
|
private String allowedOrigins;
|
||||||
|
|
||||||
@@ -30,7 +33,7 @@ public class InitializationStorage implements CommandLineRunner {
|
|||||||
private KeysMapper keysMapper;
|
private KeysMapper keysMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(String... args) throws Exception {
|
public void run(String... args) {
|
||||||
SubjectFilter.WEBHOST = allowedOrigins;
|
SubjectFilter.WEBHOST = allowedOrigins;
|
||||||
String name = ManagementFactory.getRuntimeMXBean().getName();
|
String name = ManagementFactory.getRuntimeMXBean().getName();
|
||||||
String pid = name.split("@")[0];
|
String pid = name.split("@")[0];
|
||||||
@@ -41,21 +44,22 @@ public class InitializationStorage implements CommandLineRunner {
|
|||||||
List<Keys> keylist = keysMapper.getKeys();
|
List<Keys> keylist = keysMapper.getKeys();
|
||||||
for (Keys key : keylist) {
|
for (Keys key : keylist) {
|
||||||
if(key.getStorageType()!=0 && key.getStorageType()!=null){
|
if(key.getStorageType()!=0 && key.getStorageType()!=null){
|
||||||
int ret =0;
|
|
||||||
if(key.getStorageType()==1){
|
if(key.getStorageType()==1){
|
||||||
ret =NOSImageupload.Initialize(key);
|
NOSImageupload.Initialize(key);
|
||||||
}else if (key.getStorageType()==2){
|
}else if (key.getStorageType()==2){
|
||||||
ret =OSSImageupload.Initialize(key);
|
OSSImageupload.Initialize(key);
|
||||||
}else if(key.getStorageType()==3){
|
}else if(key.getStorageType()==3){
|
||||||
ret = USSImageupload.Initialize(key);
|
USSImageupload.Initialize(key);
|
||||||
}else if(key.getStorageType()==4){
|
}else if(key.getStorageType()==4){
|
||||||
ret = KODOImageupload.Initialize(key);
|
KODOImageupload.Initialize(key);
|
||||||
}else if(key.getStorageType()==6){
|
}else if(key.getStorageType()==6){
|
||||||
ret = COSImageupload.Initialize(key);
|
COSImageupload.Initialize(key);
|
||||||
}else if(key.getStorageType()==7){
|
}else if(key.getStorageType()==7){
|
||||||
ret = FTPImageupload.Initialize(key);
|
FtpServiceImpl.Initialize(key);
|
||||||
}else if(key.getStorageType()==8){
|
}else if(key.getStorageType()==8){
|
||||||
ret = UFileImageupload.Initialize(key);
|
S3Imageupload.Initialize(key);
|
||||||
|
}else if(key.getStorageType()==9){
|
||||||
|
WebDAVImageupload.Initialize(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,67 +1,54 @@
|
|||||||
package cn.hellohao.service.impl;
|
package cn.hellohao.service.impl;
|
||||||
|
|
||||||
import cn.hellohao.config.GlobalConstant;
|
|
||||||
import cn.hellohao.pojo.Images;
|
import cn.hellohao.pojo.Images;
|
||||||
import cn.hellohao.pojo.Keys;
|
import cn.hellohao.pojo.Keys;
|
||||||
import cn.hellohao.pojo.ReturnImage;
|
import cn.hellohao.pojo.ReturnImage;
|
||||||
import cn.hellohao.pojo.UploadConfig;
|
|
||||||
import cn.hellohao.utils.*;
|
|
||||||
import com.aliyun.oss.OSSClient;
|
|
||||||
import com.aliyun.oss.model.ObjectMetadata;
|
|
||||||
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;
|
||||||
import com.qiniu.util.Auth;
|
import com.qiniu.util.Auth;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Date;
|
import java.io.FileInputStream;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class KODOImageupload {
|
public class KODOImageupload {
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(KODOImageupload.class);
|
||||||
static String upToken;
|
static String upToken;
|
||||||
static BucketManager bucketManager;
|
static BucketManager bucketManager;
|
||||||
static Keys key;
|
static Keys key;
|
||||||
|
|
||||||
public ReturnImage ImageuploadKODO(Map<String, File> fileMap, String username, Integer keyID){
|
public ReturnImage ImageuploadKODO(
|
||||||
|
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);
|
||||||
File file = null;
|
File file = null;
|
||||||
|
FileInputStream stream = null;
|
||||||
try {
|
try {
|
||||||
for (Map.Entry<String, File> entry : fileMap.entrySet()) {
|
for (Map.Entry<Map<String, String>, File> entry : fileMap.entrySet()) {
|
||||||
String ShortUID = SetText.getShortUuid();
|
String prefix = entry.getKey().get("prefix");
|
||||||
|
String ShortUIDName = entry.getKey().get("name");
|
||||||
file = entry.getValue();
|
file = entry.getValue();
|
||||||
|
stream = new FileInputStream(file);
|
||||||
try {
|
try {
|
||||||
Response response = uploadManager.put(file,username + "/" + ShortUID + "." + entry.getKey(),upToken);
|
Response response = uploadManager.put(stream,username + "/" + ShortUIDName + "." + prefix, upToken, null, null);
|
||||||
DefaultPutRet putRet = new Gson().fromJson(response.bodyString(), DefaultPutRet.class);
|
DefaultPutRet putRet =
|
||||||
returnImage.setImgname(username + "/" + ShortUID + "." + entry.getKey());
|
new Gson().fromJson(response.bodyString(), DefaultPutRet.class);
|
||||||
returnImage.setImgurl(key.getRequestAddress() + "/" + username + "/" + ShortUID + "." + entry.getKey());
|
|
||||||
returnImage.setImgSize(entry.getValue().length());
|
|
||||||
returnImage.setCode("200");
|
|
||||||
} catch (QiniuException ex) {
|
} catch (QiniuException ex) {
|
||||||
returnImage.setCode("400");
|
returnImage.setCode("400");
|
||||||
Response r = ex.response;
|
Response r = ex.response;
|
||||||
@@ -71,9 +58,12 @@ public class KODOImageupload {
|
|||||||
} catch (QiniuException ex2) {
|
} catch (QiniuException ex2) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
try {if(stream!=null){stream.close();}} catch (Exception ex) { }
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
returnImage.setCode("200");
|
||||||
e.printStackTrace();
|
} catch (Exception e) {
|
||||||
|
try {if(stream!=null){stream.close();}} catch (Exception ex) { }
|
||||||
|
logger.error("KODO发生异常:",e);
|
||||||
returnImage.setCode("500");
|
returnImage.setCode("500");
|
||||||
}
|
}
|
||||||
return returnImage;
|
return returnImage;
|
||||||
@@ -81,40 +71,30 @@ public class KODOImageupload {
|
|||||||
|
|
||||||
public static Integer Initialize(Keys k) {
|
public static Integer Initialize(Keys k) {
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
if (k.getEndpoint() != null && k.getAccessSecret() != null && k.getEndpoint() != null
|
if (StringUtils.isBlank(k.getAccessKey())
|
||||||
&& k.getBucketname() != null && k.getRequestAddress() != null) {
|
|| StringUtils.isBlank(k.getAccessSecret())
|
||||||
if (!k.getEndpoint().equals("") && !k.getAccessSecret() .equals("") && !k.getEndpoint() .equals("")
|
|| StringUtils.isBlank(k.getEndpoint())
|
||||||
&& !k.getBucketname().equals("") && !k.getRequestAddress() .equals("")) {
|
|| StringUtils.isBlank(k.getBucketname())
|
||||||
Configuration cfg;
|
|| StringUtils.isBlank(k.getRequestAddress())) {
|
||||||
if (k.getEndpoint().equals("1")) {
|
return -1;
|
||||||
cfg = new Configuration(Zone.zone0());
|
}
|
||||||
} else if (k.getEndpoint().equals("2")) {
|
Configuration cfg = new Configuration(Region.autoRegion());
|
||||||
cfg = new Configuration(Zone.zone1());
|
UploadManager uploadManager = new UploadManager(cfg);
|
||||||
} else if (k.getEndpoint().equals("3")) {
|
Auth auth = Auth.create(k.getAccessKey(), k.getAccessSecret());
|
||||||
cfg = new Configuration(Zone.zone2());
|
String upToken = auth.uploadToken(k.getBucketname(), null, 7200, null);
|
||||||
} else if (k.getEndpoint().equals("4")) {
|
BucketManager BM = new BucketManager(auth, cfg);
|
||||||
cfg = new Configuration(Zone.zoneNa0());
|
BucketManager.FileListIterator fileListIterator = null;
|
||||||
} else {
|
try {
|
||||||
cfg = new Configuration(Zone.zoneAs0());
|
fileListIterator = BM.createFileListIterator(k.getBucketname(), "", 1, "/");
|
||||||
}
|
FileInfo[] items = fileListIterator.next();
|
||||||
UploadManager uploadManager = new UploadManager(cfg);
|
if (items != null) {
|
||||||
Auth auth = Auth.create(k.getAccessKey(), k.getAccessSecret());
|
ret = 1;
|
||||||
String upToken = auth.uploadToken(k.getBucketname(),null,7200,null);//auth.uploadToken(k.getBucketname());
|
bucketManager = BM;
|
||||||
BucketManager bmObj = new BucketManager(auth, cfg);
|
key = k;
|
||||||
BucketManager.FileListIterator fileListIterator = null;
|
|
||||||
try {
|
|
||||||
fileListIterator = bmObj.createFileListIterator(k.getBucketname(), "", 1, "/");
|
|
||||||
FileInfo[] items = fileListIterator.next();
|
|
||||||
if(items!=null){
|
|
||||||
ret = 1;
|
|
||||||
bucketManager = bmObj;
|
|
||||||
key = k;
|
|
||||||
}
|
|
||||||
}catch (Exception e){
|
|
||||||
System.out.println("KODO Object Is null");
|
|
||||||
ret = -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println("KODO Object Is null");
|
||||||
|
ret = -1;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -128,6 +108,4 @@ public class KODOImageupload {
|
|||||||
}
|
}
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package cn.hellohao.service.impl;
|
|||||||
|
|
||||||
import cn.hellohao.pojo.Msg;
|
import cn.hellohao.pojo.Msg;
|
||||||
import cn.hellohao.utils.Print;
|
import cn.hellohao.utils.Print;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -16,7 +17,6 @@ public class KeysServiceImpl implements KeysService {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private KeysMapper keysMapper;
|
private KeysMapper keysMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private NOSImageupload nOSImageupload;
|
private NOSImageupload nOSImageupload;
|
||||||
@Autowired
|
@Autowired
|
||||||
@@ -28,9 +28,11 @@ public class KeysServiceImpl implements KeysService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private COSImageupload cosImageupload;
|
private COSImageupload cosImageupload;
|
||||||
@Autowired
|
@Autowired
|
||||||
private FTPImageupload ftpImageupload;
|
private FtpServiceImpl ftpService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private UFileImageupload uFileImageupload;
|
private S3Imageupload s3Imageupload;
|
||||||
|
@Autowired
|
||||||
|
private WebDAVImageupload webDAVImageupload;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -52,6 +54,29 @@ public class KeysServiceImpl implements KeysService {
|
|||||||
public Msg updateKey(Keys key) {
|
public Msg updateKey(Keys key) {
|
||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
Integer ret = -2;
|
Integer ret = -2;
|
||||||
|
//修正一边数据格式,去除末尾的斜杠
|
||||||
|
if(key.getStorageType()==9 || key.getStorageType()==8){
|
||||||
|
//s3或者webdav
|
||||||
|
if(!StringUtils.isBlank(key.getRootPath()) && !key.getRootPath().equals("/")){
|
||||||
|
if (key.getRootPath().endsWith("/")) {
|
||||||
|
String rootpath = key.getRootPath();
|
||||||
|
key.setRootPath(rootpath.substring(0, rootpath.length() - 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!StringUtils.isBlank(key.getEndpoint())){
|
||||||
|
final String endpoint = key.getEndpoint();
|
||||||
|
if (endpoint.endsWith("/")) {
|
||||||
|
key.setEndpoint(endpoint.substring(0, endpoint.length() - 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!StringUtils.isBlank(key.getRequestAddress())){
|
||||||
|
final String requestAddress = key.getRequestAddress();
|
||||||
|
if (requestAddress.endsWith("/")) {
|
||||||
|
key.setRequestAddress(requestAddress.substring(0, requestAddress.length() - 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(key.getStorageType()==1){
|
if(key.getStorageType()==1){
|
||||||
ret =nOSImageupload.Initialize(key);
|
ret =nOSImageupload.Initialize(key);
|
||||||
}else if (key.getStorageType()==2){
|
}else if (key.getStorageType()==2){
|
||||||
@@ -65,9 +90,11 @@ public class KeysServiceImpl implements KeysService {
|
|||||||
}else if(key.getStorageType()==6){
|
}else if(key.getStorageType()==6){
|
||||||
ret = cosImageupload.Initialize(key);
|
ret = cosImageupload.Initialize(key);
|
||||||
}else if(key.getStorageType()==7){
|
}else if(key.getStorageType()==7){
|
||||||
ret = ftpImageupload.Initialize(key);
|
ret = ftpService.Initialize(key);
|
||||||
}else if(key.getStorageType()==8){
|
}else if(key.getStorageType()==8){
|
||||||
ret = uFileImageupload.Initialize(key);
|
ret = s3Imageupload.Initialize(key);
|
||||||
|
}else if(key.getStorageType()==9){
|
||||||
|
ret = webDAVImageupload.Initialize(key);
|
||||||
}else{
|
}else{
|
||||||
Print.Normal("为获取到存储参数,或者使用存储源是本地的。");
|
Print.Normal("为获取到存储参数,或者使用存储源是本地的。");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ import com.netease.cloud.auth.BasicCredentials;
|
|||||||
import com.netease.cloud.auth.Credentials;
|
import com.netease.cloud.auth.Credentials;
|
||||||
import com.netease.cloud.services.nos.NosClient;
|
import com.netease.cloud.services.nos.NosClient;
|
||||||
import com.netease.cloud.services.nos.model.ObjectListing;
|
import com.netease.cloud.services.nos.model.ObjectListing;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -18,20 +21,19 @@ public class NOSImageupload {
|
|||||||
static NosClient nosClient;
|
static NosClient nosClient;
|
||||||
static Keys key;
|
static Keys key;
|
||||||
|
|
||||||
public ReturnImage Imageupload(Map<String, File> fileMap, String username,Integer keyID){
|
public ReturnImage Imageupload(Map<Map<String, String>, File> fileMap, String username,Integer keyID){
|
||||||
ReturnImage returnImage = new ReturnImage();
|
ReturnImage returnImage = new ReturnImage();
|
||||||
File file = null;
|
File file = null;
|
||||||
try {
|
try {
|
||||||
for (Map.Entry<String, File> entry : fileMap.entrySet()) {
|
for (Map.Entry<Map<String, String>, File> entry : fileMap.entrySet()) {
|
||||||
String ShortUID = SetText.getShortUuid();
|
String prefix = entry.getKey().get("prefix");
|
||||||
|
String ShortUIDName = entry.getKey().get("name");
|
||||||
file = entry.getValue();
|
file = entry.getValue();
|
||||||
nosClient.putObject(key.getBucketname(), username + "/" + ShortUID+ "." + entry.getKey(), file);
|
nosClient.putObject(
|
||||||
returnImage.setImgname(username + "/" + ShortUID+ "." + entry.getKey());
|
key.getBucketname(), username + "/" + ShortUIDName + "." + prefix, file);
|
||||||
returnImage.setImgurl(key.getRequestAddress() + "/" + username + "/" + ShortUID + "." + entry.getKey());
|
|
||||||
returnImage.setImgSize(entry.getValue().length());
|
|
||||||
returnImage.setCode("200");
|
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
returnImage.setCode("200");
|
||||||
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
returnImage.setCode("500");
|
returnImage.setCode("500");
|
||||||
}
|
}
|
||||||
@@ -42,25 +44,25 @@ public class NOSImageupload {
|
|||||||
|
|
||||||
public static Integer Initialize(Keys k) {
|
public static Integer Initialize(Keys k) {
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
if(k.getEndpoint()!=null && k.getAccessSecret()!=null && k.getEndpoint()!=null
|
if (StringUtils.isBlank(k.getAccessKey())
|
||||||
&& k.getBucketname()!=null && k.getRequestAddress()!=null ){
|
|| StringUtils.isBlank(k.getAccessSecret())
|
||||||
if(!k.getEndpoint().equals("") && !k.getAccessSecret().equals("") && !k.getEndpoint().equals("")
|
|| StringUtils.isBlank(k.getEndpoint())
|
||||||
&& !k.getBucketname().equals("") && !k.getRequestAddress().equals("") ){
|
|| StringUtils.isBlank(k.getBucketname())
|
||||||
// 初始化
|
|| StringUtils.isBlank(k.getRequestAddress())) {
|
||||||
Credentials credentials = new BasicCredentials(k.getAccessKey(), k.getAccessSecret());
|
return -1;
|
||||||
NosClient nosObj = new NosClient(credentials);
|
}
|
||||||
nosObj.setEndpoint(k.getEndpoint());
|
Credentials credentials = new BasicCredentials(k.getAccessKey(), k.getAccessSecret());
|
||||||
ObjectListing objectListing = null;
|
NosClient nosObj = new NosClient(credentials);
|
||||||
try {
|
nosObj.setEndpoint(k.getEndpoint());
|
||||||
objectListing = nosObj.listObjects(k.getBucketname());
|
ObjectListing objectListing = null;
|
||||||
ret = 1;
|
try {
|
||||||
nosClient = nosObj;
|
objectListing = nosObj.listObjects(k.getBucketname());
|
||||||
key = k;
|
ret = 1;
|
||||||
}catch (Exception e){
|
nosClient = nosObj;
|
||||||
System.out.println("NOS Object Is null");
|
key = k;
|
||||||
ret = -1;
|
}catch (Exception e){
|
||||||
}
|
System.out.println("NOS Object Is null");
|
||||||
}
|
ret = -1;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,73 +4,88 @@ import cn.hellohao.pojo.Images;
|
|||||||
import cn.hellohao.pojo.Keys;
|
import cn.hellohao.pojo.Keys;
|
||||||
import cn.hellohao.pojo.Msg;
|
import cn.hellohao.pojo.Msg;
|
||||||
import cn.hellohao.pojo.ReturnImage;
|
import cn.hellohao.pojo.ReturnImage;
|
||||||
import cn.hellohao.utils.SetText;
|
|
||||||
import cn.hellohao.utils.TypeDict;
|
import cn.hellohao.utils.TypeDict;
|
||||||
import com.aliyun.oss.OSS;
|
import com.aliyun.oss.OSS;
|
||||||
import com.aliyun.oss.OSSClientBuilder;
|
import com.aliyun.oss.OSSClientBuilder;
|
||||||
import com.aliyun.oss.model.ObjectListing;
|
import com.aliyun.oss.model.ObjectListing;
|
||||||
import com.aliyun.oss.model.ObjectMetadata;
|
import com.aliyun.oss.model.ObjectMetadata;
|
||||||
|
import com.aliyun.oss.model.PutObjectRequest;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class OSSImageupload {
|
public class OSSImageupload {
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(OSSImageupload.class);
|
||||||
static OSS ossClient;
|
static OSS ossClient;
|
||||||
static Keys key;
|
static Keys key;
|
||||||
|
|
||||||
public ReturnImage ImageuploadOSS(Map<String, File> fileMap, String username,Integer keyID){
|
public ReturnImage ImageuploadOSS(
|
||||||
|
Map<Map<String, String>, File> fileMap, String username, Integer keyID) {
|
||||||
ReturnImage returnImage = new ReturnImage();
|
ReturnImage returnImage = new ReturnImage();
|
||||||
File file = null;
|
File file = null;
|
||||||
|
FileInputStream stream = null;
|
||||||
ObjectMetadata meta = new ObjectMetadata();
|
ObjectMetadata meta = new ObjectMetadata();
|
||||||
meta.setHeader("Content-Disposition", "inline");
|
meta.setHeader("Content-Disposition", "inline");
|
||||||
try {
|
try {
|
||||||
for (Map.Entry<String, File> entry : fileMap.entrySet()) {
|
for (Map.Entry<Map<String, String>, File> entry : fileMap.entrySet()) {
|
||||||
String ShortUID = SetText.getShortUuid();
|
String prefix = entry.getKey().get("prefix");
|
||||||
java.text.DateFormat format1 = new java.text.SimpleDateFormat("MMddhhmmss");
|
String ShortUIDName = entry.getKey().get("name");
|
||||||
file = entry.getValue();
|
file = entry.getValue();
|
||||||
Msg fileMiME = TypeDict.FileMiME(file);
|
stream = new FileInputStream(file);
|
||||||
|
Msg fileMiME = TypeDict.FileMiME(stream);
|
||||||
meta.setHeader("content-type", fileMiME.getData().toString());
|
meta.setHeader("content-type", fileMiME.getData().toString());
|
||||||
System.out.println("待上传的图片:"+username + "/" + ShortUID + "." + entry.getKey());
|
PutObjectRequest putObjectRequest =
|
||||||
ossClient.putObject(key.getBucketname(), username + "/" + ShortUID + "." + entry.getKey(),file);
|
new PutObjectRequest(
|
||||||
returnImage.setImgname(username + "/" + ShortUID + "." + entry.getKey());//entry.getValue().getOriginalFilename()
|
key.getBucketname(),
|
||||||
returnImage.setImgurl(key.getRequestAddress() + "/" + username + "/" + ShortUID + "." + entry.getKey());
|
username + "/" + ShortUIDName + "." + prefix,
|
||||||
returnImage.setImgSize(file.length());
|
stream,
|
||||||
returnImage.setCode("200");
|
meta);
|
||||||
|
ossClient.putObject(putObjectRequest);
|
||||||
|
try {if(stream!=null){stream.close();}} catch (Exception e) { }
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
returnImage.setCode("200");
|
||||||
e.printStackTrace();
|
} catch (Exception e) {
|
||||||
|
try {if(stream!=null){stream.close();}} catch (Exception ex) { }
|
||||||
|
logger.error("OSS上传发生异常:",e);
|
||||||
returnImage.setCode("500");
|
returnImage.setCode("500");
|
||||||
}
|
}
|
||||||
return returnImage;
|
return returnImage;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Integer Initialize(Keys k) {
|
public static Integer Initialize(Keys k) {
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
ObjectListing objectListing = null;
|
ObjectListing objectListing = null;
|
||||||
if(k.getEndpoint()!=null && k.getAccessSecret()!=null && k.getAccessKey()!=null && k.getEndpoint()!=null
|
if (StringUtils.isBlank(k.getAccessKey())
|
||||||
&& k.getBucketname()!=null && k.getRequestAddress()!=null ) {
|
|| StringUtils.isBlank(k.getAccessSecret())
|
||||||
if(!k.getEndpoint().equals("") && !k.getAccessSecret().equals("") && !k.getAccessKey().equals("") && !k.getEndpoint().equals("")
|
|| StringUtils.isBlank(k.getEndpoint())
|
||||||
&& !k.getBucketname().equals("") && !k.getRequestAddress().equals("") ) {
|
|| StringUtils.isBlank(k.getBucketname())
|
||||||
OSS ossObj = new OSSClientBuilder().build(k.getEndpoint(), k.getAccessKey(), k.getAccessSecret());
|
|| StringUtils.isBlank(k.getRequestAddress())) {
|
||||||
try {
|
return -1;
|
||||||
objectListing = ossObj.listObjects(k.getBucketname());
|
|
||||||
ret=1;
|
|
||||||
ossClient = ossObj;
|
|
||||||
key = k;
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.out.println("OSS Object Is null");
|
|
||||||
ret = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
OSS ossObj =
|
||||||
|
new OSSClientBuilder()
|
||||||
|
.build(k.getEndpoint(), k.getAccessKey(), k.getAccessSecret());
|
||||||
|
try {
|
||||||
|
objectListing = ossObj.listObjects(k.getBucketname());
|
||||||
|
ret = 1;
|
||||||
|
ossClient = ossObj;
|
||||||
|
key = k;
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println("OSS Object Is null");
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean delOSS(Integer keyID, Images images){
|
public boolean delOSS(Integer keyID, Images images) {
|
||||||
boolean b =true;
|
boolean b = true;
|
||||||
try {
|
try {
|
||||||
ossClient.deleteObject(key.getBucketname(), images.getImgname());
|
ossClient.deleteObject(key.getBucketname(), images.getImgname());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -79,6 +94,4 @@ public class OSSImageupload {
|
|||||||
}
|
}
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,42 +12,44 @@ import java.util.concurrent.TimeUnit;
|
|||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class RedisServiceImpl implements IRedisService {
|
public class RedisServiceImpl implements IRedisService {
|
||||||
@Autowired
|
@Autowired private StringRedisTemplate stringRedisTemplate;
|
||||||
private StringRedisTemplate stringRedisTemplate;
|
@Autowired private RedisTemplate redisTemplate;
|
||||||
@Autowired
|
|
||||||
private RedisTemplate redisTemplate;
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setValue(String key, Map<String, Object> value) {
|
||||||
|
ValueOperations<String, Object> vo = redisTemplate.opsForValue();
|
||||||
|
vo.set(key, value);
|
||||||
|
redisTemplate.expire(key, 1, TimeUnit.HOURS); // 这里指的是1小时后失效
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setValue(String key, Map<String, Object> value) {
|
public Object getValue(String key) {
|
||||||
ValueOperations<String, Object> vo = redisTemplate.opsForValue();
|
ValueOperations<String, String> vo = redisTemplate.opsForValue();
|
||||||
vo.set(key, value);
|
return vo.get(key);
|
||||||
redisTemplate.expire(key, 1, TimeUnit.HOURS); // 这里指的是1小时后失效
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getValue(String key) {
|
public void setValue(String key, String value) {
|
||||||
ValueOperations<String, String> vo = redisTemplate.opsForValue();
|
ValueOperations<String, Object> vo = redisTemplate.opsForValue();
|
||||||
return vo.get(key);
|
vo.set(key, value);
|
||||||
}
|
redisTemplate.expire(key, 3, TimeUnit.MINUTES); // 这里指的是1小时后失效 时HOURS 分 MINUTES
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setValue(String key, String value) {
|
public void setTimeValue(String key, Object value, Long time) {
|
||||||
ValueOperations<String, Object> vo = redisTemplate.opsForValue();
|
ValueOperations<String, Object> vo = redisTemplate.opsForValue();
|
||||||
vo.set(key, value);
|
vo.set(key, value);
|
||||||
redisTemplate.expire(key, 3, TimeUnit.MINUTES); // 这里指的是1小时后失效 时HOURS 分 MINUTES
|
redisTemplate.expire(key, time, TimeUnit.HOURS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setValue(String key, Object value) {
|
public Object getMapValue(String key) {
|
||||||
ValueOperations<String, Object> vo = redisTemplate.opsForValue();
|
ValueOperations<String, String> vo = redisTemplate.opsForValue();
|
||||||
vo.set(key, value);
|
return vo.get(key);
|
||||||
redisTemplate.expire(key, 1, TimeUnit.HOURS); // 这里指的是1小时后失效
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object getMapValue(String key) {
|
public Boolean removeValue(String key) {
|
||||||
ValueOperations<String, String> vo = redisTemplate.opsForValue();
|
return redisTemplate.delete(key);
|
||||||
return vo.get(key);
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -0,0 +1,171 @@
|
|||||||
|
package cn.hellohao.service.impl;
|
||||||
|
|
||||||
|
import cn.hellohao.pojo.Images;
|
||||||
|
import cn.hellohao.pojo.Keys;
|
||||||
|
import cn.hellohao.pojo.ReturnImage;
|
||||||
|
import com.amazonaws.ClientConfiguration;
|
||||||
|
import com.amazonaws.auth.AWSCredentials;
|
||||||
|
import com.amazonaws.auth.AWSCredentialsProvider;
|
||||||
|
import com.amazonaws.auth.AWSStaticCredentialsProvider;
|
||||||
|
import com.amazonaws.auth.BasicAWSCredentials;
|
||||||
|
import com.amazonaws.client.builder.AwsClientBuilder;
|
||||||
|
import com.amazonaws.services.s3.AmazonS3;
|
||||||
|
import com.amazonaws.services.s3.AmazonS3Client;
|
||||||
|
import com.amazonaws.services.s3.AmazonS3ClientBuilder;
|
||||||
|
import com.amazonaws.services.s3.model.*;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Hellohao
|
||||||
|
* @version 1.0
|
||||||
|
* @date 2023/3/15 14:04
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class S3Imageupload {
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(S3Imageupload.class);
|
||||||
|
|
||||||
|
static AmazonS3 AS3;
|
||||||
|
static Keys KEY;
|
||||||
|
public ReturnImage ImageuploadS3(
|
||||||
|
Map<Map<String, String>, File> fileMap, String username, Integer keyID) {
|
||||||
|
ReturnImage returnImage = new ReturnImage();
|
||||||
|
try {
|
||||||
|
if (null == AS3 || null == AS3) {
|
||||||
|
logger.error("S3 = 存储源对象为空");
|
||||||
|
returnImage.setCode("500");
|
||||||
|
return returnImage;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
returnImage.setCode("500");
|
||||||
|
return returnImage;
|
||||||
|
}
|
||||||
|
File file = null;
|
||||||
|
FileInputStream stream = null;
|
||||||
|
try {
|
||||||
|
for (Map.Entry<Map<String, String>, File> entry : fileMap.entrySet()) {
|
||||||
|
String prefix = entry.getKey().get("prefix");
|
||||||
|
String ShortUIDName = entry.getKey().get("name");
|
||||||
|
file = entry.getValue();
|
||||||
|
stream = new FileInputStream(file);
|
||||||
|
//解决存储源不能浏览图片的问题
|
||||||
|
// ObjectMetadata objectMetadata = new ObjectMetadata();
|
||||||
|
// objectMetadata.addUserMetadata();
|
||||||
|
AS3.putObject(
|
||||||
|
new PutObjectRequest(
|
||||||
|
KEY.getBucketname(),
|
||||||
|
username + "/" + ShortUIDName + "." + prefix,
|
||||||
|
stream,null));
|
||||||
|
// S3Object object = s3.getObject( new GetObjectRequest( key.getBucketname(),
|
||||||
|
try {if(stream!=null){stream.close();}} catch (Exception e) { }
|
||||||
|
}
|
||||||
|
returnImage.setCode("200");
|
||||||
|
} catch (Exception e) {
|
||||||
|
try {if(stream!=null){stream.close();}} catch (Exception ex) { }
|
||||||
|
logger.error("S3协议上传发生异常:",e);
|
||||||
|
returnImage.setCode("500");
|
||||||
|
}
|
||||||
|
return returnImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static Integer Initialize(Keys k) {
|
||||||
|
int ret = -1;
|
||||||
|
if (StringUtils.isBlank(k.getAccessKey())
|
||||||
|
|| StringUtils.isBlank(k.getAccessSecret())
|
||||||
|
|| StringUtils.isBlank(k.getRootPath())
|
||||||
|
|| StringUtils.isBlank(k.getEndpoint())
|
||||||
|
|| StringUtils.isBlank(k.getBucketname())
|
||||||
|
|| StringUtils.isBlank(k.getRequestAddress())) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
String regionStr = k.getRegion() == null ? "" : k.getRegion();
|
||||||
|
ClientConfiguration config = new ClientConfiguration();
|
||||||
|
config.setMaxConnections(500);
|
||||||
|
config.setConnectionTimeout(30);
|
||||||
|
// cn-north-1 us-east-1
|
||||||
|
BasicAWSCredentials credentials =
|
||||||
|
new BasicAWSCredentials(k.getAccessKey(), k.getAccessSecret());
|
||||||
|
AmazonS3 s3 =
|
||||||
|
AmazonS3ClientBuilder.standard()
|
||||||
|
.withClientConfiguration(config)
|
||||||
|
.withPathStyleAccessEnabled(false)
|
||||||
|
.withCredentials(new AWSStaticCredentialsProvider(credentials))
|
||||||
|
.withEndpointConfiguration(
|
||||||
|
new AwsClientBuilder.EndpointConfiguration(
|
||||||
|
k.getEndpoint(), regionStr))
|
||||||
|
.build();
|
||||||
|
ObjectListing objectListing = s3.listObjects(k.getBucketname());
|
||||||
|
ret = 1;
|
||||||
|
AS3 = s3;
|
||||||
|
KEY = k;
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.warn("S3 Object " + k.getKeyname() + " Is null");
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
|
if(ret==-1){
|
||||||
|
ret = Initialize_Tow(k);
|
||||||
|
if(ret>-1){
|
||||||
|
//OK
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Integer Initialize_Tow(Keys k) {
|
||||||
|
int ret = -1;
|
||||||
|
try {
|
||||||
|
ClientConfiguration config = new ClientConfiguration();
|
||||||
|
AwsClientBuilder.EndpointConfiguration endpointConfig =
|
||||||
|
new AwsClientBuilder.EndpointConfiguration(k.getEndpoint(), k.getRegion());//cn-north-1
|
||||||
|
AWSCredentials awsCredentials = new BasicAWSCredentials(k.getAccessKey(),k.getAccessSecret());
|
||||||
|
AWSCredentialsProvider awsCredentialsProvider = new AWSStaticCredentialsProvider(awsCredentials);
|
||||||
|
AmazonS3 s3 = AmazonS3Client.builder()
|
||||||
|
.withEndpointConfiguration(endpointConfig)
|
||||||
|
.withClientConfiguration(config)
|
||||||
|
.withCredentials(awsCredentialsProvider)
|
||||||
|
.disableChunkedEncoding()
|
||||||
|
.withPathStyleAccessEnabled(true)
|
||||||
|
.build();
|
||||||
|
List<Bucket> buckets = s3.listBuckets();
|
||||||
|
boolean b = false;
|
||||||
|
for (Bucket bucket : buckets) {
|
||||||
|
if(k.getBucketname().equals(bucket.getName())){
|
||||||
|
b = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(b==false){
|
||||||
|
throw new NullPointerException();
|
||||||
|
}
|
||||||
|
ret=1;
|
||||||
|
AS3 = s3;
|
||||||
|
KEY = k;
|
||||||
|
} catch (Exception e) {
|
||||||
|
ret = -1;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean deleS3(Integer keyID, Images images) {
|
||||||
|
boolean b = true;
|
||||||
|
try {
|
||||||
|
DeleteObjectRequest deleteObjectRequest =
|
||||||
|
new DeleteObjectRequest(KEY.getBucketname(), images.getImgname());
|
||||||
|
AS3.deleteObject(deleteObjectRequest);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
b = false;
|
||||||
|
}
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
package cn.hellohao.service.impl;
|
|
||||||
|
|
||||||
import cn.hellohao.pojo.Images;
|
|
||||||
import cn.hellohao.pojo.Keys;
|
|
||||||
import cn.hellohao.pojo.Msg;
|
|
||||||
import cn.hellohao.pojo.ReturnImage;
|
|
||||||
import cn.hellohao.utils.SetText;
|
|
||||||
import cn.hellohao.utils.TypeDict;
|
|
||||||
import com.UpYun;
|
|
||||||
import com.aliyun.oss.model.ObjectMetadata;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class UFileImageupload {
|
|
||||||
static UpYun uFile;
|
|
||||||
static Keys key;
|
|
||||||
|
|
||||||
public ReturnImage ImageuploadUFile(Map<String, File> fileMap, String username,Integer keyID) {
|
|
||||||
ReturnImage returnImage = new ReturnImage();
|
|
||||||
File file = null;
|
|
||||||
ObjectMetadata meta = new ObjectMetadata();
|
|
||||||
meta.setHeader("Content-Disposition", "inline");
|
|
||||||
try {
|
|
||||||
for (Map.Entry<String, File> entry : fileMap.entrySet()) {
|
|
||||||
String ShortUID = SetText.getShortUuid();
|
|
||||||
file = entry.getValue();
|
|
||||||
Msg fileMiME = TypeDict.FileMiME(file);
|
|
||||||
meta.setHeader("content-type", fileMiME.getData().toString());
|
|
||||||
uFile.setContentMD5(UpYun.md5(file));
|
|
||||||
boolean result = uFile.writeFile(username + "/" + ShortUID + "." + entry.getKey(), file, true);
|
|
||||||
if(result){
|
|
||||||
returnImage.setImgname(username + "/" + ShortUID + "." + entry.getKey());
|
|
||||||
returnImage.setImgurl(key.getRequestAddress() + "/" +username + "/" + ShortUID + "." + entry.getKey());
|
|
||||||
returnImage.setImgSize(entry.getValue().length());
|
|
||||||
returnImage.setCode("200");
|
|
||||||
}else{
|
|
||||||
returnImage.setCode("400");
|
|
||||||
System.err.println("上传失败");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}catch(Exception e){
|
|
||||||
returnImage.setCode("500");
|
|
||||||
}
|
|
||||||
return returnImage;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Integer Initialize(Keys k) {
|
|
||||||
int ret = -1;
|
|
||||||
if(k.getAccessSecret()!=null && k.getAccessKey()!=null
|
|
||||||
&& k.getBucketname()!=null && k.getRequestAddress()!=null ) {
|
|
||||||
if(!k.getAccessSecret().equals("") && !k.getAccessKey().equals("")
|
|
||||||
&& !k.getBucketname().equals("") && !k.getRequestAddress().equals("") ) {
|
|
||||||
UpYun ufObj = new UpYun(k.getBucketname(), k.getAccessKey(), k.getAccessSecret());
|
|
||||||
List<UpYun.FolderItem> items = null;
|
|
||||||
try {
|
|
||||||
items = ufObj.readDir("/",null);
|
|
||||||
ret = 1;
|
|
||||||
uFile = ufObj;
|
|
||||||
key = k;
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.out.println("UFile Object Is null");
|
|
||||||
ret = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Boolean delUFile(Integer keyID, Images images) {
|
|
||||||
boolean b = true;
|
|
||||||
try {
|
|
||||||
boolean result = uFile.deleteFile(images.getImgname(), null);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
b = false;
|
|
||||||
}
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -4,72 +4,82 @@ import cn.hellohao.pojo.Images;
|
|||||||
import cn.hellohao.pojo.Keys;
|
import cn.hellohao.pojo.Keys;
|
||||||
import cn.hellohao.pojo.Msg;
|
import cn.hellohao.pojo.Msg;
|
||||||
import cn.hellohao.pojo.ReturnImage;
|
import cn.hellohao.pojo.ReturnImage;
|
||||||
import cn.hellohao.utils.SetText;
|
|
||||||
import cn.hellohao.utils.TypeDict;
|
import cn.hellohao.utils.TypeDict;
|
||||||
import com.UpYun;
|
import com.UpYun;
|
||||||
import com.aliyun.oss.model.ObjectMetadata;
|
import com.aliyun.oss.model.ObjectMetadata;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class USSImageupload {
|
public class USSImageupload {
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(USSImageupload.class);
|
||||||
static UpYun upyun;
|
static UpYun upyun;
|
||||||
static Keys key;
|
static Keys key;
|
||||||
|
|
||||||
public ReturnImage ImageuploadUSS(Map<String, File> fileMap, String username,Integer keyID) {
|
public ReturnImage ImageuploadUSS(
|
||||||
|
Map<Map<String, String>, File> fileMap, String username, Integer keyID) {
|
||||||
ReturnImage returnImage = new ReturnImage();
|
ReturnImage returnImage = new ReturnImage();
|
||||||
File file = null;
|
File file = null;
|
||||||
|
FileInputStream stream = null;
|
||||||
ObjectMetadata meta = new ObjectMetadata();
|
ObjectMetadata meta = new ObjectMetadata();
|
||||||
meta.setHeader("Content-Disposition", "inline");
|
meta.setHeader("Content-Disposition", "inline");
|
||||||
try {
|
try {
|
||||||
for (Map.Entry<String, File> entry : fileMap.entrySet()) {
|
for (Map.Entry<Map<String, String>, File> entry : fileMap.entrySet()) {
|
||||||
String ShortUID = SetText.getShortUuid();
|
String prefix = entry.getKey().get("prefix");
|
||||||
|
String ShortUIDName = entry.getKey().get("name");
|
||||||
file = entry.getValue();
|
file = entry.getValue();
|
||||||
Msg fileMiME = TypeDict.FileMiME(file);
|
stream = new FileInputStream(file);
|
||||||
|
Msg fileMiME = TypeDict.FileMiME(stream);
|
||||||
meta.setHeader("content-type", fileMiME.getData().toString());
|
meta.setHeader("content-type", fileMiME.getData().toString());
|
||||||
upyun.setContentMD5(UpYun.md5(file));
|
upyun.setContentMD5(UpYun.md5(file));
|
||||||
boolean result = upyun.writeFile(username + "/" + ShortUID + "." + entry.getKey(), file, true);
|
boolean result =
|
||||||
if(result){
|
upyun.writeFile(username + "/" + ShortUIDName + "." + prefix, stream, true, null);
|
||||||
returnImage.setImgname(username + "/" + ShortUID + "." + entry.getKey());
|
if (result) {
|
||||||
returnImage.setImgurl(key.getRequestAddress() + "/" +username + "/" + ShortUID + "." + entry.getKey());
|
|
||||||
returnImage.setImgSize(entry.getValue().length());
|
} else {
|
||||||
returnImage.setCode("200");
|
|
||||||
}else{
|
|
||||||
returnImage.setCode("400");
|
|
||||||
System.err.println("上传失败");
|
System.err.println("上传失败");
|
||||||
|
returnImage.setCode("400");
|
||||||
}
|
}
|
||||||
|
try {if(stream!=null){stream.close();}} catch (Exception e) { }
|
||||||
}
|
}
|
||||||
}catch (Exception e){
|
returnImage.setCode("200");
|
||||||
e.printStackTrace();
|
} catch (Exception e) {
|
||||||
|
try {if(stream!=null){stream.close();}} catch (Exception ex) { }
|
||||||
|
logger.error("OSS上传发生异常:",e);
|
||||||
returnImage.setCode("500");
|
returnImage.setCode("500");
|
||||||
}
|
}
|
||||||
return returnImage;
|
return returnImage;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//初始化
|
// 初始化
|
||||||
public static Integer Initialize(Keys k) {
|
public static Integer Initialize(Keys k) {
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
if(k.getStorageType()!=null && k.getAccessKey() != null && k.getAccessSecret() != null && k.getBucketname() != null
|
if (StringUtils.isBlank(k.getAccessKey())
|
||||||
&& k.getRequestAddress() !=null ) {
|
|| StringUtils.isBlank(k.getKeyname())
|
||||||
if(!k.getStorageType().equals("") && !k.getAccessKey().equals("") && !k.getAccessSecret().equals("") && !k.getBucketname().equals("")
|
|| StringUtils.isBlank(k.getAccessSecret())
|
||||||
&& !k.getRequestAddress().equals("") ) {
|
|| StringUtils.isBlank(k.getEndpoint())
|
||||||
// 初始化
|
|| StringUtils.isBlank(k.getBucketname())
|
||||||
// 创建UpYun实例。
|
|| StringUtils.isBlank(k.getRequestAddress())
|
||||||
UpYun upObj= new UpYun(k.getBucketname(), k.getAccessKey(), k.getAccessSecret());
|
|| k.getStorageType() == null) {
|
||||||
List<UpYun.FolderItem> items = null;
|
return -1;
|
||||||
try {
|
}
|
||||||
items = upObj.readDir("/",null);
|
UpYun upObj = new UpYun(k.getBucketname(), k.getAccessKey(), k.getAccessSecret());
|
||||||
ret = 1;
|
List<UpYun.FolderItem> items = null;
|
||||||
upyun = upObj;
|
try {
|
||||||
key = k;
|
items = upObj.readDir("/", null);
|
||||||
} catch (Exception e) {
|
ret = 1;
|
||||||
System.out.println("USS Object Is null");
|
upyun = upObj;
|
||||||
ret = -1;
|
key = k;
|
||||||
}
|
} catch (Exception e) {
|
||||||
}
|
System.out.println("USS Object Is null");
|
||||||
|
ret = -1;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -80,10 +90,8 @@ public class USSImageupload {
|
|||||||
boolean result = upyun.deleteFile(images.getImgname(), null);
|
boolean result = upyun.deleteFile(images.getImgname(), null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
b=false;
|
b = false;
|
||||||
}
|
}
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,132 +1,104 @@
|
|||||||
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.service.SysConfigService;
|
||||||
import cn.hellohao.utils.*;
|
import cn.hellohao.utils.*;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.baidu.aip.contentcensor.AipContentCensor;
|
|
||||||
import com.baidu.aip.contentcensor.EImgType;
|
|
||||||
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.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.annotation.Async;
|
||||||
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
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.io.IOException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Hellohao
|
* @author Hellohao
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
* @date 2020/1/9 15:46
|
* @date 2020/1/9 15:46
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class UploadServicel {
|
public class UploadServicel {
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(UploadServicel.class);
|
||||||
@Autowired
|
@Autowired
|
||||||
ConfigMapper configMapper;
|
ConfdataService confdataService;
|
||||||
@Autowired
|
@Autowired
|
||||||
SysConfigService sysConfigService;
|
SysConfigService sysConfigService;
|
||||||
@Autowired
|
@Autowired private UploadConfigMapper uploadConfigMapper;
|
||||||
UploadConfigMapper uploadConfigMapper;
|
@Autowired private KeysMapper keysMapper;
|
||||||
@Autowired
|
@Autowired private ImgServiceImpl imgServiceImpl;
|
||||||
KeysMapper keysMapper;
|
@Autowired private UserMapper userMapper;
|
||||||
@Autowired
|
@Autowired private ImgTempService imgTempService;
|
||||||
ImgMapper imgMapper;
|
@Autowired private GetSource getSource;
|
||||||
@Autowired
|
@Autowired deleImages deleimages;
|
||||||
UserMapper userMapper;
|
@Autowired ImgViolationJudgeServiceImpl imgViolationJudgeService;
|
||||||
@Autowired
|
|
||||||
ImgreviewMapper imgreviewMapper;
|
|
||||||
@Autowired
|
|
||||||
ImgTempService imgTempService;
|
|
||||||
|
|
||||||
|
public Msg uploadForLoc(
|
||||||
public Msg uploadForLoc(HttpServletRequest request,
|
HttpServletRequest request,
|
||||||
MultipartFile multipartFile, Integer setday, String imgUrl) {
|
File file,
|
||||||
|
String imgName,
|
||||||
|
Integer setday,
|
||||||
|
JSONObject imgJson,
|
||||||
|
String md5key) {
|
||||||
Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
try{
|
try {
|
||||||
String imageFileName = "未命名图像";
|
Confdata dataJson = confdataService.selectConfdata("config");
|
||||||
|
JSONObject confdata = JSONObject.parseObject(dataJson.getJsondata());
|
||||||
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
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);
|
||||||
Subject subject = SecurityUtils.getSubject();
|
Subject subject = SecurityUtils.getSubject();
|
||||||
User u = (User) subject.getPrincipal();
|
User u = (User) subject.getPrincipal();
|
||||||
if(null!=u){
|
if (null != u) {
|
||||||
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 (imgData.getCode().equals("200")) {
|
||||||
if(imgUrl==null){
|
|
||||||
imageFileName = multipartFile.getOriginalFilename();
|
|
||||||
file = SetFiles.changeFile_new(multipartFile);
|
|
||||||
}else{
|
|
||||||
Msg imgData = uploadForURL(request, imgUrl);
|
|
||||||
if(imgData.getCode().equals("200")){
|
|
||||||
file = new File((String) imgData.getData());
|
file = new File((String) imgData.getData());
|
||||||
}else{
|
} else {
|
||||||
return imgData;
|
return imgData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
FileInputStream stream = new FileInputStream(file);
|
||||||
String imguid = UUID.randomUUID().toString().replace("-", "");
|
String imguid = UUID.randomUUID().toString().replace("-", "");
|
||||||
Msg msg1 = updateImgCheck(u,uploadConfig);
|
Msg msg1 = updateImgCheck(u, uploadConfig);
|
||||||
if(!msg1.getCode().equals("300")){
|
if (!msg1.getCode().equals("300")) {
|
||||||
|
try {
|
||||||
|
if(stream!=null){stream.close();}
|
||||||
|
file.delete();
|
||||||
|
} catch (Exception e) { }
|
||||||
return msg1;
|
return msg1;
|
||||||
}
|
}
|
||||||
sourceKeyId = group.getKeyid();
|
JSONObject updateJson = JSONObject.parseObject(msg1.getData().toString());
|
||||||
Keys key = keysMapper.selectKeys(sourceKeyId);
|
final JSONObject groupJson = updateJson.getJSONObject("group");
|
||||||
Long tmp = (memory == -1 ? -2 : UsedTotleMemory);
|
final Group group = groupJson.toJavaObject(Group.class);
|
||||||
if (tmp >= memory) {
|
Long memory = updateJson.getLong("memory");
|
||||||
msg.setCode("4005");
|
Long UsedTotleMemory = updateJson.getLong("UsedTotleMemory");
|
||||||
msg.setInfo(u==null?"游客空间已用尽":"您的可用空间不足");
|
Long TotleMemory = updateJson.getLong("TotleMemory");
|
||||||
return msg;
|
String updatePath = updateJson.getString("updatePath");
|
||||||
}
|
|
||||||
if (file.length() > TotleMemory) {
|
|
||||||
System.err.println("文件大小:"+file.length());
|
|
||||||
System.err.println("最大限制:"+TotleMemory);
|
|
||||||
msg.setCode("4006");
|
|
||||||
msg.setInfo("图像超出系统限制大小");
|
|
||||||
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);
|
|
||||||
if(!fileMiME.getCode().equals("200")) {
|
|
||||||
msg.setCode("4000");
|
|
||||||
msg.setInfo(fileMiME.getInfo());
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
if(md5key==null || md5key.equals("")){
|
|
||||||
md5key = UUID.randomUUID().toString().replace("-", "");
|
|
||||||
}
|
|
||||||
if(Integer.valueOf(sysConfigService.getstate().getCheckduplicate())==1){
|
|
||||||
Images imaOBJ = new Images();
|
|
||||||
imaOBJ.setMd5key(md5key);
|
|
||||||
imaOBJ.setUserid(u==null?0:u.getId());
|
|
||||||
if(imgMapper.md5Count(imaOBJ)>0){
|
|
||||||
List<Images> images = imgMapper.selectImgUrlByMD5(md5key);
|
|
||||||
jsonObject.put("url", images.get(0).getImgurl());
|
|
||||||
jsonObject.put("name",file.getName());
|
|
||||||
jsonObject.put("imguid",images.get(0).getImguid());
|
|
||||||
msg.setData(jsonObject);
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String prefix = file.getName().substring(file.getName().lastIndexOf(".")+1);
|
|
||||||
//判断黑名单
|
|
||||||
if (uploadConfig.getBlacklist() != null) {
|
if (uploadConfig.getBlacklist() != null) {
|
||||||
String[] iparr = uploadConfig.getBlacklist().split(";");
|
String[] iparr = uploadConfig.getBlacklist().split(";");
|
||||||
for (String s : iparr) {
|
for (String s : iparr) {
|
||||||
@@ -134,229 +106,321 @@ public class UploadServicel {
|
|||||||
file.delete();
|
file.delete();
|
||||||
msg.setCode("4003");
|
msg.setCode("4003");
|
||||||
msg.setInfo("你暂时不能上传");
|
msg.setInfo("你暂时不能上传");
|
||||||
|
try {
|
||||||
|
if(stream!=null){stream.close();}
|
||||||
|
file.delete();
|
||||||
|
} catch (Exception e) { }
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Map<String, File> map = new HashMap<>();
|
sourceKeyId = group.getKeyid();
|
||||||
|
Keys key = keysMapper.selectKeys(sourceKeyId);
|
||||||
|
Long tmp = (memory == -1 ? -2 : UsedTotleMemory);
|
||||||
|
if (tmp >= memory) {
|
||||||
|
msg.setCode("4005");
|
||||||
|
msg.setInfo(u == null ? "游客空间已用尽" : "您的可用空间不足");
|
||||||
|
try {
|
||||||
|
if(stream!=null){stream.close();}
|
||||||
|
file.delete();
|
||||||
|
} catch (Exception e) { }
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
if (file.length() > TotleMemory) {
|
||||||
|
msg.setCode("4006");
|
||||||
|
msg.setInfo("图像超出系统限制大小");
|
||||||
|
try {
|
||||||
|
if(stream!=null){stream.close();}
|
||||||
|
file.delete();
|
||||||
|
} catch (Exception e) { }
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
Msg fileMiME = TypeDict.FileMiME(stream);
|
||||||
|
if (!fileMiME.getCode().equals("200")) {
|
||||||
|
msg.setCode("4000");
|
||||||
|
msg.setInfo(fileMiME.getInfo());
|
||||||
|
try {
|
||||||
|
if(stream!=null){stream.close();}
|
||||||
|
file.delete();
|
||||||
|
} catch (Exception e) { }
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
if (md5key == null || md5key.equals("")) {
|
||||||
|
md5key = DigestUtils.md5Hex(stream);
|
||||||
|
// 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);
|
||||||
|
try {
|
||||||
|
if(stream!=null){stream.close();}
|
||||||
|
} catch (Exception e) { }
|
||||||
|
// 判断路径格式 处理一下,去掉最前面的/
|
||||||
|
String RootPath = key.getRootPath().replace(" ", "");
|
||||||
|
if (!RootPath.equals("/")) {
|
||||||
|
updatePath = RootPath.substring(1) + "/" + updatePath;
|
||||||
|
}
|
||||||
|
// 先存数据库
|
||||||
|
Images imgObj = new Images();
|
||||||
|
String imgnameEd = null;
|
||||||
|
Map<Map<String, String>, File> map = new HashMap<>();
|
||||||
|
String shortUuid_y = SetText.getShortUuid();
|
||||||
|
String shortUuid_s = SetText.getShortUuid();
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
map.put(prefix, file);//prefix
|
Map<String, String> m1 = new HashMap<>();
|
||||||
|
m1.put("prefix", prefix);
|
||||||
|
m1.put("name", shortUuid_y);
|
||||||
|
map.put(m1, file);
|
||||||
|
imgnameEd = updatePath + "/" + shortUuid_y + "." + prefix;
|
||||||
|
imgObj.setImgname(imgnameEd);
|
||||||
|
if (key.getStorageType().equals(5)) {
|
||||||
|
imgObj.setImgurl(confdata.getString("domain") + "/ota/" + imgnameEd);
|
||||||
|
} else if(key.getStorageType().equals(9) && key.getSysTransmit()){
|
||||||
|
imgObj.setImgurl(confdata.getString("domain") + "/w/" + shortUuid_y);
|
||||||
|
}else {
|
||||||
|
imgObj.setImgurl(key.getRequestAddress() + "/" + imgnameEd);
|
||||||
|
}
|
||||||
|
imgObj.setSizes(Long.toString(file.length()));
|
||||||
|
}else{
|
||||||
|
msg.setInfo("未获取到指定图像:110503");
|
||||||
|
msg.setCode("110503");
|
||||||
|
try { file.delete(); } catch (Exception e) { }
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
imgObj.setUpdatetime(df.format(new Date()));
|
||||||
|
imgObj.setSource(key.getId());
|
||||||
|
imgObj.setUserid(u == null ? 0 : u.getId());
|
||||||
|
if (setday == 1 || setday == 3 || setday == 7 || setday == 30) {
|
||||||
|
imgObj.setImgtype(1);
|
||||||
|
ImgTemp imgDataExp = new ImgTemp();
|
||||||
|
imgDataExp.setDeltime(plusDay(setday));
|
||||||
|
imgDataExp.setImguid(imguid);
|
||||||
|
imgTempService.insertImgExp(imgDataExp);
|
||||||
|
} else {
|
||||||
|
imgObj.setImgtype(0);
|
||||||
|
}
|
||||||
|
imgObj.setAbnormal(userip);
|
||||||
|
imgObj.setMd5key(md5key);
|
||||||
|
imgObj.setImguid(imguid);
|
||||||
|
imgObj.setFormat(fileMiME.getData().toString());
|
||||||
|
imgObj.setShortlink(shortUuid_y);
|
||||||
|
imgObj.setBrieflink(shortUuid_s);
|
||||||
|
imgObj.setIdname(imgName);
|
||||||
|
// Integer insertRet = imgMapper.insertImgData(imgObj);
|
||||||
|
Msg insertRet = imgServiceImpl.insertImgDataForCheck(imgObj,u,confdata,file.getName());
|
||||||
|
if (insertRet.getCode().equals("000")) {
|
||||||
|
try { file.delete(); } catch (Exception e) { }
|
||||||
|
return insertRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
long stime = System.currentTimeMillis();
|
long stime = System.currentTimeMillis();
|
||||||
Map<ReturnImage, Integer> m = null;
|
System.out.println("上传前地址:"+updatePath);
|
||||||
ReturnImage returnImage = GetSource.storageSource(key.getStorageType(), map, updatePath, key.getId());
|
ReturnImage returnImage = getSource.storageSource(key.getStorageType(), map, updatePath, key.getId());
|
||||||
Images img = new Images();
|
if (returnImage.getCode().equals("200")) {
|
||||||
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
||||||
if(returnImage.getCode().equals("200")){
|
|
||||||
String imgurl = returnImage.getImgurl();
|
|
||||||
Long imgsize = returnImage.getImgSize();
|
|
||||||
String imgname = returnImage.getImgname();
|
|
||||||
img.setImgurl(imgurl);
|
|
||||||
img.setUpdatetime(df.format(new Date()));
|
|
||||||
img.setSource(key.getId());
|
|
||||||
img.setUserid(u == null ? 0 : u.getId());
|
|
||||||
img.setSizes(imgsize.toString());
|
|
||||||
if(uploadConfig.getUrltype()==2){
|
|
||||||
img.setImgname(imgname);
|
|
||||||
}else{
|
|
||||||
img.setImgname(SetText.getSubString(imgname, key.getRequestAddress() + "/", ""));
|
|
||||||
}
|
|
||||||
if(setday == 1 || setday == 3 || setday == 7 || setday == 30){
|
|
||||||
img.setImgtype(1);
|
|
||||||
ImgTemp imgDataExp = new ImgTemp();
|
|
||||||
imgDataExp.setDeltime(plusDay(setday));
|
|
||||||
imgDataExp.setImguid(imguid);
|
|
||||||
imgTempService.insertImgExp(imgDataExp);
|
|
||||||
}else{
|
|
||||||
img.setImgtype(0);
|
|
||||||
}
|
|
||||||
img.setAbnormal(userip);
|
|
||||||
img.setMd5key(md5key);
|
|
||||||
img.setImguid(imguid);
|
|
||||||
img.setFormat(fileMiME.getData().toString());
|
|
||||||
img.setIdname(imageFileName);
|
|
||||||
userMapper.insertimg(img);
|
|
||||||
long etime = System.currentTimeMillis();
|
long etime = System.currentTimeMillis();
|
||||||
Print.Normal("上传图片所用总时长:" + String.valueOf(etime - stime) + "ms");
|
Print.Normal("上传图片所用总时长:" + String.valueOf(etime - stime) + "ms");
|
||||||
jsonObject.put("url", img.getImgurl());
|
jsonObject.put("url", imgObj.getImgurl());
|
||||||
jsonObject.put("name", imgname);
|
jsonObject.put("name", imgObj.getImgname());
|
||||||
jsonObject.put("imguid",img.getImguid());
|
jsonObject.put("imguid", imgObj.getImguid());
|
||||||
new Thread(()->{LegalImageCheck(img);}).start();
|
imgViolationJudgeService.LegalImageCheck(imgObj,key);
|
||||||
}else{
|
} else {
|
||||||
|
imgServiceImpl.deleimgForImgUid(imgObj.getImguid());
|
||||||
msg.setCode("5001");
|
msg.setCode("5001");
|
||||||
msg.setInfo("上传服务内部错误");
|
msg.setInfo("上传服务内部错误");
|
||||||
|
try { file.delete(); } catch (Exception e) { }
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
file.delete();
|
|
||||||
msg.setData(jsonObject);
|
msg.setData(jsonObject);
|
||||||
|
file.delete();
|
||||||
return msg;
|
return msg;
|
||||||
}catch (Exception e){
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
msg.setInfo("上传时发生了一些错误");
|
msg.setInfo("上传时发生了一些错误");
|
||||||
msg.setCode("110500");
|
msg.setCode("110500");
|
||||||
|
file.delete();
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Msg uploadForURL(HttpServletRequest request, String imgurl){
|
public CompletableFuture<Msg> mergeFile(HttpServletRequest request, String data, User user){
|
||||||
final 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 = request.getSession().getServletContext().getRealPath("/")+File.separator+"hellohaotmp"+File.separator;
|
String classifications = jsonObj.getString("classifications");
|
||||||
Map<String ,Object> bl =ImgUrlUtil.downLoadFromUrl (imgurl, ShortUID, savePath);
|
Integer day = jsonObj.getInteger("day");
|
||||||
if((Boolean) bl.get("res")==true){
|
String imgIdentifier = jsonObj.getString("imgIdentifier");
|
||||||
msg.setCode("200");
|
JSONArray jsonArray = new JSONArray();
|
||||||
msg.setData(bl.get("imgPath"));
|
classifications = classifications==null?"":classifications;
|
||||||
return msg;
|
if(!org.apache.commons.lang3.StringUtils.isBlank(classifications)){
|
||||||
}else{
|
String[] calssif = classifications.split(",");
|
||||||
if(bl.get("StatusCode").equals("110403")){
|
for (int i = 0; i < calssif.length; i++) {
|
||||||
msg.setInfo("该链接非图像文件,无法上传");
|
jsonArray.add(calssif[i]);
|
||||||
}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;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Group group; //上传用户或游客的所属分组
|
// private static Group group; // 上传用户或游客的所属分组
|
||||||
private static Long memory;//上传用户或者游客的分配容量 memory
|
// private static Long memory; // 上传用户或者游客的分配容量 memory
|
||||||
private static Long TotleMemory;//用户或者游客下可使用的总容量 //maxsize
|
// private static Long TotleMemory; // 用户或者游客下可使用的总容量 //maxsize
|
||||||
private static Long UsedTotleMemory;//用户或者游客已经用掉的总容量 //usermemory
|
// private static Long UsedTotleMemory; // 用户或者游客已经用掉的总容量 //usermemory
|
||||||
private static String updatePath="tourist";
|
// private static String updatePath = "tourist";
|
||||||
|
|
||||||
//判断用户 或 游客 当前上传图片的一系列校验
|
// 判断用户 或 游客 当前上传图片的一系列校验
|
||||||
private Msg updateImgCheck(User user, UploadConfig uploadConfig){
|
private Msg updateImgCheck(User user, UploadConfig uploadConfig) {
|
||||||
final Msg msg = new Msg();
|
Msg msg = new Msg();
|
||||||
java.text.DateFormat dateFormat = null;
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
String updatePath = "tourist";
|
||||||
try {
|
try {
|
||||||
dateFormat = new SimpleDateFormat("yyyy/MM/dd");
|
Group group = GetCurrentSource.GetSource(user == null ? null : user.getId());
|
||||||
|
jsonObject.put("group",group);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
if(uploadConfig.getIsupdate()!=1){
|
if (uploadConfig.getIsupdate() != 1) {
|
||||||
msg.setCode("1000");
|
msg.setCode("1000");
|
||||||
msg.setInfo("系统已禁用游客上传");
|
msg.setInfo("系统已禁用游客上传");
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
updatePath="tourist";
|
updatePath = "tourist";
|
||||||
group = GetCurrentSource.GetSource(null);
|
Long memory = Long.valueOf(uploadConfig.getVisitormemory()); // 单位 B 游客设置总量
|
||||||
memory = Long.valueOf(uploadConfig.getVisitormemory());//单位 B 游客设置总量
|
Long TotleMemory = Long.valueOf(uploadConfig.getFilesizetourists()); // 单位 B 游客单文件大小
|
||||||
TotleMemory = Long.valueOf(uploadConfig.getFilesizetourists());//单位 B 游客单文件大小
|
Long UsedTotleMemory =
|
||||||
UsedTotleMemory = imgMapper.getusermemory(0)==null?0L : imgMapper.getusermemory(0);//单位 B
|
imgServiceImpl.getusermemory(0) == null
|
||||||
|
? 0L
|
||||||
|
: imgServiceImpl.getusermemory(0); // 单位 B
|
||||||
|
jsonObject.put("memory",memory);
|
||||||
|
jsonObject.put("TotleMemory",TotleMemory);
|
||||||
|
jsonObject.put("UsedTotleMemory",UsedTotleMemory);
|
||||||
} else {
|
} else {
|
||||||
if(uploadConfig.getUserclose()!=1){
|
if (uploadConfig.getUserclose() != 1) {
|
||||||
msg.setCode("1001");
|
msg.setCode("1001");
|
||||||
msg.setInfo("系统已禁用上传功能");
|
msg.setInfo("系统已禁用上传功能");
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
updatePath = user.getUsername();
|
updatePath = user.getUsername();
|
||||||
group= GetCurrentSource.GetSource(user.getId());
|
Long memory = Long.valueOf(user.getMemory()); // 单位 B *1024*1024
|
||||||
memory = Long.valueOf(user.getMemory());//单位 B *1024*1024
|
Long TotleMemory = Long.valueOf(uploadConfig.getFilesizeuser()); // 单位 B
|
||||||
TotleMemory = Long.valueOf(uploadConfig.getFilesizeuser());//单位 B
|
Long UsedTotleMemory =
|
||||||
UsedTotleMemory = imgMapper.getusermemory(user.getId())==null?0L:imgMapper.getusermemory(user.getId());//单位 B
|
imgServiceImpl.getusermemory(user.getId()) == null
|
||||||
|
? 0L
|
||||||
|
: imgServiceImpl.getusermemory(user.getId()); // 单位 B
|
||||||
|
jsonObject.put("memory",memory);
|
||||||
|
jsonObject.put("TotleMemory",TotleMemory);
|
||||||
|
jsonObject.put("UsedTotleMemory",UsedTotleMemory);
|
||||||
}
|
}
|
||||||
if (uploadConfig.getUrltype() == 2) {
|
if (uploadConfig.getUrltype() == 2) {
|
||||||
updatePath = dateFormat.format(new Date());
|
LocalDate currentDate = LocalDate.now();
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
|
||||||
|
updatePath = currentDate.format(formatter);
|
||||||
}
|
}
|
||||||
|
jsonObject.put("updatePath",updatePath);
|
||||||
|
msg.setData(jsonObject);
|
||||||
msg.setCode("300");
|
msg.setCode("300");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
logger.error("updateImgCheck异常:",e);
|
||||||
msg.setCode("500");
|
msg.setCode("500");
|
||||||
}
|
}
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
private synchronized void LegalImageCheck(Images images){
|
|
||||||
System.out.println("非法图像鉴别进程启动");
|
|
||||||
Imgreview imgreview = null;
|
|
||||||
try {
|
|
||||||
imgreview = imgreviewMapper.selectByusing(1);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Print.warning("获取鉴别程序的时候发生错误");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
if(null != imgreview){
|
|
||||||
LegalImageCheckForBaiDu(imgreview,images);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
// 计算时间
|
||||||
|
public static String plusDay(int setday) {
|
||||||
private void LegalImageCheckForBaiDu(Imgreview imgreview,Images images){
|
|
||||||
System.out.println("非法图像鉴别进程启动-BaiDu");
|
|
||||||
if(imgreview.getUsing()==1){
|
|
||||||
try {
|
|
||||||
AipContentCensor client = new AipContentCensor(imgreview.getAppId(), imgreview.getApiKey(), imgreview.getSecretKey());
|
|
||||||
client.setConnectionTimeoutInMillis(5000);
|
|
||||||
client.setSocketTimeoutInMillis(30000);
|
|
||||||
org.json.JSONObject res = client.antiPorn(images.getImgurl());
|
|
||||||
res = client.imageCensorUserDefined(images.getImgurl(), EImgType.URL, null);
|
|
||||||
System.err.println("返回的鉴黄json:"+res.toString());
|
|
||||||
com.alibaba.fastjson.JSONArray jsonArray = JSON.parseArray("[" + res.toString() + "]");
|
|
||||||
for (Object o : jsonArray) {
|
|
||||||
com.alibaba.fastjson.JSONObject jsonObject = (com.alibaba.fastjson.JSONObject) o;
|
|
||||||
com.alibaba.fastjson.JSONArray data = jsonObject.getJSONArray("data");
|
|
||||||
Integer conclusionType = jsonObject.getInteger("conclusionType");
|
|
||||||
if(conclusionType!=null){
|
|
||||||
if (conclusionType == 2) {
|
|
||||||
for (Object datum : data) {
|
|
||||||
com.alibaba.fastjson.JSONObject imgdata = (com.alibaba.fastjson.JSONObject) datum;
|
|
||||||
if (imgdata.getInteger("type") == 1) {
|
|
||||||
Images img = new Images();
|
|
||||||
img.setImgname(images.getImgname());
|
|
||||||
img.setViolation("1[1]");
|
|
||||||
imgMapper.setImg(img);
|
|
||||||
Imgreview imgv = new Imgreview();
|
|
||||||
imgv.setId(1);
|
|
||||||
Integer count = imgreview.getCount();
|
|
||||||
System.out.println("违法图片总数:" + count);
|
|
||||||
imgv.setCount(count + 1);
|
|
||||||
imgreviewMapper.updateByPrimaryKeySelective(imgv);
|
|
||||||
System.err.println("存在非法图片,进行处理操作");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}catch (Exception e){
|
|
||||||
System.out.println("图像鉴黄线程执行过程中出现异常");
|
|
||||||
e.printStackTrace();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//计算时间
|
|
||||||
public static String plusDay(int setday){
|
|
||||||
Date d = new Date();
|
Date d = new Date();
|
||||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
String currdate = format.format(d);
|
|
||||||
System.out.println("现在的日期是:" + currdate);
|
|
||||||
Calendar ca = Calendar.getInstance();
|
Calendar ca = Calendar.getInstance();
|
||||||
ca.setTime(d);
|
ca.setTime(d);
|
||||||
ca.add(Calendar.DATE, setday);// num为增加的天数,可以改变的
|
ca.add(Calendar.DATE, setday); // num为增加的天数,可以改变的
|
||||||
d = ca.getTime();
|
d = ca.getTime();
|
||||||
String enddate = format.format(d);
|
String enddate = format.format(d);
|
||||||
System.out.println("到期的日期:" + enddate);
|
System.out.println("到期的日期:" + enddate);
|
||||||
return enddate;
|
return enddate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package cn.hellohao.service.impl;
|
|||||||
import cn.hellohao.dao.CodeMapper;
|
import cn.hellohao.dao.CodeMapper;
|
||||||
import cn.hellohao.dao.UserMapper;
|
import cn.hellohao.dao.UserMapper;
|
||||||
import cn.hellohao.exception.CodeException;
|
import cn.hellohao.exception.CodeException;
|
||||||
import cn.hellohao.pojo.Images;
|
|
||||||
import cn.hellohao.pojo.User;
|
import cn.hellohao.pojo.User;
|
||||||
import cn.hellohao.service.UserService;
|
import cn.hellohao.service.UserService;
|
||||||
import cn.hellohao.utils.Print;
|
import cn.hellohao.utils.Print;
|
||||||
@@ -42,11 +41,6 @@ public class UserServiceImpl implements UserService {
|
|||||||
return userMapper.getUsers(user);
|
return userMapper.getUsers(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Integer insertimg(Images img) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return userMapper.insertimg(img);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Integer change(User user) {
|
public Integer change(User user) {
|
||||||
|
|||||||
@@ -0,0 +1,210 @@
|
|||||||
|
package cn.hellohao.service.impl;
|
||||||
|
|
||||||
|
import cn.hellohao.config.GlobalConstant;
|
||||||
|
import cn.hellohao.pojo.Images;
|
||||||
|
import cn.hellohao.pojo.Keys;
|
||||||
|
import cn.hellohao.pojo.Msg;
|
||||||
|
import cn.hellohao.pojo.ReturnImage;
|
||||||
|
import cn.hellohao.service.ImgService;
|
||||||
|
import cn.hellohao.service.KeysService;
|
||||||
|
import cn.hellohao.utils.TypeDict;
|
||||||
|
import com.github.sardine.impl.methods.HttpMkCol;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.http.HttpResponse;
|
||||||
|
import org.apache.http.auth.AuthScope;
|
||||||
|
import org.apache.http.auth.UsernamePasswordCredentials;
|
||||||
|
import org.apache.http.client.CredentialsProvider;
|
||||||
|
import org.apache.http.client.methods.*;
|
||||||
|
import org.apache.http.entity.ContentType;
|
||||||
|
import org.apache.http.entity.FileEntity;
|
||||||
|
import org.apache.http.entity.StringEntity;
|
||||||
|
import org.apache.http.impl.client.BasicCredentialsProvider;
|
||||||
|
import org.apache.http.impl.client.CloseableHttpClient;
|
||||||
|
import org.apache.http.impl.client.HttpClients;
|
||||||
|
import org.apache.http.util.EntityUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.core.io.InputStreamResource;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class WebDAVImageupload {
|
||||||
|
|
||||||
|
static CloseableHttpClient httpClient;
|
||||||
|
static Keys key;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ImgService imgService;
|
||||||
|
@Autowired
|
||||||
|
private KeysService keysService;
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(WebDAVImageupload.class);
|
||||||
|
public ReturnImage ImageuploadWebDAV(Map<Map<String, String>, File> fileMap, String username,Integer keyID) {
|
||||||
|
ReturnImage returnImage = new ReturnImage();
|
||||||
|
try {
|
||||||
|
if(null==httpClient || null==key){
|
||||||
|
System.out.println("WebDAV = 存储源对象为空");
|
||||||
|
returnImage.setCode("500");
|
||||||
|
return returnImage;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("ImageuploadWebDAV:61异常",e);
|
||||||
|
System.out.println("WebDAV = 存储源对象为空");
|
||||||
|
returnImage.setCode("500");
|
||||||
|
return returnImage;
|
||||||
|
}
|
||||||
|
File file = null;
|
||||||
|
try {
|
||||||
|
for (Map.Entry<Map<String, String>, File> entry : fileMap.entrySet()) {
|
||||||
|
String prefix = entry.getKey().get("prefix");
|
||||||
|
String ShortUIDName = entry.getKey().get("name");
|
||||||
|
file = entry.getValue();
|
||||||
|
createDirectories(httpClient, key.getEndpoint(), "/" + username);
|
||||||
|
HttpPut httpPut = new HttpPut(key.getEndpoint() + "/" + username + "/" + ShortUIDName + "." + prefix);
|
||||||
|
FileEntity fileEntity = new FileEntity(file, ContentType.DEFAULT_BINARY);
|
||||||
|
httpPut.setEntity(fileEntity);
|
||||||
|
HttpResponse response = httpClient.execute(httpPut);
|
||||||
|
final int statusCode = response.getStatusLine().getStatusCode();
|
||||||
|
logger.info("WebDav上传响应代码:"+statusCode);
|
||||||
|
EntityUtils.consume(response.getEntity());
|
||||||
|
if(statusCode >= 200 && statusCode < 300){
|
||||||
|
returnImage.setCode("200");
|
||||||
|
}else{
|
||||||
|
returnImage.setCode(Integer.toString(statusCode));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("ImageuploadWebDAV:87异常",e);
|
||||||
|
returnImage.setCode("500");
|
||||||
|
}
|
||||||
|
return returnImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
//webdav初始化
|
||||||
|
public static Integer Initialize(Keys k) {
|
||||||
|
int ret = -1;
|
||||||
|
try {
|
||||||
|
if(k.getSysTransmit()==false){
|
||||||
|
if (StringUtils.isBlank(k.getAccessKey())
|
||||||
|
|| StringUtils.isBlank(k.getAccessSecret())
|
||||||
|
|| StringUtils.isBlank(k.getEndpoint())
|
||||||
|
|| StringUtils.isBlank(k.getRequestAddress())) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if (StringUtils.isBlank(k.getAccessKey())
|
||||||
|
|| StringUtils.isBlank(k.getAccessSecret())
|
||||||
|
|| StringUtils.isBlank(k.getEndpoint())) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String endpoint = k.getEndpoint();
|
||||||
|
CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
|
||||||
|
credentialsProvider.setCredentials(
|
||||||
|
new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT),
|
||||||
|
new UsernamePasswordCredentials(k.getAccessKey(), k.getAccessSecret()));
|
||||||
|
CloseableHttpClient httpClientObj = HttpClients.custom()
|
||||||
|
.setDefaultCredentialsProvider(credentialsProvider)
|
||||||
|
.build();
|
||||||
|
HttpUriRequest request = RequestBuilder.create("PROPFIND")
|
||||||
|
.setUri(endpoint +"/"+ k.getRootPath())
|
||||||
|
.addHeader("Depth", "1")
|
||||||
|
.setEntity(new StringEntity(
|
||||||
|
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n" +
|
||||||
|
"<D:propfind xmlns:D=\"DAV:\">\n" +
|
||||||
|
" <D:allprop/>\n" +
|
||||||
|
"</D:propfind>",
|
||||||
|
ContentType.create("text/xml", "UTF-8")))
|
||||||
|
.build();
|
||||||
|
HttpResponse response = httpClientObj.execute(request);
|
||||||
|
System.out.println("=====>"+response.getStatusLine().getStatusCode());
|
||||||
|
if(response.getStatusLine().getStatusCode()==207 || response.getStatusLine().getStatusCode()==404){
|
||||||
|
ret = 1;
|
||||||
|
httpClient = httpClientObj;
|
||||||
|
key = k;
|
||||||
|
}else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
EntityUtils.consume(response.getEntity());
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("WebDAV初始化失败", e);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean delWebDAV(Integer keyID, Images images) {
|
||||||
|
boolean b = true;
|
||||||
|
try {
|
||||||
|
Keys keys = keysService.selectKeys(images.getSource());
|
||||||
|
String rootPath = keys.getRootPath().equals("/")?"":keys.getRootPath();
|
||||||
|
String fileUrl = keys.getEndpoint()+"/"+images.getImgname();
|
||||||
|
System.err.println("删除缩yuan图:"+fileUrl);
|
||||||
|
HttpDelete httpDelete = new HttpDelete(fileUrl);
|
||||||
|
HttpResponse response = httpClient.execute(httpDelete);
|
||||||
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
|
if (statusCode == 204) {
|
||||||
|
logger.info("File deleted: " + fileUrl);
|
||||||
|
// checkAndDeleteEmptyParentDirectories(httpClient,fileUrl);
|
||||||
|
} else {
|
||||||
|
logger.error("Failed to delete file: " + fileUrl);
|
||||||
|
}
|
||||||
|
EntityUtils.consume(response.getEntity());
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("WebDav删除异常:",e);
|
||||||
|
b = false;
|
||||||
|
}
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ResponseEntity<InputStreamResource> getWebDAV(String shortUuid) {
|
||||||
|
boolean b = true;
|
||||||
|
try {
|
||||||
|
Images images = null;
|
||||||
|
images = imgService.selectImgByShortlink(shortUuid);
|
||||||
|
Keys keys = keysService.selectKeys(images.getSource());
|
||||||
|
String rootPath = keys.getRootPath().equals("/")?"":keys.getRootPath();
|
||||||
|
String fileUrl = keys.getEndpoint()+"/"+images.getImgname();
|
||||||
|
HttpGet httpGet = new HttpGet(fileUrl);
|
||||||
|
HttpResponse response = httpClient.execute(httpGet);
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.add("Content-Type", "image/jpeg");
|
||||||
|
return ResponseEntity.ok()
|
||||||
|
.headers(headers)
|
||||||
|
.body(new InputStreamResource(response.getEntity().getContent()));
|
||||||
|
} catch (IOException e) {
|
||||||
|
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void createDirectories(CloseableHttpClient httpClient, String baseUrl, String directoryPath) throws Exception {
|
||||||
|
String[] directories = directoryPath.split("/");
|
||||||
|
String currentPath = baseUrl;
|
||||||
|
for (String directory : directories) {
|
||||||
|
currentPath += directory + "/";
|
||||||
|
HttpMkCol httpMkCol = new HttpMkCol(currentPath);
|
||||||
|
HttpResponse response = httpClient.execute(httpMkCol);
|
||||||
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
|
if (statusCode == 201) {
|
||||||
|
System.out.println("Directory created: " + currentPath);
|
||||||
|
} else if (statusCode == 405) {
|
||||||
|
System.out.println("Directory already exists: " + currentPath);
|
||||||
|
} else {
|
||||||
|
System.err.println("Failed to create directory: " + currentPath);
|
||||||
|
}
|
||||||
|
EntityUtils.consume(response.getEntity());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,104 +3,178 @@ package cn.hellohao.service.impl;
|
|||||||
import cn.hellohao.pojo.Images;
|
import cn.hellohao.pojo.Images;
|
||||||
import cn.hellohao.pojo.Keys;
|
import cn.hellohao.pojo.Keys;
|
||||||
import cn.hellohao.pojo.Msg;
|
import cn.hellohao.pojo.Msg;
|
||||||
|
import cn.hellohao.service.IRedisService;
|
||||||
import cn.hellohao.service.ImgAndAlbumService;
|
import cn.hellohao.service.ImgAndAlbumService;
|
||||||
import cn.hellohao.service.ImgService;
|
import cn.hellohao.service.ImgService;
|
||||||
import cn.hellohao.service.ImgTempService;
|
import cn.hellohao.service.ImgTempService;
|
||||||
import cn.hellohao.utils.LocUpdateImg;
|
import cn.hellohao.utils.LocUpdateImg;
|
||||||
import cn.hellohao.utils.progress.MyProgress;
|
import cn.hellohao.utils.progress.MyProgress;
|
||||||
|
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 javax.servlet.http.HttpSession;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class deleImages {
|
public class deleImages {
|
||||||
|
|
||||||
|
@Autowired private NOSImageupload nosImageupload;
|
||||||
|
@Autowired private OSSImageupload ossImageupload;
|
||||||
|
@Autowired private COSImageupload cosImageupload;
|
||||||
|
@Autowired private KODOImageupload kodoImageupload;
|
||||||
|
@Autowired private USSImageupload ussImageupload;
|
||||||
|
@Autowired private S3Imageupload s3Imageupload;
|
||||||
|
@Autowired private FtpServiceImpl ftpService;
|
||||||
|
@Autowired private WebDAVImageupload webDAVImageupload;
|
||||||
|
@Autowired private ImgAndAlbumService imgAndAlbumService;
|
||||||
|
@Autowired private ImgTempService imgTempService;
|
||||||
|
@Autowired private ImgService imgService;
|
||||||
|
@Autowired private KeysServiceImpl keysService;
|
||||||
|
@Autowired private IRedisService iRedisService;
|
||||||
|
|
||||||
@Autowired
|
public Msg dele(boolean forceDel,String uuid, Long... imgIds) {
|
||||||
private NOSImageupload nosImageupload;
|
Msg msg = new Msg();
|
||||||
@Autowired
|
MyProgress myProgress = new MyProgress();
|
||||||
private OSSImageupload ossImageupload;
|
myProgress.InitializeDelImg();
|
||||||
@Autowired
|
List<Long> ids = new ArrayList<>();
|
||||||
private COSImageupload cosImageupload;
|
int successCount = 0;
|
||||||
@Autowired
|
List<String> errorIds = new ArrayList<>();
|
||||||
private KODOImageupload kodoImageupload;
|
for (int i = 0; i < imgIds.length; i++) {
|
||||||
@Autowired
|
// 删除图片
|
||||||
private USSImageupload ussImageupload;
|
boolean isDele = false;
|
||||||
@Autowired
|
try {
|
||||||
private UFileImageupload uFileImageupload;
|
Images image = imgService.selectByPrimaryKey(imgIds[i]);
|
||||||
@Autowired
|
if (forceDel) {
|
||||||
private FTPImageupload ftpImageupload;
|
try {
|
||||||
@Autowired
|
imgAndAlbumService.deleteImgAndAlbum(image.getImgurl());
|
||||||
private ImgAndAlbumService imgAndAlbumService;
|
imgTempService.delImgAndExp(image.getImguid());
|
||||||
@Autowired
|
imgService.deleimg(image.getId());
|
||||||
private ImgTempService imgTempService;
|
ids.add(image.getId());
|
||||||
@Autowired
|
successCount++;
|
||||||
private ImgService imgService;
|
System.out.println("删除成功加一个" + image.getId());
|
||||||
@Autowired
|
} catch (Exception e) {
|
||||||
private KeysServiceImpl keysService;
|
e.printStackTrace();
|
||||||
|
System.err.println(image.getImgname() + ":图片数据库记录时发生错误");
|
||||||
|
errorIds.add(image.getImgurl());
|
||||||
public Msg dele(HttpSession httpSession,Integer... imgIds) {
|
}
|
||||||
Msg msg = new Msg();
|
|
||||||
MyProgress myProgress = new MyProgress();
|
|
||||||
myProgress.InitializeDelImg();
|
|
||||||
List<Integer> ids = new ArrayList<>();
|
|
||||||
int successCount = 0;
|
|
||||||
List<String> errorIds = new ArrayList<>();
|
|
||||||
for (Integer id : imgIds) {
|
|
||||||
//删除图片
|
|
||||||
boolean isDele = false;
|
|
||||||
try {
|
|
||||||
Images image = imgService.selectByPrimaryKey(id);
|
|
||||||
Keys key = keysService.selectKeys(image.getSource());
|
|
||||||
if (key.getStorageType() == 1) {
|
|
||||||
isDele = nosImageupload.delNOS(key.getId(), image);
|
|
||||||
} else if (key.getStorageType() == 2) {
|
|
||||||
isDele = ossImageupload.delOSS(key.getId(), image);
|
|
||||||
} else if (key.getStorageType() == 3) {
|
|
||||||
isDele = ussImageupload.delUSS(key.getId(), image);
|
|
||||||
} else if (key.getStorageType() == 4) {
|
|
||||||
isDele = kodoImageupload.delKODO(key.getId(), image);
|
|
||||||
} else if (key.getStorageType() == 5) {
|
|
||||||
isDele = LocUpdateImg.deleteLOCImg(image);
|
|
||||||
} else if (key.getStorageType() == 6) {
|
|
||||||
isDele = cosImageupload.delCOS(key.getId(), image);
|
|
||||||
} else if (key.getStorageType() == 7) {
|
|
||||||
isDele = ftpImageupload.delFTP(key.getId(), image);
|
|
||||||
} else if (key.getStorageType() == 8) {
|
|
||||||
isDele = uFileImageupload.delUFile(key.getId(), image);
|
|
||||||
} else {
|
|
||||||
System.err.println("未获取到对象存储参数,删除失败。");
|
|
||||||
}
|
|
||||||
if(isDele){
|
|
||||||
try {
|
|
||||||
imgAndAlbumService.deleteImgAndAlbum(image.getImgurl());
|
|
||||||
imgTempService.delImgAndExp(image.getImguid());
|
|
||||||
imgService.deleimg(image.getId());
|
|
||||||
ids.add(image.getId());
|
|
||||||
successCount++;
|
|
||||||
System.out.println("删除成功加一个"+image.getId());
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
System.err.println(image.getImgname()+":图片数据库记录时发生错误");
|
|
||||||
errorIds.add(image.getImgurl());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
myProgress.setDelSuccessCount(successCount);
|
|
||||||
myProgress.setDelSuccessImgList(ids);
|
|
||||||
myProgress.setDelErrorImgListt(errorIds);
|
|
||||||
if(null !=httpSession){
|
|
||||||
httpSession.setAttribute("myProgressForDel",myProgress);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.err.println("删除的时候发生了一些异常");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
myProgress.setDelOCT(true);
|
Keys key = keysService.selectKeys(image.getSource());
|
||||||
msg.setData(ids);
|
if (key.getStorageType() == 1) {
|
||||||
return msg;
|
isDele = nosImageupload.delNOS(key.getId(), image);
|
||||||
|
} else if (key.getStorageType() == 2) {
|
||||||
|
isDele = ossImageupload.delOSS(key.getId(), image);
|
||||||
|
} else if (key.getStorageType() == 3) {
|
||||||
|
isDele = ussImageupload.delUSS(key.getId(), image);
|
||||||
|
} else if (key.getStorageType() == 4) {
|
||||||
|
isDele = kodoImageupload.delKODO(key.getId(), image);
|
||||||
|
} else if (key.getStorageType() == 5) {
|
||||||
|
isDele = LocUpdateImg.deleteLOCImg(image);
|
||||||
|
} else if (key.getStorageType() == 6) {
|
||||||
|
isDele = cosImageupload.delCOS(key.getId(), image);
|
||||||
|
} else if (key.getStorageType() == 7) {
|
||||||
|
isDele = ftpService.delFTP(key.getId(), image);
|
||||||
|
} else if (key.getStorageType() == 8) {
|
||||||
|
isDele = s3Imageupload.deleS3(key.getId(), image);
|
||||||
|
}else if (key.getStorageType() == 9) {
|
||||||
|
isDele = webDAVImageupload.delWebDAV(key.getId(), image);
|
||||||
|
} else {
|
||||||
|
System.err.println("未获取到对象存储参数,删除失败。");
|
||||||
|
}
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(uuid!=null){
|
||||||
|
myProgress.setDelSuccessCount(successCount);
|
||||||
|
myProgress.setDelSuccessImgList(ids);
|
||||||
|
myProgress.setDelErrorImgListt(errorIds);
|
||||||
|
if (imgIds.length == (i + 1)) {
|
||||||
|
myProgress.setDelOCT(1);
|
||||||
|
} else {
|
||||||
|
myProgress.setDelOCT(0);
|
||||||
|
}
|
||||||
|
iRedisService.setTimeValue(uuid, JSONObject.toJSONString(myProgress), 24L);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("删除的时候发生了一些异常");
|
||||||
|
ids.add(imgIds[i]);
|
||||||
|
successCount++;
|
||||||
|
if(uuid!=null){
|
||||||
|
myProgress.setDelSuccessCount(successCount);
|
||||||
|
myProgress.setDelSuccessImgList(ids);
|
||||||
|
myProgress.setDelErrorImgListt(errorIds);
|
||||||
|
if (imgIds.length == (i + 1)) {
|
||||||
|
myProgress.setDelOCT(1);
|
||||||
|
} else {
|
||||||
|
myProgress.setDelOCT(0);
|
||||||
|
}
|
||||||
|
iRedisService.setTimeValue(uuid, JSONObject.toJSONString(myProgress), 24L);
|
||||||
|
}
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
msg.setData(ids);
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Msg dele2(String... imgIds) {
|
||||||
|
Msg msg = new Msg();
|
||||||
|
List<Long> ids = new ArrayList<>();
|
||||||
|
for (int i = 0; i < imgIds.length; i++) {
|
||||||
|
try {
|
||||||
|
Images image = imgService.selectByPrimaryKey(Long.valueOf(imgIds[i]));
|
||||||
|
Keys key = keysService.selectKeys(image.getSource());
|
||||||
|
if (key.getStorageType() == 1) {
|
||||||
|
nosImageupload.delNOS(key.getId(), image);
|
||||||
|
} else if (key.getStorageType() == 2) {
|
||||||
|
ossImageupload.delOSS(key.getId(), image);
|
||||||
|
} else if (key.getStorageType() == 3) {
|
||||||
|
ussImageupload.delUSS(key.getId(), image);
|
||||||
|
} else if (key.getStorageType() == 4) {
|
||||||
|
kodoImageupload.delKODO(key.getId(), image);
|
||||||
|
} else if (key.getStorageType() == 5) {
|
||||||
|
LocUpdateImg.deleteLOCImg(image);
|
||||||
|
} else if (key.getStorageType() == 6) {
|
||||||
|
cosImageupload.delCOS(key.getId(), image);
|
||||||
|
} else if (key.getStorageType() == 7) {
|
||||||
|
ftpService.delFTP(key.getId(), image);
|
||||||
|
} else if (key.getStorageType() == 8) {
|
||||||
|
s3Imageupload.deleS3(key.getId(), image);
|
||||||
|
}else if (key.getStorageType() == 9) {
|
||||||
|
webDAVImageupload.delWebDAV(key.getId(), image);
|
||||||
|
} else {
|
||||||
|
System.err.println("未获取到对象存储参数,删除失败。");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
imgAndAlbumService.deleteImgAndAlbum(image.getImgurl());
|
||||||
|
imgTempService.delImgAndExp(image.getImguid());
|
||||||
|
imgService.deleimg(image.getId());
|
||||||
|
ids.add(image.getId());
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
System.err.println(image.getImgname() + ":图片数据库记录时发生错误");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("删除的时候发生了一些异常");
|
||||||
|
// ids.add(Long.valueOf(imgIds[i]));
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
msg.setData(ids);
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,51 @@
|
|||||||
package cn.hellohao.utils;
|
//package cn.hellohao.utils;
|
||||||
|
//
|
||||||
import sun.misc.BASE64Decoder;
|
//import java.io.IOException;
|
||||||
import sun.misc.BASE64Encoder;
|
//import java.util.Base64;
|
||||||
|
//
|
||||||
import java.io.IOException;
|
///**
|
||||||
import java.util.Base64;
|
// * Created by Hellohao on 2019-08-27.
|
||||||
|
// */
|
||||||
/**
|
//public class Base64Encryption {
|
||||||
* Created by Hellohao on 2019-08-27.
|
//// public static void toBaseCode(String str) {
|
||||||
*/
|
//// String data = encryptBASE64(str.getBytes());
|
||||||
public class Base64Encryption {
|
//// }
|
||||||
public static void toBaseCode(String str) {
|
//// public static String decryptBASE64(String key) {
|
||||||
String data = encryptBASE64(str.getBytes());
|
//// byte[] b =null;
|
||||||
}
|
//// try {
|
||||||
public static String decryptBASE64(String key) {
|
//// b = (new BASE64Decoder()).decodeBuffer(key);
|
||||||
byte[] b =null;
|
//// } catch (IOException e) {
|
||||||
try {
|
//// e.printStackTrace();
|
||||||
b = (new BASE64Decoder()).decodeBuffer(key);
|
//// }
|
||||||
} catch (IOException e) {
|
//// return new String(b);
|
||||||
e.printStackTrace();
|
//// }
|
||||||
}
|
//// public static String encryptBASE64(byte[] key) {
|
||||||
return new String(b);
|
//// String string = "SGVsbG9oYW8K";
|
||||||
}
|
//// return (new BASE64Encoder()).encodeBuffer(key).replaceAll("\r|\n", "");
|
||||||
public static String encryptBASE64(byte[] key) {
|
//// }
|
||||||
String string = "SGVsbG9oYW8K";
|
//
|
||||||
return (new BASE64Encoder()).encodeBuffer(key).replaceAll("\r|\n", "");
|
//
|
||||||
}
|
// public static void toBaseCode(String str) {
|
||||||
}
|
// String data = encryptBASE64(str.getBytes());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public static String decryptBASE64(String key) {
|
||||||
|
// byte[] b = null;
|
||||||
|
// try {
|
||||||
|
// b = Base64.getDecoder().decode(key);
|
||||||
|
// } catch (IllegalArgumentException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// return new String(b);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public static String encryptBASE64(byte[] key) {
|
||||||
|
// String string = "SGVsbG9oYW8K";
|
||||||
|
// return Base64.getEncoder().encodeToString(key);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package cn.hellohao.utils;
|
package cn.hellohao.utils;
|
||||||
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import sun.misc.BASE64Decoder;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import java.util.Base64;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* base64转为multipartFile工具类
|
* base64转为multipartFile工具类
|
||||||
@@ -74,21 +74,30 @@ public class Base64ToMultipartFile implements MultipartFile {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static MultipartFile base64Convert(String base64) {
|
public static MultipartFile base64Convert(String base64) {
|
||||||
String[] baseStrs = base64.split(",");
|
// String[] baseStrs = base64.split(",");
|
||||||
|
// BASE64Decoder decoder = new BASE64Decoder();
|
||||||
|
// byte[] b = new byte[0];
|
||||||
|
// try {
|
||||||
|
// b = decoder.decodeBuffer(baseStrs[1]);
|
||||||
|
// } catch (IOException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// for (int i = 0; i < b.length; ++i) {
|
||||||
|
// if (b[i] < 0) {
|
||||||
|
// b[i] += 256;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return new Base64ToMultipartFile (b, baseStrs[0]);
|
||||||
|
|
||||||
BASE64Decoder decoder = new BASE64Decoder();
|
String[] baseStrs = base64.split(",");
|
||||||
byte[] b = new byte[0];
|
byte[] b = Base64.getDecoder().decode(baseStrs[1]);
|
||||||
try {
|
|
||||||
b = decoder.decodeBuffer(baseStrs[1]);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
for (int i = 0; i < b.length; ++i) {
|
for (int i = 0; i < b.length; ++i) {
|
||||||
if (b[i] < 0) {
|
if (b[i] < 0) {
|
||||||
b[i] += 256;
|
b[i] += 256;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new Base64ToMultipartFile (b, baseStrs[0]);
|
return new Base64ToMultipartFile(b, baseStrs[0]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,324 +0,0 @@
|
|||||||
package cn.hellohao.utils;
|
|
||||||
|
|
||||||
import org.apache.commons.net.ftp.FTP;
|
|
||||||
import org.apache.commons.net.ftp.FTPClient;
|
|
||||||
import org.apache.commons.net.ftp.FTPFile;
|
|
||||||
import org.apache.commons.net.ftp.FTPReply;
|
|
||||||
import org.apache.log4j.LogManager;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>Title: </p>
|
|
||||||
* <p>Description: </p>
|
|
||||||
*
|
|
||||||
* @author Hellohao
|
|
||||||
* @date 2019年11月10日
|
|
||||||
*/
|
|
||||||
public class FTPUtils {
|
|
||||||
private final Logger LOGGER = LogManager.getLogger(getClass());
|
|
||||||
private FTPClient ftpClient = null;
|
|
||||||
private String server;
|
|
||||||
private int port;
|
|
||||||
private String userName;
|
|
||||||
private String userPassword;
|
|
||||||
public FTPUtils(String server, int port, String userName, String userPassword) {
|
|
||||||
this.server = server;
|
|
||||||
this.port = port;
|
|
||||||
this.userName = userName;
|
|
||||||
this.userPassword = userPassword;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean open() {
|
|
||||||
// 判断是否已连接
|
|
||||||
if (ftpClient != null && ftpClient.isConnected()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
ftpClient = new FTPClient();
|
|
||||||
// 连接FTP服务器
|
|
||||||
ftpClient.connect(this.server, this.port);
|
|
||||||
ftpClient.login(this.userName, this.userPassword);
|
|
||||||
int reply = ftpClient.getReplyCode();
|
|
||||||
if (!FTPReply.isPositiveCompletion(reply)) {
|
|
||||||
Print.warning("FTP服务器拒绝连接.");
|
|
||||||
this.close();
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
ftpClient.setFileType(FTP.BINARY_FILE_TYPE);
|
|
||||||
ftpClient.enterLocalPassiveMode();
|
|
||||||
return true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
this.close();
|
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>Title: 切换到父目录</p>
|
|
||||||
* <p>Description: </p>
|
|
||||||
*
|
|
||||||
* @author Hellohao
|
|
||||||
* @date 2018年10月11日
|
|
||||||
*
|
|
||||||
* @return 切换结果 true:成功, false:失败
|
|
||||||
*/
|
|
||||||
private boolean changeToParentDir() {
|
|
||||||
try {
|
|
||||||
return ftpClient.changeToParentDirectory();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param dir 目的目录
|
|
||||||
* @return 切换结果 true:成功,false:失败
|
|
||||||
*/
|
|
||||||
private boolean cd(String dir) {
|
|
||||||
try {
|
|
||||||
return ftpClient.changeWorkingDirectory(dir);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param filePath 指定的目录
|
|
||||||
* @return 文件列表,或者null
|
|
||||||
*/
|
|
||||||
private FTPFile[] getFileList(String filePath) {
|
|
||||||
try {
|
|
||||||
return ftpClient.listFiles(filePath);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param ftpPath 目的目录
|
|
||||||
* @return 切换结果
|
|
||||||
*/
|
|
||||||
public boolean changeDir(String ftpPath) {
|
|
||||||
if (!ftpClient.isConnected()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
char[] chars = ftpPath.toCharArray();
|
|
||||||
StringBuffer sbStr = new StringBuffer(256);
|
|
||||||
for (int i = 0; i < chars.length; i++) {
|
|
||||||
if ('\\' == chars[i]) {
|
|
||||||
sbStr.append('/');
|
|
||||||
} else {
|
|
||||||
sbStr.append(chars[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ftpPath = sbStr.toString();
|
|
||||||
if (ftpPath.indexOf('/') == -1) {
|
|
||||||
// 只有一层目录
|
|
||||||
ftpClient.changeWorkingDirectory(new String(ftpPath.getBytes(), "UTF-8"));
|
|
||||||
} else {
|
|
||||||
// 多层目录循环创建
|
|
||||||
String[] paths = ftpPath.split("/");
|
|
||||||
for (int i = 0; i < paths.length; i++) {
|
|
||||||
ftpClient.changeWorkingDirectory(new String(paths[i].getBytes(), "UTF-8"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ftpPath 需要创建的目录
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean mkDir(String ftpPath) {
|
|
||||||
if (!ftpClient.isConnected()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
// 将路径中的斜杠统一
|
|
||||||
char[] chars = ftpPath.toCharArray();
|
|
||||||
StringBuffer sbStr = new StringBuffer(256);
|
|
||||||
for (int i = 0; i < chars.length; i++) {
|
|
||||||
if ('\\' == chars[i]) {
|
|
||||||
sbStr.append('/');
|
|
||||||
} else {
|
|
||||||
sbStr.append(chars[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ftpPath = sbStr.toString();
|
|
||||||
if (ftpPath.indexOf('/') == -1) {
|
|
||||||
// 只有一层目录
|
|
||||||
ftpClient.makeDirectory(new String(ftpPath.getBytes(), "UTF-8"));
|
|
||||||
ftpClient.changeWorkingDirectory(new String(ftpPath.getBytes(), "UTF-8"));
|
|
||||||
} else {
|
|
||||||
// 多层目录循环创建
|
|
||||||
String[] paths = ftpPath.split("/");
|
|
||||||
for (int i = 0; i < paths.length; i++) {
|
|
||||||
ftpClient.makeDirectory(new String(paths[i].getBytes(), "UTF-8"));
|
|
||||||
ftpClient.changeWorkingDirectory(new String(paths[i].getBytes(), "UTF-8"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param //localDirectoryAndFileName 本地文件目录和文件名
|
|
||||||
* @param ftpFileName 上传到服务器的文件名()
|
|
||||||
* @param ftpDirectory FTP目录如:/path1/pathb2/,如果目录不存在会自动创建目录(目录可以省略)
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean upload(File srcFile, String ftpFileName, String ftpDirectory) {
|
|
||||||
if (!ftpClient.isConnected()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
boolean flag = false;
|
|
||||||
if (ftpClient != null) {
|
|
||||||
FileInputStream fis = null;
|
|
||||||
try {
|
|
||||||
fis = new FileInputStream(srcFile);
|
|
||||||
// 创建目录
|
|
||||||
this.mkDir(ftpDirectory);
|
|
||||||
ftpClient.setBufferSize(100000);
|
|
||||||
ftpClient.setControlEncoding("UTF-8");
|
|
||||||
// 设置文件类型(二进制)
|
|
||||||
ftpClient.setFileType(FTPClient.BINARY_FILE_TYPE);
|
|
||||||
|
|
||||||
if (ftpFileName == null || ftpFileName == "") {
|
|
||||||
ftpFileName = srcFile.getName();
|
|
||||||
}
|
|
||||||
// 上传
|
|
||||||
flag = ftpClient.storeFile(new String(ftpFileName.getBytes(), "UTF-8"), fis);
|
|
||||||
} catch (Exception e) {
|
|
||||||
this.close();
|
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
fis.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return flag;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ftpDirectoryAndFileName ftp服务器文件路径,以/dir形式开始
|
|
||||||
* @param localDirectoryAndFileName 保存到本地的目录
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean get(String ftpDirectoryAndFileName, String localDirectoryAndFileName) {
|
|
||||||
if (!ftpClient.isConnected()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
ftpClient.enterLocalPassiveMode();
|
|
||||||
try {
|
|
||||||
// 将路径中的斜杠统一
|
|
||||||
char[] chars = ftpDirectoryAndFileName.toCharArray();
|
|
||||||
StringBuffer sbStr = new StringBuffer(256);
|
|
||||||
for (int i = 0; i < chars.length; i++) {
|
|
||||||
if ('\\' == chars[i]) {
|
|
||||||
sbStr.append('/');
|
|
||||||
} else {
|
|
||||||
sbStr.append(chars[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ftpDirectoryAndFileName = sbStr.toString();
|
|
||||||
String filePath = ftpDirectoryAndFileName.substring(0, ftpDirectoryAndFileName.lastIndexOf("/"));
|
|
||||||
String fileName = ftpDirectoryAndFileName.substring(ftpDirectoryAndFileName.lastIndexOf("/") + 1);
|
|
||||||
this.changeDir(filePath);
|
|
||||||
ftpClient.retrieveFile(new String(fileName.getBytes(), "UTF-8"), new FileOutputStream(localDirectoryAndFileName)); // download
|
|
||||||
return true;
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param pathName
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String[] getFileNameList(String pathName) {
|
|
||||||
try {
|
|
||||||
return ftpClient.listNames(pathName);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>Title: 删除FTP上的文件</p>
|
|
||||||
* <p>Description: </p>
|
|
||||||
* @param ftpDirAndFileName 路径开头不能加/,比如应该是test/filename1
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean deleteFile(String ftpDirAndFileName) {
|
|
||||||
if (!ftpClient.isConnected()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return ftpClient.deleteFile(ftpDirAndFileName);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ftpDirectory
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean deleteDirectory(String ftpDirectory) {
|
|
||||||
if (!ftpClient.isConnected()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return ftpClient.removeDirectory(ftpDirectory);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>Title: 关闭链接</p>
|
|
||||||
* <p>Description: </p>
|
|
||||||
*/
|
|
||||||
public void close() {
|
|
||||||
try {
|
|
||||||
if (ftpClient != null && ftpClient.isConnected()) {
|
|
||||||
ftpClient.disconnect();
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,11 +1,15 @@
|
|||||||
package cn.hellohao.utils;
|
package cn.hellohao.utils;
|
||||||
|
|
||||||
import cn.hellohao.config.GlobalConstant;
|
import cn.hellohao.config.GlobalConstant;
|
||||||
|
import cn.hutool.core.io.FileUtil;import org.slf4j.Logger;
|
||||||
|
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;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@@ -16,7 +20,7 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
public class FirstRun implements InitializingBean {
|
public class FirstRun implements InitializingBean {
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(FirstRun.class);
|
||||||
@Value("${spring.datasource.username}")
|
@Value("${spring.datasource.username}")
|
||||||
private String jdbcusername;
|
private String jdbcusername;
|
||||||
|
|
||||||
@@ -26,26 +30,33 @@ public class FirstRun implements InitializingBean {
|
|||||||
@Value("${spring.datasource.url}")
|
@Value("${spring.datasource.url}")
|
||||||
private String jdbcurl;
|
private String jdbcurl;
|
||||||
|
|
||||||
|
@Value("${DockerWebHost}")
|
||||||
|
private String DockerWebHost;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() {
|
public void afterPropertiesSet() {
|
||||||
|
if(!DockerWebHost.contains("null")){
|
||||||
|
contentToTxt("/hellohaotbed/webapps/hellohao/config.json", "{\"serverHost\": \""+DockerWebHost+"\"}");
|
||||||
|
}
|
||||||
isWindows();
|
isWindows();
|
||||||
RunSqlScript.USERNAME = jdbcusername;
|
RunSqlScript.USERNAME = jdbcusername;
|
||||||
RunSqlScript.PASSWORD = jdbcpass;
|
RunSqlScript.PASSWORD = jdbcpass;
|
||||||
RunSqlScript.DBURL = jdbcurl;
|
RunSqlScript.DBURL = jdbcurl;
|
||||||
|
logger.info("正在校验数据库参数...");
|
||||||
Integer dataBaseName = RunSqlScript.RunSelectCount("SELECT count(*) FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = 'tbed'");
|
|
||||||
if(dataBaseName<1){
|
|
||||||
Print.Normal("无法找到指定数据库,请先创建'tbed'数据库,并导入表结构后再试。");
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
Print.Normal("正在校验数据库参数...");
|
|
||||||
RunSqlScript.RunInsert(dynamic);
|
RunSqlScript.RunInsert(dynamic);
|
||||||
RunSqlScript.RunInsert(compressed);
|
RunSqlScript.RunInsert(compressed);
|
||||||
|
|
||||||
String uid = UUID.randomUUID().toString().replace("-", "").toLowerCase();
|
String uid = UUID.randomUUID().toString().replace("-", "").toLowerCase();
|
||||||
RunSqlScript.RunInsert("update user set uid='"+uid+"' where id = 1");
|
RunSqlScript.RunInsert("update user set uid='"+uid+"' where id = 1");
|
||||||
|
|
||||||
|
Integer ret0 =
|
||||||
|
RunSqlScript.RunSelectCount(judgeTable + "'keys' and column_name = 'Region'");
|
||||||
|
if (ret0 == 0) {
|
||||||
|
RunSqlScript.RunInsert(sql0);
|
||||||
|
Print.Normal("Add keys.Region||RootPath");
|
||||||
|
}
|
||||||
|
|
||||||
Integer ret1 = RunSqlScript.RunSelectCount(sql1);
|
Integer ret1 = RunSqlScript.RunSelectCount(sql1);
|
||||||
if(ret1==0){
|
if(ret1==0){
|
||||||
Print.Normal("In execution...");
|
Print.Normal("In execution...");
|
||||||
@@ -82,11 +93,7 @@ public class FirstRun implements InitializingBean {
|
|||||||
RunSqlScript.RunInsert(sql8);
|
RunSqlScript.RunInsert(sql8);
|
||||||
Print.Normal("Stage 6");
|
Print.Normal("Stage 6");
|
||||||
}
|
}
|
||||||
Integer ret5 = RunSqlScript.RunSelectCount(judgeTable+"'config' and column_name = 'theme'");
|
|
||||||
if(ret5==0){
|
|
||||||
RunSqlScript.RunInsert(sql9);
|
|
||||||
Print.Normal("Stage 7");
|
|
||||||
}
|
|
||||||
Integer ret6 = RunSqlScript.RunSelectCount(judgeTable+" 'user' and column_name = 'token'");
|
Integer ret6 = RunSqlScript.RunSelectCount(judgeTable+" 'user' and column_name = 'token'");
|
||||||
if(ret6==0){
|
if(ret6==0){
|
||||||
RunSqlScript.RunInsert(sql12);
|
RunSqlScript.RunInsert(sql12);
|
||||||
@@ -98,38 +105,72 @@ public class FirstRun implements InitializingBean {
|
|||||||
RunSqlScript.RunInsert(instartAppclient);
|
RunSqlScript.RunInsert(instartAppclient);
|
||||||
Print.Normal("Add table.appclient");
|
Print.Normal("Add table.appclient");
|
||||||
}
|
}
|
||||||
Integer ret7 = RunSqlScript.RunSelectCount(judgeTable+" 'imgdata' and column_name = 'idname'");
|
Integer isconfdata = RunSqlScript.RunSelectCount(isTableName+"'confdata'");
|
||||||
if(ret7==0){
|
if(isconfdata==0){
|
||||||
RunSqlScript.RunInsert(sql11);
|
RunSqlScript.RunInsert(createConfdata);
|
||||||
Print.Normal("Add imgdata.idname");
|
RunSqlScript.RunInsert(instartConfdata);
|
||||||
|
Print.Normal("Add table.confdata");
|
||||||
}
|
}
|
||||||
|
Integer ret7 =
|
||||||
RunSqlScript.RunInsert("alter table `config` modify column `explain` text,modify column `links` text,modify column `notice` text,modify column `baidu` text");
|
RunSqlScript.RunSelectCount(judgeTable + " 'keys' and column_name = 'SysTransmit'");
|
||||||
|
if (ret7 == 0) {
|
||||||
RunSqlScript.RunInsert(inddx_md5key);
|
RunSqlScript.RunInsert(sql7);
|
||||||
RunSqlScript.RunInsert("UPDATE `keys` SET `Endpoint` = '0' WHERE `id` = 8");
|
Print.Normal("Add keys.SysTransmit");
|
||||||
|
}
|
||||||
|
Integer ret8 =
|
||||||
|
RunSqlScript.RunSelectCount(judgeTable + " 'imgdata' and column_name = 'brieflink'");
|
||||||
|
if (ret8 == 0) {
|
||||||
|
RunSqlScript.RunInsert(sql8);
|
||||||
|
Print.Normal("Add imgdata.brieflink");
|
||||||
|
}
|
||||||
|
Integer ret9 =
|
||||||
|
RunSqlScript.RunSelectCount(judgeTable + " 'imgdata' and column_name = 'shortlink'");
|
||||||
|
if (ret9 == 0) {
|
||||||
|
RunSqlScript.RunInsert(sql9);
|
||||||
|
Print.Normal("Add imgdata.shortlink");
|
||||||
|
}
|
||||||
|
Integer ret10 =
|
||||||
|
RunSqlScript.RunSelectCount(" select count(*) from tbed.keys where storageType='9'");
|
||||||
|
if (ret10 == 0) {
|
||||||
|
RunSqlScript.RunInsert(sql10);
|
||||||
|
Print.Normal("Add Webdav Config");
|
||||||
|
}
|
||||||
|
RunSqlScript.RunInsert(index_imgdata);
|
||||||
|
RunSqlScript.RunInsert("ALTER TABLE tbed.`user` MODIFY id int auto_increment;");
|
||||||
Print.Normal("Stage success");
|
Print.Normal("Stage success");
|
||||||
|
|
||||||
clears();
|
clears();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//检查表是否存在,后边加'imgdata' and column_name = 'explains' 检查字段是否存在
|
||||||
private String isTableName = "SELECT count(table_name) FROM information_schema.TABLES WHERE TABLE_SCHEMA='tbed' and table_name =";
|
private String isTableName = "SELECT count(table_name) FROM information_schema.TABLES WHERE TABLE_SCHEMA='tbed' and table_name =";
|
||||||
private String judgeTable = "select count(*) from information_schema.columns where TABLE_SCHEMA='tbed' and table_name = ";
|
private String judgeTable = "select count(*) from information_schema.columns where TABLE_SCHEMA='tbed' and table_name = ";
|
||||||
//创建blacklist 2019-11-29
|
private String sql0 =
|
||||||
|
"alter table `keys` add (Region varchar(255) DEFAULT null,RootPath varchar(255) DEFAULT '/');";
|
||||||
private String sql1 = "select count(*) from information_schema.columns where table_name = 'uploadconfig' and column_name = 'blacklist'";
|
private String sql1 = "select count(*) from information_schema.columns where table_name = 'uploadconfig' and column_name = 'blacklist'";
|
||||||
private String sql2 = "alter table uploadconfig add blacklist varchar(500);";
|
private String sql2 = "alter table uploadconfig add blacklist varchar(500);";
|
||||||
//创建imgandalbum和album 添加imgdata表字段explain 2019-12-20
|
//创建imgandalbum和album 添加imgdata表字段explain 2019-12-20
|
||||||
private String sql3 ="CREATE TABLE `imgandalbum` (`imgname` varchar(5000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,`albumkey` varchar(5000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic";
|
private String sql3 ="CREATE TABLE `imgandalbum` (`imgname` varchar(5000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,`albumkey` varchar(5000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic";
|
||||||
private String sql4 ="CREATE TABLE `album` (`albumkey` varchar(5000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,`albumtitle` varchar(5000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,`createdate` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `password` varchar(5000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic";
|
private String sql4 ="CREATE TABLE `album` (`albumkey` varchar(5000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,`albumtitle` varchar(5000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,`createdate` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, `password` varchar(5000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic";
|
||||||
private String sql6 = "alter table imgdata add explains varchar(5000)";
|
private String sql6 = "alter table imgdata add explains varchar(5000)";
|
||||||
private String sql7 = "alter table album add userid int(10)";
|
private String sql7 =
|
||||||
private String sql8 = "alter table imgdata add md5key varchar(5000)";
|
"alter table `keys` add SysTransmit varchar(50) DEFAULT NULL ;";
|
||||||
private String sql9 = "ALTER TABLE config ADD theme int(4) DEFAULT '1' COMMENT '主题' ";
|
private String sql8 = "alter table `imgdata` add brieflink varchar(100) DEFAULT null ;";
|
||||||
private String sql11 = "alter table `imgdata` add idname varchar(255) DEFAULT '未命名图像' ;";
|
private String sql9 = "alter table `imgdata` add shortlink varchar(100) DEFAULT null ;";
|
||||||
|
// 图片标识名字段
|
||||||
|
private String sql10 = "INSERT INTO `tbed`.`keys`(`id`, `AccessKey`, `AccessSecret`, `Endpoint`, `Bucketname`, `RequestAddress`, `storageType`, `keyname`, `Region`, `RootPath`, `SysTransmit`) VALUES (null, '账号', '密码', '连接', '', '存储源请求域名', 9, 'WebDAV', NULL, '/', NULL);";
|
||||||
|
|
||||||
private String sql12 = "alter table tbed.user add `token` varchar(255)";
|
private String sql12 = "alter table tbed.user add `token` varchar(255)";
|
||||||
|
//创建客户端程序相关表
|
||||||
private String createAppclient = "CREATE TABLE `appclient` (`id` varchar(10) NOT NULL,`isuse` varchar(10) NOT NULL,`winpackurl` varchar(255) NULL DEFAULT NULL,`macpackurl` varchar(255) NULL DEFAULT NULL,`appname` varchar(20) NULL,`applogo` varchar(255) NULL,`appupdate` varchar(10) NOT NULL) ";
|
private String createAppclient = "CREATE TABLE `appclient` (`id` varchar(10) NOT NULL,`isuse` varchar(10) NOT NULL,`winpackurl` varchar(255) NULL DEFAULT NULL,`macpackurl` varchar(255) NULL DEFAULT NULL,`appname` varchar(20) NULL,`applogo` varchar(255) NULL,`appupdate` varchar(10) NOT NULL) ";
|
||||||
private String instartAppclient = "INSERT INTO `appclient` VALUES ('app', 'on', NULL, NULL, 'Hellohao图像托管', 'https://hellohao.nos-eastchina1.126.net/TbedClient/app.png', '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');";
|
||||||
private String inddx_md5key = "ALTER TABLE imgdata ADD INDEX index_md5key_url ( md5key,imgurl)";
|
//创建confdata表
|
||||||
|
private String createConfdata = "CREATE TABLE tbed.confdata ( `key` varchar(100) NULL, jsondata LONGTEXT NULL )";
|
||||||
|
private String instartConfdata =
|
||||||
|
"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 index_imgdata = "ALTER TABLE imgdata ADD INDEX index_md5key_url ( id,md5key,imgname,imgurl,idname,imguid)";
|
||||||
|
|
||||||
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";
|
||||||
|
|
||||||
@@ -140,14 +181,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -163,4 +205,31 @@ public class FirstRun implements InitializingBean {
|
|||||||
return System.getProperties().getProperty("os.name").toUpperCase().indexOf("WINDOWS") != -1;
|
return System.getProperties().getProperty("os.name").toUpperCase().indexOf("WINDOWS") != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void contentToTxt(String filePath, String content) {
|
||||||
|
// String str = new String(); //原有txt内容
|
||||||
|
String s1 = new String();//内容更新
|
||||||
|
try {
|
||||||
|
File f = new File(filePath);
|
||||||
|
if (f.exists()) {
|
||||||
|
logger.info("文件存在");
|
||||||
|
} else {
|
||||||
|
logger.info("文件不存在,准备创建");
|
||||||
|
// f.createNewFile();// 不存在则创建
|
||||||
|
FileUtil.createTempFile(f);
|
||||||
|
}
|
||||||
|
// BufferedReader input = new BufferedReader(new FileReader(f));
|
||||||
|
// while ((str = input.readLine()) != null) {
|
||||||
|
// s1 += str + "\n";
|
||||||
|
// }
|
||||||
|
// input.close();
|
||||||
|
s1 += content + "\n";
|
||||||
|
BufferedWriter output = new BufferedWriter(new FileWriter(f));
|
||||||
|
output.write(s1);
|
||||||
|
output.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,8 +39,6 @@ public class GetCurrentSource {
|
|||||||
userService = userServiceImpl;
|
userService = userServiceImpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static Group GetSource(Integer userid) {
|
public static Group GetSource(Integer userid) {
|
||||||
//UserType 0-未分配 1-游客 2-用户 3-管理员
|
//UserType 0-未分配 1-游客 2-用户 3-管理员
|
||||||
User user =null;
|
User user =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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -3,7 +3,8 @@ package cn.hellohao.utils;
|
|||||||
import cn.hellohao.exception.StorageSourceInitException;
|
import cn.hellohao.exception.StorageSourceInitException;
|
||||||
import cn.hellohao.pojo.ReturnImage;
|
import cn.hellohao.pojo.ReturnImage;
|
||||||
import cn.hellohao.service.impl.*;
|
import cn.hellohao.service.impl.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -13,15 +14,26 @@ import java.util.Map;
|
|||||||
* @version 1.0
|
* @version 1.0
|
||||||
* @date 2019/11/7 17:12
|
* @date 2019/11/7 17:12
|
||||||
*/
|
*/
|
||||||
|
@Service
|
||||||
public class GetSource {
|
public class GetSource {
|
||||||
public static ReturnImage storageSource(Integer type, Map<String, File> fileMap, String userpath,Integer keyID){
|
|
||||||
NOSImageupload nosImageupload = SpringContextHolder.getBean(NOSImageupload.class);
|
@Autowired
|
||||||
OSSImageupload ossImageupload = SpringContextHolder.getBean(OSSImageupload.class);
|
NOSImageupload nosImageupload;
|
||||||
USSImageupload ussImageupload = SpringContextHolder.getBean(USSImageupload.class);
|
@Autowired
|
||||||
KODOImageupload kodoImageupload = SpringContextHolder.getBean(KODOImageupload.class);
|
OSSImageupload ossImageupload;
|
||||||
COSImageupload cosImageupload = SpringContextHolder.getBean(COSImageupload.class);
|
@Autowired
|
||||||
FTPImageupload ftpImageupload = SpringContextHolder.getBean(FTPImageupload.class);
|
USSImageupload ussImageupload;
|
||||||
UFileImageupload uFileImageupload = SpringContextHolder.getBean(UFileImageupload.class);
|
@Autowired
|
||||||
|
KODOImageupload kodoImageupload;
|
||||||
|
@Autowired
|
||||||
|
COSImageupload cosImageupload;
|
||||||
|
@Autowired
|
||||||
|
FtpServiceImpl ftpService;
|
||||||
|
@Autowired
|
||||||
|
S3Imageupload s3Imageupload;
|
||||||
|
@Autowired
|
||||||
|
WebDAVImageupload webDAVImageupload;
|
||||||
|
public ReturnImage storageSource(Integer type, Map<Map<String, String>, File> fileMap, String userpath,Integer keyID){
|
||||||
ReturnImage returnImage = null;
|
ReturnImage returnImage = null;
|
||||||
try {
|
try {
|
||||||
if(type==1){
|
if(type==1){
|
||||||
@@ -37,9 +49,11 @@ public class GetSource {
|
|||||||
}else if(type==6){
|
}else if(type==6){
|
||||||
returnImage = cosImageupload.ImageuploadCOS(fileMap, userpath,keyID);;
|
returnImage = cosImageupload.ImageuploadCOS(fileMap, userpath,keyID);;
|
||||||
}else if(type==7){
|
}else if(type==7){
|
||||||
returnImage = ftpImageupload.ImageuploadFTP(fileMap, userpath,keyID);
|
returnImage = ftpService.FtpUploadFile(fileMap, userpath,keyID);
|
||||||
}else if(type==8){
|
}else if(type==8){
|
||||||
returnImage = uFileImageupload.ImageuploadUFile(fileMap, userpath,keyID);
|
returnImage = s3Imageupload.ImageuploadS3(fileMap, userpath,keyID);
|
||||||
|
}else if(type==9){
|
||||||
|
returnImage = webDAVImageupload.ImageuploadWebDAV(fileMap, userpath,keyID);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
new StorageSourceInitException("GetSource类捕捉异常:未找到存储源");
|
new StorageSourceInitException("GetSource类捕捉异常:未找到存储源");
|
||||||
|
|||||||
@@ -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;
|
||||||
@@ -64,7 +65,7 @@ public class ImgUrlUtil {
|
|||||||
httpUrlConnection.setConnectTimeout(300000);
|
httpUrlConnection.setConnectTimeout(300000);
|
||||||
httpUrlConnection.setReadTimeout(300000);
|
httpUrlConnection.setReadTimeout(300000);
|
||||||
httpUrlConnection.connect();
|
httpUrlConnection.connect();
|
||||||
String code = new Integer(httpUrlConnection.getResponseCode()).toString();
|
String code = Integer.toString(httpUrlConnection.getResponseCode());
|
||||||
String message = httpUrlConnection.getResponseMessage();
|
String message = httpUrlConnection.getResponseMessage();
|
||||||
System.out.println("getResponseCode code ="+ code);
|
System.out.println("getResponseCode code ="+ code);
|
||||||
System.out.println("getResponseMessage message ="+ message);
|
System.out.println("getResponseMessage message ="+ message);
|
||||||
@@ -74,7 +75,7 @@ public class ImgUrlUtil {
|
|||||||
throw new Exception("ResponseCode is not begin with 2,code="+code);
|
throw new Exception("ResponseCode is not begin with 2,code="+code);
|
||||||
}
|
}
|
||||||
map.put("Check","true");
|
map.put("Check","true");
|
||||||
System.out.println("连接正常");
|
// System.out.println("连接正常");
|
||||||
}catch(Exception ex){
|
}catch(Exception ex){
|
||||||
System.out.println(ex.getMessage());
|
System.out.println(ex.getMessage());
|
||||||
}
|
}
|
||||||
@@ -83,15 +84,8 @@ public class ImgUrlUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
public static Map<String ,Object> downLoadFromUrl(String urlStr,String referer,String fileName,String savePath){
|
||||||
* 从网络Url中下载文件
|
FileInputStream fileInputStream = null;
|
||||||
* @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);
|
||||||
if(map.size()==0 || map.get("Check").equals("false")){
|
if(map.size()==0 || map.get("Check").equals("false")){
|
||||||
@@ -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,9 +119,9 @@ 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);
|
fileInputStream = new FileInputStream(file);
|
||||||
|
Msg msg = TypeDict.FileMiME(fileInputStream);
|
||||||
if(msg.getCode().equals("200")){
|
if(msg.getCode().equals("200")){
|
||||||
File f = new File(saveDir+File.separator+fileName);
|
File f = new File(saveDir+File.separator+fileName);
|
||||||
String imgPath = saveDir+File.separator+fileName+"."+(msg.getData().toString().replace("image/",""));
|
String imgPath = saveDir+File.separator+fileName+"."+(msg.getData().toString().replace("image/",""));
|
||||||
@@ -144,18 +138,22 @@ public class ImgUrlUtil {
|
|||||||
resmap.put("res",false);
|
resmap.put("res",false);
|
||||||
resmap.put("StatusCode","500");
|
resmap.put("StatusCode","500");
|
||||||
}
|
}
|
||||||
|
if(fileInputStream!=null){
|
||||||
|
fileInputStream.close();
|
||||||
|
}
|
||||||
return resmap;
|
return resmap;
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
try{
|
||||||
|
if(fileInputStream!=null){
|
||||||
|
fileInputStream.close();
|
||||||
|
}
|
||||||
|
}catch (Exception e2){ }
|
||||||
resmap.put("res",false);
|
resmap.put("res",false);
|
||||||
resmap.put("StatusCode","500");
|
resmap.put("StatusCode","500");
|
||||||
return resmap;
|
return resmap;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从输入流中获取字节数组
|
* 从输入流中获取字节数组
|
||||||
* @param inputStream
|
* @param inputStream
|
||||||
|
|||||||
@@ -4,15 +4,10 @@ import cn.hellohao.config.GlobalConstant;
|
|||||||
import cn.hellohao.pojo.Images;
|
import cn.hellohao.pojo.Images;
|
||||||
import cn.hellohao.pojo.Keys;
|
import cn.hellohao.pojo.Keys;
|
||||||
import cn.hellohao.pojo.ReturnImage;
|
import cn.hellohao.pojo.ReturnImage;
|
||||||
import cn.hellohao.pojo.UploadConfig;
|
|
||||||
import cn.hellohao.service.impl.KeysServiceImpl;
|
import cn.hellohao.service.impl.KeysServiceImpl;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class LocUpdateImg {
|
public class LocUpdateImg {
|
||||||
public static boolean deleteLOCImg(Images images){
|
public static boolean deleteLOCImg(Images images){
|
||||||
@@ -20,7 +15,11 @@ public class LocUpdateImg {
|
|||||||
try {
|
try {
|
||||||
String filePath = GlobalConstant.LOCPATH + File.separator+images.getImgname();
|
String filePath = GlobalConstant.LOCPATH + File.separator+images.getImgname();
|
||||||
File file = new File(filePath);
|
File file = new File(filePath);
|
||||||
isDele = file.delete();
|
if(file.exists()){
|
||||||
|
isDele = file.delete();
|
||||||
|
}else{
|
||||||
|
isDele = true;
|
||||||
|
}
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
isDele = false;
|
isDele = false;
|
||||||
@@ -28,43 +27,35 @@ public class LocUpdateImg {
|
|||||||
return isDele;
|
return isDele;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ReturnImage ImageuploadLOC(Map<String, File> fileMap, String username,Integer keyID) throws Exception {
|
public static ReturnImage ImageuploadLOC(
|
||||||
KeysServiceImpl keysService = SpringContextHolder.getBean(KeysServiceImpl.class);
|
Map<Map<String, String>, File> fileMap, String username, Integer keyID) {
|
||||||
final Keys key = keysService.selectKeys(keyID);
|
|
||||||
ReturnImage returnImage = new ReturnImage();
|
ReturnImage returnImage = new ReturnImage();
|
||||||
String filePath =GlobalConstant.LOCPATH + File.separator;
|
String filePath = GlobalConstant.LOCPATH + File.separator;
|
||||||
File file = null;
|
try {
|
||||||
for (Map.Entry<String, File> entry : fileMap.entrySet()) {
|
for (Map.Entry<Map<String, String>, File> entry : fileMap.entrySet()) {
|
||||||
String ShortUID = SetText.getShortUuid();
|
String prefix = entry.getKey().get("prefix");
|
||||||
System.out.println("待上传的图片:"+username + File.separator + ShortUID + "." + entry.getKey());
|
String ShortUIDName = entry.getKey().get("name");
|
||||||
File dest = new File(filePath + username + File.separator+ ShortUID + "." + entry.getKey());
|
File dest = new File(filePath + username + File.separator + ShortUIDName + "." + prefix);
|
||||||
File temppath = new File(filePath + username+ File.separator );
|
|
||||||
if (!dest.getParentFile().exists()) {
|
if (!dest.getParentFile().exists()) {
|
||||||
dest.getParentFile().mkdirs();
|
dest.getParentFile().mkdirs();
|
||||||
}
|
}
|
||||||
try {
|
InputStream fileInputStream = new FileInputStream(entry.getValue());
|
||||||
InputStream fileInputStream = new FileInputStream(entry.getValue());
|
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(dest));
|
||||||
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(dest));
|
byte[] bs = new byte[1024];
|
||||||
byte[] bs = new byte[1024];
|
int len;
|
||||||
int len;
|
while ((len = fileInputStream.read(bs)) != -1) {
|
||||||
while ((len = fileInputStream.read(bs)) != -1) {
|
bos.write(bs, 0, len);
|
||||||
bos.write(bs, 0, len);
|
|
||||||
}
|
|
||||||
bos.flush();
|
|
||||||
bos.close();
|
|
||||||
returnImage.setImgname(username + "/" +ShortUID + "." + entry.getKey());//entry.getValue().getOriginalFilename()
|
|
||||||
returnImage.setImgurl(key.getRequestAddress() +"/ota/"+username + "/" + ShortUID + "." + entry.getKey());
|
|
||||||
returnImage.setImgSize(entry.getValue().length());
|
|
||||||
returnImage.setCode("200");
|
|
||||||
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
returnImage.setCode("500");
|
|
||||||
System.err.println("上传失败");
|
|
||||||
}
|
}
|
||||||
|
bos.flush();
|
||||||
|
bos.close();
|
||||||
|
}
|
||||||
|
returnImage.setCode("200");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
returnImage.setCode("500");
|
||||||
|
System.err.println("上传失败");
|
||||||
}
|
}
|
||||||
return returnImage;
|
return returnImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,15 @@
|
|||||||
package cn.hellohao.utils;
|
package cn.hellohao.utils;
|
||||||
|
|
||||||
import cn.hellohao.pojo.Config;
|
|
||||||
import cn.hellohao.pojo.EmailConfig;
|
import cn.hellohao.pojo.EmailConfig;
|
||||||
import cn.hellohao.pojo.Msg;
|
import cn.hellohao.pojo.Msg;
|
||||||
import cn.hutool.core.util.CharsetUtil;
|
import cn.hutool.core.util.CharsetUtil;
|
||||||
import cn.hutool.core.util.HexUtil;
|
import cn.hutool.core.util.HexUtil;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.mitchellbosecke.pebble.PebbleEngine;
|
import com.mitchellbosecke.pebble.PebbleEngine;
|
||||||
import com.mitchellbosecke.pebble.template.PebbleTemplate;
|
import com.mitchellbosecke.pebble.template.PebbleTemplate;
|
||||||
import io.github.biezhi.ome.OhMyEmail;
|
import io.github.biezhi.ome.OhMyEmail;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
|
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -18,7 +19,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class NewSendEmail {
|
public class NewSendEmail {
|
||||||
|
|
||||||
public static Integer sendEmail(EmailConfig emailConfig, String username, String uid, String toEmail, Config config) {
|
public static Integer sendEmail(EmailConfig emailConfig, String username, String uid, String toEmail, JSONObject jsonObject) {
|
||||||
|
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
props.put("mail.smtp.auth", "true");
|
props.put("mail.smtp.auth", "true");
|
||||||
@@ -33,8 +34,8 @@ public class NewSendEmail {
|
|||||||
// OhMyEmail.config(OhMyEmail.SMTP_QQ(false), "xxxx@qq.com", "your@password");
|
// OhMyEmail.config(OhMyEmail.SMTP_QQ(false), "xxxx@qq.com", "your@password");
|
||||||
OhMyEmail.config(props, emailConfig.getEmails(), emailConfig.getEmailkey());
|
OhMyEmail.config(props, emailConfig.getEmails(), emailConfig.getEmailkey());
|
||||||
|
|
||||||
String webname=config.getWebname();
|
String webname=jsonObject.getString("webname");
|
||||||
String domain = config.getDomain();
|
String domain = jsonObject.getString("domain");
|
||||||
try {
|
try {
|
||||||
//生成模板
|
//生成模板
|
||||||
PebbleEngine engine = new PebbleEngine.Builder().build();
|
PebbleEngine engine = new PebbleEngine.Builder().build();
|
||||||
@@ -90,7 +91,7 @@ public class NewSendEmail {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Integer sendEmailFindPass(EmailConfig emailConfig,String username, String uid, String toEmail, Config config) {
|
public static Integer sendEmailFindPass(EmailConfig emailConfig,String username, String uid, String toEmail, JSONObject jsonObject) {
|
||||||
Properties props = new Properties();
|
Properties props = new Properties();
|
||||||
props.put("mail.smtp.auth", "true");
|
props.put("mail.smtp.auth", "true");
|
||||||
props.put("mail.smtp.ssl.enable", "true");
|
props.put("mail.smtp.ssl.enable", "true");
|
||||||
@@ -103,8 +104,8 @@ public class NewSendEmail {
|
|||||||
// 配置一次即可,可以配置为静态方法
|
// 配置一次即可,可以配置为静态方法
|
||||||
// OhMyEmail.config(OhMyEmail.SMTP_QQ(false), "xxxx@qq.com", "your@password");
|
// OhMyEmail.config(OhMyEmail.SMTP_QQ(false), "xxxx@qq.com", "your@password");
|
||||||
OhMyEmail.config(props, emailConfig.getEmails(), emailConfig.getEmailkey());
|
OhMyEmail.config(props, emailConfig.getEmails(), emailConfig.getEmailkey());
|
||||||
String webname=config.getWebname();
|
String webname=jsonObject.getString("webname");
|
||||||
String domain = config.getDomain();
|
String domain = jsonObject.getString("domain");
|
||||||
String new_pass = UUID.randomUUID().toString().replace("-", "").toLowerCase().substring(0,10);
|
String new_pass = UUID.randomUUID().toString().replace("-", "").toLowerCase().substring(0,10);
|
||||||
try {
|
try {
|
||||||
//生成模板
|
//生成模板
|
||||||
|
|||||||
+15
-19
@@ -1,15 +1,14 @@
|
|||||||
package cn.hellohao.utils;
|
package cn.hellohao.utils;
|
||||||
|
|
||||||
import org.apache.ibatis.io.Resources;
|
import cn.hellohao.service.impl.S3Imageupload;
|
||||||
import org.apache.ibatis.jdbc.ScriptRunner;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
|
|
||||||
final class RunSqlScript {
|
final class RunSqlScript {
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(RunSqlScript.class);
|
||||||
public static String DBDRIVER = "com.mysql.cj.jdbc.Driver";
|
public static String DBDRIVER = "com.mysql.cj.jdbc.Driver";
|
||||||
public static String DBURL ;
|
public static String DBURL ;
|
||||||
//现在使用的是mysql数据库,是直接连接的,所以此处必须有用户名和密码
|
//现在使用的是mysql数据库,是直接连接的,所以此处必须有用户名和密码
|
||||||
@@ -26,7 +25,7 @@ final class RunSqlScript {
|
|||||||
try {
|
try {
|
||||||
Class.forName(DBDRIVER);
|
Class.forName(DBDRIVER);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
logger.error("RunSqlScript[29]", e);
|
||||||
}
|
}
|
||||||
//2、连接数据库
|
//2、连接数据库
|
||||||
//通过连接管理器连接数据库
|
//通过连接管理器连接数据库
|
||||||
@@ -34,14 +33,14 @@ final class RunSqlScript {
|
|||||||
//在连接的时候直接输入用户名和密码才可以连接
|
//在连接的时候直接输入用户名和密码才可以连接
|
||||||
conn = DriverManager.getConnection(DBURL,USERNAME,PASSWORD);
|
conn = DriverManager.getConnection(DBURL,USERNAME,PASSWORD);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
logger.error("RunSqlScript[36]", e);
|
||||||
}
|
}
|
||||||
//3、向数据库中插入一条数据
|
//3、向数据库中插入一条数据
|
||||||
//String sql = "select count(*) from information_schema.columns where table_name = 'config' and column_name = 'id'";
|
//String sql = "select count(*) from information_schema.columns where table_name = 'config' and column_name = 'id'";
|
||||||
try {
|
try {
|
||||||
stmt = conn.createStatement();
|
stmt = conn.createStatement();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
logger.error("RunSqlScript[43]", e);
|
||||||
}
|
}
|
||||||
//4、执行语句
|
//4、执行语句
|
||||||
try {
|
try {
|
||||||
@@ -51,7 +50,7 @@ final class RunSqlScript {
|
|||||||
count = resultSet.getInt(1);
|
count = resultSet.getInt(1);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
logger.error("RunSqlScript[53]", e);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
//5、关闭操作
|
//5、关闭操作
|
||||||
@@ -59,7 +58,7 @@ final class RunSqlScript {
|
|||||||
stmt.close();
|
stmt.close();
|
||||||
conn.close();
|
conn.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
logger.error("RunSqlScript[61]", e);
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
@@ -76,8 +75,7 @@ final class RunSqlScript {
|
|||||||
try {
|
try {
|
||||||
Class.forName(DBDRIVER);
|
Class.forName(DBDRIVER);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
logger.error("RunSqlScript[78]", e);
|
||||||
Print.Normal("SqlHelper.java - ClassNotFoundException");
|
|
||||||
}
|
}
|
||||||
//2、连接数据库
|
//2、连接数据库
|
||||||
//通过连接管理器连接数据库
|
//通过连接管理器连接数据库
|
||||||
@@ -85,23 +83,21 @@ final class RunSqlScript {
|
|||||||
//在连接的时候直接输入用户名和密码才可以连接
|
//在连接的时候直接输入用户名和密码才可以连接
|
||||||
conn = DriverManager.getConnection(DBURL,USERNAME,PASSWORD);
|
conn = DriverManager.getConnection(DBURL,USERNAME,PASSWORD);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
logger.error("RunSqlScript[86]", e);
|
||||||
Print.Normal("SqlHelper.java - SQLException1");
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
stmt = conn.createStatement();
|
stmt = conn.createStatement();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
logger.error("RunSqlScript[91]", e);
|
||||||
Print.Normal("SqlHelper.java - SQLException2");
|
|
||||||
}
|
}
|
||||||
//4、执行语句
|
//4、执行语句
|
||||||
try {
|
try {
|
||||||
count = stmt.executeUpdate(sql);
|
count = stmt.executeUpdate(sql);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
if(e.getMessage().contains("Duplicate key name") && e.getMessage().contains("index_md5key_url")){
|
if(e.getMessage().contains("Duplicate key name") && e.getMessage().contains("index_md5key_url")){
|
||||||
Print.Normal("Database index already exists, skip this step.");
|
logger.info("Database index already exists, skip this step.");
|
||||||
}else{
|
}else{
|
||||||
e.printStackTrace();
|
logger.error("RunSqlScript[100]", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//5、关闭操作
|
//5、关闭操作
|
||||||
@@ -109,7 +105,7 @@ final class RunSqlScript {
|
|||||||
stmt.close();
|
stmt.close();
|
||||||
conn.close();
|
conn.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
Print.Normal("SqlHelper.java - SQLException4");
|
logger.error("RunSqlScript[108]", e);
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,22 @@
|
|||||||
package cn.hellohao.utils;
|
package cn.hellohao.utils;
|
||||||
|
|
||||||
|
import cn.hellohao.pojo.Chunk;
|
||||||
|
import cn.hellohao.pojo.Msg;
|
||||||
|
import org.apache.commons.io.FileUtils;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
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 {
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(SetFiles.class);
|
||||||
// 转换文件方法
|
// 转换文件方法
|
||||||
public static File changeFile(MultipartFile multipartFile) {
|
public static File changeFile(MultipartFile multipartFile) {
|
||||||
// 获取文件名
|
// 获取文件名
|
||||||
@@ -40,17 +51,16 @@ public class SetFiles {
|
|||||||
|
|
||||||
// 转换文件方法
|
// 转换文件方法
|
||||||
public static File changeFile_new(MultipartFile multipartFile) {
|
public static File changeFile_new(MultipartFile multipartFile) {
|
||||||
// 获取文件名
|
|
||||||
String fileName = multipartFile.getOriginalFilename();//getOriginalFilename
|
String fileName = multipartFile.getOriginalFilename();//getOriginalFilename
|
||||||
// 获取文件后缀
|
|
||||||
String prefix = fileName.substring(fileName.lastIndexOf("."));
|
String prefix = fileName.substring(fileName.lastIndexOf("."));
|
||||||
// todo 修改临时文件文件名
|
// todo 修改临时文件文件名
|
||||||
File file = null;
|
File file = null;
|
||||||
try {
|
try {
|
||||||
file = File.createTempFile(fileName, prefix);
|
String new_FileName = System.getProperty("java.io.tmpdir")+"hellohao_tmp_upload"+File.separator+fileName;
|
||||||
multipartFile.transferTo(file);
|
file = new File(new_FileName);
|
||||||
|
FileUtils.copyInputStreamToFile(multipartFile.getInputStream(), file);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
logger.error("SetFiles.changeFile_new", e);
|
||||||
}
|
}
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
@@ -78,7 +88,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,64 +1,6 @@
|
|||||||
package cn.hellohao.utils;
|
package cn.hellohao.utils;
|
||||||
|
|
||||||
import cn.hellohao.pojo.Keys;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class StringUtils {
|
public class StringUtils {
|
||||||
//此方法目前未使用2020-04-06
|
|
||||||
public static Boolean doNull(Integer sourcekey,Keys k) {
|
|
||||||
if(sourcekey==1){
|
|
||||||
if(k.getEndpoint()!=null && k.getAccessSecret()!=null && k.getEndpoint()!=null
|
|
||||||
&& k.getBucketname()!=null && k.getRequestAddress()!=null ){
|
|
||||||
if(!k.getEndpoint().equals("") && !k.getAccessSecret().equals("") && !k.getEndpoint().equals("")
|
|
||||||
&& !k.getBucketname().equals("") && !k.getRequestAddress().equals("") ){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else if(sourcekey==2){
|
|
||||||
if(k.getEndpoint()!=null && k.getAccessSecret()!=null && k.getEndpoint()!=null
|
|
||||||
&& k.getBucketname()!=null && k.getRequestAddress()!=null ) {
|
|
||||||
if(!k.getEndpoint().equals("") && !k.getAccessSecret().equals("") && !k.getEndpoint().equals("")
|
|
||||||
&& !k.getBucketname().equals("") && !k.getRequestAddress().equals("") ) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else if(sourcekey==3){
|
|
||||||
if(k.getEndpoint()!=null && k.getAccessSecret()!=null
|
|
||||||
&& k.getBucketname()!=null && k.getRequestAddress()!=null ) {
|
|
||||||
if(!k.getEndpoint().equals("") && !k.getAccessSecret().equals("")
|
|
||||||
&& !k.getBucketname().equals("") && !k.getRequestAddress().equals("") ) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else if(sourcekey==4){
|
|
||||||
if (k.getEndpoint() != null && k.getAccessSecret() != null && k.getEndpoint() != null
|
|
||||||
&& k.getBucketname() != null && k.getRequestAddress() != null) {
|
|
||||||
if (!k.getEndpoint().equals("") && !k.getAccessSecret() .equals("") && !k.getEndpoint() .equals("")
|
|
||||||
&& !k.getBucketname() .equals("") && !k.getRequestAddress().equals("")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else if(sourcekey==6){
|
|
||||||
if(k.getEndpoint()!=null && k.getAccessSecret()!=null && k.getEndpoint()!=null
|
|
||||||
&& k.getBucketname()!=null && k.getRequestAddress()!=null ) {
|
|
||||||
if(!k.getEndpoint().equals("") && !k.getAccessSecret().equals("") && !k.getEndpoint().equals("")
|
|
||||||
&& !k.getBucketname().equals("") && !k.getRequestAddress().equals("") ) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else if(sourcekey==7){
|
|
||||||
if(k.getEndpoint()!=null && k.getAccessSecret()!=null && k.getEndpoint()!=null && k.getRequestAddress()!=null ) {
|
|
||||||
if(!k.getEndpoint().equals("") && !k.getAccessSecret().equals("") && !k.getEndpoint().equals("") && !k.getRequestAddress().equals("") ) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 移除 URL 中的第一个 '/'
|
* 移除 URL 中的第一个 '/'
|
||||||
* @return 如 path = '/folder1/file1', 返回 'folder1/file1'
|
* @return 如 path = '/folder1/file1', 返回 'folder1/file1'
|
||||||
|
|||||||
@@ -7,15 +7,16 @@ import javax.imageio.ImageIO;
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
|
||||||
public class TypeDict {
|
public class TypeDict {
|
||||||
|
|
||||||
//apache大法
|
//apache大法
|
||||||
public static Msg FileMiME(File file ){
|
public static Msg FileMiME(InputStream stream){
|
||||||
final Msg msg = new Msg();
|
final Msg msg = new Msg();
|
||||||
try {
|
try {
|
||||||
Tika tika = new Tika();
|
Tika tika = new Tika();
|
||||||
String fileType = tika.detect(file);
|
String fileType = tika.detect(stream);
|
||||||
if (fileType != null && fileType.contains("/")) {
|
if (fileType != null && fileType.contains("/")) {
|
||||||
if(fileType.contains("image/")){
|
if(fileType.contains("image/")){
|
||||||
msg.setData(fileType);
|
msg.setData(fileType);
|
||||||
|
|||||||
@@ -4,26 +4,22 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class MyProgress {
|
public class MyProgress {
|
||||||
|
|
||||||
//删除图片时候的数据
|
|
||||||
private int delSuccessCount=0;//已经成功的个数
|
private int delSuccessCount=0;//已经成功的个数
|
||||||
private List<String> delErrorImgListt = new ArrayList<>();//已经失败的图片
|
private List<String> delErrorImgListt = new ArrayList<>();//已经失败的图片
|
||||||
private boolean delOCT=false; //控制开关
|
private int delOCT=0; //控制开关
|
||||||
private List<Integer> delSuccessImgList = new ArrayList<>(); //删除成功的图片
|
private List<Long> delSuccessImgList = new ArrayList<>(); //删除成功的图片
|
||||||
|
|
||||||
public void InitializeDelImg(){
|
public void InitializeDelImg(){
|
||||||
//删除图片时候的数据
|
|
||||||
this.delSuccessCount=0;//已经成功的个数
|
this.delSuccessCount=0;//已经成功的个数
|
||||||
this.delErrorImgListt = new ArrayList<>();//已经失败的图片
|
this.delErrorImgListt = new ArrayList<>();//已经失败的图片
|
||||||
this.delOCT=false; //控制开关
|
this.delOCT=0; //控制开关 0代表false 1代表true
|
||||||
this.delSuccessImgList = new ArrayList<>(); //删除成功的图片
|
this.delSuccessImgList = new ArrayList<>(); //删除成功的图片
|
||||||
}
|
}
|
||||||
|
|
||||||
public MyProgress() {
|
public MyProgress() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public MyProgress(int delSuccessCount, List<String> delErrorImgListt, boolean delOCT, List<Integer> delSuccessImgList) {
|
public MyProgress(int delSuccessCount, List<String> delErrorImgListt, int delOCT, List<Long> delSuccessImgList) {
|
||||||
|
|
||||||
this.delSuccessCount = delSuccessCount;
|
this.delSuccessCount = delSuccessCount;
|
||||||
this.delErrorImgListt = delErrorImgListt;
|
this.delErrorImgListt = delErrorImgListt;
|
||||||
this.delOCT = delOCT;
|
this.delOCT = delOCT;
|
||||||
@@ -46,29 +42,21 @@ public class MyProgress {
|
|||||||
this.delErrorImgListt = delErrorImgListt;
|
this.delErrorImgListt = delErrorImgListt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getDelOCT() {
|
public int getDelOCT() {
|
||||||
return delOCT;
|
return delOCT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDelOCT(boolean delOCT) {
|
public void setDelOCT(int delOCT) {
|
||||||
this.delOCT = delOCT;
|
this.delOCT = delOCT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Integer> getDelSuccessImgList() {
|
public List<Long> getDelSuccessImgList() {
|
||||||
return delSuccessImgList;
|
return delSuccessImgList;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDelSuccessImgList(List<Integer> delSuccessImgList) {
|
public void setDelSuccessImgList(List<Long> delSuccessImgList) {
|
||||||
this.delSuccessImgList = delSuccessImgList;
|
this.delSuccessImgList = delSuccessImgList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString() {
|
|
||||||
return "MyProgress{" +
|
|
||||||
", delSuccessCount=" + delSuccessCount +
|
|
||||||
", delErrorImgListt=" + delErrorImgListt +
|
|
||||||
", delOCT=" + delOCT +
|
|
||||||
", delSuccessImgList=" + delSuccessImgList +
|
|
||||||
'}';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -30,22 +30,22 @@ private static final int VALICATE_CODE_LENGTH = 4;
|
|||||||
* @param height
|
* @param height
|
||||||
*/
|
*/
|
||||||
private static void fillBackground(Graphics graphics, int width, int height) {
|
private static void fillBackground(Graphics graphics, int width, int height) {
|
||||||
// 填充背景
|
// 填充背景
|
||||||
graphics.setColor(Color.WHITE);
|
graphics.setColor(Color.WHITE);
|
||||||
//设置矩形坐标x y 为0
|
//设置矩形坐标x y 为0
|
||||||
graphics.fillRect(0, 0, width, height);
|
graphics.fillRect(0, 0, width, height);
|
||||||
|
|
||||||
// 加入干扰线条
|
// 加入干扰线条
|
||||||
for (int i = 0; i < 8; i++) {
|
for (int i = 0; i < 8; i++) {
|
||||||
//设置随机颜色算法参数
|
//设置随机颜色算法参数
|
||||||
graphics.setColor(RandomUtils.randomColor(40, 150));
|
graphics.setColor(RandomUtils.randomColor(40, 150));
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
int x = random.nextInt(width);
|
int x = random.nextInt(width);
|
||||||
int y = random.nextInt(height);
|
int y = random.nextInt(height);
|
||||||
int x1 = random.nextInt(width);
|
int x1 = random.nextInt(width);
|
||||||
int y1 = random.nextInt(height);
|
int y1 = random.nextInt(height);
|
||||||
graphics.drawLine(x, y, x1, y1);
|
graphics.drawLine(x, y, x1, y1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -59,15 +59,15 @@ graphics.drawLine(x, y, x1, y1);
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String generate(int width, int height, OutputStream os) throws IOException {
|
public String generate(int width, int height, OutputStream os) throws IOException {
|
||||||
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||||
Graphics graphics = image.getGraphics();
|
Graphics graphics = image.getGraphics();
|
||||||
fillBackground(graphics, width, height);
|
fillBackground(graphics, width, height);
|
||||||
String randomStr = RandomUtils.randomString(VALICATE_CODE_LENGTH);
|
String randomStr = RandomUtils.randomString(VALICATE_CODE_LENGTH);
|
||||||
createCharacter(graphics, randomStr);
|
createCharacter(graphics, randomStr);
|
||||||
graphics.dispose();
|
graphics.dispose();
|
||||||
//设置JPEG格式
|
//设置JPEG格式
|
||||||
ImageIO.write(image, "JPEG", os);
|
ImageIO.write(image, "JPEG", os);
|
||||||
return randomStr;
|
return randomStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,20 +79,20 @@ return randomStr;
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public VerifyCode generate(int width, int height) {
|
public VerifyCode generate(int width, int height) {
|
||||||
VerifyCode verifyCode = null;
|
VerifyCode verifyCode = null;
|
||||||
try (
|
try (
|
||||||
//将流的初始化放到这里就不需要手动关闭流
|
//将流的初始化放到这里就不需要手动关闭流
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
) {
|
) {
|
||||||
String code = generate(width, height, baos);
|
String code = generate(width, height, baos);
|
||||||
verifyCode = new VerifyCode();
|
verifyCode = new VerifyCode();
|
||||||
verifyCode.setCode(code);
|
verifyCode.setCode(code);
|
||||||
verifyCode.setImgBytes(baos.toByteArray());
|
verifyCode.setImgBytes(baos.toByteArray());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
verifyCode = null;
|
verifyCode = null;
|
||||||
}
|
}
|
||||||
return verifyCode;
|
return verifyCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -102,15 +102,15 @@ return verifyCode;
|
|||||||
* @param randomStr
|
* @param randomStr
|
||||||
*/
|
*/
|
||||||
private void createCharacter(Graphics g, String randomStr) {
|
private void createCharacter(Graphics g, String randomStr) {
|
||||||
char[] charArray = randomStr.toCharArray();
|
char[] charArray = randomStr.toCharArray();
|
||||||
for (int i = 0; i < charArray.length; i++) {
|
for (int i = 0; i < charArray.length; i++) {
|
||||||
//设置RGB颜色算法参数
|
//设置RGB颜色算法参数
|
||||||
g.setColor(new Color(50 + RandomUtils.nextInt(100),
|
g.setColor(new Color(50 + RandomUtils.nextInt(100),
|
||||||
50 + RandomUtils.nextInt(100), 50 + RandomUtils.nextInt(100)));
|
50 + RandomUtils.nextInt(100), 50 + RandomUtils.nextInt(100)));
|
||||||
//设置字体大小,类型
|
//设置字体大小,类型
|
||||||
g.setFont(new Font(FONT_TYPES[RandomUtils.nextInt(FONT_TYPES.length)], Font.BOLD, 26));
|
g.setFont(new Font(FONT_TYPES[RandomUtils.nextInt(FONT_TYPES.length)], Font.BOLD, 26));
|
||||||
//设置x y 坐标
|
//设置x y 坐标
|
||||||
g.drawString(String.valueOf(charArray[i]), 15 * i + 5, 19 + RandomUtils.nextInt(8));
|
g.drawString(String.valueOf(charArray[i]), 15 * i + 5, 19 + RandomUtils.nextInt(8));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,31 +1,36 @@
|
|||||||
#数据库账号
|
DockerWebHost=${HELLOHAO_SERVER_HOST:null}
|
||||||
spring.datasource.username=root
|
|
||||||
#数据库密码test
|
|
||||||
spring.datasource.password=root
|
|
||||||
#数据库链接地址
|
|
||||||
spring.datasource.url=jdbc:mysql://localhost:3306/tbed?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
|
|
||||||
#端口
|
#端口
|
||||||
server.port=8089
|
server.port=10088
|
||||||
#前端域名需要带协议头http(s)://
|
#前端域名需要带协议头http(s)://
|
||||||
CROS_ALLOWED_ORIGINS=http://127.0.0.1:8080
|
CROS_ALLOWED_ORIGINS=${HELLOHAO_WEB_HOST:http://127.0.0.1:8080}
|
||||||
|
#数据库账号
|
||||||
|
spring.datasource.username=${MYSQL_USERNAME:root}
|
||||||
|
#数据库密码test
|
||||||
|
spring.datasource.password=${MYSQL_PASS:root}
|
||||||
|
#数据库链接地址
|
||||||
|
spring.datasource.url=${MYSQL_URL:jdbc:mysql://localhost:3306/tbed?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8}
|
||||||
|
#MySQL Driver 无需修改
|
||||||
|
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||||
|
|
||||||
|
spring.redis.host= 127.0.0.1
|
||||||
|
spring.redis.port=6379
|
||||||
|
## 设置最大连接数,0为无限
|
||||||
|
spring.redis.pool.max-active=8
|
||||||
|
# 连接超时时间(毫秒)
|
||||||
|
spring.redis.timeout=5000
|
||||||
|
spring.redis.password=
|
||||||
|
|
||||||
#下边的配置项不需要修改。
|
#下边的配置项不需要修改。
|
||||||
#logging.config=classpath:logback-spring.xml
|
|
||||||
#logging.file.path=/HellohaoData/tbedlog
|
|
||||||
spring.thymeleaf.suffix=.html
|
spring.thymeleaf.suffix=.html
|
||||||
mybatis.configuration.map-underscore-to-camel-case=true
|
mybatis.configuration.map-underscore-to-camel-case=true
|
||||||
mybatis.mapper-locations=classpath:mapper/*.xml
|
mybatis.mapper-locations=classpath:mapper/*.xml
|
||||||
logging.level.cn.hellohao.dao=debug
|
|
||||||
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
|
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
|
||||||
spring.jackson.time-zone=GMT+8
|
spring.jackson.time-zone=GMT+8
|
||||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
|
||||||
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
|
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
|
||||||
spring.thymeleaf.cache=false
|
spring.thymeleaf.cache=false
|
||||||
multipart.maxFileSize=10240KB
|
multipart.maxFileSize=10240KB
|
||||||
multipart.maxRequestSize=10240KB
|
multipart.maxRequestSize=10240KB
|
||||||
spring.thymeleaf.mode = LEGACYHTML5
|
spring.thymeleaf.mode = LEGACYHTML5
|
||||||
spring.http.multipart.location=/data/upload_tmp
|
|
||||||
systemupdate=2020-05-26
|
systemupdate=2020-05-26
|
||||||
|
|
||||||
spring.datasource.druid.filter.config.enabled=false
|
spring.datasource.druid.filter.config.enabled=false
|
||||||
@@ -43,4 +48,11 @@ spring.datasource.druid.stat-view-servlet.login-username=hellohao@dealer
|
|||||||
spring.datasource.druid.stat-view-servlet.login-password=52BNmXPJL0rQQ3CU
|
spring.datasource.druid.stat-view-servlet.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
|
||||||
log4j2.formatMsgNoLookups=True
|
#log4j.logger.cn.hellohao.dao=DEBUG
|
||||||
|
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
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
\/ /_/ \___|_|_|\___/|_| |_|\__,_|\___/
|
\/ /_/ \___|_|_|\___/|_| |_|\__,_|\___/
|
||||||
|
|
||||||
__________________________________________
|
__________________________________________
|
||||||
HellohaoBlog:http://www.hellohao.cn
|
Hellohao图像托管:https://www.hellohao.cn
|
||||||
__________________________________________
|
__________________________________________
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -1,197 +1,144 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!-- 日志级别从低到高分为TRACE < DEBUG < INFO < WARN < ERROR < FATAL,如果设置为WARN,则低于WARN的信息都不会输出 -->
|
<!-- 级别从高到低 OFF 、 FATAL 、 ERROR 、 WARN 、 INFO 、 DEBUG 、 TRACE 、 ALL -->
|
||||||
<!-- scan:当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true -->
|
<!-- 日志输出规则 根据当前ROOT 级别,日志输出时,级别高于root默认的级别时 会输出 -->
|
||||||
<!-- scanPeriod:设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。 -->
|
<!-- 以下 每个配置的 filter 是过滤掉输出文件里面,会出现高级别文件,依然出现低级别的日志信息,通过filter 过滤只记录本级别的日志 -->
|
||||||
<!-- debug:当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
|
<!-- scan 当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true。 -->
|
||||||
<configuration scan="true" scanPeriod="10 seconds">
|
<!-- scanPeriod 设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。 -->
|
||||||
|
<!-- debug 当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。 -->
|
||||||
|
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||||
|
|
||||||
<!--<include resource="org/springframework/boot/logging/logback/base.xml" />-->
|
<!-- 动态日志级别 -->
|
||||||
|
<jmxConfigurator/>
|
||||||
<contextName>logback</contextName>
|
|
||||||
<!-- name的值是变量的名称,value的值时变量定义的值。通过定义的值会被插入到logger上下文中。定义变量后,可以使“${}”来使用变量。 -->
|
|
||||||
<property name="log.path" value="/HellohaoData/tbedlog" />
|
<property name="log.path" value="/HellohaoData/tbedlog" />
|
||||||
|
<!-- 定义日志文件 输出位置 -->
|
||||||
|
<property name="log.log_dir" value="logs"/>
|
||||||
|
<property name="log.log_name" value="log"/>
|
||||||
|
<!-- 日志最大的历史 30天 -->
|
||||||
|
<property name="log.maxHistory" value="30"/>
|
||||||
|
<property name="log.level" value="debug"/>
|
||||||
|
<property name="log.maxSize" value="5MB" />
|
||||||
|
|
||||||
<!-- 彩色日志 -->
|
<!-- ConsoleAppender 控制台输出日志 -->
|
||||||
<!-- 彩色日志依赖的渲染类 -->
|
|
||||||
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter" />
|
|
||||||
<conversionRule conversionWord="wex" converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
|
|
||||||
<conversionRule conversionWord="wEx" converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
|
|
||||||
<!-- 彩色日志格式 -->
|
|
||||||
<property name="CONSOLE_LOG_PATTERN" value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}"/>
|
|
||||||
|
|
||||||
|
|
||||||
<!--输出到控制台-->
|
|
||||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
<!--此日志appender是为开发使用,只配置最底级别,控制台输出的日志级别是大于或等于此级别的日志信息-->
|
<!-- <filter class="ch.qos.logback.classic.filter.LevelFilter">-->
|
||||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
<!-- <!– 设置过滤级别 –>-->
|
||||||
<level>DEBUG</level>
|
<!-- <level>INFO</level>-->
|
||||||
</filter>
|
<!-- <!– 用于配置符合过滤条件的操作 –>-->
|
||||||
|
<!-- <onMatch>ACCEPT</onMatch>-->
|
||||||
|
<!-- <!– 用于配置不符合过滤条件的操作 –>-->
|
||||||
|
<!-- <onMismatch>DENY</onMismatch>-->
|
||||||
|
<!-- </filter>-->
|
||||||
<encoder>
|
<encoder>
|
||||||
<Pattern>${CONSOLE_LOG_PATTERN}</Pattern>
|
<pattern>
|
||||||
<!-- 设置字符集 -->
|
<!-- 设置日志输出格式 -->
|
||||||
<charset>UTF-8</charset>
|
<!-- 日期 [线程] [class类]-[日志级别] log内容 -->
|
||||||
|
%blue(%d{yyyy-MM-dd HH:mm:ss,SSS}) [%cyan(%t)] [%yellow(%c)]-[%highlight(%p)] %m%n
|
||||||
|
</pattern>
|
||||||
</encoder>
|
</encoder>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
|
<!-- ERROR级别日志 -->
|
||||||
<!--输出到文件-->
|
<!-- 滚动记录文件,先将日志记录到指定文件,当符合某个条件时,将日志记录到其他文件 RollingFileAppender -->
|
||||||
|
<appender name="ERROR" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
<!-- 时间滚动输出 level为 DEBUG 日志 -->
|
|
||||||
<appender name="DEBUG_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<!-- 正在记录的日志文件的路径及文件名 -->
|
|
||||||
<file>${log.path}/log_debug.log</file>
|
|
||||||
<!--日志文件输出格式-->
|
|
||||||
<encoder>
|
|
||||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
|
||||||
<charset>UTF-8</charset> <!-- 设置字符集 -->
|
|
||||||
</encoder>
|
|
||||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<!-- 日志归档 -->
|
|
||||||
<fileNamePattern>${log.path}/debug/log-debug-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
|
||||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
|
||||||
<maxFileSize>100MB</maxFileSize>
|
|
||||||
</timeBasedFileNamingAndTriggeringPolicy>
|
|
||||||
<!--日志文件保留天数-->
|
|
||||||
<maxHistory>15</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
<!-- 此日志文件只记录debug级别的 -->
|
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
|
||||||
<level>debug</level>
|
|
||||||
<onMatch>ACCEPT</onMatch>
|
|
||||||
<onMismatch>DENY</onMismatch>
|
|
||||||
</filter>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- 时间滚动输出 level为 INFO 日志 -->
|
|
||||||
<appender name="INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<!-- 正在记录的日志文件的路径及文件名 -->
|
|
||||||
<file>${log.path}/log_info.log</file>
|
|
||||||
<!--日志文件输出格式-->
|
|
||||||
<encoder>
|
|
||||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
|
||||||
<charset>UTF-8</charset>
|
|
||||||
</encoder>
|
|
||||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<!-- 每天日志归档路径以及格式 -->
|
|
||||||
<fileNamePattern>${log.path}/info/log-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
|
||||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
|
||||||
<maxFileSize>100MB</maxFileSize>
|
|
||||||
</timeBasedFileNamingAndTriggeringPolicy>
|
|
||||||
<!--日志文件保留天数-->
|
|
||||||
<maxHistory>15</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
<!-- 此日志文件只记录info级别的 -->
|
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
|
||||||
<level>info</level>
|
|
||||||
<onMatch>ACCEPT</onMatch>
|
|
||||||
<onMismatch>DENY</onMismatch>
|
|
||||||
</filter>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
<!-- 时间滚动输出 level为 WARN 日志 -->
|
|
||||||
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<!-- 正在记录的日志文件的路径及文件名 -->
|
|
||||||
<file>${log.path}/log_warn.log</file>
|
|
||||||
<!--日志文件输出格式-->
|
|
||||||
<encoder>
|
|
||||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
|
||||||
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
|
|
||||||
</encoder>
|
|
||||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<fileNamePattern>${log.path}/warn/log-warn-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
|
||||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
|
||||||
<maxFileSize>100MB</maxFileSize>
|
|
||||||
</timeBasedFileNamingAndTriggeringPolicy>
|
|
||||||
<!--日志文件保留天数-->
|
|
||||||
<maxHistory>15</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
<!-- 此日志文件只记录warn级别的 -->
|
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
|
||||||
<level>warn</level>
|
|
||||||
<onMatch>ACCEPT</onMatch>
|
|
||||||
<onMismatch>DENY</onMismatch>
|
|
||||||
</filter>
|
|
||||||
</appender>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- 时间滚动输出 level为 ERROR 日志 -->
|
|
||||||
<appender name="ERROR_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
|
||||||
<!-- 正在记录的日志文件的路径及文件名 -->
|
|
||||||
<file>${log.path}/log_error.log</file>
|
<file>${log.path}/log_error.log</file>
|
||||||
<!--日志文件输出格式-->
|
<!-- 过滤器,只记录WARN级别的日志 -->
|
||||||
<encoder>
|
<!-- 果日志级别等于配置级别,过滤器会根据onMath 和 onMismatch接收或拒绝日志。 -->
|
||||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
|
||||||
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
|
|
||||||
</encoder>
|
|
||||||
<!-- 日志记录器的滚动策略,按日期,按大小记录 -->
|
|
||||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
|
||||||
<fileNamePattern>${log.path}/error/log-error-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
|
||||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
|
||||||
<maxFileSize>100MB</maxFileSize>
|
|
||||||
</timeBasedFileNamingAndTriggeringPolicy>
|
|
||||||
<!--日志文件保留天数-->
|
|
||||||
<maxHistory>15</maxHistory>
|
|
||||||
</rollingPolicy>
|
|
||||||
<!-- 此日志文件只记录ERROR级别的 -->
|
|
||||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<!-- 设置过滤级别 -->
|
||||||
<level>ERROR</level>
|
<level>ERROR</level>
|
||||||
|
<!-- 用于配置符合过滤条件的操作 -->
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<!-- 用于配置不符合过滤条件的操作 -->
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
<!-- 最常用的滚动策略,它根据时间来制定滚动策略.既负责滚动也负责触发滚动 -->
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||||
|
<!--日志输出位置 可相对、和绝对路径 -->
|
||||||
|
<fileNamePattern>
|
||||||
|
${log.log_dir}/error/%d{yyyy-MM-dd}/error_${log.log_name}-%i.log
|
||||||
|
</fileNamePattern>
|
||||||
|
<!-- 可选节点,控制保留的归档文件的最大数量,超出数量就删除旧文件,假设设置每个月滚动,且<maxHistory>是6,
|
||||||
|
则只保存最近6个月的文件,删除之前的旧文件。注意,删除旧文件是,那些为了归档而创建的目录也会被删除 -->
|
||||||
|
<maxHistory>${log.maxHistory}</maxHistory>
|
||||||
|
<!--日志文件最大的大小-->
|
||||||
|
<MaxFileSize>${log.maxSize}</MaxFileSize>
|
||||||
|
<cleanHistoryOnStart>true</cleanHistoryOnStart>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>
|
||||||
|
<!-- 设置日志输出格式 -->
|
||||||
|
%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
|
||||||
|
</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<!-- INFO级别日志 appender -->
|
||||||
|
<appender name="INFO" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/log_info.log</file>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<level>INFO</level>
|
||||||
<onMatch>ACCEPT</onMatch>
|
<onMatch>ACCEPT</onMatch>
|
||||||
<onMismatch>DENY</onMismatch>
|
<onMismatch>DENY</onMismatch>
|
||||||
</filter>
|
</filter>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||||
|
<fileNamePattern>${log.log_dir}/info/%d{yyyy-MM-dd}/info_${log.log_name}-%i.log</fileNamePattern>
|
||||||
|
<maxHistory>${log.maxHistory}</maxHistory>
|
||||||
|
<MaxFileSize>${log.maxSize}</MaxFileSize>
|
||||||
|
<cleanHistoryOnStart>true</cleanHistoryOnStart>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] %logger - %msg%n</pattern>
|
||||||
|
</encoder>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<!--
|
|
||||||
<logger>用来设置某一个包或者具体的某一个类的日志打印级别、
|
|
||||||
以及指定<appender>。<logger>仅有一个name属性,
|
|
||||||
一个可选的level和一个可选的addtivity属性。
|
|
||||||
name:用来指定受此logger约束的某一个包或者具体的某一个类。
|
|
||||||
level:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,
|
|
||||||
还有一个特俗值INHERITED或者同义词NULL,代表强制执行上级的级别。
|
|
||||||
如果未设置此属性,那么当前logger将会继承上级的级别。
|
|
||||||
addtivity:是否向上级logger传递打印信息。默认是true。
|
|
||||||
-->
|
|
||||||
<!--<logger name="org.springframework.web" level="info"/>-->
|
|
||||||
<!--<logger name="org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor" level="INFO"/>-->
|
|
||||||
<!--
|
|
||||||
使用mybatis的时候,sql语句是debug下才会打印,而这里我们只配置了info,所以想要查看sql语句的话,有以下两种操作:
|
|
||||||
第一种把<root level="info">改成<root level="DEBUG">这样就会打印sql,不过这样日志那边会出现很多其他消息
|
|
||||||
第二种就是单独给dao下目录配置debug模式,代码如下,这样配置sql语句会打印,其他还是正常info级别:
|
|
||||||
-->
|
|
||||||
|
|
||||||
|
<!-- DEBUG级别日志 appender -->
|
||||||
|
<appender name="DEBUG" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<file>${log.path}/log_debug.log</file>
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<level>DEBUG</level>
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||||
|
<fileNamePattern>${log.log_dir}/debug/%d{yyyy-MM-dd}/debug_${log.log_name}-%i.log</fileNamePattern>
|
||||||
|
<maxHistory>${log.maxHistory}</maxHistory>
|
||||||
|
<MaxFileSize>${log.maxSize}</MaxFileSize>
|
||||||
|
<cleanHistoryOnStart>true</cleanHistoryOnStart>
|
||||||
|
</rollingPolicy>
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] %logger - %msg%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
<!--
|
<!--设置一个向上传递的appender,所有级别的日志都会输出-->
|
||||||
root节点是必选节点,用来指定最基础的日志输出级别,只有一个level属性
|
<!-- <appender name="app" class="ch.qos.logback.core.rolling.RollingFileAppender">-->
|
||||||
level:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,
|
<!-- <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">-->
|
||||||
不能设置为INHERITED或者同义词NULL。默认是DEBUG
|
<!-- <fileNamePattern>${log.log_dir}/app/%d{yyyy-MM-dd}/app_${log.log_name}-%i.log</fileNamePattern>-->
|
||||||
可以包含零个或多个元素,标识这个appender将会添加到这个logger。
|
<!-- <maxHistory>${log.maxHistory}</maxHistory>-->
|
||||||
-->
|
<!-- <MaxFileSize>${log.maxSize}</MaxFileSize>-->
|
||||||
|
<!-- <cleanHistoryOnStart>true</cleanHistoryOnStart>-->
|
||||||
|
<!-- </rollingPolicy>-->
|
||||||
|
<!-- <encoder>-->
|
||||||
|
<!-- <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%-5level] %logger - %msg%n</pattern>-->
|
||||||
|
<!-- </encoder>-->
|
||||||
|
<!-- </appender>-->
|
||||||
|
|
||||||
<!--开发环境:打印控制台-->
|
<!--name包下的类的日志输出-->
|
||||||
<springProfile name="dev">
|
<logger name="cn.hellohao" additivity="false" level="DEBUG" >
|
||||||
<logger name="cn.hellohao.dao" level="debug"/>
|
|
||||||
</springProfile>
|
|
||||||
|
|
||||||
<root level="info">
|
|
||||||
<appender-ref ref="CONSOLE" />
|
<appender-ref ref="CONSOLE" />
|
||||||
<appender-ref ref="DEBUG_FILE" />
|
<appender-ref ref="INFO" />
|
||||||
<appender-ref ref="INFO_FILE" />
|
<appender-ref ref="DEBUG" />
|
||||||
<appender-ref ref="WARN_FILE" />
|
<appender-ref ref="ERROR" />
|
||||||
<appender-ref ref="ERROR_FILE" />
|
</logger>
|
||||||
</root>
|
<logger name="proxy.system.log" additivity="false">
|
||||||
|
<appender-ref ref="INFO" />
|
||||||
|
<appender-ref ref="DEBUG" />
|
||||||
|
<appender-ref ref="ERROR" />
|
||||||
|
</logger>
|
||||||
|
|
||||||
<!--生产环境:输出到文件-->
|
|
||||||
<!--<springProfile name="pro">-->
|
|
||||||
<!--<root level="info">-->
|
|
||||||
<!--<appender-ref ref="CONSOLE" />-->
|
|
||||||
<!--<appender-ref ref="DEBUG_FILE" />-->
|
|
||||||
<!--<appender-ref ref="INFO_FILE" />-->
|
|
||||||
<!--<appender-ref ref="ERROR_FILE" />-->
|
|
||||||
<!--<appender-ref ref="WARN_FILE" />-->
|
|
||||||
<!--</root>-->
|
|
||||||
<!--</springProfile>-->
|
|
||||||
|
|
||||||
</configuration>
|
|
||||||
|
|
||||||
|
<!-- root级别 DEBUG -->
|
||||||
|
<!-- <root level="DEBUG">-->
|
||||||
|
<!-- </root>-->
|
||||||
|
</configuration>
|
||||||
@@ -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 CONCAT('%', #{albumkey}, '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="username != null">
|
<if test="username != null">
|
||||||
`username` like '%${username}%'
|
and `username` like CONCAT('%', #{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
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="cn.hellohao.dao.ConfdataMapper">
|
||||||
|
|
||||||
|
<select id="selectConfdata" resultType="cn.hellohao.pojo.Confdata">
|
||||||
|
select * from confdata where `key`=#{key}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<update id="updateConfdata" parameterType="cn.hellohao.pojo.Confdata">
|
||||||
|
UPDATE confdata
|
||||||
|
<set>
|
||||||
|
<if test="jsondata != null">
|
||||||
|
jsondata = #{jsondata},
|
||||||
|
</if>
|
||||||
|
</set>
|
||||||
|
where `key`=#{key}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="cn.hellohao.dao.ConfigMapper">
|
|
||||||
|
|
||||||
<select id="getSourceype" resultType="cn.hellohao.pojo.Config">
|
|
||||||
select * from config where id = 1
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<update id="setSourceype" parameterType="cn.hellohao.pojo.Config">
|
|
||||||
UPDATE config
|
|
||||||
<set>
|
|
||||||
<if test="sourcekey != null">
|
|
||||||
sourcekey = #{sourcekey},
|
|
||||||
</if>
|
|
||||||
<if test="emails != null">
|
|
||||||
emails = #{emails},
|
|
||||||
</if>
|
|
||||||
<if test="webname != null">
|
|
||||||
webname = #{webname},
|
|
||||||
</if>
|
|
||||||
<if test="explain != null">
|
|
||||||
`explain` = #{explain},
|
|
||||||
</if>
|
|
||||||
<if test="video != null">
|
|
||||||
`video` = #{video},
|
|
||||||
</if>
|
|
||||||
<if test="backtype != null">
|
|
||||||
`backtype` = #{backtype},
|
|
||||||
</if>
|
|
||||||
<if test="links != null">
|
|
||||||
`links` = #{links},
|
|
||||||
</if>
|
|
||||||
<if test="notice != null">
|
|
||||||
`notice` = #{notice},
|
|
||||||
</if>
|
|
||||||
<if test="baidu != null">
|
|
||||||
`baidu` = #{baidu},
|
|
||||||
</if>
|
|
||||||
<if test="domain != null">
|
|
||||||
`domain` = #{domain},
|
|
||||||
</if>
|
|
||||||
<if test="background1 != null">
|
|
||||||
`background1` = #{background1},
|
|
||||||
</if>
|
|
||||||
<if test="background2 != null">
|
|
||||||
`background2` = #{background2},
|
|
||||||
</if>
|
|
||||||
<if test="sett != null">
|
|
||||||
`sett` = #{sett},
|
|
||||||
</if>
|
|
||||||
<if test="webms != null">
|
|
||||||
`webms` = #{webms},
|
|
||||||
</if>
|
|
||||||
<if test="webkeywords != null">
|
|
||||||
`webkeywords` = #{webkeywords},
|
|
||||||
</if>
|
|
||||||
<if test="webfavicons != null">
|
|
||||||
`webfavicons` = #{webfavicons},
|
|
||||||
</if>
|
|
||||||
<if test="theme != null">
|
|
||||||
`theme` = #{theme},
|
|
||||||
</if>
|
|
||||||
<if test="websubtitle != null">
|
|
||||||
websubtitle = #{websubtitle},
|
|
||||||
</if>
|
|
||||||
<if test="logo != null">
|
|
||||||
logo = #{logo},
|
|
||||||
</if>
|
|
||||||
<if test="aboutinfo != null">
|
|
||||||
aboutinfo = #{aboutinfo},
|
|
||||||
</if>
|
|
||||||
|
|
||||||
|
|
||||||
</set>
|
|
||||||
where id=1
|
|
||||||
</update>
|
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
|
||||||
@@ -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>
|
||||||
|
|||||||
@@ -53,11 +53,11 @@
|
|||||||
<choose>
|
<choose>
|
||||||
<when test="selecttype==1">
|
<when test="selecttype==1">
|
||||||
and
|
and
|
||||||
a.userid in ( SELECT id from `user` where username LIKE '%${username}%')
|
a.userid in ( SELECT id from `user` where username LIKE CONCAT('%', #{username}, '%'))
|
||||||
</when>
|
</when>
|
||||||
<otherwise>
|
<otherwise>
|
||||||
and
|
and
|
||||||
a.userid not in ( SELECT id from `user` where username LIKE '%${username}%')
|
a.userid not in ( SELECT id from `user` where username LIKE CONCAT('%', #{username}, '%'))
|
||||||
</otherwise>
|
</otherwise>
|
||||||
</choose>
|
</choose>
|
||||||
</if>
|
</if>
|
||||||
@@ -67,17 +67,79 @@
|
|||||||
and
|
and
|
||||||
a.imguid = #{imguid}
|
a.imguid = #{imguid}
|
||||||
</if>
|
</if>
|
||||||
<if test="idname != null and idname !=''">
|
<if test="searchname != null">
|
||||||
and idname LIKE '%${idname}%'
|
and CONCAT(
|
||||||
|
imgurl,
|
||||||
|
idname
|
||||||
|
) LIKE CONCAT('%', #{searchname}, '%')
|
||||||
</if>
|
</if>
|
||||||
order by a.id desc
|
<if test="idname != null and idname !=''">
|
||||||
|
and idname LIKE CONCAT('%', #{idname}, '%')
|
||||||
|
</if>
|
||||||
|
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 INTO imgdata (
|
||||||
|
id,
|
||||||
|
imgname,
|
||||||
|
imgurl,
|
||||||
|
userid,
|
||||||
|
updatetime,
|
||||||
|
sizes,
|
||||||
|
abnormal,
|
||||||
|
`source`,
|
||||||
|
imgtype,
|
||||||
|
explains,
|
||||||
|
md5key,
|
||||||
|
imguid,
|
||||||
|
`format`,
|
||||||
|
about,
|
||||||
|
violation,
|
||||||
|
idname,
|
||||||
|
brieflink,
|
||||||
|
shortlink
|
||||||
|
)
|
||||||
|
VALUES (null, #{imgname}, #{imgurl}, #{userid}, #{updatetime},#{sizes},#{abnormal},#{source},#{imgtype},
|
||||||
|
#{explains},#{md5key},#{imguid},#{format},#{about},null,#{idname},#{brieflink},#{shortlink})
|
||||||
|
</insert>
|
||||||
|
|
||||||
<!-- 此用户下总数 -->
|
<!-- 此用户下总数 -->
|
||||||
<select id="countimg" parameterType="integer" resultType="integer">
|
<select id="countimg" parameterType="integer" resultType="integer">
|
||||||
select count(*) from imgdata where userid = #{userid}
|
select count(*) from imgdata where userid = #{userid}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<delete id="deleimg" parameterType="integer">
|
<delete id="deleimg" parameterType="Long">
|
||||||
DELETE FROM imgdata WHERE id=#{id}
|
DELETE FROM imgdata WHERE id=#{id}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
@@ -85,10 +147,18 @@
|
|||||||
DELETE FROM imgdata WHERE imguid = #{imguid}
|
DELETE FROM imgdata WHERE imguid = #{imguid}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<select id="selectByPrimaryKey" parameterType="integer" resultType="cn.hellohao.pojo.Images">
|
<select id="selectByPrimaryKey" parameterType="Long" resultType="cn.hellohao.pojo.Images">
|
||||||
select * from imgdata where id = #{id}
|
select * from imgdata where id = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectImgByBrieflink" parameterType="string" resultType="cn.hellohao.pojo.Images">
|
||||||
|
select * from imgdata where binary brieflink = #{brieflink}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectImgByShortlink" parameterType="string" resultType="cn.hellohao.pojo.Images">
|
||||||
|
select * from imgdata where binary shortlink = #{shortlink}
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="counts" resultType="integer">
|
<select id="counts" resultType="integer">
|
||||||
select count(*) from imgdata where 1=1
|
select count(*) from imgdata where 1=1
|
||||||
<if test="userid != null">
|
<if test="userid != null">
|
||||||
@@ -110,6 +180,10 @@
|
|||||||
<if test="idname!=null and idname!=''">
|
<if test="idname!=null and idname!=''">
|
||||||
idname=#{idname}
|
idname=#{idname}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="violation!=null and violation!=''">
|
||||||
|
violation=#{violation}
|
||||||
|
</if>
|
||||||
|
|
||||||
</set>
|
</set>
|
||||||
where imgname=#{imgname}
|
where imgname=#{imgname}
|
||||||
</update>
|
</update>
|
||||||
@@ -119,7 +193,7 @@
|
|||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
<!-- 批量删除-->
|
<!-- 批量删除-->
|
||||||
<delete id="deleall" parameterType="integer">
|
<delete id="deleall" parameterType="Long">
|
||||||
DELETE FROM imgdata WHERE id = #{id}
|
DELETE FROM imgdata WHERE id = #{id}
|
||||||
</delete>
|
</delete>
|
||||||
|
|
||||||
@@ -142,6 +216,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条数据-->
|
||||||
|
|||||||
@@ -27,7 +27,8 @@
|
|||||||
WHEN storageType=5 THEN '本地'
|
WHEN storageType=5 THEN '本地'
|
||||||
WHEN storageType=6 THEN '腾讯云'
|
WHEN storageType=6 THEN '腾讯云'
|
||||||
WHEN storageType=7 THEN 'FTP'
|
WHEN storageType=7 THEN 'FTP'
|
||||||
WHEN storageType=8 THEN 'UFile'
|
WHEN storageType=8 THEN 'S3协议'
|
||||||
|
WHEN storageType=9 THEN 'WebDAV'
|
||||||
ELSE '未知' END AS storageName,
|
ELSE '未知' END AS storageName,
|
||||||
keyname
|
keyname
|
||||||
FROM `keys` GROUP BY storageType,id,storageName,keyname
|
FROM `keys` GROUP BY storageType,id,storageName,keyname
|
||||||
@@ -49,7 +50,10 @@
|
|||||||
Endpoint = #{Endpoint},
|
Endpoint = #{Endpoint},
|
||||||
Bucketname = #{Bucketname},
|
Bucketname = #{Bucketname},
|
||||||
RequestAddress = #{RequestAddress},
|
RequestAddress = #{RequestAddress},
|
||||||
keyname = #{keyname}
|
keyname = #{keyname},
|
||||||
|
Region = #{Region},
|
||||||
|
RootPath = #{RootPath},
|
||||||
|
SysTransmit=#{SysTransmit}
|
||||||
WHERE
|
WHERE
|
||||||
storageType = #{storageType}
|
storageType = #{storageType}
|
||||||
</update>
|
</update>
|
||||||
|
|||||||
@@ -53,7 +53,6 @@
|
|||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 查询当前用户:根据邮箱,根据id -->
|
|
||||||
<select id="getUsers" parameterType="cn.hellohao.pojo.User" resultType="cn.hellohao.pojo.User">
|
<select id="getUsers" parameterType="cn.hellohao.pojo.User" resultType="cn.hellohao.pojo.User">
|
||||||
SELECT id,
|
SELECT id,
|
||||||
username,
|
username,
|
||||||
@@ -74,6 +73,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>
|
||||||
@@ -82,7 +84,7 @@
|
|||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
<!-- 查询当前用户:根据id -->
|
|
||||||
<select id="getUsersid" parameterType="integer" resultType="cn.hellohao.pojo.User">
|
<select id="getUsersid" parameterType="integer" resultType="cn.hellohao.pojo.User">
|
||||||
SELECT id,
|
SELECT id,
|
||||||
username,
|
username,
|
||||||
@@ -98,7 +100,7 @@
|
|||||||
FROM user
|
FROM user
|
||||||
WHERE id = #{id}
|
WHERE id = #{id}
|
||||||
</select>
|
</select>
|
||||||
<!-- 查询当前用户:根据uid -->
|
|
||||||
<select id="getUsersMail" parameterType="string" resultType="cn.hellohao.pojo.User">
|
<select id="getUsersMail" parameterType="string" resultType="cn.hellohao.pojo.User">
|
||||||
SELECT id,
|
SELECT id,
|
||||||
username,
|
username,
|
||||||
@@ -115,13 +117,6 @@
|
|||||||
WHERE uid = #{uid}
|
WHERE uid = #{uid}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 插入图片信息 -->
|
|
||||||
<insert id="insertimg" parameterType="cn.hellohao.pojo.Images">
|
|
||||||
INSERT INTO imgdata (id, imgname, imgurl, userid, updatetime,sizes,abnormal,source,imgtype,md5key,imguid,format,about,violation,idname)
|
|
||||||
VALUES (NULL, #{imgname}, #{imgurl}, #{userid}, #{updatetime},#{sizes},#{abnormal},#{source},#{imgtype},#{md5key},#{imguid},#{format},#{about},null,#{idname})
|
|
||||||
</insert>
|
|
||||||
|
|
||||||
<!-- 修改资料 -->
|
|
||||||
<update id="change" parameterType="cn.hellohao.pojo.User">
|
<update id="change" parameterType="cn.hellohao.pojo.User">
|
||||||
UPDATE `user`
|
UPDATE `user`
|
||||||
<set>
|
<set>
|
||||||
@@ -182,12 +177,10 @@
|
|||||||
SELECT count(username) FROM `user` where username=#{username}
|
SELECT count(username) FROM `user` where username=#{username}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 查询用户总数 -->
|
|
||||||
<select id="getUserTotal" resultType="integer">
|
<select id="getUserTotal" resultType="integer">
|
||||||
SELECT count(*) FROM `user`
|
SELECT count(*) FROM `user`
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 获取用户的详细信息 -->
|
|
||||||
<select id="getuserlist" resultType="cn.hellohao.pojo.User" parameterType="string">
|
<select id="getuserlist" resultType="cn.hellohao.pojo.User" parameterType="string">
|
||||||
SELECT
|
SELECT
|
||||||
id,
|
id,
|
||||||
@@ -210,7 +203,7 @@
|
|||||||
and CONCAT(
|
and CONCAT(
|
||||||
username,
|
username,
|
||||||
email
|
email
|
||||||
) LIKE '%${username}%'
|
) LIKE CONCAT('%', #{username}, '%')
|
||||||
</if>
|
</if>
|
||||||
order by birthder desc
|
order by birthder desc
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@@ -0,0 +1,64 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="en" xmlns:th="http://www.thymeleaf.org">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Welcome</title>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
<style>
|
||||||
|
|
||||||
|
* {
|
||||||
|
line-height: 1.2;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
html {
|
||||||
|
color: #888;
|
||||||
|
display: table;
|
||||||
|
font-family: sans-serif;
|
||||||
|
height: 100%;
|
||||||
|
text-align: center;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
display: table-cell;
|
||||||
|
vertical-align: middle;
|
||||||
|
margin: 2em auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
color: #555;
|
||||||
|
font-size: 2em;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin: 0 auto;
|
||||||
|
width: 280px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media only screen and (max-width: 280px) {
|
||||||
|
|
||||||
|
body, p {
|
||||||
|
width: 95%;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font-size: 1.5em;
|
||||||
|
margin: 0 0 0.3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1 style="font-size: 4.5em;" th:text="'Welcome'"></h1>
|
||||||
|
<br />
|
||||||
|
<h3 style="line-height: 80px;" th:text="${name}"></h3>
|
||||||
|
<p th:text="'服务版本:'+${version}"></p>
|
||||||
|
<p th:text="'来访者IP:'+${ip}"></p>
|
||||||
|
<a style="font-weight: bold; line-height: 80px;" th:href="'http://'+${links}" th:text="${links}"></a>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
<!-- IE needs 512+ bytes: https://blogs.msdn.microsoft.com/ieinternals/2010/08/18/friendly-http-error-pages/ -->
|
||||||
Reference in New Issue
Block a user