Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
education
Project
Project
Details
Activity
Releases
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
李丛阳
education
Commits
59ec6e0a
Commit
59ec6e0a
authored
Jan 10, 2020
by
luzhuang
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/meiteng' into meiteng
parents
04e3834e
88671c48
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
10 deletions
+9
-10
BChapterServiceImpl.java
...t/business/bchapter/service/impl/BChapterServiceImpl.java
+4
-6
ZipMultiFile.java
src/main/java/org/rcisoft/core/util/ZipMultiFile.java
+5
-4
No files found.
src/main/java/org/rcisoft/business/bchapter/service/impl/BChapterServiceImpl.java
View file @
59ec6e0a
...
@@ -675,7 +675,6 @@ public class BChapterServiceImpl implements BChapterService {
...
@@ -675,7 +675,6 @@ public class BChapterServiceImpl implements BChapterService {
public
String
getBatchDownload
(
String
bFileJson
)
{
public
String
getBatchDownload
(
String
bFileJson
)
{
//批量打包下载
//批量打包下载
List
<
BFile
>
fileList
=
JSONObject
.
parseArray
(
bFileJson
,
BFile
.
class
);
List
<
BFile
>
fileList
=
JSONObject
.
parseArray
(
bFileJson
,
BFile
.
class
);
List
<
File
>
bFiles
=
new
ArrayList
<>();
if
(
fileList
==
null
||
fileList
.
size
()
<
1
){
if
(
fileList
==
null
||
fileList
.
size
()
<
1
){
throw
new
ServiceException
(
ResultServiceEnums
.
NOT_DOWNLOAD_FILE
);
throw
new
ServiceException
(
ResultServiceEnums
.
NOT_DOWNLOAD_FILE
);
}
}
...
@@ -686,17 +685,16 @@ public class BChapterServiceImpl implements BChapterService {
...
@@ -686,17 +685,16 @@ public class BChapterServiceImpl implements BChapterService {
}
}
String
name
=
bFile
.
getVideoUrl
().
substring
(
bFile
.
getVideoUrl
().
lastIndexOf
(
"/"
)
+
1
);
String
name
=
bFile
.
getVideoUrl
().
substring
(
bFile
.
getVideoUrl
().
lastIndexOf
(
"/"
)
+
1
);
String
filePath
=
global
.
getBASE_UPLOAD_SERVER_LOCATION
()
+
global
.
getCOURSE_LOCATION
()
+
File
.
separator
+
bFile
.
getLessonId
();
String
filePath
=
global
.
getBASE_UPLOAD_SERVER_LOCATION
()
+
global
.
getCOURSE_LOCATION
()
+
File
.
separator
+
bFile
.
getLessonId
();
String
returnBasePath
=
global
.
getRETURN_UPLOAD_SERVER_LOCATION
()
+
global
.
getCOURSE_LOCATION
()
+
File
.
separator
+
bFile
.
getLessonId
();
File
file
=
new
File
(
filePath
);
File
file
=
new
File
(
filePath
);
File
fileOld
=
new
File
(
filePath
+
File
.
separator
+
name
);
File
fileOld
=
new
File
(
filePath
+
File
.
separator
+
name
);
if
(
fileOld
.
exists
())
{
if
(
fileOld
.
exists
())
{
bFile
s
.
add
(
new
File
(
returnBasePath
+
File
.
separator
+
name
)
);
bFile
.
setFileUrl
(
filePath
+
File
.
separator
+
name
);
}
else
{
}
else
{
String
downLoadName
=
downLoadFile
(
bFile
,
file
,
filePath
);
String
downLoadName
=
downLoadFile
(
bFile
,
file
,
filePath
);
bFile
s
.
add
(
new
File
(
returnBasePath
+
File
.
separator
+
downLoadName
)
);
bFile
.
setFileUrl
(
filePath
+
File
.
separator
+
downLoadName
);
}
}
});
});
if
(
bFiles
.
size
()
<
1
){
if
(
fileList
.
size
()
<
1
){
throw
new
ServiceException
(
ResultServiceEnums
.
NOT_DOWNLOAD_FILE
);
throw
new
ServiceException
(
ResultServiceEnums
.
NOT_DOWNLOAD_FILE
);
}
}
String
uuid
=
IdGen
.
uuid
();
String
uuid
=
IdGen
.
uuid
();
...
@@ -705,7 +703,7 @@ public class BChapterServiceImpl implements BChapterService {
...
@@ -705,7 +703,7 @@ public class BChapterServiceImpl implements BChapterService {
//返回地址
//返回地址
String
returnAddress
=
global
.
getRETURN_UPLOAD_SERVER_LOCATION
()
+
global
.
getCOURSE_LOCATION
()
+
File
.
separator
+
global
.
getZIP_LOCATION
()
+
File
.
separator
+
uuid
+
".zip"
;
String
returnAddress
=
global
.
getRETURN_UPLOAD_SERVER_LOCATION
()
+
global
.
getCOURSE_LOCATION
()
+
File
.
separator
+
global
.
getZIP_LOCATION
()
+
File
.
separator
+
uuid
+
".zip"
;
//打包
//打包
ZipMultiFile
.
zipFiles
(
bFiles
,
zipFile
);
ZipMultiFile
.
zipFiles
(
fileList
,
zipFile
);
return
returnAddress
;
return
returnAddress
;
}
}
...
...
src/main/java/org/rcisoft/core/util/ZipMultiFile.java
View file @
59ec6e0a
package
org
.
rcisoft
.
core
.
util
;
package
org
.
rcisoft
.
core
.
util
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.rcisoft.business.bfile.entity.BFile
;
import
java.io.*
;
import
java.io.*
;
import
java.util.Arrays
;
import
java.util.Arrays
;
...
@@ -21,10 +22,10 @@ public class ZipMultiFile {
...
@@ -21,10 +22,10 @@ public class ZipMultiFile {
File
zipFile
=
new
File
(
"C:\\Users\\三\\Desktop\\暂时\\deleteFile\\1234\\ZipFile.zip"
);
File
zipFile
=
new
File
(
"C:\\Users\\三\\Desktop\\暂时\\deleteFile\\1234\\ZipFile.zip"
);
// 调用压缩方法
// 调用压缩方法
zipFiles
(
Arrays
.
asList
(
srcFiles
),
zipFile
);
//
zipFiles(Arrays.asList(srcFiles), zipFile);
}
}
public
static
String
zipFiles
(
List
<
File
>
srcFiles
,
File
zipFile
)
{
public
static
String
zipFiles
(
List
<
B
File
>
srcFiles
,
File
zipFile
)
{
// 判断压缩后的文件存在不,不存在则创建
// 判断压缩后的文件存在不,不存在则创建
if
(!
zipFile
.
getParentFile
().
exists
()){
if
(!
zipFile
.
getParentFile
().
exists
()){
zipFile
.
getParentFile
().
mkdirs
();
zipFile
.
getParentFile
().
mkdirs
();
...
@@ -54,9 +55,9 @@ public class ZipMultiFile {
...
@@ -54,9 +55,9 @@ public class ZipMultiFile {
// 遍历源文件数组
// 遍历源文件数组
for
(
int
i
=
0
;
i
<
srcFiles
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
srcFiles
.
size
();
i
++)
{
// 将源文件数组中的当前文件读入 FileInputStream 流中
// 将源文件数组中的当前文件读入 FileInputStream 流中
fileInputStream
=
new
FileInputStream
(
srcFiles
.
get
(
i
));
fileInputStream
=
new
FileInputStream
(
new
File
(
srcFiles
.
get
(
i
).
getFileUrl
()
));
// 实例化 ZipEntry 对象,源文件数组中的当前文件
// 实例化 ZipEntry 对象,源文件数组中的当前文件
zipEntry
=
new
ZipEntry
(
srcFiles
.
get
(
i
).
get
Name
(
));
zipEntry
=
new
ZipEntry
(
srcFiles
.
get
(
i
).
get
FileName
()+
srcFiles
.
get
(
i
).
getFileUrl
().
substring
(
srcFiles
.
get
(
i
).
getFileUrl
().
lastIndexOf
(
"."
)
));
zipOutputStream
.
putNextEntry
(
zipEntry
);
zipOutputStream
.
putNextEntry
(
zipEntry
);
// 该变量记录每次真正读的字节个数
// 该变量记录每次真正读的字节个数
int
len
;
int
len
;
...
...
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