mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-11-03 22:57:14 +08:00 
			
		
		
		
	refactor: 优化部分代码
修复 Sonar 扫描问题
This commit is contained in:
		@@ -16,13 +16,15 @@
 | 
			
		||||
 | 
			
		||||
package top.charles7c.continew.admin.common.constant;
 | 
			
		||||
 | 
			
		||||
import top.charles7c.continew.starter.extension.crud.constant.ContainerPool;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 数据源容器相关常量(Crane4j 数据填充组件使用)
 | 
			
		||||
 *
 | 
			
		||||
 * @author Charles7c
 | 
			
		||||
 * @since 2024/1/20 12:33
 | 
			
		||||
 */
 | 
			
		||||
public class ContainerConstants implements top.charles7c.continew.starter.extension.crud.constant.ContainerConstants {
 | 
			
		||||
public class ContainerConstants extends ContainerPool {
 | 
			
		||||
 | 
			
		||||
    private ContainerConstants() {
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -30,6 +30,9 @@ import top.charles7c.continew.starter.core.util.validate.ValidationUtils;
 | 
			
		||||
 */
 | 
			
		||||
public class SecureUtils {
 | 
			
		||||
 | 
			
		||||
    private SecureUtils() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 公钥加密
 | 
			
		||||
     *
 | 
			
		||||
@@ -74,7 +77,4 @@ public class SecureUtils {
 | 
			
		||||
    public static String md5Salt(String data, String salt) {
 | 
			
		||||
        return SecureUtil.md5(SecureUtil.md5(data) + salt);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private SecureUtils() {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -42,6 +42,9 @@ import java.time.LocalDateTime;
 | 
			
		||||
 */
 | 
			
		||||
public class LoginHelper {
 | 
			
		||||
 | 
			
		||||
    private LoginHelper() {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * 用户登录并缓存用户信息
 | 
			
		||||
     *
 | 
			
		||||
@@ -133,7 +136,4 @@ public class LoginHelper {
 | 
			
		||||
    public static String getNickname(Long userId) {
 | 
			
		||||
        return ExceptionUtils.exToNull(() -> SpringUtil.getBean(CommonUserService.class).getNicknameById(userId));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private LoginHelper() {
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -16,14 +16,13 @@
 | 
			
		||||
 | 
			
		||||
package top.charles7c.continew.admin.system.mapper;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import org.apache.ibatis.annotations.Param;
 | 
			
		||||
 | 
			
		||||
import top.charles7c.continew.admin.common.model.resp.LabelValueResp;
 | 
			
		||||
import top.charles7c.continew.admin.system.model.entity.DictItemDO;
 | 
			
		||||
import top.charles7c.continew.starter.data.mybatis.plus.base.BaseMapper;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * 字典项 Mapper
 | 
			
		||||
 *
 | 
			
		||||
 
 | 
			
		||||
@@ -143,17 +143,15 @@ public class FieldConfigDO implements Serializable {
 | 
			
		||||
    private LocalDateTime createTime;
 | 
			
		||||
 | 
			
		||||
    public FieldConfigDO(@NonNull Column column) {
 | 
			
		||||
        String columnType = StrUtil.splitToArray(column.getTypeName(), StringConstants.SPACE)[0].toLowerCase();
 | 
			
		||||
        boolean isRequired = !column.isPk() && !column.isNullable();
 | 
			
		||||
        this.tableName = column.getTableName();
 | 
			
		||||
        this.setTableName(column.getTableName());
 | 
			
		||||
        this.setColumnName(column.getName());
 | 
			
		||||
        this.setColumnType(columnType);
 | 
			
		||||
        this.setColumnType(StrUtil.splitToArray(column.getTypeName(), StringConstants.SPACE)[0].toLowerCase());
 | 
			
		||||
        this.setColumnSize(column.getSize());
 | 
			
		||||
        this.setComment(column.getComment());
 | 
			
		||||
        this.setIsRequired(isRequired);
 | 
			
		||||
        this.setIsRequired(!column.isPk() && !column.isNullable());
 | 
			
		||||
        this.setShowInList(true);
 | 
			
		||||
        this.setShowInForm(isRequired);
 | 
			
		||||
        this.setShowInQuery(isRequired);
 | 
			
		||||
        this.setShowInForm(this.getIsRequired());
 | 
			
		||||
        this.setShowInQuery(this.getIsRequired());
 | 
			
		||||
        this.setFormType(FormTypeEnum.TEXT);
 | 
			
		||||
        this.setQueryType("String".equals(this.getFieldType()) ? QueryTypeEnum.LIKE : QueryTypeEnum.EQ);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -134,7 +134,7 @@ public class GeneratorServiceImpl implements GeneratorService {
 | 
			
		||||
            return columnList.stream().map(FieldConfigDO::new).collect(Collectors.toList());
 | 
			
		||||
        }
 | 
			
		||||
        // 同步最新数据表列信息
 | 
			
		||||
        if (requireSync) {
 | 
			
		||||
        if (Boolean.TRUE.equals(requireSync)) {
 | 
			
		||||
            Collection<Column> columnList = MetaUtils.getColumns(dataSource, tableName);
 | 
			
		||||
            // 移除已不存在的字段配置
 | 
			
		||||
            List<String> columnNameList = columnList.stream().map(Column::getName).collect(Collectors.toList());
 | 
			
		||||
@@ -286,7 +286,7 @@ public class GeneratorServiceImpl implements GeneratorService {
 | 
			
		||||
                    .getPackageName(), StringConstants.DOT));
 | 
			
		||||
                File classFile = new File(classParentFile, codePreview.getFileName());
 | 
			
		||||
                // 如果已经存在,且不允许覆盖,则跳过
 | 
			
		||||
                if (classFile.exists() && !isOverride) {
 | 
			
		||||
                if (classFile.exists() && Boolean.FALSE.equals(isOverride)) {
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
                FileUtil.writeUtf8String(codePreview.getContent(), classFile);
 | 
			
		||||
@@ -309,7 +309,7 @@ public class GeneratorServiceImpl implements GeneratorService {
 | 
			
		||||
            // 例如:D:/continew-admin-ui/src/api/tool/xxx.ts
 | 
			
		||||
            File apiParentFile = FileUtil.file(frontendModulePath, "src", "api", apiModuleName);
 | 
			
		||||
            File apiFile = new File(apiParentFile, apiCodePreview.getFileName());
 | 
			
		||||
            if (apiFile.exists() && !isOverride) {
 | 
			
		||||
            if (apiFile.exists() && Boolean.FALSE.equals(isOverride)) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            FileUtil.writeUtf8String(apiCodePreview.getContent(), apiFile);
 | 
			
		||||
@@ -318,7 +318,7 @@ public class GeneratorServiceImpl implements GeneratorService {
 | 
			
		||||
            // 例如:D:/continew-admin-ui/src/views/tool/xxx/index.vue
 | 
			
		||||
            File indexFile = FileUtil.file(frontendPath, apiModuleName, StrUtil
 | 
			
		||||
                .lowerFirst(classNamePrefix), "index.vue");
 | 
			
		||||
            if (indexFile.exists() && !isOverride) {
 | 
			
		||||
            if (indexFile.exists() && Boolean.FALSE.equals(isOverride)) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            FileUtil.writeUtf8String(viewCodePreview.getContent(), indexFile);
 | 
			
		||||
 
 | 
			
		||||
@@ -73,10 +73,7 @@
 | 
			
		||||
        <!-- 如果配置的日志等级,和 application.yml 中的日志等级配置重叠,application.yml 配置优先级高 -->
 | 
			
		||||
        <root level="INFO">
 | 
			
		||||
            <appender-ref ref="CONSOLE"/>
 | 
			
		||||
            <!--<appender-ref ref="ASYNC_FILE"/>-->
 | 
			
		||||
        </root>
 | 
			
		||||
        <!-- 日志保留天数 -->
 | 
			
		||||
        <!--<property name="FILE_MAX_HISTORY" value="15"/>-->
 | 
			
		||||
    </springProfile>
 | 
			
		||||
 | 
			
		||||
    <!-- 生产环境:打印到控制台并输出到文件 -->
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user