Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
platform
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
王琮
platform
Commits
0e17af31
Commit
0e17af31
authored
Nov 02, 2021
by
王琮
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
打包
parent
1aede14e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
16 deletions
+12
-16
FileCtrl.java
src/main/java/com/tiptimes/ctrl/FileCtrl.java
+4
-4
QuestionnaireCtrl.java
src/main/java/com/tiptimes/ctrl/QuestionnaireCtrl.java
+8
-7
FileUtil.java
src/main/java/com/tiptimes/util/FileUtil.java
+0
-5
No files found.
src/main/java/com/tiptimes/ctrl/FileCtrl.java
View file @
0e17af31
...
@@ -147,9 +147,9 @@ public class FileCtrl {
...
@@ -147,9 +147,9 @@ public class FileCtrl {
fileName
=
file
.
getFileName
();
fileName
=
file
.
getFileName
();
String
originPath
=
""
;
String
originPath
=
""
;
if
(
fileNum
.
startsWith
(
"http"
))
{
if
(
fileNum
.
startsWith
(
"http"
))
{
originPath
=
fileN
um
;
originPath
=
fileN
ame
;
}
else
{
}
else
{
originPath
=
this
.
getfileUrl
()
+
fileN
um
;
originPath
=
this
.
getfileUrl
()
+
fileN
ame
;
}
}
String
targetPath
=
myPath
+
fileName
;
String
targetPath
=
myPath
+
fileName
;
...
@@ -197,7 +197,7 @@ public class FileCtrl {
...
@@ -197,7 +197,7 @@ public class FileCtrl {
outputStream
.
write
(
data
);
outputStream
.
write
(
data
);
outputStream
.
flush
();
outputStream
.
flush
();
outputStream
.
close
();
outputStream
.
close
();
zipFileDownLoad
.
delete
();
//
zipFileDownLoad.delete();
}
else
{
}
else
{
System
.
out
.
println
(
"下载的文件不存在"
);
System
.
out
.
println
(
"下载的文件不存在"
);
}
}
...
@@ -220,7 +220,7 @@ public class FileCtrl {
...
@@ -220,7 +220,7 @@ public class FileCtrl {
map
.
put
(
"fileName"
,
myfile
.
getOriginalFilename
());
map
.
put
(
"fileName"
,
myfile
.
getOriginalFilename
());
map
.
put
(
"fileID"
,
uuid
);
map
.
put
(
"fileID"
,
uuid
);
byte
[]
buffer
=
myfile
.
getBytes
();
byte
[]
buffer
=
myfile
.
getBytes
();
FileOutputStream
fos
=
new
FileOutputStream
(
this
.
getfileUrl
()
+
fileNum
);
FileOutputStream
fos
=
new
FileOutputStream
(
this
.
getfileUrl
()
+
myfile
.
getOriginalFilename
()
);
fos
.
write
(
buffer
);
fos
.
write
(
buffer
);
fos
.
close
();
fos
.
close
();
File
file
=
new
File
();
File
file
=
new
File
();
...
...
src/main/java/com/tiptimes/ctrl/QuestionnaireCtrl.java
View file @
0e17af31
...
@@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -14,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
...
@@ -204,11 +205,11 @@ public class QuestionnaireCtrl {
...
@@ -204,11 +205,11 @@ public class QuestionnaireCtrl {
}
}
@RequestMapping
({
"downZipByFileId"
})
@RequestMapping
({
"downZipByFileId"
})
public
String
downZipByFileId
(
Long
id
,
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
IOException
{
public
String
downZipByFileId
(
@RequestParam
Long
optionId
,
HttpServletResponse
response
)
throws
IOException
{
String
forwardName
=
"/user/file"
;
String
forwardName
=
"/user/file"
;
//1.根据选项查询文件列表
//1.根据选项查询文件列表
String
forderName
=
UUIDUtils
.
getUUID
();
String
forderName
=
UUIDUtils
.
getUUID
();
String
tempPath
=
this
.
get
f
ileUrl
();
String
tempPath
=
this
.
get
F
ileUrl
();
String
zipName
=
"上传文件"
;
String
zipName
=
"上传文件"
;
String
fileName
;
String
fileName
;
String
myPath
=
tempPath
+
forderName
+
"/"
+
zipName
+
"/"
;
String
myPath
=
tempPath
+
forderName
+
"/"
+
zipName
+
"/"
;
...
@@ -216,7 +217,7 @@ public class QuestionnaireCtrl {
...
@@ -216,7 +217,7 @@ public class QuestionnaireCtrl {
if
(!
fileForExists
.
exists
())
{
if
(!
fileForExists
.
exists
())
{
FileUtil
.
mkdirFolders
(
myPath
);
FileUtil
.
mkdirFolders
(
myPath
);
}
}
List
<
String
>
fileID
=
this
.
fileServer
.
selectFileId
(
i
d
);
List
<
String
>
fileID
=
this
.
fileServer
.
selectFileId
(
optionI
d
);
for
(
int
i
=
0
;
i
<
fileID
.
size
();++
i
)
{
for
(
int
i
=
0
;
i
<
fileID
.
size
();++
i
)
{
File
file
=
this
.
fileServer
.
selectFileByFileID
(
fileID
.
get
(
i
));
File
file
=
this
.
fileServer
.
selectFileByFileID
(
fileID
.
get
(
i
));
try
{
try
{
...
@@ -225,9 +226,9 @@ public class QuestionnaireCtrl {
...
@@ -225,9 +226,9 @@ public class QuestionnaireCtrl {
fileName
=
file
.
getFileName
();
fileName
=
file
.
getFileName
();
String
originPath
=
""
;
String
originPath
=
""
;
if
(
fileNum
.
startsWith
(
"http"
))
{
if
(
fileNum
.
startsWith
(
"http"
))
{
originPath
=
fileN
um
;
originPath
=
fileN
ame
;
}
else
{
}
else
{
originPath
=
this
.
get
fileUrl
()
+
fileNum
;
originPath
=
this
.
get
FileUrl
()
+
fileName
;
}
}
String
targetPath
=
myPath
+
fileName
;
String
targetPath
=
myPath
+
fileName
;
StringBuffer
fileNameForRepeat
=
new
StringBuffer
();
StringBuffer
fileNameForRepeat
=
new
StringBuffer
();
...
@@ -270,7 +271,7 @@ public class QuestionnaireCtrl {
...
@@ -270,7 +271,7 @@ public class QuestionnaireCtrl {
outputStream
.
write
(
data
);
outputStream
.
write
(
data
);
outputStream
.
flush
();
outputStream
.
flush
();
outputStream
.
close
();
outputStream
.
close
();
zipFileDownLoad
.
delete
();
//
zipFileDownLoad.delete();
}
else
{
}
else
{
System
.
out
.
println
(
"下载的文件不存在"
);
System
.
out
.
println
(
"下载的文件不存在"
);
}
}
...
@@ -280,7 +281,7 @@ public class QuestionnaireCtrl {
...
@@ -280,7 +281,7 @@ public class QuestionnaireCtrl {
return
null
;
return
null
;
}
}
private
String
get
f
ileUrl
()
throws
IOException
{
private
String
get
F
ileUrl
()
throws
IOException
{
if
(
""
.
equals
(
fileUrl
))
{
if
(
""
.
equals
(
fileUrl
))
{
Properties
props
=
new
Properties
();
Properties
props
=
new
Properties
();
InputStream
inputStream
=
this
.
getClass
().
getClassLoader
().
getResourceAsStream
(
"file.properties"
);
InputStream
inputStream
=
this
.
getClass
().
getClassLoader
().
getResourceAsStream
(
"file.properties"
);
...
...
src/main/java/com/tiptimes/util/FileUtil.java
View file @
0e17af31
...
@@ -156,7 +156,6 @@ public class FileUtil {
...
@@ -156,7 +156,6 @@ public class FileUtil {
public
static
File
copyFileByPath
(
String
originPath
,
String
targetPath
,
String
targetPathForRepeat
)
throws
IOException
{
public
static
File
copyFileByPath
(
String
originPath
,
String
targetPath
,
String
targetPathForRepeat
)
throws
IOException
{
File
targetFile
=
new
File
(
targetPath
);
File
targetFile
=
new
File
(
targetPath
);
try
{
try
{
BufferedInputStream
input
=
null
;
BufferedInputStream
input
=
null
;
if
(
originPath
.
startsWith
(
"http"
))
{
if
(
originPath
.
startsWith
(
"http"
))
{
...
@@ -173,20 +172,16 @@ public class FileUtil {
...
@@ -173,20 +172,16 @@ public class FileUtil {
byte
[]
buffer
=
new
byte
[
1048576
];
byte
[]
buffer
=
new
byte
[
1048576
];
int
bytesum
=
0
;
int
bytesum
=
0
;
boolean
var8
=
false
;
int
byteread
;
int
byteread
;
while
((
byteread
=
input
.
read
(
buffer
))
!=
-
1
)
{
while
((
byteread
=
input
.
read
(
buffer
))
!=
-
1
)
{
bytesum
+=
byteread
;
bytesum
+=
byteread
;
fps
.
write
(
buffer
,
0
,
byteread
);
fps
.
write
(
buffer
,
0
,
byteread
);
fps
.
flush
();
fps
.
flush
();
}
}
fps
.
close
();
fps
.
close
();
input
.
close
();
input
.
close
();
}
catch
(
Exception
var9
)
{
}
catch
(
Exception
var9
)
{
}
}
return
targetFile
;
return
targetFile
;
}
}
}
}
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