refactor: 移除AuditorConfig和BadConfigurationException类
This commit is contained in:
parent
7b37a94027
commit
987c5ec779
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019-2020 Zheng Jie
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package me.zhengjie.config;
|
|
||||||
|
|
||||||
import me.zhengjie.utils.SecurityUtils;
|
|
||||||
import org.springframework.data.domain.AuditorAware;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @description : 设置审计
|
|
||||||
* @author : Dong ZhaoYang
|
|
||||||
* @date : 2019/10/28
|
|
||||||
*/
|
|
||||||
@Component("auditorAware")
|
|
||||||
public class AuditorConfig implements AuditorAware<String> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回操作员标志信息
|
|
||||||
*
|
|
||||||
* @return /
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Optional<String> getCurrentAuditor() {
|
|
||||||
try {
|
|
||||||
// 这里应根据实际业务情况获取具体信息
|
|
||||||
return Optional.of(SecurityUtils.getCurrentUsername());
|
|
||||||
}catch (Exception ignored){}
|
|
||||||
// 用户定时任务,或者无Token调用的情况
|
|
||||||
return Optional.of("System");
|
|
||||||
}
|
|
||||||
}
|
|
@ -21,7 +21,7 @@ import org.springframework.stereotype.Component;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Zheng Jie
|
* @author Zheng Jie
|
||||||
* @website https://eladmin.vip
|
* @website <a href="https://eladmin.vip">...</a>
|
||||||
* @description
|
* @description
|
||||||
* @date 2020-05-18
|
* @date 2020-05-18
|
||||||
**/
|
**/
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package me.zhengjie.config;
|
package me.zhengjie.config.mybatis;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.p6spy.engine.spy.appender.MessageFormattingStrategy;
|
import com.p6spy.engine.spy.appender.MessageFormattingStrategy;
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package me.zhengjie.config;
|
package me.zhengjie.config.webmvc;
|
||||||
|
|
||||||
import org.springframework.boot.web.servlet.MultipartConfigFactory;
|
import org.springframework.boot.web.servlet.MultipartConfigFactory;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
@ -13,7 +13,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package me.zhengjie.config;
|
package me.zhengjie.config.webmvc;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
@ -1,98 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2019-2020 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package me.zhengjie.exception;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 统一关于错误配置信息 异常
|
|
||||||
*
|
|
||||||
* @author: liaojinlong
|
|
||||||
* @date: 2020/6/10 18:06
|
|
||||||
*/
|
|
||||||
public class BadConfigurationException extends RuntimeException {
|
|
||||||
/**
|
|
||||||
* Constructs a new runtime exception with {@code null} as its
|
|
||||||
* detail message. The cause is not initialized, and may subsequently be
|
|
||||||
* initialized by a call to {@link #initCause}.
|
|
||||||
*/
|
|
||||||
public BadConfigurationException() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new runtime exception with the specified detail message.
|
|
||||||
* The cause is not initialized, and may subsequently be initialized by a
|
|
||||||
* call to {@link #initCause}.
|
|
||||||
*
|
|
||||||
* @param message the detail message. The detail message is saved for
|
|
||||||
* later retrieval by the {@link #getMessage()} method.
|
|
||||||
*/
|
|
||||||
public BadConfigurationException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new runtime exception with the specified detail message and
|
|
||||||
* cause. <p>Note that the detail message associated with
|
|
||||||
* {@code cause} is <i>not</i> automatically incorporated in
|
|
||||||
* this runtime exception's detail message.
|
|
||||||
*
|
|
||||||
* @param message the detail message (which is saved for later retrieval
|
|
||||||
* by the {@link #getMessage()} method).
|
|
||||||
* @param cause the cause (which is saved for later retrieval by the
|
|
||||||
* {@link #getCause()} method). (A {@code null} value is
|
|
||||||
* permitted, and indicates that the cause is nonexistent or
|
|
||||||
* unknown.)
|
|
||||||
* @since 1.4
|
|
||||||
*/
|
|
||||||
public BadConfigurationException(String message, Throwable cause) {
|
|
||||||
super(message, cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new runtime exception with the specified cause and a
|
|
||||||
* detail message of {@code (cause==null ? null : cause.toString())}
|
|
||||||
* (which typically contains the class and detail message of
|
|
||||||
* {@code cause}). This constructor is useful for runtime exceptions
|
|
||||||
* that are little more than wrappers for other throwables.
|
|
||||||
*
|
|
||||||
* @param cause the cause (which is saved for later retrieval by the
|
|
||||||
* {@link #getCause()} method). (A {@code null} value is
|
|
||||||
* permitted, and indicates that the cause is nonexistent or
|
|
||||||
* unknown.)
|
|
||||||
* @since 1.4
|
|
||||||
*/
|
|
||||||
public BadConfigurationException(Throwable cause) {
|
|
||||||
super(cause);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new runtime exception with the specified detail
|
|
||||||
* message, cause, suppression enabled or disabled, and writable
|
|
||||||
* stack trace enabled or disabled.
|
|
||||||
*
|
|
||||||
* @param message the detail message.
|
|
||||||
* @param cause the cause. (A {@code null} value is permitted,
|
|
||||||
* and indicates that the cause is nonexistent or unknown.)
|
|
||||||
* @param enableSuppression whether or not suppression is enabled
|
|
||||||
* or disabled
|
|
||||||
* @param writableStackTrace whether or not the stack trace should
|
|
||||||
* be writable
|
|
||||||
* @since 1.7
|
|
||||||
*/
|
|
||||||
protected BadConfigurationException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
|
||||||
super(message, cause, enableSuppression, writableStackTrace);
|
|
||||||
}
|
|
||||||
}
|
|
@ -22,7 +22,7 @@ import lombok.Data;
|
|||||||
* @date 2018-11-23
|
* @date 2018-11-23
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
class ApiError {
|
public class ApiError {
|
||||||
|
|
||||||
private Integer status = 400;
|
private Integer status = 400;
|
||||||
private Long timestamp;
|
private Long timestamp;
|
||||||
|
@ -20,7 +20,7 @@ package me.zhengjie.utils;
|
|||||||
* @author: liaojinlong
|
* @author: liaojinlong
|
||||||
* @date: 2020/6/9 17:02
|
* @date: 2020/6/9 17:02
|
||||||
* @since: 1.0
|
* @since: 1.0
|
||||||
* @see {@link SpringContextHolder}
|
* @see {@link SpringBeanHolder}
|
||||||
* 针对某些初始化方法,在SpringContextHolder 初始化前时,<br>
|
* 针对某些初始化方法,在SpringContextHolder 初始化前时,<br>
|
||||||
* 可提交一个 提交回调任务。<br>
|
* 可提交一个 提交回调任务。<br>
|
||||||
* 在SpringContextHolder 初始化后,进行回调使用
|
* 在SpringContextHolder 初始化后,进行回调使用
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
package me.zhengjie.utils;
|
package me.zhengjie.utils;
|
||||||
|
|
||||||
import lombok.AccessLevel;
|
import lombok.*;
|
||||||
import lombok.Getter;
|
import java.io.Serializable;
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Getter
|
@Data
|
||||||
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
@NoArgsConstructor
|
||||||
public class PageResult<T> {
|
@AllArgsConstructor
|
||||||
|
public class PageResult<T> implements Serializable {
|
||||||
|
|
||||||
private final List<T> content;
|
private List<T> content;
|
||||||
|
|
||||||
private final long totalElements;
|
private long totalElements;
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ public class SecurityUtils {
|
|||||||
* @return UserDetails
|
* @return UserDetails
|
||||||
*/
|
*/
|
||||||
public static UserDetails getCurrentUser() {
|
public static UserDetails getCurrentUser() {
|
||||||
UserDetailsService userDetailsService = SpringContextHolder.getBean(UserDetailsService.class);
|
UserDetailsService userDetailsService = SpringBeanHolder.getBean(UserDetailsService.class);
|
||||||
return userDetailsService.loadUserByUsername(getCurrentUsername());
|
return userDetailsService.loadUserByUsername(getCurrentUsername());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ import java.util.List;
|
|||||||
* @date 2019-01-07
|
* @date 2019-01-07
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class SpringContextHolder implements ApplicationContextAware, DisposableBean {
|
public class SpringBeanHolder implements ApplicationContextAware, DisposableBean {
|
||||||
|
|
||||||
private static ApplicationContext applicationContext = null;
|
private static ApplicationContext applicationContext = null;
|
||||||
private static final List<CallBack> CALL_BACKS = new ArrayList<>();
|
private static final List<CallBack> CALL_BACKS = new ArrayList<>();
|
||||||
@ -45,7 +45,7 @@ public class SpringContextHolder implements ApplicationContextAware, DisposableB
|
|||||||
*/
|
*/
|
||||||
public synchronized static void addCallBacks(CallBack callBack) {
|
public synchronized static void addCallBacks(CallBack callBack) {
|
||||||
if (addCallback) {
|
if (addCallback) {
|
||||||
SpringContextHolder.CALL_BACKS.add(callBack);
|
SpringBeanHolder.CALL_BACKS.add(callBack);
|
||||||
} else {
|
} else {
|
||||||
log.warn("CallBack:{} 已无法添加!立即执行", callBack.getCallBackName());
|
log.warn("CallBack:{} 已无法添加!立即执行", callBack.getCallBackName());
|
||||||
callBack.executor();
|
callBack.executor();
|
||||||
@ -127,22 +127,22 @@ public class SpringContextHolder implements ApplicationContextAware, DisposableB
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
SpringContextHolder.clearHolder();
|
SpringBeanHolder.clearHolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||||
if (SpringContextHolder.applicationContext != null) {
|
if (SpringBeanHolder.applicationContext != null) {
|
||||||
log.warn("SpringContextHolder中的ApplicationContext被覆盖, 原有ApplicationContext为:" + SpringContextHolder.applicationContext);
|
log.warn("SpringContextHolder中的ApplicationContext被覆盖, 原有ApplicationContext为:" + SpringBeanHolder.applicationContext);
|
||||||
}
|
}
|
||||||
SpringContextHolder.applicationContext = applicationContext;
|
SpringBeanHolder.applicationContext = applicationContext;
|
||||||
if (addCallback) {
|
if (addCallback) {
|
||||||
for (CallBack callBack : SpringContextHolder.CALL_BACKS) {
|
for (CallBack callBack : SpringBeanHolder.CALL_BACKS) {
|
||||||
callBack.executor();
|
callBack.executor();
|
||||||
}
|
}
|
||||||
CALL_BACKS.clear();
|
CALL_BACKS.clear();
|
||||||
}
|
}
|
||||||
SpringContextHolder.addCallback = false;
|
SpringBeanHolder.addCallback = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
@ -41,7 +41,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
|
|||||||
/**
|
/**
|
||||||
* 注入bean
|
* 注入bean
|
||||||
*/
|
*/
|
||||||
private final static Ip2regionSearcher IP_SEARCHER = SpringContextHolder.getBean(Ip2regionSearcher.class);
|
private final static Ip2regionSearcher IP_SEARCHER = SpringBeanHolder.getBean(Ip2regionSearcher.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 驼峰命名法工具
|
* 驼峰命名法工具
|
||||||
|
@ -18,7 +18,7 @@ package me.zhengjie;
|
|||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import me.zhengjie.annotation.rest.AnonymousGetMapping;
|
import me.zhengjie.annotation.rest.AnonymousGetMapping;
|
||||||
import me.zhengjie.utils.SpringContextHolder;
|
import me.zhengjie.utils.SpringBeanHolder;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.boot.context.ApplicationPidFileWriter;
|
import org.springframework.boot.context.ApplicationPidFileWriter;
|
||||||
@ -53,8 +53,8 @@ public class AppRun {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public SpringContextHolder springContextHolder() {
|
public SpringBeanHolder springContextHolder() {
|
||||||
return new SpringContextHolder();
|
return new SpringBeanHolder();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +27,7 @@ import me.zhengjie.modules.quartz.domain.QuartzLog;
|
|||||||
import me.zhengjie.modules.quartz.service.QuartzJobService;
|
import me.zhengjie.modules.quartz.service.QuartzJobService;
|
||||||
import me.zhengjie.modules.quartz.domain.vo.QuartzJobQueryCriteria;
|
import me.zhengjie.modules.quartz.domain.vo.QuartzJobQueryCriteria;
|
||||||
import me.zhengjie.utils.PageResult;
|
import me.zhengjie.utils.PageResult;
|
||||||
import me.zhengjie.utils.SpringContextHolder;
|
import me.zhengjie.utils.SpringBeanHolder;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
@ -134,7 +134,7 @@ public class QuartzJobController {
|
|||||||
private void checkBean(String beanName){
|
private void checkBean(String beanName){
|
||||||
// 避免调用攻击者可以从SpringContextHolder获得控制jdbcTemplate类
|
// 避免调用攻击者可以从SpringContextHolder获得控制jdbcTemplate类
|
||||||
// 并使用getDeclaredMethod调用jdbcTemplate的queryForMap函数,执行任意sql命令。
|
// 并使用getDeclaredMethod调用jdbcTemplate的queryForMap函数,执行任意sql命令。
|
||||||
if(!SpringContextHolder.getAllServiceBeanName().contains(beanName)){
|
if(!SpringBeanHolder.getAllServiceBeanName().contains(beanName)){
|
||||||
throw new BadRequestException("非法的 Bean,请重新输入!");
|
throw new BadRequestException("非法的 Bean,请重新输入!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ import me.zhengjie.modules.quartz.mapper.QuartzLogMapper;
|
|||||||
import me.zhengjie.modules.quartz.service.QuartzJobService;
|
import me.zhengjie.modules.quartz.service.QuartzJobService;
|
||||||
import me.zhengjie.service.EmailService;
|
import me.zhengjie.service.EmailService;
|
||||||
import me.zhengjie.utils.RedisUtils;
|
import me.zhengjie.utils.RedisUtils;
|
||||||
import me.zhengjie.utils.SpringContextHolder;
|
import me.zhengjie.utils.SpringBeanHolder;
|
||||||
import me.zhengjie.utils.StringUtils;
|
import me.zhengjie.utils.StringUtils;
|
||||||
import me.zhengjie.utils.ThrowableUtil;
|
import me.zhengjie.utils.ThrowableUtil;
|
||||||
import org.quartz.JobExecutionContext;
|
import org.quartz.JobExecutionContext;
|
||||||
@ -49,16 +49,16 @@ public class ExecutionJob extends QuartzJobBean {
|
|||||||
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
private final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||||
|
|
||||||
// 此处仅供参考,可根据任务执行情况自定义线程池参数
|
// 此处仅供参考,可根据任务执行情况自定义线程池参数
|
||||||
private final ThreadPoolTaskExecutor executor = SpringContextHolder.getBean("elAsync");
|
private final ThreadPoolTaskExecutor executor = SpringBeanHolder.getBean("elAsync");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void executeInternal(JobExecutionContext context) {
|
public void executeInternal(JobExecutionContext context) {
|
||||||
// 获取任务
|
// 获取任务
|
||||||
QuartzJob quartzJob = (QuartzJob) context.getMergedJobDataMap().get(QuartzJob.JOB_KEY);
|
QuartzJob quartzJob = (QuartzJob) context.getMergedJobDataMap().get(QuartzJob.JOB_KEY);
|
||||||
// 获取spring bean
|
// 获取spring bean
|
||||||
QuartzLogMapper quartzLogMapper = SpringContextHolder.getBean(QuartzLogMapper.class);
|
QuartzLogMapper quartzLogMapper = SpringBeanHolder.getBean(QuartzLogMapper.class);
|
||||||
QuartzJobService quartzJobService = SpringContextHolder.getBean(QuartzJobService.class);
|
QuartzJobService quartzJobService = SpringBeanHolder.getBean(QuartzJobService.class);
|
||||||
RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class);
|
RedisUtils redisUtils = SpringBeanHolder.getBean(RedisUtils.class);
|
||||||
|
|
||||||
String uuid = quartzJob.getUuid();
|
String uuid = quartzJob.getUuid();
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ public class ExecutionJob extends QuartzJobBean {
|
|||||||
quartzJobService.updateIsPause(quartzJob);
|
quartzJobService.updateIsPause(quartzJob);
|
||||||
}
|
}
|
||||||
if(quartzJob.getEmail() != null){
|
if(quartzJob.getEmail() != null){
|
||||||
EmailService emailService = SpringContextHolder.getBean(EmailService.class);
|
EmailService emailService = SpringBeanHolder.getBean(EmailService.class);
|
||||||
// 邮箱报警
|
// 邮箱报警
|
||||||
if(StringUtils.isNoneBlank(quartzJob.getEmail())){
|
if(StringUtils.isNoneBlank(quartzJob.getEmail())){
|
||||||
EmailVo emailVo = taskAlarm(quartzJob, ThrowableUtil.getStackTrace(e));
|
EmailVo emailVo = taskAlarm(quartzJob, ThrowableUtil.getStackTrace(e));
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
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.utils.SpringContextHolder;
|
import me.zhengjie.utils.SpringBeanHolder;
|
||||||
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;
|
||||||
@ -35,7 +35,7 @@ public class QuartzRunnable implements Callable<Object> {
|
|||||||
|
|
||||||
QuartzRunnable(String beanName, String methodName, String params)
|
QuartzRunnable(String beanName, String methodName, String params)
|
||||||
throws NoSuchMethodException, SecurityException {
|
throws NoSuchMethodException, SecurityException {
|
||||||
this.target = SpringContextHolder.getBean(beanName);
|
this.target = SpringBeanHolder.getBean(beanName);
|
||||||
this.params = params;
|
this.params = params;
|
||||||
if (StringUtils.isNotBlank(params)) {
|
if (StringUtils.isNotBlank(params)) {
|
||||||
this.method = target.getClass().getDeclaredMethod(methodName, String.class);
|
this.method = target.getClass().getDeclaredMethod(methodName, String.class);
|
||||||
|
@ -18,7 +18,8 @@ package me.zhengjie.modules.security.config.bean;
|
|||||||
import com.wf.captcha.*;
|
import com.wf.captcha.*;
|
||||||
import com.wf.captcha.base.Captcha;
|
import com.wf.captcha.base.Captcha;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import me.zhengjie.exception.BadConfigurationException;
|
import lombok.Getter;
|
||||||
|
import me.zhengjie.exception.BadRequestException;
|
||||||
import me.zhengjie.utils.StringUtils;
|
import me.zhengjie.utils.StringUtils;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@ -35,16 +36,13 @@ public class LoginProperties {
|
|||||||
/**
|
/**
|
||||||
* 账号单用户 登录
|
* 账号单用户 登录
|
||||||
*/
|
*/
|
||||||
|
@Getter
|
||||||
private boolean singleLogin = false;
|
private boolean singleLogin = false;
|
||||||
|
|
||||||
private LoginCode loginCode;
|
private LoginCode loginCode;
|
||||||
|
|
||||||
public static final String cacheKey = "user-login-cache:";
|
public static final String cacheKey = "user-login-cache:";
|
||||||
|
|
||||||
public boolean isSingleLogin() {
|
|
||||||
return singleLogin;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取验证码生产类
|
* 获取验证码生产类
|
||||||
*
|
*
|
||||||
@ -92,7 +90,7 @@ public class LoginProperties {
|
|||||||
captcha.setLen(loginCode.getLength());
|
captcha.setLen(loginCode.getLength());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new BadConfigurationException("验证码配置信息错误!正确配置查看 LoginCodeEnum ");
|
throw new BadRequestException("验证码配置信息错误!正确配置查看 LoginCodeEnum ");
|
||||||
}
|
}
|
||||||
if(StringUtils.isNotBlank(loginCode.getFontName())){
|
if(StringUtils.isNotBlank(loginCode.getFontName())){
|
||||||
captcha.setFont(new Font(loginCode.getFontName(), Font.PLAIN, loginCode.getFontSize()));
|
captcha.setFont(new Font(loginCode.getFontName(), Font.PLAIN, loginCode.getFontSize()));
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# 应用的拦截模块
|
# 应用的拦截模块
|
||||||
modulelist=com.baomidou.mybatisplus.extension.p6spy.MybatisPlusLogFactory,com.p6spy.engine.outage.P6OutageFactory
|
modulelist=com.baomidou.mybatisplus.extension.p6spy.MybatisPlusLogFactory,com.p6spy.engine.outage.P6OutageFactory
|
||||||
# 自定义日志打印
|
# 自定义日志打印
|
||||||
logMessageFormat=me.zhengjie.config.CustomP6SpyLogger
|
logMessageFormat=me.zhengjie.config.mybatis.CustomP6SpyLogger
|
||||||
# 日志输出到控制台
|
# 日志输出到控制台
|
||||||
appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger
|
appender=com.baomidou.mybatisplus.extension.p6spy.StdoutLogger
|
||||||
# 日期格式
|
# 日期格式
|
||||||
|
Loading…
Reference in New Issue
Block a user