Browse Source

支持Entity类注解生成处理.

nieqiurong 4 months ago
parent
commit
6d759d9ce0

+ 3 - 0
mybatis-plus-generator/build.gradle

@@ -4,6 +4,9 @@ dependencies {
     implementation "${lib.freemarker}"
     implementation "${lib.beetl}"
     implementation "${lib.enjoy}"
+    implementation "${lib.'swagger-annotations'}"
+    implementation "io.springfox:springfox-swagger2:3.0.0"
+
 
     compileOnly "org.jetbrains:annotations:24.1.0"
     testImplementation "${lib.sqlserver}"

+ 98 - 2
mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/builder/Entity.java

@@ -18,17 +18,21 @@ package com.baomidou.mybatisplus.generator.config.builder;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
 import com.baomidou.mybatisplus.core.handlers.AnnotationHandler;
 import com.baomidou.mybatisplus.core.metadata.TableInfoHelper;
+import com.baomidou.mybatisplus.core.toolkit.StringPool;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.generator.IFill;
 import com.baomidou.mybatisplus.generator.ITemplate;
 import com.baomidou.mybatisplus.generator.config.ConstVal;
+import com.baomidou.mybatisplus.generator.config.GlobalConfig;
 import com.baomidou.mybatisplus.generator.config.INameConvert;
 import com.baomidou.mybatisplus.generator.config.StrategyConfig;
 import com.baomidou.mybatisplus.generator.config.po.TableInfo;
 import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
 import com.baomidou.mybatisplus.generator.function.ConverterFileName;
+import com.baomidou.mybatisplus.generator.model.AnnotationAttributes;
 import com.baomidou.mybatisplus.generator.util.ClassUtils;
 import lombok.Getter;
 import org.jetbrains.annotations.NotNull;
@@ -39,6 +43,7 @@ import org.slf4j.LoggerFactory;
 import java.lang.reflect.Field;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Comparator;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -55,7 +60,8 @@ import java.util.stream.Collectors;
  */
 public class Entity implements ITemplate {
 
-    private final AnnotationHandler annotationHandler = new AnnotationHandler(){};
+    private final AnnotationHandler annotationHandler = new AnnotationHandler() {
+    };
 
     private static final Logger LOGGER = LoggerFactory.getLogger(Entity.class);
 
@@ -223,6 +229,19 @@ public class Entity implements ITemplate {
     @Getter
     private boolean generate = true;
 
+    /**
+     * 默认lombok (兼容属性只有Getter和Setter)
+     */
+    private boolean defaultLombok = true;
+
+    /**
+     * 实体类注解
+     *
+     * @since 3.5.10
+     */
+    @Getter
+    private final List<AnnotationAttributes> classAnnotations = new ArrayList<>();
+
     /**
      * <p>
      * 父类 Class 反射属性转换为公共字段
@@ -342,6 +361,55 @@ public class Entity implements ITemplate {
         data.put("entityLombokModel", this.lombok);
         data.put("entityBooleanColumnRemoveIsPrefix", this.booleanColumnRemoveIsPrefix);
         data.put("superEntityClass", ClassUtils.getSimpleName(this.superClass));
+        GlobalConfig globalConfig = tableInfo.getGlobalConfig();
+        String comment = tableInfo.getComment();
+        Set<String> importPackages = new HashSet<>(tableInfo.getImportPackages());
+        if (StringUtils.isBlank(comment)) {
+            comment = StringPool.EMPTY;
+        }
+        boolean kotlin = globalConfig.isKotlin();
+        if (!kotlin) {
+            // 原先kt模板没有处理这些,作为兼容项
+            if (chain) {
+                this.classAnnotations.add(new AnnotationAttributes("@Accessors(chain = true)", "lombok.experimental.Accessors"));
+            }
+            if (lombok && defaultLombok) {
+                // 原先lombok默认只有这两个
+                this.classAnnotations.add(new AnnotationAttributes("@Getter", "lombok.Getter"));
+                this.classAnnotations.add(new AnnotationAttributes("@Setter", "lombok.Setter"));
+            }
+        }
+        if (tableInfo.isConvert()) {
+            String schemaName = tableInfo.getSchemaName();
+            if (StringUtils.isBlank(schemaName)) {
+                schemaName = StringPool.EMPTY;
+            } else {
+                schemaName = schemaName + StringPool.DOT;
+            }
+            //@TableName("${schemaName}${table.name}")
+            String displayName = String.format("@TableName(\"%s%s\")", schemaName, tableInfo.getName());
+            this.classAnnotations.add(new AnnotationAttributes(TableName.class, displayName));
+        }
+        if (globalConfig.isSwagger()) {
+            //@ApiModel(value = "${entity}对象", description = "${table.comment!}")
+            String displayName = String.format("@ApiModel(value = \"%s对象\", description = \"%s\")", tableInfo.getEntityName(), comment);
+            this.classAnnotations.add(new AnnotationAttributes("@ApiModel",
+                displayName, "io.swagger.annotations.ApiModel", "io.swagger.annotations.ApiModelProperty"));
+        }
+        if (globalConfig.isSpringdoc()) {
+            //@Schema(name = "${entity}", description = "${table.comment!}")
+            String displayName = String.format("@Schema(name = \"%s\", description = \"%s\")", tableInfo.getEntityName(), comment);
+            this.classAnnotations.add(new AnnotationAttributes(displayName, "io.swagger.v3.oas.annotations.media.Schema"));
+        }
+        this.classAnnotations.forEach(attributes -> {
+            if (attributes.getDisplayNameFunction() != null) {
+                attributes.setDisplayName(attributes.getDisplayNameFunction().apply(tableInfo));
+            }
+            importPackages.addAll(attributes.getImportPackages());
+        });
+        data.put("entityClassAnnotations", this.classAnnotations.stream()
+            .sorted(Comparator.comparingInt(s -> s.getDisplayName().length())).collect(Collectors.toList()));
+        data.put("importEntityPackages", importPackages.stream().sorted().collect(Collectors.toList()));
         return data;
     }
 
@@ -420,7 +488,7 @@ public class Entity implements ITemplate {
         }
 
         /**
-         * 开启lombok模型
+         * 开启lombok模型 (默认添加Getter和Setter)
          *
          * @return this
          * @since 3.5.0
@@ -430,6 +498,22 @@ public class Entity implements ITemplate {
             return this;
         }
 
+        /**
+         * 开启lombok模型 (这里会把注解属性都加入进去,无论是否启用kotlin)
+         *
+         * @param attributes 注解属性集合
+         * @return this
+         * @since 3.5.10
+         */
+        public Builder enableLombok(@NotNull AnnotationAttributes... attributes) {
+            this.entity.lombok = true;
+            this.entity.defaultLombok = false;
+            for (AnnotationAttributes attribute : attributes) {
+                this.addClassAnnotation(attribute);
+            }
+            return this;
+        }
+
         /**
          * 开启Boolean类型字段移除is前缀
          *
@@ -676,6 +760,18 @@ public class Entity implements ITemplate {
             return this;
         }
 
+        /**
+         * 添加类注解
+         *
+         * @param attributes 注解属性
+         * @return this
+         * @since 3.5.10
+         */
+        public Builder addClassAnnotation(@NotNull AnnotationAttributes attributes) {
+            this.entity.classAnnotations.add(attributes);
+            return this;
+        }
+
         public Entity get() {
             String superClass = this.entity.superClass;
             if (StringUtils.isNotBlank(superClass)) {

+ 7 - 0
mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/po/TableInfo.java

@@ -155,6 +155,13 @@ public class TableInfo {
     @Getter
     private final Map<String, TableField> tableFieldMap = new HashMap<>();
 
+    /**
+     * @since 3.5.10
+     */
+    @Getter
+    @Setter
+    private String schemaName;
+
     /**
      * 构造方法
      *

+ 14 - 12
mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/engine/AbstractTemplateEngine.java

@@ -300,9 +300,22 @@ public abstract class AbstractTemplateEngine {
      */
     @NotNull
     public Map<String, Object> getObjectMap(@NotNull ConfigBuilder config, @NotNull TableInfo tableInfo) {
+        Map<String, Object> objectMap = new HashMap<>();
         StrategyConfig strategyConfig = config.getStrategyConfig();
+        // 启用 schema 处理逻辑
+        String schemaName = "";
+        if (strategyConfig.isEnableSchema()) {
+            // 存在 schemaName 设置拼接 . 组合表名
+            schemaName = config.getDataSourceConfig().getSchemaName();
+            if (StringUtils.isNotBlank(schemaName)) {
+                tableInfo.setSchemaName(schemaName);
+                schemaName += ".";
+                tableInfo.setConvert(true);
+            }
+        }
+        objectMap.put("schemaName", schemaName);
         Map<String, Object> controllerData = strategyConfig.controller().renderData(tableInfo);
-        Map<String, Object> objectMap = new HashMap<>(controllerData);
+        objectMap.putAll(controllerData);
         Map<String, Object> mapperData = strategyConfig.mapper().renderData(tableInfo);
         objectMap.putAll(mapperData);
         Map<String, Object> serviceData = strategyConfig.service().renderData(tableInfo);
@@ -317,17 +330,6 @@ public abstract class AbstractTemplateEngine {
         objectMap.put("swagger", globalConfig.isSwagger());
         objectMap.put("springdoc", globalConfig.isSpringdoc());
         objectMap.put("date", globalConfig.getCommentDate());
-        // 启用 schema 处理逻辑
-        String schemaName = "";
-        if (strategyConfig.isEnableSchema()) {
-            // 存在 schemaName 设置拼接 . 组合表名
-            schemaName = config.getDataSourceConfig().getSchemaName();
-            if (StringUtils.isNotBlank(schemaName)) {
-                schemaName += ".";
-                tableInfo.setConvert(true);
-            }
-        }
-        objectMap.put("schemaName", schemaName);
         objectMap.put("table", tableInfo);
         objectMap.put("entity", tableInfo.getEntityName());
         return objectMap;

+ 104 - 0
mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/model/AnnotationAttributes.java

@@ -0,0 +1,104 @@
+/*
+ * Copyright (c) 2011-2024, baomidou (jobob@qq.com).
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.baomidou.mybatisplus.generator.model;
+
+import com.baomidou.mybatisplus.generator.config.po.TableInfo;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.function.Function;
+
+/**
+ * @author nieqiurong
+ * @since 3.5.10
+ */
+@Getter
+@ToString
+public class AnnotationAttributes {
+
+    /**
+     * 显示名称处理函数(最终需要转换成{@link #displayName})
+     */
+    @Setter
+    private Function<TableInfo, String> displayNameFunction;
+
+    /**
+     * 显示名称
+     */
+    @Setter
+    private String displayName;
+
+    /**
+     * 导入包路径
+     */
+    private final Set<String> importPackages = new HashSet<>();
+
+    public AnnotationAttributes(@NotNull Class<?> annotationClass) {
+        this.displayName = "@" + annotationClass.getSimpleName();
+        this.importPackages.add(annotationClass.getName());
+    }
+
+    public AnnotationAttributes(@NotNull Class<?> annotationClass, @NotNull Function<TableInfo,String> displayNameFunction) {
+        this.displayNameFunction = displayNameFunction;
+        this.importPackages.add(annotationClass.getName());
+    }
+
+    public AnnotationAttributes(@NotNull Class<?> annotationClass, @NotNull String displayName, String... extraPkg) {
+        this.displayName = displayName;
+        this.importPackages.add(annotationClass.getName());
+        if (extraPkg != null && extraPkg.length > 0) {
+            this.importPackages.addAll(Arrays.asList(extraPkg));
+        }
+    }
+
+    public AnnotationAttributes(@NotNull Class<?> annotationClass, @NotNull Function<TableInfo,String> displayNameFunction, String... extraPkg) {
+        this.displayNameFunction = displayNameFunction;
+        this.importPackages.add(annotationClass.getName());
+        if (extraPkg != null && extraPkg.length > 0) {
+            this.importPackages.addAll(Arrays.asList(extraPkg));
+        }
+    }
+
+    public AnnotationAttributes(@NotNull String displayName, @NotNull String... importPackages) {
+        this.displayName = displayName;
+        this.importPackages.addAll(Arrays.asList(importPackages));
+    }
+
+    public AnnotationAttributes(@NotNull String importPackage, @NotNull Function<TableInfo, String> displayNameFunction) {
+        this.displayNameFunction = displayNameFunction;
+        this.importPackages.add(importPackage);
+    }
+
+    public AnnotationAttributes(@NotNull Set<String> importPackages, @NotNull Function<TableInfo, String> displayNameFunction) {
+        this.displayNameFunction = displayNameFunction;
+        this.importPackages.addAll(importPackages);
+    }
+
+    /**
+     * 添加导包
+     *
+     * @param importPackage 包路径
+     */
+    public void addImportPackage(@NotNull String importPackage) {
+        this.importPackages.add(importPackage);
+    }
+
+}

+ 3 - 28
mybatis-plus-generator/src/main/resources/templates/entity.java.btl

@@ -1,21 +1,8 @@
 package ${package.Entity};
 
-<% for(pkg in table.importPackages){ %>
+<% for(pkg in importEntityPackages){ %>
 import ${pkg};
 <% } %>
-<% if(springdoc){ %>
-import io.swagger.v3.oas.annotations.media.Schema;
-<% }else if(swagger){ %>
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-<% } %>
-<% if(entityLombokModel){ %>
-import lombok.Getter;
-import lombok.Setter;
-<% if(chainModel){ %>
-import lombok.experimental.Accessors;
-<% } %>
-<% } %>
 
 /**
  * <p>
@@ -25,20 +12,8 @@ import lombok.experimental.Accessors;
  * @author ${author}
  * @since ${date}
  */
-<% if(entityLombokModel){ %>
-@Getter
-@Setter
-    <% if(chainModel){ %>
-@Accessors(chain = true)
-    <% } %>
-<% } %>
-<% if(table.convert){ %>
-@TableName("${schemaName}${table.name}")
-<% } %>
-<% if(springdoc){ %>
-@Schema(name = "${entity}", description = "${table.comment!''}")
-<% }else if(swagger){ %>
-@ApiModel(value = "${entity}对象", description = "${table.comment!''}")
+<% for(an in entityClassAnnotations){ %>
+${an.displayName}
 <% } %>
 <% if(isNotEmpty(superEntityClass)){ %>
 public class ${entity} extends ${superEntityClass}<% if(activeRecord){ %><${entity}><%}%>{

+ 3 - 28
mybatis-plus-generator/src/main/resources/templates/entity.java.ej

@@ -1,21 +1,8 @@
 package #(package.Entity);
 
-#for(pkg : table.importPackages)
+#for(pkg : importEntityPackages)
 import #(pkg);
 #end
-#if(springdoc)
-import io.swagger.v3.oas.annotations.media.Schema;
-#elseif(swagger)
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-#end
-#if(entityLombokModel)
-import lombok.Getter;
-import lombok.Setter;
-#if(chainModel)
-import lombok.experimental.Accessors;
-#end
-#end
 
 /**
  * <p>
@@ -25,20 +12,8 @@ import lombok.experimental.Accessors;
  * @author #(author)
  * @since #(date)
  */
-#if(entityLombokModel)
-@Getter
-@Setter
-  #if(chainModel)
-@Accessors(chain = true)
-  #end
-#end
-#if(table.isConvert())
-@TableName("#(schemaName)#(table.name)")
-#end
-#if(springdoc)
-@Schema(name = "#(entity)", description = "#(table.comment)")
-#elseif(swagger)
-@ApiModel(value = "#(entity)对象", description = "#(table.comment)")
+#for(an : entityClassAnnotations)
+#(an.displayName)
 #end
 #if(superEntityClass)
 public class #(entity) extends #(superEntityClass)#if(activeRecord)<#(entity)>#end {

+ 4 - 30
mybatis-plus-generator/src/main/resources/templates/entity.java.ftl

@@ -1,22 +1,8 @@
 package ${package.Entity};
 
-<#list table.importPackages as pkg>
+<#list importEntityPackages as pkg>
 import ${pkg};
 </#list>
-<#if springdoc>
-import io.swagger.v3.oas.annotations.media.Schema;
-<#elseif swagger>
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-</#if>
-<#if entityLombokModel>
-import lombok.Getter;
-import lombok.Setter;
-    <#if chainModel>
-import lombok.experimental.Accessors;
-    </#if>
-</#if>
-
 /**
  * <p>
  * ${table.comment!}
@@ -25,21 +11,9 @@ import lombok.experimental.Accessors;
  * @author ${author}
  * @since ${date}
  */
-<#if entityLombokModel>
-@Getter
-@Setter
-    <#if chainModel>
-@Accessors(chain = true)
-    </#if>
-</#if>
-<#if table.convert>
-@TableName("${schemaName}${table.name}")
-</#if>
-<#if springdoc>
-@Schema(name = "${entity}", description = "${table.comment!}")
-<#elseif swagger>
-@ApiModel(value = "${entity}对象", description = "${table.comment!}")
-</#if>
+<#list entityClassAnnotations as an>
+${an.displayName}
+</#list>
 <#if superEntityClass??>
 public class ${entity} extends ${superEntityClass}<#if activeRecord><${entity}></#if> {
 <#elseif activeRecord>

+ 3 - 28
mybatis-plus-generator/src/main/resources/templates/entity.java.vm

@@ -1,21 +1,8 @@
 package ${package.Entity};
 
-#foreach($pkg in ${table.importPackages})
+#foreach($pkg in ${importEntityPackages})
 import ${pkg};
 #end
-#if(${springdoc})
-import io.swagger.v3.oas.annotations.media.Schema;
-#elseif(${swagger})
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-#end
-#if(${entityLombokModel})
-import lombok.Getter;
-import lombok.Setter;
-#if(${chainModel})
-import lombok.experimental.Accessors;
-#end
-#end
 
 /**
  * <p>
@@ -25,20 +12,8 @@ import lombok.experimental.Accessors;
  * @author ${author}
  * @since ${date}
  */
-#if(${entityLombokModel})
-@Getter
-@Setter
-  #if(${chainModel})
-@Accessors(chain = true)
-  #end
-#end
-#if(${table.convert})
-@TableName("${schemaName}${table.name}")
-#end
-#if(${springdoc})
-@Schema(name = "${entity}", description = "$!{table.comment}")
-#elseif(${swagger})
-@ApiModel(value = "${entity}对象", description = "$!{table.comment}")
+#foreach($an in ${entityClassAnnotations})
+${an.displayName}
 #end
 #if(${superEntityClass})
 public class ${entity} extends ${superEntityClass}#if(${activeRecord})<${entity}>#end {

+ 4 - 15
mybatis-plus-generator/src/main/resources/templates/entity.kt.btl

@@ -1,13 +1,7 @@
 package ${package.Entity}
 
-<% for(pkg in table.importPackages){ %>
-import ${pkg}
-<% } %>
-<% if(springdoc){ %>
-import io.swagger.v3.oas.annotations.media.Schema;
-<% }else if(swagger){ %>
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
+<% for(pkg in importEntityPackages){ %>
+import ${pkg};
 <% } %>
 
 /**
@@ -18,13 +12,8 @@ import io.swagger.annotations.ApiModelProperty;
  * @author ${author}
  * @since ${date}
  */
-<% if(table.convert){ %>
-@TableName("${schemaName}${table.name}")
-<% } %>
-<% if(springdoc){ %>
-@Schema(name = "${entity}", description = "$!{table.comment}")
-<% }else if(swagger){ %>
-@ApiModel(value = "${entity}对象", description = "${table.comment!''}")
+<% for(an in entityClassAnnotations){ %>
+${an.displayName}
 <% } %>
 <% if(isNotEmpty(superEntityClass)){ %>
 class ${entity} : ${superEntityClass}<% if(activeRecord){ %><${entity}><%}%>() {

+ 3 - 14
mybatis-plus-generator/src/main/resources/templates/entity.kt.ej

@@ -1,14 +1,8 @@
 package #(package.Entity);
 
-#for(pkg : table.importPackages)
+#for(pkg : importEntityPackages)
 import #(pkg);
 #end
-#if(springdoc)
-import io.swagger.v3.oas.annotations.media.Schema;
-#elseif(swagger)
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-#end
 
 /**
  * <p>
@@ -18,13 +12,8 @@ import io.swagger.annotations.ApiModelProperty;
  * @author #(author)
  * @since #(date)
  */
-#if(table.isConvert())
-@TableName("#(schemaName)#(table.name)")
-#end
-#if(springdoc)
-@Schema(name = "#(entity)", description = "#(table.comment)")
-#elseif(swagger)
-@ApiModel(value = "${entity}对象", description = "$!{table.comment}")
+#for(an : entityClassAnnotations)
+#(an.displayName)
 #end
 #if(superEntityClass)
 class #(entity) : #(superEntityClass)#if(activeRecord)<#(entity)>#end() {

+ 4 - 15
mybatis-plus-generator/src/main/resources/templates/entity.kt.ftl

@@ -1,14 +1,8 @@
 package ${package.Entity}
 
-<#list table.importPackages as pkg>
+<#list importEntityPackages as pkg>
 import ${pkg}
 </#list>
-<#if springdoc>
-import io.swagger.v3.oas.annotations.media.Schema;
-<#elseif swagger>
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-</#if>
 
 /**
  * <p>
@@ -18,14 +12,9 @@ import io.swagger.annotations.ApiModelProperty;
  * @author ${author}
  * @since ${date}
  */
-<#if table.convert>
-@TableName("${schemaName}${table.name}")
-</#if>
-<#if springdoc>
-@Schema(name = "${entity}", description = "$!{table.comment}")
-<#elseif swagger>
-@ApiModel(value = "${entity}对象", description = "${table.comment!}")
-</#if>
+<#list entityClassAnnotations as an>
+${an.displayName}
+</#list>
 <#if superEntityClass??>
 class ${entity} : ${superEntityClass}<#if activeRecord><${entity}></#if>() {
 <#elseif activeRecord>

+ 3 - 14
mybatis-plus-generator/src/main/resources/templates/entity.kt.vm

@@ -1,14 +1,8 @@
 package ${package.Entity};
 
-#foreach($pkg in ${table.importPackages})
+#foreach($pkg in ${importEntityPackages})
 import ${pkg};
 #end
-#if(${springdoc})
-import io.swagger.v3.oas.annotations.media.Schema;
-#elseif(${swagger})
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-#end
 
 /**
  * <p>
@@ -18,13 +12,8 @@ import io.swagger.annotations.ApiModelProperty;
  * @author ${author}
  * @since ${date}
  */
-#if(${table.convert})
-@TableName("${schemaName}${table.name}")
-#end
-#if(${springdoc})
-@Schema(name = "${entity}", description = "$!{table.comment}")
-#elseif(${swagger})
-@ApiModel(value = "${entity}对象", description = "$!{table.comment}")
+#foreach($an in ${entityClassAnnotations})
+${an.displayName}
 #end
 #if(${superEntityClass})
 class ${entity} : ${superEntityClass}#if(${activeRecord})<${entity}>#end() {