fix: 代码生成字段转换错误

pull/2/head
gaibu 2023-01-11 18:36:01 +08:00
parent 431c029b60
commit 215a3767ae
2 changed files with 12 additions and 12 deletions

View File

@ -11,7 +11,7 @@ import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenColumnDO;
import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenTableDO; import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenTableDO;
import com.baomidou.mybatisplus.generator.config.po.TableField; import com.baomidou.mybatisplus.generator.config.po.TableField;
import com.baomidou.mybatisplus.generator.config.po.TableInfo; import com.baomidou.mybatisplus.generator.config.po.TableInfo;
import com.baomidou.mybatisplus.generator.config.rules.IColumnType; import org.apache.ibatis.type.JdbcType;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
import org.mapstruct.Mappings; import org.mapstruct.Mappings;
@ -39,7 +39,7 @@ public interface CodegenConvert {
@Mappings({ @Mappings({
@Mapping(source = "name", target = "columnName"), @Mapping(source = "name", target = "columnName"),
@Mapping(source = "columnType", target = "dataType", qualifiedByName = "getType"), @Mapping(source = "metaInfo.jdbcType", target = "dataType", qualifiedByName = "getDataType"),
@Mapping(source = "comment", target = "columnComment"), @Mapping(source = "comment", target = "columnComment"),
@Mapping(source = "metaInfo.nullable", target = "nullable"), @Mapping(source = "metaInfo.nullable", target = "nullable"),
@Mapping(source = "keyFlag", target = "primaryKey"), @Mapping(source = "keyFlag", target = "primaryKey"),
@ -49,9 +49,9 @@ public interface CodegenConvert {
}) })
CodegenColumnDO convert(TableField bean); CodegenColumnDO convert(TableField bean);
@Named("getType") @Named("getDataType")
default String getType(IColumnType jdbcType) { default String getDataType(JdbcType jdbcType) {
return jdbcType.getType(); return jdbcType.name();
} }
// ========== CodegenTableDO 相关 ========== // ========== CodegenTableDO 相关 ==========

View File

@ -30,7 +30,7 @@ public class CodegenColumnDO extends BaseDO {
private Long id; private Long id;
/** /**
* *
* * <p>
* {@link CodegenTableDO#getId()} * {@link CodegenTableDO#getId()}
*/ */
private Long tableId; private Long tableId;
@ -42,8 +42,8 @@ public class CodegenColumnDO extends BaseDO {
*/ */
private String columnName; private String columnName;
/** /**
* *
* {@link TableField#getColumnType()}} * {@link TableField.MetaInfo#getJdbcType()}
*/ */
private String dataType; private String dataType;
/** /**
@ -71,7 +71,7 @@ public class CodegenColumnDO extends BaseDO {
/** /**
* Java * Java
* * <p>
* StringBoolean * StringBoolean
*/ */
private String javaType; private String javaType;
@ -81,7 +81,7 @@ public class CodegenColumnDO extends BaseDO {
private String javaField; private String javaField;
/** /**
* *
* * <p>
* DictTypeDO type * DictTypeDO type
*/ */
private String dictType; private String dictType;
@ -106,7 +106,7 @@ public class CodegenColumnDO extends BaseDO {
private Boolean listOperation; private Boolean listOperation;
/** /**
* List * List
* * <p>
* {@link CodegenColumnListConditionEnum} * {@link CodegenColumnListConditionEnum}
*/ */
private String listOperationCondition; private String listOperationCondition;
@ -119,7 +119,7 @@ public class CodegenColumnDO extends BaseDO {
/** /**
* *
* * <p>
* {@link CodegenColumnHtmlTypeEnum} * {@link CodegenColumnHtmlTypeEnum}
*/ */
private String htmlType; private String htmlType;