Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
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
YZG
yzg-util
Commits
ef029db4
Commit
ef029db4
authored
Sep 10, 2019
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接口文档的支持
parent
edc89a28
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
62 additions
and
2 deletions
+62
-2
ExcelHttp.java
.../src/main/java/com/yanzuoguang/cloud/excel/ExcelHttp.java
+17
-2
ExportBase.java
...il-db/src/main/java/com/yanzuoguang/excel/ExportBase.java
+7
-0
ExportData.java
...il-db/src/main/java/com/yanzuoguang/excel/ExportData.java
+38
-0
No files found.
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/excel/ExcelHttp.java
View file @
ef029db4
...
...
@@ -55,6 +55,9 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> {
* @param downFileName 下载文件名
*/
public
ExcelHttp
down
(
HttpServletResponse
response
,
String
downFileName
)
throws
IOException
{
if
(
StringHelper
.
isEmpty
(
downFileName
))
{
downFileName
=
this
.
getConfig
().
getDownFileName
();
}
if
(
StringHelper
.
isEmpty
(
downFileName
))
{
downFileName
=
this
.
getConfig
().
getFileName
();
}
...
...
@@ -70,12 +73,24 @@ public class ExcelHttp<T extends Object> extends ExcelConsole<T> {
* @param excelDao dao层实现接口
*/
public
static
<
T
extends
Object
,
M
extends
Object
>
void
export
(
ExportBase
<
T
>
req
,
HttpServletResponse
response
,
ExcelDao
<
T
,
M
>
excelDao
)
{
ExcelHttp
<
M
>
excel
=
new
ExcelHttp
<>(
req
.
getConfig
());
ExportData
config
=
req
.
getConfig
();
if
(
config
==
null
)
{
throw
new
CodeException
(
"导出时请传入配置信息"
);
}
if
(
StringHelper
.
isEmpty
(
config
.
getServerPath
()))
{
config
.
setServerPath
(
"/home/cache/"
);
}
if
(
StringHelper
.
isEmpty
(
config
.
getFileName
()))
{
config
.
setFileName
(
String
.
format
(
"%s.xlsx"
,
StringHelper
.
getNewID
()));
}
if
(
StringHelper
.
isEmpty
(
config
.
getDownFileName
()))
{
config
.
setDownFileName
(
String
.
format
(
"%s-%s.xlsx"
,
config
.
getTitle
(),
config
.
getSubTitle
()));
}
ExcelHttp
<
M
>
excel
=
new
ExcelHttp
<>(
config
);
try
{
excel
.
open
();
excelDao
.
export
(
excel
,
req
.
getCond
());
excel
.
save
();
excel
.
down
(
response
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
...
...
yzg-util-db/src/main/java/com/yanzuoguang/excel/ExportBase.java
View file @
ef029db4
package
com
.
yanzuoguang
.
excel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
/**
* 导出数据
*
* @param <T>
* @author 颜佐光
*/
@ApiModel
(
description
=
"订单导出基本请求信息"
)
public
class
ExportBase
<
T
extends
Object
>
{
/**
* 导出格式
*/
@ApiModelProperty
(
notes
=
"导出格式配置信息"
,
required
=
true
)
private
ExportData
config
;
/**
* 查询条件
*/
@ApiModelProperty
(
notes
=
"查询条件"
,
required
=
true
)
private
T
cond
;
public
ExportData
getConfig
()
{
...
...
yzg-util-db/src/main/java/com/yanzuoguang/excel/ExportData.java
View file @
ef029db4
package
com
.
yanzuoguang
.
excel
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -8,58 +11,85 @@ import java.util.List;
*
* @author 颜佐光
*/
@ApiModel
(
description
=
"订单导出数据配置信息"
)
public
class
ExportData
{
@ApiModelProperty
(
notes
=
"行默认高度"
)
public
static
final
short
ROW_HEIGHT_UNIT
=
10
;
@ApiModelProperty
(
notes
=
"标题默认高度"
)
public
static
final
short
TITLE_HEIGHT
=
80
;
@ApiModelProperty
(
notes
=
"子标题默认高度"
)
public
static
final
short
SUB_TITLE_HEIGHT
=
40
;
@ApiModelProperty
(
notes
=
"头默认高度"
)
public
static
final
short
HEAD_HEIGHT
=
20
;
@ApiModelProperty
(
notes
=
"行默认高度"
)
public
static
final
short
ROW_HEIGHT
=
20
;
@ApiModelProperty
(
notes
=
"列默认宽度"
)
public
static
final
short
COLUMN_WIDTH
=
120
;
/**
* 服务器保存路径
*/
@ApiModelProperty
(
notes
=
"服务器保存路径"
)
private
String
serverPath
;
/**
* 文件名
*/
@ApiModelProperty
(
notes
=
"文件名"
)
private
String
fileName
;
/**
* 下载文件名
*/
@ApiModelProperty
(
notes
=
"下载文件名"
)
private
String
downFileName
;
/**
* 标题
*/
@ApiModelProperty
(
notes
=
"标题"
)
private
String
title
;
/**
* 标题高度
*/
@ApiModelProperty
(
notes
=
"标题高度"
)
private
short
titleHeight
;
/**
* 子标题
*/
@ApiModelProperty
(
notes
=
"子标题"
)
private
String
subTitle
;
/**
* 子标题高度
*/
@ApiModelProperty
(
notes
=
"子标题高度"
)
private
short
subTitleHeight
;
/**
* 列标题高度
*/
@ApiModelProperty
(
notes
=
"列标题高度"
)
private
short
headHeight
;
/**
* 行高度
*/
@ApiModelProperty
(
notes
=
"行高度"
)
private
short
rowHeight
;
/**
* 包含列
*/
@ApiModelProperty
(
notes
=
"包含列"
)
private
List
<
ExportColumn
>
columns
=
new
ArrayList
<>();
public
String
getServerPath
()
{
...
...
@@ -78,6 +108,14 @@ public class ExportData {
this
.
fileName
=
fileName
;
}
public
String
getDownFileName
()
{
return
downFileName
;
}
public
void
setDownFileName
(
String
downFileName
)
{
this
.
downFileName
=
downFileName
;
}
public
String
getTitle
()
{
return
title
;
}
...
...
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