diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/codegen/CodegenConvert.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/codegen/CodegenConvert.java index 7f33cf543..6c78ac7cd 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/codegen/CodegenConvert.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/convert/codegen/CodegenConvert.java @@ -1,6 +1,5 @@ package cn.iocoder.yudao.module.infra.convert.codegen; -import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.CodegenDetailRespVO; import cn.iocoder.yudao.module.infra.controller.admin.codegen.vo.CodegenPreviewRespVO; @@ -12,9 +11,11 @@ import cn.iocoder.yudao.module.infra.dal.dataobject.codegen.CodegenColumnDO; 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.TableInfo; +import com.baomidou.mybatisplus.generator.config.rules.IColumnType; import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.Mappings; +import org.mapstruct.Named; import org.mapstruct.factory.Mappers; import java.util.List; @@ -34,19 +35,11 @@ public interface CodegenConvert { }) CodegenTableDO convert(TableInfo bean); - default List convertList(List list){ - return CollUtil.map(list,t->convert(t),true); - } - - default CodegenColumnDO convert(TableField bean) { - CodegenColumnDO codegenColumnDO = convert0(bean); - codegenColumnDO.setDataType(bean.getColumnType().getType()); - return codegenColumnDO; - } + List convertList(List list); @Mappings({ @Mapping(source = "name", target = "columnName"), - @Mapping(source = "type", target = "dataType"), + @Mapping(source = "columnType", target = "dataType", qualifiedByName = "getType"), @Mapping(source = "comment", target = "columnComment"), @Mapping(source = "metaInfo.nullable", target = "nullable"), @Mapping(source = "keyFlag", target = "primaryKey"), @@ -54,7 +47,12 @@ public interface CodegenConvert { @Mapping(source = "columnType.type", target = "javaType"), @Mapping(source = "propertyName", target = "javaField"), }) - CodegenColumnDO convert0(TableField bean); + CodegenColumnDO convert(TableField bean); + + @Named("getType") + default String getType(IColumnType jdbcType) { + return jdbcType.getType(); + } // ========== CodegenTableDO 相关 ==========