Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
D
data-server
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
data-server
Commits
93ce28f5
Commit
93ce28f5
authored
Mar 10, 2021
by
codezwjava
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
专属客服上传客服二维码图片
parent
2b954f4f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
8 deletions
+7
-8
CustomerServiceServiceImpl.java
...isenergy/service/app/impl/CustomerServiceServiceImpl.java
+7
-8
No files found.
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/CustomerServiceServiceImpl.java
View file @
93ce28f5
...
@@ -47,8 +47,8 @@ public class CustomerServiceServiceImpl implements CustomerServiceService {
...
@@ -47,8 +47,8 @@ public class CustomerServiceServiceImpl implements CustomerServiceService {
@Override
@Override
public
R
uploadImage
(
MultipartFile
file
,
HttpServletRequest
request
,
String
wechatId
)
throws
IOException
{
public
R
uploadImage
(
MultipartFile
file
,
HttpServletRequest
request
,
String
wechatId
)
throws
IOException
{
//
String basePath = request.getScheme() + "://" + request.getServerName()
String
basePath
=
request
.
getScheme
()
+
"://"
+
request
.
getServerName
()
// + ":" + request.getServerPort()+"/mimi/upload/images
/";
+
":"
+
request
.
getServerPort
()+
"/upload/video
/"
;
Long
time
=
System
.
currentTimeMillis
();
Long
time
=
System
.
currentTimeMillis
();
...
@@ -56,23 +56,22 @@ public class CustomerServiceServiceImpl implements CustomerServiceService {
...
@@ -56,23 +56,22 @@ public class CustomerServiceServiceImpl implements CustomerServiceService {
String
suffixName
=
originalFilename
.
substring
(
originalFilename
.
lastIndexOf
(
"."
));
//从最后一个.开始截取。截取zxName的后缀名
String
suffixName
=
originalFilename
.
substring
(
originalFilename
.
lastIndexOf
(
"."
));
//从最后一个.开始截取。截取zxName的后缀名
String
newName
=
time
+
suffixName
;
//文件新名称
String
newName
=
time
+
suffixName
;
//文件新名称
//设置文件存储路径,可以存放在你想要指定的路径里面
//设置文件存储路径,可以存放在你想要指定的路径里面
// String rootPath="G:/mimi/"+ File.separator+"upload/images
/"; //上传图片存放位置
String
rootPath
=
"/opt/upload/video
/"
;
//上传图片存放位置
String
filePath
=
uploadQRImagesLocation
+
newName
;
String
filePath
=
rootPath
+
newName
;
File
newFile
=
new
File
(
filePath
);
File
newFile
=
new
File
(
filePath
);
//判断目标文件所在目录是否存在
//判断目标文件所在目录是否存在
if
(!
newFile
.
getParentFile
().
exists
()){
if
(!
newFile
.
getParentFile
().
exists
()){
//如果目标文件所在的目录不存在,则创建父目录
//如果目标文件所在的目录不存在,则创建父目录
newFile
.
getParentFile
().
mkdirs
();
newFile
.
getParentFile
().
mkdirs
();
}
}
//将内存中的数据写入磁盘
//将内存中的数据写入磁盘
file
.
transferTo
(
newFile
);
file
.
transferTo
(
newFile
);
//
图片上传保存url
//
图片上传保存url
// String imgUrl = basePath + newzx
Name;
String
videoUrl
=
basePath
+
new
Name
;
CustomerService
customerService
=
new
CustomerService
();
CustomerService
customerService
=
new
CustomerService
();
customerService
.
setWechatId
(
wechatId
);
customerService
.
setWechatId
(
wechatId
);
customerService
.
setWechatImgUrl
(
filePath
);
customerService
.
setWechatImgUrl
(
videoUrl
);
customerServiceMapper
.
insert
(
customerService
);
customerServiceMapper
.
insert
(
customerService
);
return
R
.
ok
(
"上传成功"
);
return
R
.
ok
(
"上传成功"
);
}
}
...
...
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