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
924c8a06
Commit
924c8a06
authored
Jul 04, 2022
by
Zheng Jie
Browse files
Merge branch 'master' into deploy
parents
b8c545f8
255a3254
Changes
7
Hide whitespace changes
Inline
Side-by-side
eladmin-generator/src/main/java/me/zhengjie/utils/GenUtil.java
View file @
924c8a06
...
@@ -276,7 +276,8 @@ public class GenUtil {
...
@@ -276,7 +276,8 @@ public class GenUtil {
// 主键存在字典
// 主键存在字典
if
(
StringUtils
.
isNotBlank
(
column
.
getDictName
()))
{
if
(
StringUtils
.
isNotBlank
(
column
.
getDictName
()))
{
genMap
.
put
(
"hasDict"
,
true
);
genMap
.
put
(
"hasDict"
,
true
);
dicts
.
add
(
column
.
getDictName
());
if
(!
dicts
.
contains
(
column
.
getDictName
()))
dicts
.
add
(
column
.
getDictName
());
}
}
// 存储字段类型
// 存储字段类型
...
...
eladmin-system/src/main/java/me/zhengjie/config/thread/AsyncTaskExecutePool.java
View file @
924c8a06
...
@@ -43,8 +43,8 @@ public class AsyncTaskExecutePool implements AsyncConfigurer {
...
@@ -43,8 +43,8 @@ public class AsyncTaskExecutePool implements AsyncConfigurer {
executor
.
setQueueCapacity
(
AsyncTaskProperties
.
queueCapacity
);
executor
.
setQueueCapacity
(
AsyncTaskProperties
.
queueCapacity
);
//活跃时间
//活跃时间
executor
.
setKeepAliveSeconds
(
AsyncTaskProperties
.
keepAliveSeconds
);
executor
.
setKeepAliveSeconds
(
AsyncTaskProperties
.
keepAliveSeconds
);
//线程
名字前缀
//线程
工厂
executor
.
setThread
NamePrefix
(
"el-async
-
"
);
executor
.
setThread
Factory
(
new
TheadFactoryName
(
"el-async"
)
);
// setRejectedExecutionHandler:当pool已经达到max size的时候,如何处理新任务
// setRejectedExecutionHandler:当pool已经达到max size的时候,如何处理新任务
// CallerRunsPolicy:不在新线程中执行任务,而是由调用者所在的线程来执行
// CallerRunsPolicy:不在新线程中执行任务,而是由调用者所在的线程来执行
executor
.
setRejectedExecutionHandler
(
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
executor
.
setRejectedExecutionHandler
(
new
ThreadPoolExecutor
.
CallerRunsPolicy
());
...
...
eladmin-system/src/main/java/me/zhengjie/config/thread/TheadFactoryName.java
View file @
924c8a06
...
@@ -15,8 +15,8 @@
...
@@ -15,8 +15,8 @@
*/
*/
package
me.zhengjie.config.thread
;
package
me.zhengjie.config.thread
;
import
me.zhengjie.utils.StringUtils
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.util.concurrent.ThreadFactory
;
import
java.util.concurrent.ThreadFactory
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.atomic.AtomicInteger
;
...
@@ -33,24 +33,25 @@ public class TheadFactoryName implements ThreadFactory {
...
@@ -33,24 +33,25 @@ public class TheadFactoryName implements ThreadFactory {
private
final
AtomicInteger
threadNumber
=
new
AtomicInteger
(
1
);
private
final
AtomicInteger
threadNumber
=
new
AtomicInteger
(
1
);
private
final
String
namePrefix
;
private
final
String
namePrefix
;
private
final
static
String
DEF_NAME
=
"el-pool-"
;
public
TheadFactoryName
()
{
public
TheadFactoryName
()
{
this
(
"el-pool"
);
this
(
DEF_NAME
);
}
}
p
rivate
TheadFactoryName
(
String
name
){
p
ublic
TheadFactoryName
(
String
name
){
SecurityManager
s
=
System
.
getSecurityManager
();
SecurityManager
s
=
System
.
getSecurityManager
();
group
=
(
s
!=
null
)
?
s
.
getThreadGroup
()
:
group
=
(
s
!=
null
)
?
s
.
getThreadGroup
()
:
Thread
.
currentThread
().
getThreadGroup
();
Thread
.
currentThread
().
getThreadGroup
();
//此时namePrefix就是 name + 第几个用这个工厂创建线程池的
//此时namePrefix就是 name + 第几个用这个工厂创建线程池的
this
.
namePrefix
=
name
+
this
.
namePrefix
=
(
StringUtils
.
isNotBlank
(
name
)
?
name
:
DEF_NAME
)
+
"-"
+
POOL_NUMBER
.
getAndIncrement
();
POOL_NUMBER
.
getAndIncrement
();
}
}
@Override
@Override
public
Thread
newThread
(
Runnable
r
)
{
public
Thread
newThread
(
Runnable
r
)
{
//此时线程的名字 就是 namePrefix + -
thread
- + 这个线程池中第几个执行的线程
//此时线程的名字 就是 namePrefix + -
exec
- + 这个线程池中第几个执行的线程
Thread
t
=
new
Thread
(
group
,
r
,
Thread
t
=
new
Thread
(
group
,
r
,
namePrefix
+
"-
thread
-"
+
threadNumber
.
getAndIncrement
(),
namePrefix
+
"-
exec
-"
+
threadNumber
.
getAndIncrement
(),
0
);
0
);
if
(
t
.
isDaemon
())
{
if
(
t
.
isDaemon
())
{
t
.
setDaemon
(
false
);
t
.
setDaemon
(
false
);
...
...
eladmin-system/src/main/java/me/zhengjie/config/thread/ThreadPoolExecutorUtil.java
View file @
924c8a06
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
package
me.zhengjie.config.thread
;
package
me.zhengjie.config.thread
;
import
java.util.concurrent.ArrayBlockingQueue
;
import
java.util.concurrent.ArrayBlockingQueue
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -26,14 +27,20 @@ import java.util.concurrent.TimeUnit;
...
@@ -26,14 +27,20 @@ import java.util.concurrent.TimeUnit;
*/
*/
public
class
ThreadPoolExecutorUtil
{
public
class
ThreadPoolExecutorUtil
{
public
static
ThreadPoolExecutor
getPoll
(){
public
static
ExecutorService
getPoll
(){
return
getPoll
(
null
);
}
public
static
ExecutorService
getPoll
(
String
threadName
){
return
new
ThreadPoolExecutor
(
return
new
ThreadPoolExecutor
(
AsyncTaskProperties
.
corePoolSize
,
AsyncTaskProperties
.
corePoolSize
,
AsyncTaskProperties
.
maxPoolSize
,
AsyncTaskProperties
.
maxPoolSize
,
AsyncTaskProperties
.
keepAliveSeconds
,
AsyncTaskProperties
.
keepAliveSeconds
,
TimeUnit
.
SECONDS
,
TimeUnit
.
SECONDS
,
new
ArrayBlockingQueue
<>(
AsyncTaskProperties
.
queueCapacity
),
new
ArrayBlockingQueue
<>(
AsyncTaskProperties
.
queueCapacity
),
new
TheadFactoryName
()
new
TheadFactoryName
(
threadName
),
// 队列与线程池中线程都满了时使用调用者所在的线程来执行
new
ThreadPoolExecutor
.
CallerRunsPolicy
()
);
);
}
}
}
}
eladmin-system/src/main/java/me/zhengjie/modules/quartz/utils/ExecutionJob.java
View file @
924c8a06
...
@@ -19,6 +19,7 @@ import cn.hutool.extra.template.Template;
...
@@ -19,6 +19,7 @@ import cn.hutool.extra.template.Template;
import
cn.hutool.extra.template.TemplateConfig
;
import
cn.hutool.extra.template.TemplateConfig
;
import
cn.hutool.extra.template.TemplateEngine
;
import
cn.hutool.extra.template.TemplateEngine
;
import
cn.hutool.extra.template.TemplateUtil
;
import
cn.hutool.extra.template.TemplateUtil
;
import
me.zhengjie.config.thread.ThreadPoolExecutorUtil
;
import
me.zhengjie.domain.vo.EmailVo
;
import
me.zhengjie.domain.vo.EmailVo
;
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.domain.QuartzLog
;
...
@@ -32,7 +33,6 @@ import me.zhengjie.utils.ThrowableUtil;
...
@@ -32,7 +33,6 @@ import me.zhengjie.utils.ThrowableUtil;
import
org.quartz.JobExecutionContext
;
import
org.quartz.JobExecutionContext
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.quartz.QuartzJobBean
;
import
org.springframework.scheduling.quartz.QuartzJobBean
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.*
;
import
java.util.concurrent.*
;
...
@@ -42,15 +42,15 @@ import java.util.concurrent.*;
...
@@ -42,15 +42,15 @@ import java.util.concurrent.*;
* @author /
* @author /
* @date 2019-01-07
* @date 2019-01-07
*/
*/
@Async
public
class
ExecutionJob
extends
QuartzJobBean
{
public
class
ExecutionJob
extends
QuartzJobBean
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
this
.
getClass
());
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
this
.
getClass
());
// 此处仅供参考,可根据任务执行情况自定义线程池参数
private
final
static
ExecutorService
executor
=
ThreadPoolExecutorUtil
.
getPoll
(
"el-quartz-job"
);
@Override
@Override
public
void
executeInternal
(
JobExecutionContext
context
)
{
public
void
executeInternal
(
JobExecutionContext
context
)
{
// 创建单个线程
ExecutorService
executor
=
Executors
.
newSingleThreadExecutor
();
// 获取任务
// 获取任务
QuartzJob
quartzJob
=
(
QuartzJob
)
context
.
getMergedJobDataMap
().
get
(
QuartzJob
.
JOB_KEY
);
QuartzJob
quartzJob
=
(
QuartzJob
)
context
.
getMergedJobDataMap
().
get
(
QuartzJob
.
JOB_KEY
);
// 获取spring bean
// 获取spring bean
...
@@ -112,7 +112,6 @@ public class ExecutionJob extends QuartzJobBean {
...
@@ -112,7 +112,6 @@ public class ExecutionJob extends QuartzJobBean {
}
}
}
finally
{
}
finally
{
quartzLogRepository
.
save
(
log
);
quartzLogRepository
.
save
(
log
);
executor
.
shutdown
();
}
}
}
}
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/DataServiceImpl.java
View file @
924c8a06
...
@@ -43,7 +43,7 @@ public class DataServiceImpl implements DataService {
...
@@ -43,7 +43,7 @@ public class DataServiceImpl implements DataService {
private
final
DeptService
deptService
;
private
final
DeptService
deptService
;
/**
/**
* 用户角色改变时需清理缓存
* 用户角色
和用户部门
改变时需清理缓存
* @param user /
* @param user /
* @return /
* @return /
*/
*/
...
...
eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/UserServiceImpl.java
View file @
924c8a06
...
@@ -119,6 +119,10 @@ public class UserServiceImpl implements UserService {
...
@@ -119,6 +119,10 @@ public class UserServiceImpl implements UserService {
redisUtils
.
del
(
CacheKey
.
MENU_USER
+
resources
.
getId
());
redisUtils
.
del
(
CacheKey
.
MENU_USER
+
resources
.
getId
());
redisUtils
.
del
(
CacheKey
.
ROLE_AUTH
+
resources
.
getId
());
redisUtils
.
del
(
CacheKey
.
ROLE_AUTH
+
resources
.
getId
());
}
}
// 修改部门会影响 数据权限
if
(!
Objects
.
equals
(
resources
.
getDept
(),
user
.
getDept
()))
{
redisUtils
.
del
(
CacheKey
.
DATA_USER
+
resources
.
getId
());
}
// 如果用户被禁用,则清除用户登录信息
// 如果用户被禁用,则清除用户登录信息
if
(!
resources
.
getEnabled
()){
if
(!
resources
.
getEnabled
()){
onlineUserService
.
kickOutForUsername
(
resources
.
getUsername
());
onlineUserService
.
kickOutForUsername
(
resources
.
getUsername
());
...
...
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