From 431c029b6061b9ab9fb724e5cf3998417af381e3 Mon Sep 17 00:00:00 2001 From: gaibu <1016771049@qq.com> Date: Tue, 10 Jan 2023 17:51:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=9F=BA=E7=A1=80=E8=AE=BE=E6=96=BD-?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=E7=94=9F=E6=88=90-=E6=95=B4=E4=B8=AA?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E4=B8=8D=E8=83=BD=E4=BD=BF=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../infra/convert/codegen/CodegenConvert.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) 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 7f33cf5438..6c78ac7cd3 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 相关 ==========