Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
shop-Mall
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
licc
shop-Mall
Commits
a4c5661e
Commit
a4c5661e
authored
Mar 23, 2021
by
m1991
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
资讯模块——邀请码过滤特殊字符功能功能修复
parent
9887c6c4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
16 deletions
+44
-16
FileUtil.java
...mon/src/main/java/cn/wisenergy/common/utils/FileUtil.java
+1
-2
pom.xml
wisenergy-service/pom.xml
+6
-0
UploadServiceImpl.java
...java/cn/wisenergy/service/app/impl/UploadServiceImpl.java
+31
-14
pom.xml
wisenergy-web-admin/pom.xml
+6
-0
No files found.
wisenergy-common/src/main/java/cn/wisenergy/common/utils/FileUtil.java
View file @
a4c5661e
...
@@ -83,5 +83,4 @@ public class FileUtil {
...
@@ -83,5 +83,4 @@ public class FileUtil {
}
}
return
inputStream
;
return
inputStream
;
}
}
}
}
\ No newline at end of file
wisenergy-service/pom.xml
View file @
a4c5661e
...
@@ -104,6 +104,12 @@
...
@@ -104,6 +104,12 @@
<groupId>
org.bytedeco.javacpp-presets
</groupId>
<groupId>
org.bytedeco.javacpp-presets
</groupId>
<artifactId>
ffmpeg-platform
</artifactId>
<artifactId>
ffmpeg-platform
</artifactId>
</dependency>
</dependency>
<!--图片压缩处理-->
<dependency>
<groupId>
net.coobird
</groupId>
<artifactId>
thumbnailator
</artifactId>
<version>
0.4.8
</version>
</dependency>
</dependencies>
</dependencies>
<!-- MAVEN构建 -->
<!-- MAVEN构建 -->
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/UploadServiceImpl.java
View file @
a4c5661e
package
cn
.
wisenergy
.
service
.
app
.
impl
;
package
cn
.
wisenergy
.
service
.
app
.
impl
;
import
cn.hutool.core.img.Img
;
import
cn.wisenergy.common.expection.BaseException
;
import
cn.wisenergy.common.expection.BaseException
;
import
cn.wisenergy.common.utils.*
;
import
cn.wisenergy.common.utils.*
;
...
@@ -12,6 +14,9 @@ import org.springframework.stereotype.Service;
...
@@ -12,6 +14,9 @@ import org.springframework.stereotype.Service;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.net.MalformedURLException
;
import
java.net.MalformedURLException
;
import
java.nio.file.Files
;
import
java.nio.file.Files
;
...
@@ -21,8 +26,10 @@ import java.nio.file.StandardCopyOption;
...
@@ -21,8 +26,10 @@ import java.nio.file.StandardCopyOption;
import
cn.wisenergy.service.app.UploadService
;
import
cn.wisenergy.service.app.UploadService
;
import
java.io.File
;
import
java.util.*
;
import
java.util.*
;
import
java.util.List
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
cn.wisenergy.mapper.ShopZxMapper
;
import
cn.wisenergy.mapper.ShopZxMapper
;
...
@@ -31,6 +38,7 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -31,6 +38,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
/**
/**
* Created by m1991 on 2021/2/24 13:42
* Created by m1991 on 2021/2/24 13:42
*/
*/
...
@@ -52,7 +60,7 @@ public class UploadServiceImpl implements UploadService {
...
@@ -52,7 +60,7 @@ public class UploadServiceImpl implements UploadService {
private
String
path
;
private
String
path
;
/**
/**
* 视频文件上传
*
TODO
视频文件上传
*/
*/
@Override
@Override
public
Map
<
String
,
Object
>
uploadVideo
(
MultipartFile
file
,
HttpServletRequest
request
,
String
zxField
,
String
inviteCode
)
throws
Exception
{
public
Map
<
String
,
Object
>
uploadVideo
(
MultipartFile
file
,
HttpServletRequest
request
,
String
zxField
,
String
inviteCode
)
throws
Exception
{
...
@@ -105,7 +113,7 @@ public class UploadServiceImpl implements UploadService {
...
@@ -105,7 +113,7 @@ public class UploadServiceImpl implements UploadService {
}
}
/**
/**
* 图片文件上传
*
TODO
图片文件上传
*/
*/
@Override
@Override
public
Map
<
String
,
Object
>
uploadImage
(
MultipartFile
file
,
String
inviteCode
)
throws
Exception
{
public
Map
<
String
,
Object
>
uploadImage
(
MultipartFile
file
,
String
inviteCode
)
throws
Exception
{
...
@@ -148,7 +156,7 @@ public class UploadServiceImpl implements UploadService {
...
@@ -148,7 +156,7 @@ public class UploadServiceImpl implements UploadService {
}
}
/**
/**
* 多图片
*
TODO
多图片
*
*
* @param files
* @param files
* @param zxField
* @param zxField
...
@@ -158,6 +166,7 @@ public class UploadServiceImpl implements UploadService {
...
@@ -158,6 +166,7 @@ public class UploadServiceImpl implements UploadService {
@Override
@Override
public
Map
imageUpload
(
MultipartFile
[]
files
,
String
zxField
,
String
inviteCode
)
{
public
Map
imageUpload
(
MultipartFile
[]
files
,
String
zxField
,
String
inviteCode
)
{
String
zxUrl
=
new
String
();
String
zxUrl
=
new
String
();
String
xxurl
=
new
String
();
if
(
null
==
inviteCode
||
""
.
equals
(
inviteCode
))
{
if
(
null
==
inviteCode
||
""
.
equals
(
inviteCode
))
{
inviteCode
=
"0"
;
inviteCode
=
"0"
;
}
}
...
@@ -171,23 +180,23 @@ public class UploadServiceImpl implements UploadService {
...
@@ -171,23 +180,23 @@ public class UploadServiceImpl implements UploadService {
//创建集合
//创建集合
List
<
Map
<
String
,
Object
>>
root
=
new
ArrayList
<
Map
<
String
,
Object
>>();
List
<
Map
<
String
,
Object
>>
root
=
new
ArrayList
<
Map
<
String
,
Object
>>();
String
fileName1
=
null
;
String
fileName1
=
null
;
// 要上传的目标文件存放的绝对路径
// final String localPath = path;
Long
time
=
System
.
currentTimeMillis
();
Long
time
=
System
.
currentTimeMillis
();
String
localPath
=
"/upload/"
;
Map
<
String
,
Object
>
result
=
new
HashMap
<
String
,
Object
>();
//一个文件上传的结果
Map
<
String
,
Object
>
result
=
new
HashMap
<
String
,
Object
>();
//一个文件上传的结果
String
msg
=
""
;
//上传结果信息
String
msg
=
""
;
//上传结果信息
//上传图片不为空时
//上传图片不为空时
long
sa
=
0
;
long
sa
=
0
;
for
(
MultipartFile
file
:
files
)
{
for
(
MultipartFile
file
:
files
)
{
sa
=
file
.
getSize
();
sa
=
file
.
getSize
();
}
}
if
(
sa
>
0
)
{
if
(
sa
>
0
)
{
//遍历图片数据
//遍历图片数据
for
(
MultipartFile
file
:
files
)
{
for
(
MultipartFile
file
:
files
)
{
//判断上传文件格式
//判断上传文件格式
String
fileType
=
file
.
getContentType
();
String
fileType
=
file
.
getContentType
();
log
.
info
(
file
.
getSize
()
+
""
);
log
.
info
(
file
.
getSize
()
+
""
);
if
((
"image/jpeg"
).
equals
(
fileType
)
||
(
"image/png"
).
equals
(
fileType
)
||
(
"image/gif"
).
equals
(
fileType
)
||
(
"image/jpg"
).
equals
(
fileType
)
||
(
"image/bmp"
).
equals
(
fileType
)
||
(
"application/octet-stream"
).
equals
(
fileType
))
{
if
((
"image/jpeg"
).
equals
(
fileType
)
||
(
"image/png"
).
equals
(
fileType
)
||
(
"image/gif"
).
equals
(
fileType
)
||
(
"image/jpg"
).
equals
(
fileType
)
||
(
"image/bmp"
).
equals
(
fileType
)
||
(
"application/octet-stream"
).
equals
(
fileType
))
{
//上传后保存的文件名(需要防止图片重名导致的文件覆盖)
//上传后保存的文件名(需要防止图片重名导致的文件覆盖)
//获取文件名
//获取文件名
...
@@ -205,14 +214,22 @@ public class UploadServiceImpl implements UploadService {
...
@@ -205,14 +214,22 @@ public class UploadServiceImpl implements UploadService {
fileName
=
"1"
+
UUID
.
randomUUID
()
+
fileName1
+
".jpg"
;
//文件新名称
fileName
=
"1"
+
UUID
.
randomUUID
()
+
fileName1
+
".jpg"
;
//文件新名称
}
}
//设置文件存储路径,可以存放在你想要指定的路径里面
//设置文件存储路径,可以存放在你想要指定的路径里面
String
Path
=
"/opt/upload/video/"
;
//上传图片存放位置
String
Path
=
"/upload/"
;
zxUrl
+=
localPath
+
fileName
+
","
;
String
Path1
=
"/opt/upload/video/"
;
//上传图片存放位置
zxUrl
+=
Path1
+
fileName
+
","
;
String
UrlzxPath
=
"/opt/upload/video/"
;
xxurl
=
UrlzxPath
+
fileName
;
if
(
FileUtils
.
upload
(
file
,
Path
,
fileName
))
{
if
(
FileUtils
.
upload
(
file
,
Path
,
fileName
))
{
//文件存放的相对路径(一般存放在数据库用于img标签的src)
//文件存放的相对路径(一般存放在数据库用于img标签的src)
String
relativePath
=
"用于判断是否图片上传成功,返回值有:"
+
fileName
;
String
relativePath
=
"用于判断是否图片上传成功,返回值有:"
+
fileName
;
result
.
put
(
"relativePath"
,
relativePath
);
//前端根据是否存在该字段来判断上传是否成功
result
.
put
(
"relativePath"
,
relativePath
);
//前端根据是否存在该字段来判断上传是否成功
msg
=
"图片上传成功"
;
msg
=
"图片上传成功"
;
result
.
put
(
"zxUrl"
,
zxUrl
);
result
.
put
(
"zxUrl"
,
zxUrl
);
FileOutputStream
fouts
=
null
;
Img
.
from
(
cn
.
hutool
.
core
.
io
.
FileUtil
.
file
(
xxurl
))
.
setQuality
(
0.8
)
//压缩比率
.
write
(
cn
.
hutool
.
core
.
io
.
FileUtil
.
file
(
xxurl
));
}
else
{
}
else
{
msg
=
"图片上传失败"
;
msg
=
"图片上传失败"
;
}
}
...
@@ -230,7 +247,7 @@ public class UploadServiceImpl implements UploadService {
...
@@ -230,7 +247,7 @@ public class UploadServiceImpl implements UploadService {
shopZxMapper
.
zxadd
(
zxUrl
,
zxField
,
inviteCode
,
zxDate
);
shopZxMapper
.
zxadd
(
zxUrl
,
zxField
,
inviteCode
,
zxDate
);
return
result
;
return
result
;
//用户只上传文字时
//用户只上传文字时
}
else
if
(
null
!=
zxField
&&
sa
==
0
)
{
}
else
if
(
null
!=
zxField
&&
sa
==
0
)
{
/**
/**
* 生成当前时间戳
* 生成当前时间戳
*/
*/
...
@@ -251,7 +268,7 @@ public class UploadServiceImpl implements UploadService {
...
@@ -251,7 +268,7 @@ public class UploadServiceImpl implements UploadService {
}
}
/**
/**
*
多文件上传 TODO
*
TODO 多文件上传
*/
*/
private
Path
fileStorageLocation
;
// 文件在本地存储的地址
private
Path
fileStorageLocation
;
// 文件在本地存储的地址
...
@@ -356,7 +373,7 @@ public class UploadServiceImpl implements UploadService {
...
@@ -356,7 +373,7 @@ public class UploadServiceImpl implements UploadService {
@Override
@Override
public
List
<
zxUserVo
>
selectAll
(
Integer
pageNum
,
Integer
pageSize
)
{
public
List
<
zxUserVo
>
selectAll
(
Integer
pageNum
,
Integer
pageSize
)
{
return
shopZxMapper
.
selectAll
(
pageNum
,
pageSize
);
return
shopZxMapper
.
selectAll
(
pageNum
,
pageSize
);
}
}
/**
/**
...
...
wisenergy-web-admin/pom.xml
View file @
a4c5661e
...
@@ -58,6 +58,12 @@
...
@@ -58,6 +58,12 @@
<artifactId>
lombok
</artifactId>
<artifactId>
lombok
</artifactId>
<scope>
provided
</scope>
<scope>
provided
</scope>
</dependency>
</dependency>
<!--图片压缩处理-->
<dependency>
<groupId>
net.coobird
</groupId>
<artifactId>
thumbnailator
</artifactId>
<version>
0.4.8
</version>
</dependency>
</dependencies>
</dependencies>
<!-- MAVEN构建 -->
<!-- MAVEN构建 -->
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment