mirror of
				https://github.com/continew-org/continew-starter.git
				synced 2025-11-04 09:01:40 +08:00 
			
		
		
		
	refactor: 优化部分代码
修复 Sonar 扫描问题
This commit is contained in:
		@@ -3,9 +3,15 @@
 | 
				
			|||||||
<a href="https://github.com/Charles7c/continew-starter/blob/dev/LICENSE" target="_blank">
 | 
					<a href="https://github.com/Charles7c/continew-starter/blob/dev/LICENSE" target="_blank">
 | 
				
			||||||
<img src="https://img.shields.io/badge/License-LGPL--3.0-blue.svg" alt="License" />
 | 
					<img src="https://img.shields.io/badge/License-LGPL--3.0-blue.svg" alt="License" />
 | 
				
			||||||
</a>
 | 
					</a>
 | 
				
			||||||
 | 
					<a href="https://central.sonatype.com/search?q=continew-starter" target="_blank">
 | 
				
			||||||
 | 
					<img src="https://img.shields.io/maven-central/v/top.charles7c.continew/continew-starter.svg?label=Maven%20Central" alt="Release" />
 | 
				
			||||||
 | 
					</a>
 | 
				
			||||||
<a href="https://github.com/Charles7c/continew-starter" target="_blank">
 | 
					<a href="https://github.com/Charles7c/continew-starter" target="_blank">
 | 
				
			||||||
<img src="https://img.shields.io/badge/SNAPSHOT-v1.3.0-%23ff3f59.svg" alt="Release" />
 | 
					<img src="https://img.shields.io/badge/SNAPSHOT-v1.3.0-%23ff3f59.svg" alt="Release" />
 | 
				
			||||||
</a>
 | 
					</a>
 | 
				
			||||||
 | 
					<a href="https://app.codacy.com/gh/Charles7c/continew-starter/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade" target="_blank">
 | 
				
			||||||
 | 
					<img src="https://app.codacy.com/project/badge/Grade/90ed633957a9410aa8745f0654827c01" alt="Codacy Badge" />
 | 
				
			||||||
 | 
					</a>
 | 
				
			||||||
<a href="https://sonarcloud.io/summary/new_code?id=Charles7c_continew-starter" target="_blank">
 | 
					<a href="https://sonarcloud.io/summary/new_code?id=Charles7c_continew-starter" target="_blank">
 | 
				
			||||||
<img src="https://sonarcloud.io/api/project_badges/measure?project=Charles7c_continew-starter&metric=alert_status" alt="Sonar Status" />
 | 
					<img src="https://sonarcloud.io/api/project_badges/measure?project=Charles7c_continew-starter&metric=alert_status" alt="Sonar Status" />
 | 
				
			||||||
</a>
 | 
					</a>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,7 +17,6 @@
 | 
				
			|||||||
package top.charles7c.continew.starter.core.autoconfigure.password;
 | 
					package top.charles7c.continew.starter.core.autoconfigure.password;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import cn.hutool.core.collection.CollUtil;
 | 
					import cn.hutool.core.collection.CollUtil;
 | 
				
			||||||
import cn.hutool.core.util.StrUtil;
 | 
					 | 
				
			||||||
import jakarta.annotation.PostConstruct;
 | 
					import jakarta.annotation.PostConstruct;
 | 
				
			||||||
import org.slf4j.Logger;
 | 
					import org.slf4j.Logger;
 | 
				
			||||||
import org.slf4j.LoggerFactory;
 | 
					import org.slf4j.LoggerFactory;
 | 
				
			||||||
@@ -38,7 +37,7 @@ import java.util.List;
 | 
				
			|||||||
import java.util.Map;
 | 
					import java.util.Map;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * 密码编解码自动配置
 | 
					 * 密码编码器自动配置
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
 * <p>
 | 
					 * <p>
 | 
				
			||||||
 * 密码配置类,默认编解码器使用的是 BCryptPasswordEncoder <br />
 | 
					 * 密码配置类,默认编解码器使用的是 BCryptPasswordEncoder <br />
 | 
				
			||||||
@@ -63,20 +62,15 @@ public class PasswordEncoderAutoConfiguration {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 密码加密解密
 | 
					     * 密码编码器
 | 
				
			||||||
     *
 | 
					     *
 | 
				
			||||||
     * @see DelegatingPasswordEncoder
 | 
					     * @see DelegatingPasswordEncoder
 | 
				
			||||||
     * @see PasswordEncoderFactories
 | 
					     * @see PasswordEncoderFactories
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    @Bean
 | 
					    @Bean
 | 
				
			||||||
    public PasswordEncoder passwordEncoder(List<PasswordEncoder> passwordEncoderList) {
 | 
					    public PasswordEncoder passwordEncoder(List<PasswordEncoder> passwordEncoderList) {
 | 
				
			||||||
        String encodingId = "bcrypt";
 | 
					 | 
				
			||||||
        if (StrUtil.isNotBlank(properties.getEncodingId())) {
 | 
					 | 
				
			||||||
            encodingId = properties.getEncodingId();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        Map<String, PasswordEncoder> encoders = new HashMap<>();
 | 
					        Map<String, PasswordEncoder> encoders = new HashMap<>();
 | 
				
			||||||
        encoders.put(encodingId, new BCryptPasswordEncoder());
 | 
					        encoders.put("bcrypt", new BCryptPasswordEncoder());
 | 
				
			||||||
        encoders.put("ldap", new org.springframework.security.crypto.password.LdapShaPasswordEncoder());
 | 
					        encoders.put("ldap", new org.springframework.security.crypto.password.LdapShaPasswordEncoder());
 | 
				
			||||||
        encoders.put("MD4", new org.springframework.security.crypto.password.Md4PasswordEncoder());
 | 
					        encoders.put("MD4", new org.springframework.security.crypto.password.Md4PasswordEncoder());
 | 
				
			||||||
        encoders.put("MD5", new org.springframework.security.crypto.password.MessageDigestPasswordEncoder("MD5"));
 | 
					        encoders.put("MD5", new org.springframework.security.crypto.password.MessageDigestPasswordEncoder("MD5"));
 | 
				
			||||||
@@ -97,7 +91,8 @@ public class PasswordEncoderAutoConfiguration {
 | 
				
			|||||||
                .getSimpleName()
 | 
					                .getSimpleName()
 | 
				
			||||||
                .toLowerCase(), passwordEncoder));
 | 
					                .toLowerCase(), passwordEncoder));
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        CheckUtils.throwIf(!encoders.keySet().contains(encodingId), "所填 [{}] 密码编码器不存在!", encodingId);
 | 
					        String encodingId = properties.getEncodingId();
 | 
				
			||||||
 | 
					        CheckUtils.throwIf(!encoders.containsKey(encodingId), "{} is not found in idToPasswordEncoder.", encodingId);
 | 
				
			||||||
        return new DelegatingPasswordEncoder(encodingId, encoders);
 | 
					        return new DelegatingPasswordEncoder(encodingId, encoders);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -34,9 +34,9 @@ public class PasswordEncoderProperties {
 | 
				
			|||||||
    private boolean enabled = false;
 | 
					    private boolean enabled = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
     * 启用的算法 ID
 | 
					     * 默认启用的编码器 ID(默认:BCryptPasswordEncoder)
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    private String encodingId;
 | 
					    private String encodingId = "bcrypt";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public boolean isEnabled() {
 | 
					    public boolean isEnabled() {
 | 
				
			||||||
        return enabled;
 | 
					        return enabled;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -20,7 +20,6 @@ import cn.crane4j.core.support.OperateTemplate;
 | 
				
			|||||||
import cn.hutool.core.bean.BeanUtil;
 | 
					import cn.hutool.core.bean.BeanUtil;
 | 
				
			||||||
import cn.hutool.core.bean.copier.CopyOptions;
 | 
					import cn.hutool.core.bean.copier.CopyOptions;
 | 
				
			||||||
import cn.hutool.core.collection.CollUtil;
 | 
					import cn.hutool.core.collection.CollUtil;
 | 
				
			||||||
import cn.hutool.core.collection.CollectionUtil;
 | 
					 | 
				
			||||||
import cn.hutool.core.lang.Opt;
 | 
					import cn.hutool.core.lang.Opt;
 | 
				
			||||||
import cn.hutool.core.lang.tree.Tree;
 | 
					import cn.hutool.core.lang.tree.Tree;
 | 
				
			||||||
import cn.hutool.core.lang.tree.TreeNodeConfig;
 | 
					import cn.hutool.core.lang.tree.TreeNodeConfig;
 | 
				
			||||||
@@ -221,7 +220,7 @@ public abstract class BaseServiceImpl<M extends BaseMapper<T>, T extends BaseDO,
 | 
				
			|||||||
                String checkProperty;
 | 
					                String checkProperty;
 | 
				
			||||||
                // 携带表别名则获取 . 后面的字段名
 | 
					                // 携带表别名则获取 . 后面的字段名
 | 
				
			||||||
                if (property.contains(StringConstants.DOT)) {
 | 
					                if (property.contains(StringConstants.DOT)) {
 | 
				
			||||||
                    checkProperty = CollectionUtil.getLast(StrUtil.split(property, StringConstants.DOT));
 | 
					                    checkProperty = CollUtil.getLast(StrUtil.split(property, StringConstants.DOT));
 | 
				
			||||||
                } else {
 | 
					                } else {
 | 
				
			||||||
                    checkProperty = property;
 | 
					                    checkProperty = property;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user