Commit 215a3767ae088ad026f0851eb88c6ee6df41b8f4

Authored by gaibu
1 parent 431c029b

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

yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/codegen/CodegenConvert.java
@@ -11,7 +11,7 @@ import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenColumnDO; @@ -11,7 +11,7 @@ import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenColumnDO;
11 import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenTableDO; 11 import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenTableDO;
12 import com.baomidou.mybatisplus.generator.config.po.TableField; 12 import com.baomidou.mybatisplus.generator.config.po.TableField;
13 import com.baomidou.mybatisplus.generator.config.po.TableInfo; 13 import com.baomidou.mybatisplus.generator.config.po.TableInfo;
14 -import com.baomidou.mybatisplus.generator.config.rules.IColumnType; 14 +import org.apache.ibatis.type.JdbcType;
15 import org.mapstruct.Mapper; 15 import org.mapstruct.Mapper;
16 import org.mapstruct.Mapping; 16 import org.mapstruct.Mapping;
17 import org.mapstruct.Mappings; 17 import org.mapstruct.Mappings;
@@ -39,7 +39,7 @@ public interface CodegenConvert { @@ -39,7 +39,7 @@ public interface CodegenConvert {
39 39
40 @Mappings({ 40 @Mappings({
41 @Mapping(source = "name", target = "columnName"), 41 @Mapping(source = "name", target = "columnName"),
42 - @Mapping(source = "columnType", target = "dataType", qualifiedByName = "getType"), 42 + @Mapping(source = "metaInfo.jdbcType", target = "dataType", qualifiedByName = "getDataType"),
43 @Mapping(source = "comment", target = "columnComment"), 43 @Mapping(source = "comment", target = "columnComment"),
44 @Mapping(source = "metaInfo.nullable", target = "nullable"), 44 @Mapping(source = "metaInfo.nullable", target = "nullable"),
45 @Mapping(source = "keyFlag", target = "primaryKey"), 45 @Mapping(source = "keyFlag", target = "primaryKey"),
@@ -49,9 +49,9 @@ public interface CodegenConvert { @@ -49,9 +49,9 @@ public interface CodegenConvert {
49 }) 49 })
50 CodegenColumnDO convert(TableField bean); 50 CodegenColumnDO convert(TableField bean);
51 51
52 - @Named("getType")  
53 - default String getType(IColumnType jdbcType) {  
54 - return jdbcType.getType(); 52 + @Named("getDataType")
  53 + default String getDataType(JdbcType jdbcType) {
  54 + return jdbcType.name();
55 } 55 }
56 56
57 // ========== CodegenTableDO 相关 ========== 57 // ========== CodegenTableDO 相关 ==========
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/codegen/CodegenColumnDO.java
@@ -30,7 +30,7 @@ public class CodegenColumnDO extends BaseDO { @@ -30,7 +30,7 @@ public class CodegenColumnDO extends BaseDO {
30 private Long id; 30 private Long id;
31 /** 31 /**
32 * 表编号 32 * 表编号
33 - * 33 + * <p>
34 * 关联 {@link CodegenTableDO#getId()} 34 * 关联 {@link CodegenTableDO#getId()}
35 */ 35 */
36 private Long tableId; 36 private Long tableId;
@@ -42,8 +42,8 @@ public class CodegenColumnDO extends BaseDO { @@ -42,8 +42,8 @@ public class CodegenColumnDO extends BaseDO {
42 */ 42 */
43 private String columnName; 43 private String columnName;
44 /** 44 /**
45 - * 字段类型  
46 - * 关联 {@link TableField#getColumnType()}} 45 + * 数据库字段类型
  46 + * 关联 {@link TableField.MetaInfo#getJdbcType()}
47 */ 47 */
48 private String dataType; 48 private String dataType;
49 /** 49 /**
@@ -71,7 +71,7 @@ public class CodegenColumnDO extends BaseDO { @@ -71,7 +71,7 @@ public class CodegenColumnDO extends BaseDO {
71 71
72 /** 72 /**
73 * Java 属性类型 73 * Java 属性类型
74 - * 74 + * <p>
75 * 例如说 String、Boolean 等等 75 * 例如说 String、Boolean 等等
76 */ 76 */
77 private String javaType; 77 private String javaType;
@@ -81,7 +81,7 @@ public class CodegenColumnDO extends BaseDO { @@ -81,7 +81,7 @@ public class CodegenColumnDO extends BaseDO {
81 private String javaField; 81 private String javaField;
82 /** 82 /**
83 * 字典类型 83 * 字典类型
84 - * 84 + * <p>
85 * 关联 DictTypeDO 的 type 属性 85 * 关联 DictTypeDO 的 type 属性
86 */ 86 */
87 private String dictType; 87 private String dictType;
@@ -106,7 +106,7 @@ public class CodegenColumnDO extends BaseDO { @@ -106,7 +106,7 @@ public class CodegenColumnDO extends BaseDO {
106 private Boolean listOperation; 106 private Boolean listOperation;
107 /** 107 /**
108 * List 查询操作的条件类型 108 * List 查询操作的条件类型
109 - * 109 + * <p>
110 * 枚举 {@link CodegenColumnListConditionEnum} 110 * 枚举 {@link CodegenColumnListConditionEnum}
111 */ 111 */
112 private String listOperationCondition; 112 private String listOperationCondition;
@@ -119,7 +119,7 @@ public class CodegenColumnDO extends BaseDO { @@ -119,7 +119,7 @@ public class CodegenColumnDO extends BaseDO {
119 119
120 /** 120 /**
121 * 显示类型 121 * 显示类型
122 - * 122 + * <p>
123 * 枚举 {@link CodegenColumnHtmlTypeEnum} 123 * 枚举 {@link CodegenColumnHtmlTypeEnum}
124 */ 124 */
125 private String htmlType; 125 private String htmlType;