diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/generator/dao/CodeColumnConfig.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/generator/dao/CodeColumnConfig.java index f5427fc..fa9f5c5 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/generator/dao/CodeColumnConfig.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/generator/dao/CodeColumnConfig.java @@ -1,5 +1,7 @@ package org.nl.system.service.generator.dao; +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; @@ -9,6 +11,8 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Builder; import lombok.Data; import lombok.EqualsAndHashCode; +import org.nl.common.utils.GenUtil; +import org.nl.system.service.generator.dto.ColumnInfo; /** *

@@ -19,8 +23,6 @@ import lombok.EqualsAndHashCode; * @since 2023-05-03 */ @Data -@Builder -@EqualsAndHashCode(callSuper = false) @TableName("code_column_config") public class CodeColumnConfig implements Serializable { @@ -70,4 +72,24 @@ public class CodeColumnConfig implements Serializable { @ApiModelProperty(value = "日期注解") private String date_annotation; + + // 创建默认的实体 + public static CodeColumnConfig createDefault(String tableName, ColumnInfo config) { + CodeColumnConfig columnConfig = new CodeColumnConfig(); + columnConfig.setColumn_id(IdUtil.getSnowflake(1,1).nextIdStr()); + columnConfig.setTable_name(tableName); + columnConfig.setColumn_name(config.getColumn_name()); + columnConfig.setColumn_type(config.getColumn_type()); + columnConfig.setKey_type(config.getKey_type()); + columnConfig.setExtra(config.getExtra()); + columnConfig.setNot_null((ObjectUtil.isNotEmpty(config.getKey_type()) + &&ObjectUtil.isNotEmpty(config.getExtra()) + && GenUtil.PK.equalsIgnoreCase(config.getKey_type()) + &&GenUtil.EXTRA.equalsIgnoreCase(config.getExtra())) + ?false:ObjectUtil.isNotEmpty(config.getNot_null())?config.getNot_null():false); + columnConfig.setRemark(ObjectUtil.isNotEmpty(config.getRemark())?config.getRemark():null); + columnConfig.setList_show(true); + columnConfig.setForm_show(true); + return columnConfig; + } } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/generator/impl/CodeGeneratorServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/generator/impl/CodeGeneratorServiceImpl.java index d3c7ced..bb7392c 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/generator/impl/CodeGeneratorServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/generator/impl/CodeGeneratorServiceImpl.java @@ -83,23 +83,7 @@ public class CodeGeneratorServiceImpl extends ServiceImpl columnConfigList = columnConfigMapper.getTablesByTableName(tableName); // 设置默认值 List columnInfos = columnConfigList.stream() - .map(config -> CodeColumnConfig - .builder() - .column_id(IdUtil.getSnowflake(1,1).nextIdStr()) - .table_name(tableName) - .column_name(config.getColumn_name()) - .column_type(config.getColumn_type()) - .key_type(config.getKey_type()) - .extra(config.getExtra()) - .not_null((ObjectUtil.isNotEmpty(config.getKey_type()) - &&ObjectUtil.isNotEmpty(config.getExtra()) - &&GenUtil.PK.equalsIgnoreCase(config.getKey_type()) - &&GenUtil.EXTRA.equalsIgnoreCase(config.getExtra())) - ?false:ObjectUtil.isNotEmpty(config.getNot_null())?config.getNot_null():false) - .remark(ObjectUtil.isNotEmpty(config.getRemark())?config.getRemark():null) - .list_show(true) - .form_show(true) - .build()) + .map(config -> CodeColumnConfig.createDefault(tableName, config)) .collect(Collectors.toList()); return columnInfos; }