完善代码生成

This commit is contained in:
2024-03-18 09:49:16 +08:00
parent e25c22ecbb
commit 1439fb30cd

View File

@@ -31,6 +31,9 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.Named;
import org.mapstruct.control.DeepClone;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.ConversionService;
@@ -340,6 +343,37 @@ public class Codegen {
.addMethod(
MethodSpec.methodBuilder("toTreeDto")
.addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT)
.addAnnotation(
AnnotationSpec.builder(Mappings.class)
.addMember(
"value",
"{@$T(target = \"children\", qualifiedByName = \"toTreeDto\")}",
Mapping.class)
.build())
.addAnnotation(
AnnotationSpec.builder(
Named.class)
.addMember("value", "$S", "toTreeDto")
.build())
.returns(ClassName.get(dtoPackage, treeDto.name))
.addParameter(
ClassName.get(entityPackage, entity.name),
"entity")
.build())
.addMethod(
MethodSpec.methodBuilder("toTreeExcludeChildren")
.addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT)
.addAnnotation(
AnnotationSpec.builder(Mappings.class)
.addMember(
"value",
"{@$T(target = \"children\",ignore=true)}",
Mapping.class)
.build())
.returns(ClassName.get(dtoPackage, treeDto.name))
.addParameter(
ClassName.get(entityPackage, entity.name),