From 115cdae966e83cf128fed777c89e1a4ce09cf415 Mon Sep 17 00:00:00 2001
From: "review512jwy@163.com" <“review512jwy@163.com”>
Date: Wed, 15 Apr 2026 20:51:19 +0800
Subject: [PATCH] =?UTF-8?q?entity=E3=80=82mapper=E7=9B=B8=E5=85=B3?=
=?UTF-8?q?=EF=BC=8C=E8=87=AA=E5=8A=A8=E7=94=9F=E6=88=90?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
pom.xml | 26 ++
.../boot/codegen/MyBatisPlusGenerator.java | 242 ++++++++++++++++++
.../templates/codegen/ftl/entity.java.ftl | 90 +++++++
3 files changed, 358 insertions(+)
create mode 100644 src/main/java/com/youlai/boot/codegen/MyBatisPlusGenerator.java
create mode 100644 src/main/resources/templates/codegen/ftl/entity.java.ftl
diff --git a/pom.xml b/pom.xml
index 3330605..f85775d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -64,6 +64,12 @@
4.8.1.B
+ 2.3.34
+
+ 1.20.0
+
+ 1.4.0
+
@@ -276,6 +282,26 @@
${weixin-java-miniapp.version}
+
+
+ org.freemarker
+ freemarker
+ ${freemarker.version}
+
+
+
+
+ org.locationtech.jts
+ jts-core
+ ${jts-core.version}
+
+
+
+ ch.hsr
+ geohash
+ ${geohash.version}
+
+
+<#list table.fields as field>
+ <#if field.propertyType == "LocalDate" || field.propertyType == "LocalDateTime">
+import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonFormat;
+ <#break>
+ #if>
+#list>
+<#-- 导入 org.locationtech.jts.geom.Point 类型 -->
+<#list table.fields as field>
+ <#if field.propertyType == "Point">
+import org.locationtech.jts.geom.Point;
+import com.pet.map.back.handler.PointTypeHandler;
+ <#break>
+ #if>
+#list>
+<#-- BigDecimal 导入 -->
+<#list table.fields as field>
+ <#if field.propertyType == "BigDecimal">
+import java.math.BigDecimal;
+ <#break>
+ #if>
+#list>
+
+@Getter
+@Setter
+@ToString
+@Accessors(chain = true)
+@TableName("${table.name}")
+@Schema(description = "${table.comment!}")
+public class ${entity} implements Serializable {
+
+<#-- 主键字段 -->
+<#assign hasPk = false>
+<#list table.fields as field>
+ <#if field.keyFlag>
+ <#assign hasPk = true>
+ @TableId(value = "${field.name}", type = IdType.${idType!"ASSIGN_ID"})
+ @Schema(description = "${field.comment!}")
+ <#if field.propertyType == "LocalDate">
+ JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+ private Date ${field.propertyName};
+ <#elseif field.propertyType == "LocalDateTime">
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+ private Date ${field.propertyName};
+ <#else>
+ private ${field.propertyType} ${field.propertyName};
+ #if>
+
+ #if>
+#list>
+
+<#-- 普通字段 -->
+<#list table.fields as field>
+ <#if !field.keyFlag>
+ <#if field.propertyType == "Point">
+ @TableField(value = "${field.name}", typeHandler = PointTypeHandler.class)
+ <#else>
+ @TableField("${field.name}")
+ #if>
+ @Schema(description = "${field.comment!}")
+ <#if field.propertyType == "LocalDate">
+ @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+ private Date ${field.propertyName};
+ <#elseif field.propertyType == "LocalDateTime">
+ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+ private Date ${field.propertyName};
+ <#else>
+ private ${field.propertyType} ${field.propertyName};
+ #if>
+
+ #if>
+#list>
+
+<#-- 无主键表的额外处理 -->
+<#if !hasPk>
+<#-- 在这里可以添加无主键表特有的方法或注释 -->
+<#-- 例如,可能需要提供手动主键生成策略或者修改操作方法 -->
+#if>
+}