From c2df93faeb6915dde98578cb9a39ccdd3f5fde3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BF=A0=E6=9E=97?= <170083662@qq.com> Date: Thu, 16 Oct 2025 20:34:41 +0800 Subject: [PATCH] =?UTF-8?q?feat(generator):=E4=B8=BA=E4=B8=8D=E5=90=8C?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E7=B1=BB=E5=9E=8B=E5=AD=97=E6=AE=B5=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E7=89=B9=E5=AE=9A=E6=97=A5=E6=9C=9F=E6=A0=BC=E5=BC=8F?= =?UTF-8?q?=E5=8C=96=E6=B3=A8=E8=A7=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 为 LocalDateTime 类型字段添加 "yyyy-MM-dd HH:mm:ss" 格式 -为 LocalDate 类型字段添加 "yyyy-MM-dd" 格式- 为 LocalTime 类型字段添加 "HH:mm:ss" 格式 - 为 Date 类型字段保留原有 "yyyy-MM-dd HH:mm:ss" 格式- 优化时间字段格式化逻辑,提高代码可读性 --- .../com/gxwebsoft/generator/templates/entity.java.btl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/gxwebsoft/generator/templates/entity.java.btl b/src/test/java/com/gxwebsoft/generator/templates/entity.java.btl index 0838977..42b8c2a 100644 --- a/src/test/java/com/gxwebsoft/generator/templates/entity.java.btl +++ b/src/test/java/com/gxwebsoft/generator/templates/entity.java.btl @@ -69,7 +69,13 @@ public class ${entity} implements Serializable { <% } %> <% /* 为时间类型字段添加日期格式化注解 */ %> - <% if(field.propertyType == 'LocalDateTime' || field.propertyType == 'LocalDate' || field.propertyType == 'LocalTime' || field.propertyType == 'Date') { %> + <% if(field.propertyType == 'LocalDateTime') { %> + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + <% } else if(field.propertyType == 'LocalDate') { %> + @JsonFormat(pattern = "yyyy-MM-dd") + <% } else if(field.propertyType == 'LocalTime') { %> + @JsonFormat(pattern = "HH:mm:ss") + <% } else if(field.propertyType == 'Date') { %> @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") <% } %>