mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-11-04 10:57:10 +08:00 
			
		
		
		
	Merge branch 'dev' into 2.0.x
# Conflicts: # README.md
This commit is contained in:
		@@ -16,9 +16,8 @@
 | 
			
		||||
 | 
			
		||||
package top.charles7c.cnadmin.common.config.properties;
 | 
			
		||||
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
import org.springframework.stereotype.Component;
 | 
			
		||||
import lombok.AccessLevel;
 | 
			
		||||
import lombok.NoArgsConstructor;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.extra.spring.SpringUtil;
 | 
			
		||||
 | 
			
		||||
@@ -29,8 +28,7 @@ import cn.hutool.extra.spring.SpringUtil;
 | 
			
		||||
 * @author Charles7c
 | 
			
		||||
 * @since 2022/12/21 20:21
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
@Component
 | 
			
		||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
 | 
			
		||||
public class RsaProperties {
 | 
			
		||||
 | 
			
		||||
    /** 私钥 */
 | 
			
		||||
 
 | 
			
		||||
@@ -20,11 +20,11 @@ import java.util.concurrent.ScheduledExecutorService;
 | 
			
		||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
 | 
			
		||||
import java.util.concurrent.ThreadPoolExecutor;
 | 
			
		||||
 | 
			
		||||
import lombok.RequiredArgsConstructor;
 | 
			
		||||
import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
 | 
			
		||||
import org.apache.commons.lang3.concurrent.BasicThreadFactory;
 | 
			
		||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 | 
			
		||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
 | 
			
		||||
import org.springframework.context.annotation.Bean;
 | 
			
		||||
import org.springframework.context.annotation.Configuration;
 | 
			
		||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 | 
			
		||||
@@ -40,10 +40,9 @@ import top.charles7c.cnadmin.common.util.ExceptionUtils;
 | 
			
		||||
 */
 | 
			
		||||
@Slf4j
 | 
			
		||||
@Configuration
 | 
			
		||||
@RequiredArgsConstructor
 | 
			
		||||
@EnableConfigurationProperties(ThreadPoolProperties.class)
 | 
			
		||||
public class ThreadPoolConfiguration {
 | 
			
		||||
 | 
			
		||||
    private final ThreadPoolProperties threadPoolProperties;
 | 
			
		||||
    /** 核心(最小)线程数 = CPU 核心数 + 1 */
 | 
			
		||||
    private final int corePoolSize = Runtime.getRuntime().availableProcessors() + 1;
 | 
			
		||||
 | 
			
		||||
@@ -52,7 +51,7 @@ public class ThreadPoolConfiguration {
 | 
			
		||||
     */
 | 
			
		||||
    @Bean
 | 
			
		||||
    @ConditionalOnProperty(prefix = "thread-pool", name = "enabled", havingValue = "true")
 | 
			
		||||
    public ThreadPoolTaskExecutor threadPoolTaskExecutor() {
 | 
			
		||||
    public ThreadPoolTaskExecutor threadPoolTaskExecutor(ThreadPoolProperties threadPoolProperties) {
 | 
			
		||||
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
 | 
			
		||||
        // 核心(最小)线程数
 | 
			
		||||
        executor.setCorePoolSize(corePoolSize);
 | 
			
		||||
 
 | 
			
		||||
@@ -19,7 +19,6 @@ package top.charles7c.cnadmin.common.config.threadpool;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
 | 
			
		||||
import org.springframework.boot.context.properties.ConfigurationProperties;
 | 
			
		||||
import org.springframework.stereotype.Component;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 线程池配置属性
 | 
			
		||||
@@ -29,7 +28,6 @@ import org.springframework.stereotype.Component;
 | 
			
		||||
 * @since 2022/12/23 23:06
 | 
			
		||||
 */
 | 
			
		||||
@Data
 | 
			
		||||
@Component
 | 
			
		||||
@ConfigurationProperties(prefix = "thread-pool")
 | 
			
		||||
public class ThreadPoolProperties {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -45,6 +45,11 @@ public class StringConsts implements StrPool {
 | 
			
		||||
     */
 | 
			
		||||
    public static final String ASTERISK = "*";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 问号
 | 
			
		||||
     */
 | 
			
		||||
    public static final String QUESTION_MARK = "?";
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 中文逗号
 | 
			
		||||
     */
 | 
			
		||||
 
 | 
			
		||||
@@ -25,6 +25,8 @@ import lombok.AccessLevel;
 | 
			
		||||
import lombok.NoArgsConstructor;
 | 
			
		||||
import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
 | 
			
		||||
import top.charles7c.cnadmin.common.constant.StringConsts;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 异常工具类
 | 
			
		||||
 *
 | 
			
		||||
@@ -98,7 +100,7 @@ public class ExceptionUtils {
 | 
			
		||||
     * @return /
 | 
			
		||||
     */
 | 
			
		||||
    public static String exToBlank(ExSupplier<String> exSupplier) {
 | 
			
		||||
        return exToDefault(exSupplier, "");
 | 
			
		||||
        return exToDefault(exSupplier, StringConsts.EMPTY);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -24,6 +24,7 @@ import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
 | 
			
		||||
import cn.hutool.core.util.StrUtil;
 | 
			
		||||
 | 
			
		||||
import top.charles7c.cnadmin.common.constant.StringConsts;
 | 
			
		||||
import top.charles7c.cnadmin.common.exception.ServiceException;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -52,8 +53,8 @@ public class CheckUtils extends Validator {
 | 
			
		||||
     *            字段值
 | 
			
		||||
     */
 | 
			
		||||
    public static void throwIfNotExists(Object obj, String entityName, String fieldName, Object fieldValue) {
 | 
			
		||||
        String message =
 | 
			
		||||
            String.format("%s 为 [%s] 的 %s 记录已不存在", fieldName, fieldValue, StrUtil.replace(entityName, "DO", ""));
 | 
			
		||||
        String message = String.format("%s 为 [%s] 的 %s 记录已不存在", fieldName, fieldValue,
 | 
			
		||||
            StrUtil.replace(entityName, "DO", StringConsts.EMPTY));
 | 
			
		||||
        throwIfNull(obj, message, EXCEPTION_TYPE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user