Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
T
test
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
邬友楠
test
Commits
3b97cf3f
Commit
3b97cf3f
authored
Aug 21, 2019
by
雍欢
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CommonController - 添加文件输出拦截器
parent
7d579520
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
81 additions
and
23 deletions
+81
-23
pom.xml
huigou-common/pom.xml
+1
-1
pom.xml
huigou-core-api/pom.xml
+1
-1
pom.xml
huigou-core-impl/pom.xml
+1
-1
pom.xml
huigou-core-proxy/pom.xml
+1
-1
pom.xml
huigou-data/pom.xml
+1
-1
pom.xml
huigou-loader/pom.xml
+1
-1
pom.xml
huigou-system-common/pom.xml
+1
-1
pom.xml
huigou-uasp/pom.xml
+1
-1
CommonController.java
...rc/main/java/com/huigou/uasp/client/CommonController.java
+15
-12
OutputFileInterceptor.java
...in/java/com/huigou/uasp/client/OutputFileInterceptor.java
+27
-0
OutputFileInterceptorComposite.java
...om/huigou/uasp/client/OutputFileInterceptorComposite.java
+28
-0
pom.xml
huigou-xt/pom.xml
+1
-1
pom.xml
pom.xml
+2
-2
No files found.
huigou-common/pom.xml
View file @
3b97cf3f
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
<parent>
<parent>
<groupId>
com.huigou
</groupId>
<groupId>
com.huigou
</groupId>
<artifactId>
root
</artifactId>
<artifactId>
root
</artifactId>
<version>
1.1.
0
</version>
<version>
1.1.
1
</version>
</parent>
</parent>
<artifactId>
huigou-common
</artifactId>
<artifactId>
huigou-common
</artifactId>
<name>
huigou-common
</name>
<name>
huigou-common
</name>
...
...
huigou-core-api/pom.xml
View file @
3b97cf3f
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
<parent>
<parent>
<groupId>
com.huigou
</groupId>
<groupId>
com.huigou
</groupId>
<artifactId>
root
</artifactId>
<artifactId>
root
</artifactId>
<version>
1.1.
0
</version>
<version>
1.1.
1
</version>
</parent>
</parent>
<artifactId>
huigou-core-api
</artifactId>
<artifactId>
huigou-core-api
</artifactId>
<name>
huigou-core-api
</name>
<name>
huigou-core-api
</name>
...
...
huigou-core-impl/pom.xml
View file @
3b97cf3f
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
<parent>
<parent>
<groupId>
com.huigou
</groupId>
<groupId>
com.huigou
</groupId>
<artifactId>
root
</artifactId>
<artifactId>
root
</artifactId>
<version>
1.1.
0
</version>
<version>
1.1.
1
</version>
</parent>
</parent>
<artifactId>
huigou-core-impl
</artifactId>
<artifactId>
huigou-core-impl
</artifactId>
...
...
huigou-core-proxy/pom.xml
View file @
3b97cf3f
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
<parent>
<parent>
<groupId>
com.huigou
</groupId>
<groupId>
com.huigou
</groupId>
<artifactId>
root
</artifactId>
<artifactId>
root
</artifactId>
<version>
1.1.
0
</version>
<version>
1.1.
1
</version>
</parent>
</parent>
<artifactId>
huigou-core-proxy
</artifactId>
<artifactId>
huigou-core-proxy
</artifactId>
...
...
huigou-data/pom.xml
View file @
3b97cf3f
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
<parent>
<parent>
<groupId>
com.huigou
</groupId>
<groupId>
com.huigou
</groupId>
<artifactId>
root
</artifactId>
<artifactId>
root
</artifactId>
<version>
1.1.
0
</version>
<version>
1.1.
1
</version>
</parent>
</parent>
<artifactId>
huigou-data
</artifactId>
<artifactId>
huigou-data
</artifactId>
<name>
huigou-data
</name>
<name>
huigou-data
</name>
...
...
huigou-loader/pom.xml
View file @
3b97cf3f
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<groupId>
com.huigou
</groupId>
<groupId>
com.huigou
</groupId>
<artifactId>
root
</artifactId>
<artifactId>
root
</artifactId>
<version>
1.1.
0
</version>
<version>
1.1.
1
</version>
</parent>
</parent>
<artifactId>
huigou-loader
</artifactId>
<artifactId>
huigou-loader
</artifactId>
...
...
huigou-system-common/pom.xml
View file @
3b97cf3f
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<parent>
<parent>
<groupId>
com.huigou
</groupId>
<groupId>
com.huigou
</groupId>
<artifactId>
root
</artifactId>
<artifactId>
root
</artifactId>
<version>
1.1.
0
</version>
<version>
1.1.
1
</version>
</parent>
</parent>
<artifactId>
huigou-system-common
</artifactId>
<artifactId>
huigou-system-common
</artifactId>
...
...
huigou-uasp/pom.xml
View file @
3b97cf3f
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
<parent>
<parent>
<groupId>
com.huigou
</groupId>
<groupId>
com.huigou
</groupId>
<artifactId>
root
</artifactId>
<artifactId>
root
</artifactId>
<version>
1.1.
0
</version>
<version>
1.1.
1
</version>
</parent>
</parent>
<artifactId>
huigou-uasp
</artifactId>
<artifactId>
huigou-uasp
</artifactId>
...
...
huigou-uasp/src/main/java/com/huigou/uasp/client/CommonController.java
View file @
3b97cf3f
...
@@ -24,6 +24,7 @@ import org.apache.commons.fileupload.disk.DiskFileItemFactory;
...
@@ -24,6 +24,7 @@ import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import
org.apache.commons.fileupload.servlet.ServletFileUpload
;
import
org.apache.commons.fileupload.servlet.ServletFileUpload
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
com.huigou.cache.SystemCache
;
import
com.huigou.cache.SystemCache
;
...
@@ -76,6 +77,8 @@ public class CommonController extends ControllerBase {
...
@@ -76,6 +77,8 @@ public class CommonController extends ControllerBase {
protected
final
static
String
BIZ_CODE_KEY_NAME
=
"bizCode"
;
protected
final
static
String
BIZ_CODE_KEY_NAME
=
"bizCode"
;
protected
final
static
String
DATA_KEY_NAME
=
Constants
.
DATA
;
protected
final
static
String
DATA_KEY_NAME
=
Constants
.
DATA
;
@Autowired
(
required
=
false
)
private
OutputFileInterceptor
outputFileInterceptor
;
protected
enum
Status
{
protected
enum
Status
{
SUCCESS
,
SUCCESS_TIPS
,
ERROR
,
ERROR_DIALOG
;
SUCCESS
,
SUCCESS_TIPS
,
ERROR
,
ERROR_DIALOG
;
...
@@ -206,8 +209,7 @@ public class CommonController extends ControllerBase {
...
@@ -206,8 +209,7 @@ public class CommonController extends ControllerBase {
* 跳转到页面,无需配置struts的result
* 跳转到页面,无需配置struts的result
*
*
* @param page
* @param page
* @param obj
* @param obj Map SDO POJO
* Map SDO POJO
* @return String
* @return String
*/
*/
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
...
@@ -446,6 +448,7 @@ public class CommonController extends ControllerBase {
...
@@ -446,6 +448,7 @@ public class CommonController extends ControllerBase {
*
*
* @return String
* @return String
* @author
* @author
* @see OutputFileInterceptor
*/
*/
protected
String
outputFile
(
File
file
,
String
type
)
throws
Exception
{
protected
String
outputFile
(
File
file
,
String
type
)
throws
Exception
{
HttpServletResponse
res
=
this
.
getResponse
();
HttpServletResponse
res
=
this
.
getResponse
();
...
@@ -458,6 +461,9 @@ public class CommonController extends ControllerBase {
...
@@ -458,6 +461,9 @@ public class CommonController extends ControllerBase {
try
{
try
{
out
=
res
.
getOutputStream
();
out
=
res
.
getOutputStream
();
bis
=
new
BufferedInputStream
(
new
FileInputStream
(
file
));
bis
=
new
BufferedInputStream
(
new
FileInputStream
(
file
));
if
(
outputFileInterceptor
!=
null
)
{
bis
=
new
BufferedInputStream
(
outputFileInterceptor
.
intercept
(
bis
,
type
,
this
));
}
bos
=
new
BufferedOutputStream
(
out
);
bos
=
new
BufferedOutputStream
(
out
);
byte
[]
buff
=
new
byte
[
2048
];
byte
[]
buff
=
new
byte
[
2048
];
int
bytesRead
;
int
bytesRead
;
...
@@ -485,7 +491,7 @@ public class CommonController extends ControllerBase {
...
@@ -485,7 +491,7 @@ public class CommonController extends ControllerBase {
*/
*/
protected
String
outputPDF
(
String
template
,
Map
<
String
,
Object
>
variables
)
{
protected
String
outputPDF
(
String
template
,
Map
<
String
,
Object
>
variables
)
{
String
imgHttpUrl
=
this
.
getRequest
().
getScheme
()
+
"://"
+
this
.
getRequest
().
getServerName
()
+
":"
+
this
.
getRequest
().
getServerPort
()
String
imgHttpUrl
=
this
.
getRequest
().
getScheme
()
+
"://"
+
this
.
getRequest
().
getServerName
()
+
":"
+
this
.
getRequest
().
getServerPort
()
+
SystemCache
.
getContextPath
();
+
SystemCache
.
getContextPath
();
variables
.
put
(
"imgHttpUrl"
,
imgHttpUrl
);
variables
.
put
(
"imgHttpUrl"
,
imgHttpUrl
);
String
path
=
PDFCreater
.
createByFreemarker
(
template
,
variables
);
String
path
=
PDFCreater
.
createByFreemarker
(
template
,
variables
);
File
file
=
new
File
(
FileHelper
.
getTmpdir
(),
path
);
File
file
=
new
File
(
FileHelper
.
getTmpdir
(),
path
);
...
@@ -503,18 +509,15 @@ public class CommonController extends ControllerBase {
...
@@ -503,18 +509,15 @@ public class CommonController extends ControllerBase {
/**
/**
* Freemarker模板生成PDF显示在网页上(包含审批流程)
* Freemarker模板生成PDF显示在网页上(包含审批流程)
*
*
* @param template
* @param template Freemarker 模板
* Freemarker 模板
* @param bizId 业务单据ID
* @param bizId
* @param variables 参数
* 业务单据ID
* @param variables
* 参数
* @return
* @return
*/
*/
public
String
outputAndProcUnitHandlerPDF
(
String
template
,
String
bizId
,
Map
<
String
,
Object
>
variables
)
{
public
String
outputAndProcUnitHandlerPDF
(
String
template
,
String
bizId
,
Map
<
String
,
Object
>
variables
)
{
ProcUnitHandlerApplication
application
=
SpringBeanFactory
.
getBean
(
this
.
getServletContext
(),
"procUnitHandlerApplication"
,
ProcUnitHandlerApplication
application
=
SpringBeanFactory
.
getBean
(
this
.
getServletContext
(),
"procUnitHandlerApplication"
,
ProcUnitHandlerApplication
.
class
);
ProcUnitHandlerApplication
.
class
);
if
(
application
!=
null
&&
bizId
!=
null
)
{
if
(
application
!=
null
&&
bizId
!=
null
)
{
List
<
Map
<
String
,
Object
>>
group
=
application
.
groupProcUnitHandlers
(
bizId
,
"Approve"
,
""
,
""
,
"-1"
);
List
<
Map
<
String
,
Object
>>
group
=
application
.
groupProcUnitHandlers
(
bizId
,
"Approve"
,
""
,
""
,
"-1"
);
Map
<
String
,
Object
>
a
=
new
HashMap
<
String
,
Object
>(
2
);
Map
<
String
,
Object
>
a
=
new
HashMap
<
String
,
Object
>(
2
);
...
@@ -535,7 +538,7 @@ public class CommonController extends ControllerBase {
...
@@ -535,7 +538,7 @@ public class CommonController extends ControllerBase {
*/
*/
protected
String
outputWord
(
String
template
,
Map
<
String
,
Object
>
variables
)
{
protected
String
outputWord
(
String
template
,
Map
<
String
,
Object
>
variables
)
{
String
imgHttpUrl
=
this
.
getRequest
().
getScheme
()
+
"://"
+
this
.
getRequest
().
getServerName
()
+
":"
+
this
.
getRequest
().
getServerPort
()
String
imgHttpUrl
=
this
.
getRequest
().
getScheme
()
+
"://"
+
this
.
getRequest
().
getServerName
()
+
":"
+
this
.
getRequest
().
getServerPort
()
+
SystemCache
.
getContextPath
();
+
SystemCache
.
getContextPath
();
variables
.
put
(
"imgHttpUrl"
,
imgHttpUrl
);
variables
.
put
(
"imgHttpUrl"
,
imgHttpUrl
);
String
path
=
PDFCreater
.
createWord
(
template
,
variables
);
String
path
=
PDFCreater
.
createWord
(
template
,
variables
);
File
file
=
new
File
(
FileHelper
.
getTmpdir
(),
path
);
File
file
=
new
File
(
FileHelper
.
getTmpdir
(),
path
);
...
...
huigou-uasp/src/main/java/com/huigou/uasp/client/OutputFileInterceptor.java
0 → 100644
View file @
3b97cf3f
package
com
.
huigou
.
uasp
.
client
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStream
;
/**
* 文件输出拦截器。
*
* @author yonghuan
* @see CommonController#outputFile(File, String)
* @since 1.1.1
*/
public
interface
OutputFileInterceptor
{
/**
* 对文件输出进行拦截处理。
*
* @param is 文件内容
* @param type 文件类型
* @param target 被拦截的对象
* @return 拦截处理结果
* @throws IOException
*/
InputStream
intercept
(
InputStream
is
,
String
type
,
Object
target
)
throws
IOException
;
}
huigou-uasp/src/main/java/com/huigou/uasp/client/OutputFileInterceptorComposite.java
0 → 100644
View file @
3b97cf3f
package
com
.
huigou
.
uasp
.
client
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.Collections
;
import
java.util.List
;
/**
* @author yonghuan
* @since 1.1.1
*/
public
class
OutputFileInterceptorComposite
implements
OutputFileInterceptor
{
private
List
<
OutputFileInterceptor
>
delegationInterceptors
;
public
OutputFileInterceptorComposite
(
List
<
OutputFileInterceptor
>
delegationInterceptors
)
{
this
.
delegationInterceptors
=
Collections
.
unmodifiableList
(
delegationInterceptors
);
}
@Override
public
InputStream
intercept
(
InputStream
is
,
String
type
,
Object
target
)
throws
IOException
{
for
(
OutputFileInterceptor
interceptor
:
delegationInterceptors
)
{
is
=
interceptor
.
intercept
(
is
,
type
,
target
);
}
return
is
;
}
}
huigou-xt/pom.xml
View file @
3b97cf3f
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
<parent>
<parent>
<groupId>
com.huigou
</groupId>
<groupId>
com.huigou
</groupId>
<artifactId>
root
</artifactId>
<artifactId>
root
</artifactId>
<version>
1.1.
0
</version>
<version>
1.1.
1
</version>
</parent>
</parent>
<artifactId>
huigou-xt
</artifactId>
<artifactId>
huigou-xt
</artifactId>
<name>
统一应用支撑平台
</name>
<name>
统一应用支撑平台
</name>
...
...
pom.xml
View file @
3b97cf3f
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
<groupId>
com.huigou
</groupId>
<groupId>
com.huigou
</groupId>
<artifactId>
root
</artifactId>
<artifactId>
root
</artifactId>
<version>
1.1.
0
</version>
<version>
1.1.
1
</version>
<packaging>
pom
</packaging>
<packaging>
pom
</packaging>
...
@@ -159,7 +159,7 @@
...
@@ -159,7 +159,7 @@
<!-- test -->
<!-- test -->
<junit.version>
4.9
</junit.version>
<junit.version>
4.9
</junit.version>
<spring-data-mongodb.version>
1.9.3.RELEASE
</spring-data-mongodb.version>
<spring-data-mongodb.version>
1.9.3.RELEASE
</spring-data-mongodb.version>
<huigou.uasp.version>
1.1.
0
</huigou.uasp.version>
<huigou.uasp.version>
1.1.
1
</huigou.uasp.version>
</properties>
</properties>
<dependencyManagement>
<dependencyManagement>
...
...
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