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
905c8c64
"source/vscode:/vscode.git/clone" did not exist on "2ff992eea0f84555ca76906a93216b6ed3f85357"
Commit
905c8c64
authored
Oct 31, 2019
by
dqjdda
Browse files
所有列表加入日期搜索与导出功能
parent
938ae1fc
Changes
67
Hide whitespace changes
Inline
Side-by-side
eladmin-common/src/main/java/me/zhengjie/utils/PageUtil.java
View file @
905c8c64
...
@@ -29,7 +29,7 @@ public class PageUtil extends cn.hutool.core.util.PageUtil {
...
@@ -29,7 +29,7 @@ public class PageUtil extends cn.hutool.core.util.PageUtil {
/**
/**
* Page 数据处理,预防redis反序列化报错
* Page 数据处理,预防redis反序列化报错
*/
*/
public
static
Map
toPage
(
Page
page
)
{
public
static
Map
<
String
,
Object
>
toPage
(
Page
page
)
{
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<>(
2
);
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
());
...
@@ -39,7 +39,7 @@ public class PageUtil extends cn.hutool.core.util.PageUtil {
...
@@ -39,7 +39,7 @@ public class PageUtil extends cn.hutool.core.util.PageUtil {
/**
/**
* 自定义分页
* 自定义分页
*/
*/
public
static
Map
toPage
(
Object
object
,
Object
totalElements
)
{
public
static
Map
<
String
,
Object
>
toPage
(
Object
object
,
Object
totalElements
)
{
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<>(
2
);
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<>(
2
);
map
.
put
(
"content"
,
object
);
map
.
put
(
"content"
,
object
);
map
.
put
(
"totalElements"
,
totalElements
);
map
.
put
(
"totalElements"
,
totalElements
);
...
...
eladmin-logging/src/main/java/me/zhengjie/rest/LogController.java
View file @
905c8c64
...
@@ -2,6 +2,7 @@ package me.zhengjie.rest;
...
@@ -2,6 +2,7 @@ package me.zhengjie.rest;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
me.zhengjie.aop.log.Log
;
import
me.zhengjie.service.LogService
;
import
me.zhengjie.service.LogService
;
import
me.zhengjie.service.dto.LogQueryCriteria
;
import
me.zhengjie.service.dto.LogQueryCriteria
;
import
me.zhengjie.utils.SecurityUtils
;
import
me.zhengjie.utils.SecurityUtils
;
...
@@ -14,6 +15,9 @@ import org.springframework.web.bind.annotation.PathVariable;
...
@@ -14,6 +15,9 @@ import org.springframework.web.bind.annotation.PathVariable;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
/**
/**
* @author Zheng Jie
* @author Zheng Jie
* @date 2018-11-24
* @date 2018-11-24
...
@@ -29,6 +33,14 @@ public class LogController {
...
@@ -29,6 +33,14 @@ public class LogController {
this
.
logService
=
logService
;
this
.
logService
=
logService
;
}
}
@Log
(
"导出数据"
)
@ApiOperation
(
"导出数据"
)
@GetMapping
(
value
=
"/download"
)
@PreAuthorize
(
"@el.check()"
)
public
void
download
(
HttpServletResponse
response
,
LogQueryCriteria
criteria
)
throws
IOException
{
logService
.
download
(
logService
.
queryAll
(
criteria
),
response
);
}
@GetMapping
@GetMapping
@ApiOperation
(
"日志查询"
)
@ApiOperation
(
"日志查询"
)
@PreAuthorize
(
"@el.check()"
)
@PreAuthorize
(
"@el.check()"
)
...
...
eladmin-logging/src/main/java/me/zhengjie/service/LogService.java
View file @
905c8c64
...
@@ -6,6 +6,10 @@ import org.aspectj.lang.ProceedingJoinPoint;
...
@@ -6,6 +6,10 @@ import org.aspectj.lang.ProceedingJoinPoint;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.Async
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.List
;
/**
/**
* @author Zheng Jie
* @author Zheng Jie
* @date 2018-11-24
* @date 2018-11-24
...
@@ -14,6 +18,8 @@ public interface LogService {
...
@@ -14,6 +18,8 @@ public interface LogService {
Object
queryAll
(
LogQueryCriteria
criteria
,
Pageable
pageable
);
Object
queryAll
(
LogQueryCriteria
criteria
,
Pageable
pageable
);
List
<
Log
>
queryAll
(
LogQueryCriteria
criteria
);
Object
queryAllByUser
(
LogQueryCriteria
criteria
,
Pageable
pageable
);
Object
queryAllByUser
(
LogQueryCriteria
criteria
,
Pageable
pageable
);
@Async
@Async
...
@@ -25,4 +31,6 @@ public interface LogService {
...
@@ -25,4 +31,6 @@ public interface LogService {
* @return Object
* @return Object
*/
*/
Object
findByErrDetail
(
Long
id
);
Object
findByErrDetail
(
Long
id
);
void
download
(
List
<
Log
>
queryAll
,
HttpServletResponse
response
)
throws
IOException
;
}
}
eladmin-logging/src/main/java/me/zhengjie/service/dto/LogQueryCriteria.java
View file @
905c8c64
...
@@ -3,6 +3,8 @@ package me.zhengjie.service.dto;
...
@@ -3,6 +3,8 @@ package me.zhengjie.service.dto;
import
lombok.Data
;
import
lombok.Data
;
import
me.zhengjie.annotation.Query
;
import
me.zhengjie.annotation.Query
;
import
java.sql.Timestamp
;
/**
/**
* 日志查询类
* 日志查询类
* @author Zheng Jie
* @author Zheng Jie
...
@@ -17,4 +19,10 @@ public class LogQueryCriteria {
...
@@ -17,4 +19,10 @@ public class LogQueryCriteria {
@Query
@Query
private
String
logType
;
private
String
logType
;
@Query
(
type
=
Query
.
Type
.
GREATER_THAN
,
propName
=
"createTime"
)
private
Timestamp
startTime
;
@Query
(
type
=
Query
.
Type
.
LESS_THAN
,
propName
=
"createTime"
)
private
Timestamp
endTime
;
}
}
eladmin-logging/src/main/java/me/zhengjie/service/impl/LogServiceImpl.java
View file @
905c8c64
package
me.zhengjie.service.impl
;
package
me.zhengjie.service.impl
;
import
cn.hutool.core.lang.Dict
;
import
cn.hutool.core.lang.Dict
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONObject
;
import
me.zhengjie.domain.Log
;
import
me.zhengjie.domain.Log
;
import
me.zhengjie.repository.LogRepository
;
import
me.zhengjie.repository.LogRepository
;
...
@@ -8,6 +9,7 @@ import me.zhengjie.service.LogService;
...
@@ -8,6 +9,7 @@ import me.zhengjie.service.LogService;
import
me.zhengjie.service.dto.LogQueryCriteria
;
import
me.zhengjie.service.dto.LogQueryCriteria
;
import
me.zhengjie.service.mapper.LogErrorMapper
;
import
me.zhengjie.service.mapper.LogErrorMapper
;
import
me.zhengjie.service.mapper.LogSmallMapper
;
import
me.zhengjie.service.mapper.LogSmallMapper
;
import
me.zhengjie.utils.FileUtil
;
import
me.zhengjie.utils.PageUtil
;
import
me.zhengjie.utils.PageUtil
;
import
me.zhengjie.utils.QueryHelp
;
import
me.zhengjie.utils.QueryHelp
;
import
me.zhengjie.utils.StringUtils
;
import
me.zhengjie.utils.StringUtils
;
...
@@ -18,7 +20,14 @@ import org.springframework.data.domain.Pageable;
...
@@ -18,7 +20,14 @@ import org.springframework.data.domain.Pageable;
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
java.io.IOException
;
import
java.lang.reflect.Method
;
import
java.lang.reflect.Method
;
import
java.util.ArrayList
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* @author Zheng Jie
* @author Zheng Jie
...
@@ -49,6 +58,11 @@ public class LogServiceImpl implements LogService {
...
@@ -49,6 +58,11 @@ public class LogServiceImpl implements LogService {
return
page
;
return
page
;
}
}
@Override
public
List
<
Log
>
queryAll
(
LogQueryCriteria
criteria
)
{
return
logRepository
.
findAll
(((
root
,
criteriaQuery
,
cb
)
->
QueryHelp
.
getPredicate
(
root
,
criteria
,
cb
)));
}
@Override
@Override
public
Object
queryAllByUser
(
LogQueryCriteria
criteria
,
Pageable
pageable
)
{
public
Object
queryAllByUser
(
LogQueryCriteria
criteria
,
Pageable
pageable
)
{
Page
<
Log
>
page
=
logRepository
.
findAll
(((
root
,
criteriaQuery
,
cb
)
->
QueryHelp
.
getPredicate
(
root
,
criteria
,
cb
)),
pageable
);
Page
<
Log
>
page
=
logRepository
.
findAll
(((
root
,
criteriaQuery
,
cb
)
->
QueryHelp
.
getPredicate
(
root
,
criteria
,
cb
)),
pageable
);
...
@@ -102,6 +116,25 @@ public class LogServiceImpl implements LogService {
...
@@ -102,6 +116,25 @@ public class LogServiceImpl implements LogService {
@Override
@Override
public
Object
findByErrDetail
(
Long
id
)
{
public
Object
findByErrDetail
(
Long
id
)
{
return
Dict
.
create
().
set
(
"exception"
,
logRepository
.
findExceptionById
(
id
).
getExceptionDetail
());
byte
[]
details
=
logRepository
.
findExceptionById
(
id
).
getExceptionDetail
();
return
Dict
.
create
().
set
(
"exception"
,
new
String
(
ObjectUtil
.
isNotNull
(
details
)
?
details
:
""
.
getBytes
()));
}
@Override
public
void
download
(
List
<
Log
>
logs
,
HttpServletResponse
response
)
throws
IOException
{
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<>();
for
(
Log
log
:
logs
)
{
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<>();
map
.
put
(
"用户名"
,
log
.
getUsername
());
map
.
put
(
"IP"
,
log
.
getRequestIp
());
map
.
put
(
"IP来源"
,
log
.
getAddress
());
map
.
put
(
"描述"
,
log
.
getDescription
());
map
.
put
(
"浏览器"
,
log
.
getBrowser
());
map
.
put
(
"请求耗时/毫秒"
,
log
.
getTime
());
map
.
put
(
"异常详情"
,
new
String
(
ObjectUtil
.
isNotNull
(
log
.
getExceptionDetail
())
?
log
.
getExceptionDetail
()
:
""
.
getBytes
()));
map
.
put
(
"创建日期"
,
log
.
getCreateTime
());
list
.
add
(
map
);
}
FileUtil
.
downloadExcel
(
list
,
response
);
}
}
}
}
eladmin-system/src/main/java/me/zhengjie/modules/monitor/domain/Visits.java
View file @
905c8c64
...
@@ -4,6 +4,7 @@ import lombok.Data;
...
@@ -4,6 +4,7 @@ import lombok.Data;
import
org.hibernate.annotations.CreationTimestamp
;
import
org.hibernate.annotations.CreationTimestamp
;
import
javax.persistence.*
;
import
javax.persistence.*
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
/**
/**
...
@@ -15,7 +16,7 @@ import java.sql.Timestamp;
...
@@ -15,7 +16,7 @@ import java.sql.Timestamp;
@Entity
@Entity
@Data
@Data
@Table
(
name
=
"visits"
)
@Table
(
name
=
"visits"
)
public
class
Visits
{
public
class
Visits
implements
Serializable
{
@Id
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
...
...
eladmin-system/src/main/java/me/zhengjie/modules/monitor/rest/RedisController.java
View file @
905c8c64
...
@@ -11,6 +11,9 @@ import org.springframework.http.ResponseEntity;
...
@@ -11,6 +11,9 @@ import org.springframework.http.ResponseEntity;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
/**
/**
* @author Zheng Jie
* @author Zheng Jie
* @date 2018-12-10
* @date 2018-12-10
...
@@ -34,6 +37,14 @@ public class RedisController {
...
@@ -34,6 +37,14 @@ public class RedisController {
return
new
ResponseEntity
<>(
redisService
.
findByKey
(
key
,
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
redisService
.
findByKey
(
key
,
pageable
),
HttpStatus
.
OK
);
}
}
@Log
(
"导出数据"
)
@ApiOperation
(
"导出数据"
)
@GetMapping
(
value
=
"/download"
)
@PreAuthorize
(
"@el.check('redis:list')"
)
public
void
download
(
HttpServletResponse
response
,
String
key
)
throws
IOException
{
redisService
.
download
(
redisService
.
findByKey
(
key
),
response
);
}
@Log
(
"删除Redis缓存"
)
@Log
(
"删除Redis缓存"
)
@DeleteMapping
@DeleteMapping
@ApiOperation
(
"删除Redis缓存"
)
@ApiOperation
(
"删除Redis缓存"
)
...
...
eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/RedisService.java
View file @
905c8c64
package
me.zhengjie.modules.monitor.service
;
package
me.zhengjie.modules.monitor.service
;
import
me.zhengjie.modules.monitor.domain.vo.RedisVo
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.List
;
/**
/**
* 可自行扩展
* 可自行扩展
* @author Zheng Jie
* @author Zheng Jie
...
@@ -17,6 +22,13 @@ public interface RedisService {
...
@@ -17,6 +22,13 @@ public interface RedisService {
*/
*/
Page
findByKey
(
String
key
,
Pageable
pageable
);
Page
findByKey
(
String
key
,
Pageable
pageable
);
/**
* findById
* @param key 键
* @return /
*/
List
<
RedisVo
>
findByKey
(
String
key
);
/**
/**
* 查询验证码的值
* 查询验证码的值
* @param key 键
* @param key 键
...
@@ -41,4 +53,11 @@ public interface RedisService {
...
@@ -41,4 +53,11 @@ public interface RedisService {
* 清空缓存
* 清空缓存
*/
*/
void
deleteAll
();
void
deleteAll
();
/**
*
* @param redisVos /
* @param response /
*/
void
download
(
List
<
RedisVo
>
redisVos
,
HttpServletResponse
response
)
throws
IOException
;
}
}
eladmin-system/src/main/java/me/zhengjie/modules/monitor/service/impl/RedisServiceImpl.java
View file @
905c8c64
package
me.zhengjie.modules.monitor.service.impl
;
package
me.zhengjie.modules.monitor.service.impl
;
import
cn.hutool.core.util.ObjectUtil
;
import
me.zhengjie.modules.monitor.domain.vo.RedisVo
;
import
me.zhengjie.modules.monitor.domain.vo.RedisVo
;
import
me.zhengjie.modules.monitor.service.RedisService
;
import
me.zhengjie.modules.monitor.service.RedisService
;
import
me.zhengjie.utils.FileUtil
;
import
me.zhengjie.utils.PageUtil
;
import
me.zhengjie.utils.PageUtil
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
...
@@ -10,6 +12,8 @@ import org.springframework.data.domain.Pageable;
...
@@ -10,6 +12,8 @@ import org.springframework.data.domain.Pageable;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -39,6 +43,15 @@ public class RedisServiceImpl implements RedisService {
...
@@ -39,6 +43,15 @@ public class RedisServiceImpl implements RedisService {
@Override
@Override
public
Page
<
RedisVo
>
findByKey
(
String
key
,
Pageable
pageable
){
public
Page
<
RedisVo
>
findByKey
(
String
key
,
Pageable
pageable
){
List
<
RedisVo
>
redisVos
=
findByKey
(
key
);
return
new
PageImpl
<
RedisVo
>(
PageUtil
.
toPage
(
pageable
.
getPageNumber
(),
pageable
.
getPageSize
(),
redisVos
),
pageable
,
redisVos
.
size
());
}
@Override
public
List
<
RedisVo
>
findByKey
(
String
key
)
{
List
<
RedisVo
>
redisVos
=
new
ArrayList
<>();
List
<
RedisVo
>
redisVos
=
new
ArrayList
<>();
if
(!
"*"
.
equals
(
key
)){
if
(!
"*"
.
equals
(
key
)){
key
=
"*"
+
key
+
"*"
;
key
=
"*"
+
key
+
"*"
;
...
@@ -52,10 +65,7 @@ public class RedisServiceImpl implements RedisService {
...
@@ -52,10 +65,7 @@ public class RedisServiceImpl implements RedisService {
RedisVo
redisVo
=
new
RedisVo
(
s
,
Objects
.
requireNonNull
(
redisTemplate
.
opsForValue
().
get
(
s
)).
toString
());
RedisVo
redisVo
=
new
RedisVo
(
s
,
Objects
.
requireNonNull
(
redisTemplate
.
opsForValue
().
get
(
s
)).
toString
());
redisVos
.
add
(
redisVo
);
redisVos
.
add
(
redisVo
);
}
}
return
new
PageImpl
<
RedisVo
>(
return
redisVos
;
PageUtil
.
toPage
(
pageable
.
getPageNumber
(),
pageable
.
getPageSize
(),
redisVos
),
pageable
,
redisVos
.
size
());
}
}
@Override
@Override
...
@@ -83,4 +93,16 @@ public class RedisServiceImpl implements RedisService {
...
@@ -83,4 +93,16 @@ public class RedisServiceImpl implements RedisService {
redisTemplate
.
opsForValue
().
set
(
key
,
val
);
redisTemplate
.
opsForValue
().
set
(
key
,
val
);
redisTemplate
.
expire
(
key
,
expiration
,
TimeUnit
.
MINUTES
);
redisTemplate
.
expire
(
key
,
expiration
,
TimeUnit
.
MINUTES
);
}
}
@Override
public
void
download
(
List
<
RedisVo
>
redisVos
,
HttpServletResponse
response
)
throws
IOException
{
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<>();
for
(
RedisVo
redisVo
:
redisVos
)
{
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<>();
map
.
put
(
"key"
,
redisVo
.
getKey
());
map
.
put
(
"value"
,
redisVo
.
getValue
());
list
.
add
(
map
);
}
FileUtil
.
downloadExcel
(
list
,
response
);
}
}
}
eladmin-system/src/main/java/me/zhengjie/modules/quartz/domain/QuartzJob.java
View file @
905c8c64
...
@@ -6,6 +6,7 @@ import org.hibernate.annotations.CreationTimestamp;
...
@@ -6,6 +6,7 @@ import org.hibernate.annotations.CreationTimestamp;
import
javax.persistence.*
;
import
javax.persistence.*
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.NotNull
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
/**
/**
...
@@ -16,7 +17,7 @@ import java.sql.Timestamp;
...
@@ -16,7 +17,7 @@ import java.sql.Timestamp;
@Setter
@Setter
@Entity
@Entity
@Table
(
name
=
"quartz_job"
)
@Table
(
name
=
"quartz_job"
)
public
class
QuartzJob
{
public
class
QuartzJob
implements
Serializable
{
public
static
final
String
JOB_KEY
=
"JOB_KEY"
;
public
static
final
String
JOB_KEY
=
"JOB_KEY"
;
...
...
eladmin-system/src/main/java/me/zhengjie/modules/quartz/rest/QuartzJobController.java
View file @
905c8c64
...
@@ -15,6 +15,9 @@ import org.springframework.security.access.prepost.PreAuthorize;
...
@@ -15,6 +15,9 @@ 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
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
/**
/**
* @author Zheng Jie
* @author Zheng Jie
* @date 2019-01-07
* @date 2019-01-07
...
@@ -41,6 +44,22 @@ public class QuartzJobController {
...
@@ -41,6 +44,22 @@ public class QuartzJobController {
return
new
ResponseEntity
<>(
quartzJobService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
quartzJobService
.
queryAll
(
criteria
,
pageable
),
HttpStatus
.
OK
);
}
}
@Log
(
"导出任务数据"
)
@ApiOperation
(
"导出任务数据"
)
@GetMapping
(
value
=
"/download"
)
@PreAuthorize
(
"@el.check('timing:list')"
)
public
void
download
(
HttpServletResponse
response
,
JobQueryCriteria
criteria
)
throws
IOException
{
quartzJobService
.
download
(
quartzJobService
.
queryAll
(
criteria
),
response
);
}
@Log
(
"导出日志数据"
)
@ApiOperation
(
"导出日志数据"
)
@GetMapping
(
value
=
"/download/log"
)
@PreAuthorize
(
"@el.check('timing:list')"
)
public
void
downloadLog
(
HttpServletResponse
response
,
JobQueryCriteria
criteria
)
throws
IOException
{
quartzJobService
.
downloadLog
(
quartzJobService
.
queryAllLog
(
criteria
),
response
);
}
@ApiOperation
(
"查询任务执行日志"
)
@ApiOperation
(
"查询任务执行日志"
)
@GetMapping
(
value
=
"/logs"
)
@GetMapping
(
value
=
"/logs"
)
@PreAuthorize
(
"@el.check('timing:list')"
)
@PreAuthorize
(
"@el.check('timing:list')"
)
...
...
eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/QuartzJobService.java
View file @
905c8c64
package
me.zhengjie.modules.quartz.service
;
package
me.zhengjie.modules.quartz.service
;
import
me.zhengjie.modules.quartz.domain.QuartzJob
;
import
me.zhengjie.modules.quartz.domain.QuartzJob
;
import
me.zhengjie.modules.quartz.domain.QuartzLog
;
import
me.zhengjie.modules.quartz.service.dto.JobQueryCriteria
;
import
me.zhengjie.modules.quartz.service.dto.JobQueryCriteria
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.List
;
/**
/**
* @author Zheng Jie
* @author Zheng Jie
* @date 2019-01-07
* @date 2019-01-07
...
@@ -12,8 +17,12 @@ public interface QuartzJobService {
...
@@ -12,8 +17,12 @@ public interface QuartzJobService {
Object
queryAll
(
JobQueryCriteria
criteria
,
Pageable
pageable
);
Object
queryAll
(
JobQueryCriteria
criteria
,
Pageable
pageable
);
List
<
QuartzJob
>
queryAll
(
JobQueryCriteria
criteria
);
Object
queryAllLog
(
JobQueryCriteria
criteria
,
Pageable
pageable
);
Object
queryAllLog
(
JobQueryCriteria
criteria
,
Pageable
pageable
);
List
<
QuartzLog
>
queryAllLog
(
JobQueryCriteria
criteria
);
QuartzJob
create
(
QuartzJob
resources
);
QuartzJob
create
(
QuartzJob
resources
);
void
update
(
QuartzJob
resources
);
void
update
(
QuartzJob
resources
);
...
@@ -33,4 +42,8 @@ public interface QuartzJobService {
...
@@ -33,4 +42,8 @@ public interface QuartzJobService {
* @param quartzJob /
* @param quartzJob /
*/
*/
void
execution
(
QuartzJob
quartzJob
);
void
execution
(
QuartzJob
quartzJob
);
void
download
(
List
<
QuartzJob
>
queryAll
,
HttpServletResponse
response
)
throws
IOException
;
void
downloadLog
(
List
<
QuartzLog
>
queryAllLog
,
HttpServletResponse
response
)
throws
IOException
;
}
}
eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/dto/JobQueryCriteria.java
View file @
905c8c64
...
@@ -3,6 +3,8 @@ package me.zhengjie.modules.quartz.service.dto;
...
@@ -3,6 +3,8 @@ package me.zhengjie.modules.quartz.service.dto;
import
lombok.Data
;
import
lombok.Data
;
import
me.zhengjie.annotation.Query
;
import
me.zhengjie.annotation.Query
;
import
java.sql.Timestamp
;
/**
/**
* @author Zheng Jie
* @author Zheng Jie
* @date 2019-6-4 10:33:02
* @date 2019-6-4 10:33:02
...
@@ -15,4 +17,10 @@ public class JobQueryCriteria {
...
@@ -15,4 +17,10 @@ public class JobQueryCriteria {
@Query
@Query
private
Boolean
isSuccess
;
private
Boolean
isSuccess
;
@Query
(
type
=
Query
.
Type
.
GREATER_THAN
,
propName
=
"createTime"
)
private
Timestamp
startTime
;
@Query
(
type
=
Query
.
Type
.
LESS_THAN
,
propName
=
"createTime"
)
private
Timestamp
endTime
;
}
}
eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/QuartzJobServiceImpl.java
View file @
905c8c64
...
@@ -2,11 +2,13 @@ package me.zhengjie.modules.quartz.service.impl;
...
@@ -2,11 +2,13 @@ package me.zhengjie.modules.quartz.service.impl;
import
me.zhengjie.exception.BadRequestException
;
import
me.zhengjie.exception.BadRequestException
;
import
me.zhengjie.modules.quartz.domain.QuartzJob
;
import
me.zhengjie.modules.quartz.domain.QuartzJob
;
import
me.zhengjie.modules.quartz.domain.QuartzLog
;
import
me.zhengjie.modules.quartz.repository.QuartzJobRepository
;
import
me.zhengjie.modules.quartz.repository.QuartzJobRepository
;
import
me.zhengjie.modules.quartz.repository.QuartzLogRepository
;
import
me.zhengjie.modules.quartz.repository.QuartzLogRepository
;
import
me.zhengjie.modules.quartz.service.QuartzJobService
;
import
me.zhengjie.modules.quartz.service.QuartzJobService
;
import
me.zhengjie.modules.quartz.service.dto.JobQueryCriteria
;
import
me.zhengjie.modules.quartz.service.dto.JobQueryCriteria
;
import
me.zhengjie.modules.quartz.utils.QuartzManage
;
import
me.zhengjie.modules.quartz.utils.QuartzManage
;
import
me.zhengjie.utils.FileUtil
;
import
me.zhengjie.utils.PageUtil
;
import
me.zhengjie.utils.PageUtil
;
import
me.zhengjie.utils.QueryHelp
;
import
me.zhengjie.utils.QueryHelp
;
import
me.zhengjie.utils.ValidationUtil
;
import
me.zhengjie.utils.ValidationUtil
;
...
@@ -19,6 +21,13 @@ import org.springframework.stereotype.Service;
...
@@ -19,6 +21,13 @@ 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
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* @author Zheng Jie
* @author Zheng Jie
* @date 2019-01-07
* @date 2019-01-07
...
@@ -51,6 +60,16 @@ public class QuartzJobServiceImpl implements QuartzJobService {
...
@@ -51,6 +60,16 @@ public class QuartzJobServiceImpl implements QuartzJobService {
return
PageUtil
.
toPage
(
quartzLogRepository
.
findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
QueryHelp
.
getPredicate
(
root
,
criteria
,
criteriaBuilder
),
pageable
));
return
PageUtil
.
toPage
(
quartzLogRepository
.
findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
QueryHelp
.
getPredicate
(
root
,
criteria
,
criteriaBuilder
),
pageable
));
}
}
@Override
public
List
<
QuartzJob
>
queryAll
(
JobQueryCriteria
criteria
)
{
return
quartzJobRepository
.
findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
QueryHelp
.
getPredicate
(
root
,
criteria
,
criteriaBuilder
));
}
@Override
public
List
<
QuartzLog
>
queryAllLog
(
JobQueryCriteria
criteria
)
{
return
quartzLogRepository
.
findAll
((
root
,
criteriaQuery
,
criteriaBuilder
)
->
QueryHelp
.
getPredicate
(
root
,
criteria
,
criteriaBuilder
));
}
@Override
@Override
@Cacheable
(
key
=
"#p0"
)
@Cacheable
(
key
=
"#p0"
)
public
QuartzJob
findById
(
Long
id
)
{
public
QuartzJob
findById
(
Long
id
)
{
...
@@ -119,4 +138,41 @@ public class QuartzJobServiceImpl implements QuartzJobService {
...
@@ -119,4 +138,41 @@ public class QuartzJobServiceImpl implements QuartzJobService {
quartzManage
.
deleteJob
(
quartzJob
);
quartzManage
.
deleteJob
(
quartzJob
);
quartzJobRepository
.
delete
(
quartzJob
);
quartzJobRepository
.
delete
(
quartzJob
);
}
}
@Override
public
void
download
(
List
<
QuartzJob
>
quartzJobs
,
HttpServletResponse
response
)
throws
IOException
{
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<>();
for
(
QuartzJob
quartzJob
:
quartzJobs
)
{
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<>();
map
.
put
(
"任务名称"
,
quartzJob
.
getJobName
());
map
.
put
(
"Bean名称"
,
quartzJob
.
getBeanName
());
map
.
put
(
"执行方法"
,
quartzJob
.
getMethodName
());
map
.
put
(
"参数"
,
quartzJob
.
getParams
());
map
.
put
(
"表达式"
,
quartzJob
.
getCronExpression
());
map
.
put
(
"状态"
,
quartzJob
.
getIsPause
()
?
"暂停中"
:
"运行中"
);
map
.
put
(
"描述"
,
quartzJob
.
getRemark
());
map
.
put
(
"创建日期"
,
quartzJob
.
getCreateTime
());
list
.
add
(
map
);
}
FileUtil
.
downloadExcel
(
list
,
response
);
}
@Override
public
void
downloadLog
(
List
<
QuartzLog
>
queryAllLog
,
HttpServletResponse
response
)
throws
IOException
{
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<>();
for
(
QuartzLog
quartzLog
:
queryAllLog
)
{
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<>();
map
.
put
(
"任务名称"
,
quartzLog
.
getJobName
());
map
.
put
(
"Bean名称"
,
quartzLog
.
getBeanName
());
map
.
put
(
"执行方法"
,
quartzLog
.
getMethodName
());
map
.
put
(
"参数"
,
quartzLog
.
getParams
());
map
.
put
(
"表达式"
,
quartzLog
.
getCronExpression
());
map
.
put
(
"异常详情"
,
quartzLog
.
getExceptionDetail
());
map
.
put
(
"耗时/毫秒"
,
quartzLog
.
getTime
());
map
.
put
(
"状态"
,
quartzLog
.
getIsSuccess
()
?
"成功"
:
"失败"
);
map
.
put
(
"创建日期"
,
quartzLog
.
getCreateTime
());
list
.
add
(
map
);
}
FileUtil
.
downloadExcel
(
list
,
response
);
}
}
}
eladmin-system/src/main/java/me/zhengjie/modules/security/rest/OnlineController.java
View file @
905c8c64
...
@@ -2,6 +2,7 @@ package me.zhengjie.modules.security.rest;
...
@@ -2,6 +2,7 @@ package me.zhengjie.modules.security.rest;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
me.zhengjie.aop.log.Log
;
import
me.zhengjie.modules.security.service.OnlineUserService
;
import
me.zhengjie.modules.security.service.OnlineUserService
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.http.HttpStatus
;
...
@@ -9,6 +10,9 @@ import org.springframework.http.ResponseEntity;
...
@@ -9,6 +10,9 @@ import org.springframework.http.ResponseEntity;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
@RestController
@RestController
@RequestMapping
(
"/auth/online"
)
@RequestMapping
(
"/auth/online"
)
@Api
(
tags
=
"系统:在线用户管理"
)
@Api
(
tags
=
"系统:在线用户管理"
)
...
@@ -27,6 +31,14 @@ public class OnlineController {
...
@@ -27,6 +31,14 @@ public class OnlineController {
return
new
ResponseEntity
<>(
onlineUserService
.
getAll
(
filter
,
pageable
),
HttpStatus
.
OK
);
return
new
ResponseEntity
<>(
onlineUserService
.
getAll
(
filter
,
pageable
),
HttpStatus
.
OK
);
}
}
@Log
(
"导出数据"
)
@ApiOperation
(
"导出数据"
)
@GetMapping
(
value
=
"/download"
)
@PreAuthorize
(
"@el.check()"
)
public
void
download
(
HttpServletResponse
response
,
String
filter
)
throws
IOException
{
onlineUserService
.
download
(
onlineUserService
.
getAll
(
filter
),
response
);
}
@ApiOperation
(
"踢出用户"
)
@ApiOperation
(
"踢出用户"
)
@DeleteMapping
(
value
=
"/{key}"
)
@DeleteMapping
(
value
=
"/{key}"
)
@PreAuthorize
(
"@el.check()"
)
@PreAuthorize
(
"@el.check()"
)
...
...
eladmin-system/src/main/java/me/zhengjie/modules/security/service/OnlineUserService.java
View file @
905c8c64
...
@@ -3,6 +3,7 @@ package me.zhengjie.modules.security.service;
...
@@ -3,6 +3,7 @@ package me.zhengjie.modules.security.service;
import
me.zhengjie.modules.security.security.JwtUser
;
import
me.zhengjie.modules.security.security.JwtUser
;
import
me.zhengjie.modules.security.security.OnlineUser
;
import
me.zhengjie.modules.security.security.OnlineUser
;
import
me.zhengjie.utils.EncryptUtils
;
import
me.zhengjie.utils.EncryptUtils
;
import
me.zhengjie.utils.FileUtil
;
import
me.zhengjie.utils.PageUtil
;
import
me.zhengjie.utils.PageUtil
;
import
me.zhengjie.utils.StringUtils
;
import
me.zhengjie.utils.StringUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
...
@@ -12,6 +13,8 @@ import org.springframework.data.domain.Pageable;
...
@@ -12,6 +13,8 @@ import org.springframework.data.domain.Pageable;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -51,6 +54,14 @@ public class OnlineUserService {
...
@@ -51,6 +54,14 @@ public class OnlineUserService {
}
}
public
Page
<
OnlineUser
>
getAll
(
String
filter
,
Pageable
pageable
){
public
Page
<
OnlineUser
>
getAll
(
String
filter
,
Pageable
pageable
){
List
<
OnlineUser
>
onlineUsers
=
getAll
(
filter
);
return
new
PageImpl
<
OnlineUser
>(
PageUtil
.
toPage
(
pageable
.
getPageNumber
(),
pageable
.
getPageSize
(),
onlineUsers
),
pageable
,
onlineUsers
.
size
());
}
public
List
<
OnlineUser
>
getAll
(
String
filter
){
List
<
String
>
keys
=
new
ArrayList
<>(
redisTemplate
.
keys
(
onlineKey
+
"*"
));
List
<
String
>
keys
=
new
ArrayList
<>(
redisTemplate
.
keys
(
onlineKey
+
"*"
));
Collections
.
reverse
(
keys
);
Collections
.
reverse
(
keys
);
List
<
OnlineUser
>
onlineUsers
=
new
ArrayList
<>();
List
<
OnlineUser
>
onlineUsers
=
new
ArrayList
<>();
...
@@ -67,10 +78,7 @@ public class OnlineUserService {
...
@@ -67,10 +78,7 @@ public class OnlineUserService {
Collections
.
sort
(
onlineUsers
,
(
o1
,
o2
)
->
{
Collections
.
sort
(
onlineUsers
,
(
o1
,
o2
)
->
{
return
o2
.
getLoginTime
().
compareTo
(
o1
.
getLoginTime
());
return
o2
.
getLoginTime
().
compareTo
(
o1
.
getLoginTime
());
});
});
return
new
PageImpl
<
OnlineUser
>(
return
onlineUsers
;
PageUtil
.
toPage
(
pageable
.
getPageNumber
(),
pageable
.
getPageSize
(),
onlineUsers
),
pageable
,
keys
.
size
());
}
}
public
void
kickOut
(
String
val
)
throws
Exception
{
public
void
kickOut
(
String
val
)
throws
Exception
{
...
@@ -82,4 +90,19 @@ public class OnlineUserService {
...
@@ -82,4 +90,19 @@ public class OnlineUserService {
String
key
=
onlineKey
+
token
;
String
key
=
onlineKey
+
token
;
redisTemplate
.
delete
(
key
);
redisTemplate
.
delete
(
key
);
}
}
public
void
download
(
List
<
OnlineUser
>
all
,
HttpServletResponse
response
)
throws
IOException
{
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<>();
for
(
OnlineUser
user
:
all
)
{
Map
<
String
,
Object
>
map
=
new
LinkedHashMap
<>();
map
.
put
(
"用户名"
,
user
.
getUserName
());
map
.
put
(
"岗位"
,
user
.
getJob
());
map
.
put
(
"登录IP"
,
user
.
getIp
());
map
.
put
(
"登录地点"
,
user
.
getAddress
());
map
.
put
(
"浏览器"
,
user
.
getBrowser
());
map
.
put
(
"登录日期"
,
user
.
getLoginTime
());
list
.
add
(
map
);
}
FileUtil
.
downloadExcel
(
list
,
response
);
}
}
}
eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Dept.java
View file @
905c8c64
...
@@ -7,6 +7,7 @@ import org.hibernate.annotations.CreationTimestamp;
...
@@ -7,6 +7,7 @@ import org.hibernate.annotations.CreationTimestamp;
import
javax.persistence.*
;
import
javax.persistence.*
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.NotNull
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -18,7 +19,7 @@ import java.util.Set;
...
@@ -18,7 +19,7 @@ import java.util.Set;
@Getter
@Getter
@Setter
@Setter
@Table
(
name
=
"dept"
)
@Table
(
name
=
"dept"
)
public
class
Dept
{
public
class
Dept
implements
Serializable
{
@Id
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Dict.java
View file @
905c8c64
...
@@ -7,6 +7,7 @@ import org.hibernate.annotations.CreationTimestamp;
...
@@ -7,6 +7,7 @@ import org.hibernate.annotations.CreationTimestamp;
import
javax.persistence.*
;
import
javax.persistence.*
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.NotNull
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
import
java.util.List
;
import
java.util.List
;
...
@@ -18,7 +19,7 @@ import java.util.List;
...
@@ -18,7 +19,7 @@ import java.util.List;
@Getter
@Getter
@Setter
@Setter
@Table
(
name
=
"dict"
)
@Table
(
name
=
"dict"
)
public
class
Dict
{
public
class
Dict
implements
Serializable
{
@Id
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/domain/DictDetail.java
View file @
905c8c64
...
@@ -5,6 +5,7 @@ import lombok.Setter;
...
@@ -5,6 +5,7 @@ import lombok.Setter;
import
org.hibernate.annotations.CreationTimestamp
;
import
org.hibernate.annotations.CreationTimestamp
;
import
javax.persistence.*
;
import
javax.persistence.*
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.NotNull
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
/**
/**
...
@@ -15,7 +16,7 @@ import java.sql.Timestamp;
...
@@ -15,7 +16,7 @@ import java.sql.Timestamp;
@Getter
@Getter
@Setter
@Setter
@Table
(
name
=
"dict_detail"
)
@Table
(
name
=
"dict_detail"
)
public
class
DictDetail
{
public
class
DictDetail
implements
Serializable
{
@Id
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Job.java
View file @
905c8c64
...
@@ -8,6 +8,7 @@ import javax.persistence.Entity;
...
@@ -8,6 +8,7 @@ import javax.persistence.Entity;
import
javax.persistence.Table
;
import
javax.persistence.Table
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.NotNull
;
import
java.io.Serializable
;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
/**
/**
...
@@ -18,7 +19,7 @@ import java.sql.Timestamp;
...
@@ -18,7 +19,7 @@ import java.sql.Timestamp;
@Getter
@Getter
@Setter
@Setter
@Table
(
name
=
"job"
)
@Table
(
name
=
"job"
)
public
class
Job
{
public
class
Job
implements
Serializable
{
@Id
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
@GeneratedValue
(
strategy
=
GenerationType
.
IDENTITY
)
...
...
Prev
1
2
3
4
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