Merge branch '1.1.x' into dev

This commit is contained in:
2024-01-11 21:20:34 +08:00
73 changed files with 1105 additions and 328 deletions

View File

@@ -36,6 +36,7 @@ import org.springframework.context.annotation.Import;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;
import top.charles7c.continew.starter.core.constant.PropertiesConstants;
import java.util.HashMap;
import java.util.Map;
@@ -50,7 +51,7 @@ import java.util.Properties;
@Slf4j
@AutoConfiguration
@RequiredArgsConstructor
@ConditionalOnProperty(prefix = "continew-starter.captcha.behavior", name = "enabled", havingValue = "true")
@ConditionalOnProperty(prefix = PropertiesConstants.CAPTCHA_BEHAVIOR, name = PropertiesConstants.ENABLED, havingValue = "true")
@EnableConfigurationProperties(BehaviorCaptchaProperties.class)
public class BehaviorCaptchaAutoConfiguration {
@@ -61,8 +62,7 @@ public class BehaviorCaptchaAutoConfiguration {
*/
@Configuration
@Import({BehaviorCaptchaCacheConfiguration.Redis.class, BehaviorCaptchaCacheConfiguration.Custom.class})
protected static class BehaviorCaptchaCacheAutoConfiguration {
}
protected static class BehaviorCaptchaCacheAutoConfiguration {}
/**
* 行为验证码服务接口
@@ -93,8 +93,8 @@ public class BehaviorCaptchaAutoConfiguration {
config.put(Const.CAPTCHA_FONT_SIZE, properties.getFontSize());
config.put(Const.CAPTCHA_FONT_STYLE, properties.getFontStyle());
config.put(Const.CAPTCHA_WORD_COUNT, 4);
if (StrUtil.startWith(properties.getJigsawBaseMapPath(), "classpath:")
|| StrUtil.startWith(properties.getPicClickBaseMapPath(), "classpath:")) {
if (StrUtil.startWith(properties.getJigsawBaseMapPath(), "classpath:") || StrUtil.startWith(properties
.getPicClickBaseMapPath(), "classpath:")) {
// 自定义 resources 目录下初始化底图
config.put(Const.CAPTCHA_INIT_ORIGINAL, true);
initializeBaseMap(properties.getJigsawBaseMapPath(), properties.getPicClickBaseMapPath());
@@ -109,9 +109,8 @@ public class BehaviorCaptchaAutoConfiguration {
* @param picClick 点选验证码底图路径
*/
private static void initializeBaseMap(String jigsaw, String picClick) {
ImageUtils.cacheBootImage(getResourcesImagesFile(jigsaw + "/original/*.png"),
getResourcesImagesFile(jigsaw + "/slidingBlock/*.png"),
getResourcesImagesFile(picClick + "/*.png"));
ImageUtils
.cacheBootImage(getResourcesImagesFile(jigsaw + "/original/*.png"), getResourcesImagesFile(jigsaw + "/slidingBlock/*.png"), getResourcesImagesFile(picClick + "/*.png"));
}
/**
@@ -138,6 +137,6 @@ public class BehaviorCaptchaAutoConfiguration {
@PostConstruct
public void postConstruct() {
log.info("[ContiNew Starter] - Auto Configuration 'Behavior Captcha' completed initialization.");
log.debug("[ContiNew Starter] - Auto Configuration 'Behavior Captcha' completed initialization.");
}
}

View File

@@ -33,6 +33,7 @@ import org.springframework.context.annotation.Bean;
import top.charles7c.continew.starter.cache.redisson.autoconfigure.RedissonAutoConfiguration;
import top.charles7c.continew.starter.captcha.behavior.enums.StorageType;
import top.charles7c.continew.starter.captcha.behavior.impl.BehaviorCaptchaCacheServiceImpl;
import top.charles7c.continew.starter.core.constant.PropertiesConstants;
/**
* 行为验证码缓存配置
@@ -49,10 +50,11 @@ abstract class BehaviorCaptchaCacheConfiguration {
*/
@ConditionalOnClass(RedisClient.class)
@AutoConfigureBefore(RedissonAutoConfiguration.class)
@ConditionalOnProperty(name = "continew-starter.captcha.behavior.cache-type", havingValue = "redis")
@ConditionalOnProperty(name = PropertiesConstants.CAPTCHA_BEHAVIOR + ".cache-type", havingValue = "redis")
static class Redis {
static {
CaptchaServiceFactory.cacheService.put(StorageType.REDIS.name().toLowerCase(), new BehaviorCaptchaCacheServiceImpl());
CaptchaServiceFactory.cacheService.put(StorageType.REDIS.name()
.toLowerCase(), new BehaviorCaptchaCacheServiceImpl());
log.debug("[ContiNew Starter] - Auto Configuration 'Behavior-CaptchaCache-Redis' completed initialization.");
}
}
@@ -60,7 +62,7 @@ abstract class BehaviorCaptchaCacheConfiguration {
/**
* 自定义缓存实现类-自定义
*/
@ConditionalOnProperty(name = "continew-starter.captcha.behavior.cache-type", havingValue = "custom")
@ConditionalOnProperty(name = PropertiesConstants.CAPTCHA_BEHAVIOR + ".cache-type", havingValue = "custom")
static class Custom {
@Bean
@@ -71,7 +73,8 @@ abstract class BehaviorCaptchaCacheConfiguration {
@PostConstruct
public void postConstruct() {
CaptchaServiceFactory.cacheService.put(StorageType.CUSTOM.name().toLowerCase(), SpringUtil.getBean(CaptchaCacheService.class));
CaptchaServiceFactory.cacheService.put(StorageType.CUSTOM.name().toLowerCase(), SpringUtil
.getBean(CaptchaCacheService.class));
log.debug("[ContiNew Starter] - Auto Configuration 'Behavior-CaptchaCache-Custom' completed initialization.");
}
}

View File

@@ -21,6 +21,7 @@ import com.anji.captcha.service.CaptchaCacheService;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import top.charles7c.continew.starter.captcha.behavior.enums.StorageType;
import top.charles7c.continew.starter.core.constant.PropertiesConstants;
import java.awt.*;
@@ -31,7 +32,7 @@ import java.awt.*;
* @since 1.1.0
*/
@Data
@ConfigurationProperties(prefix = "continew-starter.captcha.behavior")
@ConfigurationProperties(PropertiesConstants.CAPTCHA_BEHAVIOR)
public class BehaviorCaptchaProperties {
/**

View File

@@ -21,6 +21,7 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import top.charles7c.continew.starter.core.constant.PropertiesConstants;
/**
* 图形验证码自动配置
@@ -31,11 +32,11 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
@Slf4j
@AutoConfiguration
@EnableConfigurationProperties(GraphicCaptchaProperties.class)
@ConditionalOnProperty(prefix = "continew-starter.captcha.graphic", name = "enabled", havingValue = "true")
@ConditionalOnProperty(prefix = PropertiesConstants.CAPTCHA_GRAPHIC, name = PropertiesConstants.ENABLED, havingValue = "true")
public class GraphicCaptchaAutoConfiguration {
@PostConstruct
public void postConstruct() {
log.info("[ContiNew Starter] - Auto Configuration 'Graphic Captcha' completed initialization.");
log.debug("[ContiNew Starter] - Auto Configuration 'Graphic Captcha' completed initialization.");
}
}

View File

@@ -22,6 +22,7 @@ import com.wf.captcha.base.Captcha;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import top.charles7c.continew.starter.captcha.graphic.enums.GraphicCaptchaType;
import top.charles7c.continew.starter.core.constant.PropertiesConstants;
import java.awt.*;
@@ -32,7 +33,7 @@ import java.awt.*;
* @since 1.0.0
*/
@Data
@ConfigurationProperties(prefix = "continew-starter.captcha.graphic")
@ConfigurationProperties(PropertiesConstants.CAPTCHA_GRAPHIC)
public class GraphicCaptchaProperties {
/**

View File

@@ -54,8 +54,7 @@ public enum GraphicCaptchaType {
/**
* 特殊类型
*/
SPEC(SpecCaptcha.class),
;
SPEC(SpecCaptcha.class),;
/**
* 验证码实现