mirror of https://github.com/elunez/eladmin
parent
22e6bdef8e
commit
d49aedda01
|
@ -19,9 +19,12 @@ import lombok.RequiredArgsConstructor;
|
|||
import me.zhengjie.modules.quartz.domain.QuartzJob;
|
||||
import me.zhengjie.modules.quartz.repository.QuartzJobRepository;
|
||||
import me.zhengjie.modules.quartz.utils.QuartzManage;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.ApplicationRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -31,19 +34,20 @@ import java.util.List;
|
|||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class JobRunner implements ApplicationRunner {
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(JobRunner.class);
|
||||
private final QuartzJobRepository quartzJobRepository;
|
||||
private final QuartzManage quartzManage;
|
||||
|
||||
/**
|
||||
* 项目启动时重新激活启用的定时任务
|
||||
*
|
||||
* @param applicationArguments /
|
||||
*/
|
||||
@Override
|
||||
public void run(ApplicationArguments applicationArguments){
|
||||
System.out.println("--------------------注入定时任务---------------------");
|
||||
public void run(ApplicationArguments applicationArguments) {
|
||||
log.info("--------------------注入定时任务---------------------");
|
||||
List<QuartzJob> quartzJobs = quartzJobRepository.findByIsPauseIsFalse();
|
||||
quartzJobs.forEach(quartzManage::addJob);
|
||||
System.out.println("--------------------定时任务注入完成---------------------");
|
||||
log.info("--------------------定时任务注入完成---------------------");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,10 +19,12 @@ package me.zhengjie.modules.security.config.bean;
|
|||
import com.wf.captcha.*;
|
||||
import com.wf.captcha.base.Captcha;
|
||||
import me.zhengjie.exception.BadConfigurationException;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 配置文件读取
|
||||
*
|
||||
* @author liaojinlong
|
||||
* @date loginCode.length0loginCode.length0/6/10 17:loginCode.length6
|
||||
*/
|
||||
|
@ -34,6 +36,10 @@ public class LoginProperties {
|
|||
private boolean singleLogin = false;
|
||||
|
||||
private LoginCode loginCode;
|
||||
/**
|
||||
* 用户登录信息缓存
|
||||
*/
|
||||
private boolean cacheEnable;
|
||||
|
||||
public boolean isSingleLogin() {
|
||||
return singleLogin;
|
||||
|
@ -51,6 +57,14 @@ public class LoginProperties {
|
|||
this.loginCode = loginCode;
|
||||
}
|
||||
|
||||
public boolean isCacheEnable() {
|
||||
return cacheEnable;
|
||||
}
|
||||
|
||||
public void setCacheEnable(boolean cacheEnable) {
|
||||
this.cacheEnable = cacheEnable;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取验证码生产类
|
||||
*
|
||||
|
|
|
@ -18,12 +18,12 @@ package me.zhengjie.modules.security.service;
|
|||
import lombok.RequiredArgsConstructor;
|
||||
import me.zhengjie.exception.BadRequestException;
|
||||
import me.zhengjie.exception.EntityNotFoundException;
|
||||
import me.zhengjie.modules.security.config.bean.LoginProperties;
|
||||
import me.zhengjie.modules.security.service.dto.JwtUserDto;
|
||||
import me.zhengjie.modules.system.service.DataService;
|
||||
import me.zhengjie.modules.system.service.RoleService;
|
||||
import me.zhengjie.modules.system.service.UserService;
|
||||
import me.zhengjie.modules.system.service.dto.UserDto;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -41,11 +41,10 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
|||
private final UserService userService;
|
||||
private final RoleService roleService;
|
||||
private final DataService dataService;
|
||||
@Value("${login.cache-enable:true}")
|
||||
private boolean enableCache = true;
|
||||
private final LoginProperties loginProperties;
|
||||
|
||||
public void setEnableCache(boolean enableCache) {
|
||||
this.enableCache = enableCache;
|
||||
this.loginProperties.setCacheEnable(enableCache);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -59,7 +58,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
|||
public JwtUserDto loadUserByUsername(String username) {
|
||||
boolean searchDb = true;
|
||||
JwtUserDto jwtUserDto = null;
|
||||
if (enableCache && userDtoCache.containsKey(username)) {
|
||||
if (loginProperties.isCacheEnable() && userDtoCache.containsKey(username)) {
|
||||
jwtUserDto = userDtoCache.get(username);
|
||||
searchDb = false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue