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
f9bb8cf2
Commit
f9bb8cf2
authored
Sep 26, 2019
by
dqjdda
Browse files
修复定时任务执行失败后还继续执行的bug,优化Redis发生异常时,程序正常执行,优化Excel大数据导出,优化QueryHelp,其他细节优化
parent
a481b16b
Changes
25
Hide whitespace changes
Inline
Side-by-side
eladmin-common/src/main/java/me/zhengjie/redis/RedisConfig.java
View file @
f9bb8cf2
...
@@ -3,14 +3,14 @@ package me.zhengjie.redis;
...
@@ -3,14 +3,14 @@ package me.zhengjie.redis;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.parser.ParserConfig
;
import
com.alibaba.fastjson.parser.ParserConfig
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
me.zhengjie.utils.StringUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnClass
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean
;
import
org.springframework.boot.autoconfigure.data.redis.RedisProperties
;
import
org.springframework.boot.autoconfigure.data.redis.RedisProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.cache.Cache
;
import
org.springframework.cache.annotation.CachingConfigurerSupport
;
import
org.springframework.cache.annotation.CachingConfigurerSupport
;
import
org.springframework.cache.annotation.EnableCaching
;
import
org.springframework.cache.annotation.EnableCaching
;
import
org.springframework.cache.interceptor.CacheErrorHandler
;
import
org.springframework.cache.interceptor.KeyGenerator
;
import
org.springframework.cache.interceptor.KeyGenerator
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
...
@@ -74,8 +74,8 @@ public class RedisConfig extends CachingConfigurerSupport {
...
@@ -74,8 +74,8 @@ public class RedisConfig extends CachingConfigurerSupport {
}
}
/**
/**
* 自定义缓存key生成策略
* 自定义缓存key生成策略
,默认将使用该策略
* 使用方法 @Cacheable
(keyGenerator="keyGenerator")
* 使用方法 @Cacheable
* @return
* @return
*/
*/
@Bean
@Bean
...
@@ -91,4 +91,34 @@ public class RedisConfig extends CachingConfigurerSupport {
...
@@ -91,4 +91,34 @@ public class RedisConfig extends CachingConfigurerSupport {
return
sb
.
toString
();
return
sb
.
toString
();
};
};
}
}
@Bean
@Override
public
CacheErrorHandler
errorHandler
()
{
// 异常处理,当Redis发生异常时,打印日志,但是程序正常走
log
.
info
(
"初始化 -> [{}]"
,
"Redis CacheErrorHandler"
);
CacheErrorHandler
cacheErrorHandler
=
new
CacheErrorHandler
()
{
@Override
public
void
handleCacheGetError
(
RuntimeException
e
,
Cache
cache
,
Object
key
)
{
log
.
error
(
"Redis occur handleCacheGetError:key -> [{}]"
,
key
,
e
);
}
@Override
public
void
handleCachePutError
(
RuntimeException
e
,
Cache
cache
,
Object
key
,
Object
value
)
{
log
.
error
(
"Redis occur handleCachePutError:key -> [{}];value -> [{}]"
,
key
,
value
,
e
);
}
@Override
public
void
handleCacheEvictError
(
RuntimeException
e
,
Cache
cache
,
Object
key
)
{
log
.
error
(
"Redis occur handleCacheEvictError:key -> [{}]"
,
key
,
e
);
}
@Override
public
void
handleCacheClearError
(
RuntimeException
e
,
Cache
cache
)
{
log
.
error
(
"Redis occur handleCacheClearError:"
,
e
);
}
};
return
cacheErrorHandler
;
}
}
}
eladmin-common/src/main/java/me/zhengjie/utils/FileUtil.java
View file @
f9bb8cf2
...
@@ -3,6 +3,7 @@ package me.zhengjie.utils;
...
@@ -3,6 +3,7 @@ package me.zhengjie.utils;
import
cn.hutool.core.codec.Base64
;
import
cn.hutool.core.codec.Base64
;
import
cn.hutool.core.io.IoUtil
;
import
cn.hutool.core.io.IoUtil
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.core.util.IdUtil
;
import
cn.hutool.poi.excel.BigExcelWriter
;
import
cn.hutool.poi.excel.ExcelUtil
;
import
cn.hutool.poi.excel.ExcelUtil
;
import
cn.hutool.poi.excel.ExcelWriter
;
import
cn.hutool.poi.excel.ExcelWriter
;
import
me.zhengjie.exception.BadRequestException
;
import
me.zhengjie.exception.BadRequestException
;
...
@@ -197,24 +198,20 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
...
@@ -197,24 +198,20 @@ public class FileUtil extends cn.hutool.core.io.FileUtil {
* @return
* @return
* @throws Exception
* @throws Exception
*/
*/
public
static
void
downloadExcel
(
List
<
Map
<
String
,
Object
>>
list
,
HttpServletResponse
response
){
public
static
void
downloadExcel
(
List
<
Map
<
String
,
Object
>>
list
,
HttpServletResponse
response
)
throws
IOException
{
// 通过工具类创建writer
String
tempPath
=
System
.
getProperty
(
"java.io.tmpdir"
)
+
IdUtil
.
fastSimpleUUID
()
+
".xlsx"
;
ExcelWriter
writer
=
ExcelUtil
.
getWriter
();
File
file
=
new
File
(
tempPath
);
BigExcelWriter
writer
=
ExcelUtil
.
getBigWriter
(
file
);
// 一次性写出内容,使用默认样式,强制输出标题
// 一次性写出内容,使用默认样式,强制输出标题
writer
.
write
(
list
,
true
);
writer
.
write
(
list
,
true
);
//response为HttpServletResponse对象
//response为HttpServletResponse对象
response
.
setContentType
(
"application/vnd.
ms-excel
;charset=utf-8"
);
response
.
setContentType
(
"application/vnd.
openxmlformats-officedocument.spreadsheetml.sheet
;charset=utf-8"
);
//test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
//test.xls是弹出下载对话框的文件名,不能为中文,中文请自行编码
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename=file.xls"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename=file.xlsx"
);
ServletOutputStream
out
=
null
;
ServletOutputStream
out
=
response
.
getOutputStream
();
try
{
// 终止后删除临时文件
out
=
response
.
getOutputStream
();
file
.
deleteOnExit
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
writer
.
flush
(
out
,
true
);
writer
.
flush
(
out
,
true
);
// 关闭writer,释放内存
writer
.
close
();
//此处记得关闭输出Servlet流
//此处记得关闭输出Servlet流
IoUtil
.
close
(
out
);
IoUtil
.
close
(
out
);
}
}
...
...
eladmin-common/src/main/java/me/zhengjie/utils/PageUtil.java
View file @
f9bb8cf2
package
me.zhengjie.utils
;
package
me.zhengjie.utils
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* 分页工具
* 分页工具
...
@@ -39,11 +36,9 @@ public class PageUtil extends cn.hutool.core.util.PageUtil {
...
@@ -39,11 +36,9 @@ public class PageUtil extends cn.hutool.core.util.PageUtil {
* @return
* @return
*/
*/
public
static
Map
toPage
(
Page
page
)
{
public
static
Map
toPage
(
Page
page
)
{
Map
map
=
new
HashMap
();
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<>(
2
);
map
.
put
(
"content"
,
page
.
getContent
());
map
.
put
(
"content"
,
page
.
getContent
());
map
.
put
(
"totalElements"
,
page
.
getTotalElements
());
map
.
put
(
"totalElements"
,
page
.
getTotalElements
());
return
map
;
return
map
;
}
}
...
@@ -53,8 +48,7 @@ public class PageUtil extends cn.hutool.core.util.PageUtil {
...
@@ -53,8 +48,7 @@ public class PageUtil extends cn.hutool.core.util.PageUtil {
* @return
* @return
*/
*/
public
static
Map
toPage
(
Object
object
,
Object
totalElements
)
{
public
static
Map
toPage
(
Object
object
,
Object
totalElements
)
{
Map
map
=
new
HashMap
();
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<>(
2
);
map
.
put
(
"content"
,
object
);
map
.
put
(
"content"
,
object
);
map
.
put
(
"totalElements"
,
totalElements
);
map
.
put
(
"totalElements"
,
totalElements
);
...
...
eladmin-common/src/main/java/me/zhengjie/utils/QueryHelp.java
View file @
f9bb8cf2
...
@@ -41,7 +41,7 @@ public class QueryHelp {
...
@@ -41,7 +41,7 @@ public class QueryHelp {
String
attributeName
=
isBlank
(
propName
)
?
field
.
getName
()
:
propName
;
String
attributeName
=
isBlank
(
propName
)
?
field
.
getName
()
:
propName
;
Class
<?>
fieldType
=
field
.
getType
();
Class
<?>
fieldType
=
field
.
getType
();
Object
val
=
field
.
get
(
query
);
Object
val
=
field
.
get
(
query
);
if
(
ObjectUtil
.
isNull
(
val
))
{
if
(
ObjectUtil
.
isNull
(
val
)
||
""
.
equals
(
val
)
)
{
continue
;
continue
;
}
}
Join
join
=
null
;
Join
join
=
null
;
...
@@ -58,13 +58,24 @@ public class QueryHelp {
...
@@ -58,13 +58,24 @@ public class QueryHelp {
continue
;
continue
;
}
}
if
(
ObjectUtil
.
isNotEmpty
(
joinName
))
{
if
(
ObjectUtil
.
isNotEmpty
(
joinName
))
{
switch
(
q
.
join
())
{
String
[]
joinNames
=
joinName
.
split
(
">"
);
case
LEFT:
for
(
String
name
:
joinNames
)
{
join
=
root
.
join
(
joinName
,
JoinType
.
LEFT
);
switch
(
q
.
join
())
{
break
;
case
LEFT:
case
RIGHT:
if
(
ObjectUtil
.
isNotEmpty
(
join
)){
join
=
root
.
join
(
joinName
,
JoinType
.
RIGHT
);
join
=
join
.
join
(
name
,
JoinType
.
LEFT
);
break
;
}
else
{
join
=
root
.
join
(
name
,
JoinType
.
LEFT
);
}
break
;
case
RIGHT:
if
(
ObjectUtil
.
isNotEmpty
(
join
)){
join
=
join
.
join
(
name
,
JoinType
.
RIGHT
);
}
else
{
join
=
root
.
join
(
name
,
JoinType
.
RIGHT
);
}
break
;
}
}
}
}
}
switch
(
q
.
type
())
{
switch
(
q
.
type
())
{
...
...
eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/QuartzJobService.java
View file @
f9bb8cf2
...
@@ -21,7 +21,7 @@ public interface QuartzJobService {
...
@@ -21,7 +21,7 @@ public interface QuartzJobService {
* @param pageable
* @param pageable
* @return
* @return
*/
*/
@Cacheable
(
keyGenerator
=
"keyGenerator"
)
@Cacheable
Object
queryAll
(
JobQueryCriteria
criteria
,
Pageable
pageable
);
Object
queryAll
(
JobQueryCriteria
criteria
,
Pageable
pageable
);
/**
/**
...
...
eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/TestTask.java
View file @
f9bb8cf2
package
me.zhengjie.modules.quartz.task
;
package
me.zhengjie.modules.quartz.task
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
me.zhengjie.exception.BadRequestException
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
/**
/**
...
...
eladmin-system/src/main/java/me/zhengjie/modules/quartz/utils/ExecutionJob.java
View file @
f9bb8cf2
...
@@ -25,6 +25,7 @@ public class ExecutionJob extends QuartzJobBean {
...
@@ -25,6 +25,7 @@ public class ExecutionJob extends QuartzJobBean {
private
Logger
logger
=
LoggerFactory
.
getLogger
(
this
.
getClass
());
private
Logger
logger
=
LoggerFactory
.
getLogger
(
this
.
getClass
());
// 建议自定义线程池实现方式,该处仅供参考
private
ExecutorService
executorService
=
Executors
.
newSingleThreadExecutor
();
private
ExecutorService
executorService
=
Executors
.
newSingleThreadExecutor
();
@Override
@Override
...
@@ -61,8 +62,7 @@ public class ExecutionJob extends QuartzJobBean {
...
@@ -61,8 +62,7 @@ public class ExecutionJob extends QuartzJobBean {
// 任务状态 0:成功 1:失败
// 任务状态 0:成功 1:失败
log
.
setIsSuccess
(
false
);
log
.
setIsSuccess
(
false
);
log
.
setExceptionDetail
(
ThrowableUtil
.
getStackTrace
(
e
));
log
.
setExceptionDetail
(
ThrowableUtil
.
getStackTrace
(
e
));
//出错就暂停任务
quartzJob
.
setIsPause
(
false
);
quartzManage
.
pauseJob
(
quartzJob
);
//更新状态
//更新状态
quartzJobService
.
updateIsPause
(
quartzJob
);
quartzJobService
.
updateIsPause
(
quartzJob
);
}
finally
{
}
finally
{
...
...
eladmin-system/src/main/java/me/zhengjie/modules/quartz/utils/QuartzRunnable.java
View file @
f9bb8cf2
package
me.zhengjie.modules.quartz.utils
;
package
me.zhengjie.modules.quartz.utils
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
me.zhengjie.exception.BadRequestException
;
import
me.zhengjie.utils.SpringContextHolder
;
import
me.zhengjie.utils.SpringContextHolder
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.util.ReflectionUtils
;
import
org.springframework.util.ReflectionUtils
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
import
java.util.concurrent.Callable
;
/**
/**
* 执行定时任务
* 执行定时任务
* @author
* @author
*/
*/
@Slf4j
@Slf4j
public
class
QuartzRunnable
implements
Runn
able
{
public
class
QuartzRunnable
implements
Call
able
{
private
Object
target
;
private
Object
target
;
private
Method
method
;
private
Method
method
;
...
@@ -30,17 +32,13 @@ public class QuartzRunnable implements Runnable {
...
@@ -30,17 +32,13 @@ public class QuartzRunnable implements Runnable {
}
}
@Override
@Override
public
void
run
()
{
public
Object
call
()
throws
Exception
{
try
{
ReflectionUtils
.
makeAccessible
(
method
);
ReflectionUtils
.
makeAccessible
(
method
);
if
(
StringUtils
.
isNotBlank
(
params
))
{
if
(
StringUtils
.
isNotBlank
(
params
))
{
method
.
invoke
(
target
,
params
);
method
.
invoke
(
target
,
params
);
}
else
{
}
else
{
method
.
invoke
(
target
);
method
.
invoke
(
target
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"定时任务执行失败"
,
e
);
}
}
return
null
;
}
}
}
}
eladmin-system/src/main/java/me/zhengjie/modules/system/rest/UserController.java
View file @
f9bb8cf2
...
@@ -27,6 +27,7 @@ import org.springframework.validation.annotation.Validated;
...
@@ -27,6 +27,7 @@ import org.springframework.validation.annotation.Validated;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -59,7 +60,7 @@ public class UserController {
...
@@ -59,7 +60,7 @@ public class UserController {
@Log
(
"导出用户数据"
)
@Log
(
"导出用户数据"
)
@GetMapping
(
value
=
"/users/download"
)
@GetMapping
(
value
=
"/users/download"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','USER_ALL','USER_SELECT')"
)
@PreAuthorize
(
"hasAnyRole('ADMIN','USER_ALL','USER_SELECT')"
)
public
void
update
(
HttpServletResponse
response
,
UserQueryCriteria
criteria
){
public
void
update
(
HttpServletResponse
response
,
UserQueryCriteria
criteria
)
throws
IOException
{
userService
.
download
(
userService
.
queryAll
(
criteria
),
response
);
userService
.
download
(
userService
.
queryAll
(
criteria
),
response
);
}
}
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/DeptService.java
View file @
f9bb8cf2
...
@@ -22,7 +22,7 @@ public interface DeptService {
...
@@ -22,7 +22,7 @@ public interface DeptService {
* @param criteria
* @param criteria
* @return
* @return
*/
*/
@Cacheable
(
keyGenerator
=
"keyGenerator"
)
@Cacheable
List
<
DeptDTO
>
queryAll
(
DeptQueryCriteria
criteria
);
List
<
DeptDTO
>
queryAll
(
DeptQueryCriteria
criteria
);
/**
/**
...
@@ -60,7 +60,7 @@ public interface DeptService {
...
@@ -60,7 +60,7 @@ public interface DeptService {
* @param deptDTOS
* @param deptDTOS
* @return
* @return
*/
*/
@Cacheable
(
keyGenerator
=
"keyGenerator"
)
@Cacheable
Object
buildTree
(
List
<
DeptDTO
>
deptDTOS
);
Object
buildTree
(
List
<
DeptDTO
>
deptDTOS
);
/**
/**
...
@@ -68,7 +68,7 @@ public interface DeptService {
...
@@ -68,7 +68,7 @@ public interface DeptService {
* @param pid
* @param pid
* @return
* @return
*/
*/
@Cacheable
(
keyGenerator
=
"keyGenerator"
)
@Cacheable
List
<
Dept
>
findByPid
(
long
pid
);
List
<
Dept
>
findByPid
(
long
pid
);
Set
<
Dept
>
findByRoleIds
(
Long
id
);
Set
<
Dept
>
findByRoleIds
(
Long
id
);
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/DictDetailService.java
View file @
f9bb8cf2
...
@@ -47,6 +47,6 @@ public interface DictDetailService {
...
@@ -47,6 +47,6 @@ public interface DictDetailService {
@CacheEvict
(
allEntries
=
true
)
@CacheEvict
(
allEntries
=
true
)
void
delete
(
Long
id
);
void
delete
(
Long
id
);
@Cacheable
(
keyGenerator
=
"keyGenerator"
)
@Cacheable
Map
queryAll
(
DictDetailQueryCriteria
criteria
,
Pageable
pageable
);
Map
queryAll
(
DictDetailQueryCriteria
criteria
,
Pageable
pageable
);
}
}
\ No newline at end of file
eladmin-system/src/main/java/me/zhengjie/modules/system/service/DictService.java
View file @
f9bb8cf2
...
@@ -21,7 +21,7 @@ public interface DictService {
...
@@ -21,7 +21,7 @@ public interface DictService {
* @param pageable
* @param pageable
* @return
* @return
*/
*/
@Cacheable
(
keyGenerator
=
"keyGenerator"
)
@Cacheable
Object
queryAll
(
DictQueryCriteria
dict
,
Pageable
pageable
);
Object
queryAll
(
DictQueryCriteria
dict
,
Pageable
pageable
);
/**
/**
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/MenuService.java
View file @
f9bb8cf2
...
@@ -23,7 +23,7 @@ public interface MenuService {
...
@@ -23,7 +23,7 @@ public interface MenuService {
* @param criteria
* @param criteria
* @return
* @return
*/
*/
@Cacheable
(
keyGenerator
=
"keyGenerator"
)
@Cacheable
List
<
MenuDTO
>
queryAll
(
MenuQueryCriteria
criteria
);
List
<
MenuDTO
>
queryAll
(
MenuQueryCriteria
criteria
);
/**
/**
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/PermissionService.java
View file @
f9bb8cf2
...
@@ -67,7 +67,7 @@ public interface PermissionService {
...
@@ -67,7 +67,7 @@ public interface PermissionService {
* @param permissionDTOS
* @param permissionDTOS
* @return
* @return
*/
*/
@Cacheable
(
keyGenerator
=
"keyGenerator"
)
@Cacheable
Object
buildTree
(
List
<
PermissionDTO
>
permissionDTOS
);
Object
buildTree
(
List
<
PermissionDTO
>
permissionDTOS
);
/**
/**
...
@@ -75,7 +75,7 @@ public interface PermissionService {
...
@@ -75,7 +75,7 @@ public interface PermissionService {
* @param criteria
* @param criteria
* @return
* @return
*/
*/
@Cacheable
(
keyGenerator
=
"keyGenerator"
)
@Cacheable
List
<
PermissionDTO
>
queryAll
(
PermissionQueryCriteria
criteria
);
List
<
PermissionDTO
>
queryAll
(
PermissionQueryCriteria
criteria
);
Set
<
Permission
>
getDeletePermission
(
List
<
Permission
>
permissions
,
Set
<
Permission
>
permissionSet
);
Set
<
Permission
>
getDeletePermission
(
List
<
Permission
>
permissions
,
Set
<
Permission
>
permissionSet
);
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/RoleService.java
View file @
f9bb8cf2
...
@@ -58,7 +58,7 @@ public interface RoleService {
...
@@ -58,7 +58,7 @@ public interface RoleService {
@Cacheable
(
key
=
"'findByUsers_Id:' + #p0"
)
@Cacheable
(
key
=
"'findByUsers_Id:' + #p0"
)
List
<
RoleSmallDTO
>
findByUsers_Id
(
Long
id
);
List
<
RoleSmallDTO
>
findByUsers_Id
(
Long
id
);
@Cacheable
(
keyGenerator
=
"keyGenerator"
)
@Cacheable
Integer
findByRoles
(
Set
<
Role
>
roles
);
Integer
findByRoles
(
Set
<
Role
>
roles
);
/**
/**
...
@@ -85,7 +85,7 @@ public interface RoleService {
...
@@ -85,7 +85,7 @@ public interface RoleService {
* @param pageable
* @param pageable
* @return
* @return
*/
*/
@Cacheable
(
keyGenerator
=
"keyGenerator"
)
@Cacheable
Object
queryAll
(
Pageable
pageable
);
Object
queryAll
(
Pageable
pageable
);
/**
/**
...
@@ -94,7 +94,7 @@ public interface RoleService {
...
@@ -94,7 +94,7 @@ public interface RoleService {
* @param criteria
* @param criteria
* @return
* @return
*/
*/
@Cacheable
(
keyGenerator
=
"keyGenerator"
)
@Cacheable
Object
queryAll
(
RoleQueryCriteria
criteria
,
Pageable
pageable
);
Object
queryAll
(
RoleQueryCriteria
criteria
,
Pageable
pageable
);
/**
/**
...
@@ -102,7 +102,7 @@ public interface RoleService {
...
@@ -102,7 +102,7 @@ public interface RoleService {
* @param criteria
* @param criteria
* @return
* @return
*/
*/
@Cacheable
(
keyGenerator
=
"keyGenerator"
)
@Cacheable
List
<
RoleDTO
>
queryAll
(
RoleQueryCriteria
criteria
);
List
<
RoleDTO
>
queryAll
(
RoleQueryCriteria
criteria
);
@CacheEvict
(
allEntries
=
true
)
@CacheEvict
(
allEntries
=
true
)
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/UserService.java
View file @
f9bb8cf2
...
@@ -11,6 +11,7 @@ import org.springframework.data.domain.Pageable;
...
@@ -11,6 +11,7 @@ import org.springframework.data.domain.Pageable;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -81,11 +82,11 @@ public interface UserService {
...
@@ -81,11 +82,11 @@ public interface UserService {
@CacheEvict
(
allEntries
=
true
)
@CacheEvict
(
allEntries
=
true
)
void
updateEmail
(
String
username
,
String
email
);
void
updateEmail
(
String
username
,
String
email
);
@Cacheable
(
keyGenerator
=
"keyGenerator"
)
@Cacheable
Object
queryAll
(
UserQueryCriteria
criteria
,
Pageable
pageable
);
Object
queryAll
(
UserQueryCriteria
criteria
,
Pageable
pageable
);
@Cacheable
(
keyGenerator
=
"keyGenerator"
)
@Cacheable
List
<
UserDTO
>
queryAll
(
UserQueryCriteria
criteria
);
List
<
UserDTO
>
queryAll
(
UserQueryCriteria
criteria
);
void
download
(
List
<
UserDTO
>
queryAll
,
HttpServletResponse
response
);
void
download
(
List
<
UserDTO
>
queryAll
,
HttpServletResponse
response
)
throws
IOException
;
}
}
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java
View file @
f9bb8cf2
...
@@ -180,7 +180,7 @@ public class UserServiceImpl implements UserService {
...
@@ -180,7 +180,7 @@ public class UserServiceImpl implements UserService {
}
}
@Override
@Override
public
void
download
(
List
<
UserDTO
>
queryAll
,
HttpServletResponse
response
)
{
public
void
download
(
List
<
UserDTO
>
queryAll
,
HttpServletResponse
response
)
throws
IOException
{
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<>();
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<>();
for
(
UserDTO
userDTO
:
queryAll
)
{
for
(
UserDTO
userDTO
:
queryAll
)
{
List
roles
=
userDTO
.
getRoles
().
stream
().
map
(
RoleSmallDTO:
:
getName
).
collect
(
Collectors
.
toList
());
List
roles
=
userDTO
.
getRoles
().
stream
().
map
(
RoleSmallDTO:
:
getName
).
collect
(
Collectors
.
toList
());
...
...
eladmin-system/src/main/resources/log4jdbc.log4j2.properties
View file @
f9bb8cf2
# If you use SLF4J. First, you need to tell log4jdbc-log4j2 that you want to use the SLF4J logger
# If you use SLF4J. First, you need to tell log4jdbc-log4j2 that you want to use the SLF4J logger
log4jdbc.spylogdelegator.name
=
net.sf.log4jdbc.log.slf4j.Slf4jSpyLogDelegator
log4jdbc.spylogdelegator.name
=
net.sf.log4jdbc.log.slf4j.Slf4jSpyLogDelegator
\ No newline at end of file
log4jdbc.auto.load.popular.drivers
=
false
log4jdbc.drivers
=
com.mysql.cj.jdbc.Driver
\ No newline at end of file
eladmin-system/src/main/resources/template/generator/admin/Service.ftl
View file @
f9bb8cf2
...
@@ -3,10 +3,12 @@ package ${package}.service;
...
@@ -3,10 +3,12 @@ package ${package}.service;
import
$
{
package
}
.domain.$
{
className
}
;
import
$
{
package
}
.domain.$
{
className
}
;
import
$
{
package
}
.service.dto.$
{
className
}
DTO;
import
$
{
package
}
.service.dto.$
{
className
}
DTO;
import
$
{
package
}
.service.dto.$
{
className
}
QueryCriteria;
import
$
{
package
}
.service.dto.$
{
className
}
QueryCriteria;
//
import
org.springframework.cache.annotation.CacheConfig;
import
org.springframework.cache.annotation.CacheConfig;
//
import
org.springframework.cache.annotation.CacheEvict;
import
org.springframework.cache.annotation.CacheEvict;
//
import
org.springframework.cache.annotation.Cacheable;
import
org.springframework.cache.annotation.Cacheable;
import
org.springframework.data.domain.Pageable;
import
org.springframework.data.domain.Pageable;
import
java.util.Map;
import
java.util.List;
/**
/**
*
@author $
{
author
}
*
@author $
{
author
}
...
@@ -16,24 +18,24 @@ import org.springframework.data.domain.Pageable;
...
@@ -16,24 +18,24 @@ import org.springframework.data.domain.Pageable;
public
interface $
{
className
}
Service
{
public
interface $
{
className
}
Service
{
/
**
/
**
*
queryAll
分页
*
查询数据
分页
*
@
param
criteria
*
@
param
criteria
*
@
param
pageable
*
@
param
pageable
*
@
return
*
@
return
*
/
*
/
//@
C
acheable
(
keyGenerator
=
"keyGenerator"
)
//@
C
acheable
O
bject
queryAll
(
$
{
className
}
Q
ueryCriteria
criteria
,
P
ageable
pageable
)
;
M
ap
<
S
tring
,
O
bject
>
queryAll
(
$
{
className
}
Q
ueryCriteria
criteria
,
P
ageable
pageable
)
;
/
**
/
**
*
queryAll
不分页
*
查询所有数据
不分页
*
@
param
criteria
*
@
param
criteria
*
@
return
*
@
return
*
/
*
/
//@
C
acheable
(
keyGenerator
=
"keyGenerator"
)
//@
C
acheable
public
O
bject
queryAll
(
$
{
className
}
Q
ueryCriteria
criteria
)
;
L
ist
<$
{
className
}
DTO
>
queryAll
(
$
{
className
}
Q
ueryCriteria
criteria
)
;
/
**
/
**
*
findById
*
根据
ID
查询
*
@
param
$
{
pkChangeColName
}
*
@
param
$
{
pkChangeColName
}
*
@
return
*
@
return
*
/
*
/
...
@@ -41,7 +43,7 @@ public interface ${className}Service {
...
@@ -41,7 +43,7 @@ public interface ${className}Service {
$
{
className
}
DTO
findById
(
$
{
pkColumnType
}
$
{
pkChangeColName
})
;
$
{
className
}
DTO
findById
(
$
{
pkColumnType
}
$
{
pkChangeColName
})
;
/
**
/
**
*
create
*
创建
*
@
param
resources
*
@
param
resources
*
@
return
*
@
return
*
/
*
/
...
@@ -49,14 +51,14 @@ public interface ${className}Service {
...
@@ -49,14 +51,14 @@ public interface ${className}Service {
$
{
className
}
DTO
create
(
$
{
className
}
resources
)
;
$
{
className
}
DTO
create
(
$
{
className
}
resources
)
;
/
**
/
**
*
update
*
编辑
*
@
param
resources
*
@
param
resources
*
/
*
/
//@
C
acheEvict
(
allEntries
=
true
)
//@
C
acheEvict
(
allEntries
=
true
)
void
update
(
$
{
className
}
resources
)
;
void
update
(
$
{
className
}
resources
)
;
/
**
/
**
*
delete
*
删除
*
@
param
$
{
pkChangeColName
}
*
@
param
$
{
pkChangeColName
}
*
/
*
/
//@
C
acheEvict
(
allEntries
=
true
)
//@
C
acheEvict
(
allEntries
=
true
)
...
...
eladmin-system/src/main/resources/template/generator/admin/ServiceImpl.ftl
View file @
f9bb8cf2
...
@@ -32,6 +32,8 @@ import org.springframework.data.domain.Page;
...
@@ -32,6 +32,8 @@ import org.springframework.data.domain.Page;
import
org.springframework.data.domain.Pageable;
import
org.springframework.data.domain.Pageable;
import
me.zhengjie.utils.PageUtil;
import
me.zhengjie.utils.PageUtil;
import
me.zhengjie.utils.QueryHelp;
import
me.zhengjie.utils.QueryHelp;
import
java.util.List;
import
java.util.Map;
/**
/**
*
@author $
{
author
}
*
@author $
{
author
}
...
@@ -48,13 +50,13 @@ public class ${className}ServiceImpl implements ${className}Service {
...
@@ -48,13 +50,13 @@ public class ${className}ServiceImpl implements ${className}Service {
private
$
{
className
}
M
apper
$
{
changeClassName
}
M
apper
;
private
$
{
className
}
M
apper
$
{
changeClassName
}
M
apper
;
@
O
verride
@
O
verride
public
O
bject
queryAll
(
$
{
className
}
Q
ueryCriteria
criteria
,
P
ageable
pageable
){
public
M
ap
<
S
tring
,
O
bject
>
queryAll
(
$
{
className
}
Q
ueryCriteria
criteria
,
P
ageable
pageable
){
P
age
<$
{
className
}
>
page
=
$
{
changeClassName
}
R
epository
.findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
Q
ueryHelp
.getPredicate
(
root
,
criteria
,
criteriaBuilder
),
pageable
)
;
P
age
<$
{
className
}
>
page
=
$
{
changeClassName
}
R
epository
.findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
Q
ueryHelp
.getPredicate
(
root
,
criteria
,
criteriaBuilder
),
pageable
)
;
return
P
ageUtil
.toPage
(
page
.map
(
$
{
changeClassName
}
M
apper
::
toDto
))
;
return
P
ageUtil
.toPage
(
page
.map
(
$
{
changeClassName
}
M
apper
::
toDto
))
;
}
}
@
O
verride
@
O
verride
public
O
bject
queryAll
(
$
{
className
}
Q
ueryCriteria
criteria
){
public
L
ist
<$
{
className
}
DTO
>
queryAll
(
$
{
className
}
Q
ueryCriteria
criteria
){
return
$
{
changeClassName
}
M
apper
.toDto
(
$
{
changeClassName
}
R
epository
.findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
Q
ueryHelp
.getPredicate
(
root
,
criteria
,
criteriaBuilder
)))
;
return
$
{
changeClassName
}
M
apper
.toDto
(
$
{
changeClassName
}
R
epository
.findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
Q
ueryHelp
.getPredicate
(
root
,
criteria
,
criteriaBuilder
)))
;
}
}
...
...
Prev
1
2
Next
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