Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yifu-mvp
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
fangxinjiang
yifu-mvp
Commits
165b3da1
Commit
165b3da1
authored
Jul 15, 2022
by
fangxinjiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码生成器调整
parent
5a718ac9
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
357 additions
and
1 deletion
+357
-1
EmpBadRecordSearchVo.java
.../cloud/plus/v1/yifu/archives/vo/EmpBadRecordSearchVo.java
+3
-0
TEmpBadRecordServiceImpl.java
.../yifu/archives/service/impl/TEmpBadRecordServiceImpl.java
+0
-1
CodeGenKits.java
.../yifu.cloud.plus.v1/yifu/codegen/support/CodeGenKits.java
+14
-0
Controller.java.vm
...fu-codegen/src/main/resources/template/Controller.java.vm
+26
-0
EntitySearchVo.java.vm
...odegen/src/main/resources/template/EntitySearchVo.java.vm
+56
-0
EntityVo.java.vm
...yifu-codegen/src/main/resources/template/EntityVo.java.vm
+67
-0
Service.java.vm
.../yifu-codegen/src/main/resources/template/Service.java.vm
+6
-0
ServiceImpl.java.vm
...u-codegen/src/main/resources/template/ServiceImpl.java.vm
+185
-0
No files found.
yifu-archives/yifu-archives-api/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/vo/EmpBadRecordSearchVo.java
View file @
165b3da1
...
...
@@ -14,6 +14,9 @@ import java.time.LocalDateTime;
*/
@Data
public
class
EmpBadRecordSearchVo
extends
TEmpBadRecord
{
/**
* 多选导出或删除等操作
*/
private
String
ids
;
/**
...
...
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/impl/TEmpBadRecordServiceImpl.java
View file @
165b3da1
...
...
@@ -53,7 +53,6 @@ import javax.servlet.http.HttpServletResponse;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.URLEncoder
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
yifu-visual/yifu-codegen/src/main/java/com/yifu.cloud.plus.v1/yifu/codegen/support/CodeGenKits.java
View file @
165b3da1
...
...
@@ -65,6 +65,10 @@ public class CodeGenKits {
private
final
String
ENTITY_JAVA_VM
=
"Entity.java.vm"
;
private
final
String
ENTITY_VO_JAVA_VM
=
"EntityVo.java.vm"
;
private
final
String
ENTITY_SEARCH_VO_JAVA_VM
=
"EntitySearchVo.java.vm"
;
private
final
String
MAPPER_JAVA_VM
=
"Mapper.java.vm"
;
private
final
String
SERVICE_JAVA_VM
=
"Service.java.vm"
;
...
...
@@ -94,6 +98,8 @@ public class CodeGenKits {
*/
private
List
<
String
>
getTemplates
(
GenConfig
config
)
{
List
<
String
>
templates
=
new
ArrayList
<>();
templates
.
add
(
"template/EntityVo.java.vm"
);
templates
.
add
(
"template/EntitySearchVo.java.vm"
);
templates
.
add
(
"template/Entity.java.vm"
);
templates
.
add
(
"template/Mapper.java.vm"
);
templates
.
add
(
"template/Mapper.xml.vm"
);
...
...
@@ -358,6 +364,14 @@ public class CodeGenKits {
return
packagePath
+
"entity"
+
File
.
separator
+
className
+
".java"
;
}
if
(
template
.
contains
(
ENTITY_VO_JAVA_VM
))
{
return
packagePath
+
"entity"
+
File
.
separator
+
className
+
"Vo.java"
;
}
if
(
template
.
contains
(
ENTITY_SEARCH_VO_JAVA_VM
))
{
return
packagePath
+
"entity"
+
File
.
separator
+
className
+
"SearchVo.java"
;
}
if
(
template
.
contains
(
MAPPER_JAVA_VM
))
{
return
packagePath
+
"mapper"
+
File
.
separator
+
className
+
"Mapper.java"
;
}
...
...
yifu-visual/yifu-codegen/src/main/resources/template/Controller.java.vm
View file @
165b3da1
...
...
@@ -134,4 +134,30 @@ public class ${className}Controller {
return
R
.
ok
(${
classname
}
Service
.
removeById
(${
pk
.
lowerAttrName
}));
}
/**
*
${
comments
}
批量导入
*
*
@
author
${
author
}
*
@
date
${
datetime
}
**/
@
SneakyThrows
@
Operation
(
description
=
"批量新增${comments} hasPermission('${moduleName}_${pathName}-batch-import')"
)
@
SysLog
(
"批量新增${comments}"
)
@
PostMapping
(
"/importListAdd"
)
@
PreAuthorize
(
"@pms.hasPermission('${moduleName}_${pathName}-batch-import')"
)
public
R
<
List
<
ErrorMessage
>>
importListAdd
(@
RequestBody
MultipartFile
file
){
return
${
classname
}
Service
.
importDiy
(
file
.
getInputStream
());
}
/**
*
${
comments
}
批量导出
*
@
author
${
author
}
*
@
date
${
datetime
}
**/
@
Operation
(
description
=
"导出${comments} hasPermission('${moduleName}_${pathName}-export')"
)
@
PostMapping
(
"/export"
)
@
PreAuthorize
(
"@pms.hasPermission('${moduleName}_${pathName}-export')"
)
public
void
export
(
HttpServletResponse
response
,
@
RequestBody
${
className
}
SearchVo
searchVo
)
{
${
classname
}
Service
.
listExport
(
response
,
searchVo
);
}
}
yifu-visual/yifu-codegen/src/main/resources/template/EntitySearchVo.java.vm
0 → 100644
View file @
165b3da1
/*
*
Copyright
(
c
)
2018
-
2025
,
lengleng
All
rights
reserved
.
*
*
Redistribution
and
use
in
source
and
binary
forms
,
with
or
without
*
modification
,
are
permitted
provided
that
the
following
conditions
are
met
:
*
*
Redistributions
of
source
code
must
retain
the
above
copyright
notice
,
*
this
list
of
conditions
and
the
following
disclaimer
.
*
Redistributions
in
binary
form
must
reproduce
the
above
copyright
*
notice
,
this
list
of
conditions
and
the
following
disclaimer
in
the
*
documentation
and
/
or
other
materials
provided
with
the
distribution
.
*
Neither
the
name
of
the
yifu4cloud
.
com
developer
nor
the
names
of
its
*
contributors
may
be
used
to
endorse
or
promote
products
derived
from
*
this
software
without
specific
prior
written
permission
.
*
Author
:
lengleng
(
wangiegie
@
gmail
.
com
)
*/
package
${
package
}.${
moduleName
}.
vo
;
import
io
.
swagger
.
v3
.
oas
.
annotations
.
media
.
Schema
;
import
lombok
.
Data
;
import
lombok
.
EqualsAndHashCode
;
/**
*
${
comments
}
*
*
@
author
${
author
}
*
@
date
${
datetime
}
*/
@
Data
public
class
${
className
}
SearchVo
extends
${
className
}{
/**
*
多选导出或删除等操作
*/
@
Schema
(
description
=
"选中ID,多个逗号分割"
)
private
String
ids
;
/**
*
创建时间区间
[
开始时间,结束时间
]
*/
@
Schema
(
description
=
"创建时间区间"
)
private
LocalDateTime
[]
createTimes
;
/**
*
@
Author
fxj
*
查询数据起
**/
@
Schema
(
description
=
"查询limit 开始"
)
private
int
limitStart
;
/**
*
@
Author
fxj
*
查询数据止
**/
@
Schema
(
description
=
"查询limit 数据条数"
)
private
int
limitEnd
;
}
yifu-visual/yifu-codegen/src/main/resources/template/EntityVo.java.vm
0 → 100644
View file @
165b3da1
/*
*
Copyright
(
c
)
2018
-
2025
,
lengleng
All
rights
reserved
.
*
*
Redistribution
and
use
in
source
and
binary
forms
,
with
or
without
*
modification
,
are
permitted
provided
that
the
following
conditions
are
met
:
*
*
Redistributions
of
source
code
must
retain
the
above
copyright
notice
,
*
this
list
of
conditions
and
the
following
disclaimer
.
*
Redistributions
in
binary
form
must
reproduce
the
above
copyright
*
notice
,
this
list
of
conditions
and
the
following
disclaimer
in
the
*
documentation
and
/
or
other
materials
provided
with
the
distribution
.
*
Neither
the
name
of
the
yifu4cloud
.
com
developer
nor
the
names
of
its
*
contributors
may
be
used
to
endorse
or
promote
products
derived
from
*
this
software
without
specific
prior
written
permission
.
*
Author
:
lengleng
(
wangiegie
@
gmail
.
com
)
*/
#
set
($
excludeColumns
=
[
"create_time"
,
"update_time"
,
"create_by"
,
"update_by"
])
package
${
package
}.${
moduleName
}.
vo
;
import
com
.
alibaba
.
excel
.
annotation
.
ExcelProperty
;
import
com
.
baomidou
.
mybatisplus
.
annotation
.
IdType
;
import
com
.
baomidou
.
mybatisplus
.
annotation
.
TableId
;
import
com
.
baomidou
.
mybatisplus
.
annotation
.
TableName
;
import
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
common
.
mybatis
.
base
.
BaseEntity
;
import
io
.
swagger
.
v3
.
oas
.
annotations
.
media
.
Schema
;
import
lombok
.
Data
;
import
lombok
.
EqualsAndHashCode
;
#
if
(${
hasBigDecimal
})
import
java
.
math
.
BigDecimal
;
#
end
/**
*
${
comments
}
*
*
@
author
${
author
}
*
@
date
${
datetime
}
*/
@
Data
public
class
${
className
}
Vo
extends
RowIndex
implements
Serializable
{
#
foreach
($
column
in
$
columns
)
##
排除部分字段
#
if
(
!$excludeColumns.contains($column.columnName))
/**
*
$
column
.
comments
*/
#
if
($
column
.
columnName
==
$
pk
.
columnName
)
@
TableId
(
type
=
IdType
.
ASSIGN_ID
)
#
end
#
end
#
if
($
column
.
nullable
)
@
NotBlank
(
message
=
"$column.comments 不能为空"
)
#
end
#
if
($
column
.
maxLength
&&
$
column
.
attrType
==
'String'
)
@
Length
(
max
=$
column
.
maxLength
,
message
=
"$column.comments 不能超过$column.maxLength 个字符"
)
#
end
@
ExcelAttribute
(
name
=
"$column.comments"
#
if
($
column
.
nullable
),
isNotEmpty
=
true
,
errorInfo
=
"$column.comments 不能为空"
#
end
#
if
($
column
.
attrType
==
'LocalDate'
||
$
column
.
attrType
==
'LocalDateTime'
)
,
isDate
=
true
#
end
#
if
($
column
.
maxLength
),
maxLength
=
$
column
.
maxLength
#
end
)
@
Schema
(
description
=
"$column.comments"
#
if
($
column
.
hidden
),
hidden
=$
column
.
hidden
#
end
)
@
ExcelProperty
(
"$column.comments"
)
#
if
($
column
.
attrType
==
'LocalDate'
||
$
column
.
attrType
==
'LocalDateTime'
||
$
column
.
attrType
==
'Date'
)
private
Date
$
column
.
lowerAttrName
;
#
else
private
$
column
.
attrType
$
column
.
lowerAttrName
;
#
end
#
end
}
yifu-visual/yifu-codegen/src/main/resources/template/Service.java.vm
View file @
165b3da1
...
...
@@ -33,4 +33,10 @@ public interface ${className}Service extends IService<${className}> {
*
@
return
*/
IPage
<${
className
}>
get
${
className
}
Page
(
Page
<${
className
}>
page
,
${
className
}
${
classname
});
R
<
List
<
ErrorMessage
>>
importDiy
(
InputStream
inputStream
);
void
listExport
(
HttpServletResponse
response
,
${
className
}
SearchVo
searchVo
);
List
<${
className
}>
noPageDiy
(${
className
}
SearchVo
searchVo
)
}
yifu-visual/yifu-codegen/src/main/resources/template/ServiceImpl.java.vm
View file @
165b3da1
...
...
@@ -39,4 +39,189 @@ public class ${className}ServiceImpl extends ServiceImpl<${className}Mapper, ${c
public
IPage
<${
className
}>
get
${
className
}
Page
(
Page
<${
className
}>
page
,
${
className
}
${
classname
}){
return
baseMapper
.
get
${
className
}
Page
(
page
,${
classname
});
}
/**
*
${
comments
}
批量导入
*/
@
Override
R
<
List
<
ErrorMessage
>>
importDiy
(
InputStream
inputStream
){
}
/**
*
${
comments
}
批量导出
*
@
param
${
classname
}
${
comments
}
*
@
return
*/
@
Override
void
listExport
(
HttpServletResponse
response
,
${
className
}
SearchVo
searchVo
){
String
fileName
=
"不良记录批量导出"
+
DateUtil
.
getThisTime
()
+
".xlsx"
;
//
获取要导出的列表
List
<${
className
}>
list
=
new
ArrayList
<>();
long
count
=
noPageCountDiy
(
searchVo
);
ServletOutputStream
out
=
null
;
try
{
out
=
response
.
getOutputStream
();
response
.
setContentType
(
"multipart/form-data"
);
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
+
URLEncoder
.
encode
(
fileName
,
"UTF-8"
));
//
这里
需要指定写用哪个
class
去写,然后写到第一个
sheet
,然后文件流会自动关闭
//
EasyExcel
.
write
(
out
,
TEmpBadRecord
.
class
).
sheet
(
"不良记录"
).
doWrite
(
list
);
ExcelWriter
excelWriter
=
EasyExcel
.
write
(
out
,
${
className
}.
class
).
build
();
int
index
=
0
;
if
(
count
>
CommonConstants
.
ZERO_INT
){
for
(
int
i
=
0
;
i
<=
count
;
)
{
//
获取实际记录
searchVo
.
setLimitStart
(
i
);
searchVo
.
setLimitEnd
(
CommonConstants
.
EXCEL_EXPORT_LIMIT
);
list
=
noPageDiy
(
searchVo
);
if
(
Common
.
isNotNull
(
list
)){
ExcelUtil
<${
className
}>
util
=
new
ExcelUtil
<>(${
className
}.
class
);
for
(${
className
}
vo
:
list
){
util
.
convertEntity
(
vo
,
null
,
null
,
null
);
}
}
if
(
Common
.
isNotNull
(
list
)){
WriteSheet
writeSheet
=
EasyExcel
.
writerSheet
(${
comments
}+
index
).
build
();
excelWriter
.
write
(
list
,
writeSheet
);
index
++;
}
i
=
i
+
CommonConstants
.
EXCEL_EXPORT_LIMIT
;
if
(
Common
.
isNotNull
(
list
)){
list
.
clear
();
}
}
}
else
{
WriteSheet
writeSheet
=
EasyExcel
.
writerSheet
(${
comments
}+
index
).
build
();
excelWriter
.
write
(
list
,
writeSheet
);
}
if
(
Common
.
isNotNull
(
list
)){
list
.
clear
();
}
out
.
flush
();
excelWriter
.
finish
();
}
catch
(
Exception
e
){
log
.
error
(
"执行异常"
,
e
);
}
finally
{
try
{
if
(
null
!= out) {
out
.
close
();
}
}
catch
(
IOException
e
)
{
log
.
error
(
"执行异常"
,
e
);
}
}
}
@
Override
public
List
<${
className
}>
noPageDiy
(${
className
}
SearchVo
searchVo
)
{
LambdaQueryWrapper
<${
className
}>
wrapper
=
buildQueryWrapper
(
searchVo
);
List
<
String
>
idList
=
Common
.
getList
(
searchVo
.
getIds
());
if
(
Common
.
isNotNull
(
idList
)){
wrapper
.
in
(
TEmpBadRecord
::
getId
,
idList
);
}
if
(
searchVo
.
getLimitStart
()
>=
0
&&
searchVo
.
getLimitEnd
()
>
0
){
wrapper
.
last
(
" limit "
+
searchVo
.
getLimitStart
()
+
","
+
searchVo
.
getLimitEnd
());
}
wrapper
.
orderByDesc
(
BaseEntity
::
getCreateTime
);
return
baseMapper
.
selectList
(
wrapper
);
}
private
Long
noPageCountDiy
(${
className
}
SearchVo
searchVo
)
{
LambdaQueryWrapper
<${
className
}>
wrapper
=
buildQueryWrapper
(
searchVo
);
List
<
String
>
idList
=
Common
.
getList
(
searchVo
.
getIds
());
if
(
Common
.
isNotNull
(
idList
)){
wrapper
.
in
(${
className
}::
getId
,
idList
);
}
return
baseMapper
.
selectCount
(
wrapper
);
}
private
LambdaQueryWrapper
buildQueryWrapper
(${
className
}
SearchVo
entity
){
LambdaQueryWrapper
<${
className
}>
wrapper
=
Wrappers
.
lambdaQuery
();
if
(
ArrayUtil
.
isNotEmpty
(
entity
.
getCreateTimes
()))
{
wrapper
.
ge
(${
className
}::
getCreateTime
,
entity
.
getCreateTimes
()[
0
])
.
le
(${
className
}::
getCreateTime
,
entity
.
getCreateTimes
()[
1
]);
}
if
(
Common
.
isNotNull
(
entity
.
getCreateName
())){
wrapper
.
eq
(${
className
}::
getCreateName
,
entity
.
getCreateName
());
}
return
wrapper
;
}
@
Override
public
R
<
List
<
ErrorMessage
>>
importDiy
(
InputStream
inputStream
)
{
List
<
ErrorMessage
>
errorMessageList
=
new
ArrayList
<>();
ExcelUtil
<${
className
}
Vo
>
util1
=
new
ExcelUtil
<>(${
className
}
Vo
.
class
);;
//
写法
2
:
//
匿名内部类
不用额外写一个
DemoDataListener
//
这里
需要指定读用哪个
class
去读,然后读取第一个
sheet
文件流会自动关闭
try
{
EasyExcel
.
read
(
inputStream
,
${
className
}
Vo
.
class
,
new
ReadListener
<${
className
}
Vo
>()
{
/**
*
单次缓存的数据量
*/
public
static
final
int
BATCH_COUNT
=
CommonConstants
.
BATCH_COUNT
;
/**
*
临时存储
*/
private
List
<${
className
}
Vo
>
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
@
Override
public
void
invoke
(${
className
}
Vo
data
,
AnalysisContext
context
)
{
ReadRowHolder
readRowHolder
=
context
.
readRowHolder
();
Integer
rowIndex
=
readRowHolder
.
getRowIndex
();
data
.
setRowIndex
(
rowIndex
+
1
);
ErrorMessage
errorMessage
=
util1
.
checkEntity
(
data
,
data
.
getRowIndex
());
if
(
Common
.
isNotNull
(
errorMessage
)){
errorMessageList
.
add
(
errorMessage
);
}
else
{
cachedDataList
.
add
(
data
);
}
if
(
cachedDataList
.
size
()
>=
BATCH_COUNT
)
{
saveData
();
//
存储完成清理
list
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
}
}
@
Override
public
void
doAfterAllAnalysed
(
AnalysisContext
context
)
{
saveData
();
}
/**
*
加上存储数据库
*/
private
void
saveData
()
{
log
.
info
(
"{}条数据,开始存储数据库!"
,
cachedDataList
.
size
());
import
${
className
}(
cachedDataList
,
errorMessageList
);
log
.
info
(
"存储数据库成功!"
);
}
}).
sheet
().
doRead
();
}
catch
(
Exception
e
){
log
.
error
(
CommonConstants
.
IMPORT_DATA_ANALYSIS_ERROR
,
e
);
return
R
.
failed
(
CommonConstants
.
IMPORT_DATA_ANALYSIS_ERROR
);
}
return
R
.
ok
(
errorMessageList
);
}
private
void
import
${
className
}(
List
<${
className
}
Vo
>
excelVOList
,
List
<
ErrorMessage
>
errorMessageList
)
{
//
个性化校验逻辑
ErrorMessage
errorMsg
;
//
执行数据插入操作
组装
for
(
int
i
=
0
;
i
<
excelVOList
.
size
();
i
++)
{
${
className
}
Vo
excel
=
excelVOList
.
get
(
i
);
//
数据合法情况
TODO
//
插入
insertExcel
(
excel
,
emp
);
errorMessageList
.
add
(
new
ErrorMessage
(
excel
.
getRowIndex
(),
CommonConstants
.
SAVE_SUCCESS
));
}
}
/**
*
插入
excel
bad
record
*/
private
void
insertExcel
(${
className
}
Vo
excel
)
{
${
className
}
insert
=
new
${
className
}();
BeanUtil
.
copyProperties
(
excel
,
insert
);
this
.
save
(
insert
);
}
}
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