mirror of
				https://github.com/continew-org/continew-starter.git
				synced 2025-11-04 09:01:40 +08:00 
			
		
		
		
	refactor: 使用常量优化部分配置属性名
This commit is contained in:
		@@ -27,6 +27,7 @@ import org.springframework.context.annotation.Lazy;
 | 
			
		||||
import org.springframework.web.cors.CorsConfiguration;
 | 
			
		||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
 | 
			
		||||
import org.springframework.web.filter.CorsFilter;
 | 
			
		||||
import top.charles7c.continew.starter.core.constant.PropertiesConstants;
 | 
			
		||||
import top.charles7c.continew.starter.core.constant.StringConstants;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -39,7 +40,7 @@ import top.charles7c.continew.starter.core.constant.StringConstants;
 | 
			
		||||
@Lazy
 | 
			
		||||
@AutoConfiguration
 | 
			
		||||
@ConditionalOnWebApplication
 | 
			
		||||
@ConditionalOnProperty(prefix = "continew-starter.cors", name = "enabled", havingValue = "true")
 | 
			
		||||
@ConditionalOnProperty(prefix = PropertiesConstants.CORS, name = PropertiesConstants.ENABLED, havingValue = "true")
 | 
			
		||||
@EnableConfigurationProperties(CorsProperties.class)
 | 
			
		||||
public class CorsAutoConfiguration {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -18,6 +18,7 @@ package top.charles7c.continew.starter.core.autoconfigure.cors;
 | 
			
		||||
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import org.springframework.boot.context.properties.ConfigurationProperties;
 | 
			
		||||
import top.charles7c.continew.starter.core.constant.PropertiesConstants;
 | 
			
		||||
import top.charles7c.continew.starter.core.constant.StringConstants;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
@@ -31,7 +32,7 @@ import java.util.List;
 | 
			
		||||
 * @since 1.0.0
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
@ConfigurationProperties(prefix = "continew-starter.cors")
 | 
			
		||||
@ConfigurationProperties(PropertiesConstants.CORS)
 | 
			
		||||
public class CorsProperties {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -25,6 +25,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 | 
			
		||||
import org.springframework.context.annotation.Lazy;
 | 
			
		||||
import org.springframework.scheduling.annotation.AsyncConfigurer;
 | 
			
		||||
import org.springframework.scheduling.annotation.EnableAsync;
 | 
			
		||||
import top.charles7c.continew.starter.core.constant.PropertiesConstants;
 | 
			
		||||
import top.charles7c.continew.starter.core.exception.BaseException;
 | 
			
		||||
 | 
			
		||||
import java.util.Arrays;
 | 
			
		||||
@@ -42,7 +43,7 @@ import java.util.concurrent.ScheduledExecutorService;
 | 
			
		||||
@Lazy
 | 
			
		||||
@AutoConfiguration
 | 
			
		||||
@RequiredArgsConstructor
 | 
			
		||||
@ConditionalOnProperty(prefix = "continew-starter.thread-pool", name = "enabled", havingValue = "true")
 | 
			
		||||
@ConditionalOnProperty(prefix = PropertiesConstants.THREAD_POOL, name = PropertiesConstants.ENABLED, havingValue = "true")
 | 
			
		||||
@EnableAsync(proxyTargetClass = true)
 | 
			
		||||
public class AsyncAutoConfiguration implements AsyncConfigurer {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
 | 
			
		||||
import org.springframework.context.annotation.Bean;
 | 
			
		||||
import org.springframework.context.annotation.Lazy;
 | 
			
		||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 | 
			
		||||
import top.charles7c.continew.starter.core.constant.PropertiesConstants;
 | 
			
		||||
import top.charles7c.continew.starter.core.util.ExceptionUtils;
 | 
			
		||||
 | 
			
		||||
import java.util.concurrent.ScheduledExecutorService;
 | 
			
		||||
@@ -42,7 +43,7 @@ import java.util.concurrent.ThreadPoolExecutor;
 | 
			
		||||
@Slf4j
 | 
			
		||||
@Lazy
 | 
			
		||||
@AutoConfiguration
 | 
			
		||||
@ConditionalOnProperty(prefix = "continew-starter.thread-pool", name = "enabled", havingValue = "true")
 | 
			
		||||
@ConditionalOnProperty(prefix = PropertiesConstants.THREAD_POOL, name = PropertiesConstants.ENABLED, havingValue = "true")
 | 
			
		||||
@EnableConfigurationProperties(ThreadPoolProperties.class)
 | 
			
		||||
public class ThreadPoolAutoConfiguration {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -18,6 +18,7 @@ package top.charles7c.continew.starter.core.autoconfigure.threadpool;
 | 
			
		||||
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import org.springframework.boot.context.properties.ConfigurationProperties;
 | 
			
		||||
import top.charles7c.continew.starter.core.constant.PropertiesConstants;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 线程池配置属性
 | 
			
		||||
@@ -27,7 +28,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
 | 
			
		||||
 * @since 1.0.0
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
@ConfigurationProperties(prefix = "continew-starter.thread-pool")
 | 
			
		||||
@ConfigurationProperties(PropertiesConstants.THREAD_POOL)
 | 
			
		||||
public class ThreadPoolProperties {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,80 @@
 | 
			
		||||
/*
 | 
			
		||||
 * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
 | 
			
		||||
 * <p>
 | 
			
		||||
 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE 3.0;
 | 
			
		||||
 * you may not use this file except in compliance with the License.
 | 
			
		||||
 * You may obtain a copy of the License at
 | 
			
		||||
 * <p>
 | 
			
		||||
 * http://www.gnu.org/licenses/lgpl.html
 | 
			
		||||
 * <p>
 | 
			
		||||
 * 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 top.charles7c.continew.starter.core.constant;
 | 
			
		||||
 | 
			
		||||
import lombok.AccessLevel;
 | 
			
		||||
import lombok.NoArgsConstructor;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 配置属性相关常量
 | 
			
		||||
 *
 | 
			
		||||
 * @author Charles7c
 | 
			
		||||
 * @since 1.1.1
 | 
			
		||||
 */
 | 
			
		||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
 | 
			
		||||
public class PropertiesConstants {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * ContiNew Starter
 | 
			
		||||
     */
 | 
			
		||||
    public static final String CONTINEW_STARTER = "continew-starter";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 启用配置
 | 
			
		||||
     */
 | 
			
		||||
    public static final String ENABLED = "enabled";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 跨域配置
 | 
			
		||||
     */
 | 
			
		||||
    public static final String CORS = CONTINEW_STARTER + ".cors";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 线程池配置
 | 
			
		||||
     */
 | 
			
		||||
    public static final String THREAD_POOL = CONTINEW_STARTER + ".thread-pool";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 日志配置
 | 
			
		||||
     */
 | 
			
		||||
    public static final String LOG = CONTINEW_STARTER + ".log";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 存储配置
 | 
			
		||||
     */
 | 
			
		||||
    public static final String STORAGE = CONTINEW_STARTER + ".storage";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 本地存储配置
 | 
			
		||||
     */
 | 
			
		||||
    public static final String STORAGE_LOCAL = STORAGE + ".local";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 验证码配置
 | 
			
		||||
     */
 | 
			
		||||
    public static final String CAPTCHA = CONTINEW_STARTER + ".captcha";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 图形验证码配置
 | 
			
		||||
     */
 | 
			
		||||
    public static final String CAPTCHA_GRAPHIC = CAPTCHA + ".graphic";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 行为验证码配置
 | 
			
		||||
     */
 | 
			
		||||
    public static final String CAPTCHA_BEHAVIOR = CAPTCHA + ".behavior";
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user