Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Eladmin
Commits
2e3877aa
Commit
2e3877aa
authored
Oct 31, 2019
by
dqjdda
Browse files
代码生成器优化,前后端默认添加导出功能,input时间组件自动判定
parent
6befa377
Changes
7
Hide whitespace changes
Inline
Side-by-side
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/MenuServiceImpl.java
View file @
2e3877aa
...
@@ -25,7 +25,6 @@ import org.springframework.data.domain.Sort;
...
@@ -25,7 +25,6 @@ import org.springframework.data.domain.Sort;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Propagation
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.util.*
;
import
java.util.*
;
...
...
eladmin-system/src/main/resources/template/generator/admin/Controller.ftl
View file @
2e3877aa
...
@@ -11,6 +11,8 @@ import org.springframework.security.access.prepost.PreAuthorize;
...
@@ -11,6 +11,8 @@ import org.springframework.security.access.prepost.PreAuthorize;
import
org.springframework.validation.annotation.Validated;
import
org.springframework.validation.annotation.Validated;
import
org.springframework.web.bind.annotation.
*
;
import
org.springframework.web.bind.annotation.
*
;
import
io.swagger.annotations.
*
;
import
io.swagger.annotations.
*
;
import
java.io.IOException;
import
javax.servlet.http.HttpServletResponse;
/**
/**
*
@author $
{
author
}
*
@author $
{
author
}
...
@@ -27,10 +29,18 @@ public class ${className}Controller {
...
@@ -27,10 +29,18 @@ public class ${className}Controller {
this
.$
{
changeClassName
}
S
ervice
=
$
{
changeClassName
}
S
ervice
;
this
.$
{
changeClassName
}
S
ervice
=
$
{
changeClassName
}
S
ervice
;
}
}
@
L
og
(
"导出数据"
)
@
A
piOperation
(
"导出数据"
)
@
G
etMapping
(
value
=
"/download"
)
@
P
reAuthorize
(
"@el.check('${changeClassName}:list')"
)
public
void
download
(
H
ttpServletResponse
response
,
$
{
className
}
Q
ueryCriteria
criteria
)
throws
IOE
xception
{
$
{
changeClassName
}
S
ervice
.download
(
$
{
changeClassName
}
S
ervice
.queryAll
(
criteria
),
response
)
;
}
@
G
etMapping
@
G
etMapping
@
L
og
(
"查询${className}"
)
@
L
og
(
"查询${className}"
)
@
A
piOperation
(
"查询${className}"
)
@
A
piOperation
(
"查询${className}"
)
@
P
reAuthorize
(
"@el.check('${changeClassName}:list'"
)
@
P
reAuthorize
(
"@el.check('${changeClassName}:list'
)
"
)
public
R
esponseEntity
get
$
{
className
}
s
(
$
{
className
}
Q
ueryCriteria
criteria
,
P
ageable
pageable
){
public
R
esponseEntity
get
$
{
className
}
s
(
$
{
className
}
Q
ueryCriteria
criteria
,
P
ageable
pageable
){
return
new
R
esponseEntity
<>
(
$
{
changeClassName
}
S
ervice
.queryAll
(
criteria
,
pageable
),
H
ttpStatus
.OK
)
;
return
new
R
esponseEntity
<>
(
$
{
changeClassName
}
S
ervice
.queryAll
(
criteria
,
pageable
),
H
ttpStatus
.OK
)
;
}
}
...
...
eladmin-system/src/main/resources/template/generator/admin/Service.ftl
View file @
2e3877aa
...
@@ -6,6 +6,8 @@ import ${package}.service.dto.${className}QueryCriteria;
...
@@ -6,6 +6,8 @@ import ${package}.service.dto.${className}QueryCriteria;
import
org.springframework.data.domain.Pageable;
import
org.springframework.data.domain.Pageable;
import
java.util.Map;
import
java.util.Map;
import
java.util.List;
import
java.util.List;
import
java.io.IOException;
import
javax.servlet.http.HttpServletResponse;
/**
/**
*
@author $
{
author
}
*
@author $
{
author
}
...
@@ -40,4 +42,6 @@ public interface ${className}Service {
...
@@ -40,4 +42,6 @@ public interface ${className}Service {
void
update
(
$
{
className
}
resources
)
;
void
update
(
$
{
className
}
resources
)
;
void
delete
(
$
{
pkColumnType
}
$
{
pkChangeColName
})
;
void
delete
(
$
{
pkColumnType
}
$
{
pkChangeColName
})
;
void
download
(
L
ist
<$
{
className
}
DTO
>
all
,
H
ttpServletResponse
response
)
throws
IOE
xception
;
}
}
\ No newline at end of file
eladmin-system/src/main/resources/template/generator/admin/ServiceImpl.ftl
View file @
2e3877aa
...
@@ -11,6 +11,7 @@ import me.zhengjie.exception.EntityExistException;
...
@@ -11,6 +11,7 @@ import me.zhengjie.exception.EntityExistException;
</#list>
</#list>
</#
if
>
</#
if
>
import
me.zhengjie.utils.ValidationUtil;
import
me.zhengjie.utils.ValidationUtil;
import
me.zhengjie.utils.FileUtil;
import
$
{
package
}
.repository.$
{
className
}
Repository;
import
$
{
package
}
.repository.$
{
className
}
Repository;
import
$
{
package
}
.service.$
{
className
}
Service;
import
$
{
package
}
.service.$
{
className
}
Service;
import
$
{
package
}
.service.dto.$
{
className
}
DTO;
import
$
{
package
}
.service.dto.$
{
className
}
DTO;
...
@@ -35,6 +36,10 @@ import me.zhengjie.utils.PageUtil;
...
@@ -35,6 +36,10 @@ import me.zhengjie.utils.PageUtil;
import
me.zhengjie.utils.QueryHelp;
import
me.zhengjie.utils.QueryHelp;
import
java.util.List;
import
java.util.List;
import
java.util.Map;
import
java.util.Map;
import
java.io.IOException;
import
javax.servlet.http.HttpServletResponse;
import
java.util.ArrayList;
import
java.util.LinkedHashMap;
/**
/**
*
@author $
{
author
}
*
@author $
{
author
}
...
@@ -127,4 +132,24 @@ public class ${className}ServiceImpl implements ${className}Service {
...
@@ -127,4 +132,24 @@ public class ${className}ServiceImpl implements ${className}Service {
public
void
delete
(
$
{
pkColumnType
}
$
{
pkChangeColName
})
{
public
void
delete
(
$
{
pkColumnType
}
$
{
pkChangeColName
})
{
$
{
changeClassName
}
R
epository
.deleteById
(
$
{
pkChangeColName
})
;
$
{
changeClassName
}
R
epository
.deleteById
(
$
{
pkChangeColName
})
;
}
}
@
O
verride
public
void
download
(
L
ist
<$
{
className
}
DTO
>
all
,
H
ttpServletResponse
response
)
throws
IOE
xception
{
L
ist
<
M
ap
<
S
tring
,
O
bject
>>
list
=
new
A
rrayList
<>
()
;
for
(
$
{
className
}
DTO
$
{
changeClassName
}
:
all
)
{
M
ap
<
S
tring
,
O
bject
>
map
=
new
L
inkedHashMap
<>
()
;
<#
list
columns
as
column
>
<#
if
column
.columnKey
!=
'
PRI
'>
<#
if
column
.columnComment
!=
''>
map
.put
(
"${column.columnComment}"
,
$
{
changeClassName
}
.get
$
{
column
.capitalColumnName
}())
;
<#
else
>
map
.put
(
" ${column.changeColumnName}"
,
$
{
changeClassName
}
.get
$
{
column
.capitalColumnName
}())
;
</#
if
>
</#
if
>
</#
list
>
list
.add
(
map
)
;
}
F
ileUtil
.downloadExcel
(
list
,
response
)
;
}
}
}
\ No newline at end of file
eladmin-system/src/main/resources/template/generator/front/api.ftl
View file @
2e3877aa
...
@@ -22,3 +22,12 @@ export function edit(data) {
...
@@ -22,3 +22,12 @@ export function edit(data) {
data
data
})
})
}
}
export
function download$
{
className
}
(params)
{
return
request
({
url
:
'
api
/$
{
changeClassName
}
/
download
'
,
method
:
'
get
'
,
params
,
responseType
:
'
blob
'
})
}
eladmin-system/src/main/resources/template/generator/front/eForm.ftl
View file @
2e3877aa
...
@@ -5,7 +5,11 @@
...
@@ -5,7 +5,11 @@
<#list columns as column>
<#list columns as column>
<#if column.changeColumnName != '$
{
pkChangeColName
}
'>
<#if column.changeColumnName != '$
{
pkChangeColName
}
'>
<el-form-item label="<#if column.columnComment != ''>$
{
column
.columnComment
}
<#else>$
{
column
.changeColumnName
}
</#if>" <#if column.columnKey = 'UNI'>prop="$
{
column
.changeColumnName
}
"</#if>>
<el-form-item label="<#if column.columnComment != ''>$
{
column
.columnComment
}
<#else>$
{
column
.changeColumnName
}
</#if>" <#if column.columnKey = 'UNI'>prop="$
{
column
.changeColumnName
}
"</#if>>
<#if column.columnType != 'Timestamp'>
<el-input v-model="form.$
{
column
.changeColumnName
}
" style="width: 370px;"/>
<el-input v-model="form.$
{
column
.changeColumnName
}
" style="width: 370px;"/>
<#else >
<el-date-picker v-model="form.$
{
column
.changeColumnName
}
" type="datetime" style="width: 370px;"/>
</#if>
</el-form-item>
</el-form-item>
</#if>
</#if>
</#list>
</#list>
...
...
eladmin-system/src/main/resources/template/generator/front/index.ftl
View file @
2e3877aa
...
@@ -21,6 +21,16 @@
...
@@ -21,6 +21,16 @@
icon="el-icon-plus"
icon="el-icon-plus"
@click="add">新增</el-button>
@click="add">新增</el-button>
</div>
</div>
<!-- 导出 -->
<div style="display: inline-block;">
<el-button
:loading="downloadLoading"
size="mini"
class="filter-item"
type="warning"
icon="el-icon-download"
@click="download">导出</el-button>
</div>
</div>
</div>
<!--表单组件-->
<!--表单组件-->
<eForm ref="form" :is-add="isAdd"/>
<eForm ref="form" :is-add="isAdd"/>
...
@@ -73,9 +83,9 @@
...
@@ -73,9 +83,9 @@
<
script
>
<
script
>
import
checkPermission from '@/utils/permission'
import
checkPermission from '@/utils/permission'
import
initData from '@/mixins/initData'
import
initData from '@/mixins/initData'
import
{
del
}
from '@/api/$
{
changeClassName
}
'
import
{
del
,
download
$
{
className
}
}
from '@/api/$
{
changeClassName
}
'
<#
if
hasTimestamp>
<#
if
hasTimestamp>
import
{
parseTime
}
from '@/utils/index'
import
{
parseTime
,
downloadFile
}
from '@/utils/index'
</#
if
>
</#
if
>
import
eForm from './form'
import
eForm from './form'
export
default
{
export
default
{
...
@@ -150,6 +160,17 @@ export default {
...
@@ -150,6 +160,17 @@ export default {
</#
if
>
</#
if
>
}
}
_
this
.dialog
=
true
_
this
.dialog
=
true
},
//
导出
download
()
{
this
.beforeInit
()
this
.downloadLoading
=
true
download
$
{
className
}(
this
.params
)
.then
(
result
=>
{
downloadFile
(
result
,
'$
{
className
}
列表'
,
'
xlsx
'
)
this
.downloadLoading
=
false
})
.catch
(()
=>
{
this
.downloadLoading
=
false
})
}
}
}
}
}
}
...
...
Write
Preview
Supports
Markdown
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