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